Re: Calculating very large exponents in python

2010-03-08 Thread Mark Dickinson
[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

Re: Calculating very large exponents in python

2010-03-10 Thread Mark Dickinson
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

Re: Calculating very large exponents in python

2010-03-10 Thread Mark Dickinson
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

Re: Writing tests for the Python bug tracker

2010-03-20 Thread Mark Dickinson
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

Re: Writing tests for the Python bug tracker

2010-03-20 Thread Mark Dickinson
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):

Re: what's the precision of fractions.Fraction?

2010-11-20 Thread Mark Dickinson
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

Re: Weibull distr. random number generation

2010-11-20 Thread Mark Dickinson
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) >

Re: Some syntactic sugar proposals

2010-12-02 Thread Mark Dickinson
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 '

Re: round in 2.6 and 2.7

2010-12-27 Thread Mark Dickinson
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

Re: round in 2.6 and 2.7

2010-12-29 Thread Mark Dickinson
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

Re: An amazing one-minute bit of fun at the interactive prompt

2011-02-21 Thread Mark Dickinson
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?

Re: Why these don't work??

2010-04-08 Thread Mark Dickinson
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

Re: ctypes question

2010-04-14 Thread Mark Dickinson
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

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Mark Dickinson
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

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Mark Dickinson
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.

Re: Engineering numerical format PEP discussion

2010-04-27 Thread Mark Dickinson
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

Re: long int computations

2010-05-06 Thread Mark Dickinson
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__

Re: Fastest way to calculate leading whitespace

2010-05-08 Thread Mark Dickinson
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) > >> >>>

Re: Fastest way to calculate leading whitespace

2010-05-09 Thread Mark Dickinson
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

Re: function that counts...

2010-05-19 Thread Mark Dickinson
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

Re: Can upper() or lower() ever change the length of a string?

2010-05-24 Thread Mark Dickinson
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

Re: Can upper() or lower() ever change the length of a string?

2010-05-24 Thread Mark Dickinson
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 > >

A Friday Python Programming Pearl: random sampling

2010-05-28 Thread Mark Dickinson
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

Re: A Friday Python Programming Pearl: random sampling

2010-05-29 Thread Mark Dickinson
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

Re: Question about permutations (itertools)

2010-05-31 Thread Mark Dickinson
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

Re: Mixing Decimal and float

2010-06-02 Thread Mark Dickinson
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

Re: Decimal problem

2010-06-10 Thread Mark Dickinson
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

Re: math.erfc OverflowError

2010-06-13 Thread Mark Dickinson
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

Re: a +b ?

2010-06-14 Thread Mark Dickinson
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[

Re: SyntaxError not honoured in list comprehension?

2010-07-04 Thread Mark Dickinson
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

Re: SyntaxError not honoured in list comprehension?

2010-07-04 Thread Mark Dickinson
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

Re: SyntaxError not honoured in list comprehension?

2010-07-05 Thread Mark Dickinson
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

Re: SyntaxError not honoured in list comprehension?

2010-07-05 Thread Mark Dickinson
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

Re: Python -- floating point arithmetic

2010-07-07 Thread Mark Dickinson
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

Re: Python -- floating point arithmetic

2010-07-08 Thread Mark Dickinson
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

Re: Python -- floating point arithmetic

2010-07-08 Thread Mark Dickinson
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 > >

Re: Python -- floating point arithmetic

2010-07-08 Thread Mark Dickinson
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

Re: Python -- floating point arithmetic

2010-07-08 Thread Mark Dickinson
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

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-11 Thread Mark Dickinson
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

Re: round issue

2010-07-12 Thread Mark Dickinson
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:

Re: ValueError: invalid literal for float(): -1.#IND (pickle.py)

2010-07-12 Thread Mark Dickinson
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

Re: round issue

2010-07-12 Thread Mark Dickinson
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

Re: ctypes' c_longdouble: underflow error (bug?)

2010-07-16 Thread Mark Dickinson
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

Re: Floating numbers

2010-08-13 Thread Mark Dickinson
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.

Re: Floating numbers

2010-08-13 Thread Mark Dickinson
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

Re: How to convert bytearray into integer?

2010-08-16 Thread Mark Dickinson
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

Re: How to convert bytearray into integer?

2010-08-16 Thread Mark Dickinson
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

Re: Assert statements in python 3.1

2010-08-20 Thread Mark Dickinson
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

Re: weakref.proxy behaviour in python 3.0

2010-08-21 Thread Mark Dickinson
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

Re: weakref.proxy behaviour in python 3.0

2010-08-21 Thread Mark Dickinson
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

Re: python version in snow leopard?

2009-06-09 Thread Mark Dickinson
On Jun 9, 7:30 am, Alia Khouri wrote: > Does anyone know what version of python will appear in snow leopard > which is apparently being released in September? The python-dev thread starting at http://mail.python.org/pipermail/python-3000/2008-September/014816.html suggests that back in Septembe

Re: random number including 1 - i.e. [0,1]

2009-06-10 Thread Mark Dickinson
On Jun 10, 7:25 am, John Yeung wrote: > On Jun 10, 1:52 am, Steven D'Aprano > > wrote: > > On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote: > > > Therefore, to me the most up-to-date docs (which say > > > that uniform(a, b) returns a float in the closed > > > interval [a, b]) is closer to co

Re: retrieve bitwise float representation

2009-06-10 Thread Mark Dickinson
n the above would truncate, while the implicit conversion from double to single precision involved in packing with 'f' is more likely to do a round-to-nearest. -- Mark Dickinson -- http://mail.python.org/mailman/listinfo/python-list

Re: random number including 1 - i.e. [0,1]

2009-06-10 Thread Mark Dickinson
On Jun 10, 6:21 pm, Mensanator wrote: > So, the 2.6.2 documentation is STILL wrong. Before it implied > it was ALWAYS a semi-open interval, and now it says it's ALWAYS > a closed interval. But neither is correct. Exactly which bit of the 2.6.2 documentation do you think is incorrect? The documen

Re: random number including 1 - i.e. [0,1]

2009-06-10 Thread Mark Dickinson
On Jun 10, 6:57 pm, Mensanator wrote: > On Jun 10, 12:37 pm, Mark Dickinson wrote: > > > On Jun 10, 6:21 pm, Mensanator wrote: > > > > So, the 2.6.2 documentation is STILL wrong. Before it implied > > > it was ALWAYS a semi-open interval, and now it says it'

Re: random number including 1 - i.e. [0,1]

2009-06-10 Thread Mark Dickinson
On Jun 10, 8:15 pm, Robert Kern wrote: > On 2009-06-10 13:53, Terry Reedy wrote: > > A full technical discussion does not below in the docs, in my opinion. A > > wike article would be fine. > > True. However, a brief note that "Due to floating point arithmetic, for some > values of a and b, b may

Re: random number including 1 - i.e. [0,1]

2009-06-10 Thread Mark Dickinson
Robert Kern wrote: > On 2009-06-10 14:46, Mark Dickinson wrote: >> On Jun 10, 8:15 pm, Robert Kern wrote: >>> On 2009-06-10 13:53, Terry Reedy wrote: >>>> A full technical discussion does not below in the docs, in my opinion. A >>>> wike article woul

Re: random number including 1 - i.e. [0,1]

2009-06-10 Thread Mark Dickinson
Robert Kern wrote: > On 2009-06-10 15:54, Mark Dickinson wrote: >> [...] I'm not sure I'm capable of coming up with extra wording >> for the docs that won't just cause more confusion, so I'll leave that >> to someone else. > > I did make a

Re: Convert integer to fixed length binary string

2009-06-11 Thread Mark Dickinson
On Jun 11, 10:29 am, casebash wrote: > Sorry, I didn't quite make it clear. The issue isn't about limiting > the length (as I won't be using integers bigger than this). The > problem is that sometimes the output is shorter. Is this what you're looking for? Python 2.6.2 (r262:71600, Jun 8 2009,

Re: Changing Hash Values Across Versions

2009-06-11 Thread Mark Dickinson
On Jun 11, 8:55 pm, Christian Heimes wrote: > Phil Thompson schrieb: > > > How stable should the implementation of, for example, a string's hash > > across different Python versions? > > > Is it defined that hash("foo") will return the same value for Python 2.5.1, > > 2.6.1 and 2.6.2? > > The hash

Re: frustrating failure of 'break' statement ( novice )

2009-06-13 Thread Mark Dickinson
On Jun 13, 10:48 pm, pdlem...@earthlink.net wrote: > In my programs the 'break' fails to work.  I've studied the docs for > 3.0 and Programming in Python, neither of which are illuminating. > Simplest example : > > while True : >     num = int(input()) >     print(num) >     if num == 0 : >        

Re: Measuring Fractal Dimension ?

2009-06-17 Thread Mark Dickinson
On Jun 17, 7:04 am, Paul Rubin wrote: > I think a typical example of a curve that's continuous but not > uniformly continuous is > >    f(t) = sin(1/t), defined when t > 0 > > It is continuous at every t>0 but wiggles violently as you get closer > to t=0.  You wouldn'

Re: Measuring Fractal Dimension ?

2009-06-17 Thread Mark Dickinson
On Jun 17, 1:26 pm, Jaime Fernandez del Rio wrote: > On Wed, Jun 17, 2009 at 1:52 PM, Mark Dickinson wrote: > > Maybe James is thinking of the standard theorem > > that says that if a sequence of continuous functions > > on an interval converges uniformly then its limit

Re: Measuring Fractal Dimension ?

2009-06-17 Thread Mark Dickinson
On Jun 17, 2:18 pm, pdpi wrote: > On Jun 17, 1:26 pm, Jaime Fernandez del Rio > wrote: > > > P.S. The snowflake curve, on the other hand, is uniformly continuous, right? > > The definition of uniform continuity is that, for any epsilon > 0, > there is a delta > 0 such that, for any x and y, if x-

Re: Measuring Fractal Dimension ?

2009-06-17 Thread Mark Dickinson
On Jun 17, 3:46 pm, Paul Rubin <http://phr...@nospam.invalid> wrote: > Mark Dickinson writes: > > It looks as though you're treating (a portion of?) the Koch curve as > > the graph of a function f from R -> R and claiming that f is > > uniformly continuous.  Bu

Re: Measuring Fractal Dimension ?

2009-06-18 Thread Mark Dickinson
On Jun 18, 7:26 pm, David C. Ullrich wrote: > On Wed, 17 Jun 2009 08:18:52 -0700 (PDT), Mark Dickinson > >Right.  Or rather, you treat it as the image of such a function, > >if you're being careful to distinguish the curve (a subset > >of R^2) from its parametrization (

Re: Integer Division

2009-06-19 Thread Mark Dickinson
On Jun 19, 8:22 am, Anjanesh Lekshminarayanan wrote: > >>> a = 1 > >>> b = 25 > >>> a / b > 0 > >>> float(a) / b > > 0.040001 Python typically stores floats in binary, not decimal. The value 0.04 isn't exactly representable in binary, so the division float(1)/25 can't produce 0.04:

Re: generator expression works in shell, NameError in script

2009-06-19 Thread Mark Dickinson
On Jun 19, 1:45 pm, Bruno Desthuilliers wrote: > [...] > but it indeed looks like using bar.index *in a generator expression* > fails (at least in 2.5.2) : > >   >>> class Foo(object): > ...     bar = ['a', 'b', 'c'] > ...     baaz = list((bar.index(b), b) for b in bar) > ... > Traceback (most rec

Re: Measuring Fractal Dimension ?

2009-06-19 Thread Mark Dickinson
On Jun 19, 7:43 pm, David C. Ullrich wrote: > Evidently my posts are appearing, since I see replies. > I guess the question of why I don't see the posts themselves > \is ot here... Judging by this thread, I'm not sure that much is off-topic here. :-) > Perhaps not. I'm very surprised to see tho

Re: Measuring Fractal Dimension ?

2009-06-19 Thread Mark Dickinson
On Jun 17, 12:52 pm, Mark Dickinson wrote: > g_n(t) = nt if 0 <= t <= 1/n else 1 Whoops. Wrong definition. That should be: g_n(t) = nt if 0 <= t <= 1/n else n(2/n-t) if 1/n <= t <= 2/n else 0 Then my claim that g_n(t) -> 0 for all t might actuall

Re: Measuring Fractal Dimension ?

2009-06-22 Thread Mark Dickinson
On Jun 22, 7:43 pm, David C. Ullrich wrote: > Surely you don't say a curve is a subset of the plane and > also talk about the integrals of verctor fields over _curves_? > [snip rest of long response that needs a decent reply, but > possibly not here... ] I wonder whether we can find a better pl

Re: Measuring Fractal Dimension ?

2009-06-23 Thread Mark Dickinson
On Jun 23, 3:52 am, Steven D'Aprano wrote: > On Mon, 22 Jun 2009 13:43:19 -0500, David C. Ullrich wrote: > > In my universe the standard definition of "log" is different froim what > > log means in a calculus class > > Now I'm curious what the difference is. It's just the usual argument about whe

Re: Measuring Fractal Dimension ?

2009-06-24 Thread Mark Dickinson
On Jun 24, 10:12 am, pdpi wrote: > Regarding inf ** 0, why does IEEE745 define it as 1, when there is a > perfectly fine NaN value? Have a look at: http://www.eecs.berkeley.edu/~wkahan/ieee754status/ieee754.ps (see particularly page 9). Mark -- http://mail.python.org/mailman/listinfo/python-l

Re: Measuring Fractal Dimension ?

2009-06-24 Thread Mark Dickinson
On Jun 24, 10:12 am, pdpi wrote: > Regarding inf ** 0, why does IEEE745 define it as 1, when there is a > perfectly fine NaN value? Other links: the IEEE 754 revision working group mailing list archives are public; there was extensive discussion about special values of pow and similar functions

Re: 3.2*2 is 9.6 ... or maybe it isn't?

2009-06-25 Thread Mark Dickinson
On Jun 25, 7:04 pm, Bojan Sudarevic wrote: > Hi, > > I'm PHP developer and entirely new to Python. I installed it (version > 2.5.2, from Debian repos) today on the persuasion of a friend, who is a > Python addict. > > The first thing I typed into it was 3.2*3 (don't ask why I typed *that*, > I don

Re: 3.2*2 is 9.6 ... or maybe it isn't?

2009-06-25 Thread Mark Dickinson
On Jun 25, 7:04 pm, Bojan Sudarevic wrote: > The first thing I typed into it was 3.2*3 (don't ask why I typed *that*, > I don*t know, I just did). And the answer wasn't 9.6. It looks like it's false in PHP too, by the way (not that I know any PHP, so I could well be missing something...) bernou

Re: 3.2*2 is 9.6 ... or maybe it isn't?

2009-06-25 Thread Mark Dickinson
On Jun 25, 7:41 pm, Michael Torrie wrote: > I guess PHP artificially rounds the results or something to make it seem > like it's doing accurate calculations, which is a bit surprising to me. After a bit of experimentation on my machine, it *looks* as though PHP is using the usual hardware floats

Re: python3 fail to start

2009-06-30 Thread Mark Dickinson
On Jun 30, 3:43 pm, ts wrote: > i just install the python 3.1 dmg onto my mac. when i run python3, it > fail with : > > Fatal Python error: Py_Initialize: can't initialize sys standard > streams > LookupError: unknown encoding: > Abort trap > > couldnt understand the problem. anyone can help? Hmm

Re: Compiling 64 bit python on a mac - cannot compute sizeof (int)

2009-07-03 Thread Mark Dickinson
On Jul 3, 5:30 pm, Keflavich wrote: > I'm trying to compile a 64 bit version of python 2.6.2 on my mac (OS X > 10.5.7), and am running into a problem during the configure stage. > > I configure with: > ./configure --enable-framework=/Library/Frameworks --enable- > universalsdk MACOSX_DEPLOYMENT_TA

Re: How Python Implements "long integer"?

2009-07-05 Thread Mark Dickinson
On Jul 5, 8:38 am, Pedram wrote: > Hello, > I'm reading about implementation of long ints in Python. I downloaded > the source code of CPython and will read the longobject.c, but from > where I should start reading this file? I mean which function is the > first? I don't really understand the que

Re: How Python Implements "long integer"?

2009-07-05 Thread Mark Dickinson
On Jul 5, 1:09 pm, Pedram wrote: > Thanks for reply, > Sorry I can't explain too clear! I'm not English ;) That's shocking. Everyone should be English. :-) > But I want to understand the implementation of long int object in > Python. How Python allocates memory and how it implements operations

Re: How Python Implements "long integer"?

2009-07-06 Thread Mark Dickinson
On Jul 6, 1:24 pm, Pedram wrote: > OK, fine, I read longobject.c at last! :) > I found that longobject is a structure like this: > > struct _longobject { >     struct _object *_ob_next; >     struct _object *_ob_prev; For current CPython, these two fields are only present in debug builds; for a

Re: A Bug By Any Other Name ...

2009-07-06 Thread Mark Dickinson
On Jul 6, 3:32 am, Lawrence D'Oliveiro wrote: > I wonder how many people have been tripped up by the fact that > >     ++n > > and > >     --n > > fail silently for numeric-valued n. Recent python-ideas discussion on this subject: http://mail.python.org/pipermail/python-ideas/2009-March/003741.h

Re: How Python Implements "long integer"?

2009-07-07 Thread Mark Dickinson
On Jul 6, 4:13 pm, Pedram wrote: > On Jul 6, 5:46 pm, Mark Dickinson wrote: > > On Jul 6, 1:24 pm, Pedram wrote: > > > > OK, fine, I read longobject.c at last! :) > > > I found that longobject is a structure like this: > > > > struct _longo

Re: python3 fail to start

2009-07-09 Thread Mark Dickinson
On Jun 30, 3:43 pm, ts wrote: > i just install the python 3.1 dmg onto my mac. when i run python3, it > fail with : > > Fatal Python error: Py_Initialize: can't initialize sys standard > streamsLookupError: unknown encoding: > Abort trap > > couldnt understand the problem. anyone can help? Any ch

Re: missing 'xor' Boolean operator

2009-07-14 Thread Mark Dickinson
On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" wrote: > Current Boolean operators are 'and', 'or', and 'not'.  It would be nice to > have an 'xor' operator as well. Hmm. I don't think 'nice' is sufficient. You'd need to make the case that it's sufficiently useful to justify adding a new keyword '

Re: bad behaviour in interactive Python prompt

2009-07-14 Thread Mark Dickinson
On Jul 14, 8:20 pm, "~km" wrote: > I'm experiencing a strange behaviour of the Python prompt when using > the > four arrow keys ( not the VIM' nor Emacs' ones ;-) ). Instead of > getting > the previous and next command respectively I get ugly characters. See > it > yourself:http://tinypic.com/view

Re: missing 'xor' Boolean operator

2009-07-14 Thread Mark Dickinson
On Jul 14, 8:43 pm, Chris Rebert wrote: > On Tue, Jul 14, 2009 at 11:47 AM, Mark Dickinson wrote: > > (1) It's easy to emulate xor:  'x xor y' <-> bool(x) != bool(y) > > Using the xor bitwise operator is also an option: > bool(x) ^ bool(y) Good poi

Re: missing 'xor' Boolean operator

2009-07-15 Thread Mark Dickinson
On Jul 15, 5:07 am, "Dr. Phillip M. Feldman" wrote: > I appreciate the effort that people have made, but I'm not impressed with any > of the answers.  For one thing, xor should be able to accept an arbitrary > number of input arguments (not just two), and should return True if and only > if the nu

Re: missing 'xor' Boolean operator

2009-07-15 Thread Mark Dickinson
On Jul 15, 7:29 pm, Wayne Brehaut wrote: > On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson > wrote: > >I'd also guess that 'xor' would be much less used than 'and' or 'or', > >but maybe that's just a reflection of the sort of

Re: missing 'xor' Boolean operator

2009-07-18 Thread Mark Dickinson
On Jul 17, 12:06 pm, Jean-Michel Pichavant wrote: > I was saying that using boolean operators with object instead of boolean > values is error prone, I agree with this to some extent. After all, Python conditional expressions were eventually introduced in response to buggy uses of the 'a and b o

Re: missing 'xor' Boolean operator

2009-07-21 Thread Mark Dickinson
On Jul 20, 11:34 pm, Ethan Furman wrote: > Dr. Phillip M. Feldman wrote: >  > Suppose that 'xor' returns the value that is true when only one value is >  > true, and False otherwise.  This definition of xor doesn't have the > standard >  > associative property, that is, >  > >  > (a xor b) xor c >

Re: len() should always return something

2009-07-24 Thread Mark Dickinson
On Jul 24, 3:11 pm, "Rhodri James" wrote: > Which doesn't make your point less valid.  In fact I'd go so > far as to argue that what len() gives you is the number of > items in a container, so len(7) should return 0. Nah. 7 contains three bits, so len(7) should *clearly* return 3. Mark -- http

Re: missing 'xor' Boolean operator

2009-07-27 Thread Mark Dickinson
On Jul 27, 1:53 am, "Delaney, Timothy (Tim)" wrote: > Mark Dickinson wrote: > >> Since the 'and' and 'or' already return objects (and objects > >> evaluate to true or false), then 'xor' should behave likewise, IMO. > >> I ex

Re: possible to round number and convert to string?

2009-08-01 Thread Mark Dickinson
On Jul 31, 11:17 pm, "Dr. Phillip M. Feldman" wrote: > I'd like to be able to convert a float to a string representation in which > the number is rounded to a specified number of digits.  If num2str is a > hypothetical function that does this, then num2str(pi,3) would be '3.142' > (not '3.141').

Re: Overlap in python

2009-08-04 Thread Mark Dickinson
On Aug 4, 7:15 pm, Jay Bird wrote: > Hi everyone, > > I've been trying to figure out a simple algorithm on how to combine a > list of parts that have 1D locations that overlap into a non- > overlapping list.  For example, here would be my input: > > part name   location > a                  5-9 >

Re: Overlap in python

2009-08-04 Thread Mark Dickinson
On Aug 4, 9:03 pm, Mark Dickinson wrote: > for i, (pt, startend, name) in enumerate(transitions): Whoops. That line should just be: for pt, startend, name in transitions: The enumerate was accidentally left-over from a more complicated version. -- Mark -- http://mail.python.org/mail

Re: Python 2.6 still not giving memory back to the OS...

2009-08-15 Thread Mark Dickinson
On Aug 15, 12:55 pm, Chris Withers wrote: > Hi All, > > I thought this was fixed back in Python 2.5, but I guess not? > > So, I'm playing in an interactive session: > >  >>> from xlrd import open_workbook >  >>> b = open_workbook('some.xls',pickleable=0,formatting_info=1) > > At this point, top sh

Re: getting the fractional part of a real?

2009-08-15 Thread Mark Dickinson
On Aug 15, 7:40 pm, Christian Heimes wrote: > Roy Smith schrieb: > > > What's the best way to get the fractional part of a real?  The two ways I > > can see are r % 1 and r = int(r), but both seem a bit hokey.  Is there > > something more straight-forward that I'm missing, like fraction(r)? > >>>

Re: Python on Crays

2009-08-21 Thread Mark Dickinson
On Aug 21, 12:21 am, Carrie Farberow wrote: > I am trying to build a statically-linked Python based on directions at: > > http://yt.enzotools.org/wiki/CrayXT5Installation > > I have tried this on multiple systems.  The first time I attempt to build > python, 'make' runs fine but 'make install' fa

<    1   2   3   4   5   >