quot;);
What, you mean like:
int('0011001100110101', 2)
Which you could show as:
hex(int('0011001100110101', 2))
I guess because Python is not so wonderful as Perl. Apparently Python
stupidly forgot to follow Perl's great naming conventions.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
s' in files:
file = FITS.Read(os.path.join(root, 'flux.fits'))
if root != DATADIR:
del dirs[:] # Stop recursing after the first descent)
depending on whether you know 'flux.fits' should be there or
you only want to work on subdirs where it is in the directory.
-Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ex number with b format..:(
Well, that's true, but it is a bit like saying:
I cannot find the distance in meters between Paris and London with:
for i in range(10):
print i
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ng underscore
rather than use an abbreviation or spelling corruption. Thus
"print_" is better than "prnt". (Perhaps better is to avoid
such clashes by using a synonym.)
Reference:
http://www.python.org/dev/peps/pep-0008/
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
print >>dest
print repr(dest.getvalue())
prints:
'0 1 2 3 4 5 6 7 8 9\n'
--
-Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
a "big"
language, while C is a "small" one; it will take much longer to "know"
C++ even though C++ started with the goal of being "C with objects."
If you are interested in languages, reading "the Design and Evolution
of C++" is a great base; it explains
][max(0, x + dx)] = entry
field[max(0, y + dx)][x] = entry
return field
There is still overlap done at x = y and x = -y; you could squeeze that
out as well by changing wedge_nz not to put it out, and making circle2
do diagonal diameters as well (leaving the center the sole overwrite).
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
and somehow you couldn't have an issue
with characters in strings, you would have to deal with this:
simple_list = [3.1415]
container = [simple_list]
simple_list.append(container)
Your function (and mine) assumes the argument is a DAG (Directed Acyclic
Graph), but there is no such guarantee about data structures in python.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
finition was completely machine-independent).
> 3) C - The "Latin" of modern programming languages. Used in low level
> tasks (e.g. - hardware drivers) as well as larger projects (e.g. -
> operating systems and other programming languages). Logcal, explicit
> flow albe
t;
>
> Does anyone know what the problem is here?
I have trouble believing you. I suspect you are telling us what you
think is happening, and leaving something vital out. In particular,
cut and paste the traceback.
Here's another experiment, interactively do:
import node
pri
Kent Johnson wrote:
> In Python 2.5 you can do this with operator.attrgetter():
> L.sort(key=operator.attrgetter('whatever', 'someother', 'anotherkey'))
Note: this is also available in Python 2.4
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Kent Johnson wrote:
> Scott David Daniels wrote:
>> Kent Johnson wrote:
>>> In Python 2.5 you can do this with operator.attrgetter():
>>> L.sort(key=operator.attrgetter('whatever', 'someother', 'anotherkey'))
>>
>> Note: this
:
yield number
else:
yield prelude
prelude = None
path = "d:/emacs files/emacsinit.txt"
source = open(path)
try:
for line in starts(source):
print line,
# could ju
Steve Bergman wrote:
> One of these days Alex will come out with a 2nd Edition of Nutshell and
> there will be much rejoicing. ;-)
>
Rumor has it he is trying to hit print for OSCON (so soon, soon).
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
yboardInterrupt has a reasonable
repr (the result of the %r translation), but its str conversion (the
result of the %s translation) is a zero length string (which is kind
of hard to see in a print).
So, avoid "except:" when catching exceptions, and your life will be
happier.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
etdefault = mutating(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
class__.needs_initial = False
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
d out 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/
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 i
make 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
tialized.a, 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
her than looping in the way you might in C for example, the
numpy where might be quicker 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)
I
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
art making 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
l you what locations 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.
--
gt;>> q = s.decode('utf-8')
>>> degrees, rest = q.split(u'\N{DEGREE SIGN}')
>>> print degrees
48
>>> print rest
13' 16.80" N
And if you are unsure of the name to use:
>>> import unicodedata
>>> unicodedata.name(u'\xb0')
'DEGREE SIGN'
--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 ke
ion _very_ 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
aqs/smart-questions.html
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
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
.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
in
order to make equal immutable values identical, you'd
have to end each operation producing 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
e 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/listinfo/python-list
jects
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.o
. Maybe your 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
bzip compression as well, 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
ments, 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
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
s" as if
Microsoft got it wrong; it did not -- Unix made up a convenient fiction
and people went along with it. (And, yes, if Unix had been 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
nside)
And here is a fix
foo.py:
if __name__ == '__main__':
import sys
sys.modules['foo'] = sys.modules['__main__']
class Foo:
inside = __name__
import foo
if __name__ == '__main__':
print(Foo is foo.Foo)
print(Foo.inside, foo.Foo.inside)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
the dictionary becomes that holding point.
The counter-as-key idea allows you to keep separate references
to the same thing, so the reference is held for precisely as long
as needed. It (counter-as-key) beats the str(id(obj)) of can
because it tracks the actual object, not simply the id that can
dirs[:] = sorted([d for d in dirs
if d[0] != '.' and d not in ('RCS', 'CVS')])
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Christian Heimes wrote:
...
2.7rc1 is already out. There is no way a new piece of code will land in
the 2.7 release.
Christian
3.1rc1 is out, but 2.7 is not even in alpha.
See pep 373 for the 2.7 schedule; 3.1's schedule is on pep 375.
--Scott David Daniels
scott.dani...@acm.org
--
Gaudha wrote:
Can anybody tell me what is meant by 'openhook' ?
Certainly someone can.
--
http://mail.python.org/mailman/listinfo/python-list
al semantics,
you might prefer either:
if s[-1:] != '/':
s = (s or '.') + '/'
or:
if s and s[-1] != '/':
s += '/'
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
he cost of
that speed is that timing is a black art. Perhaps modern operating
systems need the syyem call that was implemented in the Stanfor AI Lab's
operating system -- phase of the moon.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ist).
Foldl is the eager-beaver's dream; foldr is the procrastinator's dream.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
print 'Failed:', why
import sys, traceback
traceback.print_tb(sys.exc_info()[2])
raw_input('Leaving: ')
Note that building your script like this also allows you to
open the interpretter, and type:
import mymodule
mymodule.main()
in order to exa
red = mangled('red', "their side")
white = mangled('white', "the poor civilians")
def _mangle(self, text):
print text
return text.join('<>')
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
from selling it.
(3) You'll probably advertize your new solution via bulk
e-mail to all e-mail addresses you know of that might
be interested in learning of your great discovery.
:-)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Lew wrote:
Scott David Daniels wrote:
the nub of the problem is not on the benchmarks. There is something
to be said for the good old daays when you looked up the instruction
timings that you used in a little document for your machine, and could
know the cost of any loop. We are faster now
e)
# break the post-DIHED part into '=', ,
words = parts[1].split(None, 2)
values.append(float(tokens[1]))
mean = sum(values) / len(values)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
r brackets, if I
were you I'd go with the list form.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
CifradorDeCesar(class_, mensagem, chave, funcao):
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
_info < (2, 3):
...
elif (2, 5) <= sys.version_info <= (2, 6, 2, 'final'):
...
else:
print('Untested')
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
into writing
from the array directly -- using cStringIO if you need to get to the
result within Python, rather than as an I/O format.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
'-')
print node.tag, ', '.join(sorted('%s=%r' % pair
for pair in node.items()))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
William Purcell wrote:
Scott David Daniels wrote:
William Purcell wrote:
I am writing a application to calculate pressure drop for a piping
network. Namely a building sprinkler system. This will be a
command line program at first with the system described in xml
If you are going to be
not be
surprised to see a non-CPython implementation use a different hash.
Generally it is a good idea to keep the result of hash computations
inside the program, and off the persistant store, so I'd want a good
excuse to use the hash "outside."
--Scott David Daniels
scott.dani..
shutdown, but it sounds like you have a thread
shutdown issue.
--Scott David Daniels
Scott.Daniels#Acm.Org
--
http://mail.python.org/mailman/listinfo/python-list
handful.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
... or {1}∩0. (If that character between the set and zero ends up missing,
it's meant to be INTERSECTION u'\u2229'.)
Note that you can write this in a quite readable way in ASCII:
"it's meant to be the character u'\N{INTERSECTION}
C1 = np.fromfile(data, count=ncells, dtype=float)
# and again, possibly:
TC1.byteswap(True) # True to byteswap in place.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
center. I'm not quite sure which one
is more properly called "contrast," as I can see wanting
either one.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
#2)
a, b = (int(t) for t in input('Numbers: ').split())
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
n(ctrls) and '~' >= max(chars
) and min(chars - ctrls) > ' '
For potentially more performance (at least on 2.X), you could do min
and max on the data read, and only do the set(data) if the min and
max are OK.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
decorator(function):
@functools.wraps(function)
def new_function(*args, **kwargs):
return function(*args, **kwargs)
return new_function
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
norseman wrote:
Scott David Daniels wrote:
Dave Angel wrote:
Jorge wrote: ...
I'm making a application that reads 3 party generated ASCII files,
but some times the files are corrupted totally or partiality and
I need to know if it's a ASCII file with *nix line terminators.
In l
@indexed
def first_function(...):
...
@indexed
def second_function(...):
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
o sleep a short time and then retry.
Can you just import and use time.strptime once before you start the
threads?
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
\n').
A good guess of what might be going wrong.
Another could be using read.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
roop wrote:
I was browsing ImageEnhace.py, and found something that I thought was
odd in class Contrast:
class Contrast(_Enhance):
"Adjust image contrast"
...
Good catch [I'll send a copy to the imaging sig]. If you replace class
...
Ov
()
=== EOF ===
Is the 'something()' line at the end in an ok location? I just put it
at the end.
Seems fine there. I'd add a comment like:
something() #initialize the frambus so the whatzies are set up.
Perhaps I'd choose better names :-)
--Scott David Daniels
scott.dan
ion files in /path or /path/f/9/e/95ea
with only hundred of them in each path.
Probably better to use:
/path/f9/e9/5ea4926a4
If you want to talk hundreds per layer. Branching 16 ways seems silly.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
k in a numpy world long
enough, you'll forget that not everyone uses numpy.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
your operation to everything with that tag.
operations include such things as color manipulation, delete, clone,
and move.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
perhaps augmented by dynamic scaling.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ject):
_default = None
def __init__(self, test=None):
if test is None:
test = self._default
if test is None:
B._default = test = A()
...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
(functools.partial(self._function,
cls if obj is None else obj))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
host of experiences to our writing,
and we should similarly bring that to the programs we write.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Lawrence D'Oliveiro wrote:
... Use Python mapping objects.
Most real-world databases will fit in memory anyway.
Interesting theory. Certainly true for some definitions of "most"
and "real-world" (and "databases" for that matter).
--Scott David Dan
language in addition to learning
the rest of the coursework. The first course is now in Python, since
at the end of the two-semester sequence they know two languages and
apparently suffer no compensating loss.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ot;python-dev" : home + "/py-dev"}
or even (if the list gets much longer):
home = "/home/test"
config = {"home" : "", "user1" : "/user1", "user2" : "/user2",
"python-dev" : "/py-dev"}
for key, entry in config.iteritems():
config[key] = home + entry
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
with open(filename) as instream:
gen = (line.strip() for line in instream)
for key in gen:
lookup[key] = next(gen)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
sh in the right
direction.
Thanks!
What OS and version, what Python and version.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
Scott David Daniels wrote:
Peter Otten wrote:
with open(filename) as instream:
lines = (line.strip() for line in lines)
lookup = dict(zip(lines, lines))
Little bit of a fluff-up here.
Sorry, it should have been
with open(filename) as instream:
lines
g my feet wet, and I'll try not to ask too many
silly questions!
First impressions are: (1) Python seems both elegant and practical;
and (2) Beazley seems a pleasantly unfussy introduction for someone
with at least a little programming experience in other languages.
Both 1 an
p(), "-->", next(lines).strip()
NameError: global name 'next' is not defined
Sorry, I am running 2.6
Try:
print line.strip(), "-->", lines.next().strip()
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
Angus Rodgers wrote:
... my first ... question is how best to find out what's changed from
version 2.1
> to version 2.5. (I've recently installed 2.5.4)
Consecutively read:
http://docs.python.org/whatsnew/2.2.html
As someone else pointed ou
going on related to multithreading at this point
in the code. Why else might the program freeze at a try statement?
Or a print statement or ...
We need more clues than three lines of source.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
arbitrary-precision, huge exponent
version of binary floating point. In that sense the Decimal floating
point beats it. Not that it would be too hard to have such a floating
point in Python (long for mantissa, int for exponent, ...), but we don't
in fact have such a module in place.
--Scott
TE
261 105 ą LATIN SMALL LETTER A WITH OGONEK
347 15b ś LATIN SMALL LETTER S WITH ACUTE
322 142 ł LATIN SMALL LETTER L WITH STROKE
380 17c ż LATIN SMALL LETTER Z WITH DOT ABOVE
378 17a ź LATIN SMALL LETTER Z WITH ACUTE
263 107 ć LATIN SMALL LETTER C WITH ACUTE
324 144 ń LATIN SMALL LETTE
the obvious choice, digits and letters, and 1/N works
for n in range(1, 7) + range(8, 11). Gödel numbers, anyone? :-)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
e attempting to work it out alone.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
norseman wrote:
Scott David Daniels wrote:
norseman wrote:
... A note here: In reading the original posting I get ...
then an e with a goatee
Here's something to try in any future circumstances:
Good thought, good idea, useful tool.
BUT - compare your output to what I
= data[key]
The form:
try:
value = data[key]
except KeyError:
pass
works, but is not terribly efficient unless failures are rare.
And this is a micro-optimization, measure before changing your
program structure away from the clearest code you can write.
--Scott David
olivergeorge wrote:
Ditto. Anyone know what's happening with pythonware? (and why PIL is
such a pain to install for that matter.)
(1) It is usually there; be patient.
(2) I suggest you demand a refund.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/lis
e the world from our 'bot overlords.
Congratulations on another release from the hydra-like world of
multi-head development.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
golu wrote:
here i have posted my code...plz tell why am i getting the error "int
argument required" on the hash marked line(see below) although i am
giving an int value
... url_count += 1
curse.execute("INSERT INTO URL_TABLE VALUES(%d,%s)",
(url_count,file_path)
1901 - 2000 of 2115 matches
Mail list logo