, and will be waiting for me
when I move to Python3.
So a big thank you is in order.
And thank you for, having done that, not simply smiling because your
work was lighter. Instead you described a great work path and handed
an attaboy to a pair of people that richly deserve attaboys.
--Scott David Daniels
there first,
their convention was, in fact, better).
So, sorry for venting, but I have bee wanting to say this in public
for years.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Since nobody else has mentioned it, I'd point you at Mock objects:
http://python-mock.sourceforge.net/
for another way to skin the cat that it sounds like has been
biting you. They are surprisingly useful for exploratory
and regression testing.
--Scott David Daniels
scott.dani...@acm.org
--
http
groundwork can help me out
with that.
I must be in a really cranky mood today.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
, and about the find which bits
means what was where my process broke down.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
what is suggested in those comments, which
appears to be the biggest convention :-)
Perhaps: The comments are a directive to delete the comment if
you happen do this.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
they could be more tolerant,
since I don't think control characters are likely in the interpreter
file name.
You could work around this by creating a symlink (or even hard link to
the python executable named python\r
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman
an immutable result
with a search of all appropriately typed values for one
that was equal.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
3.1.1 and 2.6.4? Does your test work in 2.6?
Also consider how 2to3 translates the problem section(s).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
, since these are numbers:
a, b = [x.__add__ for x in [1, 2]]
print a(10)
print b(10)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Hint: I don't know your CPU, python version, IDLE version, matplotlib
version, nor do you provide a small code example that allows me to
easily reproduce your problem (or not).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
soon) -- get to python dev immediately if
you have problems with the release candidate.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
George Trojan wrote:
Scott David Daniels wrote:
...
And if you are unsure of the name to use:
import unicodedata
unicodedata.name(u'\xb0')
'DEGREE SIGN'
Thanks for all suggestions. It took me a while to find out how to
configure my keyboard to be able to type the degree sign. I prefer
unicodedata.name(u'\xb0')
'DEGREE SIGN'
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
are being checked for files.
Normally you should:
1) tell us python version and which OS (and OS version) you are using.
2) include a pasted copy of exactly what did not work, along with the
resulting output, and why you did not expect the output you got.
--Scott David Daniels
scott.dani
Ben Finney wrote:
Scott David Daniels wrote: ...
class Initialized(ClassBase):
@classmethod
def _init_class(class_):
class_.a, class_.b = 1, 2
super(Initialized, class_)._init_class()
Mea culpa: Here super is _not_ a good idea,
[…]
Why is ‘super
real money from it, like ActiveState you'll help out
the community that is giving you its support.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
, Initialized.b
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
...
Look into metaclasses:
...
class Initialized(ClassBase):
@classmethod
def _init_class(class_):
class_.a, class_.b = 1, 2
super(Initialized, class_)._init_class()
Mea culpa: Here super is _not_ a good idea, and I had
if you have a big image. Just a
thought...
And a good thought too...
I think what Martin is telling you is:
Look to numpy to continue working on the array first.
byte_store = imgL.astype(np.uint8)
Image.fromarray(byte_store).save('_a%s.png' % lev)
--Scott David Daniels
scott.dani
the easy path the fast path, and more will use it;
provide two ways, and the first that springs to mind is the one
used.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
the efficiency reason (asking the machine
to do a pile of work that you intend to throw away). But nobody
warned you:
s.rsplit(None, 1)[-1]
would be better in the case of 'single_word'.rsplit(None, 1)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python
candide wrote:
Hi
I was wondering if there exists somme way to clear memory of all objects
created during a current IDLE session (with the same effect as if one
starts an IDLE session). Thanks.
Different than Shell / Restart Shell (Ctrl+F6) ?
Of course this doesn't work if you started Idle
(dict.setdefault)
update = mutating(dict.update)
d = SerializedDictionary(whatever)
Then just use dict.serial to see if there has been a change.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
def setUp(self):
if self.needs_initial:
self.initialize()
And write your test classes like:
class Bump(FunkyTestCase):
def initialize(self):
super(Bump, self).initialize()
print 'One time Action'
...
--Scott David Daniels
%s % (c, u'c', c)
u'[str] c [unicode]'
--Scott David Daniels
Scott David dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
is 2 ** 64 - 2 ** 53.
There are approx. 2 ** 53 NaNs (half with the sign bit on).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
that in the BarW case (with object), not all mixins are called.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
', expand=1)
...
Also note from Pep 8, spaces are cheap and make the code easier to read.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
be nice as well (don't bother with
ordering though, you get lost in a twisty maze of definitions
all different).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
at the end of the queue...I thought t.join() would just work.
Why do we need None?
Because your workers aren't finished, they are running trying to get
something more to do out of the queue. The t.join() would cause a
deadlock w/o the None.
--Scott David Daniels
scott.dani...@acm.org
--
http
+ 3] = chunk
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Piet van Oostrum wrote:
Scott David Daniels scott.dani...@acm.org (SDD) wrote:
SDD James Harris wrote:...
Another option:
0.(2:1011), 0.(8:7621), 0.(16:c26b)
where the three characters 0.( begin the sequence.
Comments? Improvements?
SDD I did a little interpreter where non-base 10
' ?
If there is such a spot, it is a major security weakness.
You'd be able to automate password attacks.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
)
.F.100 == 256 (hexadecimal)
.1.100 == 4 (binary)
.3.100 == 9 (trinary)
.Z.100 == 46656 (base 36)
Advantages:
Tokenizer can recognize chunks easily.
Not visually too confusing,
No issue of what base the base indicator is expressed in.
--Scott David Daniels
scott.dani
yourself]
To understand more of why we need this on every question, see:
http://www.mikeash.com/getting_answers.html
or google for smart questions.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
chain.from_iterable (on my machine):
[0.7828263089303249, 0.79326171343005925, 0.80967664884783019]
[1.499510971366476, 1.5263249938190455, 1.5599706107899181]
[3.4427520816193109, 3.632409426337702, 3.5290488036887382]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python
(
'%s implementation missing' % name)
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
. So, no, unittest does not
require that you code things into foo.py. You will find that you
may bend your coding style within foo.py in order to make it more
testable, but (if you do it right) that should also make the code
clearer.
--Scott David Daniels
scott.dani...@acm.org
--
http
MRAB wrote:
Scott David Daniels wrote:
MRAB wrote:
The shortest I can come up with is:
[ + ][.join(letters) + ]
Maybe a golf shot:
][.join(letters).join([])
Even shorter:
[+][.join(letters)+]
:-)
I was going by PEP8 rules. ;-)
--Scott David Daniels
Scott David dani
or s is not None)
//code
ensure(ENSURE_OFF or hasattr(returnValue, '__iter__'))
Python has no good way to turn off argument calculation by
manipulating function definition (at least that I know of).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo
MRAB wrote:
The shortest I can come up with is:
[ + ][.join(letters) + ]
Maybe a golf shot:
][.join(letters).join([])
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
explanations:
http://xkcd.com/327/
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
. The SELECT * form in the EXIST test is something DB
optimizers look for, so don't fret about wasted data movement.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
that says, stick to
normal names and you don't have to worry about mucking with the
way Python itself works, but if you are curious, looks for those
things and fiddle with them.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
:
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
()).hexdigest().upper()
return ':'.join(digest[pos : pos+2] for pos in range(0, 40, 2))
--Scott David Daniels
scott.dani...@acm.org
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
'
True
'a' 'D' 'z'
False
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
.
I must learn this etc. language, I hear it mentioned all the time :-)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
'''
source = iter(sample.split('\n')) # source of lines, opened file?
ignored = source.next() # discard heading
for interval in combined_range(source):
print '%s %s-%s' % (interval.name, interval.start, interval.stop)
Prints:
c.a.b 3-10
d.e 15-23
--Scott David Daniels
scott.dani...@acm.org
)
I think it explained in the complex math area, but basically EE types
use j, math types use i for exactly the same thing. Since i is so
frequently and index in CS, and there is another strong convention,
why not let the EE types win?
--Scott David Daniels
scott.dani...@acm.org
--
http
Piet van Oostrum wrote:
Scott David Daniels scott.dani...@acm.org (SDD) wrote:
SDD Stephen Cuppett (should have written in this order):
Fred Atkinson fatkin...@mishmash.com wrote ...
Is there a pre-defined variable that returns the GET line...
os.environment('QUERY_STRING')
SDD Maybe you
, does this work?
import random
random.seed(123542552)
I'm not quite sure how you came to believe that Python controls MySQL,
as opposed to using its services.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
the grayscale.
.MNG is pictures only, but that doesn't hurt you in the least.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
very clearly.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
('QUERY_STRING')
Maybe you mean:
os.environ['USER']
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
imagined a woman. I suspect it would come to irk one
almost enough to become a Gabe.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
it
to work.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
)
with gzip.open(filename, 'w') as dest:
for line in iter(proc.stdout, ''):
f.write(line)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
to be running up and down strings
a character at a time, changing here and there. So it becomes more
natural to deal with strings as chunks to pass around, and it is nice
not to have to copy the strings when doing that passing around.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org
, install Python 3.1 rather than 3.0; think of 3.0 as the
alpha of the 3.X branches (it will get no love at all now that 3.1
is out).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
(sys.stdin.detach(), encoding='utf8')
for line in sys.stdin:
line = line.strip()
if line == 'page':
#do something here
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
for the children explicitely.
And you loower your locality of reference (cache-friendliness).
Note the insert in Python, for example, is quite cache-friendly.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
#;
And mine is one w/o the base 10 bias:
.f.123 == 0x123
.7.123 == 0o123
.1.1101 == 0b1101
That is, .largest allowed digit.digits
-- show the base by showing base-1 in the base.
I actually built this into OZ, an interpretter.
--Scott David Daniels
scott.dani...@acm.org
--
http
machine than the Aho-Corasick processing
requires.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
the duck programming language?
It shares a type system with Python, of course. :-)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
-effects is needed:
def xor(a, b):
if a:
if not b:
return a
elif b:
return b
return False
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
capable of that. If no success, you might contact PJ at Groklaw, she
has dealt with a _lot_ of PDFs (and knows people who deal with PDFs
in bulk).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
house for a cup of coffee. :-)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
On Fri, 10 Jul 2009 08:28:29 -0700, Scott David Daniels wrote:
Steven D'Aprano wrote:
Even *soup stock* fits the same profile as what Hendrik claims is
almost unique to programming. On its own, soup stock is totally
useless. But you make it, now, so you can you feed
Raymond Hettinger wrote:
[Scott David Daniels]
def most_frequent(arr, N): ...
In Py2.4 and later, see heapq.nlargest().
I should have remembered this one
In Py3.1, see collections.Counter(data).most_common(n)
This one is from Py3.2, I think.
--Scott David Daniels
scott.dani...@acm.org
Scott David Daniels wrote:
Raymond Hettinger wrote:
[Scott David Daniels]
def most_frequent(arr, N): ...
In Py2.4 and later, see heapq.nlargest().
I should have remembered this one
In Py3.1, see collections.Counter(data).most_common(n)
This one is from Py3.2, I think.
Oops -- egg all
in the library. So, take the sources and
edit, but change the module name. Even better is figure out how to
use _socket.pyd, to create a smaller _socketexpmodule.c and use that.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
):
__metaclass__ = MyType
a = 5
print MyClass.a, MyClass.demo
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Changes by Scott David Daniels scott.dani...@acm.org:
--
keywords: +patch
Added file: http://bugs.python.org/file14472/timeit.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6422
changes).
http://rgruet.free.fr/
Sadly, I no longer work there, so my copy is gone. :-(
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels scott.dani...@acm.org added the comment:
I've got the code working on trunk2 for my tests.
Should I port to py3K before checking in, and give diffs from there, or
what?
--
___
Python tracker rep...@bugs.python.org
http
DRY (don't repeat yourself) as a maxim, let
it go the first time and wait until you see the pattern (a possible
function). I'd go with a function first, a pair of functions, and
only then look to abstracting the function.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org
better nails.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
Scott David Daniels wrote:
Scott David Daniels wrote:
t = timeit.Timer('sum(part[:-1]==part[1:])',
'from __main__ import part')
What happens if you calculate the sum in numpy? Try
t = timeit.Timer('(part[:-1]==part[1:]).sum
the factors then append((num, 1))
powers.append(2)
return powers
OK, that's a straightforward speedup, _but_:
factorize(6) == [2, 2] == factorize(10) == factorize(15)
So I am not sure exactly what you are calculating.
--Scott David Daniels
scott.dani
('a')
unwind.append(a)
self.b = Foo('b', fail=True)
unwind.append(b)
...
except Exception, why:
while unwind):
unwind.pop().close()
raise
bar = Bar()
--Scott David Daniels
scott.dani...@acm.org
--
http
Scott David Daniels wrote:
... Here's a heuristic replacement for my previous frequency code:
I've tried to mark where you could fudge numbers if the run time
is at all close.
Boy, I cannot let go. I did a bit of a test checking for cost to
calculated number of discovered samples, and found
New submission from Scott David Daniels scott.dani...@acm.org:
timeit.main has a _very_ handy autoranging facility to pick an
appropriate number of repetitions when not specified. The autoranging
code should be lifted to a method on Timer instances (so non-main code
can use it). If number
upwestdon wrote:
if not (self.higher and self.lower):
return self.higher or self.lower
self.lower = 0
self.higher = 123
???
More than just None is False
--
http://mail.python.org/mailman/listinfo/python-list
Patrick Sabin wrote:
Horace Blegg schrieb:
You might consider using a VM with 'save-points'. You run the program
(in a debugger/ida/what have you) to a certain point (logical point
would be if/ifelse/else statements, etc) and save the VM state. Once
you've saved, you continue. If you find the
) # put most frequent first.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Dave Angel wrote:
Scott David Daniels wrote:
Patrick Sabin wrote:
Horace Blegg schrieb:
You might consider using a VM with 'save-points'. You run the
program (in a debugger/ida/what have you) to a certain point
(logical point would be if/ifelse/else statements, etc) and save the
VM state
So there are only 1000 points to investigate.
With any distribution other than uniform, that should go _way_ down.
So just pull out those points, use bisect to get their frequencies, and
feed those results into the heap accumulation.
--Scott David Daniels
--
http://mail.python.org/mailman/listinfo
are providing.
How about:
...
if x = 0: raise ValueError('x = %r not allowed (negative)?' % x)
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
mclovin wrote:
On Jul 4, 12:51 pm, Scott David Daniels scott.dani...@acm.org wrote:
mclovin wrote:
OK then. I will try some of the strategies here but I guess things
arent looking too good. I need to run this over a dataset that someone
pickled. I need to run this 480,000 times so you can see
# Nothing new found, let's get out.
return text_lines or None
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
, 21, 27, 33, 39, 45]
5: [5, 25, 35]
7: [7, 49]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
comparisons:
if (expr1 is not None
and expr2 is not None
and expr3 is not None):
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Mitchell L Model wrote:
Sorry, after looking over some other responses, I went back and re-read
your reply. I'm just making sure here, but:
Scott David Daniels wrote:
Below compressed for readability in comparison:
class A:
def __init__(self): super().__init__(); print
in your bag
of tricks:
def convert(in_queue, out_queue):
for row in iter(in_queue.get, None):
# ... convert row
out_queue.put(converted_line)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
for a for statement is not executed for breaks,
# So indicates the end of testing without a match
raise SystemExit # Or whatever you'd rather do.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
for adler32 vs. crc32 vs. seeded crc32, ...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 1437 matches
Mail list logo