its not a GUI app.
Use a thread that uses something like:
def action():
sleep(50)
if not canceled:
callback(foo)
as its action.
The callback ill be in another thread, but Look up threading for
more details.
--Scott David Daniels
[EMAIL PROTECTED]
-
s there a way to query the use count
> of an object? This would be useful for debugging and testing.
>>> import sys
>>> sys.getrefcount(42 * 7)
2
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
es above don't do anything (the return decrefs the locals).
> return(excinfo_str)
The parens here can be skipped as well:
return excinfo_str
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Constants then becomes a nice place to define methods
to convert values to associated names for debugging and such.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
B, C
a.east, b.east, c.east = A, B, C
A.west, B.west, C.west = a, b, c
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ring formatting.
For this portion, you could quite simply:
totalsecs = int(whatever)
print '%02d:%02d' % divmod(totalsecs, 60)
Or, depending on your leading zero requirements:
totalsecs = int(whatever)
print '%2d:%02d' % divmod(totalsecs, 60)
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Dr. Pastor wrote:
> Scott David Daniels wrote:
>> Dr. Pastor wrote:
>>> I need a row of 127 bytes that I will use as a
>>> circular buffer. Into the bytes (at unspecified times)
>>> a mark (0>> After some time the "buffer" will contain the last
Scott David Daniels wrote:
> Dr. Pastor wrote:
>> Scott David Daniels wrote:
>>> Dr. Pastor wrote:
>>>> I need a row of 127 bytes that I will use as a
>>>> circular buffer. Into the bytes (at unspecified times)
>>>> a mark (0>>&g
ons wud b of great help...
This is a wxPython question, not a Python question.
Ask on the wxPython group. Available on gmane as
gmane.comp.python.wxpython
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
annot remember when I have last
> received a relevant email that I could not read in text mode.
Because
(A) This _is_ a technical newsgroup with mores you are violating.
(B) Some of us "technical users" avoid such email/news readers
precisely because they can cause tra
ndled faster than random data.
If you are using your gut without testing, go ahead and
presort. In any case, reading documents and testing beats
gut feels every time.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
native Chinese speaker who
has put the work into learning enough English to get by and is
confronted with yet another European language to decipher. In
consideration for such people, please limit yourself to English.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/
:
yield single + rest
for v in Counter('ab', Counter('cd', Counter('ef', Counter('gh':
print v
This works with "iterables" (and produces), rather than "iterators",
which is vital to the operation.
[EMAIL PROTECTED] wrote:
> Scott David Daniels wrote:
>
>> This works with "iterables" (and produces), rather than "iterators",
>> which is vital to the operation.
>>
>> --Scott David Daniels
>> [EMAIL PROTECTED]
>
> Sorry, it doe
WIdgeteye wrote:
>
Thank you very much for your participation.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
of Python with cygmin (I've no idea if that compile
cleanly). If you want to use the MinGW approach, your call to setup is
something like "python setup.py -compiler=mingw32 -build " (look it up,
there are more details to know about.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Scott David Daniels wrote:
>> Sorry, "re-iterables". A file re-iterable is:
>>
>> class FileReIterable(object): ...
>> def __iter__(self):
>> self.file.seek(0)
>> return iter(self
43, 11, 0, 30, 49, 32, 44, 24, 47, 42, 27, 23, 28, 12, 18, 13, 35, 1,
34, 25, 45, 21, 20, 46, 38, 17, 31, 6, 4, 14, 41, 51, 19]
Don't be so sure the advice you get is wrong.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
sier.
This is the inevitable result of running a pair of GUIs simultaneously:
They both want control of the main program to run their idle loop, and
only can win.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Jim Segrave wrote:
> In article <[EMAIL PROTECTED]>,
> Scott David Daniels <[EMAIL PROTECTED]> wrote:
>> class FileReIterable2(object):
>> ...
>> def __iter__(self):
>> self.file.seek(0)
>> f
o the tutorial and this and many other things will become clear.
Instead of just "print sometext", do something like:
...
f = open('filename', 'w')
...
print >>f, sometext
... (possibly more prints like the above).
f.clo
Brian wrote:
> One question (and this is a topic that I still have trouble getting my
> arms around). Why is the text in STYLEBLOCK tripple quoted?
Because triple-quoted strings can span lines and include single quotes
and double quotes.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
velope containing five $100 bills is equal to
an envelope containing five $100 bills with different serial numbers?
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> are there any specific groups for zope / plone regarding questions?
Check gmane (google for it).
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
you could read through all the web thingies around (the online
tutorial is great), many others listed "getting started" should help,
and to really build your muscles, try the "Python challenge."
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ss thing on .com) is where the main
> developers of ReportLab (a library freely available on www.reporlab.org)
> work. So what you want really is .org, but apparently it's having
> problems right now.
>
Or, you could look for:
http://www.reportlab.org/
a polite question. If this were not true, then
all manner of spam would be polite.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.pyw
to:
C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.pyw -n
That "target", by the way, can also be typed directly to the command
line to start Idle in "no subprocess" mode.
The big advantage to using Idl
g and
then updating.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
re a couple of standard answers.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
wx.BoxSizer(wx.HORIZONTAL)
panel.SetSizer(sizer)
sizer.Add(wx.Button(panel, label='OK'), 0, wx.ALL, 10)
sizer.Add(wx.Button(panel, label='Cancel'), 0, wx.ALL, 10)
class MyApp(wx.App):
def OnInit(self):
frame = InputForm(title='Data
enses for software."
I had one lawyer tell me the MIT license was better at declaring your
non-liability than BSD. IANAL, your lawyer may vary,
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
yteswap()
return ' '.join(hexx(ord(char), 2) for char in data.tostring())
def fours(number, swap=False):
data = array.array('f', [number])
if swap:
data.byteswap()
return ' '.join(hexx(ord(char), 2) for char in data.tostring())
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ose third-party packages; they likely
aren't getting money for their contribution.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
til now, I think you can
send a pickle of a data structure and unpickle it on a different
processor to get equivalent data.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
> Scott David Daniels wrote:
>
>> class InputForm(wx.Frame):
>> def __init__(self, parent=None, id=-1, title=__file__):
>
> Also, is there a way to define parent and id with defaults, but not
> title? Is it good to change the order around to d
rror," Your exception may have some specific data that
assists you in discovering the source of the problem. Meanwhile,
any code that says:
try:
something()
except ValueError, error:
...
will catch your new exception in the ValueError clause. Subclasses
of ex
ot certain, but you could take a look at Komodo from ActiveState.
I do have an interactive window, edit window(s), and an output window.
You can get a free trial from them, as I remember.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Hi everyone,
>
> which compiler will Python 2.5 on Windows (Intel) be built with?
Same as for Python 2.4 (the decision was taken a while ago).
Intel sells a compatible compiler, I believe.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.or
ce OO) give you is a way of saying, "I'd
like something a bit like a module, but I'd like to make several
of them, and not have them interfere with each other." That is
the big intuition about objects, the rest is just details.
--Scott David Daniels
[EMAIL PROTECTED]
--
fallen in love with Python as both a programming language and
a way of expressing algorithms to other programmers (who didn't
necessarily know it was Python I was writing).
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
> John Salerno wrote:
...
And I didn't quote him at all, so my post looks like it was
attributed to him, rather than in response to his message.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
) about
learning VI:
"The two weeks you'll spend hating vi (or vim) as you learn it will
be repaid in another month, ad the rest is pure profit."
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ible
to purchase suitable versions of VC6.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
for i in range(n):
polys.append(lambda x: polys[i](x)*x)
i=3
The lambda-defined functions will be called after the for loop is done,
at which time the "i" (from the surrounding environment) will have a
value of 3. Hope this makes it a bit clearer.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Jarek Zgoda wrote:
> Sorry, gals and guys, but if you force us to buy something irrelevant
> like VC2003, you will not get our sympathy.
Oh, no. And just when our bank account was getting full from your
appreciation of our efforts.
--Scott David Daniels
[EMAIL PROTECTED]
--
developers used the Visual
Studio toolkit.
As to MinGW, nobody has signed up to commit long-term to doing the PyDev
work that is required to get (and keep) it working. Such a developer
would be welcome. There _are_ notes out there on the web to help you
get such things going; I have done my own
Istvan Albert wrote:
> Scott David Daniels wrote:
>
>> To paraphrase someone else (their identity lost in my mental fog) about
>> learning VI:
>> "The two weeks you'll spend hating vi (or vim) as you learn it will
>> be repaid in another month
Scott David Daniels wrote:
> Jarek Zgoda wrote:
>> Sorry, gals and guys, but if you force us to buy something irrelevant
>> like VC2003, you will not get our sympathy.
> Oh, no. And just when our bank account was getting full from your
> appreciation of our efforts.
Sorry gu
s everything to do with what
you prefer.
The Cookbook comes later. As does getting all the way through the
challenge, but for puzzle lovers, it can be great fun.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
through its language systems, and has
used that edge to knock off other compilers (such as WatCom) by
providing header files that are not standard C compatible.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
st a strawman, but that was really
for other readers, not for you.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
>
More like:
[(i, "")[i in ("None", None)] for i in [a,b,c]]
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
pil/handbook/image.htm - The Image
> Module
That, by the way, is the "PIL" library that you'll see a lot about --
The Python Imaging Library that the effbot is justly proud of. You
won't do better than that.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Also, there are many free software programs that use special
> features of GCC and cannot be compiled using another compiler.
This is precisely what bothers me about standardizing on GCC --
lock-in is lock-in whether you must pay cash or not.
--Scott David D
quot;red", "brown"])
for line in file:
words = set(line.split())
if words & search_words:
for word in search_words:
if word in words:
if word == 'red':
print 'weasels rip my flesh'
else:
print word
...
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ten discard the cStringIO object.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
rmat it, use '%.2f' % (float(a)/b)
Sybren has this right. If you follow everyone else's advice,
you'll eventually discover:
>>> print round(11024. / 5000.1, 2)
only gives you "2.2", not "2.20" (which is what, I suspect, you want).
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
umerate(zip(a, b)) if v[0] == v[1] ]
>
> You're right, that design stemmed from my first broken version.
Or even deconstruct to avoid the (very mildly confusing) v[0], v[1]:
[i for i, (left, right) in enumerate(zip(a, b)) if left == right]
--
--Scott David Daniels
[EMAIL PROTECTED]
--
ht
'__getattribute__'
method which will get used, but I doublbt thre is a promise for
an exposed name '__getattribute__'.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ory
(flag manipulation), you can get these values in different ways.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
t tracked the
"decimal point" (or "binary point" or whatever) in the mind of the
programmer, not in the state of the hardware. There never was
"fixed point hardware," it was simply a way of viewing the results
of the gates of the same hardware we use today.
--
Several have suggested struct, I'd suggest you look at array:
import array
v = array.array('B', [1, 2, 3])
for i in range(17):
v[i % 3] *= max(1, i // 3)
v.tostring()
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
#x27;__name__',
'pywin', 'keep', 'item', 'globs']) # Faster to test
globs = globals()
for item in dir():
if item not in keep:
del globs[item]
del globs, item
Note that this leaves all imported modules imported.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Network Ninja wrote:
> Scott David Daniels wrote:
>> keep = set(['__builtins__', '__doc__', '__name__',
>> 'pywin', 'keep', 'item', 'globs']) # Faster to test
>> globs = globals()
t; It means that the select command does not add but concatenates the
> different amounts. Why ?
Sounds like you selected columns are strings, not numbers.
Remember '123.5' + '-23' is '123.5-23', while 123.5 + -23 is 100.5
You need the amount column of the transac
simply bugs in the theory."
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ents out; you'll get better advice.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
27; to indentation
Riffing on this idea:
message = """
This is line 1
This is line 2
This is line 3
""".replace("""
""", '\n')[1:]
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
janama wrote:
> i can use this:
> aaa = 1
> result = eval("self.b%s.SetBitmapDisabled(self.yellow)" % aaa)
>
> How would i to achieve this with getattr() ?
result = getattr(self, 'b%s' % aaa).SetBitmapDisabled(self.yellow)
--Scott David
27;, (msb * 65536 + low for msb, low
in itertools.izip(sbytes, uhalf)))
That was fun.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
uld require a lot of
code generated on each operation, and without common hardware, the
infinity / denormal / NaN behavior would mean code at every floating
point operation. The C standards body was not interested in that work.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
done before it gets to your C code. I suspect
if you don't define a __len__ method, you'd suppress this.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
system for C++ code,
See Knuth on Literate Programming and the "Web" systems (e.g. CWeb).
His goal is to look good typeset with explanation, and extract-to-compile.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
big_dispatch_table = {}
for function, keys in [
(doStuff, ["abc", "def", "xyz"]),
(doOtherStuff, ["pqr", "tuv", "123"]),
... ]:
for key in keys:
big_dispatch_table[key]
ry:
<<>>
finally:
old_output, sys.stdout = sys.stdout, old_output
old_output.close()
print 'Output safely written to:', old_output.name
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
# You could go over here if threading is an issue
instance = super(class_, Limited).__new__(
class_, *args, **kwargs)
class_._held_instances[id(instance)] = instance
return instance
return ra
ally predictable (and hopefully testable)
parts with a logable communication pattern. You still may have
trouble (to which the best reply is, "See, we told you so.").
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
t). All of this was
in the mid seventies or earlier.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> I can't speak for your code, but this is the most common use of keys in
> my coding:
> # d is some dictionary
> keys = d.keys()
> keys.sort()
> for k in keys:
> #blah
This you can rewrite quite effectively as:
for k in sorted(d):
o apply (and looking for things
like "__metaclass__" and "__slots__"). For more on all of this read
the language reference, esp. the "Data Model" section, and probably that
on the difference between old-style and new-style classes.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
bject):
...
is a new-style class.
class Whoever(SomeClass):
...
is an old-style class if SomeClass is an old-style class,
and a new-style class if SomeClass is a new-style class.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
things go, at least by comparison.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
able graphs).
Also look at PyGame if you want to paint screens.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
mn field1.
The proper SQL clause is:
... WHERE field1 LIKE 'e*' ...
But, you did not include that part of the program, so you wound up
crippling those who were willing to try to help you, because you
thought you kinda-sorta knew what was going on (but not enough to
fix it). Find "
d test. Your
reasoning is off in the ozone. You waste a lot of time creating
great theories; make tiny theories and _test_ them.
<>
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ant is mutability
in a pattern, read the array module documentation as well.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
.
But copy-on-write in the presence of reference counts doesn't do the
mad useless-copy stuff.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
; 429, or _something_ problem specific. saying
that x must be an int is almost always simultaneously too specific and
too general.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
yprog.A('simple')
self.assertEqual(sys.stdout.getvalue(), '---simple---\n')
def tearDown(self):
sys.stdout = self.held
if __name__ == '__main__':
unittest.main()
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
the best three python books they own?
Sounds great! Send me $1.50 and I'll send you my six answers.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
is to modify the
the interpreter. We could call the new language "Python?!", or
actually use an interobang if Unicode has such a character.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
return self.forwarder(name)
raise AttributeError("%r object has no attribute %r"
% (self.__class__.__name__, name))
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
>
> class Forwards(object):
>
> to_forward = set(['flush', 'read', 'write', 'close'])
>
> def __init__(self, backends):
> self.backends = backends
>
> def forwarder(self, methodn
stir" in Spanish has a
> similar meaning, but not exactly the same, as "to resist"
As we all know, a "resistir" has a reactance that doesn't vary with
frequency, unlike an "inductir".
--Scott David Daniels (who couldn't resist)
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
g the arg to "reversed" to a list.
While "sorted" could be special cased for those cases, the chances of
real useful code containing, "sorted(xrange(a, b, c))" are pretty slim.
If you don't have to build the list in memory, returning a list can make
a program tha
any menu elements are
ordered alphabetically, the result of changing the language will be
jarring to the user, as well as expensive to implement.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
they seem to contradict everything a power-point wielding IT executive
who understands everything "from a 5000 foot point of view" knows to
be true. I really wish I knew how to explain these things politically.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
s in restricted ranges and varying orders); the contrast may be
more substantial even to a viewer with full color vision.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
tectural directions at the same time as you
learn an assembly language. You can still execute it (plenty of
simulators are available for free), and you can get an idea of kinds of
efficiency without having to learn five or six architectures.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mai
1001 - 1100 of 2115 matches
Mail list logo