Re: Using metaclasses to inherit class variables

2006-05-20 Thread [EMAIL PROTECTED]
Hmm. setattr() only does a shallow search. Good to know.

Your

if not name in dict: setattr(cls, name, value)

is a more succinct/better way of writing

if not cls.__dict__.has_key(var): setattr(cls, var, val)

Which i tested a fair bit.

OK it appears that both are working for the simple types. However, if I
do:

>>> class SetClassVars(type):
... cvars = dict(lst=[], desc=None)
... def __init__(cls, name, bases, classdict):
... for name, value in SetClassVars.cvars.iteritems():
...  if not name in classdict: setattr(cls, name, value)

>>> class C(object):
...  __metaclass__ = SetClassVars
...  desc = 'foo'
...
>>> class D(C):
... desc = bar

>>> C.lst.append('c')
>>> D.lst.append('')
>>> C.lst
['c', '']
>>> D.lst
['c', '']

I get the piling on behavior.

OK. So it seems to be a problem only with the mutable list. I made the
mistake of thinking that the list behavior was the same as for
non-mutables.

This must be a newbie mistake and it is probably documented somewhere.
*Ding* I'll bet it is the same one that bites newbies when they define
functions like:

def myfunc(lst=[]):

Looking for complicated problems with metaclasses when simple mistakes
about mutables are the issue. Occam wags his finger at me.

Thank you. That helped.
t4

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


Re: hidden file detection

2006-05-20 Thread Fabian Steiner
Lenny G. wrote:
> What's the best way to do cross-platform hidden file detection?  I want
> to do something like weed-out the files that should be 'hidden' from
> os.listdir() (which would be files that start with '.' under Unix,
> files that have the hidden attribute set on windows, and whatever it is
> that makes Mac files hidden).  Is there a util or lib that does this
> for me?
> 
> Thanks,
> Gary
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


mysql

2006-05-20 Thread yogesh shrikhande
hello   sir i want to aceess database at any location i know my.ini config. setting but my problem is suppose my i have two database ie. abc & xyz  abc database is stored at path c:\apache\mysql\data  this path is also in my.ini . & xyz database at path c:\mydocument i want to access both database at a time  i use vb front end & mysql backend i want both database in connetion string   plz ans me as early as possible     thanks  yogesh  [EMAIL PROTECTED]
	

	
		 
Do you have a question on a topic you cant find an Answer to. Try Yahoo! Answers India 
Get the all new Yahoo! Messenger Beta Now-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Using python for a CAD program

2006-05-20 Thread David Cuthbert
Terry Hancock wrote:
> I disagree that transactions are bad for CAD -- they may have
> a different semantic role and the needed granularity may be
> different, but the need to roll data back to an earlier revision
> is just as present in drawings as it is for code or financial
> transactions.

Sure, but that's called source control.  So you do need transactions, 
but for the entire database state, not on database operations.  (This 
was certainly true at Cadence -- there was a thriving third-party market 
for handling source control on CDBA databases, and I never encountered 
any code which operated on the database in a transactional manner. 
OpenAccess did have some basic support for transactions, but I never 
heard of anyone using them.)

Some kind of transactionality is needed for undo/redo, but this is 
usually done in a different (some might say "more efficient", others 
might say "hackier") method than how transactions are implemented for 
RDBMS (that I've dealt with, anyway).  I suspect this can be attributed 
to two major factors: concurrent access is never an issue in such 
systems, and the number of database objects representing a given state 
is far larger than in, say, e-commerce.

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


Re: altering an object as you iterate over it?

2006-05-20 Thread netvaibhav
bruno at modulix wrote:
> fin = open(path, 'r')
> fout = open(temp, 'w')
> for line in fin:
>   if line.strip():
> fout.write(line)
> fin.close()
> fout.close()
>
> then delete path and rename temp, and you're done. And yes, this is
> actually the canonical way to do this !-)

What if there's a hard link to path?


-- 
Vaibhav

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


Help Needed plz :)

2006-05-20 Thread Yasmeen Alkadi
Hello . .    I am trying to control an NIDS (network intustion detection system) that uses Snort via mobile phones, but I need urgent help please in the following topics below:   1. How to send a text file from a PC running windows to a nokia mobile phone series 60, for example nokia 6680 via bluetoooth   2. How python that is installed on the mobile phone reads the accepted bluetooth message that was recived just a while ago in number 1.    Thank you so much for your help, I really appricate it :)
		Be a chatter box. Enjoy free PC-to-PC calls  with Yahoo! Messenger with Voice.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Creating a new file object; open() vs file()

2006-05-20 Thread Fredrik Lundh
Ben Finney wrote:


>> I see what you mean, but I think that's why I like using open,
>> because I like having my functions be verbs instead of nouns.
> 
> Note though that you're calling a class (in this case, type)
> constructor, to return a new object.

no, he's calling a factory function to get an object that provides the 
expected behaviour.

in future versions of Python, open() may not always create an instance 
of the file type.



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


Re: PEP 3102 for review and comment

2006-05-20 Thread Carl Banks

Talin wrote:
> Specification
>
> Syntactically, the proposed changes are fairly simple.  The first
> change is to allow regular arguments to appear after a varargs
> argument:
>
> def sortwords(*wordlist, case_sensitive=False):
>...
>
> This function accepts any number of positional arguments, and it
> also accepts a keyword option called 'case_sensitive'.  This
> option will never be filled in by a positional argument, but
> must be explicitly specified by name.

Ick.  Pretty big change hinging on subtle juxtaposition in the argument
list.  I don't like it, it doesn't stand out enough... but it makes
logical sense and any other solution would have to be way more
contrived.  I think argument lists are already confusing enough with
just mixing *, **, and default arguments.

Two thoughts:

Would these arguments go before of after **kwargs?

This is apparently for Python 3.0. (I'd make the implementation
schedule explicit, even if the PEP number implies it's Python 3.0.)  It
looks like Python 3.0 might declare function arguments like Ada.  If
so, what about a little modifier (like Ada's "in and out") instead?
Problem with that is then positional arguments line up wrong.  Ick.

def func(a : int = 1): pass
def func(a : kwonly int = 1): pass


Carl Banks

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


Re: combining a C# GUI with Python code?

2006-05-20 Thread Rony Steelandt
Isn't it a bit overkill to implement the whole .net framework 'Just' 
for a GUI ??

If you want to build quickly nice GUI's for your python program, have a 
look at wxpython & wxdesigner

Rony


> Is it possible to construct a C# form (using Visual Studio) but write only 
> Python code for the events? Is there some way to tell your program to run 
> Python whenever code is run, since it will be all Python code (e.g. for 
> button presses, etc.)?
>
> I know it's sort of silly, and it makes your program depend on .NET, but it 
> would be a nice and easy way to create a GUI while still writing in Python, 
> if it's possible.


-- 
---
Rony Steelandt
BuCodi
rony dot steelandt (at) bucodi dot com

Visit the python blog at http://360.yahoo.com/bucodi


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


Generating Cutter numbers

2006-05-20 Thread Gerard Flanagan
All

would anyone happen to have code to generate Cutter Numbers:

  eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm

or is anyone looking for something to do?-)  (I'm under pressure!)

def cutter(lname, fname, book_title):

(maybe more to it than that).


cheers

Gerard

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


Re: combining a C# GUI with Python code?

2006-05-20 Thread Gerard Flanagan

John Salerno wrote:
> Is it possible to construct a C# form (using Visual Studio) but write
> only Python code for the events? Is there some way to tell your program
> to run Python whenever code is run, since it will be all Python code
> (e.g. for button presses, etc.)?
>
> I know it's sort of silly, and it makes your program depend on .NET, but
> it would be a nice and easy way to create a GUI while still writing in
> Python, if it's possible.

code here any use:

http://gflanagan.net/site/dotnet/05/RunPythonScriptFromWord.html

?

Gerard

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


Re: Exception style (was: calling python functions using variables)

2006-05-20 Thread Carl Banks
Fredrik Lundh wrote:
> Cameron Laird wrote:
>
> > Guys, I try--I try *hard*--to accept the BetterToAskForgiveness
> > gospel, but this situation illustrates the discomfort I consistently
> > feel:  how do I know that the NameError means VARIABLE didn't resolve,
> > rather than that it did, but that evaluation of commands.VARIABLE()
> > itself didn't throw a NameError?  My usual answer:  umm, unless I go
> > to efforts to prevent it, I *don't* know that didn't happen.
>
> two notes:
>
> 1) getattr() raises an AttributeError if the attribute doesn't exist, not a 
> NameError.
>
> 2) as you point out, doing too much inside a single try/except often results 
> in hard-
> to-find errors and confusing error messages.  the try-except-else pattern 
> comes in
> handy in cases like this:
>
> try:
> f = getattr(commands, name)
> except AttributeError:
> print "command", name, "not known"
> else:
> f()

What if commands were an instance of this class:

class CommandClass:

def __getattr__(self,attr):
try:
return self.dircontenst[attr]
except KeyError:
raise AttributeError

The call to getattr manages to raise AttributeError even though the
command is known. Yes, self.dircontents[attr] does exist and is valid
in this example, but it still raises AttributeError because dircontents
is spelled wrong.

I make this silly example to point out that Python's dynamicism is a
possible pitfall with ETAFTP even if you're careful.  It's something
worth keeping in mind.

Another example, much more realistic: GvR says don't use callable(),
just try calling it and catch CallableError (or whatever it is).  Of
course, that error can be raised inside the function; and in this case,
there's no way to isolate only the part you you're checking for an
exception.


Carl Banks

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


Re: Exception style (was: calling python functions using variables)

2006-05-20 Thread Carl Banks
Dennis Lee Bieber wrote:
> On Fri, 19 May 2006 14:41:13 +, [EMAIL PROTECTED] (Cameron Laird)
> declaimed the following in comp.lang.python:  .
> > Guys, I try--I try *hard*--to accept the BetterToAskForgiveness
> > gospel, but this situation illustrates the discomfort I consistently
> > feel:  how do I know that the NameError means VARIABLE didn't resolve,
> > rather than that it did, but that evaluation of commands.VARIABLE()
>
>   I'd suggest that each of your "valid" commands should contain
> whatever error checking is appropriate to it -- and if needed, raise
> some custom "command failure" exception after handling the real failure
> internally.

That probably doesn't help when the exception is due to a bug and not
bad input.  If you have an AttributeError due to a bug, it would be
wrong to raise a custom command failure exception.

Carl Banks

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


Re: noob import question

2006-05-20 Thread Carl Banks
PA wrote:
> On May 19, 2006, at 15:33, Diez B. Roggisch wrote:
>
> > And it seems as if you have some JAVA-background, putting one class in
> > one
> > file called the same as the class. Don't do that, it's a stupid
> > restriction
> > in JAVA and should be avoided in PYTHON.
>
> Restrictive or not, what's so fundamentally devious in putting a class
> declaration in a separate file whose name is that of the declared class
> (class Queue -> Queue.py)?
>
> Sounds like a handy way of organizing your code, no?

Handy for a lazy programmer, maybe.  Confusing for the reader, though
(do you mean Queue module, or Queue class? I must scroll up...).  And
highly tacky.  I recommend avoiding it.  For modules, I recommend "act
of" words (words ending in -ing and -ion) because such words aren't
common identitiers.  So queuing instead of Queue.

Unfortunately, the Python library isn't setting a good example here.
Too much glob.glob, time.time, socket.socket, and Queue.Queue.  I hope
all these go away in Python 3000.


Carl Banks

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


Re: open file with whitespaces

2006-05-20 Thread Claudio Grondi
mardif wrote:
> OK OK GUYS
> I've found the solution: ( effectly, a friend of mine has found the
> solution )
> 
> import os
> 
> os.spawnl(os.P_WAIT, "c:\programmi\internet
> explorer\iexplore.exe",'"C:\Documents and
> Settings\michele\Desktop\ciccio.html"','"C:\Documents and
> Settings\michele\Desktop\ciccio.html"')
> 
> The secret are the ' simbols around arguments:
> 
> ' "C:\Documents and Settings\michele\Desktop\ciccio.html" '
> 
> Without these, don't work!
> 
> Very STRONG!
> 
> bye and thx
> 
Wasn't that what I have suggested?

By the way:
it is much better to use double backslashes here, as in case of other 
file/directory names (e.g. folder\name.txt folder\remote.htm i.e. for 
all the cases a backslash is followed by a letter making out of this 
twin one special character) this above won't work.
But best is to use in full path file names forward slashes as Python 
handles them properly not only on *nix and Linux, but also on Windows:
'"C:/Documents and Settings/michele/Desktop/ciccio.html"'

The "secret" symbols around arguments are single quotation marks making 
the double quotation marks part of the string passed to the .spawnl() 
function. Check out in IDLE, that:
 >>> "x"
'x'
 >>> '"x"'
'"x"'
Command shell command arguments need to be enclosed in quotation marks 
in case spaces can occur in them (as it can happen in file names) as 
otherwise the spaces will be interpreted as separator characters between 
the arguments and as consequence of this the command shell command fails 
due to bad or wrong number of parameter.

You see, no "secrets" here ... only some simple rules and a bit more 
understanding of what is going on behind the scenes.

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


Re: Decimal and Exponentiation

2006-05-20 Thread Raymond L. Buvel
elventear wrote:
> Hi,
> 
> I am the in the need to do some numerical calculations that involve
> real numbers that are larger than what the native float can handle.
> 
> I've tried to use Decimal, but I've found one main obstacle that I
> don't know how to sort. I need to do exponentiation with real
> exponents, but it seems that Decimal does not support non integer
> exponents.
> 
> I would appreciate if anyone could recommend a solution for this
> problem.
> 
> Thank you.
> 
The clnum module has arbitrary precision floating point and complex
numbers with all of the standard math functions.  For example, the cube
root of 2 can be computed to 40 decimal places with the following.

>>> from clnum import mpf,mpq
>>> mpf(2,40)**mpq(1,3)
mpf('1.259921049894873164767210607278228350570251464701',46)

For more information see

http://calcrpnpy.sourceforge.net/clnumManual.html

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


Re: Decimal and Exponentiation

2006-05-20 Thread Raymond L. Buvel
Tim Peters wrote:


> The GNU GMP library (for which Python bindings are available) also
> supports "big floats", but their power operation is also restricted to
> integer powers and/or exact roots.  This can be painful even to try;
> e.g.,
> 
>>>> from gmpy import mpf
>>>> mpf("1e1") ** mpf("3.01")
> 
> consumed well over a minute of CPU time (on a 3.4 GHz box) before dying
> with
> 
>ValueError: mpq.pow fractional exponent, inexact-root
> 


The clnum module handles this calculation very quickly:

>>> from clnum import mpf
>>> mpf("1e1") ** mpf("3.01")
mpf('9.99932861e30099',26)
>>> x=_
>>> x ** (1/mpf("3.01"))
mpf('9.99953924e',26)

See http://calcrpnpy.sourceforge.net/clnumManual.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple DAV server?

2006-05-20 Thread robert
Kyler Laird wrote:
> Ivan Voras <[EMAIL PROTECTED]> writes:
> 
> 
>>Most of the problems are probably because I didn't mean it to be a 
>>fully-compliant WebDAV server, but to serve my need at the time :)
> 
> 
> I am *so* close to having a WebDAV solution.  Unfortunately when I finally
> moved to using HTTPS, it all broke in MS Windows.  (Konqueror handles it
> beautifully.) 
> 
> If I make a Web Folder with HTTP, Windows displays it (as "\\hostname\")
> in Windows Explorer.  If I make it with HTTPS, it throws me into Internet
> Explorer (where WebDAV isn't used - I can't even launch files).
> 
> WTF?!  It looks like other people are using WebDAV over HTTPS.
>   http://www.mydocsonline.com/info_webfolders.html
> Why is Windows kicking me into IE for HTTPS???
> 
> (I'm tired and frustrated.  I hate being forced to deal with proprietary
> software.)
> 

The Windows Web Folder mapping service is also "proprietary" : MS
It can't handle HTTPS in XP so far.

That HTTPS example on this page is from a Mac.

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


The ONE TRUE WAY to use tabs (Re: Tabs versus Spaces in Source Code)

2006-05-20 Thread Andy Sy
achates wrote:

> Yeah - we've got to the repeating ourselves stage.

Actually a couple of the responses on this newsgroup
have settled the question for me.  I did learn something
new by engaging in this holy war.


Tabs need not be evil, but ONLY if they are used in one
particular way:

If you really must use tabs, use them *ONLY* for 'semantic'
indentation and use pure spaces when you need arbitrary
indentation (e.g. arbitrary spacing).

PHP Example
===

function xyz() {
->print  "This is a really really really long line that I'd ".
->   "like to extend to the one down below while preserving ".
->   "ease of readability by aligning the start of the string".
->   "lines.  I use tabs to reflect syntactical (e.g. semantic) ".
->   "indentation, but use spaces for arbitrary indentation.\n\n".;
->while (10) {
->->print "This code will align properly no matter what tabsize setting ".
->->  "the reader uses, and is the only real benefit of using tab ".
->->  "characters instead of pure spaces.\n\n";
}



I did some basic tests, and it looks like this style should also
work for Python code.


THIS IS THE *SINGLE* CORRECT WAY TO USE TABS IN CODE!  ANYTHING
ELSE WILL BE A PAIN FOR PEOPLE WITH TABSIZE SETTINGS DIFFERENT
FROM YOURS!!


> But that's the problem with this issue: it's really hard to get the
> space-indenters to actually think about it and to address what is being
> said. Every time it comes up, there's always a few people trying to
> explain why tabs give are a good idea, facing a whole raft of others
> spouting stuff like:

Most of the tab-indenters have the same attitude.  But I did get ALL
of my points against tabs addressed this time.  And thank you to those
people including you for the 'less -x' tip.



> But unfortunately the situation is worse than that: tab indentation
> needs to be actively defended.

A world where everyone uses pure spaces would be far far far better
than the current situation where tab users can't even decide what
the universal tabsize should be and whose code alignment breaks
on different tabsize settings.

However, a world where EVERYONE who uses tabs strictly practice the
ONE TRUE TAB WAY would be a *slightly* better place than one where
everyone used pure spaces.

And remember, the ONE TRUE TAB WAY does not come for free and involves
a certain amount of tedium and attention.  It will be impractical on
most simple text editors.  For most people, I frankly don't think the
minor benefits are worth it.



> Unlikely perhaps. I hope so. It's a cruel irony that Python's creator
> didn't appreciate the benefits that tab indentation would bring to his
> own language - the only major language in which indentation levels
> actually have semantic significance.

You might want to run those benefit/s/ by me again, because the SINGLE
benefit I can still see to using tabs is so that people who have
different indentation width preferences can view code according to
the way they want.  And remember, this benefit will ONLY occur
IF people stick to using the ONE TRUE TAB WAY outlined above.

Any other method of tabbing would just be worse than a pure-spaces
world.




--
It's called DOM+XHR and it's *NOT* a detergent!

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


misleading prefix ++

2006-05-20 Thread LuciferLeo
given i = 0,
I know i = i + 1 and i += 1 are all correct
but when I type:
>>> i++
the interpreter replies:
  File "", line 1
i++
  ^
SyntaxError: invalid syntax

so I get the idea that suffix ++ is invalid in python
but when I input:
>>> ++i
and the interpreter replies
0

Don't you think it is misleading when you expect a variable to
increment?

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


Re: misleading prefix ++

2006-05-20 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> given i = 0,
> I know i = i + 1 and i += 1 are all correct
> but when I type:
> 
i++
> 
> the interpreter replies:
>   File "", line 1
> i++
>   ^
> SyntaxError: invalid syntax
> 
> so I get the idea that suffix ++ is invalid in python
> but when I input:
> 
++i
> 
> and the interpreter replies
> 0
> 
> Don't you think it is misleading when you expect a variable to
> increment?
> 
Terribly. So stop expecting it to increment :)

Seriously, --i is also valid Python. Both expressions apply two unary 
operators to a name. Would you have these become illegal, or start to 
mean increment/decrement? Either change would break years of backwards 
compatibility.

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

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


Re: misleading prefix ++

2006-05-20 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> Don't you think it is misleading when you expect a variable to
> increment?

no.  and in my experience, most people know that they cannot just type 
random stuff into a computer and expect it to do what they want.

(have you figured out *why* this is valid syntax, and what it does to 
your integer?)



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


Re: misleading prefix ++

2006-05-20 Thread Tim Chase
>++i
>>
>>and the interpreter replies
>>0
>>
>>Don't you think it is misleading when you expect a variable to
>>increment?
>>
> 
> Terribly. So stop expecting it to increment :)
> 
> Seriously, --i is also valid Python. Both expressions apply two unary 
> operators to a name. Would you have these become illegal, or start to 
> mean increment/decrement? Either change would break years of backwards 
> compatibility.

It looks like Python behaves more consistantly than C/C++/Java :) 
By adding plus/minus signs, you get consistant behavior:

 >>> x = 42
 >>> +x
42
 >>> ++x
42
 >>> +++x
42
 >>> x
42
 >>> # ad infinitum

In C-like languages, you get

x: 42
+x: 42
++x: 43
+++x: invalid lvalue in increment -> compile fails
x: 45
+x: invalid lvalue in increment -> compile fails
++x: 48

(actually, g++ accepted this funky syntax, but gcc choked on it, 
so linguistic sludge is more tolerable in C++ than in C)

Looks like the OP should be over on c.l.c++ griping about the 
inconsistancy of the "unary +" and "unary -" operators ;)

-tkc
(still waiting for my brain to kick in on a Sat. morning...)




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


Re: misleading prefix ++

2006-05-20 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> but when I input:
 ++i
> and the interpreter replies
> 0
> 
> Don't you think it is misleading when you expect a variable to
> increment?

You have been warned...

$ cat pp.py
i = 42
++i
print i
--i
$ pychecker pp.py
Processing pp...
42

Warnings...

pp.py:2: Operator (++) doesn't exist, statement has no effect
pp.py:4: Operator (--) doesn't exist, statement has no effect

...or you would have been, had you used the pychecker :-)

Now I'm not recommending

>>> class Int(object):
... def __init__(self, value=0):
... self.value = 0
... self.half = False
... def __pos__(self):
... if self.half:
... self.value += 1
... self.half = not self.half
... return self
... def __str__(self):
... return str(self.value)
... __repr__ = __str__
...
>>> i = Int()
>>> i
0
>>> ++i
1
>>> ++i
2
>>> i
2

which is slightly harder to fix than to break but gives some (weak)
motivation not to rule out multiple prefixed signs.

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


Re: Generating Cutter numbers

2006-05-20 Thread skryskalla
Gerard Flanagan wrote:
> All
>
> would anyone happen to have code to generate Cutter Numbers:
>
>   eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm
>
> or is anyone looking for something to do?-)  (I'm under pressure!)
>
> def cutter(lname, fname, book_title):
>

What do you use lname and fname (author first name and last name?) for?
 The page you linked to does not have any information (that I could
see) about first names or last names.

I wrote a script to see if I could capture what the table is doing on
the page you linked to.  It gets the Cutter number right about 50% of
the time, otherwise its off by a few digits.

I am stumped about what to do when the first letter is Q not followed
by U.  It says to use numbers 2-29 for the second letters a-t, but that
is obviously not right (for one thing t would be 21, not 29).

Since you seem a little bit more experienced in library science could
you explain what is going on? :)

you can find the script here:
http://lost-theory.org/python/cutter.txt

 Titlemine  realmatch?
---
IBM  I26I26 True
IdahoI33I33 True
Ilardo   I43I4  False
Import   I47I48 False
InmanI56I56 True
Ipswich  I67I67 True
Ito  I86I87 False
Ivy  I99I94 False
Sadron   S23S23 True
Scanlon  S33S29 False
SchreiberS37S37 True
Shillingburg S55S53 False
Singer   S56S57 False
Stinson  S75S75 True
Suryani  S87S87 True
SymposiumS96S96 True
Qadduri  Q23Q23 True
Qiao Q103   Q27 False
QuadeQ33Q33 True
Queiroz  Q45Q45 True
QuinnQ56Q56 True
Quorum   Q67Q67 True
QutubQ88Q88 True
Qvortrup Q236   Q97 False
Campbell C46C36 False
Ceccaldi C53C43 False
Chertok  C64C48 False
ClarkC73C58 False
Cobblestone  C43C63 False
CryerC79C79 True
Cuellar  C74C84 False
Cymbal   C36C96 False


Steve

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


Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)

2006-05-20 Thread Christophe Cavalaria
Christopher Weimann wrote:

> On 05/19/2006-07:18AM, Duncan Booth wrote:
>> 
>> My experience of programming with either spaces or tabs has taught me
>> that tabs are evil not for themselves, but simply because no matter how
>> hard you try they always end up being mixed with spaces.
>> 
> 
> Swap the word 'tabs' for the word 'spaces' and you get...
> 
>   My experience of programming with either tabs or spaces has taught me
>   that spaces are evil not for themselves, but simply because no matter
>   how hard you try they always end up being mixed with tabs.
> 
> Which is just as vaild as the un-swapped paragraph. Both versions
> express a bias. The first is biased in favor of spaces. The second is
> biased in favor of tabs. Neither have any useful content. Mixing is bad
> but that fact doesn't favor spaces OR tabs.

The difference is that you cannot code without spaces but you can do it
without tabs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generating Cutter numbers

2006-05-20 Thread Tim Chase
> I am stumped about what to do when the first letter is Q not 
> followed by U.  It says to use numbers 2-29 for the second 
> letters a-t, but that is obviously not right (for one thing t 
> would be 21, not 29).
> 
> Since you seem a little bit more experienced in library 
> science could you explain what is going on? :)

I too tried to play with it, and Steve found one of the cases
with which I was having trouble ("Q[^u]").  Additionally, is "Y"
considered a consonant or vowel for the sake of this exercise?
Other trouble came when consonants were not followed by the list
of letters given.  It also looks like the definiton of "initial
letter" seems to change a bit.  In some cases, "initial letter"
seems to refer to the first letter (which gets output
carte-blanche), and in other cases, it seems to be used to refer
to "the first letter that should be converted to a number"
(meaning the second letter of the input).

Some examples for which expected results (and the
reasoning/logic/algorithm/table behind how they were generated)
would be helpful:
"Cyr", "Cyprus", "Mbarine", "McGrady", "Sczepanski", "Yvette"

They're all are sample last-names pulled from my local phonebook.

Too bad my librarian wife is working today :)

-tkc







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


Re: Generating Cutter numbers

2006-05-20 Thread Rick Zantow
[EMAIL PROTECTED] wrote in news:1148133784.844430.23130@
38g2000cwa.googlegroups.com:

> Gerard Flanagan wrote:
>> All
>>
>> would anyone happen to have code to generate Cutter Numbers:
>>
>>   eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm
>>
[...]
> 
> I wrote a script to see if I could capture what the table is doing on
> the page you linked to.  It gets the Cutter number right about 50% of
> the time, otherwise its off by a few digits.
> 
> I am stumped about what to do when the first letter is Q not followed
> by U.  It says to use numbers 2-29 for the second letters a-t, but 
that
> is obviously not right (for one thing t would be 21, not 29).
> 
> Since you seem a little bit more experienced in library science could
> you explain what is going on? :)
> 
> you can find the script here:
> http://lost-theory.org/python/cutter.txt
> 

I found another page 
 that 
expresses the letter codes more fully than the one the OP posted. But 
nothing I've seen so far accounts for an example like " Chertok (.C48)". 

This page  shows essentially 
the same information the OP posted, including the Chertok example, which 
is linked to another page that says this (and only this): "These Cutters 
reflect the adjustments made to allow for a range of letters on the 
table, e.g., l-m, or for letters not explicitly stated, e.g., h after an 
initial consonant." Given that some unnamed adjustment is made, it's not 
clear how one would go about programming it. I mean, Python's good, but 
it only has a serpent brain.

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


Re: Decimal and Exponentiation

2006-05-20 Thread Tim Peters
[Raymond L. Buvel, on
http://calcrpnpy.sourceforge.net/clnumManual.html
]
> The clnum module handles this calculation very quickly:
>
> >>> from clnum import mpf
> >>> mpf("1e1") ** mpf("3.01")
> mpf('9.99932861e30099',26)

That's probably good enough for the OP's needs -- thanks!

OTOH, it's not good enough for the decimal module:

(10**1)**3.01 =
10**(1*3.01) =
10**30100

exactly, and the proposed IBM standard for decimal arithmetic requires
error < 1 ULP (which implies that if the mathematical ("infinite
precision") result is exactly representable, then that's the result
you have to get).  It would take some analysis to figure out how much
of clnum's error is due to using binary floats instead of decimal, and
how much due to its pow implementation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: combining a C# GUI with Python code?

2006-05-20 Thread John Salerno
Rony Steelandt wrote:
> Isn't it a bit overkill to implement the whole .net framework 'Just' 
> for a GUI ??
> 
> If you want to build quickly nice GUI's for your python program, have a 
> look at wxpython & wxdesigner

wxdesigner looked good until I had to pay. :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decimal and Exponentiation

2006-05-20 Thread Raymond L. Buvel
Tim Peters wrote:
> [Raymond L. Buvel, on
>http://calcrpnpy.sourceforge.net/clnumManual.html
> ]
> 
>> The clnum module handles this calculation very quickly:
>>
>> >>> from clnum import mpf
>> >>> mpf("1e1") ** mpf("3.01")
>> mpf('9.99932861e30099',26)
> 
> 
> That's probably good enough for the OP's needs -- thanks!
> 
> OTOH, it's not good enough for the decimal module:
> 
>(10**1)**3.01 =
>10**(1*3.01) =
>10**30100
> 
> exactly, and the proposed IBM standard for decimal arithmetic requires
> error < 1 ULP (which implies that if the mathematical ("infinite
> precision") result is exactly representable, then that's the result
> you have to get).  It would take some analysis to figure out how much
> of clnum's error is due to using binary floats instead of decimal, and
> how much due to its pow implementation.

Indeed, it is not clear where the error is comming from especially since
you can increase the precision of the intermediate calculation and get
the exact result.

>>> mpf(mpf("1e1",30) ** mpf("3.01",30), 20)
mpf('1.0e30100',26)

Is this the kind of thing you will need to do in the Decimal module to
meet the specification?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: combining a C# GUI with Python code?

2006-05-20 Thread BartlebyScrivener
John,

I know you started out asking about .NET, but peruse this thread,
wherein some old hands recommend staying with what you know, if what
you know is VBA guis.

http://tinyurl.com/ehujm

rick

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


Re: DO NOT USE file()

2006-05-20 Thread Aahz
In article <[EMAIL PROTECTED]>,
Ben Finney  <[EMAIL PROTECTED]> wrote:
>"Tim Peters" <[EMAIL PROTECTED]> writes:
>> [John Salerno, on the difference between `open` and `file`]
>>>
>>> Interesting. What is the difference between them now?
>> 
>> In 2.5 `file` is unchanged but `open` becomes a function:
>> 
> file
>> 
> open
>> 
>
>In that case I'll happily use 'file()', since it meshes nicely with
>creating a new instance of any built-in type.

Nobody will prevent you from going against the standard decreed by Guido.
But you also probably won't be able to contribute any code to the
standard library, and other people mucking with your code who do care
about Guido's decrees will probably change it.

Unlike all the other built-in types, files are special because they are
proxies for non-Python external objects.  For that reason, there has long
been interest in extending open() to work with file-like objects (such as
URLs).  Splitting open() and file() is a necessary precondition to making
that happen, and it's also possible that Python 3.0 may have separate
textfile and binary file objects.  Finally, file() doesn't exist in
Python 2.1 and earlier, and using file() instead of open() is gratuitous
breakage.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"I saw `cout' being shifted "Hello world" times to the left and stopped
right there."  --Steve Gonedes
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generating Cutter numbers

2006-05-20 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote:
> Gerard Flanagan wrote:
> > All
> >
> > would anyone happen to have code to generate Cutter Numbers:
> >
> >   eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm
> >
> > or is anyone looking for something to do?-)  (I'm under pressure!)
> >
> > def cutter(lname, fname, book_title):
> >
>
> What do you use lname and fname (author first name and last name?) for?
>  The page you linked to does not have any information (that I could
> see) about first names or last names.
>

Sorry, couldn't find a better link, I'm struggling to find anything
definitive about this.

I'm cataloging a small library and want to generate a unique id (called
a 'call number') for each book.  This id is composed of:

 * Dewey 3-digit Subject Classification Number
 * Dewey Decimal  (always 0 for the minute)
 * Cutter Number
 * Copy number  (multiple copies or volumes)

(That Celestial Emporium again...)

I haven't researched it much but it seems the Cutter number is used to
distinguish between authors with the same name, and between different
books written by the same author - so you need last name, first name
and title.  But it may be as much art as science.

> I wrote a script to see if I could capture what the table is doing on
> the page you linked to.  It gets the Cutter number right about 50% of
> the time, otherwise its off by a few digits.
>
> I am stumped about what to do when the first letter is Q not followed
> by U.  It says to use numbers 2-29 for the second letters a-t, but that
> is obviously not right (for one thing t would be 21, not 29).
>
> Since you seem a little bit more experienced in library science could
> you explain what is going on? :)
>
> you can find the script here:
> http://lost-theory.org/python/cutter.txt
>

Thanks very much for taking the time - I'll have to go study it now!
But I don't think it will be as simple now since the Cutter may depend
on books already in the database.  Maybe I'll just stick a random
string on the end of what your function produces!

Thanks again.

Gerard

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


Find Your Soul Mate

2006-05-20 Thread Knowledge


  Find Your Soul Mate !
Cheat Your Wife/Husband!
Try New Things!
  Or Just Met Friends!



http://affiliatecash.designerlove.com/idevaffiliate.php?id=3537




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


Re: Generating Cutter numbers

2006-05-20 Thread Terry Reedy

"Gerard Flanagan" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I'm cataloging a small library and want to generate a unique id (called
> a 'call number') for each book.  This id is composed of:
>
> * Dewey 3-digit Subject Classification Number
> * Dewey Decimal  (always 0 for the minute)
> * Cutter Number
> * Copy number  (multiple copies or volumes)
>
> (That Celestial Emporium again...)
>
> I haven't researched it much but it seems the Cutter number is used to
> distinguish between authors with the same name, and between different
> books written by the same author - so you need last name, first name
> and title.  But it may be as much art as science.

I seems you are mixing pieces of two cataloging systems.  The link you gave 
was for creating Cutter numbers to represent subtopics of Library of 
Congress classes.  For instance, 'algorithms' is .A43.



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


Re: python vs perl lines of code

2006-05-20 Thread Edward Elliott
A little out-of-order execution seems useful here. ;)

John Bokma wrote:

> Edward Elliott <[EMAIL PROTECTED]> wrote:
>> I can readily believe that the "community" frequenting the newsgroups,
>> mailing lists, and blogs don't encourage it anymore.  But that's a
>> tiny fraction of all perl programmers, and most of them have no
>> exposure to this little clique.
> 
> Pfft, you are just guessing around now.

How many organizations have you worked at?  How much exposure to coders
whose daily job description doesn't include the word programming?  I've
been at Fortune 100 companies with thousands of programmers and support
staff, and at startups with a half dozen employees.  I've been employed at
3 universities from small to huge.  I know full-time software developers,
software testers, sys admins, network admins, managers, web developers,
graphic artists, physics researchers, bioinformatics researchers,
instructors, librarians, consultants, contractors, hardware engineers,
forensic analysts, and even a law professor.  They all code perl to some
degree.  Many of them don't even know what a newsgroup is, and you can have
their cookbook when you pry it from their cold dead hands.  Guessing?
Hardly.  Just not trapped in your insular world of who makes up the perl
"community".
 

>>> Don't forget that most
>>> of the book was written around 1998. Yes, 8 years ago.
>> 
>> Doesn't matter.
> 
> Yes it matters. 8 years is a lot of time in IT. In 1998 Perl5.005 was
> announced (22 July). [1] Which should tell you a lot if you indeed have
> 3 years of Perl skills.

Tell that to everyone who relies on the cookbook.  It gets their job done. 
They don't care if it was written in the dark ages.  Until a replacement
comes along, that's what they'll use.  Of course Perl itself has moved on,
that's not the point.

 
> If they are serious with their study they know that a 8 year old book is
> hardly up to date. I tend to take most IT related books I use that are
> older then 3-4 years with quite a grain of salt. I am not going to take
> an 8 year old Java CookBook very seriously for example.

Many/most people aren't "serious with their study" of perl.  They just want
to get things done.  Perl 5 works for them now, it will work for them 10
years from now.  Unless something significantly better comes along to
justify the cost of switching, they'll stick with what they know.  And that
includes perl 6.  One would hope an updated cookbook is out before then. 
Or maybe it's not needed because the current one works just fine.

Time isn't a great measure of language change.  A C++ book from 8-10 years
ago is just as good as one today in most respects (maybe exceptions and
templates are a bit underused).  A C book from 20 years ago is perfectly
fine for most purposes (how well does K&R stand the test of time?).  C99
and C++0x aren't revolutionary changes (ISO committees frown on such
things).  God only knows how far back useful LISP resources go.

 
>>> You can even find examples on my site that use imported functions
>>> (which I will fix, because I frown upon it :-) ). But I doubt you can
>>> find a majority in the perl community that *encourages* the use of
>>> imported functionality.

I'm not arguing what best practices the hardcore community recommends. 
Many/most perl programmers aren't part of that community, their only
exposure is the perl books (especially the cookbook), and they'll do
whatever it says in there.  Call perl a victim of its own success (a nice
position to be in).


>> For many people, whatever the
>> cookbook says goes.  If it's wrong, update it.
> 
> Well, contact the authors or O'Reilly. 

Sorry, I've got a bad case of "not my problem". ;)

> Seriously, are you using 8 year 
> old Python recipes without thinking?

Sure, if they do the job and an updated reference isn't handy.

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


[OT] - Requesting Comments for "Open Source Rework" Business Concept

2006-05-20 Thread Ilias Lazaridis
You may remember the request for comments at the start of this year:

http://groups.google.com/group/comp.lang.python/msg/b0e3487ef8b13eed
http://groups.google.com/group/comp.lang.ruby/msg/b0e3487ef8b13eed

-

The services of "Lazaridis System Design" have reached pre-release state 
and will be soon released to the public:

http://lazaridis.com/services/index.html

You can find the overall picture of how the services interconnect with 
other company activities here:

http://lazaridis.com/pj/index.html

The target groups for the services are mainly:

  * Open Source Projects
  * Individuals and Vendors (intrested in open source projects)
  * Commercial Vendors (proprietary systems)

I would like to ask for feedback subjecting the business concept 
especialy in the context of Open Source Projects.

You can reply publically or with private email.

-

The initial plan is the following:

The "Initial Analysis" week has a low rate (trial rate). This is to 
allow Vendors & Projects to try the services for a lower investment:

http://lazaridis.com/efficiency/graph/analysis.html

Small Scale Open Source Projects can benefit from very special prices, 
which can reach 1/5th of the current rates (80% off).

If the product category is currently under review, an open source 
project will be charged only a-day-for-a-week:

http://case.lazaridis.com/multi/wiki

Actual Subsystems is for following:

  * persistency systems (python, ruby)
  * complete frameworks, which contain persistency (python, ruby)
  * project hosts and collaboration tools (python, ruby)

As an example, python persistence candidates for the reduced rates would 
be "Axiom", "Django" and "SQLObject":

http://case.lazaridis.com/multi/wiki/Persist

-

Audits of other listed Subsystems will be charged with 2/5th of the 
current rates.

Large Scale Open Source Projects and/or fully commercialized Open Source 
Projects will be charged with 3/5th (actual subsystems) or 4/5th 
(scheduled subsystems).

Commercial Entities and Open Source Projects not within the Subsystem 
listing will be charged with 5/5ths of the rates.

-

Another possibility would be to make the audits freely and to ask for a 
small fee from the end-users which use the results (e.g. paypal link 
within the section).

-

This is a draft version and the facts and interconnections are most 
possibly not demonstrated very clearly.

You feedback will assist to clarify / adjust the concept.

Thank you very much for your time.

.

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


Re: [silly] Does the python mascot have a name ?

2006-05-20 Thread Edward Elliott
John D Salt  wrote:

> Most things don't have names?
> 
> I'll believe you if you can give me a list of ten things that don't have
> names.

Chairs, couches, tables, desks, beds, cars, pens, phones, trees, windows
(can you tell how I came up with this list? ;).  Those are all object types
without names to identify individual instances.  "Ed's chair" and "John's
blue car" aren't names to me, just descriptions.  It's like saying "that
temporary object on line 24 of function foo".

Really, how many things *do* have names?  People, pets, computers, ships,
and a few guns?

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decimal and Exponentiation

2006-05-20 Thread Tim Peters
[Raymond L. Buvel, on
   http://calcrpnpy.sourceforge.net/clnumManual.html
]
>>> The clnum module handles this calculation very quickly:
>>>
>>> >>> from clnum import mpf
>>> >>> mpf("1e1") ** mpf("3.01")
>>> mpf('9.99932861e30099',26)

[Tim Peters]
>> That's probably good enough for the OP's needs -- thanks!
>>
>> OTOH, it's not good enough for the decimal module:
>>
>>(10**1)**3.01 =
>>10**(1*3.01) =
>>10**30100
>>
>> exactly, and the proposed IBM standard for decimal arithmetic requires
>> error < 1 ULP (which implies that if the mathematical ("infinite
>> precision") result is exactly representable, then that's the result
>> you have to get).  It would take some analysis to figure out how much
>> of clnum's error is due to using binary floats instead of decimal, and
>> how much due to its pow implementation.

[Raymond]
> Indeed, it is not clear where the error is comming from especially since
> you can increase the precision of the intermediate calculation and get
> the exact result.
>
> >>> mpf(mpf("1e1",30) ** mpf("3.01",30), 20)
> mpf('1.0e30100',26)
>
> Is this the kind of thing you will need to do in the Decimal module to
> meet the specification?

It will vary by function and the amount of effort people are willing
to put into implementations.  Temporarily (inside a function's
implementation) increasing working precision is probably the easiest
way to get results provably suffering less than 1 ULP error in the
destination precision.  The "provably" part is the hardest part under
any approach ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: combining a C# GUI with Python code?

2006-05-20 Thread Luis M. González
PythonCard is based on wxpython and it's free:
http://pythoncard.sourceforge.net/

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


Re: combining a C# GUI with Python code?

2006-05-20 Thread James
Yes! It is. Just make your GUI in C# and assign event handlers using
Python for .NET
http://www.zope.org/Members/Brian/PythonNet/

Python for .NET is a great tool and has a minimal learning curve.
Unfortunately, it hasn't attracted enough attention from the Python
community. It does not have a .NET 2.0 release yet but it is in the
works.

Or you could use Boo with SharpDevelop. You will get Visual form design
with a very Pythonic language. But you won't get to use Python
libraries.

IronPython is getting IDE integration in the CTP releases for Visual
Studio. Maybe it will support form design in the future. I have not
tried it yet.

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


Re: Simple DAV server?

2006-05-20 Thread fuzzylollipop
webfolders is broken, I have worked on webdav support at the isp level
( for millions of customers to use ) webfolders is NOT something you
should base compliancey on. It is broken so badly that we decided to
just not even test against it. We provide our customers with our own
application with which to map drive letters to mount webdav our webdav
store so we don't have to even worry about Web Folders not working.

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


mod_python, COM, on win2k3 server

2006-05-20 Thread drs
I have an application that runs on mod_python/apache using the publisher 
handler.  It uses an access db as the backend and connects via ADO.  In a 
test environment on XP it runs fine, but when on a win2k3 server it will 
load one page, but all subsequent page loads throw a 
pythoncom.CoInitializeEX error until I restart the apache.

Presumably, this is a threading issue, but I am not sure what the best 
approach to fixing it is.  Should I simply wrap all COM calls with 
pythoncom.CoInitialize/pythoncom.CoUninitialize calls, or is this somethig 
that needs to be done at a lower level.

This is mod_python 3.2, Python 2.3.5, apache2.0.*, win2k3, ado 2.8, and the 
server has 2 processors in case that matters.

Thanks,

-d 


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


Re: Question about Python on Mac

2006-05-20 Thread James Stroud
elventear wrote:
> Hello,
> 
> I am working with Python 2.4.3 built from source courtesy of Fink. So
> far so good, until now. I want to use a module called GMPY
> (http://gmpy.sf.net/). I am able to build correctly the module, but
> once I try to import it I get the following error:
> 
> ImportError: Failure linking new module: gmpy.so: Symbol not found:
> ___gmpn_sub_nc
>  Referenced from: /sw/lib/libgmp.3.dylib
>  Expected in: dynamic lookup
> 
> The weird thing is that just for kicks I tried building with Python
> that comes with MacOSX (py2.3) and it works. It builds and it loads
> fine. Anybody have an idea why this would happen? Any ideas how to
> solve this? In the worse case scenario, can I use the binary (gmpy.so)
> built with against Python 2.3 with Python 2.4.3 (It seems to load
> correctly but I don't know if I should expect any meltdowns later on)
> 
> I would appreciate any suggestions.
> 
> Thanks.
> 
I think fink is not detecting the gmp (GNU multiple precision arithmetic 
library) dependency.

Try:

% fink install gmp

Then try building gmpy with /sw/bin/python.

James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python, COM, on win2k3 server

2006-05-20 Thread drs
Some details, and this is weirder than I thought.

It is working fine with internet explorer or mozilla as the client, but only 
crashes with Firefox.  Moreover, even while firefox is getting errors, IE 
stilll works fine.

The error I get is:

Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "C:\Python23\Lib\site-packages\mod_python\apache.py", line 299, in 
HandlerDispatch
result = object(req)

  File "C:\Python23\Lib\site-packages\mod_python\publisher.py", line 213, in 
handler
published = publish_object(req, object)

  File "C:\Python23\Lib\site-packages\mod_python\publisher.py", line 410, in 
publish_object
return publish_object(req,util.apply_fs_data(object, req.form, req=req))

  File "C:\Python23\Lib\site-packages\mod_python\util.py", line 439, in 
apply_fs_data
return object(**args)

  File "E:\http_server\timeslips\index.py", line 84, in index
rtn.append(ts_widget.make_employee_picker())

  File "C:\Python23\lib\site-packages\ecptimeslips\ts_widget.py", line 128, 
in make_employee_picker
rs = win32com.client.Dispatch("ADODB.Recordset")

  File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 95, 
in Dispatch
dispatch, userName = 
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)

  File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 91, 
in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)

  File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 79, 
in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, 
pythoncom.IID_IDispatch)

com_error: (-2147221008, 'CoInitialize has not been called.', None, None)

? 


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


Name conflict in class hierarchy

2006-05-20 Thread Jeffrey Barish
I believe that the answer to my question is no, but I want to be sure that I
understand this issue correctly:  Suppose that there are two classes
defined as follows:

class A(object):
def f1(self):
print 'In A.f1, calling func'
self.func()

def func(self):
print 'In A.func'

class B(A):
def func(self):
print 'In B.func, calling A.f1'
A.f1(self)

Class A was defined by someone else or it comes from a library, so I have no
prior information about what is in it.  I subclass A to add some new
functionality, and I call the new function "func".  The function B.func
uses A.f1, but unbeknownst to me, A.f1 uses A.func.  Unfortunately, class B
overrides func, so the call in A.f1 to self.func actually invokes B.func,
resulting in this case in an infinite loop.  Is there a way from B to
specify that A should use its own version of func and ignore the version in
B?  I know that I could rename A.func to avoid the name clash, but since A
is actually in a library, I will lose that change when I upgrade the
library.  I could rename B.func, but there is already a bunch of code that
calls it so I would have to update all the calls.  That seems like the
correct solution, though.  The other possibility is to use composition
rather than subclassing:

class B:
def func(self):
print 'In B.func, calling A.f1'
a = A()
a.f1()

but then B does not inherit other functions of A that I would like to use. 
It struck me that this must be a common problem in OOP, so I'm wondering
whether there is a simple solution that I am missing.
-- 
Jeffrey Barish

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


Re: Question about exausted iterators

2006-05-20 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Christophe wrote:

> Well, the main reason for such change is and will always be to catch 
> bugs. The fact is, using duct typing is something very common with the 
> Python language.

Duct typing?  I guess you mean duct taping, or duck taping [1] or maybe
duck typing.  :-)

SCNR,
Marc 'BlackJack' Rintsch

[1] http://www.cybersalt.org/cleanlaugh/images/03/ducktape.htm
-- 
http://mail.python.org/mailman/listinfo/python-list


LocaWapp 0a - localhost web application

2006-05-20 Thread .
http://daviderognoni.blogspot.com?locawapp


- MAIN NEWS
===

* add ajax
* new "Request" methods
* fixed editor.py
* fixed files.py
* ...


- DESCRIPTION
=

LocaWapp want use HTML and Python not only for the web, but also for
the local applications:

Local + HTML + Python = LocaWapp

HTML = (CSS, images, JS, ...)

The LocaWapp mission is to build useful and beautiful LWA-UI (LocaWapp
User Interfaces) for the main functions of the system operator.

LocaWapp is searching free programmers, free designers, free
business-men that want advertise yourself with this open project.


- QUICKSTART


* Run:

python run.py

* and browse:

http://localhost:8080/locawapp/main.py

* You can change the port:

python run.py 8081


- DEVELOPING WITH THIS FRAMEWORK


* Put your application folder in root directory:

[your_application]
[locawapp]
__init__.py
common.py
main.py
[static]
logo.gif
main.css
main.js
LICENSE.html
README.html
run.py

* Your application must have "init" and "main" files (for convention):

[your_application]
__init__.py
main.py
other web applications (ex. main2.py)
your files or folders (ex. your [static])

* main.py is a web application, then it has "locawapp_main" function:

def locawapp_main(request):
[...]
html = [...String...]
request.sendResponse(html)

* See locawapp.main.py and locawapp.common.py


- UNDER CONSTRUCTION


Aioxml - is not xml (data formatter)

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


'error reading datastream' -- loading file only when transfer is complete?

2006-05-20 Thread liuliuliu
hello --

i'm running python/pygame on maemo (nokia 770). my situation is that
i'm continually scouring this one directory for incoming files. if i
see if there's a new file (coming in via wireless scp), i proceed to
load it and process it.

however, i think i am running into the issue that my program starts to
load the file after it recognises there is new data, but before the
file has completely transferred, so at unpredictable times i get a
pygame.error: Error reading from datastream.

what is the easiest way to work out this issue? easy being the key
word. :) thank you very much!

christine

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


File encoding strategy question

2006-05-20 Thread Andrew Robert
Hi everyone,

I am in the process of creating a file transmit/receiver program using
MQSeries.

The way it works is through creation of an XML message.

Elements within the XML message contain things such as file name, size,
and the file contents.

The file contents are encoded, currently using Base64, for support of
both binary and text data.

This works great but there is a small rub to the problem.

I would like to be able to view the contents of the file if it is text
while still maintaining the ability to transmit binary data.

Does anyone know of an encoding format that would make this possible?

The viewing of the file contents does not need to be perfect, merely
enough that a particular in-transit file could be identified.

Thoughts on this would be greatly appreciated.

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


Re: 'error reading datastream' -- loading file only when transfer is complete?

2006-05-20 Thread Andrew Robert
[EMAIL PROTECTED] wrote:
> hello --
> 
> i'm running python/pygame on maemo (nokia 770). my situation is that
> i'm continually scouring this one directory for incoming files. if i
> see if there's a new file (coming in via wireless scp), i proceed to
> load it and process it.
> 
> however, i think i am running into the issue that my program starts to
> load the file after it recognises there is new data, but before the
> file has completely transferred, so at unpredictable times i get a
> pygame.error: Error reading from datastream.
> 
> what is the easiest way to work out this issue? easy being the key
> word. :) thank you very much!
> 
> christine
> 

You might want to test for file locking before attempting to use
-- 
http://mail.python.org/mailman/listinfo/python-list


buffers readlines and general popen2 confusion...

2006-05-20 Thread [EMAIL PROTECTED]
I'm interested in taking the output of a daemonized shell script that
greps for patterns which would act as an argument to a script. Is it
better to write this stuff to file and visit the file every few seconds
or can this be done a better way. I'm hoping for a more elegant
solution. So far I've seen some troubling info about buffer overflows
with popen2 but it looks like the low-hanging fruit. I'm not a unixpro
so I want to make sure anything I tackle is best practice. Suggestions
welcomed.

-Aris

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


Re: python vs perl lines of code

2006-05-20 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote:

> A little out-of-order execution seems useful here. ;)

No, not interested in a pissing contest. Your statement that the Perl 
community encourages importing is *encouraged* (over using OO without 
importing) is false.

-- 
John   MexIT: http://johnbokma.com/mexit/
   personal page:   http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python vs perl lines of code

2006-05-20 Thread Edward Elliott
John Bokma wrote:

> Edward Elliott <[EMAIL PROTECTED]> wrote:
> 
>> A little out-of-order execution seems useful here. ;)
> 
> No, not interested in a pissing contest. Your statement that the Perl
> community encourages importing is *encouraged* (over using OO without
> importing) is false.

The cookbook says otherwise.  So it depends how you define community.

You lecturing people on pissing contests, that's rich.  Nice way to duck the
issue and sound like a winner.  Wake me when you decide to address the
substance of my arguments.

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


PHP's openssl_sign() using M2Crypto?

2006-05-20 Thread KW
I'm trying to convert some PHP code using OpenSSL to Python and I'm stuck 
on openssl_sign() which uses an RSA private key to compute a signature.

Example PHP code:
  $privkeyid = openssl_get_privatekey($priv_key, $key_pass);
  openssl_sign($data, $signature, $privkeyid);
  openssl_free_key($privkeyid);

I've tried several permutations of the stuff in M2Crypto.EVP but I can't get
it to work...

The openssl module in PHP basicly does this (C code): 
  EVP_SignInit(&md_ctx, EVP_sha1());
  EVP_SignUpdate(&md_ctx, data, data_len);
  EVP_SignFinal(&md_ctx, sigbuf, &siglen, pkey);

Looks like some magic is used to get pkey, I think that's what I'm missing.
See php_openssl_evp_from_zval() in PHP's ext/openssl/openssl.c.

I've tried the following:
  key = M2Crypto.EVP.load_key(keyfile, lambda x: passphr)
  hmac = M2Crypto.EVP.HMAC(key, 'sha1')
  hmac.update(message)
  hmac.final()

But this results in:
File "/usr/lib/python2.4/site-packages/M2Crypto/EVP.py", line 39, in 
__init__
  m2.hmac_init(self.ctx, key, self.md)
  TypeError: expected a readable buffer object
  Segmentation fault

Unfortunately M2Crypto documentation is practically nonexistent..

Best regards,
-- 
Konrad
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Name conflict in class hierarchy

2006-05-20 Thread Larry Bates
Jeffrey Barish wrote:
> I believe that the answer to my question is no, but I want to be sure that I
> understand this issue correctly:  Suppose that there are two classes
> defined as follows:
> 
> class A(object):
> def f1(self):
> print 'In A.f1, calling func'
> self.func()
> 
> def func(self):
> print 'In A.func'
> 
> class B(A):
> def func(self):
> print 'In B.func, calling A.f1'
> A.f1(self)
> 
> Class A was defined by someone else or it comes from a library, so I have no
> prior information about what is in it.  I subclass A to add some new
> functionality, and I call the new function "func".  The function B.func
> uses A.f1, but unbeknownst to me, A.f1 uses A.func.  Unfortunately, class B
> overrides func, so the call in A.f1 to self.func actually invokes B.func,
> resulting in this case in an infinite loop.  Is there a way from B to
> specify that A should use its own version of func and ignore the version in
> B?  I know that I could rename A.func to avoid the name clash, but since A
> is actually in a library, I will lose that change when I upgrade the
> library.  I could rename B.func, but there is already a bunch of code that
> calls it so I would have to update all the calls.  That seems like the
> correct solution, though.  The other possibility is to use composition
> rather than subclassing:
> 
> class B:
> def func(self):
> print 'In B.func, calling A.f1'
> a = A()
> a.f1()
> 
> but then B does not inherit other functions of A that I would like to use. 
> It struck me that this must be a common problem in OOP, so I'm wondering
> whether there is a simple solution that I am missing.

When you subclass an object it is your responsibility to check to make sure
you don't override existing methods in that class unintentionally.  Of course
you may want to intentionally override the methods so as to replace them with
your own methods.  You are correct, renaming A.func wouldn't be a good idea.
A good editor should make changing all the calls to B.func not be all that
hard.

You can easily get information about the methods by doing an import and dir().

Example:

>>> import ConfigParser
>>> dir(ConfigParser)
['ConfigParser', 'DEFAULTSECT', 'DuplicateSectionError', 'Error',
'InterpolationDepthError', 'InterpolationError',
'InterpolationMissingOptionError', 'InterpolationSyntaxError',
'MAX_INTERPOLATION_DEPTH', 'MissingSectionHeaderError', 'NoOptionError',
'NoSectionError', 'ParsingError', 'RawConfigParser', 'SafeConfigParser',
'__all__', '__builtins__', '__doc__', '__file__', '__name__', 're']


Depending on the author, you may also be able to get extensive help
on all the methods with help().

>>> help(ConfigParser)
Help on module ConfigParser:

NAME
ConfigParser - Configuration file parser.

FILE
c:\python24\lib\configparser.py

DESCRIPTION
A setup file consists of sections, lead by a "[section]" header,
and followed by "name: value" entries, with continuations and such in
the style of RFC 822.


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


Re: buffers readlines and general popen2 confusion...

2006-05-20 Thread Larry Bates
[EMAIL PROTECTED] wrote:
> I'm interested in taking the output of a daemonized shell script that
> greps for patterns which would act as an argument to a script. Is it
> better to write this stuff to file and visit the file every few seconds
> or can this be done a better way. I'm hoping for a more elegant
> solution. So far I've seen some troubling info about buffer overflows
> with popen2 but it looks like the low-hanging fruit. I'm not a unixpro
> so I want to make sure anything I tackle is best practice. Suggestions
> welcomed.
> 
> -Aris
> 
Sounds like you should take a look at logdog.  It uses fifo files to
send the output of /var/log/messages and greps them for patterns.
As the daemon just looks at the fifo file for any input, it is quite
efficient.

I could be way off base about what you are trying to do, but it still
might we worth a look.

http://caspian.dotconf.net/menu/Software/LogDog/v1.0-old/

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


Re: python vs perl lines of code

2006-05-20 Thread George Sakkis
Edward Elliott wrote:

> John Bokma wrote:
>
> > Edward Elliott <[EMAIL PROTECTED]> wrote:
> >
> >> A little out-of-order execution seems useful here. ;)
> >
> > No, not interested in a pissing contest. Your statement that the Perl
> > community encourages importing is *encouraged* (over using OO without
> > importing) is false.
>
> The cookbook says otherwise.  So it depends how you define community.
>
> You lecturing people on pissing contests, that's rich.  Nice way to duck the
> issue and sound like a winner.  Wake me when you decide to address the
> substance of my arguments.
>
> --
> Edward Elliott
> UC Berkeley School of Law (Boalt Hall)
> complangpython at eddeye dot net


Not trying to be as ass, but can you take this offline or at least in a
perl newsgroup ? Arguing on a particular fact or speculation about the
perl community is rather unproductive and offtopic for a python
newsgroup.

Thanks,
George

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


Re: python vs perl lines of code

2006-05-20 Thread Larry Bates
Edward Elliott wrote:
> This is just anecdotal, but I still find it interesting.  Take it for what
> it's worth.  I'm interested in hearing others' perspectives, just please
> don't turn this into a pissing contest.
> 
> I'm in the process of converting some old perl programs to python.  These
> programs use some network code and do a lot of list/dict data processing. 
> The old ones work fine but are a pain to extend.  After two conversions,
> the python versions are noticeably shorter.
> 
> The first program does some http retrieval, sort of a poor-man's wget with
> some extra features.  In fact it could be written as a bash script with
> wget, but the extra processing would make it very messy.  Here are the
> numbers on the two versions:
> 
>Raw   -Blanks -Comments
>lines  chars   lines  chars lines  chars
> mirror.py  16746321324597  1184009
> mirror.pl  30958362115647  1844790
>  
> I've listed line and character counts for three forms.  Raw is the source
> file as-is.  -Blanks is the source with blank lines removed, including
> lines with just a brace.  -Comments removes both blanks and comment lines. 
> I think -Blanks is the better measure because comments are a function of
> code complexity, but either works.
> 
> By the numbers, the python code appears roughly 60% as long by line and 80%
> as long by characters.  The chars percentage being (higher relative to line
> count) doesn't surprise me since things like list comprehensions and
> explicit module calling produce lengthy but readable lines.
> 
> I should point out this wasn't a straight line-for-line conversion, but the
> basic code structure is extremely similar.  I did make a number of
> improvements in the Python version with stricter arg checks and better
> error handling, plus added a couple minor new features.
> 
> The second program is an smtp outbound filtering proxy.  Same categories as
> before:
> 
> Raw -Blanks   -Comments
> lines  chars lines  chars   lines  chars
> smtp-proxy.py   2617788  222 7749   205 6964
> smtp-proxy.pl   96624110 66023469   45214869
> 
> The numbers here look much more impressive but it's not a fair comparison. 
> I wasn't happy with any of the cpan libraries for smtp sending at the time
> so I rolled my own.  That accounts for 150 raw lines of difference. Another
> 70 raw lines are logging functions that the python version does with the
> standard library.  The new version performs the same algorithms and data
> manipulations as the original.  I did do some major refactoring along the
> way, but it wasn't the sort that greatly reduces line count by eliminating
> redundancy; there is very little redundancy in either version.  In any
> case, these factors alone don't account for the entire difference, even if
> you take 220 raw lines directly off the latter columns.
> 
> The two versions were written about 5 years apart, all by me.  At the time
> of each, I had about 3 years experience in the given language and would
> classify my skill level in it as midway between intermediate and advanced. 
> IOW I'm very comfortable with the language and library reference docs (minus
> a few odd corners), but generally draw the line at mucking with interpreter
> internals like symbol tables.
> 
> I'd like to here from others what their experience converting between perl
> and python is (either direction).  I don't have the sense that either
> language is particularly better suited for my problem domain than the
> other, as they both handle network io and list/dict processing very well. 
> What are the differences like in other domains?  Do you attribute those
> differences to the language, the library, the programmer, or other
> factors?  What are the consistent differences across space and time, if
> any?  I'm interested in properties of the code itself, not performance.
> 
> And just what is the question to the ultimate answer to life, the universe,
> and everything anyway? ;)
> 
Sorry, I don't buy this.  I can write REALLY short programs that don't handle
exceptions, don't provide for logging for debugging purposes, don't allow
for future growth, etc.  I find that 60% of my code has nothing to do with
the actual algorithm or function I'm trying to accomplish.  It has more to
do with handling user's bad input, exceptions, recovering from hardware or
communications failures, etc.  Inexperienced programmers can write some
pretty short programs that get the job done, but can't handle the real world.

Also, many years ago I wrote a number of applications in APL.  We often
referred to programs written in APL as "write only code" because going back
to read what you had written after-the-fact was very hard.  You could write
in one line of APL what takes 1000's of lines of C or even Python and it was
pretty

Re: python vs perl lines of code

2006-05-20 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote:

> You lecturing people on pissing contests, that's rich.  Nice way to
> duck the issue and sound like a winner.

Then you've missed what a discussion really is. It's not about winning, 
it's about learning. Sadly you missed that point. 

> Wake me when you decide to address the substance of my arguments.

I have done so. If you don't consider it enough and think that code in a 
book based on 8+ year old modules is the current state of Perl 
programming, fine with me.

As a final word, I quote from chapter 12.10 of Learning Perl Objects, 
References, & Modules [1]:

"As seen earlier, *the normal means* of using an object-oriented module
 is to call class methods and then methods against instances 
 resulting from constructors of that class. This means that an OO
 module *typically exports nothing*, ..."


Which is in general recommended as the book one has to read after Learning 
Perl (IIRC it will be renamed in a next edition to reflect this).

-- 
John   MexIT: http://johnbokma.com/mexit/
   personal page:   http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python vs perl lines of code

2006-05-20 Thread John Bokma
"George Sakkis" <[EMAIL PROTECTED]> wrote:

> Not trying to be as ass, but can you take this offline or at least in
> a perl newsgroup ? Arguing on a particular fact or speculation about
> the perl community is rather unproductive and offtopic for a python
> newsgroup.

Use a real Usenet client, and you can make it skip a thread.

Like I said, I am not interested in a(n OT) pissing contest, but when 
people make silly statements like Edward did, I think its a good thing to 
point out that import is *not* encouraged by the Perl community. It has 
been used (abused IMO) a lot in the past, and yes, those modules are still 
around.

But in general OO is perferred, except in those cases that import extends 
the language with for example constructs like try / catch or case etc.

-- 
John   MexIT: http://johnbokma.com/mexit/
   personal page:   http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python vs perl lines of code

2006-05-20 Thread Edward Elliott
George Sakkis wrote:

> Not trying to be as ass, but can you take this offline or at least in a
> perl newsgroup ? Arguing on a particular fact or speculation about the
> perl community is rather unproductive and offtopic for a python
> newsgroup.

No offense taken.  It's definitely OT.  I left it here because 1)
comp.lang.python seems pretty lax about going OT when it's related to the
thread, which in this case it was, and 2) the general discussion about what
constitutes a community seemed kinda useful.

That said, I definitely think the discussion has run its course.  It's
getting dangerously close to flaming at this point, which indicates it's
time to go offline.

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'error reading datastream' -- loading file only when transfer is complete?

2006-05-20 Thread liuliuliu
thanks - i'm looking, but i found this as well. actually, does this
work?

import os
os.access(file, os.R_OK) # is it readable?

is this valid:

{ i have my file identified }
isFileAccessible = os.access(file, os.R_OK)
while !isFileAccessible:
 isFileAccessible = os.access(file, os.R_OK)

and then whenever it's true it can only then proceed to load the file?

thanks, christine

Andrew Robert wrote:
> [EMAIL PROTECTED] wrote:
> > hello --
> >
> > i'm running python/pygame on maemo (nokia 770). my situation is that
> > i'm continually scouring this one directory for incoming files. if i
> > see if there's a new file (coming in via wireless scp), i proceed to
> > load it and process it.
> >
> > however, i think i am running into the issue that my program starts to
> > load the file after it recognises there is new data, but before the
> > file has completely transferred, so at unpredictable times i get a
> > pygame.error: Error reading from datastream.
> >
> > what is the easiest way to work out this issue? easy being the key
> > word. :) thank you very much!
> >
> > christine
> >
> 
> You might want to test for file locking before attempting to use

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


Re: 'error reading datastream' -- loading file only when transfer is complete?

2006-05-20 Thread Jim Segrave
In article <[EMAIL PROTECTED]>,
Andrew Robert  <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] wrote:
>> hello --
>> 
>> i'm running python/pygame on maemo (nokia 770). my situation is that
>> i'm continually scouring this one directory for incoming files. if i
>> see if there's a new file (coming in via wireless scp), i proceed to
>> load it and process it.
>> 
>> however, i think i am running into the issue that my program starts to
>> load the file after it recognises there is new data, but before the
>> file has completely transferred, so at unpredictable times i get a
>> pygame.error: Error reading from datastream.
>> 
>> what is the easiest way to work out this issue? easy being the key
>> word. :) thank you very much!
>> 
>> christine
>> 
>
>You might want to test for file locking before attempting to use


Or, really crude - when you see the file, record the time and the file
size, but don't attempt to process it yet. Wait for a short interval,
then check the size again. If it's changed, wait again. When it gives
the same size after a delay period, assume all the data is there. 

This isn't a good method, but it's simple to implement and will reduce
the occurrence of attempts to process a file which is still in
transit/

-- 
Jim Segrave   ([EMAIL PROTECTED])

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


Re: buffers readlines and general popen2 confusion...

2006-05-20 Thread Jim Segrave
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>I'm interested in taking the output of a daemonized shell script that
>greps for patterns which would act as an argument to a script. Is it
>better to write this stuff to file and visit the file every few seconds
>or can this be done a better way. I'm hoping for a more elegant
>solution. So far I've seen some troubling info about buffer overflows
>with popen2 but it looks like the low-hanging fruit. I'm not a unixpro
>so I want to make sure anything I tackle is best practice. Suggestions
>welcomed.

I'm puzzled - a daemonised program normally closes stdin/stdout/stderr
and disconnects from its controlling terminal, so where is its output
going? 




-- 
Jim Segrave   ([EMAIL PROTECTED])

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


Re: FAQ for XML with Python

2006-05-20 Thread BartlebyScrivener
I have one suggestion. It's a beautiful page, and one day I'll know
enough to appreciate the help it provides, but until then it's always a
big help to the novice (in many fields of knowledge) if the first use
of an acronym includes the words it stands for in parenthesis.

In law and medicine and many other fields, this is a quick, unobtrusive
way to enlighten anyone who doesn't know what SAX or DOM stand for.
Think of it as initializing the acronym or defining the variable or
whatever: you do it only once, but it really helps the new  kids.

Thanks,

rick

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


Re: python vs perl lines of code

2006-05-20 Thread Edward Elliott
Larry Bates wrote:

> Sorry, I don't buy this.  I can write REALLY short programs that don't
> handle exceptions, don't provide for logging for debugging purposes, don't
> allow
> for future growth, etc.  I find that 60% of my code has nothing to do with
> the actual algorithm or function I'm trying to accomplish.  It has more to 
> do with handling user's bad input, exceptions, recovering from hardware or
> communications failures, etc.  

Wow, only 60%, I'm surprised it's that low :).  When I say the algorithms
are roughly equivalent, I'm including the amount of input verification and
error checking that they do.  To me, that's part of the algorithm.

> Inexperienced programmers can write some 
> pretty short programs that get the job done, but can't handle the real
> world.

Tell me about it.  I've taught intro comp sci, things can get real ugly real
quick. :)
 
> Also, many years ago I wrote a number of applications in APL.  We often
> referred to programs written in APL as "write only code" because going
> back
> to read what you had written after-the-fact was very hard.  You could
> write in one line of APL what takes 1000's of lines of C or even Python
> and it was pretty efficient also (for applications that needed to
> manipulate vectors or matrices).

Of course.  Comparing line counts between assembly and Prolog is pretty
useless given the vast discrepancy in their expressive power.  Perl and
Python are roughly comparable in expressiveness, so it doesn't seem
unreasonable to compare their line counts.  It might not tell you much,
there are undoubtedly better comparisons to make, but I don't think it's
grossly unfair the way you suggest.  I'm all ears if you have another
metric I can test as easily.
 
> I understand what you are trying to say, but I can't support your
> conclusions as presented.

What would those be?  I tried hard not draw any conclusions.  I just want to
see how other people's data compares to mine.

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: buffers readlines and general popen2 confusion...

2006-05-20 Thread [EMAIL PROTECTED]
That's just it. I was hoping to have python listening for events and
responding continually according to the demaons stdout. That's why I
mention popen2.

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


CRLF handling in the rfc822 module

2006-05-20 Thread Nikolaus Schulz
Hi, 

while playing with the rfc822 module and imaplib, I've found the
following weird behaviour.  Quickstart: rfc822.Message(fp) instantiates
a rfc822.Message object from a file object fp.  The docs for the rfc822
module say here: 

Input lines as read from the file may either be terminated by CR-LF or
by a single linefeed; a terminating CR-LF is replaced by a single
linefeed before the line is stored.

I've tested that with a message read from an IMAP server and a
locally generated message; since I'm running Linux, the local one has LF
line terminators, while the IMAP message uses CRLF.  

The following code snippet demonstrates that these two cases yield
different line terminators in the resulting rfc822.Message object.

#v+
#!/usr/bin/python

import imaplib
import rfc822

# Assignments omitted
# imap_server = 
# imap_username = 
# imap_password = 
# imap_folder = 

def print_header(msg_str):
import cStringIO
msg = rfc822.Message(cStringIO.StringIO(msg_str))
print repr(msg.headers[1])
print repr(msg.getrawheader('Envelope-to'))
print repr(msg.getheader('Envelope-to'))

imap_srv = imaplib.IMAP4_SSL(imap_server)
imap_srv.login(imap_username, imap_password)
imap_srv.select(imap_folder)
result, response = imap_srv.fetch(1, '(RFC822)')
imap_srv.close()
imap_srv.logout()
print_header(response[0][1])

local_msg = """\
Return-path: [EMAIL PROTECTED]
Envelope-to: [EMAIL PROTECTED]
Delivery-date: Fri, 12 May 2006 05:37:22 +0200
Message-ID: <[EMAIL PROTECTED]>
Date: Thu, 11 May 2006 20:30:44 -0700
From: Grargravarr <[EMAIL PROTECTED]>
To: Nikolaus Schulz <[EMAIL PROTECTED]>
Subject: Bogus CRLF handling in Python
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Dummy mail body. 
"""
print_header(local_msg)
# EO: demo
#v- 

Running the demo script gives this: 

#v+
'Envelope-to: [EMAIL PROTECTED]'
' [EMAIL PROTECTED]'
'[EMAIL PROTECTED]'
'Envelope-to: [EMAIL PROTECTED]'
' [EMAIL PROTECTED]'
'[EMAIL PROTECTED]'
#v-

Isn't that inconsistent?  Have I hit a bug?
Please enlighten me!

Have a nice day,
Nikolaus
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python vs perl lines of code

2006-05-20 Thread George Sakkis
John Bokma wrote:

> "George Sakkis" <[EMAIL PROTECTED]> wrote:
>
> > Not trying to be as ass, but can you take this offline or at least in
> > a perl newsgroup ? Arguing on a particular fact or speculation about
> > the perl community is rather unproductive and offtopic for a python
> > newsgroup.
>
> Use a real Usenet client, and you can make it skip a thread.

That's funny, coming from the same guy that's been harassing Xah for OT
posts. Oh, the irony.

George

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


Re: misleading prefix ++

2006-05-20 Thread Edward Elliott
Peter Otten wrote:

 class Int(object):
[snip]
> ... def __pos__(self):
> ... if self.half:
> ... self.value += 1
> ... self.half = not self.half
> ... return self
[snip]
 i = Int()

which leads us to:

 i
> 0
 +i
> 0
 +i
> 1
 +i
> 1
 +i
> 2

Now that is absolutely lovely.  Looks like it's time to join the ranks of
Perl and C with an Obfuscated Python Contest. ;)

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to tell if function was passed a list or a string?

2006-05-20 Thread Edward Elliott
Roy Smith wrote:

> Ben Finney <[EMAIL PROTECTED]> wrote:
>> Currently there's no good duck-typing way to differentiate
>> strings from other sequences.
> 
> I suppose you could do something like:
> 
> try:
>foo.isalpha
> except AttributeError:
>print "foo is not a string"

Another way:

if getattr (foo, 'isalpha', False):
print 'foo is a string'

Of course now string duck types must have an 'isalpha' and list ones can't,
but that shouldn't matter much.

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Feature request: sorting a list slice

2006-05-20 Thread Edward Elliott
John Machin wrote:

> Use case?

quicksort! :)

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


WeakrefValueDictionary of Callables?

2006-05-20 Thread Lloyd Weehuizen
Hey

I'm trying to set up a WeakrefValueDictionary of callables however as 
soon as my method that adds the callable to the dictionary exits the 
value is removed? Is there any way around this?

Example:
import weakref
TEST_EVENT = 1

class TestBinder:
def __init__( self ):
self.entries = weakref.WeakValueDictionary()

def BindFunction( self, event_id, function ):
self.entries[event_id] = function

def CallFunction( self, event_id, *args ):
self.entries[event_id]( *args )


class TestCase:
def __init__( self, binder ):
binder.BindFunction( TEST_EVENT, self.TestFunction )

def TestFunction():
print "TestFunction OK"

test_binder = TestBinder()
test_case = TestCase( test_binder )

test_binder.CallFunction( TEST_EVENT )

This generates a KeyError: 1, if I don't use weakrefs, then the TestCase 
object is never cleaned up until TestBinder is destroyed.

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


Re: python vs perl lines of code

2006-05-20 Thread John Bokma
"George Sakkis" <[EMAIL PROTECTED]> wrote:

> John Bokma wrote:
> 
>> "George Sakkis" <[EMAIL PROTECTED]> wrote:
>>
>> > Not trying to be as ass, but can you take this offline or at least in
>> > a perl newsgroup ? Arguing on a particular fact or speculation about
>> > the perl community is rather unproductive and offtopic for a python
>> > newsgroup.
>>
>> Use a real Usenet client, and you can make it skip a thread.
> 
> That's funny, coming from the same guy that's been harassing Xah for OT
> posts. Oh, the irony.

Xah was harassing 5 groups with a cross post without setting a follow-up 
to for the sole purpose of spamvertizing his website [1] repeatedly.

If you are that clueless, don't post.


[1] He is looking for another hoster btw.

-- 
John   MexIT: http://johnbokma.com/mexit/
   personal page:   http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Python update trouble (2.3 to 2.4): x<

2006-05-20 Thread Gonzalo Monzón
Hi all!

I have been translating some Python custom C extension code into Python, 
as I need these modules to be portable and run on a PocketPC without the 
need of compile (for the purpose its a must 2.4 as it is the last 
PythonCE release with great improvements).

But I've been stuck with a script wich does not work as expected once 
translated to python, 2.4

In the meantime, I thought I could test it with an old 2.3 version I 
have installed too on my computer, and found it run as expected, but see 
the FutureWarning, so googled a bit and found PEP 237 and long integer 
integration issue, but then can't find any workaround to fix the code 
for Python 2.4

Hope somebody could point some suggestion, or perhaps, the solution is 
pretty simple, but I missed it.

As I said, the code works fine on 2.3. I attach the code below.

The trouble is on the CalcCRC16 function, as you can see on the 
FutureWarning message.

InitCRC16 function does some bitwise xor's too, but I checked it and 
works as expected. Thought because only happen to be with small values 
there.

Thanks in advance for any help,
Gonzalo

##
Python 2.3.2:

pytest1.py:90: FutureWarning: x<> 8) & 255)] ^ (crc << 8) ^ ord(str[x])
67560050

##
Python 2.4.2:

22002496167782427386022437441624938050682666541682


*Expected result is 67560050*


# #
# pytest1.py

gCRC16Table = []

def InitCRC16():
global gCRC16Table

for i in xrange(0,256):
crc = i << 8
for j in xrange(0,8):
if (crc & 0x8000) != 0:
tmp = 0x1021
else:
tmp = 0
  
crc = (crc << 1) ^ tmp
gCRC16Table.append(crc)
   
def CalcCRC16(str):
global gCRC16Table

crc = 0x  
for x in xrange(0,len(str)):
crc = gCRC16Table[((crc >> 8) & 255)] ^ (crc << 8) ^ ord(str[x])
   
return crc
  
test = "123456asdfg12345123"
InitCRC16()
print CalcCRC16(test)

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


Re: Python update trouble (2.3 to 2.4): x<

2006-05-20 Thread Gonzalo Monzón
I reply again attaching a file as I see the editor wrecked the tab 
indentation.


Gonzalo Monzón escribió:


Hi all!

I have been translating some Python custom C extension code into 
Python, as I need these modules to be portable and run on a PocketPC 
without the need of compile (for the purpose its a must 2.4 as it is 
the last PythonCE release with great improvements).


But I've been stuck with a script wich does not work as expected once 
translated to python, 2.4


In the meantime, I thought I could test it with an old 2.3 version I 
have installed too on my computer, and found it run as expected, but 
see the FutureWarning, so googled a bit and found PEP 237 and long 
integer integration issue, but then can't find any workaround to fix 
the code for Python 2.4


Hope somebody could point some suggestion, or perhaps, the solution is 
pretty simple, but I missed it.


As I said, the code works fine on 2.3. I attach the code below.

The trouble is on the CalcCRC16 function, as you can see on the 
FutureWarning message.


InitCRC16 function does some bitwise xor's too, but I checked it and 
works as expected. Thought because only happen to be with small values 
there.


Thanks in advance for any help,
Gonzalo

##
Python 2.3.2:

pytest1.py:90: FutureWarning: x> 8) & 255)] ^ (crc << 8) ^ ord(str[x])
67560050

##
Python 2.4.2:

22002496167782427386022437441624938050682666541682


*Expected result is 67560050*


# #
# pytest1.py

gCRC16Table = []

def InitCRC16():
   global gCRC16Table

   for i in xrange(0,256):
   crc = i << 8
   for j in xrange(0,8):
   if (crc & 0x8000) != 0:
   tmp = 0x1021
   else:
   tmp = 0
crc = (crc << 1) ^ tmp
   gCRC16Table.append(crc)
  def CalcCRC16(str):
   global gCRC16Table

   crc = 0x for x in xrange(0,len(str)):
   crc = gCRC16Table[((crc >> 8) & 255)] ^ (crc << 8) ^ ord(str[x])
 return crc
 
test = "123456asdfg12345123"

InitCRC16()
print CalcCRC16(test)




gCRC16Table = []

def InitCRC16():
global gCRC16Table
for i in xrange(0,256):
crc = i << 8
for j in xrange(0,8):
if (crc & 0x8000) != 0:
tmp = 0x1021
else:
tmp = 0

crc = (crc << 1) ^ tmp
gCRC16Table.append(crc)

def CalcCRC16(str):
global gCRC16Table
crc = 0x

for x in xrange(0,len(str)):
crc = gCRC16Table[((crc >> 8) & 255)] ^ (crc << 8) ^ ord(str[x])

return crc

test = "123456asdfg12345123"
InitCRC16()
print CalcCRC16(test)
-- 
http://mail.python.org/mailman/listinfo/python-list

Python update trouble (2.3 to 2.4): x<

2006-05-20 Thread Gonzalo Monzón
I reply again attaching a file as I see the editor wrecked the tab 
indentation.


Gonzalo Monzón escribió:


Hi all!

I have been translating some Python custom C extension code into 
Python, as I need these modules to be portable and run on a PocketPC 
without the need of compile (for the purpose its a must 2.4 as it is 
the last PythonCE release with great improvements).


But I've been stuck with a script wich does not work as expected once 
translated to python, 2.4


In the meantime, I thought I could test it with an old 2.3 version I 
have installed too on my computer, and found it run as expected, but 
see the FutureWarning, so googled a bit and found PEP 237 and long 
integer integration issue, but then can't find any workaround to fix 
the code for Python 2.4


Hope somebody could point some suggestion, or perhaps, the solution is 
pretty simple, but I missed it.


As I said, the code works fine on 2.3. I attach the code below.

The trouble is on the CalcCRC16 function, as you can see on the 
FutureWarning message.


InitCRC16 function does some bitwise xor's too, but I checked it and 
works as expected. Thought because only happen to be with small values 
there.


Thanks in advance for any help,
Gonzalo

##
Python 2.3.2:

pytest1.py:90: FutureWarning: x> 8) & 255)] ^ (crc << 8) ^ ord(str[x])
67560050

##
Python 2.4.2:

22002496167782427386022437441624938050682666541682


*Expected result is 67560050*


# #
# pytest1.py

gCRC16Table = []

def InitCRC16():
   global gCRC16Table

   for i in xrange(0,256):
   crc = i << 8
   for j in xrange(0,8):
   if (crc & 0x8000) != 0:
   tmp = 0x1021
   else:
   tmp = 0
crc = (crc << 1) ^ tmp
   gCRC16Table.append(crc)
  def CalcCRC16(str):
   global gCRC16Table

   crc = 0x for x in xrange(0,len(str)):
   crc = gCRC16Table[((crc >> 8) & 255)] ^ (crc << 8) ^ ord(str[x])
 return crc
 
test = "123456asdfg12345123"

InitCRC16()
print CalcCRC16(test)


gCRC16Table = []

def InitCRC16():
global gCRC16Table
for i in xrange(0,256):
crc = i << 8
for j in xrange(0,8):
if (crc & 0x8000) != 0:
tmp = 0x1021
else:
tmp = 0

crc = (crc << 1) ^ tmp
gCRC16Table.append(crc)

def CalcCRC16(str):
global gCRC16Table
crc = 0x

for x in xrange(0,len(str)):
crc = gCRC16Table[((crc >> 8) & 255)] ^ (crc << 8) ^ ord(str[x])

return crc

test = "123456asdfg12345123"
InitCRC16()
print CalcCRC16(test)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python vs perl lines of code

2006-05-20 Thread George Sakkis
John Bokma wrote:
> "George Sakkis" <[EMAIL PROTECTED]> wrote:
>
> > John Bokma wrote:
> >
> >> "George Sakkis" <[EMAIL PROTECTED]> wrote:
> >>
> >> > Not trying to be as ass, but can you take this offline or at least in
> >> > a perl newsgroup ? Arguing on a particular fact or speculation about
> >> > the perl community is rather unproductive and offtopic for a python
> >> > newsgroup.
> >>
> >> Use a real Usenet client, and you can make it skip a thread.
> >
> > That's funny, coming from the same guy that's been harassing Xah for OT
> > posts. Oh, the irony.
>
> Xah was harassing 5 groups with a cross post without setting a follow-up
> to for the sole purpose of spamvertizing his website [1] repeatedly.

And somehow this made all real usenet clients unable to skip his
thread.

> If you are that clueless, don't post.

I will seriously ponder upon this, rest assured.

> [1] He is looking for another hoster btw.

This must feel really empowering huh ? 

George

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


Re: Feature request: sorting a list slice

2006-05-20 Thread Steve Holden
The effbot wrote:

> George Sakkis wrote:
> 
>>> It would be useful if list.sort() accepted two more optional
>>> parameters
> 
> useful for what?  what's the use case ?
> 
John Machin then wrote, without quoting any context at all:
> Use case?
> 
He means "under what circumstances do you see someone actually using the 
proposed feature rather than just nodding and saying "that looks 
useful". IOW, who would use the new feature, and why?

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

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


Re: Feature request: sorting a list slice

2006-05-20 Thread Robert Kern
Steve Holden wrote:
> The effbot wrote:
> 
>>George Sakkis wrote:
>>
It would be useful if list.sort() accepted two more optional
parameters
>>
>>useful for what?  what's the use case ?
> 
> John Machin then wrote, without quoting any context at all:
> 
>>Use case?
> 
> He means "under what circumstances do you see someone actually using the 
> proposed feature rather than just nodding and saying "that looks 
> useful". IOW, who would use the new feature, and why?

I believe that John was asking George for a use case rather than asking Fredrik
what a use case was.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: WeakrefValueDictionary of Callables?

2006-05-20 Thread Steve Holden
Lloyd Weehuizen wrote:
> Hey
> 
> I'm trying to set up a WeakrefValueDictionary of callables however as 
> soon as my method that adds the callable to the dictionary exits the 
> value is removed? Is there any way around this?
> 
> Example:
> import weakref
> TEST_EVENT = 1
> 
> class TestBinder:
>   def __init__( self ):
>   self.entries = weakref.WeakValueDictionary()
>   
>   def BindFunction( self, event_id, function ):
>   self.entries[event_id] = function
> 
>   def CallFunction( self, event_id, *args ):
>   self.entries[event_id]( *args )
> 
> 
> class TestCase:
>   def __init__( self, binder ):
>   binder.BindFunction( TEST_EVENT, self.TestFunction )
>   
>   def TestFunction():
>   print "TestFunction OK"
> 
> test_binder = TestBinder()
> test_case = TestCase( test_binder )
> 
> test_binder.CallFunction( TEST_EVENT )
> 
> This generates a KeyError: 1, if I don't use weakrefs, then the TestCase 
> object is never cleaned up until TestBinder is destroyed.
> 
I believe your problem is that the bound method references aren't being 
retained (i.e. referenced) anywhere else. A bound method is an object in 
its own right, and can cease to exist at any time - particularly in your 
case when the weak reference is the only reference to it!

Consider that the following code actually appears to work:

import weakref
TEST_EVENT = 1

class TestBinder:
 def __init__(self):
 self.entries = weakref.WeakValueDictionary()

 def BindFunction(self, event_id, obj):
 self.entries[event_id] = obj

 def CallFunction(self, event_id, *args):
 self.entries[event_id].TestFunction(*args)


class TestCase:
 def __init__(self, binder):
 binder.BindFunction(TEST_EVENT, self)

 def TestFunction(self):
 print "TestFunction OK"

test_binder = TestBinder()
test_case = TestCase(test_binder)

test_binder.CallFunction(TEST_EVENT)

The difference is that now a reference to the object rather than its 
bound method is stored, and your program *does* contain other references 
to the TesTcase object. It's perfectly leagal to store weak references 
to bound methods, but as you have seen they aren't referenced by their 
parent object.

Further notes: I have cleaned your code up to be closer to PEP 8 
conformance (if you don't know what PEP 8 is you shoudl find out), and I 
added the necessary "self" argument to the TestCase.TestFunction() method.

Hope this helps.

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

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


Re: Feature request: sorting a list slice

2006-05-20 Thread Steve Holden
Robert Kern wrote:
> Steve Holden wrote:
> 
>>The effbot wrote:
>>
>>
>>>George Sakkis wrote:
>>>
>>>
>It would be useful if list.sort() accepted two more optional
>parameters
>>>
>>>useful for what?  what's the use case ?
>>
>>John Machin then wrote, without quoting any context at all:
>>
>>
>>>Use case?
>>
>>He means "under what circumstances do you see someone actually using the 
>>proposed feature rather than just nodding and saying "that looks 
>>useful". IOW, who would use the new feature, and why?
> 
> 
> I believe that John was asking George for a use case rather than asking 
> Fredrik
> what a use case was.
> 
In which case, as I pointed out, John would have done better to quote a 
little more context.

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

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


Re: Feature request: sorting a list slice

2006-05-20 Thread Robert Kern
Steve Holden wrote:
> Robert Kern wrote:

>>I believe that John was asking George for a use case rather than asking 
>>Fredrik
>>what a use case was.
> 
> In which case, as I pointed out, John would have done better to quote a 
> little more context.

No argument here.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Name conflict in class hierarchy

2006-05-20 Thread Ralf Muschall
Jeffrey Barish wrote:

[overriding of base class member functions by subclass]

> but then B does not inherit other functions of A that I would like to use. 
> It struck me that this must be a common problem in OOP, so I'm wondering
> whether there is a simple solution that I am missing.

In C++, one has virtual member functions (which behave like python's),
and their purpose is to be overriden (o.g. a print method, whose subclass
version will print more attributes than the base knows about).

Such functions usually are documented - otherwise their being virtual
would make no sense.

In Python, a function not intended to be overriden should be either
have a name starting with an underscore or be documented.  So the person
who should change something is the author of the library, not you.

In your current situation, the following options seem to remain:

1. Use funny names ("foobar239847562384756" instead of "func")
   and hope that the library update will not use them

2. Call dir(classname) at hacking time and avoid names listed
   therein.  This breaks if the library update may happen at the
   user's site without you being able to change your code.

3. Call dir(classname) at runtime and raise an exception
   if it contains a name used by you.

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


Re: Python - Web Display Technology

2006-05-20 Thread foxtree
None of you seem to know what you are talking about.

Flash should be used where one needs to use Flash, and HTML/JS/CSS
(+XML+XSLT) likewise.

Flash can play video. That is not possible w/ HTML/CSS/JS.

Flash also behaves consistently cross-browser, cross/platform -- and
most features cannot be disabled by the user.  (compare that to a user
being able to turn off JS, or Java -- something often mandated in a
corporate environment.)  It's either "all on" or "all off."

Flash has such a large install base, that it could be argued it is the
most widely available platform for delivering media-rich "applications"
over the web.  (And code does not involve anywhere near the same level
of attention to kludges and workarounds that one would have to use to
replicate similar feature -- where possible -- in different browsers
and browser *versions.*)   -- Not to sound like I work for
MM/Adobe, but, here's what the Flash Player can do at *run time*:

Flash can load and play external MP3 audio.

Flash can render text -- w/ custom-defined and packaged fonts.  (not
possible in a browser!)  It can apply a limited set of CSS to the
rendered text, BTW.

Flash can load/parse/serialize/send XML.

Flash can POST and GET a variety of data  (true, it may access browser
controls to manage this.)

Flash can access you webcam, allowing you to create your own video
chat/IM app.

Flash can programatically-build vector shapes, gradients, and fills.

Flash can load and render jpegs, gifs(v8), and pngs(v8) -- and in
version 8, composite all that w/ vector graphics (+video?) -- *and,*
sample the resulting display pixel by pixel.  (passing that data back
to a server would allow dynamic creation of a jpeg or gif.)

Flash 8 has a new "file upload" ability that goes beyond what a browser
is capable of:   You can *multi-select* files, filter files by type or
size, and have programatic access to the state of the upload.  It
accesses an Operating System GUI control to do this -- and  I have
tested that these features work in MSIE, Moz FF, and Safari on OSX. ***

Flash can #animate# stuff!!!

Flash is like a 2 MB download that works in almost *every* browser out
there.  ...it's pretty phenomenal that all those features could have
been crammed into it.(like: a built-in interpreter for a
late-version-EcmaScript-compliant scripting language -- that, in many
ways, is far more capable than what is available w/ JavaScript in most
browsers!)



*** This feature can be used for a web-based CMS!  It would blow-away
anything (non-Java) now available for managing and uploading assets.
- Show quoted text -

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


Re: python vs perl lines of code

2006-05-20 Thread John Bokma
"George Sakkis" <[EMAIL PROTECTED]> wrote:

> John Bokma wrote:
>> "George Sakkis" <[EMAIL PROTECTED]> wrote:

[ Xah Lee ]

>> [1] He is looking for another hoster btw.
> 
> This must feel really empowering huh ? 

I am sure I've had quite some help. Also, you made quite a mistake. I have 
0 power, I just reported what I saw: repeatedly cross posting to 5 groups 
for the sole purpose of trolling and spamvertizing a website. And I am 
afraid that 5 is a limit set by Google Groups, not by your kook buddy.

Funny though, how you have a problem with a thread that side steps to Perl 
only for 4 or 5 postings, but have no problem with a hit & run post in 5 
groups to spamvertize a site.

Have fun with the pondering btw.

-- 
John   MexIT: http://johnbokma.com/mexit/
   personal page:   http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list