dict__
>>> X.__dict__['__dict__']
and
>>> class Y(object):
... def _getdict(self): print '_getdict'; return self._dict
... __dict__=property(_getdict)
... def __init__( self ):
... self._dict = CustomDict( foo = 'bar' )
...
>>> y = Y()
>>> y.__dict__
_getdict
{'foo': 'bar'}
>>> y._dict
{'foo': 'bar'}
>>> y.foo
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: 'Y' object has no attribute 'foo'
>>> def ga(self, attr): print '__getattr__(%s)'%attr; return
>>> self.__dict__[attr]
...
>>> Y.__getattr__ = ga
>>> y.foo
__getattr__(foo)
_getdict
'bar'
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ems of
a generator from the outside, e.g.,
def gfoo(x, y):
while True:
yield x**2 + y**2
ifoo = gfoo('dummy','dummy') # or first pair
for ifoo.x, ifoo.y in pairs: print ifoo.next()
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
And
all
that in the face of the fact that much of the problem will be engineering
consensus,
not engineering technical solutions. So are you excited? Good luck ;-)
Probably the best anyone with any excitement to spare could do is ask Martin
what he could use help with, if anything. He'd probably not like muddying any
existing clear visions and plans with impractical ramblings though ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
and yielding that to tell the world the latest. Since
only attributes
are being modified, the original state binding could be used and the
generator's yielded
value could be ignored, but it could be handy if the generator is passed around
IWT.
The world could also feed info in as attributes of state. And other generators
could share
the same external state variable and all kinds of weird things could be built
;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
nt call last):
> File "", line 1, in
>TypeError: expected 0 arguments, got 1
>
>>> def square(xbox):
... while True: yield xbox[0]*xbox[0]
...
>>> xbox = [3]
>>> g = square(xbox)
>>> g.next()
9
>>> xbox[0]=4
>
(vars(x))
>>> type(x.__dict__)
>>> vars(x)['?']
'THIS ITEM NOT AVAILABLE'
>>> type(x)
>>> type(x).__dict__
>>> type(x).__dict__['__dict__']
>>> type(x).__dict__['__dict__'].__get__
of LatInt might work, since it's a string (so is Latitude))
>TypeError: cannot add type "int" to string
^^ ^^^ ^^
This is not lying ;-)
>
>
>I tried print repr(filename) and it returned the actual filename:
>'n16w099.asc' , 'n17w062.asc' , etc.
So you can see Latitude would be '16' '17' etc. right?
On to the next traceback ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
val(((8, PLUS, 6), TIMES, (MINUS, 2)))
PLUS(8, 6)
MINUS(2, None)
TIMES(14, -2)
-28
>>> seqeval((MINUS, (8, PLUS, 6), TIMES, (MINUS, 2)))
PLUS(8, 6)
MINUS(14, None)
MINUS(2, None)
TIMES(-14, -2)
28
>>> list(seqeval((i, TIMES, j, PLUS, k)) for i in (2,3) for j in (10,100) for
>>> k in (5,7))
TIMES(2, 10)
PLUS(20, 5)
TIMES(2, 10)
PLUS(20, 7)
TIMES(2, 100)
PLUS(200, 5)
TIMES(2, 100)
PLUS(200, 7)
TIMES(3, 10)
PLUS(30, 5)
TIMES(3, 10)
PLUS(30, 7)
TIMES(3, 100)
PLUS(300, 5)
TIMES(3, 100)
PLUS(300, 7)
[25, 27, 205, 207, 35, 37, 305, 307]
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
o get the data and then prints the message. E.g.,
program1.print_the_message('John')
instead of
program1.inst.John()
No class needed.
OTOH, if you are going to use a class, you might want to name it
capitalized (more conventional) and derive from object, or subclass
from something else if it makes sense. I.e. class Klass(object): ...
What kind of "database" are you accessing? An RDBMS? A CSV text file?
A directory full of named single-line files (ugh), or?
How often will you access the data? Are you the only one?
Requirements, requirements ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ilias_lazaridis.py
peter 16
anton 21
name=peter, age=16,
name=anton, age=21,
(the first for user in users loop presumes knowledge of the field names name
and age.
The second gets them automatically from the names loaded in the load method from
the first line of the text file. The second l
; print "%(key)s" % d
'key'
test
>>> print "%((1,2))s" % d
'(1,2)'
(1, 2)
Right
>>> d[123] = 'onetwothree'
>>> print "%(123)s" % d
'123'
123
onetwothree
Note recursive printing of convert
te" virtual blocks when it gets real
zero blocks to write from a user, or even with file system copy utils?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
n just permit only the
>http: protocol?
>
How about finding the browser via .html association and then letting that
handle the url? E.g., slong the lines of
>>> import os
>>> ft = os.popen('assoc .html').read().split('=',1)[1].strip()
>>> ft
'MozillaHTML'
>>> os.popen('ftype %s'%ft).read().split('=',1)[1].strip()
'D:\\MOZ\\MOZILL~1\\MOZILL~1.EXE -url "%1"'
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ree:
(S (NP (NP The horse)
(VP raced
(PP past
(NP the barn
(VP fell)
.)
IIUC, that's the way I parse it too ;-)
(I.e., "The horse [being] raced past the barn fell.")
BTW, the online response has some clickable elements in the diagram
to get to definitions of the terms.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
oo
...
popdir
log,file,c:\temp\foo\log.txt
log,on
...
log,off
etc. etc)
Of course, you can jigger an INI file to contain any info you want also,
even using the windows
{Get,Write}PrivateProfile{String,Int,Section,SectionNames}
API functions, which like many MS APIs IME of yore seem to work simply if you
conform to
their usage preconceptions, but punish you with info discovery hell otherwise
;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
cant fraction of the total execution time. There is little or no
>point in avoiding generators due to a misplaced and foolish attempt to
>optimise your code.
>
I show an advantage favoring generator resumption vs function call:
>>> from time import clock
>>> def f(): return clock()
...
>>> def g(): yield clock(); yield clock()
...
>>> max(f()-f() for x in xrange(1))
-9.2190462142316409e-006
>>> max(f()-f() for x in xrange(1))
-9.2190462139818408e-006
>>> max(float.__sub__(*g()) for x in xrange(1))
-7.5428559682677587e-006
>>> max(float.__sub__(*g()) for x in xrange(1))
-7.5428559682677587e-006
>>> max(float.__sub__(*g()) for x in xrange(1))
-7.5428559682677587e-006
(It'll probably go ten times faster on a recent box ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
at if '\n' *doesn't* signify a line break on the Mac,
>then it may exist in the body of the text - and trigger ``ending =
>'\n'`` prematurely ?
>
Are you guaranteed that text bodies don't contain escape or quoting
mechanisms for binary data where it would be a mistake to convert
or delete an '\r' ? (E.g., I think XML CDATA might be an example).
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
(s)
>>> binascii.unhexlify(h)
'\x00\x01\x02\x03ABCD0123'
>>> b64 = binascii.b2a_base64(s)
>>> binascii.a2b_base64(b64)
'\x00\x01\x02\x03ABCD0123'
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
106 SocialSecurity: 123456789'
[Person('David'), Person('Ernesto')]
ssdict keys: [123456789, 476892771999L]
Name: David Age: 108 SS: 476892771999
Name: Ernesto Age: 25 SS: 123456789
if you want to try this on a file, (we'll use the source itself here
since it includes valid example data lines), do something like:
>>> import ernesto
>>> info = ernesto.extract_info(open('ernesto.py'))
AssertionError: Bad second line after "Name: Ernesto" line:
'Age: 44 Brithdy: 040106 SocialSecurity: 123456789\n'
>>> info
[Person('David'), Person('Ernesto')]
tweak to taste ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
s
>that if I just assign to the list variable it just modifies the local
>(to the function) name space, and that those changes aren't reflected
>in the list in the original name space.
>
>I believe there are some ways around this, but I haven't found one that
>would not require any special handling in either the code calling the
>client stub or the original functions. I want to maintain transparency.
>
>etv
>
Good luck ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 07 Feb 2006 18:10:05 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
[...]
>< ernesto.py >-
[...]
Just noticed:
>substrings = line.split()
>if substrings and isinstance(substrings, list) and substrings
s module().
OTOH, I could see wanting to define properties, and access module.latest_foo
and have it choose dynamically from versioned stuff, or something like that.
Of course you can write module.get_latest_foo() as an ordinary function, and
not be bothered with subclassing and jimmying sys.module
large
else:
large,also
but that reads gawdawfully. (So, I imagine, does about any code hitting the
offset limit ;-)
If it's a matter of too many elifs, the OP could break that more readably, e.g.
(untested)
done=True
if cond:
bla
elif c2:
bla 2
Personally, I'd always use (depending on guesses regarding lengths of
>lists) [x for x in l1 if x in l2] or the setified equivalent, of course.
>
Perhaps newbies should be advised that
[x for x in l1 if x in set(l2)]
is not a (well) setified equivalent? I could see them being tempted.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
would be welcome. :-)
>>
>
>ok, sorry, but subject is very explicit!
>
Should we expect your "WordPress Python Library 1.0" to do to words
what the dry cleaners do to suits and shirts then? ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
to be produced by the iterable,
though you might need to use '==' instead of 'is' depending on your choice.
But e.g., I don't think I'd write
x = Exception # weird sentinel choice
for x in mystring:
print x, ord(x)
if x is Exception:
print 'null sequence'
None probably works well a lot of the time, but not always.
Similarly ''. Seems like a builtin sentinel binding like sentinel = object()
might be handy to standardize usage.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
kup info access effectively atomic),
but that's a general idea. I don't know what other thread interaction issues
you may have with the state of possibly mutable data being printed.
This is just an idea for an approach. I may not be understanding your problem
at all ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
hon-list/2005-March/270760.html
Also for more general (not just python syntax) parssing the pyparsing
program referenced in the followon post looks very nice, though I have not
tried it.
http://pyparsing.sourceforge.net/
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
is being converted to . Seems not unlikely that the rest are
also being converted, and to unicode. You just wouldn't notice a glitch when
unicode is converted to any usual western text encoding.
OTOH, if the intent (which I doubt) of the non-python client were to pass
through
a block of pre-formatted XML as such (possibly for direct pasting into e.g. web
page XHTML?)
then a way to avoid escaping every & and < would be to use CDATA to encapsulate
it. That
would have to be fixed on that end.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ly for a way of estimating
better numbers based
on flawed data (though that was what he apparently thought his best option was,
using the
rounded text tables as data). I'd bet that is not his best option, especially
since distributions
of actual roundoff errors can be weird. There must be
SimpleXMLRPCServer.CGIXMLRPCRequestHandler.handle_xmlrpc(self,
>request_text)
>####
>class Foo:
>def settings(self):
>return os.environ
>def echo(self, something):
>logger = logging.getLogger()
> logger.debug(something)
repr it, unless you know ;-)
>return something
>def greeting(self, name):
>return "hello, " + name
>
># these are used to run as a CGI
>handler = LoggingXMLRPCRequestHandler()
>handler.register_instance(Foo())
>handler.handle_request()
>
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
27;__doc__', '__name__', 'fooholder']
>>> fooholder.append(lambda: 'not that anonymous ;-)')
>>> fooholder
[, at 0x02EE8D14>]
>>> [f.__name__ for f in fooholder]
['', '']
>>> fooholder[0](), fooholder[1]()
statement 1
statement 2
statement etc
(None, 'not that anonymous ;-)')
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
eError, 'x must be non-negative, not %r' %x
return math.sqrt(x)
And then, why not allow an anonymous defs as expressions anywhere expressions
can go?
(indentation problems are actually easy to overcome).
Anyway, in general, I'd rather be persuaded than forced ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ded revs (none), missing ['02'], actual other (none)
patch 116455: recommended revs (none), missing ['01'], actual other (none)
patch 116602: recommended revs (none), missing ['01'], actual other ['02']
patch 116606: recommended revs (none), missing ['01'], actual other (none)
patch 117000: recommended revs (none), missing ['05'], actual other ['01']
patch test23: recommended revs ['02', '03'], missing (none), actual other ['01']
patch test_0: recommended revs (none), missing ['02', '03', '01'], actual other
(none)
patch test_2: recommended revs ['02', '01'], missing ['03'], actual other (none)
patch testok: recommended revs ['02', '03', '01'], missing (none), actual other
(none)
Oops, didn't pyt multiple revs in sort order. Oh well, you can do that if you
like.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
x in recc_ary])
>serv_dct = dict([x.split("-") for x in serv_ary])
>
But what about multiple revs for the same patch?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
quality with
each element in half the list. Checking for membership in a set should
be much faster for any significant size set/list. I.e., just changing to
a = set(range(1, 10, 5))
should help. I assume those aren't examples of your real data ;-)
You must have a lot of memory if
ect at 0x02EF16EC>, ('hi',))
>>> bmg = b.bm
>>> bmg('hello')
(<__main__.bob object at 0x02EF16EC>, ('hello',))
>>> class C: pass
...
>>> c=C()
>>> c.m = b.bm
>>> c.m('greets')
(<__main__.bob object at 0x02EF16EC>, ('greets',))
>>> C.M = b.bm
>>> C.M('saludos')
(<__main__.bob object at 0x02EF16EC>, ('saludos',))
>>> c.M('amigos')
(<__main__.bob object at 0x02EF16EC>, ('amigos',))
Obviously "self" has nothing to do with c or C etc.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 07 May 2005 14:03:34 +1000, Maurice LING <[EMAIL PROTECTED]> wrote:
>John Machin wrote:
>> On Sat, 07 May 2005 02:29:48 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
>>
>>
>>>On Sat, 07 May 2005 11:08:31 +1000, Maurice LING <[EMAIL PROTECTED]&g
>>> Borg._shared_states['Duck']
{'covering': 'feathers'}
>>> Borg._shared_states['Rabbit']
{'covering': 'fur'}
Since you are calling Borg.__init__(self), you could specify some other
classifier than the implicit class name, e.g., Borg.__init__(self, 'feathered')
vs Borg.__init__(self, 'furred') and use that as the key in the setdefault call.
As mentioned in the recipe discussion, new style classes differ somewhat, but
you
can accomplish the same functionality, just that if you have special things like
__slots__ or descriptors, you may have to think about how they might interact
with
your shared state access.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
g': 'feathers'}
>>> class Rabbit(Borgomat):
... def __init__(self):
... self.covering = 'fur'
...
>>> bugs = Rabbit()
>>> bugs.covering
'fur'
>>> Rabbit._shared_state
{'covering': 'fur'}
>>> bugs.food = 'carrots'
>>> Rabbit._shared_state
{'food': 'carrots', 'covering': 'fur'}
>>> roger = Rabbit()
>>> roger.food
'carrots'
Oops, forgot to use the optional keyword arg in Duck ...
>>> donald = Duck(food='Disney duck chow')
>>> donald.food
'Disney duck chow'
>>> donald.covering
'feathers'
>>> daffy.food
'Disney duck chow'
Some shared state may not be all that appropriate ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
gt;Is there a way to force Python to check the definition of symbol ?
>
If _are_ going to test your functions, how long will it take to discover that
a function doesn't exist?
IOW, do you mean that if you know a function is defined, you will assume
it is free of dummy errors? Such faith ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
>best alternative to Perl, and trying to know what it is fit for.
>
I see you as being in a place where they give away all kinds
of musical instruments for free, and I hear you saying you
want to know what they are "fit" for ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
idea and we're in python riddle country...)
>
Another:
>>> L = ["11", "22", "33"]
>>> S = "xyzzy text we've got xyzzy text xyzzy yeah yeah yeah"
>>> ''.join([(i%2 and [n()] or [s()])[0] for s, n in
... [(iter(S.split('xyzzy')).next, iter(L).next)] for i in
xrange(2*len(L)+1)])
"11 text we've got 22 text 33 yeah yeah yeah"
Or maybe:
>>> ''.join(map(lambda x,y:(x or '')+(y or ''), S.split('xyzzy'), L))
"11 text we've got 22 text 33 yeah yeah yeah"
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ng.
>When I run this script on Linux, each file is 13,890 bytes and contains
>no "\x00" characters. This piece of code::
>
I don't want to think about the _exact_ explanation, but try the above
(untested ;-)
and see if the symptoms change ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
11010000101111'
>>> len(prb(95.895).split('.')[1])
46
>>> prb(95.895*2**46)
'10001010000101111010000101111'
>>> int(prb(95.895*2**46),2)
6748010722917089L
>>> int(prb(95.895*2**46),2)*1
6748010722917089L
>>> prb(int(prb(95.895*2**46)
t, you're depending too much on mind reading ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
=set()
>>> for el in data:
... if el in once: more.add(el)
... else: once.add(el)
...
>>> once-more
set([0.900000002, 0.40002])
Not the most efficient space-wise, not sure about speed.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
for s,e in sorted(spans):
... if start is None: start, end = s,e; continue
... if s <= end: end = e; continue
... yield start, end
... start,end = s,e
... if start is not None: yield start, end
...
>>> spans = [(0,3), (4,7), (2,5),
uce(lambda L,se: (L and se[0]<=L[-1][1] and (L.append((L.pop()[0],
>>> se[1])) or L)) or L.append(se) or L ,sorted(spans), [])
[(0, 7), (9, 17)]
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 10 May 2005 23:53:43 GMT, Jim Sizelove <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
[...]
>> Maybe (not tested beyond what you see ;-)
I had that feeling ... somehow the word "max" was trying to get my attention,
but I posted without figuring out why ;-/
>
ily just machine code via low level C or ASM, but I haven't checked
current status re that.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ties
from the system icon, or get there by Alt-Space P etc.
You can change the fg/bg colors also, though not a big selection either. I'm
not a fan of idle
for my system (NT4) though it looks nice enough and has more fonts to choose
from.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
e', 's', 't', '.', 't', 'x', 't']
>>> print '-->>%s<<--'%b1
-->>c: est.txt<<--
Escaping the escape:
>>> b1="c:\\test.txt"
>>> print '-->>%s<<--'%b1
-->>c:\test.txt<<--
Using raw string format (prefixed r on string), which won't work if
string ends in backslash BTW)
>>> b1=r"c:\test.txt"
>>> print '-->>%s<<--'%b1
-->>c:\test.txt<<--
To see the single tab character in your original
>>> b1="c:\test.txt"
>>> b1[2]
'\t'
>>> ord(b1[2])
9
BTW, you might want to use os.system('start notepad ' + b1)
if you want an independent process and not wait for notepad to finish.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
r foo/bar/s
or
dir/s foo/bar
I don't know why MS used backslashes when unix had a perfectly good path syntax
(not to mention drive letter idiocy). Maybe some legal idiocy, wanting to be
different to be safe from SCO types?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 12 May 2005 17:41:29 +0200, Brian Quinlan <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>> If you make your console 96 wide and set the font to Lucida Console Bold
>> 24point,
>> it will probably expand to near full screen on 1024x768. You can set the
>
On Thu, 12 May 2005 16:30:36 GMT, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>On Thu, 12 May 2005 15:14:09 GMT, [EMAIL PROTECTED] (Bengt Richter) declaimed
>the following in comp.lang.python:
>
>
>>
>> I don't know why MS used backslashes when unix had a per
found how to do this in a few
>> seconds in PHP. I searched the Python docs for "class name", "classname",
>> "introspection" and "getclass". I looked in the Class section of the
>> tutorial also and also the Programming FAQ. The "
On 13 May 2005 09:37:07 -0700, "Matt" <[EMAIL PROTECTED]> wrote:
>
>Christopher J. Bottaro wrote:
>> Christopher J. Bottaro wrote:
>>
>> > Bengt Richter wrote:
>> >
>> >> >>> type(obj)
>> >>
>> >>
On 13 May 2005 14:59:13 -0700, "Matt" <[EMAIL PROTECTED]> wrote:
>
>Bengt Richter wrote:
[...]
>> I'm afraid inheriting explicitly from object will make the exception
>unraisable.
>> Exceptions are still based on "classic" classes for some
and STORE_FAST etc, but you can see
what's
happening above. I.e., on return from the function call, the returned sequence
(we know it's
a tuple in your example, but it could be some other sequence thing) is upacked
and its elements
are bound to the individual names, just as individual "assignments" would do.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
omatically.
In short, a whole unopened deluxe set of programming Legos is at your elbow,
besides the
pieces you have encountered so far. Have fun ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
', 'tuple'), 'BC', 'Sandra']
>>> a
'A'
>>> tup
('a', 'tuple')
>>> b
'B'
>>> c
'C'
>>> d
'Sandra'
>>> dis.dis(compile("a, tup, (b,c), d = ['A', ('a', 'tuple'), 'BC',
>>> 'Sandra']",'','exec'))
1 0 LOAD_CONST 0 ('A')
3 LOAD_CONST 6 (('a', 'tuple'))
6 LOAD_CONST 3 ('BC')
9 LOAD_CONST 4 ('Sandra')
12 BUILD_LIST 4
15 UNPACK_SEQUENCE 4
18 STORE_NAME 0 (a)
21 STORE_NAME 1 (tup)
24 UNPACK_SEQUENCE 2
27 STORE_NAME 2 (b)
30 STORE_NAME 3 (c)
33 STORE_NAME 4 (d)
36 LOAD_CONST 5 (None)
39 RETURN_VALUE
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
f foo(nlines=1):
7: for i, line in enumerate(open(sys.argv[1])):# test default 'r'
8: print '%4s: %s' %(i+1, line.rstrip())
9: if i+1 >= nlines: break
10: print '< 3 lines of %r' % sys.argv[1]
11: foo(3)
12:
<
cmp=None, key=None, reverse=False) --> new sorted list
>
That's plenty of information, but IMO "key=None" doesn't hint strongly enough
about what you can do with it, so I'd advise reading about all the parameters
;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
al speeches ;-)
>that doesn't matter, of course, since the tuple is removed by the
>garbage collector immediately after it has been unpacked.
I'm too tired to figure a humorous segue ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
as now. Anyway, lots of stuff
would become possible... e.g., msys, the MinGW-related shell provides
some of this capability, virtualizing windows partitions as /c/* /d/*
and so forth, as well as having virtual mounts of various subdir trees.
Good night...
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
))
>>> print t2
:D\cimsu
Note that there is only one of each character in t2 (e.g. 'D' and '\\')
And the result is the same for t and t2:
>>> s.lstrip(t)
'aniel Lanois\\For the beauty of Wynona'
>>> s.lstrip(t2)
'aniel Lanois\\For the beauty of Wynona'
If you want to replace an exact prefix, a regex could be a simple way
to get the startswith check and replace in one whack.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
t
>has the externally visible effect of degrading performance (to a nullity)
>for arguments that the user might reasonably want to work.
Agreed, but the key thing there is to define "unnecessarily" ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
und method we saved by binding it to af still is bound to the old
method function,
so a new dynamically created one is not the same:
>>> af.im_func is a2.f.im_func
False
>>> af.im_func
>>> a.f.im_func
at 0x02F99B1C>
>>> a2.f.im_func
at 0x02F99B1C>
ten such an expression, so you will this strategy when people try
to squeeze extra performance from their programs.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
and-optimizes inner loops by hoisting
>the bound objection creation, as
>
>data = []
>data_append = data.append
>for x in some_other_data:
> work with x to make y
> data_append(y)
>
Sorry about the me-too. I hadn't seen your post. I should know better ;-)
Re
Python code with block bracketing, please
program up a suitable code viewer for them ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
t; with compatibility of existing code IMHO.
>
>It's mostly a good way to add inconsistency and confusion to a situation
>that's already confusing enough for newbies.
I don't agree with your idea of inconsistency.
IMO it would be better to explain that a legal basetuple value (empty tuple) is
currently
being abused as a logical flag to call types.ClassType(clsname, basestuple,
clsdict)
instead of type(clsname, basestuple, clsdict), and explain that it will be
corrected, so that
class X():pass will now call the latter, consistent with class X(bases):pass.
Bottom line: IMO class C():pass should create a new-style class,
and the parens serve well as a reminder of which kind it is, whether empty or
not,
until py3k.
I.e., make it easy for newbies: parens means new-style, no parens means
old-style, until py3k.
Pontificating pushes my counter-pontificating button; that's the only
explanation
I have for doing this. I was going to stop wasting time, but find myself
unable as yet fully to abandon scanning clp and python-dev ;-/
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 23 Apr 2006 22:12:01 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
[...]
>(IMO the proper way to indicate the you don't have a tuple is to use None or
>some other sentinel,
>not abuse a perfectly legal tuple value).
>
> >>> dis.dis(compile('class X:p
901 - 974 of 974 matches
Mail list logo