Re: Loading functions from a file during run-time

2005-02-16 Thread Wensheng
or don't use exec(): f=[getattr(fs,a) for a in dir(fs) if a[0:2]!='__' and type(getattr(fs,a))==types.FunctionType] >>> f [, ] >>> f[0](n) -5 >>> f[1](n) 25 -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting milliseconds in Python

2005-02-16 Thread Fredrik Lundh
Brian Beck wrote: > That IS what you want. > > seconds * 100 = milliseconds are you sure you know what a millisecond is? (duck) -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-16 Thread Jeff Shannon
john san wrote: Just want to show "windows" under dos without MsWindows. Also find some difficulty to simply install WxPython under directory(DOS) and then run, which is very good thing if it is just like Java. I don't think you'll have any luck finding wxPython for DOS. A bit of a looksee around

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread peter
brain reset and understood thx a lot for all your answers Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Multidimensional arrays - howto?

2005-02-16 Thread Colin J. Williams
[EMAIL PROTECTED] wrote: Hello all, I am trying to convert some C code into python. Since i am new to python, i would like to know how to deal with multidimensional arrays? Thanks, -Joe Here's a snippet of what i am trying to convert: # define table0 15 # define table1 20 unsigned int Table[table0]

Re: Getting milliseconds in Python

2005-02-16 Thread Amand Tihon
Brian Beck wrote: > That IS what you want. > > seconds * 100 = milliseconds May I assume that this IS what you want ? ()___ ()//__/)_() ||(___)//#/_/#/_/#/_/#()/|| |||#| |#|_|#|_|#|_|| || |||_|#|_|#|_|#|_|#||/|| |||#|_

[ann] Appscript Installer 1.0

2005-02-16 Thread has
Hi all, Announcing the first release of the all-in-one Appscript Installer package for Mac OS X 10.3. Appscript brings AppleScript-quality application scripting support to MacPython on Mac OS X. This package installs everything you need to control "Applescriptable" applications using the Python 2

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread Jeff Shannon
peter wrote: Hello, nice solution: but it puzzles me :) can anyone tell me why ---correct solution def fA(input): return input def newFA(input, f= fA): return f(input) This saves a reference to the original function in the new function's default argument.

Re: [ANN] IPython 0.6.11 is out.

2005-02-16 Thread Fernando Perez
Ville Vainio wrote: > Warning - if you are upgrading and have an old pysh.py dangling around > in $HOME/.ipython, be sure to delete it. The old version is > incompatible with the new ipython. Just to clarify: you need to delete ONLY the old pysh.py, not your entire $HOME/.ipython/ directory. Y

How can I get the source file name and current line number inside executed C-function

2005-02-16 Thread Marek Prerovsky
Hello, I implemented some Python functions in my C/C++ code. I need to know the Python source file name and line number of just executed Python command which calls my function. How can I get this information inside my C/C++ function? Thanks for any help. Marek -- http://mail.python.org/mailman/

Re: adding new functionality to a function non-intrusively!

2005-02-16 Thread Terry Reedy
"peter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > so my problem in fact is: > BEFORE: > def myfunction(a,b): > return (a+b) > AFTER: > def myfunction(a,b, op="add"): > if (op == "add"): > # some function which calls the old code for myfunction Is this

Re: Win32api shellexecute Bshow

2005-02-16 Thread infidel
Acrobat is stupid like this. I haven't yet found a way to prevent it from launching a new window, so I gave up and went with GhostScript and GSPrint instead. Works fabulously. -- http://mail.python.org/mailman/listinfo/python-list

Why doesn't join() call str() on its arguments?

2005-02-16 Thread Leo Breebaart
I've tried Googling for this, but practically all discussions on str.join() focus on the yuck-ugly-shouldn't-it-be-a-list-method? issue, which is not my problem/question at all. What I can't find an explanation for is why str.join() doesn't automatically call str() on its arguments, so that e.g. s

Re: [EVALUATION] - E02 - ULTIMATE RECIPE TO RESOLVE ALL ISSUES

2005-02-16 Thread Terry Reedy
"Peter Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > http://nobelprize.org/medicine/educational/pavlov/ > > and then do something useful :) Thanks. I showed this to my daughter, who enjoyed the game, and explained your point re Pavlov posting, and about Pavlov advertising

Pmw.Balloon under Windows

2005-02-16 Thread Aki Niimura
Hello everyone, I'm encountering a weird problem and couldn't find any Internet postings that are relevant to my problem and it seems coming from the Pmw Balloon widget inside. I have developed a Tkinter software using Pmw. The software is being developed under Solaris but is targeting all platfo

Re: Can __new__ prevent __init__ from being called?

2005-02-16 Thread Colin J. Williams
Felix Wiemann wrote: Steven Bethard wrote: Felix Wiemann wrote: How can I prevent __init__ from being called on the already-initialized object? The short answer: you can't: http://www.python.org/2.2.3/descrintro.html#__new__ [snip] This prompts a similar query. __new__ appears to be intende

Re: Loading functions from a file during run-time

2005-02-16 Thread tjprojects_usenet
Wensheng wrote: > #--- file bar.py > >>> foo="bar" > >>> fs=__import__(foo) Wensheng: The problem with this is that it assumes the text file is a valid python file, and that the extension is ".py". This may work for the OP's situation; he would need to weigh in. 'exec'ing the functions int

Re: SHA1 broken

2005-02-16 Thread Irmen de Jong
Tim Churches wrote: Also, the new findings only apply to hash collisions, not to the invertibility of SHA1 hashes - thus, as Schneier points out, uses of keyed hashes (such as HMAC) are not compromised by this. What about HMAC-MD5? --Irmen -- http://mail.python.org/mailman/listinfo/python-list

Imported or executed?

2005-02-16 Thread Stephan Schulz
Hi All, I've written a Python replacement of fixbb, as shell/awk script that will create tightly fitting bounding boxes for PostScript files. Most of the functionality is encapsulated in a small function called fixbb(filename). I'm importing this into other code via 'import'. A few lines of code

web spider and password protected pages

2005-02-16 Thread jdonnell
I've been writing a simple web spider for fun, and I've run into a problem I can't figure out. The spider hangs (waits for username and pass) when I hit a page that requires .htaccess authentication. self.f = urllib.urlopen('http://blogbloc.com/~jay/test/') #nothing below here gets executed print

Re: How can I Fill in web form and post back

2005-02-16 Thread Rigga
Joe Francia wrote: > Rigga wrote: >> Hi, >> >> I am looking for the best way to use Python to get a web page, look for >> some particular fields on a form, fill in the fields and submit the form >> but I have no idea where to start - any pointers appreciated >> >> many thanks >> >> Rigga > > H

Re: SHA1 broken

2005-02-16 Thread Paul Rubin
Irmen de Jong <[EMAIL PROTECTED]> writes: > > Also, the new findings only apply to hash collisions, not to the > > invertibility of SHA1 hashes - thus, as Schneier points out, uses of > > keyed hashes (such as HMAC) are not compromised by this. > > What about HMAC-MD5? HMAC-MD5 and HMAC-SHA1 shou

Re: Win32api shellexecute Bshow

2005-02-16 Thread Josh
Thanks, I'll take a look at using GhostScript and GSPrint instead. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Imported or executed?

2005-02-16 Thread Fredrik Lundh
Stephan Schulz wrote: > Is there a (portable, standard) way for the program/module to find out > if it is imported or executed stand-alone? if a module is executed, it's name is set to "__main__". see: http://www.python.org/doc/faq/programming.html#how-do-i-find-the-current-module-name --

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Jeff Shannon
Leo Breebaart wrote: What I can't find an explanation for is why str.join() doesn't automatically call str() on its arguments [...] [...] Presumably there is some counter-argument involved, some reason why people preferred the existing semantics after all. But for the life of me I can't think what

Re: Imported or executed?

2005-02-16 Thread Jeff Shannon
Stephan Schulz wrote: Is there a (portable, standard) way for the program/module to find out if it is imported or executed stand-alone? def fixbb(*filelist): # ... if __name__ == '__main__': # Executed stand-alone fixbb(sys.argv[1:]) (Obviously, you'd probably want to do more command-li

Re: Imported or executed?

2005-02-16 Thread Stephan Schulz
In article <[EMAIL PROTECTED]>, Fredrik Lundh wrote: >Stephan Schulz wrote: > >> Is there a (portable, standard) way for the program/module to find out >> if it is imported or executed stand-alone? > >if a module is executed, it's name is set to "__main__". see: [...] It works. Thanks! Bye,

Re: Can __new__ prevent __init__ from being called?

2005-02-16 Thread Steven Bethard
Colin J. Williams wrote: This prompts a similar query. __new__ appears to be intended for immutable objects but it seems to be called as part of constructor process for all instances. That's because Python has no builtin way of determining whether or not a given type is immutable. If you wante

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Fredrik Lundh
Jeff Shannon wrote: > One possibility I can think of would be Unicode. I don't think that > implicitly calling str() on > Unicode strings is desirable. it's not. but you could make an exception for basestring types. > Of course, one could ensure that unicode.join() used unicode() and str.joi

Re: Test for structure

2005-02-16 Thread Steven Bethard
alex wrote: So how can I test if a variable 'a' is either a single character string or a list? py> def test(x): ... return (isinstance(x, list) or ... isinstance(x, basestring) and len(x) == 1) ... py> test('a') True py> test('ab') False py> test([]) True py> test(['a', 'b']) True B

Re: more os.walk() issues... probably user error

2005-02-16 Thread rbt
Kent Johnson wrote: rbt wrote: rbt wrote: This function is intended to remove unwanted files and dirs from os.walk(). It will return correctly *IF* I leave the 'for fs in fs_objects' statement out (basically leave out the entire purpose of the function). It's odd, when the program goes into tha

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Aahz
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >I've proposed adding a "join" built-in that knows about the available >string types, and does the right thing for non-string objects. >unfortunately, the current crop of py-dev:ers don't seem to use strings >much, so they p

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Steven Bethard
Leo Breebaart wrote: I'm not complaining as such -- sep.join(str(i) for i in seq) is not *that* ugly, but what annoys me is that I don't understand *why* this was never changed. py> chars = [u'ä', u'å'] py> ', '.join(chars) u'\xe4, \xe5' py> ', '.join(str(c) for c in chars) Traceback (most recent c

Re: How can I get the source file name and current line number inside executed C-function

2005-02-16 Thread python
Below is a function to find the caller's file name, line number, etc. inside Python. Maybe this works for your case. /Jean Brouwers - import traceback - - def caller(up=0): - '''Get file name, line number, function name and -source text of the caller's caller as 4-tuple: -

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread John Machin
On 16 Feb 2005 18:47:21 GMT, Leo Breebaart <[EMAIL PROTECTED]> wrote: > >What I can't find an explanation for is why str.join() doesn't >automatically call str() on its arguments, so that e.g. >str.join([1,2,4,5]) would yield "1245", and ditto for e.g. >user-defined classes that have a __str__()

Re: low-end persistence strategies?

2005-02-16 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Paul Rubin wrote: >I've started a few threads before on object persistence in medium to >high end server apps. This one is about low end apps, for example, a >simple cgi on a personal web site that might get a dozen hits a day. >The idea

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Skip Montanaro
John> 4. For consistency, would you like "1" + 2 to produce "12"? No, the correct answer is obviously 3. ;-) S -- http://mail.python.org/mailman/listinfo/python-list

Re: Test for structure

2005-02-16 Thread Michael Hartl
I use a function isListLike in cases such as this one: # def isListLike(L): # """Return True if L is list-like, False otherwise.""" # try: # L + [] # return True # except: # return False Then you can use a standard if-else construct: # if isListLike(myvar): #

Re: How can I Fill in web form and post back

2005-02-16 Thread Joe Francia
On Wed, 16 Feb 2005 19:05:35 GMT, Rigga <[EMAIL PROTECTED]> wrote: Joe Francia wrote: Rigga wrote: Hi, I am looking for the best way to use Python to get a web page, look for some particular fields on a form, fill in the fields and submit the form but I have no idea where to start - any pointers

Re: web spider and password protected pages

2005-02-16 Thread Peter Hansen
jdonnell wrote: I've been writing a simple web spider for fun, and I've run into a problem I can't figure out. The spider hangs (waits for username and pass) when I hit a page that requires .htaccess authentication. self.f = urllib.urlopen('http://blogbloc.com/~jay/test/') #nothing below here gets

huge help for interactive python

2005-02-16 Thread David S.
If you are using ipython on Windows then you will have made sure you have Gary Bishop's readline library as instructed in the ipython install directions found at: http://ipython.scipy.org/ Even if you use the standard commandline tool, installing readline makes the basic command line a lot eas

PIL question. draw string with angle?

2005-02-16 Thread sector119
How am I able to draw a sting with some angle on image? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Leo Breebaart
John Machin <[EMAIL PROTECTED]> writes: > On 16 Feb 2005 18:47:21 GMT, Leo Breebaart <[EMAIL PROTECTED]> wrote: > > >What I can't find an explanation for is why str.join() doesn't > >automatically call str() on its arguments, so that e.g. > >str.join([1,2,4,5]) would yield "1245", and ditto for

Re: How can I Fill in web form and post back

2005-02-16 Thread Rigga
Joe Francia wrote: > On Wed, 16 Feb 2005 19:05:35 GMT, Rigga <[EMAIL PROTECTED]> wrote: > >> Joe Francia wrote: >> >>> Rigga wrote: Hi, I am looking for the best way to use Python to get a web page, look for some particular fields on a form, fill in the fields and submit the >

problem with tutor mailing

2005-02-16 Thread administrata
i'm using tutor maling... i e-mail some questions to tutor and get answers. but, i frequently get mails which aren't related with my question. how should i stop it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Thomas Heller
Skip Montanaro <[EMAIL PROTECTED]> writes: > John> 4. For consistency, would you like "1" + 2 to produce "12"? > > No, the correct answer is obviously 3. ;-) > > S No, '"1"2' is correct. Or '"1"+2'. -- http://mail.python.org/mailman/listinfo/python-list

Re: huge help for interactive python

2005-02-16 Thread David S.
David S. alumni.tufts.edu> writes: > I am sure it can be improved, but it was easy. By the > way, it generates LaTeK. LaTeX, rather. -- http://mail.python.org/mailman/listinfo/python-list

Re: super not working in __del__ ?

2005-02-16 Thread Christopher J. Bottaro
Jeff Shannon wrote: > Christopher J. Bottaro wrote: > >> 2 Questions... >> 1) Why does this never happen in C++? Or does it, its just never >> happened to me? >> 2) I can understand random destruction of instantiated objects, but I >> find it weird that class definitions (sorry, bad terminolog

Multiple initialization methods?

2005-02-16 Thread alex
Hi, it is possible to define multiple initialization methods so that the method is used that fits? I am thinking of something like this: def __init__(self, par1, par2): self.init(par1, par2); def __init__(self, par1): self.init(par1, None) def init(self, par1, par2): ...

Re: problem with tutor mailing

2005-02-16 Thread Brian van den Broek
administrata said unto the world upon 2005-02-16 16:11: i'm using tutor maling... i e-mail some questions to tutor and get answers. but, i frequently get mails which aren't related with my question. how should i stop it? You do know it's a mailing list that you've subscribed too, right? As in, peop

Re: Can __new__ prevent __init__ from being called?

2005-02-16 Thread Martin
Felix Wiemann wrote: > Sometimes (but not always) the __new__ method of one of my classes > returns an *existing* instance of the class. However, when it does > that, the __init__ method of the existing instance is called > nonetheless, so that the instance is initialized a second time. [snip] >

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread John Roth
"Leo Breebaart" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I've tried Googling for this, but practically all discussions on str.join() focus on the yuck-ugly-shouldn't-it-be-a-list-method? issue, which is not my problem/question at all. What I can't find an explanation for is why

Using 'in' with a Dict

2005-02-16 Thread cpmcdaniel
I was wondering if the following two "if" statements compile down to the same bytecode for a standard Dictionary type: m = {"foo": 1, "blah": 2} if "foo" in m: print "sweet" if m.has_key("foo"): print "dude" -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with tutor mailing

2005-02-16 Thread Kartic
> but, i frequently get mails which aren't related with my question. You mean spam?! This is not the first time you are using email, is it? > how should i stop it? Well, it depends. If you are on *nix machine, you can install Spamassassin locally for your id and filter emails out. If you are on

Re: Using 'in' with a Dict

2005-02-16 Thread kowboy
I posted too quickly. A little performance testing told me that has_key is somewhat slower than "in". I used a large number of string keys in my test. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can __new__ prevent __init__ from being called?

2005-02-16 Thread Martin
I meant to say: Although the base class __new__ does have to check to see if the ^^^ instance is initialized, ... not: > Although the base class __init__ does have to check to see if the > instance is initialized, ... -- http://mail.python.org/mailman/listinfo/pytho

Re: huge help for interactive python

2005-02-16 Thread Fernando Perez
David S. wrote: > If you are using ipython on Windows then you will > have made sure you have Gary Bishop's readline > library as instructed in the ipython install > directions found at: > http://ipython.scipy.org/ [...] Thanks, very handy. I just reposted your message to the ipyhton-users list

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread John Roth
"Leo Breebaart" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I've tried Googling for this, but practically all discussions on str.join() focus on the yuck-ugly-shouldn't-it-be-a-list-method? issue, which is not my problem/question at all. What I can't find an explanation for is why

Re: Test for structure

2005-02-16 Thread Steven Bethard
Michael Hartl wrote: I use a function isListLike in cases such as this one: # def isListLike(L): # """Return True if L is list-like, False otherwise.""" # try: # L + [] # return True # except: # return False Then you can use a standard if-else construct: # if isL

Re: Multiple initialization methods?

2005-02-16 Thread Dennis Benzinger
alex wrote: > Hi, > > it is possible to define multiple initialization methods so that the > method is used that fits? No, there is no overloading in Python. > I am thinking of something like this: > > def __init__(self, par1, par2): > self.init(par1, par2); > > def __init__(self, par1

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Nick Vargish
Leo Breebaart <[EMAIL PROTECTED]> writes: > That suggests > to me an "obvious default" of the kind that exists elsewhere in > Python as well. I feel pretty much the opposite... If a non-string-type has managed to get into my list-of-strings, then something has gone wrong and I would like to know

Re: Multiple initialization methods?

2005-02-16 Thread Steven Bethard
alex wrote: I am thinking of something like this: def __init__(self, par1, par2): self.init(par1, par2); def __init__(self, par1): self.init(par1, None) def init(self, par1, par2): ... ... So if the call is with one parameter only the second class is executed (calling the 'i

Re: Using 'in' with a Dict

2005-02-16 Thread Kartic
This is what I did >>> import compiler >>> exec1 = compiler.compile('''if "foo" in m: print "sweet"''', '', 'exec') >>> exec2 = compiler.compile('''if m.has_key("foo"): print "dude"''', '', 'exec') >>> exec1.co_code 'd\x01\x00e\x00\x00j\x06\x00o\t\x00\x01d\x02\x00GHn\x01\x00\x01d\x00\x00S'

Re: [perl-python] problem: reducing comparison (correction)

2005-02-16 Thread Xah Lee
Xah Lee wrote: > In imperative languages such as Perl and Python and Java, in general it > is not safe to delete elements when looping thru a list-like entity. > (it screws up the iteration) One must make a copy first, and work with > the copy. Correction: When looping thru a list-like entity and

Re: problem with tutor mailing

2005-02-16 Thread Kartic
Ah...I see your predicament after reading Brian's response. I mistook your post to be about getting spammed. Sorry fella, if you are on a mailing list you are going to get ALL mails addressed to the list (whether or not they are responses to your questions). Your only option is to turn off mail

Re: Multiple initialization methods?

2005-02-16 Thread Mathias Waack
alex wrote: > it is possible to define multiple initialization methods so that > the method is used that fits? > > I am thinking of something like this: > > def __init__(self, par1, par2): > self.init(par1, par2); > > def __init__(self, par1): > self.init(par1, None) > > def init

Re: Using 'in' with a Dict

2005-02-16 Thread Steven Bethard
[EMAIL PROTECTED] wrote: I was wondering if the following two "if" statements compile down to the same bytecode for a standard Dictionary type: m = {"foo": 1, "blah": 2} if "foo" in m: print "sweet" if m.has_key("foo"): print "dude" To answer the question you actually asked, you can use dis.dis

Re: adding new functionality to a function non-intrusively!

2005-02-16 Thread peter
indeed it does, so basically everything works except my original solution: def myfunction(a,b): return a+b def _myfunction(a,b): return myfunction(a,b) myfunction = _myfunction oh well, it was enough to puzzle my tiny brain -- http://mail.python.org/mailman/listinfo/python-list

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
"Michele Simionato" <[EMAIL PROTECTED]> writes: > The documentation hides this fact (I missed that) but actually > python 2.3+ ships with the pybsddb module which has all the > functionality you allude too. Check at the test directory for bsddb. Thanks, this is very interesting. It's important f

Re: [perl-python] problem: reducing comparison (erratum)

2005-02-16 Thread Xah Lee
Xah Lee wrote: > In imperative languages such as Perl and Python > and Java, in general it is not safe to delete > elements when looping thru a list-like entity. > (it screws up the iteration) One must make a > copy first, and work with the copy. Correction: When looping thru a list-like entity an

Re: Multiple initialization methods?

2005-02-16 Thread Joe Francia
On 16 Feb 2005 13:31:31 -0800, alex <[EMAIL PROTECTED]> wrote: Hi, it is possible to define multiple initialization methods so that the method is used that fits? I am thinking of something like this: def __init__(self, par1, par2): self.init(par1, par2); def __init__(self, par1): self.i

Re: Newbie question about class operator overloading

2005-02-16 Thread Rory Campbell-Lange
Hi Steve I've been playing around with your two suggestions. The Record class is an elegant solution. It doesn't however help in the case where the class has the following general data structure (something I should have stated originally): class.config1 = param class.config2 = param

Re: Using 'in' with a Dict

2005-02-16 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: >I was wondering if the following two "if" statements compile down to > the same bytecode for a standard Dictionary type: > > m = {"foo": 1, "blah": 2} > > if "foo" in m: > print "sweet" > > if m.has_key("foo"): > print "dude" nope. >>> import dis >>> dis.dis(compile

Re: Using 'in' with a Dict

2005-02-16 Thread Steven Bethard
kowboy wrote: I posted too quickly. A little performance testing told me that has_key is somewhat slower than "in". I used a large number of string keys in my test. See my other post, but the reason has_key is slower is almost certainly that it has to do a LOAD_ATTR: $ python -m timeit -s "m = di

Re: [perl-python] problem: reducing comparison (erratum)

2005-02-16 Thread Xah Lee
Xah Lee wrote: > In imperative languages such as Perl and Python > and Java, in general it is not safe to delete > elements when looping thru a list-like entity. > (it screws up the iteration) One must make a > copy first, and work with the copy. Correction: When looping thru a list-like entity an

Re: Getting milliseconds in Python

2005-02-16 Thread Brian Beck
Fredrik Lundh wrote: Brian Beck wrote: That IS what you want. seconds * 100 = milliseconds are you sure you know what a millisecond is? (duck) Touché. But it was a typo. -- Brian Beck Adventurer of the First Order -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about class operator overloading

2005-02-16 Thread Steven Bethard
Rory Campbell-Lange wrote: Hi Steve I've been playing around with your two suggestions. The Record class is an elegant solution. It doesn't however help in the case where the class has the following general data structure (something I should have stated originally): class.config1 = param

Re: web spider and password protected pages

2005-02-16 Thread jdonnell
"I quickly found a page that starts "Here is an explanation about how to handle password protected sites." ... I hope that teaches you a bit about how to fish, rather than just giving you one. ;-) " Actually, I found a much easier solution, but since you know how to fish I don't need to tell you

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread David Eppstein
In article <[EMAIL PROTECTED]>, Leo Breebaart <[EMAIL PROTECTED]> wrote: > What I can't find an explanation for is why str.join() doesn't > automatically call str() on its arguments, so that e.g. > str.join([1,2,4,5]) would yield "1245", and ditto for e.g. > user-defined classes that have a __str

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
"Michele Simionato" <[EMAIL PROTECTED]> writes: > The documentation hides this fact (I missed that) but actually python > 2.3+ ships > with the pybsddb module which has all the functionality you allude too. > Check at the test directory for bsddb. Oh yow, it looks pretty complicated. Do you have

sampling items from a nested list

2005-02-16 Thread Steven Bethard
So, I have a list of lists, where the items in each sublist are of basically the same form. It looks something like: py> data = [[('a', 0), ... ('b', 1), ... ('c', 2)], ... ... [('d', 2), ... ('e', 0)], ... ... [('f', 0), ... ('g', 2), ...

Re: low-end persistence strategies?

2005-02-16 Thread Fred Pacquier
KirbyBase sounds like something that could fit the bill. -- http://mail.python.org/mailman/listinfo/python-list

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Fred Pacquier <[EMAIL PROTECTED]> writes: > KirbyBase sounds like something that could fit the bill. Hmm, this looks kind of nice. However, when used in embedded mode, the overview blurb doesn't say anything about concurrency control. I don't want to use it in client/server mode, for reasons alre

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread John Machin
On Wed, 16 Feb 2005 14:24:02 -0600, Skip Montanaro <[EMAIL PROTECTED]> wrote: > >John> 4. For consistency, would you like "1" + 2 to produce "12"? > >No, the correct answer is obviously 3. ;-) > Obviously, in awk. Bletch! I once had to help out some users of a system where software developmen

Re: super not working in __del__ ?

2005-02-16 Thread Jeff Shannon
Christopher J. Bottaro wrote: So encapsulating your script in a main function fixes the problem: Not necessarily. because all the objects instantiated in main() will be deleted when main ends, but before the interpreter shuts down, thus the objects will have access to all the symbols in module's _

RE: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Delaney, Timothy C (Timothy)
John Roth wrote: > result = "".join([str(x) for x in list]) As of 2.4, you should use a generator expression here instead (unless you require backwards-compatibility with 2.3). result = ''.join(str(x) for x in iterable) Easier to read, more memory-efficient, potentially faster (depending on

Re: Stable GUI + wxPython memory leak

2005-02-16 Thread Viktor
I just noticed that wxPython is leaking memory?! Playing with wxPython-demo, I started with 19MB used, and ended whith almost 150MB used?! It's wxPython 2.5.3.1 running on Python 2.4. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Leo Breebaart
"Delaney, Timothy C (Timothy)" <[EMAIL PROTECTED]> writes: > John Roth wrote: > > > result = "".join([str(x) for x in list]) > > As of 2.4, you should use a generator expression here instead (unless > you require backwards-compatibility with 2.3). > > result = ''.join(str(x) for x in itera

Re: supress creation of .pyc files

2005-02-16 Thread "Martin v. Löwis"
Thomas Guettler wrote: Is there a way to import a file without creating a .pyc file? That is part of PEP 304, which is not implemented yet, and apparently currently stalled due to lack of interest. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Font size

2005-02-16 Thread Adam
"Adam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > "BOOGIEMAN" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> On Tue, 15 Feb 2005 21:22:43 GMT, Adam wrote: >> >>> Please help me. >>> How do you clear the screen and then display a number with an enlarged >>>

Re: How to implement a file lock ??

2005-02-16 Thread ionel
i'm having some problems... Traceback (most recent call last): File "D:\_ROOT\pywww\opinia\test2.py", line 5, in ? portalocker.lock(log, portalocker.LOCK_EX) File "D:\_ROOT\pywww\opinia\portalocker.py", line 61, in lock win32file.LockFileEx(hfile, flags, 0, 0x, __overlapped) Overflo

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Michael Hoffman
Fredrik Lundh wrote: I've proposed adding a "join" built-in that knows about the available string types, and does the right thing for non-string objects. That would be *so* useful. I frequently have to use the "".join(map(str, mylist)) idiom, which is a wart. -- Michael Hoffman -- http://mail.pyth

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Roy Smith
In article <[EMAIL PROTECTED]>, David Eppstein <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Leo Breebaart <[EMAIL PROTECTED]> wrote: > > > What I can't find an explanation for is why str.join() doesn't > > automatically call str() on its arguments, so that e.g. > > str.join([1

Re: Font size

2005-02-16 Thread Jeff Shannon
Adam wrote: Here's what I'm trying to do. We are running a numbers game at our retirement village and using a roulette wheel to generate the numbers. but this wheel is only about 12 in diameter and is little more than a toy. So we came up with the idea of using a random number generator to gener

Re: Test for structure

2005-02-16 Thread Ben Finney
alex wrote On 17/02/05 02:08: how can I check if a variable is a structure (i.e. a list)? For my special problem the variable is either a character string OR a list of character strings line ['word1', 'word2',...] You're trying to apply the LBYL principle. My bet is that your "special problem" c

Re: sampling items from a nested list

2005-02-16 Thread Michael Spencer
Steven Bethard wrote: So, I have a list of lists, where the items in each sublist are of basically the same form. It looks something like: ... Can anyone see a simpler way of doing this? Steve You just make these up to keep us amused, don't you? ;-) If you don't need to preserve the ordering, wo

Re: web spider and password protected pages

2005-02-16 Thread Peter Hansen
jdonnell wrote: "I quickly found a page that starts "Here is an explanation about how to handle password protected sites." ... I hope that teaches you a bit about how to fish, rather than just giving you one. ;-) " Actually, I found a much easier solution, but since you know how to fish I don't nee

Re: PythonCard and Py2Exe

2005-02-16 Thread Peter Hansen
[EMAIL PROTECTED] wrote: You should move these 'import ...' statements to your *script* so that py2exe doesn find them, not to the setup script. Removing import statements only returns this error message before the package compiles: = "custdb", 'setup' is not defined No files are returned. Please u

Re: adding new functionality to a function non-intrusively!

2005-02-16 Thread Terry Reedy
"peter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > indeed it does, so basically everything works except my original > solution: > > def myfunction(a,b): >return a+b > > def _myfunction(a,b): > return myfunction(a,b) > myfunction = _myfunction > > oh well, it was enou

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread Jeff Shannon
Roy Smith wrote: What I can't find an explanation for is why str.join() doesn't automatically call str() on its arguments, so that e.g. str.join([1,2,4,5]) would yield "1245", and ditto for e.g. user-defined classes that have a __str__() defined. That would be the wrong thing to do when the argumen

<    1   2   3   >