of the answer.
Might be too complicated to know what to do with an answer like that.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
the students into the auditorium?
You would think so, but darned if some of them don't wind up in a
*different* *auditorium*!
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
for example, will do
this. Intermediate results get rounded off in different ways on different
paths through the same calculation. The whole truth for this will be
revealed in a Numerical Analysis textbook, e.g. James B. Scarbourough,
_Numerical Mathematical Analysis_,
Mel.
--
http
) Try
if f.find(fileBase) -1:
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
for more information.
repr (2.385)
'2.3848'
so it correctly rounded down. You need to use Decimal numbers if you want
numbers that behave the way they look.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
, not everybody advertises plonks.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
?
TIA
Try
def foo (*args):
print 'foo args:', repr (args)
foo (1, 2, 3, 4)
def bar (*args, **kwargs):
print 'bar args:', args
print 'bar kwargs:', kwargs
bar (1, 2, 3, 4)
bar (1, 2, 3, baz=6, boz=None)
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
I see his name in the context of a lightweight invective.
AFAIK he's just a guy who thinks Usenet is his blog, and kicks off big
rambling threads, cross-posted to infinity that mathematically have
probability 0.0 of being on topic in any of the groups they're in.
Mel.
--
http
}]
None of the three are exactly clones of each other, but it seems to me
that Tcl and Python are quite close in spirit, if not syntax.
They both have the interpreter spirit. Very different under the hood; Tcl
is the LISP of strings. They could have called it STRP.
Mel.
--
http
] on linux2
Type help, copyright, credits or license for more information.
a = 'x(3)'
id(a)
3075373248L
c='x(3)'
id(c)
3075373856L
a==c
True
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
that code there and then. Then 'resumable exceptions' just
become a kind of subroutine call, perhaps like the triggers in SQL.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
with
p1 = r'([\x80-\xff])'
r1 = re.compile (p1)
m = r1.search (a)
I get at least an _sre.SRE_Match object at 0xb749a6e0 when I try this.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
. They don't have to be recognized and
passed back up the call chain from level to level till they get to the right
place -- the way out-of-band error returns have to be.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
a workaround ?
Have you tried
'''INSERT INTO foo VALUES (NULL, ?)'''
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
(self, parent, title=title, size=size)
and so on.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
about:
t = foo() as v if pred(v) else default_value
!! so: assignment inside an expression.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
application, you'd perhaps
want to package it up (not tested):
def important_range ():
for x in xrange (3, 7):
yield x
for x in xrange (17,23):
yield x
to be used elsewhere as
for v in important_range():
# use v ...
Mel.
--
http://mail.python.org/mailman
is (200, , 10001.0). So far my
math has not been up to explaining why.
Mel
--
http://mail.python.org/mailman/listinfo/python-list
Mel wrote:
MRAB wrote:
On 22/10/2010 13:33, Baba wrote:
only a has an upper limit of 200
Really? The quote you gave included whose small sides are no larger
than n. Note: sides, plural.
Strangely, there does seem to be a limit. Fixing one side at 200, the
largest pythagorean triple I
you a
sales total, regardless of what you might or might not write as
computational statements.
Mel.
* somewhere hah! I covertly looked it up. It's in the _Blue and Brown
Books_.
** This I haven't looked up. It got some publicity a year or so ago. It
started when somebody gave a mid
the extra
side-effects.
Probably there are workarounds here too,
The workaround would be (untested)
x = {1: fna, 2: fnb, 3: fnc}.get(i, lambda: None Of The Above) ()
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
, so it deals with an
empty sequence here. We're probably due for an argument on whether it
should raise an exception instead. See the current thread on whether `+`
should be a sequence concatenation operator.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
other language that did it already.
Could be mnemonic for 'one thing followed by another thing', just like '='
originally conveyed 'one thing the same as another'.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
we're stuck with non-negative integers, and no hope
of general-purpose subtraction.
I wouldn't change it. As an idiom, ' '*20 is just too handy a way to get a
20-blank string to give up.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
, etc
Sure ... in math, multiplying a vector by -1 gives a vector
with all its elements negated:
-1 * [1, 2, 3] - [-1, -2, -3]
:-)
And math applies associativity
v * (3 - 1) == v * 3 + v * -1
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
?
One way (not tested):
thisplayer = Player()
otherplayer = Player()
while not_won:
thisplayer.take_turn()
thisplayer, otherplayer = otherplayer, thisplayer
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
chaining. `is` is a comparison operator, like
``, and chains of comparisons are handled differently.
`a b c` is equivalent to `(a b) and (b c)`
Therefore the first expression is testing
(3 0) and (0 is True)
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
as much as it's a
language issue. Posix aren't the only O/S.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
not
have been written by Homer, but by someone else with the same name.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
to handle the
non-base cases. There's no such problem as overlapping recursions.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
check the code for details, I think is better.
Did you actually click the loginBtn?
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
larger number can be reached.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
` until the number left to buy is between k and k+n-1
inclusive, then follow the scheme for that number.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
as
dead as a print() function, so the statement's so-called
advantage is not that great.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
is a computational heavyweight -- very
repetitive when called inside a loop. It could be cheaper to compute a
list of quantities that can be purchased, then check to see what's in
the list -- or the set, if you optimize a bit more.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
its
own empty dict. Ditto for lists.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
by all the instances.
Assigning to a.var creates a new variable in instance a's namespace, and
from then on that becomes the value that will be found by looking up a.var .
The `is` test shows that this is true.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
a pointer to the first element.
KR2 A7.4.2
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
inspect.isfunction(str)
print inspect.isfunction(open)
print inspect.isfunction(hello)
help (inspect.isfunction) gives
Help on function isfunction in module inspect:
isfunction(object)
Return true if the object is a user-defined function.
Mel.
--
http://mail.python.org/mailman/listinfo
):
return sum (1 for x in s if x==target)
test_candidates = 'c'*100 + 'b'*100 + 't'*100
for i in xrange (10):
test = [weighted_choice (test_candidates, test_weight) for k in xrange
(100)]
for x in 'cbt':
print x, item_count (test, x), '\t',
print
Mel.
--
http
with) and set up your
printable text and graphics in a appropriate device context suitable for
your printer.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
processing. Then you can write a new GUI program based on jacXlgui that
imports the data processing module and calls computations and reports
results from the model.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
of
Contents controlled disk space allocation and directories provided name-
keyed access to the VTOC entries. Pretty much as Linux does now with
directories and inodes.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
provided by the individual caller.
Refactoring the Python function to a Python class, as you mention later,
solves the static-access problem, but that solution is just as vulnerable to
the need-more-than-just-the-one problem as my C function.
Mel.
--
http://mail.python.org/mailman
=1.0e200+1.0j
nj=1.0+1.0e200j
ai=(ni, nj, 156.0+651.0j, -ni, -nj)
sum(ai)
(-1+0j)
fsum(ai)
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: can't convert complex to float; use abs(z)
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
a particularly brilliant pop song called
Code Monkey.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
I think replacing `except:` with `except StandardError:` would work as well,
and be correct, too.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
you think it says, you're fine. If you
encounter a file that does #define sys, then the sys module is forever
masked, and your module can't invoke it. A header file that contains
#define declare will be fun.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
Gregory Ewing wrote:
Mel wrote:
You could think of it as a not bad use of the design principle Clear The
Simple Stuff Out Of The Way First. Destinations are commonly a lot
simpler than sources
Calculations for immediate values could be just about anything.
Mel.
--
http
The
Simple Stuff Out Of The Way First. Destinations are commonly a lot simpler
than sources -- just as in Python assignment statements. So you can tell
more or less at a glance what's going to be changed, then get into the deep
analysis to find what it's going to be changed to.
Mel
guaranteeing that when a function returns, any otherwise unreferenced
locals are immediately collected.
That would be nice. The argument against it is that it would make
implementations like Jython very difficult to make, if it didn't rule them
out altogether.
Mel.
--
http
.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
wordy. It may be an
uphill fight getting it accepted into computer science the way Call by
value, Call by reference, Call by sharing, and Call by copy-restore have
been (http://en.wikipedia.org/wiki/Evaluation_strategy).
Mel.
That is, you change labels by assignment, but pass
Dave Angel wrote:
But I still think there must be code for the gamma function that would
be quicker. But I haven't chased that lead.
Log of the gamma function is also an algorithm in its own right (e.g.
published in _Numerical Recipes_.)
Mel.
--
http://mail.python.org/mailman
(input[0])
input = input [1:]
return ''.join (output)
original = 'fooxxxbazyyyquux'
replacements = {'quux':'foo', 'foo':'bar', 'baz':'quux'}
print original, '--', replaced (original, replacements)
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
The real coefficients show how the 8th, 16th, 24th, 32nd harmonics -- where
the coefficients are near zero -- have dropped out of the waveform.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
type(x) == type (())
...
Traceback (most recent call last):
File stdin, line 2, in module
AssertionError
Because of the comma, this creates a tuple containing the empty list, and
iterates over the tuple.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
library subroutines that return only 0 for good
or -1 for bad, and do all their real work in side-effects (through pointers
as function arguments.) Python is a big improvement: use the function
return values for the payload, and push the out-of-band omyghod response
into an Exception.
Mel
into the dict?
Yep.
Mel.
Jean-Paul
--
http://mail.python.org/mailman/listinfo/python-list
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
` in the namespace it finally
gets executed in, so it has to have it's own private namespace to use then.
That's why you don't see `j` in your local namespace when `list` finallty
runs the sequence comprehension.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
arguments as a
bunch, and apply them when you want.
The other function call feature that sequence types don't do is
a, b, c = **{'b':3, 'c':a, 'a':c}
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
to yield 9, but I can accept
that ** binds tighter than the unary -, but shouldn't the results
be consistent regardless if I use a literal or a variable?
When you say ** binds tighter than unary -, you're also saying that -3 isn't
a literal: it's an expression. Try
y=3
-y**2
Mel
was a syntax error.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
` as a name from its
global namespace. Inside argFunc, the names one.x and one.a are rebound to
different strings from the ones they started with. *But* one.myList[0]
isn't touched, and still refers to 'place_x' like it always did.
Mel.
--
http://mail.python.org/mailman/listinfo
at the boundaries of your program, letting user
input in through the gates, as it were. Deeper in, I agree; that stuff
should have been dealt with at the gates.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
().items():
print item
f = Moo(1)
g = Moo(2)
h = Moo(3)
Because self is not in globals().
It's defined as a local symbol in Moo.__init__ , supplied to that function
as the first parameter.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
Joyce has written _Finnegans Wake_ there are no grammar
errors and there are no spelling errors. There are only unexpected
meanings.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
Gerry wrote:
On Nov 8, 2:42 pm, Ozz notva...@wathever.com wrote:
vsoler schreef:
And, of course, you'd want to take a look a this: http://xkcd.com/287/
:) I remember that.
mwil...@tecumseth:~/sandbox$ python xkcd_complete.py
[1, 0, 0, 2, 0, 1] 1505
[7] 1505
Mel.
--
http
if you want to
give some_value's usual class an __eq__ method. It's a pretty arcane
point.. but perhaps not.. the object named some_value might belong to a
class that expects its instances only to be compared with each other, for
the sake of economy and clear code.
Mel.
--
http
, and the syntactically correct
something.that(x)
just doesn't look like the simple assignment statement.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
(6) Metaphoric equivalence:
Kali is death.
Life is like a box of chocolates.
OK to here, but this one switches between metaphor and simile, and arguably,
between identity and equality.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
, for example, uses the Java Runtime Environment for its virtual
machine. JRE doesn't have reference-counts, so Jython can't close files
immediately after the last reference ends. It seems guaranteed object
cleanup would lock Python out of too many possible platforms.
Mel.
--
http
Aahz wrote:
In article mailman.1683.1255964347.2807.python-l...@python.org,
geremy condra debat...@gmail.com wrote:
And always apply ROT13 twice for extra security.
Can't you tell? I'm already doing that!
Just don't flaunt the export restrictions by using ROT52.
Mel.
--
http
that they could be thrown into.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
.replace ('10', '1 0')
c1.split()
['00', '1', '', '11', '0']
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
and deallocated) used, so
CPython gives it the same id value.
When the == comparison happens, all it needs are the two ints returned from
the id calls.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
to
writing the entire function at run-time. Better to use a dictionary.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
into a generator
would simplify the statement, and if it were done well the code overall
would probably be better.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
(1, []).append (Test0)
The new way is to inherit from defaultdict.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
in all the arguments you don't:
def stand_in (great, nifty):
call a_function (bo, great, ri, nifty, ng)
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
anyone any idea why it's acting the way it
is?
Yeah. You convert a 5 digit number by calling _2digit for the thousands,
and _4digit for the rest. Why?
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
ethical. We can do his homework for him, we can perhaps pass exams
for him, maybe graduate for him, and then with our luck, he'll get a job in
our office and we get to do his work for him.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
of the possible combinations
from the second through nth lists.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
:
... print `a` is not defined
...
`a` is not defined
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
Mel wrote:
Grant Edwards wrote:
On 2009-09-22, Brown, Rodrick rodrick.br...@citi.com wrote:
How could I do the following check in Python
In Perl I could do something like if ((defined($a)) { ... }
[ ... ]
This is an artifact of the interactive interpreter,
True
much time -- from the text (with Pythonic nested
quotes:)
'''I said Tell me Mister People Eater, what's your line?
He said Eatin' purple people, and it sure is fine.'''
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
():
... empty function
...
f()
print f()
None
def g():
...
File stdin, line 2
^
IndentationError: expected an indented block
def h():
... pass
...
print h()
None
Cheers, Mel.
--
http://mail.python.org/mailman/listinfo/python-list
in advance to know which
parameters are acceptable to which database module.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
()
process_that_input()
mess_with_the_collected_data()
write_the_output()
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
a little 3-in-a-row game to get familiar with Chinese characters.
Astonished at how Chinese-ready Python 2.5 already is. Collecting characters
from web sites and pasting them in to literals in the program source just
works.
Mel.
--
http://mail.python.org/mailman/listinfo/python
digit you have is 0 then your numbers
take the form
0*1 + 0*1**2 + 0*1**3 ...
and every number has an infinitely long representation. If you cheat and
take a 1 digit instead then it becomes workable.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
verbose, but, saying what it means, it avoids having to guess which
age of several ages might have to be used in various places; the same would
go for other input variables. Actually, I probably wouldn't use p as a
stand-in for person unless person were a global name and p could be local.
Mel
Steven D'Aprano wrote:
Leading zeroes in decimal numbers are *very* common in dates and times.
In banking too, according to someone at work today.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
no promises so as not to constrain present and
future implementations.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
4.3.3] on linux2
Type help, copyright, credits or license for more information.
int ('rst', 32)
28573
Mel.
James
--
http://mail.python.org/mailman/listinfo/python-list
: building a list. It
isn't out creating wild options in the program control flow at large.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list
101 - 200 of 342 matches
Mail list logo