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
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-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
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 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
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):
... @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
__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
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 ;-)
>>
>
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
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
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
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))]
>
, '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 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:
>>> ...
>
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
;> 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
...
>>> 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
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
'__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
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
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
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
.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
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
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
>>
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
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
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
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
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
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
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
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
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
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'
>>
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
ith a
"wish I could here" comment line? ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
>> 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
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
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
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
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
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
.
>>> 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
', '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
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:
>>>
>>>
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
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
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
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
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
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
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
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 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
;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
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
#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
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
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
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
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
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
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
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
, 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
D_ATTR3 (x)
anti-attribute, remove above byte code
51 BUILD_TUPLE 4
54 RETURN_VALUE
You might want to do the same for LOAD_GLOBAL/STORE_GLOBAL, and
STORE_DEREF/LOAD_DEREF, I don't know. But it wouldn't be a big deal
to get a hack working. Thorough testing is another matter,
not to mention justifying it ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
you can use other expressions than bool(x) to get the boolean
value, but you may have to think more about whether (x and 1) will
do it, or whether you should write (x!=0) or, in case x can be None,
perhaps settle on (x and 1 or 0) as an idiom to play safe.
Well, bool(x) is safe, and less typing ;-) OTOH, it's not a hammer for all
nails.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 19 Sep 2005 22:58:40 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
>On 19 Sep 2005 00:02:34 -0700, "malv" <[EMAIL PROTECTED]> wrote:
>
>>Simple case:
>>In this list, how to find all occurences of intervals of n adjacent
>>indexes having at least on
On 19 Sep 2005 00:02:34 -0700, "malv" <[EMAIL PROTECTED]> wrote:
>Simple case:
>In this list, how to find all occurences of intervals of n adjacent
>indexes having at least one list-member with a value between given
>limits.
>Visualizing the list as a two-dimensional curve, this is like
>horizonta
d act like if False
if 1 would act like if True
if 0.0would act like if False
if 5.0would act like if True
if '' would act like if False
if 'a'would act like if True
if [] would act like if False
if [1]would act like if True
if {} would act like if False
if {1: 2} would act like if True
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
mt.__new__:', mt.__new__
... something = mt.__new__(mt, cname, cbases, cdict)
... print 'something:', something
... return something
...
>>> class B(A): __metaclass__ = bar
...
cname, cbases: B (,)
cdict: {'__module__': '__main__', '__metaclass__': }
mt:
mt.mro(mt): [, ]
mt.__new__:
something:
>>>
And the something returned, whatever it is, if no checking is triggered by
normal use,
gets bound to the class name, e.g.,
>>> class C(A): __metaclass__ = lambda *a:('silly', 'result')
...
>>> C
('silly', 'result')
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
in groupby(lines,
... lambda line:line.strip()!='') if k):
... print ''.join(t)
...
200501221530
John
*** long string here ***
200503130935
Jeremy
*** jeremy string here
200504151625
Clyde
*** clyde's long string here ***
>>>
If your source of line groups is not delimited by blank lines,
or has other non-blank lines, you will have to change the source
or change the lambda to some other key function that produces one
value for the lines to include (True if you want to use if k as above)
and another (False) for the ones to exclude.
HTH
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On 17 Sep 2005 11:01:41 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
>> or tell sorted what to do ;-)
>>
>> >>> original= {
>> ... 'hello':135,
>> ... 'goodbye':30,
>> ... 'lucy':4,
(most recent call last):
> File "", line 1, in ?
>TypeError: float() takes at most 1 argument (2 given)
>
>So my question to you is: how can I change my code so I can pass two
>values to the WrapFloat constructor?
>
Float is an immutable, so you need to override __new__
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
gt;'lucy':4,
>'sky':55,
>'diamonds':239843,
>'yesterday':4 }
>
>items = sorted( (v,k) for (k,v) in original.iteritems() )
>items.reverse() # depending on what order you want
>print items
>
>
>The result is:
>[(239843, '
thon interface, in which case an
interface object could have a suitable property to do the final
trimming or padding of bits. Or do you want to define some kind
of mathematical space? For specifying bits in literals see my
other post in this thread (I think ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
>Another poster suggested a solution using struct. Here's my
>solution (which assume python integers are represented in 2's
>compliment binary):
>
>def ioctlValue(i):
>if i & 0x8000:
>i = -((i^0x)+1)
>return i
>
Do you think it's PEP-able, or should I quit being obnoxious ;-)
I think str.mod format like %x except %.b would make it
easy to write '0h%08b.16' % a_signed_integer and get something both
readable and inputtable as a constant. (0h. would be short
for 0b16.) BTW, %b (or %B for uppercase) could default to base 16.
The ouput would only be as wide as necessary, with the leading digit
guaranteed 0 or f (which is 0 or in the general case).
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
clog up the digest with details and code snippets, does this sound
>familiar to anyone?
>
A snippet demonstrating a real bug would be helpful.
A snippet demonstrating a misunderstanding could be helpful.
What's the problem? ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
n't modify or delete an existing important
file until you know you have a new representation safely completed. I say
"new representation" since that also covers the possiblity of original plus
diff patch file as separate files, which could also be an option.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
_
of a container being iterated over effectively modifies the initial parameters
of
the iteration control, so there you need either to have intimate knowledge of
how
the iterator does its thing, or you have to insulate yourself from that need.
OTOH, a mutation of the content can be safe, if it doesn't modify the content
yet to be accessed during the iteration.
In the case of a list, the order can be depended on, so it's not that hard.
Other iterable containers are not so clear, and of course even in a list you
could have cases of access to early items having side effects on upcoming items,
e.g., if the "keep" evaluation had side effects on deep data shared between
early
and later list items. But that would be nasty any which way ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
e, unless the OS goes to the net for a more accurate time. Usually
drift swamps the second resolution in short order though (a problem for
networked parallel makes BTW?)
Enough rambling ...
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
.org/pub/python/2.4.1/Python-2.4.1.tgz is ~9mb)
and people could also post with url references to particular sources.
Seems like providing source trees could be automated, so there would
only be an initial effort involved.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
r the chance is
>that you:
>- Search longer for fitting technologies
>- Adapt your road
- Think more carefully about ego satisfaction cost/benefit vs getting the job
done ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
lues
that would appear in full matrix representations of the same.
http://www.rush3d.com/reference/opengl-redbook-1.1/appendixg.html
Also wondering about some helper function to measure sensitivity of
.solve results when getting near-singular, but maybe that's an
out-side-of-the package job.
enumerate('dab'))
{'a': 2, 'b': 1, 'd': 3}
though note that dict wants the sequence as a single argument:
>>> dict( ('d', 3), ('a', 2), ('b', 1) )
Traceback (most recent call last):
File "", line 1, in ?
s both the true and false results,
>> which may have side effects.
>
>If you are depending on that kind of nit-picking behavior,
>you have a serious design flaw, a bug waiting to bite you,
>and code which shouldn't have been embedded in an expression
>in the first place.
>
Or you might know excatly what you are doing ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
t;Is it a bug or a control behavour ? I don't understand ?!?!?!?!...
>
Others have pointed out the output formatting and binary representation
problems behind your question, but I thought you might not realize the above.
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
tion is primarily used by graphics applications to
create a console window. Graphics applications are
initialized without a console. Console applications are
normally initialized with a console, unless they are created
as detached processes (by calling the CreateProcess function
with the DETACHED_PROCESS flag).
See Also
CreateProcess, FreeConsole, GetStdHandle
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
e thought (and some additional considerations)
I hadn't read yours yet, or I would have mentioned it ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 06 Sep 2005 10:31:33 GMT, Ron Adam <[EMAIL PROTECTED]> wrote:
>Steve Holden wrote:
[...]
>
>> My point was that you can make those changes in your own code, leaving
>> others to accept the situation as it is.
>
>It's only a suggestion and an interesting idea I thought I would share
>and s
7;m fairly certain that 'sort' won't start spending CPU time
>until it has collected all its input, so you won't gain much
>there either.
>
Why wouldn't a large sequence sort be internally broken down into parallel
sub-sequence sorts and merges that separate processors can work on?
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
args = map(float, cmd[1:])
print getattr(algomodule, cmd[0], (lambda name, *ign: 'No such
function: %r'%name).__get__(cmd[0], str))(*args)
this would (theoretically ;-) let you type commands like
sqrt 9
and have alogomodule.sqrt called with float('9'), and then
edit
and edit the module source in notepad, and then
sqrt 16
and have the new function called, etc.
The cmd module will let you set up something fancier than above, and obviously
you don't have to run notepad ;-)
Regards,
Bengt Richter
--
http://mail.python.org/mailman/listinfo/python-list
301 - 400 of 974 matches
Mail list logo