Alexzive wrote:
I'd like to get the same result of set() but getting an indexable
object. How to get this in an efficient way?
Go look at Ray Hettinger's recently announced recipe for 'OrderedSet':
http://code.activestate.com/recipes/576694/
--Scott David Daniels
S
le hb <= ha: # again your comparison here
yield hb
hb = next(b)
except StopIteration:
pass
if first is not flag:
yield first
for first in remainder:
yield first
--Scott David Daniels
scott.dani...@a
. def myMethod(self):
... pass
c = MyClass()
m = c.myMethod
m is c.myMethod
False <--- What? Why is that?
Method access binds the instance in dynamically.
Comparing m is c.myMethod
is like comparing m is partial(MyClass.method, c)
--Scott David Daniels
scott.da
times are recorded in a dictionary, then
the insertion order has to be sorted prior to iteration
which makes iteration go from O(n) to O(n log n).
The double-linked list part could be done with weakrefs and
perhaps Aahz would relax a bit.
--Scott David Daniels
scott.dani...@acm.org
--
t as many resources as you like;
it really only decides who gets the lock; you decide what you only do
while holding the lock (the other threads are running, except those
waiting for the lock).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
lamber...@corning.com wrote:
... Removing the comment character to increase the stream
reference count fixes the program, at the expense of
an extra TextIOWrapper object.
But you do create that extra TextIOWrapper, so there should
be no crying about its existence. If you rely on the d
o make
this more obvious, I'm sure we'd be happy to "fix" the documentation.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
is can be very useful for certain kinds of table-driven code (where
you may want to be able to efficiently store lists of functions to call
in data files).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ay what version of Python you are working with,
how the code you tried, and the results you got.
Using Python 3.1, I get:
>>> "\u003cb\u003eMar 17\u003c/b\u003e" == 'Mar 17'
True
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
racter), not two
characters long. I think its sad that 'C:\Thesis' doesn't cause
an error because there is no such character as '\T', but I am
probably excessively pedantic.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ste rather than
type. If you do that, you get the backslashes (and you better be
prepared for that by using r'' to paste into).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
sense?
Sorry, this latter rant has been building up for a while (spurred on by
a sojourn into the unittest code where they have the private disease in
spades.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
short time.
Perhaps a "strange variable model," huge integers, defining a function,
class, using modules, what "global" does and means (if you have time)
and a hand-wave about types.
[other excellent choices deleted]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
hayes.ty...@gmail.com wrote:
Any suggestions where to start?
Start by reading the docs on the difflib module, perform some of
the examples, and attempt to solve it yourself. Once you get in
trouble, show a clear example of what you think went wrong.
--Scott David Daniels
scott.dani...@acm.org
f)(x - y for x, y in zip(self, other))
def __repr__(self):
return '%s(%s)' % (
type(self).__name__, list.__repr__(self))
x = Vector([1,2])
x + x + x
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
rn BigNumber.__new__(class_, something * 3)
then you can do something like:
print 'dog = %r = %016X' % (HugeNumber(123), HugeNumber(123))
Hope that helps.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
T/Method/SpaceImpact/code/tools/ProfileViewer/"
"performance_profile.csv", "rb")
pass1(csv.reader(source))
source.seek(0)
pass2(csv.reader(source))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
extract the contents,
Or, you can use the tarfile module to extract it using Python.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ng you how to get to some of what you are looking for
is assistance. If you want exact answers to an array of questions,
pay someone to fetch you the answers, or do your own homework.
Clearly I am too grumpy this weekend.
Sorry about that,
--Scott David Daniels
scott.dani...@acm.org
--
http:
ish, while reducing its utility as a clickie.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Alan G Isaac wrote:
On 3/29/2009 3:43 AM Scott David Daniels apparently wrote:
OK, that was plain rude. a couple of questions is not six questions.
A reply telling you how to get to some of what you are looking for
is assistance. If you want exact answers to an array of questions,
pay someone
Alan G Isaac wrote:
Alan asked:
- Why does a Variable need a master? - If s is a StringVar instance,
why is str(s) its name rather than its value?
On 3/29/2009 2:46 PM Scott David Daniels apparently wrote:
The answer to that, grasshopper, lies in the answer to the question,
"Wha
Aahz wrote:
In article ,
Daniel Fetchinson wrote:
===
Changes
===
2.6.1.1 -- 2009-12-07
I guess it should be 2008-12-07 :)
That's just the time machine in operation.
I thought I smelled ozone.
--
http://mail.python.org/mailman/listinfo/python-list
hoping for 2.6.2
final on 10-April).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
mark.sea...@gmail.com wrote:
...
I'm not sure what the "something * 3" does? Here is the printout:
dog = HugeNumber(369) = 0171
But I was able to put the concept into practice.
It was simply meant to be an absurd example.
If you could apply it, you've got the
t_val, reg_info):
self.reg_info = reg_info
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
st of which were subclasses of the
base RegisterValue class with different bit name lists.
Remember that just because a Register might have a name, doesn't mean
its string representations don't necessarily reflect the contents of
the register (lists show their contents, for example). I think you&
b.org/~esr/faqs/smart-questions.html
We need more information.
You can oen a command window (run cmd.exe) and type
C:> python -m idlelib.idle
This may give details about exactly what is happening in
output in that command window.
--Scott David Daniels
scott.dani...@acm.org
--
http://ma
'/desktop', /desktop/pc', '/desktop/mac']
Should the answer be ['/desk'] or ['/desk', '/desktop'] ?
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
"A wizard is someone who can fix his own mistakes quickly."
Heaven save us from wizards.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
break
else:
raise Exception("Shouldn't have run out of primes!")
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
fetime. Make some
clients slow and others fast in your mix.
Performance testing (seeing how much you can accomplish in a second) is,
I'd argue, a later phase (where you need a good model of actual use).
First, go for correctness under "strange" interactions.
--Scott David Daniels
entForm.Control = FancyControl
ClientForm.HTMLForm = FancyHTMLForm
But substituting monkey-patching for class method insertion seems like
you are going from one quick and dirty technique to a slightly nicer
quick and dirty technique.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.pyth
Grant Edwards wrote:
On 2009-04-07, Grant Edwards wrote:
On 2009-04-07, Scott David Daniels wrote:
Grant Edwards wrote:
I realize that technically all methods are added to classes at
"run-time", but what I'm talking about is this:
...
ClientForm.Control.__eq__
VPython. Especially if MayaVi is too much. It has provisions
for running with cross-eyed and wall-eyed 3-D as well as the cheapo
colored paper glasses and the seriously not cheapo shuttered-glasses /
special display card option.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org
Grant Edwards wrote:
On 2009-04-07, Scott David Daniels wrote:
File "/usr/lib/python2.5/site-packages/ClientForm.py", line 2016, in
add_to_form
Control.add_to_form(self, form)
TypeError: unbound method add_to_form() must be called with FancyControl
instance as firs
print "decompressed: %d+%d+%d: %r %r %r" % (
len(a), len(b), len(c), a, b, c)
--Scott David Daniels
scott.dani...@acm.org
> decompressor = zlib.decompressobj() # wbits
--
http://mail.python.org/mailman/listinfo/python-list
, and start each use with something like:
from base_functions import bibble, babble, bobble, bome
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
erial port data, particularly pySerial results...
Cheers
Stu
Well, search for Smart Questions. I have no idea what your OS is, nor
what level of "virtual serial port" you want/need. All anyone could
do with your current request is guess what you need and try to steer you
towards it.
-
n _any_ language (likely they'll have an Objective C way).
Then pop back over here (or even better a python-mac list, where
they'll be familiar with how to do lots of stuff) and you can get
help getting python to either do the same thing or talk to a bit
of code that does the byte-trans
Stuart Davenport wrote:
On 11 Apr, 08:52, Scott David Daniels wrote:
Stuart Davenport wrote:
... I'm on a OS X, python 2.5 Then the GPS program I have
running on my MAC, RouteBuddy, can read the data from that serial port
as standard.
I'ms confused by this statement. Wha
I could plug in
anything but a USB connector, an ethernet connector, a firewire
connector, headphones, speakers, a display connector, or a
power cord.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
hy I
was trying to figure that out.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
)
use something like:
from xml.etree import cElementTree as ET
...
parsed = ET.parse('CharacterID.xml')
for node in parsed.getiterator('osArchitecture'): print node.text
or if you have the data in a string,
root = ET.fromstring('string')
print root[
length, you
using the magic constant for practically everything, "42", can give you
the chunk size to use:
ord("4") * ord("2") * int("42") == 109200
:-)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ookrin wrote:
I am still learning. And it's not that I won't take the advice
for using ElementTree, I just currently don't know anything about it.
I just didn't want to say, "I have no idea what you're talking about!"
to Scott cause I figured that would be
s cut into
pygame to see how _it_ accomplishes your task, and mimic that.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
e, label):
# here you know it was the (sequence+1)th entry named label
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
on as why:" if >= Py2.6
logging.error('%s: %s encountered' % (
(why.__class__.__name__, why))
if not isinstance(why, Exception):
raise
data = conn
parts.append(hex(v))
return '%s(%s)' % (self.__class__.__name__,
'|'.join(parts))
for _name, _value in Status._bits:
setattr(Status, _name, Status(_value))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Does anyone know if the Testing in Python mailing list
is broken or turned off? It was running almost too many
messages, but now there has been a _huge_ silence.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
file for all the gory details.
Congratulations. A great success.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
Does anyone know if the Testing in Python mailing list
is broken or turned off? It was running almost too many
messages, but now there has been a _huge_ silence.
--Scott David Daniels
scott.dani...@acm.org
Never mind, I've seen a couple posts.
--
for "is" comparison, how about:
max(id(x) for x in mylist) == min(id(x) for x in mylist)
It has the advantage that if [id(x) for x in mylist] = [2N, 1N, 3N],
you get the answer you desire.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney wrote:
... the upgrade police have not been given your address yet
Don't be so sure! We of the Python Secret Upgradepolice ...
--
http://mail.python.org/mailman/listinfo/python-list
one great editor and one abomination.
Opinions differ, however, on which one is the abomination. :-)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
d
you that behavior allow the other answer to someone who wanted
the opposite.
sys.stdin is not a keyboard driver.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
; for k in D:
> exec '%s=D[%r]' % (k,k)
> print i, j, k
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
:
function()
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
gitulyar wrote:
On Apr 17, 5:23 pm, Scott David Daniels wrote:
Marco Mariani wrote:
Piet van Oostrum wrote:
funclist = [func01, func02, func03, ... ]
for i in range(1,n):
funclist[i]()
Or myscript.funclist[i]() from another module.
...
For example, you could do it like:
funclist
pyt...@bdurham.com wrote:
Scott,
Newbie question (and I'm not the OP): What are your thoughts on having
your decorator add an attribute to the functions vs. placing the
functions in a global variable?
def _included(f):
f._included = True
return f
I tried experimenting with
hung up on terms like
"Pythonic". Treat such labels are more of a red flag and get people
who throw out the term to explain why.
Think of it as a comment like "that has a bad code smell" -- you can do
it if you like, but you should have satisfied yourself that your case is
su
changed. The changes to Python 3.x
is a language change, but Python has been _very_ conservative about
changing (as opposed to extending) the language.
There are only a few languages that might plausibly called "Basic",
and Dartmouth Basic has maybe the best claim to that name.
--Scott Dav
it."
How did you manage to keep your reply so meek?
You must be a really well brought up person.
:-)
Possibly because the proper reply was probably, "You only THINK
you know how it works. _I_, on the other hand, know how it behaves,
even if I don't know how it was supposed to wor
good
or evil.
The goto is a sharp, spiky dangerous tool that seduces
people into thinking of using it far too often. It should
be used with the same respect you approach beautiful well-
armed people of questionable morals who you find attractive.
--Scott David Daniels
scott.dani...@acm.org
called "immune to programming."
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
look for that work (and perhaps FePy or unladen swallow).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
wrote a book entitled "My Cat is Object-Oriented."
His basic premise is that, while everyone understands what you mean
when you say something is object-oriented, everyone's understanding is
different.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ll be good enough.
This technique takes advantage of the fact that trying several different
algorithms will be much easier in Python than in C or C++.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
iteration,
which is placed on a canvas.
Other?
Are there obvious considerations in the choice?
(Right now I do not need to interact with the squares,
but in the future I may need to.)
You should have said, but I'll guess you are using Tkinter.
I'd put the rectangles on a canvas, myself.
--S
data, then do UPDATEs and
INSERTs to get the data spread out into the main tables. You (the OP)
might try a scheme like that.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ericwoodwo...@gmail.com wrote:
On Apr 21, 4:01 pm, ericwoodwo...@gmail.com wrote:
On Apr 21, 3:36 pm, Scott David Daniels wrote:
I forget the name of the SQL Server bulk loader,
bcp (bulk copy) was the name of the bulk loader. I just remembered.
Sorry, no more exciting advice
C:\WhereEver> python25
Personally, I would use the name "python25.cmd", but that may just be
superstition on my part about the difference between .bat and .cmd
files.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
confuse your reader (they may be fooled into
looking up what the "__callFn__" special method does in addition to
normal method behaviors.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
it, while the
parent process will get() them as long as there is an active
subprocess
Well, if the protocol for a worker is:
:
queue.put(result)
queue.put()
queue.close()
Then you can keep count of how many have finished in the consumer.
--Scott David Daniels
ening.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
someone else's
trade-offs, which likely fail to match your use case. You might check
gmane.comp.python.scientific.user
which I think is gmane's mirror of comp.python.scipy.user, but I'm
not certain of the mailing list name. Certainly the people over there
regularly deal with accessi
jt wrote:
JOB: Statistical Programmer ...
Job postings are not in order here, they are off-topic.
If you go to
http://www.python.org/community/jobs/
You will see a jobs posting board that will happily post your job.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org
function. Right now
you can get the function name and (with a bit more effort) its module.
Imagine debugging a pile of code that includes a module with:
import random
def random.random():
return .42
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
early version of Crunchy
are demonstrated in this screencast.
http://showmedo.com/videos/video?name=143&fromSeriesID=143
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
most likely a
single comparison for a dict whether it is a hit or a miss.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
file(src, count=128 * 128)
block.shape = (128, 128)
and then you've got your sub-block.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Marco Mariani wrote:
Scott David Daniels wrote:
I am afraid it will make it too easy to define functions in other
modules remotely, a tempting sharp stick to poke your eye out with.
Imagine debugging a pile of code that includes a module with:
import random
def random.random
otherwise unchanged.
But the compiled C extension modules are called ".pyd" files and
they are built separately from the execution time and thus do not
suffer the faults of which you complain.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Travis wrote:
... I've noticed that every one of you is wrong about programming.
Since I can't say it effectively, here's someone who can:
http://www.youtube.com/watch?v=XHosLhPEN3k
That's the answer.
That is a wonderful link. Thanks for sharing.
--Scott David Daniels
s
ode before it works fully correctly.
Therefore, you had better write code so simple that you can
know what is going wrong with it. If your code is too hard
to understand for the average programmer, you are either four
times as brilliant as those "average" progr
ct, is what would happen if you
could kill it).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
. It should be more based on framework type.
b. It should have all the features present in mod_python.
These two goals conflict. You'll need to use your brain to discover
what is best for your application. In general "have all the features
of" and "but better"
block.append(numpy.array(cx))
block.append(numpy.array(px))
return (''.join(block[0::3]),
numpy.concatenate(block[1::3]),
numpy.concatenate(block[2::3]))
# The following repeats 128, to avoid initial read issues.
# Treat the diff twixt the
shiny fun!!! How's this for that:
def monge_shuffle2(deck):
even = (len(deck) ^ 1) & 1
return deck[even::2] + deck[-2::-2]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
t;
If you define the short-circuit boolean operators "and" and "or" as
Python does, the idea of "most anything is True" menas you can have
code that does:
v = look('here') or look('there') or look('everywhere') or default
This is
alk from PyCon:
Title:
Batteries Included! Python on Low Cost Tiny Embedded Wireless Devices
http://blip.tv/file/1947528
You might want to try contacting them.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
else:
return # success -- have the lock
raise ImTiredError
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers wrote:
d = {}
for line in open(thefile):
arr = line.strip().split()
d[arr[0]] = arr
Sorry, not picking on Bruno in particular, but I keep seeing
this formulation around various places.
When does line.strip().split() ever differ from line.split()?
--Scott David
t VLMLegacy.WINGTL.Conditions.Conditions as WINGTL_Conditions
...
b = VLM4997_Conditions(2)
b.test()
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
MRAB wrote:
Scott David Daniels wrote:
Bruno Desthuilliers wrote:
d = {}
for line in open(thefile):
arr = line.strip().split()
d[arr[0]] = arr
Sorry, not picking on Bruno in particular, but I keep seeing
this formulation around various places.
When does line.strip().split() ever differ
is a namespace to hold modules (possibly more).
I don't understand why you don't use files like:
VLMLegacy/
__init__.py
Reader.py
VLM4997.py
WINGTL.py
But, presuming some kind of rationale,
put the code you want in
VLMLegacy/VLM4997/__init__.py
Dale Amon wrote:
On Wed, Apr 29, 2009 at 01:12:33PM -0700, Scott David Daniels wrote:
Dale Amon wrote:
I am trying to get to the heart of what it is I am
missing. Is it the case that if you have a module C in a package A:
A.C
that there is no way to load it such that you can
prueba...@latinmail.com wrote:
It is probably out of habit of using the generalized idiom:
line="a,b,c\n"
line.strip().split(",")
Ah, thank you. I just couldn't figure out where it started.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
.reader import Reader
from VLMLegacy.VLM997.conditions import Conditions
...
The the consuming python code can do:
import VLMLegacy.VLM997
something = VLMLegacy.VLM997.Reader()
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
1601 - 1700 of 2114 matches
Mail list logo