Re: Building CPython

2015-05-14 Thread Dave Angel
On 05/14/2015 01:02 PM, BartC wrote: On 14/05/2015 17:09, Chris Angelico wrote: On Fri, May 15, 2015 at 1:51 AM, BartC wrote: OK, the answer seems to be No then - you can't just trivially compile the C modules that comprise the sources with the nearest compiler to hand. So much for C's famous

Re: Looking for direction

2015-05-13 Thread Dave Angel
On 05/13/2015 08:45 PM, 20/20 Lab wrote:> You accidentally replied to me, rather than the mailing list. Please use reply-list, or if your mailer can't handle that, do a Reply-All, and remove the parts you don't want. > > On 05/13/2015 05:07 PM, Dave Angel wrote: >&g

Re: Looking for direction

2015-05-13 Thread Dave Angel
On 05/13/2015 07:24 PM, 20/20 Lab wrote: I'm a beginner to python. Reading here and there. Written a couple of short and simple programs to make life easier around the office. Welcome to Python, and to this mailing list. That being said, I'm not even sure what I need to ask for. I've never

Re: Python file structure

2015-05-12 Thread Dave Angel
On 05/12/2015 03:58 PM, zljubisic...@gmail.com wrote: On Tuesday, May 12, 2015 at 9:49:20 PM UTC+2, Ned Batchelder wrote: If you need to use globals, assign them inside a parse_arguments function that has a "global" statement in it. This advice is consistent with Chris' "define things before

Re: Feature Request: Reposition Execution

2015-05-11 Thread Dave Angel
On 05/11/2015 08:35 AM, Steven D'Aprano wrote: On Mon, 11 May 2015 09:57 pm, Dave Angel wrote: On 05/11/2015 07:46 AM, Skybuck Flying wrote: Hello, Sometimes it can be handy to "interrupt/reset/reposition" a running script. For example something externally goes badly wr

Re: Feature Request: Reposition Execution

2015-05-11 Thread Dave Angel
On 05/11/2015 07:46 AM, Skybuck Flying wrote: Hello, Sometimes it can be handy to "interrupt/reset/reposition" a running script. For example something externally goes badly wrong. os.kill() then in your process, handle the exception, and do whatever you think is worthwhile. -- DaveA -

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-10 Thread Dave Angel
On 05/10/2015 05:10 PM, zljubisic...@gmail.com wrote: No, we can't see what ROOTDIR is, since you read it from the config file. And you don't show us the results of those prints. You don't even show us the full exception, or even the line it fails on. Sorry I forgot. This is the output of the

Re: functions, optional parameters

2015-05-10 Thread Dave Angel
On 05/09/2015 11:33 PM, Chris Angelico wrote: On Sun, May 10, 2015 at 12:45 PM, Steven D'Aprano wrote: This is the point where some people try to suggest some sort of complicated, fragile, DWIM heuristic where the compiler tries to guess whether the user actually wants the default to use early

Re: getting fieldnames from Dictreader before reading lines

2015-05-10 Thread Dave Angel
On 05/09/2015 09:51 PM, Vincent Davis wrote: On Sat, May 9, 2015 at 5:55 PM, Dave Angel wrote: 1) you're top-posting, putting your response BEFORE the stuff you're responding to. I responded to my own email, seemed ok to top post on myself saying it was resolved. Yeah, I o

Re: getting fieldnames from Dictreader before reading lines

2015-05-09 Thread Dave Angel
On 05/09/2015 07:01 PM, Vincent Davis wrote: Not sure what I was doing wrong, it seems to work now. I still see two significant things wrong: 1) you're top-posting, putting your response BEFORE the stuff you're responding to. 2) both messages are in html, which thoroughly messed up parts

Re: Jython from bathc file?

2015-05-09 Thread Dave Angel
On 05/09/2015 05:04 PM, vjp2...@at.biostrategist.dot.dot.com wrote: Thanks.. I suspected it wasn't meant to be taken as in the file THe one thing I'm not sure if Jython is suppsosedto keep running after the initisl stuff is loaded in.. To put the question in purely DOS terms if you run a progr

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-09 Thread Dave Angel
On 05/09/2015 06:31 AM, zljubisic...@gmail.com wrote: title = title[:232] title = title.replace(" ", "_").replace("/", "_").replace("!", "_").replace("?", "_")\ .replace('"', "_").replace(':', "_").replace(',', "_").replace('"', '')\ .replace('\n', '_'

Re: calling base class method fetches no results

2015-05-09 Thread Dave Angel
On 05/09/2015 03:59 AM, david jhon wrote: Hi, I am sorry for sending in five attachments, I cloned the code from here : Let me explain it here: Please don't top-post. Your earlier problem description, which I could make no sense of, is now located af

Re: Encrypt python files

2015-05-08 Thread Dave Angel
On 05/08/2015 06:59 AM, Denis McMahon wrote: On Wed, 06 May 2015 00:23:39 -0700, Palpandi wrote: On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote: Hi, What are the ways to encrypt python files? No, I just want to hide the scripts from others. You can do that by deleting t

Re: Is this unpythonic?

2015-05-08 Thread Dave Angel
On 05/08/2015 06:53 AM, Frank Millman wrote: "Steven D'Aprano" wrote in message news:554c8b0a$0$12992$c3e8da3$54964...@news.astraweb.com... On Fri, 8 May 2015 06:01 pm, Frank Millman wrote: Hi all [...] However, every time I look at my own code, and I see "def x(y, z=[]): ." it l

Re: asyncio: What is the difference between tasks, futures, and coroutines?

2015-05-08 Thread Dave Angel
On 05/08/2015 02:42 AM, Chris Angelico wrote: On Fri, May 8, 2015 at 4:36 PM, Rustom Mody wrote: On Friday, May 8, 2015 at 10:39:38 AM UTC+5:30, Chris Angelico wrote: Why have the concept of a procedure? On Friday, Chris Angelico ALSO wrote: With print(), you have a conceptual procedure...

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-07 Thread Dave Angel
On 05/07/2015 06:24 AM, Chris Angelico wrote: On Thu, May 7, 2015 at 8:10 PM, Marko Rauhamaa wrote: Stefan Zimmermann : And last but not least, Popen behavior on Windows makes it difficult to write OS-independent Python code which calls external commands that are not binary by default: Then

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-06 Thread Dave Angel
On 05/06/2015 06:11 PM, Stefan Zimmermann wrote: Hi. I don't like that subprocess.Popen(['command']) only works on Windows if there is a command.exe in %PATH%. As a Windows user you would normally expect that also command.bat and command.cmd can be run that way. and command.com. If it'

Re: extracting zip item to in-memory

2015-05-06 Thread Dave Angel
On 05/06/2015 04:27 PM, noydb wrote: I have a zip file containing several files and I want to extract out just the .xml file. I have that code. Curious if this xml file can be extracted into memory. If so, how to? I only need to move the file around, and maybe read some tags. Thanks for a

Re: Throw the cat among the pigeons

2015-05-06 Thread Dave Angel
On 05/06/2015 11:36 AM, Alain Ketterlin wrote: Yes, plus the time for memory allocation. Since the code uses "r *= ...", space is reallocated when the result doesn't fit. The new size is probably proportional to the current (insufficient) size. This means that overall, you'll need fewer reallocat

Re: Throw the cat among the pigeons

2015-05-06 Thread Dave Angel
On 05/06/2015 09:55 AM, Chris Angelico wrote: On Wed, May 6, 2015 at 11:12 PM, Dave Angel wrote: I had guessed that the order of multiplication would make a big difference, once the product started getting bigger than the machine word size. Reason I thought that is that if you multiply

Re: Throw the cat among the pigeons

2015-05-06 Thread Dave Angel
On 05/06/2015 02:26 AM, Steven D'Aprano wrote: On Wednesday 06 May 2015 14:05, Steven D'Aprano wrote: My interpretation of this is that the difference has something to do with the cost of multiplications. Multiplying upwards seems to be more expensive than multiplying downwards, a result I nev

Re: Throw the cat among the pigeons

2015-05-05 Thread Dave Angel
On 05/05/2015 05:39 PM, Ian Kelly wrote: On Tue, May 5, 2015 at 3:23 PM, Ian Kelly wrote: On Tue, May 5, 2015 at 3:00 PM, Dave Angel wrote: def loop(func, funcname, arg): start = time.time() for i in range(repeats): func(arg, True) print("{0}({1}) took {2:7.4}&qu

Re: Throw the cat among the pigeons

2015-05-05 Thread Dave Angel
On 05/05/2015 04:30 PM, Ian Kelly wrote: On Tue, May 5, 2015 at 12:45 PM, Dave Angel wrote: When the "simple" is True, the function takes noticeably and consistently longer. For example, it might take 116 instead of 109 seconds. For the same counts, your code took 111. I can&#

Re: Stripping unencodable characters from a string

2015-05-05 Thread Dave Angel
On 05/05/2015 02:19 PM, Paul Moore wrote: You need to specify that you're using Python 3.4 (or whichever) when starting a new thread. I want to write a string to an already-open file (sys.stdout, typically). However, I *don't* want encoding errors, and the string could be arbitrary Unicode

Re: Throw the cat among the pigeons

2015-05-05 Thread Dave Angel
On 05/05/2015 12:18 PM, Cecil Westerhof wrote: Well, I did not write many tail recursive functions. But what surprised me was that for large values the ‘tail recursive’ version was more efficient as the iterative version. And that was with myself implementing the tail recursion. I expect the co

Re: Step further with filebasedMessages

2015-05-05 Thread Dave Angel
On 05/05/2015 11:25 AM, Cecil Westerhof wrote: I have a file with quotes and a file with tips. I want to place random messages from those two (without them being repeated to soon) on my Twitter page. This I do with ‘get_random_message’. I also want to put the first message of another file and r

Re: Bitten by my C/Java experience

2015-05-04 Thread Dave Angel
On 05/04/2015 04:28 PM, Cecil Westerhof wrote: Op Monday 4 May 2015 21:39 CEST schreef Ian Kelly: On Mon, May 4, 2015 at 11:59 AM, Mark Lawrence wrote: On 04/05/2015 16:20, Cecil Westerhof wrote: Potential dangerous bug introduced by programming in Python as if it was C/Java. :-( I used: ++

Re: Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Dave Angel
On 05/03/2015 05:22 AM, Cecil Westerhof wrote: Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney: Cecil Westerhof writes: When I have a value like 5.223701009526849e-05 in most cases I am not interested in all the digest after the dot. What type of value is it? If the absolute value is

Re: Custom alphabetical sort

2015-05-02 Thread Dave Angel
On 05/02/2015 11:35 AM, Pander Musubi wrote: On Monday, 24 December 2012 16:32:56 UTC+1, Pander Musubi wrote: Hi all, I would like to sort according to this order: (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', '

Re: Python is not bad ;-)

2015-05-02 Thread Dave Angel
On 05/02/2015 05:33 AM, Cecil Westerhof wrote: Please check your email settings. Your messages that you type seem to be indented properly, but those that are quoting earlier messages (even your own) are not. See below. I suspect there's some problem with how your email program processes htm

Re: Python is not bad ;-)

2015-05-02 Thread Dave Angel
On 05/02/2015 05:58 AM, Marko Rauhamaa wrote: Chris Angelico : Guido is against anything that disrupts tracebacks, and optimizing tail recursion while maintaining traceback integrity is rather harder. Tail recursion could be suppressed during debugging. Optimized code can play all kinds of no

Re: Is my implementation of happy number OK

2015-04-30 Thread Dave Angel
On 04/30/2015 07:31 PM, Jon Ribbens wrote: On 2015-04-30, Dave Angel wrote: Finally, I did some testing on Jon Ribben's version. His was substantially faster for smaller sets, and about the same for 10*7. So it's likely it'll be slower than yours and mine for 10**8. You kno

Re: Rounding a number

2015-04-30 Thread Dave Angel
On 04/30/2015 06:35 PM, Seymore4Head wrote: On Thu, 30 Apr 2015 22:00:17 +0200, Thijs Engels wrote: round(65253, -3) might be what you are looking for... On Thu, Apr 30, 2015, at 21:49, Seymore4Head wrote: I have this page book marked. https://mkaz.com/2012/10/10/python-string-format/ I a

Re: Is my implementation of happy number OK

2015-04-30 Thread Dave Angel
On 04/30/2015 04:35 PM, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 20:53 CEST schreef Dave Angel: Finally, I did some testing on Jon Ribben's version. His was substantially faster for smaller sets, and about the same for 10*7. So it's likely it'll be slower than yours and

Re: Lucky numbers in Python

2015-04-30 Thread Dave Angel
On 04/30/2015 02:55 PM, Cecil Westerhof wrote: Because I want the code to work with Python 3 also, the code is now: def lucky_numbers(n): """ Lucky numbers from 1 up-to n http://en.wikipedia.org/wiki/Lucky_number """ if n < 3: return

Re: l = range(int(1E9))

2015-04-30 Thread Dave Angel
On 04/30/2015 02:48 PM, alister wrote: On Thu, 30 Apr 2015 20:23:31 +0200, Gisle Vanem wrote: Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other pro

Re: Is my implementation of happy number OK

2015-04-30 Thread Dave Angel
On 04/30/2015 11:59 AM, Cecil Westerhof wrote: I implemented happy_number function: _happy_set = { '1' } _unhappy_set= set() def happy_number(n): """ Check if a number is a happy number https://en.wikipedia.org/wiki/Happy_number """

Re: seek operation in python

2015-04-30 Thread Dave Angel
On 04/30/2015 04:06 AM, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 09:33 CEST schreef Chris Angelico: On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof wrote: with open("input.cpp") as f: lines = f.readlines() print(lines[7]) Is the following not better: print(open('input.cpp', 'r').read

Re: Let exception fire or return None

2015-04-30 Thread Dave Angel
On 04/30/2015 03:43 AM, Cecil Westerhof wrote: I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): """ Get index message from a file, where 0 gets the first message """ return open(expanduser(message_filenam

Re: Not possible to hide local variables

2015-04-29 Thread Dave Angel
On 04/29/2015 10:16 AM, Grant Edwards wrote: On 2015-04-28, Cecil Westerhof wrote: If I remember correctly you can not hide variables of a class or make them read-only? I want to rewrite my moving average to python. The init is: def __init__(self, length): if type(length) != int:

Re: implicitly concats of adjacent strings does not work with format

2015-04-29 Thread Dave Angel
On 04/29/2015 08:42 AM, Cecil Westerhof wrote: I have the folowing print statements: print( 'Calculating fibonacci_old, fibonacci_memoize and ' 'fibonacci_memoize once for {0} '.format(large_fibonacci)) print( 'Calculating fibonacci_old, fibonacci_memoize an

Re: Panda data read_csv returns 'TextFileReader' object

2015-04-24 Thread Dave Angel
On 04/24/2015 04:04 PM, Kurt wrote: Isn't the call pd.read_csv(filepath,...) suppose to return a dataframe, not this other object? I keep getting the following error when I try to view the attribute head. AttributeError: 'TextFileReader' object has no attribute 'head' I reference pandas as pd

Re: can you help guys?

2015-04-24 Thread Dave Angel
On 04/24/2015 04:29 AM, brokolists wrote: 24 Nisan 2015 Cuma 02:20:12 UTC+3 tarihinde Steven D'Aprano yazdı: On Fri, 24 Apr 2015 01:51 am, brokolists wrote: my problem is i m working with very long float numbers and i use numberx =float(( input( 'enter the number\n '))) after i use this comman

Re: A question on the creation of list of lists

2015-04-23 Thread Dave Angel
On 04/23/2015 08:36 AM, Gregory Ewing wrote: Jean-Michel Pichavant wrote: From: "subhabrata banerji" list_of_files = glob.glob('C:\Python27\*.*') > 1/ Your file pattern search will not get files that do not have any dot in their name Actually, on Windows, it will. (This is for compatibili

Re: May I drop list bracket from list?

2015-04-23 Thread Dave Angel
On 04/23/2015 06:11 AM, subhabrata.bane...@gmail.com wrote: Dear Group, I am trying to read a list of files as list_of_files = glob.glob('C:\Python27\*.*') Now I am trying to read each one of them, convert into list of words, and append to a list as. list1=[] for file in list_of_files: p

Re: Diff between object graphs?

2015-04-22 Thread Dave Angel
On 04/22/2015 09:46 PM, Chris Angelico wrote: On Thu, Apr 23, 2015 at 11:37 AM, Dave Angel wrote: On 04/22/2015 09:30 PM, Cem Karan wrote: On Apr 22, 2015, at 8:53 AM, Peter Otten <__pete...@web.de> wrote: Another slightly more involved idea: Make the events pickleable, and sa

Re: Diff between object graphs?

2015-04-22 Thread Dave Angel
On 04/22/2015 09:30 PM, Cem Karan wrote: On Apr 22, 2015, at 8:53 AM, Peter Otten <__pete...@web.de> wrote: Another slightly more involved idea: Make the events pickleable, and save the simulator only for every 100th (for example) event. To restore the 7531th state load pickle 7500 and apply

Re: multiprocessing module and matplotlib.pyplot/PdfPages

2015-04-21 Thread Dave Angel
On 04/21/2015 07:54 PM, Dennis Lee Bieber wrote: On Tue, 21 Apr 2015 18:12:53 +0100, Paulo da Silva declaimed the following: Yes. fork will do that. I have just looked at it and it is the same as unix fork (module os). I am thinking of launching several forks that will produce .png images an

Re: multiprocessing module and matplotlib.pyplot/PdfPages

2015-04-21 Thread Dave Angel
On 04/20/2015 10:14 PM, Paulo da Silva wrote: I have program that generates about 100 relatively complex graphics and writes then to a pdf book. It takes a while! Is there any possibility of using multiprocessing to build the graphics and then use several calls to savefig(), i.e. some kind of gra

Re: Opening Multiple files at one time

2015-04-21 Thread Dave Angel
On 04/21/2015 03:56 AM, subhabrata.bane...@gmail.com wrote: Yes. They do not. They are opening one by one. I have some big chunk of data I am getting by crawling etc. now as I run the code it is fetching data. I am trying to fetch the data from various sites. The contents of the file are gettin

Re: Opening Multiple files at one time

2015-04-20 Thread Dave Angel
On 04/20/2015 07:59 AM, subhabrata.bane...@gmail.com wrote: Dear Group, I am trying to open multiple files at one time. I am trying to do it as, for item in [ "one", "two", "three" ]: f = open (item + "world.txt", "w") f.close() This is fine. But it does not open multiple

Re: Python and lotus notes

2015-04-20 Thread Dave Angel
On 04/20/2015 04:29 AM, gianluca.pu...@gmail.com wrote: Hi, Hi and welcome. I don't know Lotus Notes, but i can at least comment on some of your code, pointing out at least some problems. i am having a problem when i try to access lotus notes with python, think i do all ok but it seems so

Re: do you guys help newbies??

2015-04-19 Thread Dave Angel
On 04/19/2015 09:37 PM, josiah.l...@stu.nebo.edu wrote: On Wednesday, November 27, 2002 at 4:01:02 AM UTC-7, John Hunter wrote: "malik" == malik martin writes: malik>i'm having a simple problem i guess. but i still dont malik> know the answer. anyone see anything wrong with thi

Re: Python and fortran Interface suggestion

2015-04-19 Thread Dave Angel
On 04/19/2015 11:56 AM, pauld11718 wrote: I shall provide with further details Its about Mathematical modelling of a system. Fortran does one part and python does the other part (which I am suppose to provide). For a time interval tn --> t_n+1, fortran code generates some values, for which

Re: Best search algorithm to find condition within a range

2015-04-19 Thread Dave Angel
On 04/19/2015 09:02 AM, Steven D'Aprano wrote: On Sun, 19 Apr 2015 04:08 am, Albert van der Horst wrote: Fire up a lowlevel interpreter like Forth. (e.g. gforth) Yay! I'm not the only one who uses or likes Forth! Have you tried Factor? I'm wondering if it is worth looking at, as a more moder

Re: New to Python - block grouping (spaces)

2015-04-19 Thread Dave Angel
On 04/19/2015 07:38 AM, BartC wrote: Perhaps you don't understand what I'm getting at. Suppose there were just two syntaxes: C-like and Python-like (we'll put aside for a minute the question of what format is used to store Python source code). Why shouldn't A configure his editor to displa

Re: HELP! How to return the returned value from a threaded function

2015-04-18 Thread Dave Angel
On 04/18/2015 01:07 PM, D. Xenakis wrote: Maybe this is pretty simple but seems I am stuck... def message_function(): return "HelloWorld!" def thread_maker(): """ call message_function() using a new thread and return it's "HelloWorld!" """ pass Could someon

Re: Failed to import a "pyd: File When python intepreter embed in C++ project

2015-04-17 Thread Dave Angel
On 04/17/2015 01:17 PM, saadaouijihed1...@gmail.com wrote: I have a swig module (.pyd).I followed the steps but it doesn't work please help me. First, unplug the computer and remove the battery. Then if it's still burning, douse it with a fire extinguisher. If your symptoms are different,

Re: Converting text file to different encoding.

2015-04-17 Thread Dave Angel
On 04/17/2015 10:48 AM, Dave Angel wrote: On 04/17/2015 09:19 AM, subhabrata.bane...@gmail.com wrote: >>> target = open("target", "w") It's not usually a good idea to use the same variable for both the file name and the opened file object. What if yo

Re: Converting text file to different encoding.

2015-04-17 Thread Dave Angel
On 04/17/2015 09:19 AM, subhabrata.bane...@gmail.com wrote: I am having few files in default encoding. I wanted to change their encodings, preferably in "UTF-8", or may be from one encoding to any other encoding. You neglected to specify what Python version this is for. Other information tha

Re: ctypes: using .value or .value() doesn't work for c_long

2015-04-15 Thread Dave Angel
On 04/15/2015 03:48 PM, IronManMark20 wrote: I am using ctypes to call a few windll funcions. One of them returns a c_long object. I want to know what number the function returns. Problem is, when I try foo.value , it gives me this: AttributeError: LP_c_long object has no attribute value. Any

Re: Is there functions like the luaL_loadfile and luaL_loadbuffer in lua source to dump the lua scripts in Python's source?

2015-04-14 Thread Dave Angel
On 04/14/2015 08:07 AM, zhihao chen wrote: HI,I want to dump the python script when some application(android's app) use the python engine.they embedding python into its app. I can dump the script from an app which use the lua engine through

Re: Pickle based workflow - looking for advice

2015-04-13 Thread Dave Angel
On 04/13/2015 10:58 AM, Fabien wrote: Folks, A comment. Pickle is a method of creating persistent data, most commonly used to preserve data between runs. A database is another method. Although either one can also be used with multiprocessing, you seem to be worrying more about the mechan

Re: Excluding a few pawns from the game

2015-04-13 Thread Dave Angel
On 04/13/2015 07:30 AM, userque...@gmail.com wrote: I am writing a function in python, where the function excludes a list of pawns from the game. The condition for excluding the pawns is whether the pawn is listed in the database DBPawnBoardChart. Here is my code: def _bring_bigchart_pa

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

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 b

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

Re: try..except with empty exceptions

2015-04-11 Thread Dave Angel
On 04/11/2015 06:14 AM, Dave Angel wrote: On 04/11/2015 03:11 AM, Steven D'Aprano wrote: On Sat, 11 Apr 2015 12:23 pm, Dave Angel wrote: On 04/10/2015 09:42 PM, Steven D'Aprano wrote: On Sat, 11 Apr 2015 05:31 am, sohcahto...@gmail.com wrote: It isn't document because it is

Re: try..except with empty exceptions

2015-04-11 Thread Dave Angel
On 04/11/2015 03:11 AM, Steven D'Aprano wrote: On Sat, 11 Apr 2015 12:23 pm, Dave Angel wrote: On 04/10/2015 09:42 PM, Steven D'Aprano wrote: On Sat, 11 Apr 2015 05:31 am, sohcahto...@gmail.com wrote: It isn't document because it is expected. Why would the exception get c

Re: try..except with empty exceptions

2015-04-10 Thread Dave Angel
On 04/10/2015 10:38 PM, Rustom Mody wrote: On Saturday, April 11, 2015 at 7:53:31 AM UTC+5:30, Dave Angel wrote: On 04/10/2015 09:42 PM, Steven D'Aprano wrote: On Sat, 11 Apr 2015 05:31 am, sohcahtoa82 wrote: It isn't document because it is expected. Why would the exception get

Re: try..except with empty exceptions

2015-04-10 Thread Dave Angel
On 04/10/2015 09:42 PM, Steven D'Aprano wrote: On Sat, 11 Apr 2015 05:31 am, sohcahto...@gmail.com wrote: It isn't document because it is expected. Why would the exception get caught if you're not writing code to catch it? If you write a function and pass it a tuple of exceptions to catch, I'

Re: find all multiplicands and multipliers for a number

2015-04-10 Thread Dave Angel
On 04/10/2015 09:06 PM, Dave Angel wrote: On 04/10/2015 07:37 PM, ravas wrote: def m_and_m(dividend): rlist = [] dm = divmod end = (dividend // 2) + 1 for divisor in range(1, end): q, r = dm(dividend, divisor) if r is 0: rlist.append((divisor

Re: find all multiplicands and multipliers for a number

2015-04-10 Thread Dave Angel
On 04/10/2015 07:37 PM, ravas wrote: def m_and_m(dividend): rlist = [] dm = divmod end = (dividend // 2) + 1 for divisor in range(1, end): q, r = dm(dividend, divisor) if r is 0: rlist.append((divisor, q)) return rlist print(m_and_m(999)) -

Re: try..except with empty exceptions

2015-04-10 Thread Dave Angel
On 04/10/2015 04:48 AM, Pavel S wrote: Hi, I noticed interesting behaviour. Since I don't have python3 installation here, I tested that on Python 2.7. Well known feature is that try..except block can catch multiple exceptions listed in a tuple: exceptions = ( TypeError, ValueError ) try:

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Dave Angel
On 04/09/2015 08:56 AM, Alain Ketterlin wrote: Marko Rauhamaa writes: Alain Ketterlin : No, it would not work for signed integers (i.e., with lo and hi of int64_t type), because overflow is undefined behavior for signed. All architectures I've ever had dealings with have used 2's-complemen

Re: python implementation of a new integer encoding algorithm.

2015-04-09 Thread Dave Angel
On 04/09/2015 05:33 AM, janhein.vanderb...@gmail.com wrote: Op donderdag 19 februari 2015 19:25:14 UTC+1 schreef Dave Angel: I wrote the following pair of functions: Here's a couple of ranges of output, showing that the 7bit scheme does better for values between 384 and 16379. T

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Dave Angel
On 04/07/2015 06:35 PM, jonas.thornv...@gmail.com wrote: Den tisdag 7 april 2015 kl. 21:27:20 UTC+2 skrev Ben Bacarisse: Ian Kelly writes: On Tue, Apr 7, 2015 at 12:55 PM, Terry Reedy wrote: On 4/7/2015 1:44 PM, Ian Kelly wrote: def to_base(number, base): ... digits = [] ... whi

Re: Euler module under python 2.7 and 3.4 instalation...

2015-04-07 Thread Dave Angel
On 04/07/2015 11:39 AM, blue wrote: Dear friends . I want to install Euler module under python 2.7 and / or 3.4 version. I try pip and pip 3.4 but seam not working for me. I need some help with this . Thank you . Regards. You don't specify what you mean by Euler. There are at least 3 things

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Dave Angel
On 04/07/2015 11:40 AM, jonas.thornv...@gmail.com wrote: Den tisdag 7 april 2015 kl. 16:32:56 UTC+2 skrev Ian: On Tue, Apr 7, 2015 at 3:44 AM, wrote: I want todo faster baseconversion for very big bases like base 1 000 000, so instead of adding up digits i search it. I need the fastest al

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Dave Angel
On 04/07/2015 11:05 AM, Grant Edwards wrote: On 2015-04-07, Chris Angelico wrote: On Wed, Apr 8, 2015 at 12:36 AM, wrote: Integers are internally assumed to be base 10 otherwise you could not calculate without giving the base. All operations on integers addition, subtraction, multiplicatio

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Dave Angel
On 04/07/2015 10:36 AM, jonas.thornv...@gmail.com wrote: All operations on integers addition, subtraction, multiplication and division assume base 10. There have been machines where that was true, but I haven't worked on such for about 30 years. On any machines I've programmed lately, the

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Dave Angel
On 04/07/2015 10:10 AM, jonas.thornv...@gmail.com wrote: Den tisdag 7 april 2015 kl. 15:30:36 UTC+2 skrev Dave Angel: If that code were in Python, I could be more motivated to critique it. The whole algorithm could be much simpler. But perhaps there is some limitation of javascript

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Dave Angel
On 04/07/2015 05:44 AM, jonas.thornv...@gmail.com wrote: I want todo faster baseconversion for very big bases like base 1 000 000, so instead of adding up digits i search it. For this and most of the following statements: I can almost guess what you're trying to say. However, I cannot. N

Re: Permission denied when opening a file that was created concurrently by os.rename (Windows)

2015-04-05 Thread Dave Angel
On 04/05/2015 01:45 PM, Alexey Izbyshev wrote: Hello! I've hit a strange problem that I reduced to the following test case: * Run several python processes in parallel that spin in the following loop: while True: if os.path.isfile(fname): with open(fname, 'rb') as f: f.read()

Re: Strategy/ Advice for How to Best Attack this Problem?

2015-04-03 Thread Dave Angel
On 04/03/2015 08:50 AM, Saran A wrote: On Friday, April 3, 2015 at 8:05:14 AM UTC-4, Dave Angel wrote: On 04/02/2015 07:43 PM, Saran A wrote: I addressed most of the issues. I do admit that, as a novice, I feel beholden to the computer - hence the over-engineering. Should be quite the

Re: New to Programming: Adding custom functions with ipynotify classes

2015-04-03 Thread Dave Angel
On 04/03/2015 07:37 AM, Steven D'Aprano wrote: On Fri, 3 Apr 2015 12:30 pm, Saran A wrote: #This helper function returns the length of the file def file_len(f): with open(f) as f: for i, l in enumerate(f): pass return i + 1 Not as given it doesn't. It w

Re: Strategy/ Advice for How to Best Attack this Problem?

2015-04-03 Thread Dave Angel
On 04/02/2015 07:43 PM, Saran A wrote: I debugged and rewrote everything. Here is the full version. Feel free to tear this apart. The homework assignment is not due until tomorrow, so I am currently also experimenting with pyinotify as well. I do have questions regarding how to make this

Re: Strategy/ Advice for How to Best Attack this Problem?

2015-04-02 Thread Dave Angel
On 04/02/2015 09:06 AM, Saran A wrote: Thanks for your help on this homework assignment. I started from scratch last night. I have added some comments that will perhaps help clarify my intentions and my thought process. Thanks again. from __future__ import print_function I'll just randomly

Re: Strategy/ Advice for How to Best Attack this Problem?

2015-04-01 Thread Dave Angel
On 04/01/2015 09:43 AM, Saran A wrote: On Tuesday, March 31, 2015 at 9:19:37 AM UTC-4, Dave Angel wrote: On 03/31/2015 07:00 AM, Saran A wrote: > @DaveA: This is a homework assignment. Is it possible that you could provide me with some snippets or guidance on where to place y

Re: generator/coroutine terminology

2015-03-31 Thread Dave Angel
On 03/31/2015 09:18 AM, Albert van der Horst wrote: In article <55062bda$0$12998$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: The biggest difference is syntactic. Here's an iterator which returns a never-ending sequence of squared numbers 1, 4, 9, 16, ... class Squares:

Re: Strategy/ Advice for How to Best Attack this Problem?

2015-03-31 Thread Dave Angel
On 03/31/2015 07:00 AM, Saran A wrote: > @DaveA: This is a homework assignment. Is it possible that you could provide me with some snippets or guidance on where to place your suggestions (for your TO DOs 2,3,4,5)? > On Monday, March 30, 2015 at 2:36:02 PM UTC-4, Dave Angel

Re: Strategy/ Advice for How to Best Attack this Problem?

2015-03-30 Thread Dave Angel
On 03/30/2015 12:45 PM, Saran A wrote: On Sunday, March 29, 2015 at 10:04:45 PM UTC-4, Chris Angelico wrote: On Mon, Mar 30, 2015 at 12:08 PM, Paul Rubin wrote: Saran Ahluwalia writes: cross-platform... * Monitors a folder for files that are dropped throughout the day I don't see a cross-p

Re: Sudoku solver

2015-03-30 Thread Dave Angel
On 03/30/2015 03:29 AM, Ian Kelly wrote: On Mon, Mar 30, 2015 at 1:13 AM, Christian Gollwitzer wrote: Am 30.03.15 um 08:50 schrieb Ian Kelly: On Sun, Mar 29, 2015 at 12:03 PM, Marko Rauhamaa wrote: Be careful with the benchmark comparisons. Ian's example can be solved with the identical al

Re: Addendum to Strategy/ Advice for How to Best Attack this Problem?

2015-03-29 Thread Dave Angel
On 03/29/2015 07:37 AM, Saran Ahluwalia wrote: On Sunday, March 29, 2015 at 7:33:04 AM UTC-4, Saran Ahluwalia wrote: Below are the function's requirements. I am torn between using the OS module or some other quick and dirty module. In addition, my ideal assumption that this could be cross-plat

Re: Sudoku solver

2015-03-27 Thread Dave Angel
On 03/27/2015 09:56 AM, Marko Rauhamaa wrote: "Frank Millman" : So what I am talking about is called a "satisfactory" puzzle, which is a subset of a "proper" puzzle. That is impossible to define, though, because some people are mental acrobats and can do a lot of deep analysis in their heads.

Re: Sudoku solver

2015-03-27 Thread Dave Angel
On 03/27/2015 09:35 AM, Frank Millman wrote: "Dave Angel" wrote in message news:551557b3.5090...@davea.name... But now I have to disagree about "true Sudoku puzzle." As we said earlier, it might make sense to say that puzzles that cannot be solved that way are not reaso

Re: Sudoku solver

2015-03-27 Thread Dave Angel
On 03/27/2015 09:25 AM, Chris Angelico wrote: On Sat, Mar 28, 2015 at 12:14 AM, Dave Angel wrote: But now I have to disagree about "true Sudoku puzzle." As we said earlier, it might make sense to say that puzzles that cannot be solved that way are not reasonable ones to put in a hu

Re: Sudoku solver

2015-03-27 Thread Dave Angel
On 03/27/2015 05:25 AM, Chris Angelico wrote: On Fri, Mar 27, 2015 at 8:07 PM, Frank Millman wrote: There seems to be disagreement over the use of the term 'trial and error'. How about this for a revised wording - "It should be possible to reach that solution by a sequence of logical deduction

  1   2   3   4   5   6   7   8   9   10   >