Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-07 Thread Sybren Stuvel
Steven D'Aprano enlightened us with: > Once the lookup table is created, you shouldn't use that function > again -- at best it is just sitting around like a third wheel, at > worst it might have side-effects you don't want. So I del the > function. I'd prefer to check the lookup table, and raise a

Re: Documentation suggestions

2005-12-07 Thread rurpy
[EMAIL PROTECTED] wrote: > Ian> I think the point is that there is the core language, and from a > Ian> user's perspective builtins and statements and syntax are all the > Ian> same thing. When you import a module, it's more-or-less obvious > Ian> where you find information about the

Re: Python web publishing framework like Cocoon?

2005-12-07 Thread James
None of those are anything like Cocoon. I can't think of any other Python equivalents. -- http://mail.python.org/mailman/listinfo/python-list

Re: unittest and non-.py files

2005-12-07 Thread Sybren Stuvel
Michael Hoffman enlightened us with: > Hi. I am trying to use unittest to run a test suite on some > scripts that do not have a .py extension. I'd move the functionality of the script into a separate file that does end in .py, and only put the invocation into the .py-less script. Sybren -- The p

Mutability of function arguments?

2005-12-07 Thread ex_ottoyuhr
I'm trying to create a function that can take arguments, say, foo and bar, and modify the original copies of foo and bar as well as its local versions -- the equivalent of C++ funct(&foo, &bar). I've looked around on this newsgroup and elsewhere, and I gather that this is a very common concern in

Re: How to ping in Python?

2005-12-07 Thread [EMAIL PROTECTED]
There is also always searching the Python Cookbook (http://pythoncookbook.activestate.com/) for something like this. There is already an ICMP library there (written by me and a friend) that includes a ping function that uses the library. -Brett -- http://mail.python.org/mailman/listinfo/python-l

Re: Documentation suggestions

2005-12-07 Thread rurpy
Fredrik Lundh wrote: > Ian Bicking wrote: > > > > the standard library is not an add-on. you're confused. > > > > I think the point is that there is the core language, and from a user's > > perspective builtins and statements and syntax are all the same thing. > > When you import a module, it's m

Re: Mutability of function arguments?

2005-12-07 Thread ex_ottoyuhr
(Re. mutability question:) Update, never mind. I found that the FooWrapper solution isn't so bad after all -- and even better is putting the variable in question in a different module entirely. However, anyone who wants to answer the question is still welcome to. Sorry to be a bother, and to have

Re: Bitching about the documentation...

2005-12-07 Thread Steven D'Aprano
On Wed, 07 Dec 2005 17:15:03 -0500, Mike Meyer wrote: > "Fredrik Lundh" <[EMAIL PROTECTED]> writes: >>> Er... no, I can't parse that. I suffered a Too Much Recursion error about >>> the third Badger (I only have a limited runtime stack). > > I always loved the demonstration that English requires

hi i have some doubts on a volume and the file system

2005-12-07 Thread muttu2244
hi everybody, i want to check the position of a volume in a particular drive. say for example in a disk i have 3 different drives: C:\ , D:\ and E:\. Now if i want to check what position is the D:\ in, how can i write the code. Means whether its in a 0th position or 1st position or a 2nd position

Re: Memoizing decorator

2005-12-07 Thread Daishi Harada
Hi, Sorry about the previous dup; I'm posting through Google Groups which seems to have burped. Anyways, I've "improved" things (or at least got things passing more tests). I now bind the cache to each object instance (and class for classmethods). At least one issue still remains, mostly due to

Re: Documentation suggestions

2005-12-07 Thread Steven Bethard
Aahz wrote: > In article <[EMAIL PROTECTED]>, > A.M. Kuchling <[EMAIL PROTECTED]> wrote: > >>So now we're *really* stuck. The RefGuide doesn't describe the rules; >>the PEP no longer describes them either; and probably only Guido can >>write the new text for the RefGuide. (Or are the semantics t

Re: Calculating Elapsed Time

2005-12-07 Thread Bengt Richter
On Wed, 07 Dec 2005 18:32:50 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2005-12-07, Fredrik Lundh <[EMAIL PROTECTED]> wrote: ... >> if I keep running the script over and over again, I do get individual >> >> -1.19209289551e-06 >> >> items from time to time on both machines... > >We're see

Re: Bitching about the documentation...

2005-12-07 Thread Dan Sommers
On Thu, 08 Dec 2005 12:19:13 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Linguists call that "garden path sentences", because they lead the > reader/listener up the garden path. > Here are some more examples: [ examples snipped ] And the ever-popular, ever-ambiguous: Women can fish. R

Re: Mutability of function arguments?

2005-12-07 Thread Mike Meyer
"ex_ottoyuhr" <[EMAIL PROTECTED]> writes: > I'm trying to create a function that can take arguments, say, foo and > bar, and modify the original copies of foo and bar as well as its local > versions -- the equivalent of C++ funct(&foo, &bar). C++'s '&' causes an argument to be passed by reference.

Re: Mutability of function arguments?

2005-12-07 Thread Mark Tolonen
"ex_ottoyuhr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm trying to create a function that can take arguments, say, foo and > bar, and modify the original copies of foo and bar as well as its local > versions -- the equivalent of C++ funct(&foo, &bar). > > I've looked around

Re: Mutability of function arguments?

2005-12-07 Thread bonono
Mike Meyer wrote: > "ex_ottoyuhr" <[EMAIL PROTECTED]> writes: > > I'm trying to create a function that can take arguments, say, foo and > > bar, and modify the original copies of foo and bar as well as its local > > versions -- the equivalent of C++ funct(&foo, &bar). > > C++'s '&' causes an argum

Re: uuDecode problem

2005-12-07 Thread Alex Martelli
py <[EMAIL PROTECTED]> wrote: ... > """data is a string""" > if len(data) > 45: > tmp = [] > for c in data: > tmp.append(binascii.b2a_uu(c)) You can't decode b2a-encoded data character by character, blindly, as you're trying to to here. Each character in the

Re: Documentation suggestions

2005-12-07 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > > wasn't the idea to get rid of the language reference altogether, and > > replace it with a better introduction ? > > Can an introduction provide the information the language > reference provides (or maybe I am misunderstanding what > you mean by introduction.) from th

Re: Mutability of function arguments?

2005-12-07 Thread Fredrik Lundh
"ex_ottoyuhr" wrote: > I've looked around on this newsgroup and elsewhere, and I gather that > this is a very common concern in Python, but one which is ordinarily > answered with "No, you can't. Neat, huh?" A few websites, newsgroup > posts, etc. have recommended that one ask for a more "Pythonic

Another newbie question

2005-12-07 Thread solaris_1234
I am a python newbie and have been trying to learn python. To this end, I have coded the following program creates: a 8 by 8 checker board Places two checkers on the board Checks the board and prints out which squares has a checker on them. It works. But I have a one question: 1) The stmt "board

Re: Mutability of function arguments?

2005-12-07 Thread Brett g Porter
ex_ottoyuhr wrote: > I'm trying to create a function that can take arguments, say, foo and > bar, and modify the original copies of foo and bar as well as its local > versions -- the equivalent of C++ funct(&foo, &bar). > > I've looked around on this newsgroup and elsewhere, and I gather that > th

Re: ElementTree - Why not part of the core?

2005-12-07 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > seems to be asking a lot for some people.) And at some > companies, one has to jump though beauracratic hoops > for each external package installed. And I personally > stear away from packages that have a long list of > prerequisites. Funny -- me, I prefer to

Re: Mutability of function arguments?

2005-12-07 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Mike Meyer wrote: >> "ex_ottoyuhr" <[EMAIL PROTECTED]> writes: >> > I'm trying to create a function that can take arguments, say, foo and >> > bar, and modify the original copies of foo and bar as well as its local >> > versions -- the equivalent of C++ funct(&foo, &bar)

Re: Implementing deepcopy

2005-12-07 Thread Alex Martelli
Mr.Rech <[EMAIL PROTECTED]> wrote: ... > Suppose one of the attributes of my class is a dictionary whose values > are callable functions, such as: > > >>>def foo(): > .pass > >>>def bar(): > .pass > > >>>adict = dict(a = foo, b = bar) > > Now if I try: > > >>> anotherdict = c

Re: Mutability of function arguments?

2005-12-07 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: > > Many people from C/C++ background would be tricked for this situation. > > That's because they don't understand binding. Any language that has > bindings instead of has assignments will "trick" them this way. ...Java being probably the most popular examp

Re: Mutability of function arguments?

2005-12-07 Thread Carl J. Van Arsdall
> > And, indeed, would that approach work? Would declaring: > > class FooWrapper : > __init__(fooToLoad) : > self.foo = fooToLoad > > mean that I could now declare a FooWrapper holding a foo, pass the > FooWrapper to a function, and have the function conclude with the foo > within the

[ANN] Python-OpenID 1.0

2005-12-07 Thread Kevin Turner
It is with great pleasure that JanRain, Inc. announces version 1.0 of the Python OpenID library. This library contains packages to support both OpenID consumers (relying parties) and servers. For back-end storage, it supports a variety of methods, including flat file, SQL, and MemCached. In our

Re: Is Python string immutable?

2005-12-07 Thread Frank Potter
Thank you very much.Steve Holden, I post my soucecode at my blog here:http://hiparrot.wordpress.com/2005/12/08/implementing-a-simple-net-spider/ I wish you can read and give me some suggestion. Any comments will be appreciated.On 12/2/05, Steve Holden < [EMAIL PROTECTED]> wrote:could ildg wrote:> I

Re: Implementing deepcopy

2005-12-07 Thread Mr.Rech
Thanks for your answer. Since perfomances are not an issue in my case I think I'd stay with copy.copy(). In this way I'm not required to know in advance the object type, and I can implement a __deepcopy__ method for my own classes as follows: >>> def __deepcopy__(self, memo = {}): new

Re: Mutability of function arguments?

2005-12-07 Thread bonono
Mike Meyer wrote: > [EMAIL PROTECTED] writes: > > Mike Meyer wrote: > >> "ex_ottoyuhr" <[EMAIL PROTECTED]> writes: > >> > I'm trying to create a function that can take arguments, say, foo and > >> > bar, and modify the original copies of foo and bar as well as its local > >> > versions -- the equi

Re: Calculating Elapsed Time

2005-12-07 Thread Grant Edwards
On 2005-12-08, Bengt Richter <[EMAIL PROTECTED]> wrote: >>We're seeing floating point representation issues. >> >>The resolution of the underlying call is exactly 1us. Calling >>gettimeofday() in a loop in C results in deltas of exactly 1 or >>2 us. Python uses a C double to represent time, an

sql escaping module

2005-12-07 Thread David Bear
Being new to pgdb, I'm finding there are lot of things I don't understand when I read the PEP and the sparse documentation on pgdb. I was hoping there would be a module that would properly escape longer text strings to prevent sql injection -- and other things just make sure the python string obje

python24.dll and encodings ?

2005-12-07 Thread Bugs
I believe I read in a relatively recent thread that the reason python24.dll is so large compared to previous releases is that all the language encodings are linked into the library? Are there any plans for future releases to split the encodings out so that, for example, if someone wanted to mak

Re: Another newbie question

2005-12-07 Thread Mike Meyer
"solaris_1234" <[EMAIL PROTECTED]> writes: > 1) The stmt "board.Blist[10].DrawQueen(board.Blist[10].b1)" seems > awkward. Is there another way (cleaner, more intuitive) to get the > same thing done? Yes. Reaching through objects to do things is usually a bad idea. Some languages don't allow you

Re: Mutability of function arguments?

2005-12-07 Thread Mike Meyer
[EMAIL PROTECTED] writes: > Mike Meyer wrote: >> [EMAIL PROTECTED] writes: >> > Mike Meyer wrote: >> >> "ex_ottoyuhr" <[EMAIL PROTECTED]> writes: >> >> > I'm trying to create a function that can take arguments, say, foo and >> >> > bar, and modify the original copies of foo and bar as well as its l

Re: Mutability of function arguments?

2005-12-07 Thread bonono
Mike Meyer wrote: > Except "trick" is a poor word choice. Nobody is playing a trick on > them - they just don't understand what is going on. > oops, never thought about the negative meaning of it, it is just meant as "not behave as expected", what would be the word you use then ? -- http://mail.

first post: new to pythong. some questions.

2005-12-07 Thread shawn a
Hello. Im brand new to this list and to python.  Ive recently started reading about it  and am now in the tinkering stage.  I have a script im working on that i need some asistance debugging. Its super small and should be a snap for you gurus =) I have 2 files in a dir off my home dir: mkoneurl.py

Re: Another newbie question

2005-12-07 Thread [EMAIL PROTECTED]
Mike, Thanks for your insight. It has been a big help. I guess I was trying to learn too much with my original code. Trying to implement inheritance, object creation, calling methods via inheritance made the code harder than it needed to be. I'm off to study the code. (Hmm.. how does python pars

Re: Documentation suggestions

2005-12-07 Thread Bengt Richter
On Thu, 8 Dec 2005 01:32:08 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] wrote: > >> > wasn't the idea to get rid of the language reference altogether, and >> > replace it with a better introduction ? >> >> Can an introduction provide the information the language >> referen

Re: sql escaping module

2005-12-07 Thread Fredrik Lundh
David Bear wrote: > Being new to pgdb, I'm finding there are lot of things I don't understand > when I read the PEP and the sparse documentation on pgdb. > > I was hoping there would be a module that would properly escape longer text > strings to prevent sql injection -- and other things just make

Re: movie module

2005-12-07 Thread davidtweet
Hello, It would be helpful to know what platform you are on, because it appears that the movie module of pygame is not implemented for Windows currently: http://www.pygame.org/docs/ref/movie.html The page recommends PyMedia as an alternative: http://www.pymedia.org Finally, you might get a

efficient 'tail' implementation

2005-12-07 Thread s99999999s2003
hi I have a file which is very large eg over 200Mb , and i am going to use python to code a "tail" command to get the last few lines of the file. What is a good algorithm for this type of task in python for very big files? Initially, i thought of reading everything into an array from the file and

Re: efficient 'tail' implementation

2005-12-07 Thread bonono
[EMAIL PROTECTED] wrote: > hi > > I have a file which is very large eg over 200Mb , and i am going to use > python to code a "tail" > command to get the last few lines of the file. What is a good algorithm > for this type of task in python for very big files? > Initially, i thought of reading eve

Re: efficient 'tail' implementation

2005-12-07 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I have a file which is very large eg over 200Mb , and i am going to use > python to code a "tail" > command to get the last few lines of the file. What is a good algorithm > for this type of task in python for very big files? > Initially, i thought of reading everything

Re: Mutability of function arguments?

2005-12-07 Thread Mike Meyer
[EMAIL PROTECTED] writes: >> Except "trick" is a poor word choice. Nobody is playing a trick on >> them - they just don't understand what is going on. > oops, never thought about the negative meaning of it, it is just meant > as "not behave as expected", what would be the word you use then ? Surp

Re: efficient 'tail' implementation

2005-12-07 Thread bonono
Mike Meyer wrote: > It would probably be more efficient to read blocks backwards and paste > them together, but I'm not going to get into that. > That actually is a pretty good idea. just reverse the buffer and do a split, the last line becomes the first line and so on. The logic then would be no

Re: sql escaping module

2005-12-07 Thread Fredrik Lundh
Fredrik Lundh wrote: >> web searchs for 'python sql escape string' yeild way too many results. >> >> Any pointers would be greatly appreciated. > > for x in range(100): >print "USE PARAMETERS TO PASS VALUES TO THE DATABASE" for an example, see "listing 2" in the following article: h

<    1   2   3