Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Paul Rubin
Dave Angel writes: >> if x < 1e9: > Now 10**9 is way below either limit of floating point. The idea was just to get rid of the case where c (further down in the code) ends up being a negative number. Floating point works fine for numbers that small. > And I can't figure out your code

Re: installing error in python

2015-04-12 Thread Rustom Mody
On Monday, April 13, 2015 at 11:08:38 AM UTC+5:30, Mahima Goyal wrote: > error of corrupted file or directory is coming if i am installing > python for 64 bit. 1. Download again and install 2. Please specify OS and installation method 3. If persists, please paste error IN FULL -- https://mail.pyt

Re: installing error in python

2015-04-12 Thread Cameron Simpson
On 13Apr2015 11:08, Mahima Goyal wrote: error of corrupted file or directory is coming if i am installing python for 64 bit. You will need to supply more information. What platform are you installing on? (Windows, Linux, something else? What version?) What was the download page _and_ link

Re: installing error in python

2015-04-12 Thread Dave Angel
On 04/13/2015 01:38 AM, Mahima Goyal wrote: error of corrupted file or directory is coming if i am installing python for 64 bit. And what OS is that on, and how long has it been since you've done a file system check on the drive? For that matter, what version of Python are you installing,

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Dave Angel
On 04/13/2015 01:25 AM, Paul Rubin wrote: Dave Angel writes: But doesn't math.pow return a float?... Or were you saying bignums bigger than a float can represent at all? Like: x = 2**1 -1 ... math.log2(x) 1.0 Yes, exactly that. Well that value x has some 3300 digits, and I seem

installing error in python

2015-04-12 Thread Mahima Goyal
error of corrupted file or directory is coming if i am installing python for 64 bit. -- https://mail.python.org/mailman/listinfo/python-list

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Paul Rubin
Dave Angel writes: > But doesn't math.pow return a float?... > Or were you saying bignums bigger than a float can represent at all? Like: x = 2**1 -1 ... math.log2(x) > 1.0 Yes, exactly that. Thus (not completely tested): def isqrt(x): def log2(x): return mat

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Dave Angel
On 04/12/2015 11:30 PM, Paul Rubin wrote: Dave Angel writes: If I were trying to get a bound for stopping the divide operation, on a value too large to do exact real representation, I'd try doing just a few iterations of Newton's method. Python ninja trick: math.log works on bignums too large

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Paul Rubin
Dave Angel writes: > If I were trying to get a bound for stopping the divide operation, on > a value too large to do exact real representation, I'd try doing just > a few iterations of Newton's method. Python ninja trick: math.log works on bignums too large to be represented as floats ;-) -- htt

Re: Regular Expression

2015-04-12 Thread Pippo
I fixed all! Thanks. This is the result: #C[Health] #P[Information] #ST[genetic information] #C[oral | (recorded in (any form | medium))] #C[Is created or received by] #A[health care provider | health plan | public health authority | employer | life insurer | school | university | or health car

Re: Regular Expression

2015-04-12 Thread Pippo
Sweet! Thanks all of you! I matched everything except these ones... trying to find the best way > whether #C[oral | (recorded in (any form | medium))], that #C[the past, present, or future physical | mental health | condition of an individual] | > #C[the past, present, or future payment fo

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Dave Angel
On 04/12/2015 09:56 PM, Paul Rubin wrote: Marko Rauhamaa writes: And in fact, the sqrt optimization now makes the original version 20% faster: ... bound = int(math.sqrt(n)) That could conceivably fail because of floating point roundoff or overflow, e.g. fac(3**1000). A fancier approach

Anyone used snap.py for drawing a graph?

2015-04-12 Thread Pippo
Hi, Any guide on this? http://snap.stanford.edu/snappy/#download -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression

2015-04-12 Thread Pippo
> Put the print inside the "if"; you don't really care when result is None, and > anyway you can't access .group when it is None - it is not an 're.match" > object, because there was no match. Thanks Cameron, this worked. > > Once you're happy you should consider what happens when there is m

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
On 12Apr2015 18:28, Pippo wrote: On Sunday, 12 April 2015 21:21:48 UTC-4, Cameron Simpson wrote: [...] Pippo, please take a moment to trim the less relevant verbiage from the quoted material; it makes replies easier to read because what is left can be taken to be more "on point". Thanks.

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Paul Rubin
Marko Rauhamaa writes: > And in fact, the sqrt optimization now makes the original version 20% > faster: ... > bound = int(math.sqrt(n)) That could conceivably fail because of floating point roundoff or overflow, e.g. fac(3**1000). A fancier approach to finding the integer square root might

Re: calling an api in python code

2015-04-12 Thread Ben Finney
Pippo writes: > On Sunday, 12 April 2015 20:50:51 UTC-4, Steven D'Aprano wrote: > > The API tells you how to use a library. That's what API means: "Application > > Programming Interface".[…] > > Can you ask a more specific question? > > This is what I want to use: https://github.com/mbrubeck/col

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 21:21:48 UTC-4, Cameron Simpson wrote: > On 12Apr2015 17:55, Pippo wrote: > >On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> It looks like it should, unless you have mangled your regular expression. > [...] > >> Also note that you can print the reg

Re: Python newbie here! No module named settings

2015-04-12 Thread rdavis7408
On Thursday, June 2, 2011 at 10:29:48 AM UTC-5, Neeraj Agarwal wrote: > Hello all, > > I'm a newbie to Python and its my 2nd day exploring it. > > I was trying to use Python wrapper for Google Charts API and was > tweaking the examples. > https://github.com/gak/pygooglechart/raw/master/examples/p

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
On 12Apr2015 17:55, Pippo wrote: On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: It looks like it should, unless you have mangled your regular expression. [...] Also note that you can print the regexp's .pattern attribute: print(constraint.pattern) as a check that what was

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 21:07:09 UTC-4, MRAB wrote: > On 2015-04-13 01:55, Pippo wrote: > > On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> >> >> > > constraint = re.compile(r'(#C\[\w*\]')) > >> >> >> > > result = constraint.search(content[j],re.MULTILINE) > >> >>

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 01:55, Pippo wrote: On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: >> >> > > constraint = re.compile(r'(#C\[\w*\]')) >> >> > > result = constraint.search(content[j],re.MULTILINE) >> >> > > text.append(result) >> >> > > print(text) [...] >> >> r

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 01:25, Pippo wrote: On Sunday, 12 April 2015 20:06:08 UTC-4, MRAB wrote: On 2015-04-13 00:47, Pippo wrote: > On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: >> On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: >> > On 2015-04-12 23:49, Pippo wrote: >> > > I have a text

Re: calling an api in python code

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 20:50:51 UTC-4, Steven D'Aprano wrote: > On Mon, 13 Apr 2015 10:31 am, Pippo wrote: > > > I am new in this matter.. I need some help to understand how do I call an > > api in python code? > > Your question is too general. It is like: > > > "I am new to carpentry and wo

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 20:46:19 UTC-4, Cameron Simpson wrote: > >> >> > > constraint = re.compile(r'(#C\[\w*\]')) > >> >> > > result = constraint.search(content[j],re.MULTILINE) > >> >> > > text.append(result) > >> >> > > print(text) > [...] > >> >> result is empty! Although

Re: calling an api in python code

2015-04-12 Thread Steven D'Aprano
On Mon, 13 Apr 2015 10:31 am, Pippo wrote: > I am new in this matter.. I need some help to understand how do I call an > api in python code? Your question is too general. It is like: "I am new to carpentry and wood-working. How do I use a tool?" Which tool? Hammer, electric drill, hand saw, el

Re: calling an api in python code

2015-04-12 Thread Ben Finney
Pippo writes: > I am new in this matter.. I need some help to understand how do I call > an api in python code? You do whatever is documented as the API. That's tautological, so you probably already know that. But it's not clear what you are asking. Which API are you looking to use? Where is it

Re: Regular Expression

2015-04-12 Thread Cameron Simpson
On 12Apr2015 17:25, Pippo wrote: >> > > constraint = re.compile(r'(#C\[\w*\]')) >> > > result = constraint.search(content[j],re.MULTILINE) >> > > text.append(result) >> > > print(text) [...] >> result is empty! Although it should have a content. [...] > I fixed the syntax

calling an api in python code

2015-04-12 Thread Pippo
I am new in this matter.. I need some help to understand how do I call an api in python code? -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 20:06:08 UTC-4, MRAB wrote: > On 2015-04-13 00:47, Pippo wrote: > > On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > >> On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > >> > On 2015-04-12 23:49, Pippo wrote: > >> > > I have a text as follows: > >> > > > >> >

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-13 00:47, Pippo wrote: On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > On 2015-04-12 23:49, Pippo wrote: > > I have a text as follows: > > > > "#D{#C[Health] #P[Information] - > > means any information, including #ST[genet

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 19:47:09 UTC-4, Pippo wrote: > On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > > On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > > > On 2015-04-12 23:49, Pippo wrote: > > > > I have a text as follows: > > > > > > > > "#D{#C[Health] #P[Information] - > > >

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 19:44:05 UTC-4, Pippo wrote: > On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > > On 2015-04-12 23:49, Pippo wrote: > > > I have a text as follows: > > > > > > "#D{#C[Health] #P[Information] - > > > means any information, including #ST[genetic information], > > > wh

Re: Regular Expression

2015-04-12 Thread Pippo
On Sunday, 12 April 2015 19:28:44 UTC-4, MRAB wrote: > On 2015-04-12 23:49, Pippo wrote: > > I have a text as follows: > > > > "#D{#C[Health] #P[Information] - > > means any information, including #ST[genetic information], > > whether #C[oral | (recorded in (any form | medium))], that > > (1)#C[Is

Re: Regular Expression

2015-04-12 Thread Ben Finney
Pippo writes: > I try with regex but it doesn't work: Thank you for providing a short, self-contained example. What does this code do when you try? If there is an error, please post the full traceback exactly (cut and paste the traceback text). What are you expecting it to do, and how is that

Re: Regular Expression

2015-04-12 Thread MRAB
On 2015-04-12 23:49, Pippo wrote: I have a text as follows: "#D{#C[Health] #P[Information] - means any information, including #ST[genetic information], whether #C[oral | (recorded in (any form | medium))], that (1)#C[Is created or received by] a #A[health care provider | health plan | public hea

Regular Expression

2015-04-12 Thread Pippo
I have a text as follows: "#D{#C[Health] #P[Information] - means any information, including #ST[genetic information], whether #C[oral | (recorded in (any form | medium))], that (1)#C[Is created or received by] a #A[health care provider | health plan | public health authority | employer | life

Re: Getting rid of

2015-04-12 Thread Denis McMahon
On Sun, 12 Apr 2015 21:27:30 +0200, Cecil Westerhof wrote: > When you run my script you do not get warnings? I ran into too many issues trying to install the modules I needed to try and run it. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list

Re: python implementation of a new integer encoding algorithm.

2015-04-12 Thread janhein . vanderburg
Op donderdag 9 april 2015 14:04:25 UTC+2 schreef Dave Angel: > I still don't see where you have anywhere declared what your goal is. Sorry that you didn't like the improvements to the stop bit encoding that I illustrated in http://optarbvalintenc.blogspot.nl/2015/04/the-new-proposal.html and the

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Paul Rubin
Brian Gladman writes: > As we factor the number with increasing prime values from a simple > sieve, if the number remaining to be factored is still large it can then > be efficient to run a prime test to see if what remains is prime. In the case of 2**111+1, the second-largest prime factor is lar

error with Firefox Binary 'The browser appears to have exited'

2015-04-12 Thread mahmoud alnafei
I have problem with selenium and Firefox when i run my code below: from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC fro

Re: Getting rid of

2015-04-12 Thread Cecil Westerhof
Op Sunday 12 Apr 2015 20:54 CEST schreef Denis McMahon: > On Sun, 12 Apr 2015 19:48:53 +0200, Cecil Westerhof wrote: > >> What should I do to get rid of the warnings: >> /usr/lib/python2.7/site-packages/requests-2.6.0-py2.7.egg/requests/ > packages/urllib3/connectionpool.py:769: >> InsecureRequest

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Brian Gladman
On 12/04/2015 18:20, Paul Rubin wrote: > Steven D'Aprano writes: >> Um, "simple sieve"? You're using Miller-Rabin to check for candidate >> prime factors. I don't think that counts as a simple sieve :-) > > How does Miller-Rabin help? It has to cost more than trial division. As we factor the nu

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Brian Gladman
On 12/04/2015 15:29, Steven D'Aprano wrote: >> I don'tknow how well it compares more generally but where large amounts >> of memory are available a simple sieve works quite well. I have an >> implementation available here (in Python 3): >> >> http://ccgi.gladman.plus.com/wp/?page_id=1500 > > Um,

Re: Getting rid of

2015-04-12 Thread Denis McMahon
On Sun, 12 Apr 2015 19:48:53 +0200, Cecil Westerhof wrote: > What should I do to get rid of the warnings: > /usr/lib/python2.7/site-packages/requests-2.6.0-py2.7.egg/requests/ packages/urllib3/connectionpool.py:769: > InsecureRequestWarning: Unverified HTTPS request is being made. > Ad

Getting rid of

2015-04-12 Thread Cecil Westerhof
I am playing a little bit with libturpial. I got a few warnings. Most I could get rid of, but one I still get, while I have done what is said in the reference of the warning. Example code: #!/usr/bin/env python import certifi import urllib3 import urllib3.contrib.pyopenssl

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Paul Rubin
Paul Rubin writes: >... d = gcd(abs(x-y), n) ... >print pollard(2778562183799360736577L) > finds the factor 25781083 almost instantly. > Whoops, you need this too: def gcd(x,y): while True: x,y = y,x%y if y==0: return x -- https://mail.pyth

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Paul Rubin
Steven D'Aprano writes: > Um, "simple sieve"? You're using Miller-Rabin to check for candidate > prime factors. I don't think that counts as a simple sieve :-) How does Miller-Rabin help? It has to cost more than trial division. Meanwhile, trial division up to 10 is almost instantaneous and

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Steven D'Aprano
On Sun, 12 Apr 2015 07:34 pm, Brian Gladman wrote: > On 11/04/2015 03:04, Steven D'Aprano wrote: > >> It may be a bit slow for very large numbers. On my computer, this takes >> 20 seconds: >> >> py> pyprimes.factors.factorise(2**111+1) >> [3, 3, 1777, 3331, 17539, 25781083, 107775231312019L] >>

Primes [was Re: find all multiplicands and multipliers for a number]

2015-04-12 Thread Steven D'Aprano
On Sun, 12 Apr 2015 05:17 pm, Marko Rauhamaa wrote: > The range(2, n) version is 3 times slower than the candidates() version. > > And in fact, the sqrt optimization now makes the original version 20% > faster: MY pyprimes module includes a series of progressively better (or, in the opposite di

Re: try..except with empty exceptions

2015-04-12 Thread Cameron Simpson
On 12Apr2015 17:00, Chris Angelico wrote: On Sun, Apr 12, 2015 at 4:33 PM, Cameron Simpson wrote: [...] That's what try/finally is for. You can do your cleanup without caring exactly what was raised. Hmm, yes. [...] However, my Asynchron class really is a little special. I use Asynchron t

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Brian Gladman
On 11/04/2015 03:04, Steven D'Aprano wrote: > It may be a bit slow for very large numbers. On my computer, this takes 20 > seconds: > > py> pyprimes.factors.factorise(2**111+1) > [3, 3, 1777, 3331, 17539, 25781083, 107775231312019L] > > > but that is the nature of factorising large numbers. >

Re: find all multiplicands and multipliers for a number

2015-04-12 Thread Marko Rauhamaa
wolfram.hinde...@googlemail.com: > I get other results on 3.2.3: > > n % 0 raises ZeroDivisionError. > After fixing that by using range(2, n) it takes about three times as > long as the original version, which is what I'd expect. You're right. I got wrong results because I ran a wrong command! T

Re: try..except with empty exceptions

2015-04-12 Thread Chris Angelico
On Sun, Apr 12, 2015 at 4:33 PM, Cameron Simpson wrote: > On 12Apr2015 09:21, Chris Angelico wrote: >> Fair enough. Do you know how often you actually catch stuff that >> wouldn't be caught by "except BaseException:"? > > > I don't know and I'm not sure I care (but discussion below). I would need