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-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-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: 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: 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/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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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-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-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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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:How to use SQLite (sqlite3) more efficiently

2014-06-05 Thread Dave Angel
R Johnson Wrote in message: > > I've attached some new sample code in which I've attempted to correct > various things that you mentioned. Attachments don't work well for many people using this list. I for one can't even see them. -- DaveA -- https://mail.python.org/mailman/listinfo/py

Re: How to use SQLite (sqlite3) more efficiently

2014-06-06 Thread Dave Angel
Chris Angelico Wrote in message: > On Sat, Jun 7, 2014 at 4:15 AM, R Johnson > wrote: >>> The subject line isn't as important as a header, carried invisibly >>> through, that says that you were replying to an existing post. :) >> >> Sorry for my ignorance, but I've never edited email headers befo

Re:How to use imported function to get current globals

2014-06-07 Thread Dave Angel
1989lzhh <1989l...@gmail.com> Wrote in message: > Here is the code > m1.py > def f(): > print globals() > > m2.py > from m1 import f > f()# how to get current module's globals? > As others have said, it's probably a bad idea. I can think of 3 reasons to try: teacher said so, writing a debu

Re:try/except/finally

2014-06-07 Thread Dave Angel
Frank B Wrote in message: > Ok; this is a bit esoteric. > > So finally is executed regardless of whether an exception occurs, so states > the docs. > > But, I thought, if I from my function first, that should take > precedence. > > au contraire > > Turns out that if you do this: > > try: >

Re:About python while statement and pop()

2014-06-11 Thread Dave Angel
hito koto Wrote in message: > Hello,all > I'm first time, > > I want to make a while statement which can function the same x.pop () and > without the use of pop、how can i to do? No idea what the question means. Are you just trying to rewrite the loop in a python implementation where pop is bro

Re: Single underscore in interactive mode

2014-06-25 Thread Dave Angel
Terry Reedy Wrote in message: > On 6/25/2014 11:20 AM, candide wrote: >> According to the official documentation (The Python Language Reference, >> Release 3.2): >> >> >> --- >> The special identifier _ is used in the interactive interpreter to >> store the result

Re:how to build web based database performance monitoring application

2014-06-27 Thread Dave Angel
sandhyaranimangip...@gmail.com Wrote in message: > Hi Gurus, > > Can you pls suggest to build a web based application to monitor sybase > database with the help of python, I am new to this. > You'll probably get better answers if you're more specific. What part of the assignment has you puzzl

Re:Writing Multiple files at a times

2014-06-29 Thread Dave Angel
subhabangal...@gmail.com Wrote in message: > Dear Group, > > I am trying to crawl multiple URLs. As they are coming I want to write them > as string, as they are coming, preferably in a queue. > > If any one of the esteemed members of the group may kindly help. > >From your subject line, it

Re:Writing files at run time

2014-06-30 Thread Dave Angel
subhabangal...@gmail.com Wrote in message: > Dear Group, > > In my previous > post["https://groups.google.com/forum/#!topic/comp.lang.python/ZYjsskV5MgE";] > I was trying to discuss some issue on file writing. > > I got an associated issue. > > I am trying to crawl a link, through urllib and

Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

2014-07-06 Thread Dave Angel
gintare Wrote in message: > The answer is on > page:https://docs.python.org/3.3/howto/unicode.html#reading-and-writing-unicode-data > > The correct code: > f=open('C:\Python33\Scripts\lang\langu\svtxt.txt','r', encoding='utf-8') > linef=f.readlines() > print(repr(linef)) > But naturally the pa

Re: open() and EOFError

2014-07-07 Thread Dave Angel
Steven D'Aprano Wrote in message: > On Mon, 07 Jul 2014 17:04:12 +1200, Gregory Ewing wrote: > >> Steven D'Aprano wrote: >>> Are there any circumstances where merely *opening* a file (before >>> reading it) can raise EOFError? >> >> I don't think so. As far as I know, the only built-in thing tha

Re:Writing Python File at Specific Interval

2014-07-09 Thread Dave Angel
subhabangal...@gmail.com Wrote in message: > > > In the next part, I am trying to store the daily > results to a new file. > > As I researched I found some tips around time module, > logging module, pythoncom etc. But not getting any important > lead. > What exactly is the problem? Perhaps y

Re:base64 convert to binary by binascii is that right?

2014-07-11 Thread Dave Angel
Frank Liou Wrote in message: > conn = engine.connect() > encoded = base64.b64encode(getbody) > binary_string = binascii.a2b_base64(encoded) > puresql = sqla.text("INSERT INTO friends(name) VALUES(:binary_string)") > conn.execute(puresql,binary_string = binary_string) > > Sta

Re:Hello. I'm new here...

2014-07-11 Thread Dave Angel
Antonio Dalvit Wrote in message: > Hello! > > Im Antonio, from Italy. I'm new here and i'd like to introduce myself: i'm > learning python language after years working in ICT sector. I decided to > study python after fortran basic, c++, java and php for fun and because i'm > tired to spend lin

Re:initializing "parameters" class in Python only once?

2014-07-14 Thread Dave Angel
Catherine M Moroney Wrote in message: > Hello, > > Pardon me for not using the proper Python language terms, but I hope > that people can still understand the question: > > The problem: I'm writing a large Python program and I have a bunch of > parameters (whose values are static) that I want

Re: What is the simplest method to get a vector result?

2014-07-24 Thread Dave Angel
fl Wrote in message: > > I am puzzled about the last part of your code and want to learn > from it (" * " " + "*" "). > 6 * " " + "x" will produce a string of 6 blanks followed by an x. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list

Re:What's the difference between gevent.sleep and time.sleep?

2014-07-27 Thread Dave Angel
Xiadong Zhu Wrote in message: > Hi, I'm learning gevent, but I didn't found the difference with gevent.sleep > and time.sleep, does anybody could give me a sample code to show their > difference? Thanks! > gevent is a cooperative analog to the threading module. When using it you would never u

Re:Python crashing when script is running against live system

2014-08-03 Thread Dave Angel
Igor Korot Wrote in message: > Hi, ALL, > I'm working on the script that should starting from the given > directory enumerate all directories and files underneath and > calculates the hash value of such file. > It works fine when I start it from some particular directory, but when > I give the "C:

Re:how to call back a method ?

2014-08-04 Thread Dave Angel
elearn Wrote in message: > I want to call back a function which is the method of a class . > > def callback(self.do,x): > return(self.do(x)) > > That is what i want to write,when i input > > def callback(self.do,x): > > error message: > > >File "", line 1 >

Re: how to write file into my android phone?

2014-08-09 Thread Dave Angel
Chris “Kwpolska” Warrick Wrote in message: > On Sat, Aug 9, 2014 at 7:56 PM, luofeiyu wrote: >> When i input usb line with my android phone into the pc , there are two >> disks j: and k: (type :removable disk) displayed in win7. >> >> i can get my android phone bluetooth mac address . >> >> impo

Re:get the min date from a list

2014-08-10 Thread Dave Angel
luofeiyu Wrote in message: > >>> date > ['Sat, 09 Aug 2014 07:36:46 -0700', 'Fri, 8 Aug 2014 22:25:40 -0400', > 'Sat, 9 Au > g 2014 12:46:43 +1000', 'Sat, 9 Aug 2014 12:50:52 +1000', 'Sat, 9 Aug > . > 2014 03:4 > 4:56 +0200', 'Sun, 10 Aug 2014 01:55:24 + (UTC)', 'Sun, 10 Aug 2014

Re:Log base 2 of large integers

2014-08-13 Thread Dave Angel
Mok-Kong Shen Wrote in message: > > I like to compute log base 2 of a fairly large integer n but > with math.log(n,2) I got: > > OverflowError: long int too large to convert to float. > > Is there any feasible work-around for that? > > Thanks in advance. > > M. K. Shen > Easiest way to get

Re:why i can't get the sourcecode with inspect module?

2014-08-20 Thread Dave Angel
luofeiyu Wrote in message: > >>> import inspect > >>> def changer(x,y): > ... return(x+y) > ... > >>> dir() > ['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__ > 'changer', 'inspect'] > >>> inspect.getsource(changer) > Traceback (most recent call last): >File "

Re:error while writing program to send mail.

2014-09-01 Thread Dave Angel
Om Prakash Wrote in message: > Hi, > > I am writing this program from > https://docs.python.org/2/library/email-examples.html > > but getting the error as > > singhom@debian:~/pythons$ python send_email.py > Traceback (most recent call last): >File "send_email.py", line 18, in > msg[

Re:My backwards logic

2014-09-05 Thread Dave Angel
Seymore4Head Wrote in message: > I'm still doing practice problems. I haven't heard from the library > on any of the books I have requested. > > http://www.practicepython.org/exercise/2014/04/16/11-check-primality-functions.html > > This is not a hard problem, but it got me to thinking a little

Re: My backwards logic

2014-09-05 Thread Dave Angel
Seymore4Head Wrote in message: > On Fri, 05 Sep 2014 12:48:56 -0400, Seymore4Head > wrote: > > > If you start with the list [3,5,7] and step through the list of all > remaining odd numbers (step 2), and start appending numbers that won't > divide by numbers already appended in the list, that w

Re:find the error

2014-09-13 Thread Dave Angel
daoudi...@gmail.com Wrote in message: > Dear friends when i used > import urllib, re, sys > > symbol = sys.argv[1] >>> this function is show -->> symbol = sys.argv[1] > IndexError: list index out of range > > kindly find the solution of this > sys.argv is filled in from the command line argum

Re:Lists

2014-09-15 Thread Dave Angel
Seymore4Head Wrote in message: > import random > nums=range(1,11) > print (nums) > samp=random.sample(nums,10) > top=nums > newlist=nums[::-1] > tail=newlist > > for x in range(10): > print ("Top {:2d}Tail {:2.0f} Sample {:2d} > ".format(top[x],tail[x],samp[x])) > > I don't understa

<    10   11   12   13   14   15   16   17   18   19   >