Re: turn list of letters into an array of integers

2012-10-24 Thread 88888 Dihedral
Chris Rebert於 2012年10月24日星期三UTC+8下午2時07分29秒寫道: On Tue, Oct 23, 2012 at 10:23 PM, seektime michael.j.kra...@gmail.com wrote: Here's some example code. The input is a list which is a matrix of letters: a b a b b a and I'd like to turn this into a Python array:

Re: pls help me with this prog

2012-10-21 Thread 88888 Dihedral
On Friday, October 19, 2012 4:40:42 PM UTC+8, inshu chauhan wrote: in this prog I have written a code to calculate teh centre of a given 3D data.. but i want to calculate it for every 3 points not the whole data, but instead of giving me centre for every 3 data the prog is printing

Re: Remove uncide notation

2012-10-19 Thread 88888 Dihedral
Ashish Jain於 2012年10月18日星期四UTC+8下午5時27分04秒寫道: Hi, I have a html string in an object, when I do repr() of that object, I get value as: {'Id' : 1, 'Body': u'p Hello /p'} I don't wish to have 'u' as the character in my string representation. As this is not a valid json

Re: list comprehension question

2012-10-17 Thread 88888 Dihedral
Dave Angel於 2012年10月17日星期三UTC+8下午10時37分01秒寫道: On 10/17/2012 10:06 AM, rusi wrote: On Oct 17, 5:33 pm, Dave Angel d...@davea.name wrote: On 10/17/2012 12:43 AM, Kevin Anthony wrote: Is it not true that list comprehension is much faster the the for loops? If it is not the correct

Re: list comprehension question

2012-10-17 Thread 88888 Dihedral
rusi於 2012年10月17日星期三UTC+8下午10時50分11秒寫道: On Oct 17, 7:37 pm, Dave Angel d...@davea.name wrote: And I'd wager all the improvement is in the inner loop, the dot() function. Sorry -- red herring! Changing def mm1(a,b): return [[sum(x*y for x,y in zip(ra,rb)) for rb in

Re: overriding equals operation

2012-10-16 Thread 88888 Dihedral
Pradipto Banerjee於 2012年10月16日星期二UTC+8下午9時59分05秒寫道: I am trying to define class, where if I use a statement a = b, then instead of a pointing to the same instance as b, it should point to a copy of b, but I can't get it right. Currently, I have the following: class

Re: Checking for dlls in ctypes

2012-10-13 Thread 88888 Dihedral
Wanderer於 2012年10月12日星期五UTC+8下午11時36分27秒寫道: I'm trying to write some code that will load one of three dll depending on the one available. I've tried the code below, but it doesn't work. The try except doesn't catch the exception. Is there a way to do this? try:

Re: Private methods

2012-10-10 Thread 88888 Dihedral
D.M. Procida於 2012年10月9日星期二UTC+8下午9時24分30秒寫道: What exactly is the point of a private method? Why or when would I want Private methods in the object level are searched first in the run time of python interpreter. I did turn some private methods in to c programs from time to time. --

Re: Problems building Python from hg trunk on Open SUSE

2012-10-07 Thread 88888 Dihedral
Skip Montanaro於 2012年10月6日星期六UTC+8上午8時25分06秒寫道: I haven't messed around with Python 3 recently, so decided to give it a whirl again. I cloned the trunk (cpython) and set about it. This is on an OpenSUSE 12.1 system. I configured like so: ./configure

Re: notmm is dead!

2012-10-05 Thread 88888 Dihedral
Prasad, Ramit於 2012年10月6日星期六UTC+8上午4時06分31秒寫道: Steven D'Aprano wrote: Sent: Thursday, October 04, 2012 7:22 PM To: python-list@python.org Subject: Re: notmm is dead! On Thu, 04 Oct 2012 14:10:46 -0400, Etienne Robillard wrote: Dear list, Due to lack of

Re: write binary with struct.pack_into

2012-10-05 Thread 88888 Dihedral
palmeira於 2012年10月6日星期六UTC+8上午11時27分47秒寫道: Dear pythonists, I'm having a problem with read/write binary in python. I have a binary file that I need to read information, extract a array, modify this array and put these values into file again in same binary format. I need to use

Re: Combinations of lists

2012-10-04 Thread 88888 Dihedral
to properly implement force_unique_combinations, but it runs. I hope this is right. If you need significantly more speed your best chance is probably Cython or C, although I don't doubt 10x more speed may well be possible from within Python. Also, 8 Dihedral is a bot

Re: Combinations of lists

2012-10-03 Thread 88888 Dihedral
Oscar Benjamin於 2012年10月4日星期四UTC+8上午4時29分51秒寫道: Oscar wrote: def uniquecombinations(h, m): for ha in submultisets(h, len(h)//2): hb = list(h) for c in ha: hb.remove(c) yield [m[0] + a for a in ha] + [m[1] + b for b in hb] h =

Re: Slicing iterables in sub-generators without loosing elements

2012-10-02 Thread 88888 Dihedral
On Monday, October 1, 2012 4:17:50 PM UTC+8, Mark Lawrence wrote: On 01/10/2012 01:58, 8 Dihedral wrote: Your question seems vague to me. If you know you are storing only immutable tuples in a list, then the way to iterate is simple. Does Python have a magic method

Re: Slicing iterables in sub-generators without loosing elements

2012-10-02 Thread 88888 Dihedral
Steven D'Aprano於 2012年10月3日星期三UTC+8上午8時57分20秒寫道: On Wed, 03 Oct 2012 03:58:02 +1000, Chris Angelico wrote: Dihedral might be a bot and might not. I've come to the conclusion that it's not worth trying to find out, given that a good bot can outdo a lot of humans in useful

Re: Slicing iterables in sub-generators without loosing elements

2012-10-02 Thread 88888 Dihedral
Steven D'Aprano於 2012年10月3日星期三UTC+8上午9時24分13秒寫道: On Tue, 02 Oct 2012 18:11:20 -0700, 8 Dihedral wrote: Steven D'Aprano於 2012年10月3日星期三UTC+8上午8時57分20秒寫道: Oh, I'm convinced that it's a bot. The fact that Dihedral never responds to conversations about him/it is a give away

Re: parse an environment file

2012-10-01 Thread 88888 Dihedral
On Monday, October 1, 2012 10:42:02 PM UTC+8, Chris Angelico wrote: On Tue, Oct 2, 2012 at 12:37 AM, Jason Friedman ja...@powerpull.net wrote: Is there a reason to use that format, rather than using Python notation? I've at times made config files that simply get imported. Instead of

Re: Slicing iterables in sub-generators without loosing elements

2012-09-30 Thread 88888 Dihedral
On Sunday, September 30, 2012 12:15:57 AM UTC+8, Thomas Bach wrote: Hi, say we have the following: data = [('foo', 1), ('foo', 2), ('bar', 3), ('bar', 2)] is there a way to code a function iter_in_blocks such that result = [ list(block) for block in

Re: using * to make a list of lists with repeated (and independent) elements

2012-09-29 Thread 88888 Dihedral
On Saturday, September 29, 2012 9:46:22 PM UTC+8, Ramchandra Apte wrote: On Thursday, 27 September 2012 04:14:42 UTC+5:30, Tim Chase wrote: On 09/26/12 17:28, 8 Dihedral wrote: 8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: In these conditions, how to make this list

Re: using * to make a list of lists with repeated (and independent) elements

2012-09-29 Thread 88888 Dihedral
On Sunday, September 30, 2012 1:19:22 AM UTC+8, Ian wrote: On Sat, Sep 29, 2012 at 11:01 AM, 8 Dihedral dihedral88...@googlemail.com wrote: Don't you get it why I avoided the lambda one liner as a functon. I prefer the def way with a name chosen. Certainly

Re: Python source code easy to hack?

2012-09-28 Thread 88888 Dihedral
Jayden於 2012年9月28日星期五UTC+8下午7時57分14秒寫道: Dear All, I have a concern in developing commercial code with Python. Someone told me that its program can be easily hacked to get its source code. Is it really the case? Any way to protect your source code? Thanks a lot! Jayden

Re: creating an artificial last element in sort list

2012-09-28 Thread 88888 Dihedral
dave於 2012年9月29日星期六UTC+8上午7時51分10秒寫道: more clearer, this is a more realistic use case: ['awefawef', 'awefawfsf', 'awefsdf', 'zz', 'zz', 'zz'] and the quantity of ''zz'' would be dynamic. On Friday, September 28, 2012 4:46:15

Re: Algorithms using Python?

2012-09-27 Thread 88888 Dihedral
Wayne Werner於 2012年9月27日星期四UTC+8上午12時05分31秒寫道: On Fri, 21 Sep 2012, Dennis Lee Bieber wrote: On Fri, 21 Sep 2012 14:26:04 +0530, Mayuresh Kathe mayur...@kathe.in declaimed the following in gmane.comp.python.general: Is there a good book on foundational as well as advanced

Re: using * to make a list of lists with repeated (and independent) elements

2012-09-27 Thread 88888 Dihedral
Tim Chase於 2012年9月27日星期四UTC+8上午6時44分42秒寫道: On 09/26/12 17:28, 8 Dihedral wrote: 8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: In these conditions, how to make this list [[0,0,0],[0,0,0]] with * without this behavior? a = [[0]*3 for i in xrange(2)] a[0][0]=2

Re: using * to make a list of lists with repeated (and independent) elements

2012-09-26 Thread 88888 Dihedral
TP於 2012年9月27日星期四UTC+8上午5時25分04秒寫道: Hi everybody, I have tried, naively, to do the following, so as to make lists quickly: a=[0]*2 a [0, 0] a[0]=3 a [3, 0] All is working fine, so I extended the technique to do: a=[[0]*3]*2 a [[0, 0, 0], [0,

Re: using * to make a list of lists with repeated (and independent) elements

2012-09-26 Thread 88888 Dihedral
Paul Rubin於 2012年9月27日星期四UTC+8上午5時43分58秒寫道: TP t...@frenoespam.fr.invalid writes: copies a list, he copies in fact the *pointer* to the list Is it the correct explanation? Yes, that is correct. In these conditions, how to make this list [[0,0,0],[0,0,0]] with *

Re: using * to make a list of lists with repeated (and independent) elements

2012-09-26 Thread 88888 Dihedral
8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: Paul Rubin於 2012年9月27日星期四UTC+8上午5時43分58秒寫道: TP t...@frenoespam.fr.invalid writes: copies a list, he copies in fact the *pointer* to the list Is it the correct explanation? Yes, that is correct

Re: using * to make a list of lists with repeated (and independent) elements

2012-09-26 Thread 88888 Dihedral
Tim Chase於 2012年9月27日星期四UTC+8上午6時44分42秒寫道: On 09/26/12 17:28, 8 Dihedral wrote: 8 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道: In these conditions, how to make this list [[0,0,0],[0,0,0]] with * without this behavior? a = [[0]*3 for i in xrange(2)] a[0][0]=2

Re: How to limit CPU usage in Python

2012-09-25 Thread 88888 Dihedral
DPalao於 2012年9月25日星期二UTC+8下午11時13分54秒寫道: On Jueves septiembre 20 2012 11:12:44 Rolando Cañer Roblejo escribió: Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this

Re: Article on the future of Python

2012-09-25 Thread 88888 Dihedral
Grant Edwards於 2012年9月26日星期三UTC+8上午2時25分31秒寫道: On 2012-09-25, Martin P. Hellwig martin.hell...@gmail.com wrote: On Tuesday, 25 September 2012 09:14:27 UTC+1, Mark Lawrence wrote: Hi all, I though this might be of interest.

Re: Does python have built command for package skeleton creation?

2012-09-24 Thread 88888 Dihedral
xliiv於 2012年9月21日星期五UTC+8下午9時13分38秒寫道: On Friday, September 21, 2012 3:04:02 PM UTC+2, Tarek Ziadé wrote: On 9/21/12 2:14 PM, xliiv wrote: Python Paste is probably what you are looking for - see http://lucasmanual.com/mywiki/PythonPaste for example

Re: Java singletonMap in Python

2012-09-24 Thread 88888 Dihedral
Duncan Booth於 2012年9月25日星期二UTC+8上午1時33分31秒寫道: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 24 Sep 2012 00:14:23 +0100, Mark Lawrence wrote: Purely for fun I've been porting some code to Python and came across the singletonMap[1]. I'm aware that there

Re: Blue Screen Python

2012-09-23 Thread 88888 Dihedral
Chris Angelico於 2012年9月22日星期六UTC+8下午10時10分12秒寫道: On Sat, Sep 22, 2012 at 11:07 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: As per their partnership agreement, IBM took over development of OS/2 version 2 while Microsoft worked on developing version 3. OS/2 2.0 was

Re: write to a file two dict()

2012-09-23 Thread 88888 Dihedral
giuseppe...@gmail.com於 2012年9月24日星期一UTC+8上午1時44分30秒寫道: Hi Have two dict() of the same length and i want print them to a common file. a={1: 1, 2: 2, 3: 3} b={1: 11, 2: 22, 3: 33} in order to obtain 1 1 1 11 2 2 2 22 3 3 3 33 I tried output =

Re: Functional way to compare things inside a list

2012-09-22 Thread 88888 Dihedral
Ian於 2012年9月22日星期六UTC+8下午2時23分43秒寫道: On Fri, Sep 21, 2012 at 7:25 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 21 Sep 2012 14:49:55 -0600, Ian Kelly wrote: On Fri, Sep 21, 2012 at 1:54 PM, 8 Dihedral dihedral88...@googlemail.com wrote: I don't

Re: Blue Screen Python

2012-09-22 Thread 88888 Dihedral
Dave Angel於 2012年9月22日星期六UTC+8下午7時44分54秒寫道: On 09/22/2012 06:53 AM, Alister wrote: On Fri, 21 Sep 2012 18:47:57 -0400, Dave Angel wrote: SNIP That's not true at all. You'd re thinking of Windows 3, Windows 95, 98, and ME, which were hacked on top of MSDOS. But Windows

Re: Functional way to compare things inside a list

2012-09-21 Thread 88888 Dihedral
Ulrich Eckhardt於 2012年9月21日星期五UTC+8下午5時15分03秒寫道: Am 21.09.2012 00:58, schrieb thorso...@lavabit.com: list = [{'1': []}, {'2': []}, {'3': ['4', '5']}] I want to check for a value (e.g. '4'), and get the key of the dictionary that contains that value. Note: 1. list is a

Re: [Q] How to exec code object with local variables specified?

2012-09-21 Thread 88888 Dihedral
Makoto Kuwata於 2012年9月20日星期四UTC+8下午7時27分40秒寫道: Hi, Is it possible to run code object with local variables specified? I'm trying the following code but not work: def fn(): x = 1 y = 2 localvars = {'x': 0} exec(fn.func_code, globals(),

Re: Functional way to compare things inside a list

2012-09-21 Thread 88888 Dihedral
A Ian於 2012年9月22日星期六UTC+8上午4時50分49秒寫道: On Fri, Sep 21, 2012 at 1:54 PM, 8 Dihedral dihedral88...@googlemail.com wrote: I don't think functional aspects are only marked as lazy programming. He wrote lazy evaluation, not lazy programming. Two entirely different things

Re: technologies synergistic with Python

2012-09-21 Thread 88888 Dihedral
i Rodrick Brown於 2012年9月22日星期六UTC+8上午6時33分59秒寫道: On Sep 21, 2012, at 5:59 PM, Ethan Furman et...@stoneleaf.us wrote: Greetings! What is the consensus... okay, okay -- what are some wide ranging opinions on technologies that I should know if my dream job is one that consists

Re: Python presentations

2012-09-19 Thread 88888 Dihedral
andrea crotti於 2012年9月20日星期四UTC+8上午12時42分50秒寫道: 2012/9/19 Trent Nelson tr...@snakebite.org: FWIW, I gave a presentation on decorators to the New York Python User Group back in 2008. Relevant blog post: http://blogs.onresolve.com/?p=48 There's a

Re: Decorators not worth the effort

2012-09-18 Thread 88888 Dihedral
Chris Angelico於 2012年9月18日星期二UTC+8下午9時25分04秒寫道: On Tue, Sep 18, 2012 at 11:19 PM, Neil Cerutti ne...@norwich.edu wrote: On 2012-09-14, Chris Angelico ros...@gmail.com wrote: But then again, who actually ever needs fibonacci numbers? If it should happen that your question is not

Re: Decorators not worth the effort

2012-09-18 Thread 88888 Dihedral
Terry Reedy於 2012年9月15日星期六UTC+8上午4時40分32秒寫道: 2nd try, hit send button by mistake before On 9/14/2012 5:28 AM, Jean-Michel Pichavant wrote: Decorators are very popular so I kinda already know that the fault is mine. Now to the reason why I have troubles writing them, I don't

Re: Python garbage collector/memory manager behaving strangely

2012-09-16 Thread 88888 Dihedral
alex23於 2012年9月17日星期一UTC+8上午11時25分06秒寫道: On Sep 17, 12:32 pm, Jadhav, Alok alok.jad...@credit-suisse.com wrote: - As you have seen, the line separator is not '\n' but its '|\n'. Sometimes the data itself has '\n' characters in the middle of the line and only way to find true end of

Re: Decorators not worth the effort

2012-09-15 Thread 88888 Dihedral
Steven D'Aprano於 2012年9月15日星期六UTC+8上午7時39分28秒寫道: On Fri, 14 Sep 2012 15:16:47 -0600, Ian Kelly wrote: If only there were a conceptually simpler way to do this. Actually, there is. I give you: metadecorators! [code snipped but shown below] Which I think is certainly easier to

Re: Decorators not worth the effort

2012-09-15 Thread 88888 Dihedral
David Hutto於 2012年9月15日星期六UTC+8下午6時04分28秒寫道: On Sat, Sep 15, 2012 at 5:45 AM, 8 Dihedral dihedral88...@googlemail.com wrote: Steven D'Aprano於 2012年9月15日星期六UTC+8上午7時39分28秒寫道: On Fri, 14 Sep 2012 15:16:47 -0600, Ian Kelly wrote: If only there were a conceptually

Re: Python presentations

2012-09-14 Thread 88888 Dihedral
Chris Angelico於 2012年9月14日星期五UTC+8上午6時39分25秒寫道: On Fri, Sep 14, 2012 at 8:33 AM, Alexander Blinne n...@blinne.net wrote: On 13.09.2012 21:01, 8 Dihedral wrote: def powerlist(x, n): # n is a natural number result=[] y=1 for i in xrange(n

Re: Decorators not worth the effort

2012-09-14 Thread 88888 Dihedral
Chris Angelico於 2012年9月14日星期五UTC+8下午10時41分06秒寫道: On Sat, Sep 15, 2012 at 12:12 AM, andrea crotti andrea.crott...@gmail.com wrote: def fib(n): if n = 1: return 1 return fib(n-1) + fib(n-2) @memoize def fib_memoized(n): if n = 1:

Re: Python presentations

2012-09-13 Thread 88888 Dihedral
mblume於 2012年9月14日星期五UTC+8上午12時26分17秒寫道: Am Thu, 13 Sep 2012 17:00:19 +0100 schrieb andrea crotti: I have to give a couple of Python presentations in the next weeks, and I'm still thinking what is the best approach. My idea for an introductory presentation of python was to

Re: set and dict iteration

2012-09-10 Thread 88888 Dihedral
Paul Rubin於 2012年8月17日星期五UTC+8上午9時01分39秒寫道: Ian Kelly ian.g.ke...@gmail.com writes: With regard to key insertion and deletion while iterating over a dict or set, though, there is just no good reason to be doing that (especially as the result is very implementation-specific), and I

Re: Unittest - testing for filenames and filesize

2012-08-31 Thread 88888 Dihedral
On Saturday, September 1, 2012 12:19:10 AM UTC+8, Chris Withers wrote: On 23/08/2012 12:25, Tigerstyle wrote: class FileTest(unittest.TestCase): def setUp(self): self.origdir = os.getcwd() self.dirname = tempfile.mkdtemp(testdir)

Re: Objects in Python

2012-08-26 Thread 88888 Dihedral
Jan Kuiken於 2012年8月24日星期五UTC+8上午2時02分00秒寫道: On 8/23/12 06:11 , Steven D'Aprano wrote: 2) Related to the above, you can infinitely nest scopes. There's nothing wrong with having six variables called 'q'; you always use the innermost one. Yes, this can hurt readability Well,

Re: Abuse of Big Oh notation

2012-08-20 Thread 88888 Dihedral
Paul Rubin於 2012年8月21日星期二UTC+8上午3時29分12秒寫道: Ian Kelly ian.g.ke...@gmail.com writes: The difference between the two is that the former is bounded by a constant that is fundamental to the algorithm at hand,... S is clearly bounded by the constraints of actual shoes, so we can safely

Re: Abuse of Big Oh notation

2012-08-20 Thread 88888 Dihedral
Paul Rubin於 2012年8月21日星期二UTC+8上午3時29分12秒寫道: Ian Kelly ian.g.ke...@gmail.com writes: The difference between the two is that the former is bounded by a constant that is fundamental to the algorithm at hand,... S is clearly bounded by the constraints of actual shoes, so we can safely

Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread 88888 Dihedral
On Monday, August 20, 2012 1:03:34 AM UTC+8, Blind Anagram wrote: Steven D'Aprano wrote in message news:502f8a2a$0$29978$c3e8da3$54964...@news.astraweb.com... On Sat, 18 Aug 2012 01:09:26 -0700, wxjmfauth wrote: [...] If you can consistently replicate a 100% to 1000%

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread 88888 Dihedral
On Monday, August 20, 2012 4:42:16 AM UTC+8, kj wrote: As far as I've been able to determine, Python does not remember (immutably, that is) the working directory at the program's start-up, or, if it does, it does not officially expose this information. Does anyone know why this is?

Re: New image and color management library for Python 2+3

2012-08-15 Thread 88888 Dihedral
Christian Heimes於 2012年8月15日星期三UTC+8上午2時22分54秒寫道: Hello fellow Pythonistas, I'm looking for co-developers, testers, documentation writers and users for a new image library I created. The code is available at https://bitbucket.org/tiran/smc.freeimage Background story:

Re: looking for a neat solution to a nested loop problem

2012-08-14 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道: On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: for i in range(N,N+100): for j in range(M,M+100): do_something(i % 100 ,j % 100) Emile How about... for i in range(100):

Re: save dictionary to a file without brackets.

2012-08-12 Thread 88888 Dihedral
Steven D'Aprano於 2012年8月11日星期六UTC+8下午7時26分37秒寫道: On Fri, 10 Aug 2012 08:53:43 +1000, Chris Angelico wrote: On Fri, Aug 10, 2012 at 8:26 AM, Dave Angel d...@davea.name wrote: On 08/09/2012 06:03 PM, Andrew Cooper wrote: O(n) for all other entries in the dict which suffer a hash

Re: save dictionary to a file without brackets.

2012-08-10 Thread 88888 Dihedral
Dave Angel於 2012年8月10日星期五UTC+8上午5時47分45秒寫道: On 08/09/2012 05:34 PM, Roman Vashkevich wrote: Actually, they are different. Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred thousand entries, and you will feel the difference. Dict uses hashing to get a value from

Re: looking for a neat solution to a nested loop problem

2012-08-09 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道: On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: for i in range(N,N+100): for j in range(M,M+100): do_something(i % 100 ,j % 100) Emile How about... for i in range(100):

Re: looking for a neat solution to a nested loop problem

2012-08-09 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道: On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: for i in range(N,N+100): for j in range(M,M+100): do_something(i % 100 ,j % 100) Emile How about... for i in range(100):

Re: save dictionary to a file without brackets.

2012-08-09 Thread 88888 Dihedral
Andrew Cooper於 2012年8月10日星期五UTC+8上午6時03分26秒寫道: On 09/08/2012 22:34, Roman Vashkevich wrote: Actually, they are different. Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred thousand entries, and you will feel the difference. Dict uses hashing to get a value from

Re: [newbie] String to binary conversion

2012-08-07 Thread 88888 Dihedral
Steven D'Aprano於 2012年8月7日星期二UTC+8上午10時01分05秒寫道: On Mon, 06 Aug 2012 22:46:38 +0200, Mok-Kong Shen wrote: If I have a string abcd then, with 8-bit encoding of each character, there is a corresponding 32-bit binary integer. How could I best obtain that integer and from that integer

Re: looking for a neat solution to a nested loop problem

2012-08-07 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道: On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: for i in range(N,N+100): for j in range(M,M+100): do_something(i % 100 ,j % 100) Emile How about... for i in range(100):

Re: Linux shell to python

2012-07-31 Thread 88888 Dihedral
Mark Lawrence於 2012年7月31日星期二UTC+8下午3時15分32秒寫道: On 31/07/2012 02:20, Dennis Lee Bieber wrote: On Mon, 30 Jul 2012 22:56:48 +, Dan Stromberg drsali...@gmail.com declaimed the following in gmane.comp.python.general: Sigh, and I'm also not keen on multi-line list

Re: Basic question about speed/coding style/memory

2012-07-23 Thread 88888 Dihedral
Jan Riechers於 2012年7月21日星期六UTC+8下午3時33分27秒寫道: Hello Pythonlist, I have one very basic question about speed,memory friendly coding, and coding style of the following easy quot;ifquot;-statement in Python 2.7, but Im sure its also the same in Python 3.x Block

Re: Basic question about speed/coding style/memory

2012-07-23 Thread 88888 Dihedral
Chris Angelico於 2012年7月21日星期六UTC+8下午5時04分12秒寫道: On Sat, Jul 21, 2012 at 5:33 PM, Jan Riechers lt;janpet...@freenet.degt; wrote: gt; Block gt; #-- gt; if statemente_true: gt; doSomething() gt; else: gt; doSomethingElseInstead() gt; gt;

Re: reloading code and multiprocessing

2012-07-19 Thread 88888 Dihedral
andrea crotti於 2012年7月19日星期四UTC+8下午6時15分11秒寫道: We need to be able to reload code on a live system. This live system has a daemon process always running but it runs many subprocesses with multiprocessing, and the subprocesses might have a short life... Now I found a way to reload the code

Re: Diagramming code

2012-07-17 Thread 88888 Dihedral
Chris Rebert於 2012年7月16日星期一UTC+8上午9時38分53秒寫道: On Sun, Jul 15, 2012 at 6:26 PM, hamilton lt;hamil...@nothere.comgt; wrote: gt; Subject: Diagramming code gt; gt; Is there any software to help understand python code ? What sort of diagrams? Control flow diagrams? Class diagrams? Sequence

Re: lambda in list comprehension acting funny

2012-07-14 Thread 88888 Dihedral
Alister於 2012年7月12日星期四UTC+8下午5時44分15秒寫道: On Wed, 11 Jul 2012 08:43:11 +0200, Daniel Fetchinson wrote: gt;gt; funcs = [ lambda x: x**i for i in range( 5 ) ] gt;gt; print funcs[0]( 2 ) gt;gt; print funcs[1]( 2 ) gt;gt; print funcs[2]( 2 ) gt;gt; gt;gt; This gives me gt;gt; gt;gt; 16 16 16

Re: lambda in list comprehension acting funny

2012-07-11 Thread 88888 Dihedral
On Thursday, July 12, 2012 12:34:33 AM UTC+8, Ian wrote: On Wed, Jul 11, 2012 at 4:28 AM, Colin J. Williams lt;c...@ncf.cagt; wrote: gt; I don#39;t understand why you would expect 1, 2, 4. Because: funcs[0](2) == 2 ** 0 == 1 funcs[1](2) == 2 ** 1 == 2 funcs[2](2) == 2 ** 2 == 4 gt;

Re: lambda in list comprehension acting funny

2012-07-11 Thread 88888 Dihedral
On Thursday, July 12, 2012 11:51:04 AM UTC+8, Steven D#39;Aprano wrote: On Wed, 11 Jul 2012 20:39:45 -0700, 8 Dihedral wrote: gt; I#39;ll contribute my way of python programming: gt; gt; def powerb(x, b): # gt; return x**b Here#39;s a shorter version: pygt; pow lt;built

Re: Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-22 Thread 88888 Dihedral
Albert van der Horst於 2012年6月22日星期五UTC+8下午11時53分01秒寫道: In article jr4pcc$fl3$1...@dont-email.me, Kevin Walzer k...@codebykevin.com wrote: On 6/11/12 8:01 AM, Wolfgang Keller wrote: Tkinter is imho honestly the very best argument if you want to make potential new users turn their backs away

Re: which one do you prefer? python with C# or java?

2012-06-11 Thread 88888 Dihedral
Yesterday Paid於 2012年6月10日星期日UTC+8上午6時44分44秒寫道: I'm planning to learn one more language with my python. Someone recommended to do Lisp or Clojure, but I don't think it's a good idea(do you?) So, I consider C# with ironpython or Java with Jython. It's a hard choice...I like Visual

Re: .py to .pyc

2012-05-20 Thread 88888 Dihedral
On Saturday, May 19, 2012 7:54:18 PM UTC+8, Colin J. Williams wrote: On 18/05/2012 7:20 PM, Tony the Tiger wrote: On Sun, 13 May 2012 23:36:02 +0200, Irmen de Jong wrote: Why do you care anyway? Wanna hide his code...? /Grrr Curiosity. Perhaps there are st ack-based processors

Re: why can't I pickle a class containing this dispatch dictionary?

2012-04-03 Thread 88888 Dihedral
Peter Otten於 2012年4月3日星期二UTC+8下午3時54分50秒寫道: jkn wrote: I'm clearly not understanding the 'can't pickle instancemethod objects' error; can someone help me to understand, I think classes implemented in C need some extra work to make them picklable, and that hasn't been done for

Re: Porting Python to an embedded system

2012-03-04 Thread 88888 Dihedral
On Sunday, March 4, 2012 6:58:50 PM UTC+8, Justin Drake wrote: I am working with an ARM Cortex M3 on which I need to port Python (without operating system). What would be my best approach? I just need the core Python and basic I/O. Sounds like the JVM law suites in ANDROINDS did stimulate a

Re: Need to write python source with python

2012-02-28 Thread 88888 Dihedral
在 2012年2月29日星期三UTC+8上午1时56分43秒,Peter Otten写道: crs...@gmail.com wrote: I'm new to Python but have experience with a few other programming languages(Java, Perl, JavaScript). I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) a python class and functions from

Re: pickle handling multiple objects ..

2012-02-27 Thread 88888 Dihedral
在 2012年2月26日星期日UTC+8下午9时00分31秒,Chris Angelico写道: On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten __pete...@web.de wrote: This is however a bit errorprone. If you accidentally write the loading code as fruit, beverages, vegetables = pickle.load(f) you'll end up drinking potatoes. You

Re: Python as a default shell, replacement of bash, sh, cmd ?

2012-02-19 Thread 88888 Dihedral
在 2012年2月20日星期一UTC+8上午8时23分33秒,Michael Torrie写道: On 02/18/2012 11:58 AM, SherjilOzair wrote: Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. I'm sure everyone would agree that doing this would make the

Re: Python as a default shell, replacement of bash, sh, cmd ?

2012-02-18 Thread 88888 Dihedral
在 2012年2月19日星期日UTC+8上午3时21分53秒,Jabba Laci写道: Have a look at IPython (http://ipython.org/). It can interact with the normal shell very well. Laszlo On Sat, Feb 18, 2012 at 19:58, SherjilOzair sherjiloz...@gmail.com wrote: Has it been considered to add shell features to python, such that

Re: [OT]: Smartphones and Python?

2012-02-18 Thread 88888 Dihedral
在 2012年2月19日星期日UTC+8上午8时36分48秒,Michael Torrie写道: On 02/18/2012 10:46 AM, Lie Ryan wrote: Android does have a full Linux experience; what it lacks is the GNU experience. Unlike normal Linux distros, Android does not use GNU userspace, instead it have its own userspace based on bionic,

Re: question about function pointer

2012-02-17 Thread 88888 Dihedral
在 2012年2月17日星期五UTC+8下午5时55分11秒,Nobody写道: On Fri, 17 Feb 2012 16:53:00 +0900, Zheng Li wrote: def method1(a = None): print a i can call it by method1(*(), **{'a' : 1}) I am just curious why it works and how it works? and what do *() and **{'a' : 1} mean? In a function

Re: ANN: Sarge, a library wrapping the subprocess module, has been released.

2012-02-17 Thread 88888 Dihedral
Check PY2EXE, PYREX and PSYChO. I must use these packages to relase commercial products with my own dll in c. -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT]: Smartphones and Python?

2012-02-17 Thread 88888 Dihedral
-- http://mail.python.org/mailman/listinfo/python-list

Re: [OT]: Smartphones and Python?

2012-02-17 Thread 88888 Dihedral
在 2012年2月18日星期六UTC+8上午9时51分13秒,Michael Torrie写道: On 02/16/2012 10:25 PM, 8 Dihedral wrote: Android is a customized linux OS used in mobile phones. I don't think any linux systm has to be locked by JAVA or any JVM to run applications. Getting waaa off topic here, but... I guess

Re: [semi OT]: Smartphones and Python?

2012-02-16 Thread 88888 Dihedral
The law suites of JAVA Vitrtual Machine from Oracle are famous now. But in 201X the JVM patents will be expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms easily. Then I personally prefer

Re: [semi OT]: Smartphones and Python?

2012-02-16 Thread 88888 Dihedral
在 2012年2月16日星期四UTC+8下午11时22分44秒,Michael Torrie写道: On 02/16/2012 07:53 AM, 8 Dihedral wrote: The law suites of JAVA Vitrtual Machine from Oracle are famous now. But in 201X the JVM patents will be expired, thus it is not very urgent to chunk out a new jython now. Anyway just write

Re: [semi OT]: Smartphones and Python?

2012-02-15 Thread 88888 Dihedral
在 2012年2月16日星期四UTC+8上午10时19分15秒,geremy condra写道: On Wed, Feb 15, 2012 at 12:58 PM, Martin Schöön martin.sch...@gmail.com wrote: First of all: I don't have any first hand experience of smartphones but now that my trusted old GSM phone is getting old I decided I am in for an up-grade. It

TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL

2012-02-14 Thread 88888 Dihedral
After my testing of JAVA, PYTHON, VB, C-sharp and Erlang like script languages, I noticed that script languages should be timed after the shell interpreter completed loaded. The start up loading time of script interpreters should be excluded in the measure of executing a byte code script.

Re: how to tell a method is classmethod or static method or instance method

2012-02-13 Thread 88888 Dihedral
在 2012年2月13日星期一UTC+8下午4时03分24秒,Steven D#39;Aprano写道: On Mon, 13 Feb 2012 15:59:27 +0900, Zheng Li wrote: how to tell a method is class method or static method or instance method? That's a good question, with a subtle answer that depends on exactly what you mean by the question. If you

Re: Numeric root-finding in Python

2012-02-12 Thread 88888 Dihedral
在 2012年2月12日星期日UTC+8下午2时41分20秒,Steven D#39;Aprano写道: This is only peripherally a Python problem, but in case anyone has any good ideas I'm going to ask it. I have a routine to calculate an approximation of Lambert's W function, and then apply a root-finding technique to improve the

Re: Postpone evaluation of argument

2012-02-11 Thread 88888 Dihedral
在 2012年2月11日星期六UTC+8上午7时57分56秒,Paul Rubin写道: Righard van Roy writes: I want to add an item to a list, except if the evaluation of that item results in an exception. This may be overkill and probably slow, but perhaps most in the spirit that you're asking. from itertools import

Re: Common LISP-style closures with Python

2012-02-10 Thread 88888 Dihedral
在 2012年2月4日星期六UTC+8上午8时27分56秒,Antti J Ylikoski写道: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows: - # Make a Common LISP-like closure with

Re: Guide to: Learning Python Decorators

2012-02-10 Thread 88888 Dihedral
I prefer to decorate a function not a method. I prefer to decorate an object to own a new method from the existed ones inherited in all the class levels. I do not decorate a class if not necessary. I believe this is more pythonic to add functionalities to objects in classes by aggregated

Re: frozendict

2012-02-10 Thread 88888 Dihedral
在 2012年2月11日星期六UTC+8上午2时57分34秒,John Nagle写道: On 2/10/2012 10:14 AM, Nathan Rice wrote: Lets also not forget that knowing an object is immutable lets you do a lot of optimizations; it can be inlined, it is safe to convert to a contiguous block of memory and stuff in cache, etc. If you know

Re: copy on write

2012-02-03 Thread 88888 Dihedral
在 2012年1月14日星期六UTC+8上午6时48分29秒,Evan Driscoll写道: On 01/13/2012 03:20 PM, Neil Cerutti wrote: They perform the same action, but their semantics are different. operator+ will always return a new object, thanks to its signature, and operator+= shall never do so. That's the main difference I

Re: copy on write

2012-02-02 Thread 88888 Dihedral
在 2012年1月14日星期六UTC+8上午6时48分29秒,Evan Driscoll写道: On 01/13/2012 03:20 PM, Neil Cerutti wrote: They perform the same action, but their semantics are different. operator+ will always return a new object, thanks to its signature, and operator+= shall never do so. That's the main difference I

Re: Looking under Python's hood: Will we find a high performance or clunky engine?

2012-01-23 Thread 88888 Dihedral
在 2012年1月23日星期一UTC+8上午2时01分11秒,Robert Kern写道: On 1/22/12 3:50 PM, Rick Johnson wrote: What does Python do when presented with this code? py [line.strip('\n') for line in f.readlines()] If Python reads all the file lines first and THEN iterates AGAIN to do the strip; we are driving

<    1   2   3   >