, especially if __getitem__ of list and tuple would do coercion
(you
could argue about coercing floats, etc. in that context, as was probably done
;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
MTP id 8C4871E4013
for <[EMAIL PROTECTED]>; Fri, 23 Sep 2005 01:50:10 +0200 (CEST)
_________
...
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
title. Your first post got a response, the second
had a worse title ("time challenge").
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
aybe there could be a way to detect this kind of
situation from the python.org or xs4all.nl side and not feed a thing
that vomits indiscriminately, so to speak. Sorry about the metaphor ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ing it in the decorator's class
where it belongs:
>>> def __repr__(self):
... fname = self.values()[0].func_name
... types = [tuple((t.__name__ for t in sig)) for sig in self.keys()]
... return '<%s-disp for args %s>' % (fname, repr(types)[1:-1])
...
>>> type(test).__repr__ = __repr__
>>> test
>>> @method(str, str)
... def test(s1, s2): return s1, s2
...
>>> test
>>> test('ah', 'ha')
('ah', 'ha')
>>> test(123)
int 123
That __repr__ could definitely be improved some more ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
and bar
# ...: test_foo for new foo works!
# ...: vacation
Later a tool can strip this out to the devlog.txt or DONE file, when the tool
sees an added progress line like
# ---: woohoo, completed ;-)
My preliminary .02USD for now ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 27 Sep 2005 18:53:03 +0100, Tom Anderson <[EMAIL PROTECTED]> wrote:
>On Tue, 27 Sep 2005, Bengt Richter wrote:
>
>> 5) Sometimes time of day can be handy, so maybe <2005-09-26 12:34:56>
>> could be recognized?
>
>ISO 8601 suggests writing date-and-ti
t charging for
.pdf versions is perversely contrary to the purpose of wide dissemination
necessary for wide adoption. IOW, IMO they ought to think of another way to
get funded).
Anyway, the 'T' looks to me to be optional by mutual agreement between
particular information exchangers, but ot
#x27;this is global X'
>>> bar().cv
'this is K.X'
>
>>> C and X or Y (only if X is True)
>>
>> hopefully, "only if X is True" isn't in fact a limitation of "X if C else Y"
>> ?
>>
>> /... snip comment that the natural order is C, X, Y and that programmers that
>> care about readable code will probably want to be extremely careful with this
>> new feature .../
>
>Yes, that was my comment too, but I'll not demonize it before I have used it.
>
Me too ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ound methods, and then bind in
a proxy "self" instead that would have self.private_var on its own "self" and
delegate public
attribute accesses to the normal self. Maybe this could get around
byte-code-munging at the cost
of easier breakin than via inspect etc., and less run time efficiency. Just
musing ...
But the bottom line question is, would you actually use this privacy feature?
Or maybe, what are your real requirements?
;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
;t supposed to touch, but only in kernel
>mode. An internal OS API change meant it only showed up in the
>upgraded OS.
>
>The infamous Pentium floating point bug shows that this case isn't
>restricted to failing hardware.
>
Was that software? I've forgotten the details and am too lazy to google ;-/
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On 2 Oct 2005 10:31:07 -0700, "El Pitonero" <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>>
>> I decided to read this thread today, and I still don't know exactly
>> what your requirements are for "private" whatevers.
>
>No name collis
lets me modify g's internal value of n
>at this point? How is that different from modifying a private
>instance variable? "Python feature" means something in the language
>definition, not an artifact of some particular implementation. Is
>Python somehow deficient because it doesn't give a way to do that? Do
>you want to write a PEP to add a way? Do you think anyone will take
>it seriously?
I could see it as part of a debugging interface that might let you mess more
with frames in general. I wouldn't be surprised if a lot of the under-the-hood
access
we enjoy as it is was a byproduct of scratching debugging-tool-need itches.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On 03 Oct 2005 04:47:26 -0700, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] (Bengt Richter) writes:
>> Would you want to outlaw 'None' as an attribute name?
>> Python seems to be straddling the fence at this point:
>> >>> c.None
5))
>>> add5
of 5>
>>> add5(10)
15
I can't stuff the method on type(5) since it's built in,
>>> type(5).add5 = (lambda self, x: self+x).__get__(5, type(5))
Traceback (most recent call last):
File "", line 1, in ?
TypeError: can't set attributes of built-in/extension type 'int'
but that doesn't stop forming a bound method ;-)
for a better name than you can always fix it up ;-)
>>> add5.im_func.func_name = 'add5'
>>> add5
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ould you compare that with
lambda a=expr: ... do something (limited to expression) with a
?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
dollars for a program that now could now be used by her competition.
>Nobody wants to pay money to level the playing field for all in a
>business environment.
So the biggest threat would seem to be her competition posting requirements
here and having some showoff post a complete solution ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
f declaration
requirement for
the var := expr usage, and an initialization to a particular type could enhance
inference.
Especially if you could have a decorator for statements in general, not just
def's, and
you could then have a sticky-types decoration that would say certain bindings
may be inferred
to stick to their initial binding's object's type.
Rambling uncontrollably ;-)
My .02USD ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ts handed to check or modify before what it
returns is bound to the def function name. ;-)
>
>An external checker could possibly work as well if a suitable marker is
>used such as a bare string.
>
> ...
> x = y = z = None
> "No_New_Names"# checker looks for this
> ...
> X = y/z # and reports this as an error
> return x,y
>
>and..
>
> ...
> Author = "Fred"
> "Name_Lock Author"# checker sees this...
> ...
> Author = "John" # then checker catches this
> ...
>
>So there are a number of ways to possibly add these features.
Yup ;-)
>
>Finding common use cases where these would make a real difference would
>also help.
>
Yup ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
is a total ordering). So I can use whatever
>method I want as long as it is achieves this.
>
>But that is contradicted by the unittest. If you have a unittest for
>comparing dictionaries, that means comparing dictionaries has a
>testable characteristic and thus is further defined.
>
>So I don't need a full implementation of dictionary comparison,
>I need to know in how far such a comparison is defined and
>what I can choose.
>
A couple of data points that may be of interest:
>>> {'a':0j} < {'a':1j}
Traceback (most recent call last):
File "", line 1, in ?
TypeError: cannot compare complex numbers using <, <=, >, >=
and
>>> cmp(0j, 1j)
Traceback (most recent call last):
File "", line 1, in ?
TypeError: cannot compare complex numbers using <, <=, >, >=
but
>>> {'a':0j} == {'a':1j}
False
>>> {'a':1j} == {'a':1j}
True
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On 6 Oct 2005 06:44:41 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote:
>Op 2005-10-06, Bengt Richter schreef <[EMAIL PROTECTED]>:
>> On 5 Oct 2005 09:27:04 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote:
>>
>>>Antoon Pardon wrote:
>>>
>>>
', 'hey': 'there'}
BTW, @presets does not change the signature of the function whose selected
locals
are being preset from the decoration-time-generated constant, e.g.,
>>> presets(hey='there')(bar)()
Traceback (most recent call last):
File "", line 1, in ?
TypeError: bar() takes at least 1 argument (0 given)
>>> presets(hey='there')(bar)('exx', 'wye')
{'y': 'wye', 'x': 'exx', 'hey': 'there'}
>>> presets(hey='there')(bar)('exx', 'wye', 'zee')
Traceback (most recent call last):
File "", line 1, in ?
TypeError: bar() takes at most 2 arguments (3 given)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
.
>>> A.x
Getting x...
8
>>> vars(A).items()
[('__module__', '__main__'), ('__metaclass__', ), ('_x', 8), ('_
_dict__', ), ('__weakref__', ), ('__doc__', None)]
>>> A._x
8
>>> vars(A).keys()
['__module__', '__metaclass__', '_x', '__dict__', '__weakref__', '__doc__']
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
nt, A.a_cnt
(1, 0)
>>> A.ratio
Getting ratio...
0.0
>>> a=A()
>>> A.ratio
Getting ratio...
0.5
>>> a=A()
>>> A.ratio
Getting ratio...
0.3
The old instance is no longer bound, so should it still be counted as it is?
You might want to check how to use weak references if not...
>>> b2=B()
>>> B.ratio
Getting ratio...
0.5
>>> b3=B()
>>> B.ratio
Getting ratio...
0.40002
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
c use of them could lead to a full-on plate of
>spaghetti, where you really wanted code.
>They can be impenitrable. Whenever I'm dealing with them in C/C++, I
>always line the ?, the :, and the ; characters vertically, which may
>seem a bit excessive in terms of whitespace, but provides a nice
>hieroglyph over on the right side of the screen, to make things
>obvious.
>Best,
>Chris
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
id straying into ad hominem
irrelevancies.
OTOH, I think everyone is entitled at least to ask if a perceived innuendo was
real and
intentional (and should be encouraged to do so before launching a
counter-offence).
Sometimes endless niggling and nitpicking gets tiresome, but I don't think that
is necessarily
troll scat either. And one can always tune out ;-)
Anyway, thanks for the pychecker and pylint demos. And I'm glad that we can
enjoy your posts again,
even if for a limited time.
-- Martellibot admirer offering his .02USD for peace ... ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
d
email.
>
>I try to explain Java each day both on my website on the plaintext
>only newsgroups. It is so much easier to get my point across in HTML.
How about pdf?
>
>Program listings are much more readable on my website.
IMO FOSS pdf could provide all the layout benefits while
avoi
d?
>Why is it an "execresence"?
>
>By the way, dict.org doesn't think "execresence" is a word,
>although I interpret the neologism as meaning something like
>"execrable utterance":
>
>dict.org said:
>> No definitions found for 'execresence'!
>
Gotta be something to do with .exe ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
>> another name
>
>Though I will not be using this solution (plan to use flush() explicitly)
>for speed reasons, thanks ! I will file this away for future reference :)
I suspect Scott's try/finally approach will get you better speed, since it
avoids unneeded flush calls and the associated buffer management, but
it is best to measure speed when you are concerned.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
tration"
That comes after parents buy some toys for their children, and the
children have posession of both the toys and the associated warranty cards.
Of course if one is a parent who worries about warranties in a circumstance
such as this,
"One should be prompt in mailing t
text()
...
>>> diss(foo)
' 1 0 LOAD_FAST0 (x)\n 3 LOAD_CONST
1 (1)\
n 6 BINARY_ADD \n 7 LOAD_CONST
2 (2)\n
10 BINARY_POWER\n 11 RETURN_VALUE\n'
>>> print diss(foo)
1 0 LOAD_FAST0 (x)
3 LOAD_CONST 1 (1)
6 BINARY_ADD
7 LOAD_CONST 2 (2)
10 BINARY_POWER
11 RETURN_VALUE
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
to do on the C API (perhaps nothing, perhaps
> allowing UTF-8)
Perhaps string equivalence in keys will be treated like numeric equivalence?
I.e., a key/name representation is established by the initial key/name binding,
but
values can be retrieved by "equivalent" key/names with diff
d does what you want, you need a callable that can
remember state one way or another. A callable could be a function with
a mutable closure variable or possibly a function attribute as shown in
other posts in the thread, or maybe a class bound method or class method,
or even an abused met
On 16 Oct 2005 00:31:38 GMT, John Bokma <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] (Bengt Richter) wrote:
>
>> On Tue, 04 Oct 2005 17:14:45 GMT, Roedy Green
>> <[EMAIL PROTECTED]> wrote:
>>
>>>On Tue, 23 Aug 2005 08:32:09 -0500, l v <[EMAIL
On Sun, 16 Oct 2005 12:16:58 +0200, =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
<[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>> Perhaps string equivalence in keys will be treated like numeric equivalence?
>> I.e., a key/name representation is established by the initial
ith a
"wish I could here" comment line? ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
e a managed attribute x:
| class C(object):
| def getx(self): return self.__x
| def setx(self, value): self.__x = value
| def delx(self): del self.__x
| x = property(getx, setx, delx, "I'm the 'x' property.")
|
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 18 Oct 2005 01:34:09 +0200, =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
<[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>> Well, what will be assumed about name after the lines
>>
>> #-*- coding: latin1 -*-
>> name = 'Martin Löwis'
>>
ll still have to decide whether he likes the semantics ;-)
E.g., what does he really want as the date for "one month" after January 30 ?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
functionality in some helper thing ;-)
>b.x = 7
With the above mods put in becker.py, I get:
>>> import becker
obs0 _x 3
obs0 _x 4
obs1 _x 7
But adding another observer doesn't eliminate the other(s):
>>> def obs3(inst,pName,value):
... print 'obs3', inst, pName, value
...
>>> becker.A.x.add(obs3)
>>> becker.b.x = 777
obs1 _x 777
obs3 _x 777
>>> becker.a.x = 777
obs0 _x 777
obs3 _x 777
HTH
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
e asset of the depth and breadth of Python archives
>> - for learning (and teaching) and real world production - should not be
>> underestimated, IMO. I could be confident if there was an answer to
>> getting the functionality I was looking for as above, it would be found
>> easily enough by a google search. It is only with the major
>> technologies that one can hope to pose a question of almost any kind to
>> google and get the kind of relevant hits one gets when doing a Python
>> related search. Python is certainly a major technology, in that
>> respect. As these archives serve as an extension to the documentation,
>> the body of Python documentation is beyond any normal expectation.
>>
>> True, this asset is generally better for answers than explanations.
>>
>> I got the answer I needed. Pursuing here some explanation of that answer.
>>
HTH
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
lf, name):
... self.__delitem__(name)
... def __repr__(self):
... return 'Context(%s)' % ', '.join('%s=%r'% t for t in
sorted(self.items()))
...
>>> print Context(color='red', size='large', shape='ball')
Context(color='red', shape='ball', size='large')
>>> ctx = Context(color='red', size='large', shape='ball')
>>> print ctx
Context(color='red', shape='ball', size='large')
>>> ctx
Context(color='red', shape='ball', size='large')
>>> ctx.color
'red'
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
Borland Delphi Object Pascal:
"""
The following constructs are comments and are ignored by the compiler:
{ Any text not containing right brace }
(* Any text not containing star/right parenthesis *)
A comment that contains a dollar sign ($) immediately after the opening { or (*
is a
/compiler directive/. A mnemonic of the compiler command follows the $
character.
"""
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
y:
>>> class Sic:
... def getFoo(self):
... print "GET"
... return "FOO"
... def setFoo(self, value):
... print "SET", value
... def delFoo(self):
... print "DEL"
... foo = property(getFoo, setFoo, delFoo)
...
>>> sic = Sic()
>>> print sic.foo
GET
FOO
>>> sic.foo = 10
>>> print sic.foo
10
>>> del sic.foo
>>> print sic.foo
GET
FOO
but it won't go beyond the instance for del foo
>>> del sic.foo
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: Sic instance has no attribute 'foo'
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
was called. If you
wanted to
make your code work, perhaps replacing (untested)
__import__(f2)
with
exec '%s = __import__(f2)'%f2 # bind imported module to name specified by
f2 string
might have got by the error in eval (c), but I suspect you would want to leave
the () off
the .main in any case. And why go through all that rigamarole?
>
>TIA.
>
Try it both ways and report back what you found out ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
return mod
>
>for reasons given here...
>
>http://www.python.org/doc/2.3.5/lib/built-in-funcs.html
>
Aha. You didn't mention multi-dot names ;-)
But was that the real problem? Your original code
wasn't using anything corresponding to mod above.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
x27;
>value = 25
>foo( name=name, position=position )
>
Just had the thought that if you want to add bindings on the fly modifying the
original object, you could use the __call__ method, e.g.,
>>> class NameSpace(dict):
... __getattr__ = dict.__getitem__
... __setattr__ = dict.__setitem__
... __delattr__ = dict.__delitem__
... def __call__(self, **upd):
... self.update(upd)
... return self
...
>>> def show(x): print '-- showing %r'%x; return x
...
>>> ns = NameSpace(initial=1)
>>> show(ns)
-- showing {'initial': 1}
{'initial': 1}
And updating with a second keyword on the fly:
>>> show(show(ns)(second=2))
-- showing {'initial': 1}
-- showing {'second': 2, 'initial': 1}
{'second': 2, 'initial': 1}
FWIW ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
that does date interval addition/subtraction, but it
didn't
come with the batteries in my version.
BTW, make sure all your date stuff is using the same epoch base date, in case
you
have some odd variant source of numerically encoded dates, e.g., look at
>>> import time
>>
esetEvent
SetEvent
WaitForMultipleObjects
WaitForMultipleObjectsEx
WaitForSingleObject
WaitForSingleObjectEx
BTW,
"""
The CreateFile function creates, opens, or truncates a file, pipe,
communications resource, disk device, or console. It returns a handle
that can be used to access the
.glob is already
>guaranteed to be strings, so using either '%s'%f or str(f) is superfluous.
>
And so is a listcomp that only reproduces the list returned by glob.glob
-- especially by iterating through that same returned list ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
simple a job of buffering as you might think. Maybe
you'll want to wrap
a byte array or an mmap instance to store your info, depending on what you are
doing?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
dict.
Nothing to do with optimization. In fact, re-using the shared default dict
would be faster, though of course generally wrong.
>
>Worked like a charm, Thanks!
>
Just wanted to make sure you realize why it made a difference, in case ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
xample code that
might be useful.
I'm suspicious of the default values you provide in your noisy_import though.
They are all mutable, though I guess nothing should mutate them. But will they
be valid for all the contexts your hook will be invoked from? (Or are they
actually
useless and always overridden?)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
'__gt__'; return NotImplemented
...def __coerce__(*ignore): print '__coerce__'; return NotImplemented
...def __cmp__(*ignore): print '__cmp__'; return NotImplemented
...
>>> sorted((D(),D()))
__lt__
__gt__
__cmp__
__cmp__
(I haven't followed the t
27 LOAD_CONST 5 ('face')
30 CALL_FUNCTION2
33 STORE_FAST 0 (newPhrase)
36 LOAD_CONST 0 (None)
39 RETURN_VALUE
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
>>> mydict = dict(a=1, b=None, c=3, d=None, e=5)
>>> mydict
{'a': 1, 'c': 3, 'b': None, 'e': 5, 'd': None}
>>> mydict.update((k,'Null') for k,v in mydict.items() if v is None)
>>> mydict
{'a': 1, 'c': 3, 'b': 'Null', 'e': 5, 'd': 'Null'}
(too lazy to measure ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
;> s.count('0010')
1
vs. brute force counting overlapped substrings (not tested beyond what you see
;-)
>>> def ovcount(s, sub):
... start = count = 0
... while True:
... start = s.find(sub, start) + 1
... if start==0: break
... count += 1
...
en(whatever, 'b')
>count = 0
>for block in byblocks(f, 1024*1024, len(subst)-1):
>count += block.count(subst)
>f.close()
>
>not much "fiddling" needed, as you can see, and what little "fiddling"
>is needed is entirely encompassed by the generator...
>
Do I get a job at google if I find something wrong with the above? ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 29 Oct 2005 10:34:24 +0200, Peter Otten <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
>> On Fri, 28 Oct 2005 20:03:17 -0700, [EMAIL PROTECTED] (Alex Martelli)
>> wrote:
>>
>>>Mike Meyer <[EMAIL PROTECTED]> wrote:
>>> ...
>
, 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
Now the zipped sort unzipped:
>>> zip(*sorted(zip(first,second)))
[(1, 1, 1, 1, 1, 2, 2, 2, 2, 2), ('A', 'B', 'C', 'D', 'E
On Sun, 30 Oct 2005 10:13:42 +0100, Peter Otten <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
[...]
>> Now select from the second list, by first-element position correspondence:
>> >>> [second[t[1]] for t in sorted((f,i) for i,f in enumerate(first))]
>
On Sat, 29 Oct 2005 21:10:11 +0100, Steve Holden <[EMAIL PROTECTED]> wrote:
>Peter Otten wrote:
>> Bengt Richter wrote:
>>
>>
>>>What struck me was
>>>
>>>
>>>>>> gen = byblocks(StringIO.StringIO('no'),1024,le
gt; for c in s:
... nc = printf('%1c', c)
...
now is the time>>>
Just to show multiple args, you could pass all the characters
separately, but at once, e.g., (of course you need a format to match)
>>> printf('%s'*len(s)+'\n', *s)
now is the t
ve gone differently if the
title had been "How to count frames in an MPEG2 file?" and the OP had supplied
the info about what marks a frame and whether it is guaranteed not to occur
in the data ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 31 Oct 2005 09:19:10 +0100, Peter Otten <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
>> I still smelled a bug in the counting of substring in the overlap region,
>> and you motivated me to find it (obvious in hindsight, but aren't most ;-)
>>
>
__new__ method too (by temporarily binding the
instance returned by frozenset.__new__ and assigning the name attribute
before returning the instance), or you can define __init__ to do that part.
See many various posted examples of subclassing immutable types.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
t):
... @funnycm
... def foo(cls, a, b):
... print cls, a, b # do something
...
>>> class B(A):
... pass # just inherit
...
>>> a=A()
>>> a.foo(1,2)
1 2
>>> b=B()
>>> b.foo(1,2)
1 2
>>> A.foo(3,4)
3 4
thon might help,
with some idea of the kind of visualization aspects being controlled ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
t hooking and could one rewrite
sys.argv
so the special import command line opts would not be visible to subsequent
processing (and the import hook would be in effect)? IWT so, but probably
should read
site.py again and figure it out, but appreciate any hints on pitfalls ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
rgname in argnames
if argname not in args])
return func(*actualargs)
_f.func_name = func.func_name
return _f
and then wrap like
extract_audio = call_with_args_from_dict(extract_audio)
or use as a decorator if you are defining the function to be wrapped, e.g.,
@call_with_args_from_dict
def mux(firstarg, second, etc):
...
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
t-set.
>
Very dependent on what kind of "searches" -- e.g., 1024*1024 suggests the
possibility of two dimensions. Quad-trees? How sparse is the data? Etc.
What kinds of patterns are you going to search for?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
re very very good at descriptions, it's hard to beat presentation of
machine representations of what you are talking about ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
t ''.join(chr(48+((ord(c)>>b)&1)) for b in xrange(7,-1,- 1)),
...
0101 0110 0111 00110001 00110010 00110011 00101110 00101110
00101110 0001 0010 0011
(cf. 41 42 42 etc above)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
ecent call last):
> File "", line 1, in ?
> File "", line 2, in fn2
>KeyError: 'fn'
>>>>
>
>Using globals() in this case will work, but then won't find functions
>defined in the local name space.
>
>For a lot of uses, it'd be better to build the dictionary by hand
>rather than relying on one of the tools that turns a namespace into a
>dictionary.
IMO it would be nice if name lookup were as cleanly
controllable and defined as attribute/method lookup.
Is it a topic for py3k?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
during the execution of the body of the class definition, where
classmethod
was called. The function will have no demands except to match its signature
when the
classmethod descriptor instance calls it with first arg of D.
>>> D.f
>
>>> D.f()
__main__.D
You could extract t
scope,
but lookahead determines that a is local to inner, period, so that
is the reference that is used (and fails).
>>> def outer():
... a = 1
... def inner():
... a += 2
... print a
... print 'outer a', a
... inner()
... print 'outer a', a
...
>>> outer()
outer a 1
Traceback (most recent call last):
File "", line 1, in ?
File "", line 7, in outer
File "", line 4, in inner
UnboundLocalError: local variable 'a' referenced before assignment
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
rd))
7
So the test would be
>>> len(set(cellboard))==len(cellboard)
False
And after repairing the list to uniqueness of elements:
>>> cellboard[2] = 2
>>> len(set(cellboard))==len(cellboard)
True
HTH
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
;-)
OTOH, is suppose a function could have a reseved slot for a name space object
stack
that wouldn't cost much run time to bypass with a machine language check for
NULL.
BTW2, this kind of stack might play well with a future "with," to guarantee name
space popping. Perhaps "with" syntax could even be extended to make typical
usage
slick ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
to spell "find x and rebind it to expr" (or raise NameError if not found).
Extending that to attributes and augassign,
b.a +:= 2
could mean find the "a" attribute, and in whatever attribute dict it's found,
rebind it there. Or raise an Exception for whatever failure is encountered.
This would be nice for rebinding closure variables as well. But it's been
discussed,
like most of these things ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
l what happens, pretty much in as much detail as you can describe
requirements ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
e was the global "a" because
a local "a" hadn't been defined until the assignment, which worked to
produce a local binding of "a". Personally, I like that better than
the current way, because it follows the order of accesses implied
by the precedences in expression evaluation and statement execution.
But maybe I don't RC ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
e prevented'
>>> b.a
'instance attr'
>>> B.a
'this could be prevented'
The spelled out attribute update works too
>>> B.a = shared('alpha')
>>> b.a
'alpha'
>>> b.a = b.a + ' beta'
>>> b.a
'alpha beta'
>>> B.a
'alpha beta'
But the instance attribute we forced is still there
>>> vars(b)
{'a': 'instance attr'}
You could have shared define __add__ and __iadd__ and __radd__ also,
for confusion to taste ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
;Small correction, it expands to b.a = B.a.__class__.__iadd__(b.a,2),
>assuming all relevant quantities are defined. For integers, you're
>perfectly right.
But before you get to that, a (possibly inherited) type(b).a better
not have a __get__ method trumping __class__ and the rest ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On 04 Nov 2005 17:53:34 -0800, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] (Bengt Richter) writes:
>> Hm, "the" fix? Why wouldn't e.g. treating augassign as shorthand for
>> a source transformation (i.e., asstgt = expr becomes by simple
bject that just happens to define
>__iadd__(self,type(other) == int).
But if it is an esoteric descriptor (or even a simple property, which is
a descriptor), the behaviour will depend on the descriptor, and an instance
variable can be created or not, as desired, along with any side effect you like.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 04 Nov 2005 21:14:17 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] (Bengt Richter) writes:
>> On Thu, 03 Nov 2005 13:37:08 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote:
>> [...]
>>>> I think it even less sane, if the same occu
On Sat, 05 Nov 2005 14:37:19 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>On Sat, 05 Nov 2005 00:25:34 +, Bengt Richter wrote:
>
>> On Fri, 04 Nov 2005 02:59:35 +1100, Steven D'Aprano <[EMAIL PROTECTED]>
>> wrote:
>>
>>>
#x27;, '[startdelim]', 'this\nis\nanother', '[enddelim]',
'this\nis\n\n33
\n4\n', '[startdelim]', '\n77\n888', '[enddelim]',
'\n00\n']
Which had the replacing when not i%4 was true
>>> for i,s in enumerate(sp): print '%6s: %r'%(not i%4,s)
...
True: 'this\nis\na\nsentence'
False: '[startdelim]'
False: 'this\nis\nanother'
False: '[enddelim]'
True: 'this\nis\n\n33\n4\n'
False: '[startdelim]'
False: '\n77\n888'
False: '[enddelim]'
True: '\n00\n'
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
r of:
>
>def function(value=[]):
>value.append(None)
IMO that's not a wart at all, that's a direct design decision, and it's
different from the dual referencing that happens in Scenario 4.
>
>I can live with that. It is a familiar wart, and keeps inheritance of
>attributes working the right way. And who knows? If your attributes are
>mutable, AND you want Antoon's behaviour, then you get it for free just by
>using b.a += 1 instead of b.a = b.a + 1.
Not quite, because there is no way to avoid the binding of the __iadd__
return value to b.a by effective setattr (unless you make type(b).a
a descriptor that intercepts the attempt -- see another post for example).
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
27;s not complete, but
it's quite useful and pretty easy to use. Hm, seems to be updated since I
downloaded a copy, guess I'll grab the newest ;-) Hm2, it doubled in size!
The creation dates are
*** FILE tkinter.pdf ***
/CreationDate (D:20030416170500)
*** FILE tkinter2.pdf ***
/CreationDate (D:20050803114234)
So I guess it could double in 2 years 4 months. I'll have to look into it.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
d. (And look for bare except: clauses or other exception
handling that
might be throwing away a DataUtil definition exception).
HTH
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 06 Nov 2005 12:23:02 -0500, Christopher Subich <[EMAIL PROTECTED]>
wrote:
>Bengt Richter wrote:
>> On Fri, 04 Nov 2005 10:28:52 -0500, Christopher Subich <[EMAIL PROTECTED]>
>> wrote:
>
>>>is very much within the language specification. Indeed,
On Thu, 03 Nov 2005 14:23:53 +1000, Paul Cochrane <[EMAIL PROTECTED]> wrote:
>On Wed, 02 Nov 2005 06:33:28 +0000, Bengt Richter wrote:
>
>> On Wed, 2 Nov 2005 06:08:22 + (UTC), Paul Cochrane <[EMAIL PROTECTED]>
>> wrote:
>>
>>>Hi all,
>>
pursuit of quantum nits ;-)
I suspect we all experience the emotions relevant to being misunderstood;
we just stop at different nit granularities (modulo horn locking ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
t; management and development of Python is dynamic and fairly
>> open-minded. If there had been an obvious way to change this
>> in a way that solved more problems than it caused, I suspect
>> that change would have happened already.
>
>Fine I can live with that.
>
A
pretty effective. But this is a social engineering problem more than
technical ;-)
BTW, would such a thing appropriately be defined in a process PEP?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
, standard alignment
>>> struct.calcsize('>'+hdrFormat)
590
Network (big endian), standard alignment:
>>> struct.calcsize('!'+hdrFormat)
590
I guess if you want alignment for anything non-native, you have to specify pad
bytes
where you need them (with x format character).
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
..
>>> list(findit(s))
['00 target 01']
>>> s2 = s + ' garbage noise3 00 almost 01 target_mark 00 success 01
>>> target_mark'
>>> list(findit(s2))
['00 target 01', '00 success 01']
(I didn't enforce exact adjacency the first time, obviously it would be more
efficient
to search for end+tmk instead of tmk and back to beg and forward to end ;-)
If there can be spurious target_marks, and tricky matching spans, additional
logic may be needed.
Too lazy to think about it ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
= bob(8)
>py> list(b)
>[0, 1, 2, 3, 4, 5, 6, 7]
>py> doit(*b)
>(0, 1, 2, 3, 4, 5, 6, 7)
>
I think you can also just define __getitem__ if that's handier. E.g.,
>>> class MyClass(object):
... def __init__(self, limit=1): self.limit=limit
... def __getitem__(self, i):
... if i < self.limit: return i**3
... raise StopIteration
...
>>> myobj = MyClass(5)
>>> list(myobj)
[0, 1, 8, 27, 64]
>>> list(MyClass(10))
[0, 1, 8, 27, 64, 125, 216, 343, 512, 729]
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
d you format the number you got from os.path.getmtime?
You might want to try some of the above.
If you actually created/modified files just before and after the DST change
and saw an extra hour difference instead of the time between the two actions,
then maybe I'd look into whether the
1 - 100 of 974 matches
Mail list logo