Re: Changing argument value

2007-12-14 Thread Stargaming
On Thu, 13 Dec 2007 22:52:56 +0100, Bruno Desthuilliers wrote: > flyfree a écrit : [snip] >> What is the difference between "y = [3,4]" and "y[0]=3 y[1] =4 " > > In the first case, you rebind the local name y to a new list object - > and since the name is local, rebinding it only affects the loca

Re: replacing built-in exception types

2007-12-14 Thread Stargaming
On Tue, 11 Dec 2007 12:51:52 -0800, Nishkar Grover wrote: > I'm trying to replace a built-in exception type and here's a simplified > example of what I was hoping to do... > > > >>> import exceptions, __builtin__ > >>> > >>> zeroDivisionError = exceptions.ZeroDivisionError I don't know why y

Re: How to refer to the current module?

2008-01-07 Thread Stargaming
On Mon, 07 Jan 2008 05:21:42 -0800, Mike wrote: > I want to do something like the following (let's pretend that this is in > file 'driver.py'): > > #!/bin/env python > > import sys > > def foo(): > print 'foo' > > def bar(arg): > print 'bar with %r' % arg > > def main(): > getattr

Re: helper function in a class' namespace

2008-01-31 Thread Stargaming
On Thu, 31 Jan 2008 20:51:23 +0100, Helmut Jarausch wrote: > Hi, > > the following code works fine > > def Helper(M) : >return 'H>'+M String concatenation is generally considered unpythonic, better use string interpolation:: 'H> %s' % (M,) > class A(object): >def __init__(self,Ms

Re: Naive idiom questions

2008-01-31 Thread Stargaming
On Thu, 31 Jan 2008 15:30:09 -0600, Terran Melconian wrote: > * Is there a way to get headings in docstrings? > > I want to create my own sections, like "OVERVIEW", "EXAMPLES", > "AUTHORS", "BUGS", etc. I can't figure out any way to do this. In > perldoc, I can easily use =head1, but

Re: Better way to negate a boolean list?

2008-02-10 Thread Stargaming
On Sun, 10 Feb 2008 08:46:24 +0100, David Trémouilles wrote: [snip] > I tried: > >>> map(not, boolean_list) > but it seems that "not" is not a function. `not` is not a function, indeed. It is a keyword, allowing you to write ``not x`` instead of ``not(x)``. You can of course write a function t

Re: catching object

2008-03-12 Thread Stargaming
On Wed, 12 Mar 2008 01:05:06 +0100, Igor V. Rafienko wrote: > Hi, > > > I was wondering if someone could help me explain this situation: > > h[1] >>> import inspect > h[1] >>> inspect.getmro(ValueError) > (, , > , , 'object'>) > h[2] >>> try: > raise ValueError("argh") > except object: >

Re: About reading Python code

2008-03-16 Thread Stargaming
ds of tracing (apart from debugging, which is rather unpopular in Python) because you have one *extra* level (the interpreter) between your machine and your code. HTH, Stargaming -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutable and Mutable Types

2008-03-17 Thread Stargaming
On Mon, 17 Mar 2008 10:40:43 +, Duncan Booth wrote: > Here's a puzzle for those who think they know Python: > > Given that I masked out part of the input, which version(s) of Python > might give the following output, and what might I have replaced by > asterisks? > a = 1 b = >>

Re: Immutable and Mutable Types

2008-03-17 Thread Stargaming
On Mon, 17 Mar 2008 16:03:19 +, Duncan Booth wrote: > For the answer I actually want each asterisk substitutes for exactly one > character. Played around a bit and found that one: Python 3.0a3+ (py3k:61352, Mar 12 2008, 12:58:20) [GCC 4.2.3 20080114 (prerelease) (Debian 4.2.2-7)] on linux2 T

Re: Need help with OptionParser

2008-03-25 Thread Stargaming
On Tue, 25 Mar 2008 05:42:03 -0700, hellt wrote: [snip] > usage = "usage: %prog [options]" > parser = OptionParser(usage) > parser.add_option("-f", "--file", dest="filename", > help="executable filename", > metavar="FILE") > parser.add_option("-b"

<    1   2