Ben Bacarisse bsb.me.uk> writes:
> [1] Not being a Python expert I don't know how you show that actual
> value of a float. What is the Pythonic way to do that?
I don't know about Pythonic, but here are some options.
1. Convert the float to Decimal, and print the result. This shows
the exact
Mark Lawrence yahoo.co.uk> writes:
> Somebody got there first http://bugs.python.org/issue22477
I think there's good reason to suspect that Brian Gladman and
blindanagram are one and the same. :-)
>>> sorted("BrianGladman".lower()) == sorted("blindanagram")
True
--
https://mail.python.o
isp.com> writes:
> I've tested on all platforms I know of and confirmed it. The wrong digit
> occurs in the middle of the number. Propagation error would have a bad digit
> near the end, and garbage after that. Here there's a perfect sequence of
> numbers, but with one single digit changed in th
On Tue, 29 Apr 2014 19:37:17 -0700, pleasedontspam wrote:
> Hello, I believe I found a bug in the Decimal library. The natural logarithm
> results seem to be off in a certain range, as compared with Wolfram Alpha.
I had a quick look: this isn't a bug - it's just the result of propagation of
the e
Jayanth Koushik gmail.com> writes:
> "Note: When converting from a string, the string must not contain whitespace
> around the central + or - operator. For example, complex('1+2j') is fine, but
> complex('1 + 2j') raises ValueError."
>
> Why is this so?
See http://bugs.python.org/issue9574 for
3ds.com> writes:
> When formatting a float using the exponential format, the rounding is
> different in Python-2.6 and Python-2.7. See example below. Is this
> intentional?
Yes, in a sense. Python <= 2.6 uses the OS-provided functionality (e.g., the C
library's strtod, dtoa and sprintf functi
On Monday, July 30, 2012 3:16:05 PM UTC+1, Grant Edwards wrote:
> The last ones I worked on that where the FP format wasn't IEEE were
>
> the DEC VAX and TI's line if 32-bit floating-point DSPs. I don't
>
> think Python runs on the latter, but it might on the former.
For current hardware, there
On Monday, July 30, 2012 1:44:04 AM UTC+1, Steven D'Aprano wrote:
> 1) Are there any known implementations or platforms where Python floats
> are not C doubles? If so, what are they?
Well, IronPython is presumably using .NET Doubles, while Jython will be using
Java Doubles---in either case, that
On Feb 12, 6:41 am, Steven D'Aprano wrote:
> err = -a/b # Estimate of the error in the current w.
> if abs(err) <= 1e-16:
> break
If the result you're expecting is around -1.005, this exit condition
is rather optimistic: the difference between the two Py
On Jan 31, 7:24 am, Neal Becker wrote:
> In [31]: all is numpy.all
> Out[31]: True
>
> Excellent detective work, Mark! But it still is unexpected, at least to me.
Agreed that it's a bit surprising. It's a consequence of NumPy's
general mechanisms for converting arbitrary inputs to arrays:
>>>
On Jan 31, 6:40 am, Neal Becker wrote:
> I was just bitten by this unexpected behavior:
>
> In [24]: all ([i > 0 for i in xrange (10)])
> Out[24]: False
>
> In [25]: all (i > 0 for i in xrange (10))
> Out[25]: True
What does:
>>> import numpy
>>> all is numpy.all
give you?
--
Mark
--
http://m
On Dec 5, 8:09 am, Chris Angelico wrote:
> May be, yes, but since calcsize() is returning 12 when the elements
> are put in the other order, it would seem to be not counting such
> padding.
Indeed. That's arguably a bug in the struct module, and one that
people have had to find workarounds for i
On Dec 4, 3:17 pm, Chris Angelico wrote:
> On Mon, Dec 5, 2011 at 1:51 AM, Dave Angel wrote:
> > In C, the padding to the largest alignment occurs at the
> > end of a structure as well as between items. Otherwise, an array of the
> > struct would not be safely aligned. if you have an 8byte item
On Dec 1, 10:21 am, Hrvoje Niksic wrote:
> Chris Rebert writes:
> > C does not have a built-in fixed-point datatype, so the `struct`
> > module doesn't handle fixed-point numbers directly.
>
> The built-in decimal module supports fixed-point arithmetic, but the
> struct module doesn't know about
On Oct 12, 8:24 pm, Ian Kelly wrote:
> On Wed, Oct 12, 2011 at 11:51 AM, MRAB wrote:
> >> Aside:
>
> >> I'm astonished to see that range objects have a count method! What's the
> >> purpose of that? Any value's count will either be 0 or 1, and a more
> >> appropriate test would be `value in range
On Sep 24, 6:01 pm, Steven D'Aprano wrote:
> Ah, I knew it was too easy!
>
> >>> from fractions import Fraction as F
> >>> start, stop, n = 1, 3.1, 7
> >>> [float(F(start) + i*(F(stop)-F(start))/n) for i in range(n+1)]
>
> [1.0, 1.3, 1.6, 1.9001, 2.2, 2.5, 2.8003, 3.1]
I b
On Sep 24, 5:46 pm, Steven D'Aprano wrote:
> Speed is important, but secondary to correctness. To be honest, I never even
> thought of using fractions as an intermediate result -- I was thinking of
> generating lists of Fractions. I think I can use this approach.
Speed could be improved greatly b
On Sep 24, 2:53 pm, Steven D'Aprano wrote:
> I'm trying to generate a sequence of equally-spaced numbers between a lower
> and upper limit. Given arbitrary limits, what is the best way to generate a
> list of equally spaced floats with the least rounding error for each point?
>
> For example, supp
On Sep 24, 10:38 am, Ian Kelly wrote:
> On Sat, Sep 24, 2011 at 12:55 AM, Steven D'Aprano
>
>
>
>
>
>
>
>
>
> wrote:
> > If you want unbiased, random (or at least pseudo-random) integers chosen
> > from an uniform distribution with proper error checking, you should use
> > randint or randrange.
>
On Sep 21, 2:07 am, Steven D'Aprano wrote:
> After playing around with various combinations of C1, C2, D1 and D2, it
> seems to me that the rule is:
>
> If the right-hand argument is a subclass of the left-hand argument, AND also
> defines __radd__ directly rather than inheriting it, then its __ra
On Sep 19, 1:42 pm, Robin Becker wrote:
> I'm not really very used to the decimal module so I'm asking here if any one
> can
> help me with a problem in a well known third party web framework
>
> The code in question is
>
> def format_number(value, max_digits, decimal_places):
> """
> F
On Sep 16, 9:17 pm, Arnaud Delobelle wrote:
> Ah go on, let's make a codegolf contest out of it.
> My entry:
>
> >>> sum(map(int,str(2**1000)))
You could save another character by replacing "2**1000" with "2<<999"
--
Mark
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 11, 1:43 am, "Dr. Phillip M. Feldman"
wrote:
> I've written a recursive class that creates an iterator to solve a general
> formulation of the combinatorics problem known as "balls in numbered boxes"
> (also known as "indistinguishable balls in distinguishable boxes"). The
> code has been
On Sep 7, 4:58 am, casevh wrote:
> IIRC, Python
> 3.2 changed (for floats) __str__ to call __repr__.
Yes, exactly: str and repr of a float are identical in Python 3.2 +
I'm also puzzled by the
2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
[...]
>>> 1.1 * 1.1
1.21
in jmf's
On Jul 7, 9:30 am, Ulrich Eckhardt
wrote:
> That said, I'm sure that the developers would accept a patch that switches
> to a different algorithm if the numbers get large enough. I believe it
> already doesn't use Karatsuba for small numbers that fit into registers,
> too.
I'm far from sure that
On Jun 17, 5:10 pm, Steven D'Aprano wrote:
>
> print((lambda f:((lambda p:p[0]+'.'+p[1:])(str((lambda Q:2*Q[0]*Q[0]//Q
> [3])((lambda F:(lambda S:f(lambda T,_:((T[0]+T[1])//2,S((T[0]*T[1])//
> F),2*T[2],(T[3]-(T[2]*(((T[0]+T[1])//2)**2-(S((T[0]*T[1])//F))**2))//F)),
> [0]*13,(F,(F*F)//S(2*F),2,F//
On May 15, 8:20 pm, Mark Dickinson wrote:
> On May 15, 4:32 am, rusi wrote:
>
> > On May 15, 2:19 am, Ian Kelly wrote:
> > > Yup, linear. Assuming you optimize the even case so that it doesn't
> > > actually call fib(n//2) twice, the call tree can be appr
On May 15, 4:32 am, rusi wrote:
> On May 15, 2:19 am, Ian Kelly wrote:
> > Yup, linear. Assuming you optimize the even case so that it doesn't
> > actually call fib(n//2) twice, the call tree can be approximated as a
> > balanced binary tree with height log(n). The total number of nodes in
> >
On May 11, 11:06 pm, Hans Mulder wrote:
> On 03/05/2011 09:52, rusi wrote:
>
> > [If you believe it is, then try writing a log(n) fib iteratively :D ]
>
> It took me a while, but this one seems to work:
>
> from collections import namedtuple
>
> Triple = namedtuple('Triple', 'hi mid lo')
> Triple.
On May 2, 5:24 pm, Steven D'Aprano wrote:
> As far as I'm concerned, there are only two definitions of Fibonacci
> numbers that have widespread agreement in the mathematical community:
>
> 0,1,1,2,3 ... (starting from n=0)
> 1,1,2,3,5 ... (starting from n=1)
>
> Any other definition is rather, sh
On Mar 27, 3:00 pm, joy99 wrote:
> (i) Suppose we have 8 which is 2^3 i.e., 3 is the power of 2, which we
> are writing in Python as,
> variable1=2
> variable2=3
> result=pow(variable1,variable2)
>
> In my first problem p(x) a list of float/decimals and f(x) is another
> such.
> Here,
> variable1=
On Mar 27, 11:07 am, joy99 wrote:
> (b) Suppose we have two distributions p(x1) and p(x2), of the Model M,
> the E of EM algorithm, without going into much technical details is,
> P0(x1,x2), P1(x1,x2)
>
> Now I am taking random.random() to generate both x1 and x2 and trying
> to multiply the
On Mar 27, 11:07 am, joy99 wrote:
> (i) By standard definition of Likelihood Estimation, we get if x EURO X,
> where X is a countable set of types, p is probability and f is
> frequency.
> L(f;p)=Ðp(x)f(x)
>
> My question is python provides two functions,
> (a) pow for power.
> (b) reduce(
On Mar 25, 2:00 pm, Stefan Behnel wrote:
> Westley Martínez, 25.03.2011 14:39:
>
> > On Fri, 2011-03-25 at 07:11 +0100, Stefan Behnel wrote:
> >> Steven D'Aprano, 25.03.2011 06:46:
> >>> On Thu, 24 Mar 2011 18:32:11 -0700, Carl Banks wrote:
>
> It's probably the least justified builtin other
On Feb 25, 12:52 am, Grant Edwards wrote:
> So I think the C standard actually
> forces the compiler to convert results to 64-bits at the points where
> a store to a temporary variable happens.
I'm not sure that this is true. IIRC, C99 + Annex F forces this, but
C99 by itself doesn't.
> Indeed.
On Mar 3, 10:38 am, Stephen Evans wrote:
> The CPython builtins min() and max() both return the first satisfactory
> object found. This behaviour is undocumented. Examining the source in
> bltinmodule.c shows that min() and max() both result in a call to min_max()
> with Py_LT and Py_GT passed
On Feb 20, 8:08 am, Raymond Hettinger wrote:
> [...]
> >>> n * e
>
> 3.1415926
>
> Compute ð ± e by counting Mandlebrot set iterations :-)
Very neat! Is it supposed to be obvious why this gives an
approximation to pi? If so, I'll think about it a bit more; if not,
do you have any references?
On Dec 28, 9:47 pm, "Martin v. Loewis" wrote:
> >> "Float-to-string and string-to-float conversions are correctly rounded.
> >> The round() function is also now correctly rounded."
>
> >> Not sure that this is correct English; I think it means that the
> >> round() function is now correct.
>
> > W
On Dec 23, 6:57 pm, Hrvoje Niksic wrote:
> I stumbled upon this. Python 2.6:
>
> >>> round(9.95, 1)
>
> 10.0
>
> So it seems that Python is going out of its way to intuitively round
> 9.95, while the repr retains the unnecessary digits.
No, Python's not doing anything clever here. Python 2.6 us
On Nov 15, 12:46 pm, Tim Chase wrote:
> On 11/15/2010 12:39 AM, Dmitry Groshev wrote:
>
> > x in range optimisation
>
> I've often thought this would make a nice O(1)-test lookup on an
> xrange() generator.
An O(1) test for 'x in ' is implemented in Python 3.2,
at least provided that x has type '
On Nov 19, 3:21 pm, Dimos wrote:
> I would like to use the random module, and if I understand well the Random
> class, to create 1300 decimal numbers in python, by providing the 2 Weibull
> parameters (b,c). How this can be done???
>
> import random
> print random
> random.weibullvariate(b,c)
>
On Nov 19, 3:29 pm, RJB wrote:
> Does Fractions remove common factors the way it should?
>
> If it does and you want to find the closest fraction with a smaller
> denominator i think tou'll need some number theory and continued
> fractions.
Or perhaps just use the existing Fraction.limit_denomina
On Aug 21, 5:06 pm, Nicholas Cole wrote:
> On Sat, Aug 21, 2010 at 3:31 PM, Mark Dickinson wrote:
>
> [SNIP]
>
> > So my guess is that the change was unintentional.
>
> > It's probably worth a bug report. Even if the behaviour isn't going
> > to c
On Aug 21, 1:13 pm, Nicholas Cole wrote:
> I've searched for information on this without success. Has
> weakref.proxy changed in Python 3? I couldn't see any note in the
> documentation, but the following code behaves differently on Python
> 2.6.1 and Python 3:
>
> import weakref
> class Test(ob
On Aug 20, 6:13 am, genxtech wrote:
> This is more of a curiosity question then anything else... I was just
> wondering why in version 3 of python assertions weren't converted to
> use parenthesis, since print was.
>
> I am just asking because it seems the following line of code would
> seem more
On Aug 16, 8:36 pm, Mark Dickinson wrote:
> On Aug 16, 8:08 pm, Jacky wrote:
> > My concern is that struct may need to parse the format string,
> > construct the list, and de-reference index=0 for this generated list
> > to get the int out.
>
> > There should be som
On Aug 16, 8:08 pm, Jacky wrote:
> Hi Thomas,
>
> Thanks for your comments! Please check mine inline.
>
> On Aug 17, 1:50 am, Thomas Jollans wrote:
>
> > On Monday 16 August 2010, it occurred to Jacky to exclaim:
>
> > > Hi there,
>
> > > Recently I'm facing a problem to convert 4 bytes on an by
On Aug 13, 3:03 pm, jmfauth wrote:
> A quick question.
>
> I understand how to get these numbers
>
> 34.5231263880373081783294677734375
>
> and
>
> 47 (from 2**47)
>
> and the sign.
>
> with the decimal module, but I fail to find this one
>
> 4858258098025923
>
> Possible?
See the
On Aug 12, 9:43 pm, Bradley Hintze
wrote:
> Hi all.
>
> Is there a way I can keep my floating point number as I typed it? For
> example, I want 34.52 to be 34.52 and NOT 34.520002.
Nitpick: unless you're on very unusual hardware, you're missing some
zeros here. On my machine, under Python 2.
On Jul 16, 2:53 pm, kj wrote:
> This is extremely confusing. From my naive reading of the
> documentation, I would have expected that the following two blocks
> would produce identical results (expl is one of the standard C math
> library exponential functions, with signature "long double expl(lo
Emile van Sebille fenx.com> writes:
>
> On 7/12/2010 2:52 AM Robin Becker said...
>
> > What value should round(-9.85,1) return?
>
> Per round's definition, -9.9.
No. The float that's represented by the literal '-9.85' *isn't*
exactly -9.85, for all the usual binary floating-point reasons.
T
Alexander Eisenhuth stacom-software.de> writes:
>File "C:\Python25\lib\pickle.py", line 954, in load_float
> self.append(float(self.readline()[:-1]))
> ValueError: invalid literal for float(): -1.#IND
>
> - I'm not sure what -1.#IND means. Can somebody assist?
It's the Windows way of r
On Jul 12, 10:52 am, Robin Becker wrote:
> What value should round(-9.85,1) return? Is the result explainable in python
> (ie
> without resort to the internal FP representations etc etc)?
As you observe, the closest float to -9.85 is actually just a little
smaller (i.e., closer to 0) than -9.85:
On Jul 11, 6:38 am, rantingrick wrote:
> Seems kinda dumb to build a tuple just so a conditional wont blow
> chunks! This integer bool-ing need to be fixed right away!
Okay. What fix do you propose? Would your fix maintain the identity
"0 == False"? For bonus points, explain how you'd deal with
On Jul 8, 9:52 pm, Wolfram Hinderer
wrote:
> JFTR, it works because a+b == a+b (while I don't think that a+b == b+a
> holds for all a and b).
Actually, that's one of the few identities that's safe. Well, for non-
NaN IEEE 754 floating-point, at any rate. And assuming that there's
no use of exte
On Jul 8, 2:59 pm, Stefan Krah wrote:
> pow() is trickier. Exact results have to be weeded out before
> attempting the correction loop for correct rounding, and this is
> complicated.
>
> For example, in decimal this expression takes a long time (in cdecimal
> the power function is not correctly r
On Jul 8, 3:29 pm, Adam Skutt wrote:
> On Jul 8, 9:22 am, Mark Dickinson wrote:
> > On Jul 8, 2:00 pm, Adam Skutt wrote:
> > > For some computations, the number of bits required to
> > > get the desired precision can quickly overwhelm the finite limitations
> >
On Jul 8, 2:00 pm, Adam Skutt wrote:
> On Jul 8, 7:23 am, Mark Dickinson wrote:> On Jul 8,
> 11:58 am, Adam Skutt wrote:
>
> > > accurately. Moreover, in general, it's impossible to even round
> > > operations involving transcendental functions to an arbitr
On Jul 7, 1:05 pm, david mainzer wrote:
> Dear Python-User,
>
> today i create some slides about floating point arithmetic. I used an
> example from
>
> http://docs.python.org/tutorial/floatingpoint.html
>
> so i start the python shell on my linux machine:
>
> d...@maxwell $ python
> Python 2.6.5
On Jul 5, 7:12 pm, jmfauth wrote:
> BTW, if I understand correctly the module tokenize import
> the module token. So your example becomes:
>
> >>> from cStringIO import StringIO
> >>> import tokenize
> >>> for tok in tokenize.generate_tokens(StringIO("print9.0").readline):
>
> print tokeni
On Jul 4, 11:02 pm, John Machin wrote:
> On Jul 5, 1:08 am, Thomas Jollans wrote:
>
> > On 07/04/2010 03:49 PM, jmfauth wrote:
> > > File "", line 1
> > > print9.0
> > > ^
> > > SyntaxError: invalid syntax
>
> > somewhat strange, yes.
>
> There are two tokens, "print9" (a name) a
On Jul 4, 9:55 am, Mark Dickinson wrote:
> Why? If Python itself has no problem parsing this code, why should it
> be so difficult for editors? Python's grammar is fairly simple: it's
> LL(1) (unlike C's, for example), so can be parsed with only 1 token of
> looka
On Jul 4, 9:31 am, jmfauth wrote:
> Python all versions.
>
> It's not a bug, but I'm suprised the following does
> not raise a SyntaxError (missing space between
> '9' and 'for').
>
>
>
> >>> [9for c in 'abc']
> [9, 9, 9]
>
> Side effect: If this behaviour is considered as correct,
> it makes a co
On Jun 13, 5:46 pm, exar...@twistedmatrix.com wrote:
> On 04:25 pm, wuwe...@gmail.com wrote:
>
>
>
> >Steven D'Aprano wrote:
> >>No, I think your code is very simple. You can save a few lines by
> >>writing
> >>it like this:
>
> >>s = input('enter two numbers: ')
> >>t = s.split()
> >>print(int(t[
On Jun 13, 12:56 am, geremy condra wrote:
> On Sat, Jun 12, 2010 at 4:40 PM, Robert Kern wrote:
> > On 2010-06-12 17:49 , geremy condra wrote:
>
> >> In Python3.2, calling math.erfc with a value in [-27.2, -30) raises
> >> an OverflowError: math range error. This is inconsistent with the
> >> erf
On Jun 10, 8:45 pm, durumdara wrote:
> ne 91, in fixed_conv_out_precise
> from decimal import Decimal
> ImportError: cannot import name Decimal
Is it possible that you've got another file called decimal.py
somewhere in Python's path? What happens if you start Python manually
and type 'from d
On Jun 2, 9:24 am, "B.V." wrote:
> Hi,
>
> In order to solve some issues due to operations between Decimal and
> float, we wanted to implement a class that inherits from both float
> and Decimal.
>
> Typically, we wrote:
>
> class Float(Decimal, float):
Can you explain exactly what issues you wan
On May 31, 3:04 pm, Vincent Davis wrote:
> For example If I want all possible ordered lists of 0,1 of length 3
> (0,0,0)
> (0,0,1)
> (0,1,1)
> (1,1,1)
> (1,0,1)
> (1,1,0)
> (1,0,0)
> I don't see a way to get this directly from the itertools. But maybe I
> am missing something.
In this case, you'r
On May 29, 3:43 pm, Bryan wrote:
> Mark Dickinson wrote:
> > N.B. I don't claim any originality for the algorithm; only for the
> > implementation: the algorithm is based on an algorithm attributed to
> > Robert Floyd, and appearing in Jon Bentley's 'Program
For a lazy Friday evening, here's a Python algorithm that seemed so
cute that I just had to share it with everyone. I'm sure it's well
known to many here, but it was new to me. Skip directly to the
'sample2' function to see the algorithm and avoid the commentary...
Suppose that you want to selec
On May 24, 1:13 pm, Steven D'Aprano wrote:
> Do unicode.lower() or unicode.upper() ever change the length of the
> string?
>
> The Unicode standard allows for case conversions that change length, e.g.
> sharp-S in German should convert to SS:
>
> http://unicode.org/faq/casemap_charprop.html#6
>
>
On May 24, 1:13 pm, Steven D'Aprano wrote:
> Do unicode.lower() or unicode.upper() ever change the length of the
> string?
>From looking at the source, in particular the fixupper and fixlower
functions in Objects/unicode.c [1], it looks like not: they do a
simple character-by-character replaceme
On May 19, 9:30 pm, superpollo wrote:
> René 'Necoro' Neumann ha scritto:
> > An idea would be:
>
> def prttn(m, n):
> > ... return sum(1 for x in range(n) if sum(map(int, str(x))) == m)
>
> TypeError: 'int' object is not callable
>
> on 2.5.4
The TypeError is almost certainly because
On May 9, 6:13 am, Steven D'Aprano wrote:
> On Sat, 08 May 2010 13:46:59 -0700, Mark Dickinson wrote:
> >> However, s[:-len(t)] should be both faster and correct.
>
> > Unless len(t) == 0, surely?
>
> Doh! The hazards of insufficient testing. Thanks for ca
On May 8, 8:46 pm, Steven D'Aprano wrote:
> On Sat, 08 May 2010 12:15:22 -0700, Wolfram Hinderer wrote:
> > On 8 Mai, 20:46, Steven D'Aprano
> > wrote:
>
> >> def get_leading_whitespace(s):
> >> t = s.lstrip()
> >> return s[:len(s)-len(t)]
>
> >> >>> c = get_leading_whitespace(a)
> >> >>>
On May 3, 9:49 pm, s...@sig.for.address (Victor Eijkhout) wrote:
> Jerry Hill wrote:
> > >>> from __future__ import division
> > >>> long1/long2
> > 0.5
>
> Beautiful. Thanks so much guys.
And if for some reason you don't want to use the 'from __future__'
import, then you can do long1.__truediv__
On Apr 27, 2:16 am, Keith wrote:
> On Apr 26, 8:47 pm, MRAB wrote:
>
> > "t" for "powers of a thousand", perhaps? (Or "m"?)
>
> Both of those letters are fine. I kinda like "m" for the whole Greco-
> Roman angle, now that you point it out :-)
By the way, there's already a feature request open f
On Apr 26, 6:47 am, Keith wrote:
> From that document it appears that my decimal.Decimal(1234567) example
> shows that the module has a bug:
>
> Doc says:
> [0,123,3] ===> "123E+3"
>
> But Python does:>>> import decimal
> >>> decimal.Decimal(123000).to_eng_string()
>
> '123000'
That's not a bug.
On Apr 26, 4:36 am, Keith wrote:
> I am considering writing a PEP for the inclusion of an engineering
> format specifier, and would appreciate input from others.
> [...]
> I am thinking that if we simply added something like %n (for eNgineer)
> to the list of format specifiers that we could make
On Apr 14, 7:09 pm, Brendan Miller wrote:
> I'm using python 2.5.2.
>
> I have a ctypes function with argtypes like this:
>
> _create_folder.argyptes = [c_void_p, c_int]
Is that line a cut-and-paste? If so, try 'argtypes' instead of
'argyptes'. :)
> The issue I am having is that I can call it
On Apr 8, 7:10 pm, "M. Hamed"
wrote:
> I'm trying the following statements that I found here and there on
> Google, but none of them works on my Python 2.5, are they too old? or
> newer?
>
> "abc".reverse()
This isn't valid Python in any version that I'm aware of. Where did
you see it? It would
On Mar 20, 6:52 am, Steven D'Aprano wrote:
> I've found this:
>
> http://docs.python.org/library/test.html
>
> and I've written a small test:
>
> $ cat test_unicode_interpolation.py
> # For testinghttp://bugs.python.org/issue8128
>
> import test.test_support
> import unittest
>
> class K(unicode):
On Mar 20, 6:23 am, Steven D'Aprano wrote:
> I have two reported bugs in the bug tracker waiting on tests:
>
> http://bugs.python.org/issue8128http://bugs.python.org/issue4037
>
> Are there any guidelines for writing tests for the standard library and
> language?
Not that I can think of, beyond t
On Mar 9, 1:54 pm, casevh wrote:
> After a few hours, the remaining factors are
>
> 6060517860310398033985611921721
>
> and
>
> 9941808367425935774306988776021629111399536914790551022447994642391
>
> casevh
Whoops---I missed this. I'm too slow! But at least my answers agree
with yours. (Factor
On Mar 9, 6:39 am, casevh wrote:
> [also replying to Geremy since the OP's message doesn't appear...]
>
> On Mar 8, 11:05 am, geremy condra wrote:
>
>
>
>
>
> > On Mon, Mar 8, 2010 at 2:15 AM, Fahad Ahmad wrote:
> > > Thanks Geremy,
>
> > > That has been an absolute bump... GOD i cant si
[Replying to Geremy's reply because the OP's post didn't show up in my
newsreader.]
On Mar 7, 8:40 pm, geremy condra wrote:
> On Sun, Mar 7, 2010 at 1:55 PM, Fahad Ahmad wrote:
> > Dear All,
>
> > i am writing my crytographic scheme in python, i am just a new user to it.
> > I have written the co
On Feb 23, 8:11 am, Steven D'Aprano
wrote:
> Making spaces significant in that fashion is mind-bogglingly awful. Let's
> look at a language that does this:
>
> [st...@sylar ~]$ cat ws-example.rb
> def a(x=4)
> x+2
> end
>
> b = 1
> print (a + b), (a+b), (a+ b), (a +b), "\n"
>
> [st...@sylar ~]
On Feb 21, 5:53 pm, vsoler wrote:
> I'm trying to print .7 as 70%
> I've tried:
>
> print format(.7,'%%')
> .7.format('%%')
>
> but neither works. I don't know what the syntax is...
Assuming that you're using Python 2.6 (or Python 3.x):
>>> format(.7, '%')
'70.00%'
>>> format(.7, '.2%')
'70.
On Sat, Feb 20, 2010 at 2:42 PM, Shashwat Anand
wrote:
> A quick solution I came out with, no stirling numbers and had tried to avoid
> large integer multiplication as much as possible.
>
> import math
>
> for i in range(int(raw_input())):
> n, k, l = [int(i) for i in raw_input().split()]
>
On Feb 20, 3:37 pm, mukesh tiwari
wrote:
> I don't know if is possible to import this decimal module but kindly
> tell me.Also a bit about log implementation
The decimal module is part of the standard library; I don't know what
the rules are for SPOJ, but you're already importing the math module
On Feb 20, 11:17 am, mukesh tiwari
wrote:
> Hello everyone. I think it is related to the precision with double
> arithmetic so i posted here.I am trying with this problem
> (https://www.spoj.pl/problems/CALCULAT) and the problem say that "Note : for
> all test cases whose N>=100, its K<=15." I k
On Feb 14, 4:53 pm, mukesh tiwari
wrote:
> Hello everyone. I am new to python and previously i did programming in
> c/c++.Could some one please help me to improve the run time for this
> python program as i don't have idea how to optimized this code.This
> code also seems to be more unpythonic so
On Feb 14, 6:03 pm, a...@pythoncraft.com (Aahz) wrote:
> In article
> <363498c7-3575-4f1e-ad53-d9cd10c8d...@q16g2000yqq.googlegroups.com>,
> Mark Dickinson wrote:
>
> >(2) Obvious things: use range rather than xrange in your loops.
>
> Um, what? You meant the r
On Feb 14, 4:53 pm, mukesh tiwari
wrote:
> Hello everyone. I am new to python and previously i did programming in
> c/c++.Could some one please help me to improve the run time for this
> python program as i don't have idea how to optimized this code.
> [...]
How much of a speedup do you need? Ar
On Feb 11, 1:38 pm, Duncan Booth wrote:
> Tim Chase wrote:
> > But perhaps Py3 changes evaluation, returning an complex number.
>
> Yes, the change is documented
> athttp://docs.python.org/3.1/reference/expressions.html#the-power-operator
>
> If it is in any of the "What's new in Python x.xx" do
On Feb 11, 12:44 am, Terrence Cole wrote:
> Can someone explain to me what python is doing here?
> >>> -0.1 ** 0.1
> -0.7943282347242815
Here you're computing -(0.1 ** 0.1). The exponentiation operator
binds more strongly than the negation operator.
> >>> a = -0.1; b = 0.1
> >>> a ** b
> (0.75
On Feb 10, 8:31 am, Mark Dickinson wrote:
> And here's how it's used in the decimal.Context module:
Aargh! decimal.Context *class*, not module.
And it occurs to me that it would have been cleaner to have
Decimal.__add__ call Context.add rather than the other way around.
Then De
On Feb 9, 6:47 pm, Martin Drautzburg wrote:
> BTW I am not really trying to add three objects, I wanted a third object
> which controls the way the addition is done. Sort of like "/" and "//"
> which are two different ways of doing division.
That seems like a reasonable use case for a third param
On Feb 7, 8:45 pm, duncan smith wrote:
[...]
> interested, but the following pseudo-python gives the idea. For an
[...]
> try:
> yield rand() < exp(dF / temp)
Practically speaking, the condition rand() < exp(dF / temp) is never
going to be satisfied if dF / temp <
On Feb 7, 12:52 am, duncan smith
wrote:
> import platform
> if platform.architecture()[0].startswith('64'):
> TINY = 2.2250738585072014e-308
> else:
> TINY = 1.1754943508222875e-38
As Christian said, whether you're using 32-bit or 64-bit shouldn't
make a difference here. Just use the f
1 - 100 of 414 matches
Mail list logo