Re: Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-16 Thread Fredrik Lundh
"Scott" <[EMAIL PROTECTED]> wrote: > >>The trouble I have is that there are no PC or PCbuild > >>subdirectories in C:\Python24. Where do I find these? > > > > > > As the quoted URL says (2nd para): > > """ > > To build extensions using these instructions, you need to have a copy > > of the Python

Re: difference between class methods and instance methods

2005-02-16 Thread Steven Bethard
John M. Gabriele wrote: 1. Are all of my class's methods supposed to take 'self' as their first arg? If by "class's methods" you mean methods on which you called classmethod, then no, they shouldn't take a 'self' parameter, they should take a 'cls' parameter because the first argument to the func

Re: Pausing a program - poll/sleep/threads?

2005-02-16 Thread Paul Rubin
"Simon John" <[EMAIL PROTECTED]> writes: > So, how would I make a Python program automatically call a function > after a preset period of time, without the Python process running in > the foreground (effectively single-tasking)? See the signal module and use the alarm signal. -- http://mail.pytho

Re: Font size

2005-02-16 Thread Fredrik Lundh
"Adam" <[EMAIL PROTECTED]> wrote: > So we came up with the idea of using a random number generator to > generate numbers from 0 to 36 and display them in large figures on my > laptop. This is for the benefit of those people who are hard of hearing. > They like to see what is happening. here's on

Pausing a program - poll/sleep/threads?

2005-02-16 Thread Simon John
I'm writing a PyQt network client for XMMS, using the InetCtrl plugin, that on connection receives a track length. To save on bandwidth, I don't want to be continually querying the server for updates (e.g. has the current track finished yet?) so I figured the best thing to do is just update after

difference between class methods and instance methods

2005-02-16 Thread John M. Gabriele
I've done some C++ and Java in the past, and have recently learned a fair amount of Python. One thing I still really don't get though is the difference between class methods and instance methods. I guess I'll try to narrow it down to a few specific questions, but any further input offered on the su

Re: Font size

2005-02-16 Thread [EMAIL PROTECTED]
Adam wrote: > "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

Re: low-end persistence strategies?

2005-02-16 Thread Nick Craig-Wood
Paul Rubin wrote: > The issue with using an rdbms is not with the small amount of code > needed to connect to it and query it, but in the overhead of > installing the huge piece of software (the rdbms) itself, and keeping > the rdbms server running all the time so the infrequently used app can

Re: sampling items from a nested list

2005-02-16 Thread Michael Spencer
Steven Bethard wrote: Michael Spencer wrote: 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? ;-)

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

2005-02-16 Thread john san
Actually the "windows" running very good under the xbox-NTOS via xboxmediacenter. its just limited functions(not easy to programming the "windows" prog.), if we can find WxPython-like can be ported (I can import * from it to my xboxPython) )it will be a great great . You will have HD scre

Re: sampling items from a nested list

2005-02-16 Thread Michael Spencer
Michael Spencer wrote: >>> def resample2(data): ... bag = {} ... random.shuffle(data) ... return [[(item, label) ... for item, label in group ... if bag.setdefault(label,[]).append(item) ... or len(bag[label]) < 3] ...

Re: low-end persistence strategies?

2005-02-16 Thread Michele Simionato
What happens if for any reason the application crashes? Locked files will stay locked or not? And if yes, how do I unlock them? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: sampling items from a nested list

2005-02-16 Thread Steven Bethard
Michael Spencer wrote: 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? ;-) Heh heh. I wish. It's

Re: PythonCard and Py2Exe

2005-02-16 Thread pipedreamergrey
The Error: (Most recent call last): C:\Documents and Settings\Gateway User\ Desktop\custdb\setup.py", line 1, name = "custdb", 'setup' is not defined There may be a single word infront of 'setup' on the fourth line, it scramble on my screen because I have to use a screen capture to read th

Re: Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-16 Thread Simon John
What's the difference between ctypes, SWIG and SIP? I've used SWIG to "convert" C source to Python (as I believe SIP does?), so does ctypes wrap functions from binaries (e.g. DLL's)? -- http://mail.python.org/mailman/listinfo/python-list

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

2005-02-16 Thread Michael Spencer
peter wrote: brain reset and understood thx a lot for all your answers Peter Now that you've got reset, you might want to consider an alternative solution: def fA(input): return input oldfA = fA # Hold a reference to the the old function def newFA(input): "Do something new" return oldfA

Derived class and deepcopy

2005-02-16 Thread Philip Smith
Hi If I derive a class (eg Matrix) from list I presume this implies the classic OOP 'is a' relation between the derived and super class. I therefore presume I can use a derived class in any context that I can use the superclass. In the given example I want to apply deepcopy() to the Matrix ins

Re: Iterator / Iteratable confusion

2005-02-16 Thread Michael Spencer
Adam DePrince wrote: How is a spencerator [an iterator that doesn't return itself unmodified on iter] > different than itertools.tee? Taking your question literally, it changes the behavior of an itertools.tee object 'tee', so that iter(tee) returns tee.__copy__(), rather than tee itself. It wa

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
John Lenton <[EMAIL PROTECTED]> writes: > flock(fp, LOCK_EX) # block until can write ... > Of course I'm probably overlooking something, because it really can't > be this easy, can it? Yes, maybe so. I'm just way behind the times and didn't realize flock would block until existing inc

Re: low-end persistence strategies?

2005-02-16 Thread John Lenton
On Tue, Feb 15, 2005 at 06:57:47PM -0800, 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 is you just wa

Re: Iterator / Iteratable confusion

2005-02-16 Thread Michael Spencer
Terry Reedy wrote: "Michael Spencer" <[EMAIL PROTECTED]> wrote in message We are both interested in the murky edges at and beyond conventional usage. ... I am quite aware that multiple iterators for the same iterable (actual or conceptual) can be useful (cross products, for example). But I am d

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
"Michele Simionato" <[EMAIL PROTECTED]> writes: > This was my impression too :-( The ZODB is way much easier to use so > at the end I used just that. Apparently the bsddb stuff is more > complicated than needed and the documentation sucks. However, > it does satisfy your requirements of being alrea

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Jamey Cribbs <[EMAIL PROTECTED]> writes: > The only time there might be trouble is if two clients try to write to > the same table (physical file) at the same time. Yes, that's what I'm concerned about. > When it writes to a file, KirbyBase opens it in append mode (r+, I > think). My guess woul

Re: low-end persistence strategies?

2005-02-16 Thread Michele Simionato
Paul Rubin: > Oh yow, it looks pretty complicated. Do you have any example code > around that uses the transaction stuff? If not I can try to figure it > out, but it looks like it would take significant effort. This was my impression too :-( The ZODB is way much easier to use so at the end I use

Re: Multiple initialization methods?

2005-02-16 Thread xtian
Several people have told you about dispatching to the different methods based on the different parameters. Another technique is to have the different initialisation methods be static or class methods. For example, the python dictionary type can be instantiated in a variety of ways: dict(a=1, b=2,

Re: low-end persistence strategies?

2005-02-16 Thread Jamey Cribbs
Paul Rubin wrote: Jamey Cribbs <[EMAIL PROTECTED]> writes: Either of these server scripts would have to be running as a process either on your web server or on another server on your network in order for them to work. I don't know if that would be an issue for you. Yes, that's the whole point. I

Re: [perl-python] problem: reducing comparison

2005-02-16 Thread gene . tani
This could have been a really unique thread: 15 messages, 1 author -- http://mail.python.org/mailman/listinfo/python-list

Re: low-end persistence strategies?

2005-02-16 Thread Paul Rubin
Jamey Cribbs <[EMAIL PROTECTED]> writes: > Either of these server scripts would have to be running as a process > either on your web server or on another server on your network in > order for them to work. I don't know if that would be an issue for you. Yes, that's the whole point. I don't want

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

2005-02-16 Thread Kent Johnson
rbt wrote: ## for fs in fs_objects: ## ##for f in fs[2]: ##if f in file_skip_list: ##print f ##fs[2].remove(f) ## ##for d in fs[1]: ##if d in dir_skip_list: ##print d ##

Problem using/installing numarray

2005-02-16 Thread maxwell
I'm trying to use the 'numarray' package (v1.1.1) under Python 2.4 running under CygWin. I initially downloaded the Windows executable version of the numarray package, and installed it under C:\program files\python\lib\site-packages. That works with the Windows version of Python, but not the CygW

Re: Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-16 Thread Scott
John Machin wrote: > On Wed, 16 Feb 2005 20:57:18 -0500, Scott > <[EMAIL PROTECTED]> wrote: > > >>I've installed Python 2.4 under WinXP and am attempting to >>create an extension module using the steps outlined here: >>http://python.org/doc/2.4/ext/win-cookbook.html >> >>I'm specifically trying to

Re: low-end persistence strategies?

2005-02-16 Thread Jamey Cribbs
Paul Rubin wrote: 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,

Re: Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-16 Thread John Machin
On Wed, 16 Feb 2005 20:57:18 -0500, Scott <[EMAIL PROTECTED]> wrote: >I've installed Python 2.4 under WinXP and am attempting to >create an extension module using the steps outlined here: >http://python.org/doc/2.4/ext/win-cookbook.html > >I'm specifically trying to perform step 6. Creating a bran

make_obcallback(): could not import mod_python.apache

2005-02-16 Thread Christopher
I am running: Fedora Core 1 Python 2.4 Apache 1.3.3 mod_python 2.7.11 When I try to access the test mptest.py file I receive: > Internal Server Error When starting apache in my error_log I find: > [Wed Feb 16 20:41:44 2005] [warn] Loaded DSO libexec/mod_python.so uses plain Apache 1.3 API, thi

Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-16 Thread Scott
I've installed Python 2.4 under WinXP and am attempting to create an extension module using the steps outlined here: http://python.org/doc/2.4/ext/win-cookbook.html I'm specifically trying to perform step 6. Creating a brand new project using VC6. The trouble I have is that there are no PC or PCbui

Re: web spider and password protected pages

2005-02-16 Thread Peter Hansen
jdonnell wrote: "Nevertheless, perhaps you'll still post the answer here so that others who come along later can benefit from your experience in the same way that you benefited from reading whatever page you found (even if you didn't benefit from my suggestions...). " Your funny :) Perhaps you shou

Re: web spider and password protected pages

2005-02-16 Thread jdonnell
"Nevertheless, perhaps you'll still post the answer here so that others who come along later can benefit from your experience in the same way that you benefited from reading whatever page you found (even if you didn't benefit from my suggestions...). " Your funny :) Perhaps you should take your ow

Re: Stable GUI + wxPython memory leak

2005-02-16 Thread Peter Hansen
Viktor wrote: 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. On which platform? And how are you measuring this apparent memory consumption? And what happens (assu

Re: Font size

2005-02-16 Thread Peter Hansen
Adam wrote: 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 generate numbers from 0 to 36 and d

Re: PythonCard and Py2Exe

2005-02-16 Thread pipedreamergrey
> You should move these 'import ...' statements to your *script* so that > py2exe doesn find them, not to the setup script. > > Thomas Removing import statements only returns this error message before the package compiles: = "custdb", 'setup' is not defined No files are returned. -- http://ma

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

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

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

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

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

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

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

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

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

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

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

  1   2   3   >