Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 05:31 PM, Carsten Lechte wrote: On 23/03/15 19:44, Dave Angel wrote: I'll give you a worse version. Back in the day I had occasion to write a simple program in a language which had no add or subtract. It could only increment and decrement indices. Oh yes, the olden days. I

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 07:49 PM, Chris Angelico wrote: On Tue, Mar 24, 2015 at 10:12 AM, Dave Angel da...@davea.name wrote: On the other hand, my loop makes some non-obvious assumptions, like that append is always the right place to put a new value. Yes, I had to stop and think about that one a bit

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 06:53 PM, Terry Reedy wrote: On 3/23/2015 2:44 PM, Dave Angel wrote: ## Example 2: Using recursion with caching cache = [0, 1] def fib4(n): if len(cache) = n: value = fib4(n-2) + fib4(n-1) cache.append(value) return cache[n] This one takes less than

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 08:19 PM, Steven D'Aprano wrote: On Tue, 24 Mar 2015 03:16 am, Chris Angelico wrote about the standard recursive version of the Fibonacci series: On Tue, Mar 24, 2015 at 3:01 AM, Ganesh Pal ganesh1...@gmail.com wrote: def fib(n): if n == 0: return 0 elif n

Re: Python+Glade+Gtk tutorial?

2015-03-17 Thread Dave Farrance
Jason Heeris jason.hee...@gmail.com wrote: In terms of toolkit bindings, (a) I prefer GTK, but (b) it's impossible to tell what the greater proportion of people using one vs. the other is. Or if they're wise to do so. Are there more Google hits/SO questions because it's harder to use? Or because

Python+Glade+Gtk tutorial?

2015-03-16 Thread Dave Farrance
In the past, I've used Visual-C++ for creating dialog-based interfaces for controlling equipment and displaying data, and I'm looking for something of similar ease-of-use in Python since that's now my preferred language. A web-search told me that Glade seems to be most peoples choice (over

Re: More or less code in python?

2015-03-16 Thread Dave Angel
On 03/15/2015 03:09 PM, jonas.thornv...@gmail.com wrote: Den söndag 15 mars 2015 kl. 20:01:36 UTC+1 skrev Paul Rubin: jonas.thornv...@gmail.com writes: I though it would be interesting doing comparissons in timing adding massive digits in different bases. Especially in Python. Python has

Re: More or less code in python?

2015-03-16 Thread Dave Angel
On 03/16/2015 03:36 AM, Chris Angelico wrote: On Mon, Mar 16, 2015 at 6:32 PM, Dave Angel da...@davea.name wrote: Assuming Python 3.x of course. if you're in Python 2, you'd use long rather than int. Not sure you need to bother. Even in Py2, you can use the int constructor to get a long

Re: PSF news - BBC launches MicroBit

2015-03-15 Thread Dave Farrance
Mark Lawrence breamore...@yahoo.co.uk wrote: http://pyfound.blogspot.co.uk/2015/03/bbc-launches-microbit.html may be of interest to some of you. Python is one of the three languages that work with the device. That's cool, and the article says that the Raspberry Pi Foundation is involved in

Re: The idle gui

2015-03-14 Thread Dave Angel
On 03/14/2015 05:57 AM, Chris Angelico wrote: On Sat, Mar 14, 2015 at 12:35 PM, Dave Angel da...@davea.name wrote: Not if you don't take it to him. If you just call him on the phone, and say Jimmy doesn't work he doesn't even know what make and model the vehicle is. Or whether it's even a car

Re: The idle gui

2015-03-14 Thread Dave Angel
On 03/13/2015 09:24 PM, Steven D'Aprano wrote: sohcahto...@gmail.com wrote: We need more information than just It doesn't work. You wouldn't go to a car mechanic and say It makes a funny noise, would you? No. Actually, most likely yes.It's remarkably hard to describe noises, and often

Re: Module/lib for controlling a terminal program using redrawing?

2015-03-14 Thread Dave Angel
On 03/14/2015 06:50 AM, Jason Heeris wrote: I am trying to automate the use of some old, in-house terminal-based programs that use screen redrawing for their interface. This includes single line redrawing (eg. using '\r' and overwriting), complete screen clearing, and fine-grained cursor

Re: generator/coroutine terminology

2015-03-14 Thread Dave Angel
On 03/14/2015 12:51 PM, Chris Angelico wrote: On Sun, Mar 15, 2015 at 3:33 AM, Rustom Mody rustompm...@gmail.com wrote: As best as I can see python makes no distinction between such a foo and the more usual function/methods that have no returns. You can I can talk about these and distinguish

Re: when may sys.executable be empty

2015-03-11 Thread Dave Angel
On 03/11/2015 10:41 AM, Wolfgang Maier wrote: From the documentation of sys.executable: A string giving the absolute path of the executable binary for the Python interpreter, on systems where this makes sense. If Python is unable to retrieve the real path to its executable, sys.executable

Re: Idle - ImportError: No module named numpy

2015-03-09 Thread Dave Angel
On 03/07/2015 02:15 PM, Markos wrote: Hi, I'm beginning to study the numpy. When I open a terminal (Debian Squeeze) and run the python interpreter the command import numpy as np run without errors. But when I run the same command on idle3 the following error appears. import numpy as np

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Dave Angel
On 03/09/2015 08:56 PM, Chris Angelico wrote: On Tue, Mar 10, 2015 at 11:45 AM, Paulo da Silva p_s_d_a_s_i_l_v_a...@netcabo.pt wrote: Hi! What is the best way to read a file that begins with some few text lines and whose rest is a binary stream? As an exmaple ... files .pnm. Thanks for any

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Dave Angel
On 03/09/2015 08:45 PM, Paulo da Silva wrote: Hi! What is the best way to read a file that begins with some few text lines and whose rest is a binary stream? As an exmaple ... files .pnm. Thanks for any comments/help on this. In which version of Python? there's a huge difference between

Re: Speeding up permutations generation

2015-03-06 Thread Dave Angel
On 03/06/2015 11:14 AM, Gene Heskett wrote: On Friday 06 March 2015 06:22:34 Dave Angel wrote: Sorry, but 50! is not even close to 50**50. The latter is 85 digits as you say, but 50! is only 64. 30414093201713378043612608166064768844377641568960512L What utility output

Re: Speeding up permutations generation

2015-03-06 Thread Dave Angel
On 03/06/2015 05:32 AM, Gene Heskett wrote: On Friday 06 March 2015 03:24:48 Abhiram R wrote: A list of 100 elements has approximately 9.33 x 10**157 permutations. If you could somehow generate one permutation every yoctosecond, exhausting them would still take more than a hundred orders of

Re: Speeding up permutations generation

2015-03-06 Thread Dave Angel
On 03/06/2015 01:44 AM, Abhiram R wrote: Hi all, Is there a way to generate permutations of large arrays of sizes say,in the hundreds, faster than in the time itertools.permutations() can return? When dealing with large loops like that (or even permutations of 50, which is also gy-normous

Re: Do not run this code.

2015-03-04 Thread Dave Farrance
Ben Finney ben+pyt...@benfinney.id.au wrote: Chris Angelico ros...@gmail.com writes: import base64; exec(…) That's all I need to know. Code with ‘exec()’ calls, I consider unsafe by default. Indeed. replacing exec with print...

Re: rst and pypandoc

2015-03-03 Thread Dave Angel
On 03/02/2015 02:09 PM, Ben Finney wrote: Dave Angel da...@davea.name writes: And D'oh right back at ya. Ironic isn't it that I make a second mistake in the same message I correct yours? URL:https://en.wikipedia.org/wiki/Muphry%27s_law I guess that word is too small to qualify

Re: date

2015-03-03 Thread Dave Angel
On 03/02/2015 11:25 AM, Chris Angelico wrote: On Tue, Mar 3, 2015 at 3:09 AM, alister alister.nospam.w...@ntlworld.com wrote: Sounds ominous. Is that better or worse than the final solution? As in this program will inadvertantly self distruct in five seconds? It's usually implied as being

Re: rst and pypandoc

2015-03-02 Thread Dave Angel
On 03/02/2015 05:40 PM, alb wrote: Hi Dave, Dave Angel da...@davea.name wrote: [] or use a raw string: i = r'\\ref{fig:abc}' Actually that'd be: i = r'\ref{fig:abc}' Could you explain why I then see the following difference: In [56]: inp = r'\\ref{fig:abc}' print inp and you

Re: rst and pypandoc

2015-03-02 Thread Dave Angel
On 03/02/2015 08:51 AM, alb wrote: Hi Steven, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: [] Since \r is an escape character, that will give you carriage return followed by ef{fig:abc. The solution to that is to either escape the backslash: i = '\\ref{fig:abc}' or use a raw

Re: rst and pypandoc

2015-03-02 Thread Dave Angel
On 03/02/2015 02:59 AM, alb wrote: Hi everyone, I'm writing a document in restructured text and I'd like to convert it to latex for printing. To accomplish this I've used semi-successfully pandoc and the wrapper pypandoc. I don't see other responses yet, so I'll respond even though i don't

Re: Python27.dll could not be found

2015-03-02 Thread Dave Angel
On 03/02/2015 01:00 AM, Sarvagya Pant wrote: I have been writing a c++ program that is supposed to call the python function. The code is a snippet from python.org itself. #include Python.h #include iostream #include string int main() { Py_SetProgramName(Learning); Py_Initialize();

Re: Python Worst Practices

2015-03-02 Thread Dave Angel
On 03/02/2015 07:38 AM, MRAB wrote: On 2015-03-02 04:49, Dave Angel wrote: On 03/01/2015 08:59 PM, MRAB wrote: On 2015-03-02 01:37, Dennis Lee Bieber wrote The 16 bit address bus permitted addressing of 64k words. On most processors, that was 64k bytes, though I know one Harris had

Re: rst and pypandoc

2015-03-02 Thread Dave Angel
On 03/02/2015 09:43 AM, Steven D'Aprano wrote: Dave Angel wrote: On 03/02/2015 08:51 AM, alb wrote: Hi Steven, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: or use a raw string: i = r'\\ref{fig:abc}' Actually that'd be: i = r'\ref{fig:abc}' D'oh! I mean, you

Re: Sort list of dictionaries

2015-03-02 Thread Dave Angel
On 03/02/2015 01:38 PM, Charles Heizer wrote: Sorry, sortedlist = sorted(mylist , key=lambda elem: %s %s % (elem['name'], LooseVersion(elem['version'])), reverse=True) This is what I was trying but LooseVersion() was not sorting version numbers like I thought it would. You will notice that

Re: Python27.dll could not be found

2015-03-02 Thread Dave Angel
I INTENDED to send it to the list, but made the same mistake myself. Forwarded Message Subject: Re: Python27.dll could not be found Date: Mon, 02 Mar 2015 08:51:07 -0500 From: Dave Angel da...@davea.name To: Sarvagya Pant sarvagya.p...@gmail.com Sarvaqya accidentally sent me

Re: Python27.dll could not be found

2015-03-02 Thread Dave Angel
On 03/02/2015 02:22 PM, Gisle Vanem wrote: Dave Angel wrote: When I ran Windows, I had written a simple utility that searched the PATH for a specified file. I called it which.bat to match the Linux equivalent. I've written a similar tool; envtool --path --python python27.dll Matches

Re: Python Worst Practices

2015-03-01 Thread Dave Angel
On 03/01/2015 08:59 PM, MRAB wrote: On 2015-03-02 01:37, Dennis Lee Bieber wrote You'd be able to run it on a TI99/4 (in which the BASIC interpreter, itself, was run on an interpreter... nothing like taking the first 16-bit home computer and shackling it with an interpreted language that

Re: Newbie question about text encoding

2015-02-27 Thread Dave Angel
On 02/27/2015 06:54 AM, Steven D'Aprano wrote: Dave Angel wrote: On 02/27/2015 12:58 AM, Steven D'Aprano wrote: Dave Angel wrote: (Although I believe Seymour Cray was quoted as saying that virtual memory is a crock, because you can't fake what you ain't got.) If I recall correctly, disk

Re: Newbie question about text encoding

2015-02-27 Thread Dave Angel
On 02/27/2015 09:22 AM, Chris Angelico wrote: On Sat, Feb 28, 2015 at 1:02 AM, Dave Angel da...@davea.name wrote: The term virtual memory is used for many aspects of the modern memory architecture. But I presume you're using it in the sense of running in a swapfile as opposed to running

Re: Newbie question about text encoding

2015-02-27 Thread Dave Angel
On 02/27/2015 11:00 AM, alister wrote: On Sat, 28 Feb 2015 01:22:15 +1100, Chris Angelico wrote: If you're trying to use the pagefile/swapfile as if it's more memory (I have 256MB of memory, but 10GB of swap space, so that's 10GB of memory!), then yes, these performance considerations are

Re: Python Worst Practices

2015-02-27 Thread Dave Angel
On 02/27/2015 04:21 PM, Travis Griggs wrote: On Feb 25, 2015, at 12:45 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: http://www.slideshare.net/pydanny/python-worst-practices Any that should be added to this list? Any that be removed as not that bad? I read ‘em. I thought they were

Re: Python Worst Practices

2015-02-27 Thread Dave Angel
On 02/27/2015 04:40 PM, Chris Angelico wrote: On Sat, Feb 28, 2015 at 8:37 AM, Dave Angel da...@davea.name wrote: Right. In C and C++, instead of being the first slide, it'd be the first 3 or 4. Between header file conflicts (especially good because the stdlib itself has many multiply-defined

Re: Picking apart a text line

2015-02-26 Thread Dave Angel
On 02/26/2015 10:53 PM, memilanuk wrote: So... okay. I've got a bunch of PDFs of tournament reports that I want to sift thru for information. Ended up using 'pdftotext -layout file.pdf file.txt' to extract the text from the PDF. Still have a few little glitches to iron out there, but I'm

Re: Newbie question about text encoding

2015-02-26 Thread Dave Angel
On 02/27/2015 12:58 AM, Steven D'Aprano wrote: Dave Angel wrote: (Although I believe Seymour Cray was quoted as saying that virtual memory is a crock, because you can't fake what you ain't got.) If I recall correctly, disk access is about 1 times slower than RAM, so virtual memory

Re: Newbie question about text encoding

2015-02-26 Thread Dave Angel
On 02/26/2015 08:05 PM, Steven D'Aprano wrote: Rustom Mody wrote: eg consider the case of 32 vs 64 bit executables. The 64 bit executable is generally larger than the 32 bit one Now consider the case of a machine that has say 2GB RAM and a 64-bit processor. You could -- I think -- make a

Re: Python Worst Practices

2015-02-25 Thread Dave Angel
On 02/25/2015 08:44 PM, Mark Lawrence wrote: On 25/02/2015 20:45, Mark Lawrence wrote: http://www.slideshare.net/pydanny/python-worst-practices Any that should be added to this list? Any that be removed as not that bad? Throwing in my own, how about built-in functions should not use object

[issue6818] remove/delete method for zipfile/tarfile objects

2015-02-25 Thread Dave Sawyer
Dave Sawyer added the comment: I'd be interested in taking up the zip portion at Pycon 2015 this year. I recently had need to delete file(s) from a zipfile. To do it today with the existing API requires you to unpack the zip and repack it. The unpack is slow and you need enough free disk

Re: Newbie question about text encoding

2015-02-24 Thread Dave Angel
On 02/24/2015 02:57 PM, Laura Creighton wrote: Dave Angel are you another Native English speaker living in a world where ASCII is enough? I'm a native English speaker, and 7 bits is not nearly enough. Even if I didn't currently care, I have some history: No. CDC display code is enough

Re: Newbie question about text encoding

2015-02-24 Thread Dave Angel
On 02/24/2015 05:49 AM, pierrick.brih...@gmail.com wrote: Hello, Working with pyshp, this is my code : What version of Python, what version of pyshp, from where, and what OS? These are the first information to supply in any query that goes outside of the standard library. For example,

Re: Newbie question about text encoding

2015-02-24 Thread Dave Angel
On 02/24/2015 11:20 AM, Laura Creighton wrote: In a message of Wed, 25 Feb 2015 02:33:30 +1100, Chris Angelico writes: Also a reasonable baseline assumption; but the trouble is that if you automatically assume that text is encoded in your favourite eight-bit system, you're taking a huge risk.

Re: Bug in timsort!?

2015-02-24 Thread Dave Angel
On 02/24/2015 07:07 PM, Chris Angelico wrote: On Wed, Feb 25, 2015 at 10:50 AM, Skip Montanaro skip.montan...@gmail.com wrote: Even if/when we get to the point where machines can hold an array of 2**49 elements, I suspect people won't be using straight Python to wrangle them. Looking just at

Re: Future of Pypy?

2015-02-23 Thread Dave Cook
On 2015-02-22, Dave Farrance davefarra...@omitthisyahooandthis.co.uk wrote: It's still quicker to do a re-write in the more cumbersome C You should try Cython. Dave -- https://mail.python.org/mailman/listinfo/python-list

Re: Future of Pypy?

2015-02-23 Thread Dave Farrance
Dave Cook davec...@nowhere.net wrote: On 2015-02-22, Dave Farrance davefarra...@omitthisyahooandthis.co.uk wrote: It's still quicker to do a re-write in the more cumbersome C You should try Cython. I did try Cython when I was trying to figure out what to do about the slow speed. My initial

Re: list storing variables

2015-02-23 Thread Dave Angel
On 02/23/2015 07:55 AM, ast wrote: hi a = 2; b = 5 Li = [a, b] Li [2, 5] a=3 Li [2, 5] Ok, a change in a or b doesn't impact Li. This works as expected Is there a way to define a container object able to store some variables so that a change of a variable make a change in this object

Re: Future of Pypy?

2015-02-23 Thread Dave Farrance
Laura Creighton l...@openend.se wrote: Good news -- it seems to be working fine with PyPy. https://travis-ci.org/hugovk/Pillow/builds for me, not extensively tested, it just seems to be working. I have several pypy's floating around here, each within its own virtualenv. If you aren't familiar

Future of Pypy?

2015-02-22 Thread Dave Farrance
As an engineer, I can quickly knock together behavioural models of electronic circuits, complete units, and control systems in Python, then annoyingly in a few recent cases, have to re-write in C for speed. I've tried PyPy, the just-in-time compiler for Python, and that is impressively, hugely

Re: Future of Pypy?

2015-02-22 Thread Dave Farrance
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I assume you're talking about drawing graphics rather than writing text. Can you tell us which specific library or libraries won't run under PyPy? Yes, mainly the graphics. I'm a hardware engineer, not a software engineer, so I might

Re: Future of Pypy?

2015-02-22 Thread Dave Farrance
jkn jkn...@nicorp.f9.co.uk wrote: I'm curious what ...behavioural... models you are creating quickly in Python that then need rewriting in C for speed. SPICE? some other CAD? Might be interesting to learn more about what and how you are actually doing. The convert-to-C cases were complex

Re: Future of Pypy?

2015-02-22 Thread Dave Farrance
Dave Farrance davefarra...@omitthisyahooandthis.co.uk wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I assume you're talking about drawing graphics rather than writing text. Can you tell us which specific library or libraries won't run under PyPy? Yes, mainly the graphics

Re: Future of Pypy?

2015-02-22 Thread Dave Farrance
Laura Creighton l...@openend.se wrote: I don't understand 'an interpreter rather than a JIT'. PyPy has a JIT, that sort of is the whole point. Yes. I meant that from my end-user, non-software-engineer perspective, it looked as though CPython was proceeding with leaps and bounds and that PyPy

Re: Unrecognized backslash escapes in string literals

2015-02-22 Thread Dave Angel
On 02/22/2015 09:29 PM, Chris Angelico wrote: In Python, unrecognized escape sequences are treated literally, without (as far as I can tell) any sort of warning or anything. This can mask bugs, especially when Windows path names are used: 'C:\sqlite\Beginner.db' 'C:\\sqlite\\Beginner.db'

Re: Unrecognized backslash escapes in string literals

2015-02-22 Thread Dave Angel
On 02/22/2015 09:41 PM, Ben Finney wrote: Chris Angelico ros...@gmail.com writes: In Python, unrecognized escape sequences are treated literally, without (as far as I can tell) any sort of warning or anything. Right. Text strings literals are documented to work that way

Re: calling subprocess

2015-02-22 Thread Dave Angel
On 02/22/2015 09:38 PM, Dave Angel wrote: On 02/22/2015 08:13 PM, jkuplin...@gmail.com wrote: OK (1) sorry about for/from That's not what you should be sorry about. You should be sorry you didn't use cutpaste. (2) print() sounds nice, but fact is , no matter what I try, i always get C

Re: calling subprocess

2015-02-22 Thread Dave Angel
On 02/22/2015 08:13 PM, jkuplin...@gmail.com wrote: OK (1) sorry about for/from That's not what you should be sorry about. You should be sorry you didn't use cutpaste. (2) print() sounds nice, but fact is , no matter what I try, i always get C:\\apps instead of c:\apps. So in this sense

Re: Python path on windows

2015-02-21 Thread Dave Angel
On 02/21/2015 06:05 AM, Gisle Vanem wrote: Dave Angel wrote: Finally, when py.exe starts, it reads that first (shebang) line, and decides which python interpreter to actually use. py.exe? Do you mean python.exe? Reread my post, or read Mark's reply to yours. The job of py.exe or pyw.exe

Re: Best practice: Sharing object between different objects

2015-02-21 Thread Dave Angel
On 02/21/2015 07:15 AM, pfranke...@gmail.com wrote: Hello! I have a best-practice question: Imagine I have several hardware devices that I work with on the same I2C bus and I am using the python smbus module for that purpose. The individual devices are sensors, ADC, DAC components. As I said,

Re: Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-21 Thread Dave Angel
On 02/21/2015 02:46 PM, TommyVee wrote: Start off with sets of elements as follows: 1. A,B,E,F 2. G,H,L,P,Q 3. C,D,E,F 4. E,X,Z 5. L,M,R 6. O,M,Y Note that sets 1, 3 and 4 all have the element 'E' in common, therefore they are related and form the following superset: A,B,C,D,E,F,X,Z

Re: What behavior would you expect?

2015-02-20 Thread Dave Angel
On 02/20/2015 12:51 AM, Jason Friedman wrote: I'd still advise using my_list.sort() rather than sorted(), as you don't need to retain the original. Hmm. Trying to figure out what that looks like. If I understand correctly, list.sort() returns None. What would I return to the caller?

Re: Python path on windows

2015-02-20 Thread Dave Angel
On 02/20/2015 09:43 AM, loial wrote: On Linux we use #!/usr/bin/env python At the start of scripts to ensure that the python executable used is the one defined in the PATH variable, rather than hardcoding a path to the python executable. What is the equivalent functionality in Windows?

Re: urgent help

2015-02-20 Thread Dave Angel
On 02/20/2015 07:20 PM, ms.isma...@gmail.com wrote: On Saturday, February 21, 2015 at 8:17:06 AM UTC+8, ms.is...@gmail.com wrote: On Saturday, February 21, 2015 at 8:14:43 AM UTC+8, ms.is...@gmail.com wrote: On Friday, February 20, 2015 at 4:41:57 PM UTC+8, Mark Lawrence wrote: On 20/02/2015

Re: urgent help

2015-02-19 Thread Dave Angel
On 02/19/2015 03:35 AM, ismaham...@gcuf.edu.pk wrote: this is the error in the following python code, can any one help me error{Traceback (most recent call last): File C:\Python27\Scripts\BeOk\getBeOKExperts.py, line 6, in module from BeautifulSoup import BeautifulSoup ImportError: No

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Dave Angel
On 02/19/2015 10:45 AM, janhein.vanderb...@gmail.com wrote: On Wednesday, February 18, 2015 at 11:20:12 PM UTC+1, Dave Angel wrote: I'm not necessarily doubting it, just challenging you to provide a data sample that actually shows it. And of course, I'm not claiming that 7bit is in any way

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Dave Angel
On 02/19/2015 01:32 PM, Ian Kelly wrote: On Thu, Feb 19, 2015 at 11:24 AM, Dave Angel da...@davea.name wrote: Here's a couple of ranges of output, showing that the 7bit scheme does better for values between 384 and 16379. 382 2 80fe --- 2 7e82 383 2 80ff --- 2 7f82 384 3 81 --- 2 0083 384

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Dave Angel
On 02/19/2015 01:34 PM, Chris Angelico wrote: On Fri, Feb 20, 2015 at 5:24 AM, Dave Angel da...@davea.name wrote: In all my experimenting, I haven't found any values where the 7bit scheme does worse. It seems likely that for extremely large integers, it will, but if those

Re: python implementation of a new integer encoding algorithm.

2015-02-18 Thread Dave Angel
On 02/18/2015 02:55 PM, janhein.vanderb...@gmail.com wrote: Op woensdag 18 februari 2015 17:47:49 UTC+1 schreef Dave Angel: On 02/18/2015 03:59 AM, janhein.vanderb...@gmail.com wrote: encoding individual integers optimally without any assumptions about their values. Contradiction

Re: What behavior would you expect?

2015-02-18 Thread Dave Angel
On 02/19/2015 12:10 AM, Chris Angelico wrote: On Thu, Feb 19, 2015 at 3:44 PM, Jason Friedman jsf80...@gmail.com wrote: I have need to search a directory and return the name of the most recent file matching a given pattern. Given a directory with these files and timestamps, q.pattern1.abc Feb

Re: python implementation of a new integer encoding algorithm.

2015-02-18 Thread Dave Angel
On 02/18/2015 04:04 AM, janhein.vanderb...@gmail.com wrote: On Tuesday, February 17, 2015 at 3:35:16 PM UTC+1, Chris Angelico wrote: Oh, incidentally: If you want a decent binary format for variable-sized integer, check out the MIDI spec. I did some time ago, thanks, and it is indeed a decent

Re: python implementation of a new integer encoding algorithm.

2015-02-18 Thread Dave Angel
On 02/18/2015 03:59 AM, janhein.vanderb...@gmail.com wrote: encoding individual integers optimally without any assumptions about their values. Contradiction in terms. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list

Re: python implementation of a new integer encoding algorithm.

2015-02-17 Thread Dave Angel
On 02/17/2015 06:22 AM, janhein.vanderb...@gmail.com wrote: In http://optarbvalintenc.blogspot.nl/ I propose a new way to encode arbitrarily valued integers and the python code that can be used as a reference for practical implementations of codecs. The encoding algorithm itself is optimized

Re: python implementation of a new integer encoding algorithm.

2015-02-17 Thread Dave Angel
On 02/17/2015 09:34 AM, Chris Angelico wrote: On Wed, Feb 18, 2015 at 1:12 AM, Dave Angel da...@davea.name wrote: They had a field type called a compressed integer. It could vary between one byte and I think about six. And the theory was that it took less space than the equivalent format

Re: python implementation of a new integer encoding algorithm.

2015-02-17 Thread Dave Angel
On 02/17/2015 09:58 AM, Chris Angelico wrote: On Wed, Feb 18, 2015 at 1:50 AM, Dave Angel da...@davea.name wrote: But the first thing I'd expect to see would be a target estimate of the anticipated distribution of number values/magnitudes. For example, if a typical integer is 1500 bits, plus

Re: Printing to printer, windows 7

2015-02-16 Thread Dave Angel
On 02/16/2015 09:08 PM, ken.hes...@gmail.com wrote: Would seem to be a simple problem. I just want to print to my printer instead of the console using Python 2.7, Windows 7. Hours of looking through FAQ's and Google haven't yielded a solution. Any suggestions appreciated -- It is a

Re: [Tutor] sql-like join on two lists or dictionaries

2015-02-16 Thread Dave Angel
On 02/16/2015 09:26 PM, Joel Goldstick wrote: On Sun, Feb 15, 2015 at 2:14 PM, Peter Otten __pete...@web.de wrote: Joel Goldstick wrote: You can dispense with the slicing if you use the str.split() method. It will put each item in a list. Only if there are no whitespace chars in the

Re: Floating point g format not stripping trailing zeros

2015-02-13 Thread Dave Angel
On 02/13/2015 03:33 PM, Grant Edwards wrote: On 2015-02-13, Ian Kelly ian.g.ke...@gmail.com wrote: Significant digits are within the precision of the calculation. Writing 1.230 indicates that the fourth digit is known to be zero. Writing 1.23 outside a context of exact calculation indicates

Re: function inclusion problem

2015-02-11 Thread Dave Angel
On 02/11/2015 08:27 AM, Victor L wrote: Laura, thanks for the answer - it works. Is there some equivalent of include to expose every function in that script? Thanks again, -V Please don't top-post, and please use text email, not html. Thank you. yes, as sohcahto...@gmail.com pointed out, you

Re: Varable parsing error with python

2015-02-10 Thread Dave Angel
On 02/10/2015 03:29 AM, OmPs wrote: On 10 Feb 2015 13:12, Chris Angelico ros...@gmail.com wrote: On Tue, Feb 10, 2015 at 6:30 PM, OmPs torque.in...@gmail.com wrote: def _getPackgeVersion(xmlfile, p): package = str(p) if isinstance(fpmdict[application][package], list):

Re: TypeError: list indices must be integers, not tuple

2015-02-10 Thread Dave Angel
On 02/10/2015 09:33 AM, Chris Angelico wrote: On Wed, Feb 11, 2015 at 1:28 AM, Dave Angel da...@davea.name wrote: If you can show me a one tuple anywhere in the original code I'll happily buy you a tipple of your choice. print Menu[fav,RandomNum] was in the original code That's not a one

Re: TypeError: list indices must be integers, not tuple

2015-02-10 Thread Dave Angel
On 02/10/2015 01:48 PM, Chris Angelico wrote: On Wed, Feb 11, 2015 at 2:51 AM, Dave Angel da...@davea.name wrote: You're right of course. I didn't notice the meaning of one-tuple; I took Mark's comment as if he had said: If you can show me a ruboutrubout one tuple anywhere ... Ah, yeah. I

Re: Varable parsing error with python

2015-02-10 Thread Dave Angel
On 02/10/2015 01:24 PM, Denis McMahon wrote: On Tue, 10 Feb 2015 18:39:42 +1100, Chris Angelico wrote: On Tue, Feb 10, 2015 at 6:30 PM, OmPs torque.in...@gmail.com wrote: def _getPackgeVersion(xmlfile, p): package = str(p) if isinstance(fpmdict[application][package],

Re: Wildly OT: pop-up virtual keyboard for Mac or Linux?

2015-02-10 Thread Dave Angel
On 02/10/2015 04:05 PM, Skip Montanaro wrote: I know this is way off-topic for this group, but I figured if anyone in the online virtual communities I participate in would know the answer, the Pythonistas would... Google has so far not been my friend in this realm. One of the things I really

Re: TypeError: list indices must be integers, not tuple

2015-02-10 Thread Dave Angel
On 02/10/2015 06:35 AM, Mark Lawrence wrote: On 10/02/2015 00:05, Ryan Stuart wrote: Hi, If you can show me a one tuple anywhere in the original code I'll happily buy you a tipple of your choice. print Menu[fav,RandomNum] was in the original code -- DaveA --

Re: TypeError: list indices must be integers, not tuple

2015-02-09 Thread Dave Angel
On 02/09/2015 07:02 PM, Ethan Furman wrote: On 02/09/2015 03:52 PM, james8boo...@hotmail.com wrote: import random RandomNum = random.randint(0,7) restraunt = raw_input(What's your favourite takeaway?Pizza, Chinease or Indian?) if restraunt == (Pizza): fav = (1) elif restraunt ==

Re: Please help.

2015-02-09 Thread Dave Angel
On 02/09/2015 01:08 PM, John Ladasky wrote: On Monday, February 9, 2015 at 9:44:16 AM UTC-8, chim...@gmail.com wrote: Hello. Am trying to change the key words to my tribal language. Eg change English language: print() to igbo language: de(). I have been stuck for months I need a mentor or

Re: Weird behavior on __dict__ attr

2015-02-09 Thread Dave Angel
On 02/09/2015 09:52 PM, Shiyao Ma wrote: Hi. My context is a little hard to reproduce. WHY don't you try? Telling us about a class without showing how it's defined leaves us all guessing. Start by telling us Python version. And if it's 2.x, tell us whether this class is an old style or

Re: TypeError: list indices must be integers, not tuple

2015-02-09 Thread Dave Angel
On 02/09/2015 10:05 PM, Dave Angel wrote: On 02/09/2015 07:02 PM, Ethan Furman wrote: On 02/09/2015 03:52 PM, james8boo...@hotmail.com wrote: import random RandomNum = random.randint(0,7) restraunt = raw_input(What's your favourite takeaway?Pizza, Chinease or Indian?) if restraunt == (Pizza

Re: help for using Python rsa

2015-02-07 Thread Dave Angel
On 02/07/2015 10:00 PM, Chris Angelico wrote: On Sun, Feb 8, 2015 at 1:55 PM, Cameron Simpson c...@zip.com.au wrote: Given that Dave Angel has a tool that displays the 'SEcP...' string using mhr1224's input string, I'd say we're missing some context. I don't think he does; that was simulated

Re: Setuptools, __init__ and __main__

2015-02-06 Thread Dave Angel
On 02/06/2015 04:35 PM, Ben Finney wrote: Rob Gaddi rgaddi@technologyhighland.invalid writes: So I'm trying to wrap my head around packaging issues Congratulations on tackling this. You will likely find the Python Packaging User Guide URL:https://packaging.python.org/ helpful. Also know

Re: help for using Python rsa

2015-02-06 Thread Dave Angel
On 02/07/2015 12:14 AM, mhr1...@gmail.com wrote: I use this code to create public and private keys: import rsa (pubkey, privkey) = rsa.newkeys(512) And then convert it to PEM format: exppub =pubkey.save_pkcs1(format='PEM') exppriv =

Re: Setuptools, __init__ and __main__

2015-02-06 Thread Dave Angel
On 02/06/2015 06:56 PM, Steven D'Aprano wrote: Dave Angel wrote: And don't name any source code __main__.py, That's incorrect. Starting from Python 2.6, __main__.py is reserved for the application main script in packages. That is, if you design your application as a package (not a single

Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-02-04 Thread Dave Angel
On 01/28/2015 07:34 PM, Steven D'Aprano wrote: Devin Jeanpierre wrote: On Wed, Jan 28, 2015 at 1:40 PM, Chris Angelico ros...@gmail.com wrote: On Thu, Jan 29, 2015 at 5:47 AM, Chris Kaynor ckay...@zindagigames.com wrote: I use Google Drive for it for all the stuff I do at home, and use SVN

Re: Problem while reading files from hdfs using python

2015-02-03 Thread Dave Angel
On 01/25/2015 03:23 PM, Shalini Ravishankar wrote: Hello Everyone, I am trying to read(open) and write files in hdfs inside a python script. But having error. Please copy/paste the full error traceback. Can someone tell me what is wrong here. Code (full): sample.py #!/usr/bin/python

Re: Benchmarking some modules - strange result

2015-02-03 Thread Dave Angel
On 01/24/2015 09:36 PM, Dan Stromberg wrote: On Sat, Jan 24, 2015 at 6:24 PM, Chris Angelico ros...@gmail.com wrote: On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg drsali...@gmail.com wrote: For simplicity, let's say I've been running the suite of performance tests within a single interpreter

Re: Idiomatic backtracking in Python

2015-02-03 Thread Dave Angel
On 01/25/2015 08:45 PM, Chris Angelico wrote: On Mon, Jan 26, 2015 at 12:31 PM, Marko Rauhamaa ma...@pacujo.net wrote: Backtracking means the part of depth-first traversal where you retreat to the parent node. If you implement your traversal with a recursive function, backtracking means — more

[issue23318] (compiled RegEx).split gives unexpected results if () in pattern

2015-01-25 Thread Dave Notman
New submission from Dave Notman: # Python 3.3.1 (default, Sep 25 2013, 19:30:50) # Linux 3.8.0-35-generic #50-Ubuntu SMP Tue Dec 3 01:25:33 UTC 2013 i686 i686 i686 GNU/Linux import re splitter = re.compile( r'(\s*[+/;,]\s*)|(\s+and\s+)' ) ll = splitter.split( 'Dave Sam, Jane and Zoe' ) print

<    1   2   3   4   5   6   7   8   9   10   >