you should investigate __import__.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
your zip grows with every change.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
To discover what is happening, try something like:
python -c 'for a in "ä", unicode("ä"): print len(a), a'
I suspect that in your encoding, "ä" is two bytes long, and in
unicode it is converted to to a single character.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
rint [id(x) for x in [[] for x in header]]
So, I think you should use:
columnMap = dict(zip(header, ([] for x in header)))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
e IPython shell, and I would suffer
if I didn't have it in postgres, but not while editing python.
You'd be amazed at how much ActiveState's Python _can_ and _does_
guess/infer about available methods. It is pretty fancy (even for
an old stick-in-the-mud "Lave my keyboard alone&q
#x27;two.xml', "I don't give a damn.")
nz.writestr('one.xml', 'Frankly, Scarlett, ')
nz.close()
Which will produce the same output as the original, confounding
your user. You could just write the new values out, since .read
picks the last entry (as I
Kurt Mueller wrote:
Scott David Daniels schrieb:
To discover what is happening, try something like:
python -c 'for a in "ä", unicode("ä"): print len(a), a'
I suspect that in your encoding, "ä" is two bytes long, and in
unicode it is converted to to a
well past the time SomeClass
is fully built.
Typically, classmethod is used to provide alternate constructors
for a class, though it does have other uses.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ollowing code to print?:
print 'NoneUnique:', Spam() is Spam()
Objects are created and then used somehow (including being put
somewhere), not created int a "variable."
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
convenience tools (dinky little functions and classes that I would
otherwise waste time scratching together each time I needed them).
They obviate the need to fiddle with site.py.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
tree abstraction should be
responsible for producing its leaves, rather than a blunderbus that
doesn't know where one container abstraction ends, and its contents
begin. In other words, I'd like to see thigs like "flatten one layer."
--Scott David Daniels
scott.dani...@acm.org
am
return "spam is a tasty %s-like food product" % func(self)
TypeError: ham() takes exactly 1 argument (2 given)
Now it is tough to use obj.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
a has the type of its current value.
any kind of object can be stored in any variable.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
node = node.right
Not so hard, really.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ed it for assignment
statements, causing much consternation when our source code displayed
funny on new-fangled terminals. So, just an unfortunate setting on
the time machine is the basic flaw.
--Scott David Daniels
@Acm.Org
--
http://mail.python.org/mailman/listinfo/python-list
here ...
What's wrong with:
for _ in (None,):
... do stuff ...
if (check1_failed)
break;
... do even more stuff ...
... cleanup ...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
base, dirs, files = next(os.walk(dirn)) # older: os.walk(dirn).next()
current = dict((name.upper() for name in dirs + files)
...
changed = some_name == current[some_name.upper()]
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ces and re-isolate until you
have a small bit of code with the issue. This is why we point
people to smart-questions(*) so often.
(*) http://www.catb.org/~esr/faqs/smart-questions.html
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ages directory, Python 2.6 and later will use it to
find .pth, .py, .pyw, and .pyd files (as well as .pyc and .pyo
files). You may find changing your personal site-packages directory
(and/or a .pth therein that you manipulate) will address the issues
that you are planning to solve with virtualenv.
ning the sample code with the
sample data.
For extra points, identify the Python version you are using.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
is rather literal, so be careful if copy/pasting more
than one line, or a line that was wrapped.
Also, you can type into the cmd window:
Alt-Space E P
Alt-Space
E
P
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python
ng as
fidgety as multiprocessing.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
CTO wrote:
...
If OrderedDict winds up being backported, will you include it
in 2.x?
I see it in the 2.7 sources.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
octets if you
prefer), and not use it if what you expect is "text." Your code
becomes less confusing by using 'b' properly, even if you see no
particular difference.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
x27;t borrow trouble
you don't need. Rethink your problem and write it in Python. Don't try
to do a line-by-line translation, you'll just have a slow awkward Python
program with a Java heart.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
n real-
world code, using this package? My google-fu wasn't strong enough to
find anything directly :-(
Try writing one yourself, as you are learning the interface. The
package authors will love it, and will probably be overjoyed to
help you as you stumble.
--Scott David Daniels
d unicode to that destination.
If you are running under IDLE, print goes to the output window, and
if you are running from the command line, it is going elsewhere.
the encoding that is being used for output is sys.stdout.encoding.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
esn't match the corresponding .py file, the
.py (or .pyw) file is "compiled into either a .pyc or .pyo, and the
contents of that .pyc or .pyo are used to build the module.
So, importing a module will write a .pyc or .pyo file unless an
appropriate .pyc or .pyo file is found.
--Scott David Dani
iles are getting imported from the file
system and when. "-v" iswhat it got, "-vv" is everywhere it tries.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
pyw=Python.NoConFile
C:\Projects> ftype Python.NoConFile
Python.NoConFile="C:\Python31\pythonw.exe" "%1" %*
It is possible you installed something that switched those settings.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
way, it is safe
to simply uninstall-reinstall a python .msi in order to make that
version of python be the default. uninstalling only removes that
which it installs, so after a reinstall, your other libraries are
still safely there.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
oblem were to be split into groups of 3, I've tried something like:
... Ideally, my outcome would be
[1,2,3]
[4,5,6]
[7,8,9]
[10,11,12]
for i in range(0, len(a), 3):
segment = a[i : i +3]
print segment
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.o
print r.size
print '-'
r.size = -3,7
print r.size
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
for stream in streams]
for element in heapq.merge(*keyed_streams):
yield element.obj
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
return 'two'
def __str__(self):
return 'three'
b = B()
print b, unicode(b), [b]
By the way, pasting code with non-ASCII characters does not mean
your recipient will get the characters you pasted.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
fraught with traps for
newbies, who might want to ask for, for example:
def setter(self, (height=4, width=3)):
the Python 3.X world is wisely losing the unpacking in parameter
passing trick.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
nk of your reader, not just your operational environment, unless
you are programming on your own and don't care to share.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
uuid wrote:
Any recommendation on an alternate way to build a priority queue to use
with a "one producer, many consumers" type multiprocessing setup would
be welcomed!
? "one producer, many consumers" ?
What would the priority queue do? Choose a consumer?
--Scott Davi
uuid wrote:
Scott David Daniels wrote:
? "one producer, many consumers" ?
What would the priority queue do? Choose a consumer?
Sorry, I should have provided a little more detail. There is one
producer thread, reading urls from multiple files and external input.
These urls have
ct?
At least vim and emacs can do so. Some other editors redefine
standards in order to make their work easier.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
re[0] - post[0])
print 'Globals added: %s, removed: %s' % (
post[1] - pre[1], pre[1] - post[1])
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
()])
'[repr]'
Now if you ask _why_ call repr on its elements,
the answer is, "so that the following is not deceptive:
>>> repr(["a, b", "c"])
"['a, b', 'c']"
which does not look like a 3-element list.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
, 'size', len(dir())
from x import y as z
print __name__, 'size', len(dir()), 'completed import of', z
try:
print my_name
except NameError, e:
print '%s found unhandled NameError: "%s"' % (__name__, e)
sys.exit()
produces:
__main__
__main__ size 8
x
x size 6
x size 7 completed import of 42
x found unhandled NameError: "name 'my_name' is not defined"
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
e in Portland, where you'd better recycle it. ;)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
starting with a lowercase g is removed :)
You (the OP) don't seem to know about PEP 8, which advises 4-space
indents, all-caps constants, and many more style specifics.
http://www.python.org/dev/peps/pep-0008/
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ild(c)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
y there?')
as opposed to:
try:
v = mumble.field
sys.warning('field was actually there?')
except AttributeError:
pass
The idea is to make it clear what you expect might go
wrong that you are prepared to handle.
--Scott David Daniels
scott.dani...@a
:
def find_names(value, dictionary):
for name, val in dictionary.items():
if val is value: # note: "is", not "=="
yield name
x = 123456
y = 123456 * 3 // 3
z = 123456.0
q = y
print list(find_names(y, locals()))
--Scott Davi
ibuteError:
pass
Then you could easily fail to notice that
you had written 'warming' instead of 'warning'.
Well, if you look, you'll discover that warning is not in the
sys module at all, but in the logging module.
So the original example already demonstrated t
precip_feb', 'precip_mar', 'precip_apr',
'precip_may', 'precip_jun', 'precip_jul', 'precip_aug',
'precip_sep', 'precip_oct', 'precip_nov', 'precip_dec'] * 2
start = 2
ordered_raster_list = multi_months[start - 1: start + 11]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
_foot = %s' % (
month, inches_per_foot))
might print:
Month is now: 11, inches_per_foot = 11
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
=> 0.49998662654663256
What would your missing something be for tracer(math.sin)?
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
norseman wrote:
Scott David Daniels wrote:
kj wrote:
Suppose that f is an object whose type is 'function'.
Is there a way to find out f's list of formal arguments?...
I can write a wrapper now:
def tracer(function):
def internal(*args, **kwargs):
print
(writing a
setup.py, using "python setup.py build"; "python setup.py install",
you would discover, by what I would guess to be your astonishment, that
a .pyd file got put in site-packages or wherever.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ld with mingw32, not the full-blown gcc
environment when working on Windows at home. When at work, it is
my employer's choice what tools I use (Visual C/C++, Intel C/C++ on
Windows usually; more varied on *ix).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
is:
(start, -end)
Maybe it will prove helpful to you as well.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
)
v.shape = (16, 8)
sum(v.transpose()) / 8.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
hing like:
C:\sound\effects> cd C:\
C:\> python -m sound.effects.surround
(2) you can run
python -v surround.py
or
python -vv surround.py
To see files opened (or attempted and opened for -vv) in order to
discover what exactly is tried and in what order on imports.
Warning: the o
at least identified. I expect
nobody wants to crawl into that code to make your case work,
especially since you can switch to 2.6 and have it work. The
import code is said to be quite nasty and being rewritten/redocumented.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Daniel wrote:
Thanks for doing the experiment. I'll begin to consider testing with
python 2.6 for a possible upgrade.
I hope you know you can have different minor versions installed
simultaneously.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/p
fining and declaring types on creating test cases. Then
you have nicely unit-tested code for only a bit more effort than you
had to spend on gettting a program to run before.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
I'd call it F_3, but using a Germanic F (Farey sequence limit 3).
Do I get a banana or one with a few more ans?
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ndidate is coming 30-May, with final release on 27-June:
http://python.org/dev/peps/pep-0375
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
f = [functools.partial(add, n) for n in range(0)]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
to ask them to define a particular module and go
names inside that module.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
#x27; % (
sum(1 for w in weights if w > 0)))
for n in range(10):
gen = sample_without_replacement('abcdef', [32,16,8,4,2,1])
print gen.next(), gen.next(), gen.next()
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Christian Heimes wrote:
abolotnov schrieb:
Hi, I am trying to build mySQL-python with python 2.6 on windows and
can't figure what's wrong with it.
...
You need Visual Studio 2008. Other versions of VS aren't supported by
Python 2.6.
You might be able to use mingw32 as well.
p=u.read()
open(filename,"w").write(p)
with this:
try:
u = urllib2.urlopen(link)
p = u.read()
except urllib2.HTTPError:
pass
else:
dest = open(filename, "w")
dest.write(p)
dest.close()
--Scott
2, 123, 1234, 12345, 123456, 1234567:
print '%s\t%s=%r\t%s=%r' % (n, GroupedInt(n), GroupedInt(n),
GroupedInt(-n), GroupedInt(-n))
1 1=1 -1=-1
12 12=12 -12=-12
123 123=123 -123=-123
12341_234=1234 -1_234=-1234
12345 12_345=12345-
-file
and file-to-Python, where the other user of the file may be
a completely different program.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
OSS wrote:
Plone Developer, Washington, D.C. - Relo OK | 55-75k
You should post this to the Python Jobs board, and not here.
http://www.python.org/community/jobs/
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Sumitava Mukherjee wrote:
On May 27, 8:08 pm, Scott David Daniels wrote:
Sumitava Mukherjee wrote:
I need to randomly sample from a list where all choices have weights
attached to them. The probability of them being choosen is dependent
on the weights.
I am not sure why everybody is
n a
worst-case analysis. I suspect the default is shifting towards
average case (although it may already be there). Certainly best
practice for the next couple of decades would be to be explicit
about the meaning
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
Scott David Daniels wrote:
[a real correction and a bogus one]
raise ValueError('Samplng more than %d without replacement?' % (
sum(1 for w in weights)))
That would be len(weights)
Yup, probably I should have just saved len(combined).
but I think your first v
.html#itertools.product
(new in 2.6, but code works in lower versions).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
member thudfoo wrote:
On 5/31/09, Scott David Daniels wrote:
Johannes Bauer wrote:
I'm trying to write a function in Python which ...
Look here:
http://docs.python.org/library/itertools.html#itertools.product
(new in 2.6, but code works in lower versions).
How would one go
Djames Suhanko wrote:
Hello, all!
Did you know the bmp32 module for linux? This module can to load bmp
image with alpha channel where is not supported others images formats.
Hmmm, why do you think PNG and TGA do not support alpha?
--Scott David Daniels
scott.dani...@acm.org
--
http
buntu.
Sounds like this might be a capability problem on your embedded system.
Look for and install PIL (the Python Imaging Library). It might help if
you are not simply running up against hardware issues.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
re, but one of intent. A true deepcopy could
survive making a copy of the number 23, but might fail as it makes
a copy of None, True, or False. Certainly a dictionary might or
might not be copied, depending on how the dictionary is used.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.py
Michael H. Goldwasser wrote:
On Monday June 1, 2009, Scott David Daniels wrote:
Michael H. Goldwasser wrote:
> I'll accept the "small price for flexibility" that you
> note, if necessary. However, I still desire a cleaner solution.
You seem to thi
(with smooth left and right
margins) works well for proportional fonts, but decreases readability
for fixed pitch fonts, where ragged right (or ragged left) works better.
Sadly, I have no idea where I read that as it is only in the recesses
of my somewhat addled brain.
--Scott David Daniels
scott.dani
et an idle window with the -n switch on (so you are using the idle
"in-process") to see the effects of each Tkinter operation as you go.
You can then run these operations in place, seeing results and effects.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Esmail wrote:
Scott David Daniels wrote:
Esmail wrote:
... Tk seems a bit more complex .. but I really don't know much about
it and its interface with Python to make any sort of judgments as
to which option would be better.
This should look pretty easy:
Thanks Scott for taking the ti
accessing them.
Requiring that the C++ compiler used to make the dll's/so's to be the
same one Python is compiled with wouldn't be too burdensome would it?
And what gave you then impression that Python is compiled with a C++
compiler?
--Scott David Daniels
scott.dani...@
t;>> i = 'Surprise!'
>>> print([f() for f in c])
[11, 12, 13, 14, 15]
When you evaluate a lambda expression, the default args are evaluated,
but the expression inside the lambda body is not. When you apply that
evaluated lambda expression, the expression inside the lambda body is
is evaluated and returned.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Yves Dorfsman wrote:
... Sorry this was a typo (again :-), I meant:
d = time.local()
y = d[0]
d = d[2]
Then:
y, d = list(time.localtime())[:4:2]
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
it offers the needed
functionality. Does anyone have suggestions of other image libraries I
should be looking at it, or if PIL can do what I need?
If PIL's "histogram" method doesn't give you a clue how you might do
this, hire someone to do it.
--Scott David Dan
in list(procs_dict):
...
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
e than the
"byte sex" issue (go ahead, look it up).
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
if i want o test:
if a == 5 and b ==5 and c==5 ... z==5
is there some synctactic suagr for this?
rather than maiking one of my own i mean, something built-in like:
if a,b,c... z == 5:
How about:
if 5 == a == b == c == ... z:
...
--Scott David Daniels
27;.join( [ c for c in input if c not in ' -' ] )
output
'858215558'
If you are planning to do a lot of strings:
identity_trans = ''.join(chr(x) for x in range(256))
Then you can do simply:
input = '8 58-2155-58'
output = input.translate(identity_trans,
Mark d. wrote:
How about:
mov = open(afile)
line = mov.readline()
...(process your ':' line)
for line in mov.readlines():
...
The problem here is that you read the entire file in in the
call to readlines.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailma
s).
Put this file in your site-packages file (for windows in your case,
that is C:\Python25\Lib\site-packages
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
t;thinko"s, embrace what they tell you,
and don't look for mechanical ways to avoid them; test them out.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
e untested code, because there was no test that made
you write it. If you want to do code coverage, find a code coverage
tool and count your code while runnign your unit tests.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
D'Arcy J.M. Cain wrote:
Yes! One of the biggest advantages to unit testing is that you never
ever deliver the same bug to the client twice. Delivering software
with a bug is bad but delivering it with the same bug after it was
reported and fixed is calamitous.
QOTW for sure.
--Scott
y times you repeat the same "hand-test"
of some code on a subsequent version. Think of how much time that can
add up to if you no longer do that; you had-tesing time is subtracting
from the time you have to do unit tests.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/ma
forbidden multi-roots, you could
# test if set(trouble) & forbidden_multi_parents: ...
if object in trouble:
trouble.pop(object) # Avoid simply new-style classes
for common_ancestor, progeny in trouble.items():
print common_ancestor.__n
ck event system that connects to your code and provides specific
event chains and "expects" certain responses.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
t;lambda i=i: i)", but if you
don't know the idiom, I find the "i=i" part confuses people.
(2) Use something like functools.partial. if you are simply binding
different args to the "same" function:
import functools
def thefunction(x):
return
1701 - 1800 of 2114 matches
Mail list logo