From flt.johnson at gmail.com Tue Nov 1 00:01:45 2011 From: flt.johnson at gmail.com (Fletcher Johnson) Date: Mon, 31 Oct 2011 21:01:45 -0700 (PDT) Subject: Unicode literals and byte string interpretation. References: <8de0e9b7-aaac-44a4-8a07-9c1a20bfc3eb@s7g2000yqa.googlegroups.com> <4eaa545f$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7371ad5a-83f1-45cf-800e-987812f9c6a1@a12g2000vbz.googlegroups.com> On Oct 28, 3:06?am, Steven D'Aprano wrote: > On Thu, 27 Oct 2011 20:05:13 -0700, Fletcher Johnson wrote: > > If I create a newUnicodeobject u'\x82\xb1\x82\xea\x82\xcd' how does > > this creation process interpret the bytes in the byte string? > > It doesn't, because there is no byte-string. You have created aUnicode > object from aliteralstring ofunicodecharacters, not bytes. Those > characters are: > > Dec Hex ?Char > 130 0x82 ? > 177 0xb1 ? > 130 0x82 ? > 234 0xea ? > 130 0x82 ? > 205 0xcd ? > > Don't be fooled that all of the characters happen to be in the range > 0-255, that is irrelevant. > > > Does it > > assume the string represents a utf-16 encoding, at utf-8 encoding, > > etc...? > > None of the above. It assumes nothing. It takes a string of characters, > end of story. > > > For reference the string is ??? in the 'shift-jis' encoding. > > No it is not. The way to get aunicodeliteralwith those characters is > to use aunicode-aware editor or terminal: > > >>> s = u'???' > >>> for c in s: > > ... ? ? print ord(c), hex(ord(c)), c > ... > 12371 0x3053 ? > 12428 0x308c ? > 12399 0x306f ? > > You are confusing characters with bytes. I believe that what you are > thinking of is the following: you start with a byte string, and then > decode it intounicode: > > >>> bytes = '\x82\xb1\x82\xea\x82\xcd' ?# not u'...' > >>> text = bytes.decode('shift-jis') > >>> print text > > ??? > > If you get the encoding wrong, you will get the wrong characters: > > >>> print bytes.decode('utf-16') > > ??? > > If you start with theUnicodecharacters, you can encode it into various > byte strings: > > >>> s = u'???' > >>> s.encode('shift-jis') > > '\x82\xb1\x82\xea\x82\xcd'>>> s.encode('utf-8') > > '\xe3\x81\x93\xe3\x82\x8c\xe3\x81\xaf' > > -- > Steven Thanks Steven. You are right. I was confusing characters with bytes. From pmaupin at gmail.com Tue Nov 1 00:03:59 2011 From: pmaupin at gmail.com (Patrick Maupin) Date: Mon, 31 Oct 2011 21:03:59 -0700 (PDT) Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4EAF175A.6060508@davea.name> <4EAF1C40.6030202@davea.name> <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> Message-ID: <6cc3dd78-3f08-4fe8-92b5-56a6b23b4006@es7g2000vbb.googlegroups.com> On Oct 31, 9:12?pm, Dave Angel wrote: > I would claim that a well-written (in C) translate function, without > using the delete option, should be much quicker than any python loop, > even if it does copy the data. Are you arguing with me? I was agreeing with you, I thought, that translate would be faster than a regex. I also pointed out that the delete function was available as , but OTOH, that might be a little slow because I think it does the deletion before the translate. I think I'd just do something like this: >>> transtab = ''.join(' ' if 32 <= x <= 126 else chr(x) for x in range(256)) >>> 'abc\x05\def\x0aghi'.translate(transtab).replace(' ', '') '\x05\n' Regards, Pat From abhishek.vit at gmail.com Tue Nov 1 01:31:53 2011 From: abhishek.vit at gmail.com (Abhishek Pratap) Date: Mon, 31 Oct 2011 22:31:53 -0700 Subject: Module for Python and SGE interaction Message-ID: Hey Guys I shud mention I am relative new to the language. Could you please let me know based on your experience which module could help me with farm out jobs to our existing clusters(we use SGE here) using python. Ideally I would like to do the following. 1. Submit #N jobs to cluster 2. monitor their progress 3. When all #N finishes, push another set of jobs Thanks! -Abhi -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Nov 1 02:56:51 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Nov 2011 06:56:51 GMT Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> On Mon, 31 Oct 2011 20:44:45 -0400, Terry Reedy wrote: [...] >> def is_ascii_text(text): >> for c in text: >> if c not in LEGAL: >> return False >> return True > > If text is 3.x bytes, this does not work ;-). OP did not specify bytes > or unicode or Python version. The OP specified *string*. Whether that's a byte-string in Python 2, or a unicode string in Python 3, it will still work, so long as both `text` and `LEGAL` are strings. [steve at sylar ~]$ python2 -c "print 'a' in 'abc'" # both byte strings True [steve at sylar ~]$ python2 -c "print u'a' in u'abc'" # both unicode strings True [steve at sylar ~]$ python3 -c "print('a' in 'abc')" # both unicode strings True Mixing bytes and characters may or may not do what you expect. [steve at sylar ~]$ python2 -c "print 'a' in u'abc'" # one of each True Whether that's a good thing or a bad thing is open for debate :) >> Algorithmically, that's as efficient as possible: > > This is a bit strange since you go on to explain that it is inefficient > -- O(n*k) where n = text length and k = legal length -- whereas below is > O(n). But since k is a constant, O(nk) is O(n). When using Big Oh notation, it is acceptable to hand-wave away a lot of detail. For example, it's common to assume that n+7, n//7 and n**7 all take the same constant amount of time, which is patently untrue: division and exponentiation both require more work than addition. In this case, relative to the size of the input text, both a linear string search and a constant-time hash lookup are O(1). That doesn't imply that they *literally* take constant time. [...] >> Since all() is guaranteed to keep short-cut semantics, that will be as >> fast as possible in Python, > > A dangerous statement to make. I like living dangerously :) > 'c in legal' has to get hash(c) and look > that up in the hash table, possible skipping around a bit if t If text > is byte string rather than unicode, a simple lookup 'mask[c]', where > mask is a 0-1 byte array, should be faster (see my other post). Oooh, clever! I like! It's not necessary to assume bytes, nor is it necessary to create a bitmask the size of the entire Unicode range. Here's a version for strings (bytes or unicode in Python 2, unicode in Python 3): LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) # Untested def is_ascii_text(text): for c in text: n = ord(c) if n >= len(MASK) or MASK[n] == '\0': return False return True Optimizing it is left as an exercise :) I *suspect*, even with any optimizations, that this will be slower than the version using a set. > On my > new Pentium Win 7 machine, it is -- by albout 5%. For 100,000,000 legal > bytes, a minimum of 8.69 versus 9.17 seconds. On my old Linux box, I get the opposite result: set lookup is a tiny bit faster, coincidentally also by almost 5%. >>> from time import time >>> legal_set = frozenset(range(32, 128)) >>> text = b'a' * 100000000 >>> t = time(); all(c in legal_set for c in text); time()-t True 27.174341917037964 >>> >>> legal_ray = 128 * b'\1' >>> t = time(); all(legal_ray[c] for c in text); time()-t True 28.39691996574402 -- Steven From steve+comp.lang.python at pearwood.info Tue Nov 1 03:10:50 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Nov 2011 07:10:50 GMT Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4EAF175A.6060508@davea.name> <4EAF1C40.6030202@davea.name> <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> Message-ID: <4eaf9b7a$0$29968$c3e8da3$5496439d@news.astraweb.com> On Mon, 31 Oct 2011 22:12:26 -0400, Dave Angel wrote: > I would claim that a well-written (in C) translate function, without > using the delete option, should be much quicker than any python loop, > even if it does copy the data. I think you are selling short the speed of the Python interpreter. Even for short strings, it's faster to iterate over a string in Python 3 than to copy it with translate: >>> from timeit import Timer >>> t1 = Timer('for c in text: pass', 'text = "abcd"') >>> t2 = Timer('text.translate(mapping)', ... 'text = "abcd"; mapping = "".maketrans("", "")') >>> min(t1.repeat()) 0.450606107711792 >>> min(t2.repeat()) 0.9279451370239258 > Incidentally, on the Pentium family, > there's a machine instruction for that, to do the whole loop in one > instruction (with rep prefix). I'm pretty sure that there isn't a machine instruction for copying an entire terabyte of data in one step. Since the OP explicitly said he was checking text up to a TB in size, whatever solution is used has to scale well. -- Steven From __peter__ at web.de Tue Nov 1 05:21:14 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Nov 2011 10:21:14 +0100 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4EAF175A.6060508@davea.name> <4EAF1C40.6030202@davea.name> <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> <4eaf9b7a$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > On Mon, 31 Oct 2011 22:12:26 -0400, Dave Angel wrote: > >> I would claim that a well-written (in C) translate function, without >> using the delete option, should be much quicker than any python loop, >> even if it does copy the data. > > I think you are selling short the speed of the Python interpreter. Even > for short strings, it's faster to iterate over a string in Python 3 than > to copy it with translate: > >>>> from timeit import Timer >>>> t1 = Timer('for c in text: pass', 'text = "abcd"') >>>> t2 = Timer('text.translate(mapping)', > ... 'text = "abcd"; mapping = "".maketrans("", "")') >>>> min(t1.repeat()) > 0.450606107711792 >>>> min(t2.repeat()) > 0.9279451370239258 Lies, damn lies, and benchmarks ;) Copying is fast: >>> Timer("text + 'x'", "text='abcde '*10**6").timeit(100) 1.819761037826538 >>> Timer("for c in text: pass", "text='abcde '*10**6").timeit(100) 18.89239192008972 The problem with str.translate() (unicode.translate() in 2.x) is that it needs a dictionary lookup for every character. However, if like the OP you are going to read data from a file to check whether it's (a subset of) ascii, there's no point converting to a string, and for bytes (where a lookup table with the byte as an index into that table can be used) the numbers look quite different: >>> t1 = Timer("for c in text: pass", "text = b'abcd '*10**6") >>> t1.timeit(100) 15.818882942199707 >>> t2 = Timer("text.translate(mapping)", "text = b'abcd '*10**6; mapping = b''.maketrans(b'', b'')") >>> t2.timeit(100) 2.821769952774048 From wonjunchoi001 at gmail.com Tue Nov 1 08:03:17 2011 From: wonjunchoi001 at gmail.com (pyman) Date: Tue, 1 Nov 2011 05:03:17 -0700 (PDT) Subject: proving two formula are same each other! Message-ID: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> hello, I need some idea to prove two formula is same. if N = 3, these formula are same each other. each formula has 3 input . To prove this, drawing shape or anything would be possible. how can I do this? please give me your idea! for example: N = 1 : formula1 has a, b, c input value, formula2 has d, e, f input value and each formula's output are different. N = 2 : formula1 has a, b, c input value, formula2 has d, e, f input value and each formula's output are different. N = 3 : formula1 has a, b, c input value, formula2 has d, e, f input value and each formula's output are SAME. Wonjun, Choi From d at davea.name Tue Nov 1 08:17:30 2011 From: d at davea.name (Dave Angel) Date: Tue, 01 Nov 2011 08:17:30 -0400 Subject: proving two formula are same each other! In-Reply-To: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> References: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> Message-ID: <4EAFE35A.7080106@davea.name> On 11/01/2011 08:03 AM, pyman wrote: > hello, I need some idea to prove two formula is same. if N = 3, these > formula are same each other. each formula has 3 input . To prove this, > drawing shape or anything would be possible. how can I do this? please > give me your idea! > > for example: > N = 1 : formula1 has a, b, c input value, formula2 has d, e, f input > value and each formula's output are different. > N = 2 : formula1 has a, b, c input value, formula2 has d, e, f input > value and each formula's output are different. > N = 3 : formula1 has a, b, c input value, formula2 has d, e, f input > value and each formula's output are SAME. > > Wonjun, Choi Python doesn't have formulae, it has functions and methods. So you have to describe more completely what kind of formula you have, math, physics, chemistry? And how is one different than the next? And how can a formula with 3 input use four values, N, a,. b, and c ? Please be more specific, and maybe somebody can help. -- DaveA From d at davea.name Tue Nov 1 09:01:18 2011 From: d at davea.name (Dave Angel) Date: Tue, 01 Nov 2011 09:01:18 -0400 Subject: proving two formula are same each other! In-Reply-To: References: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> <4EAFE35A.7080106@davea.name> Message-ID: <4EAFED9E.1070707@davea.name> (You forgot to do a REPLY-ALL, so that your message didn't get sent to the list) >> >>> Python doesn't have formulae, it has functions and methods. So you have >> to describe more completely > > what kind of formula you have, math, physics, chemistry? > > the formula is related to math. > > >> And how is one different than the next? > > > these formula are completely different each other and it is custom > formula. > for example, when I put 3 input into A formula, it outputs 1 result. > and when I put 3 input into B formula, it outputs 1 result > so each formula have 3 input for example > > A formula : f(x,y,z)=3x+4y+2z+3 > B formula : f(k,j,t)=2k+3j+2t+1 > > this formula is different each other which has 3 input. > and have only 1 result > > and if I loop this formula from 0 to N(for example : N = 3) > if N=1, the result will be different each other. and N=2 too. > but when N=3, the result will be same each other. > Since N isn't a parameter to either function, the results can never change. > so I wanted to prove this. by drawing shape or something so that children > can be understand easily. > > >> > I'm still trying to help you clarify your problem, but you are getting much closer. Those two formulae take three arguments (although you should use the same name for the arguments if the comparison is to mean anything). N doesn't come into it at all. Perhaps by N you mean tuples like (2,1,1) and (4,2,1), and you want to know for which tuples the result will be the same. That could be represented by some 4 dimensional graph, but I don't know any graphing package that could show it, in python or otherwise. -- DaveA From no at mail.de Tue Nov 1 11:04:26 2011 From: no at mail.de (MrSmile) Date: Tue, 01 Nov 2011 16:04:26 +0100 Subject: sending more then 2 messages to SocketServer fasils In-Reply-To: <7699e647-98fb-4a6e-aff4-1694d06fd705@h39g2000prh.googlegroups.com> References: <7699e647-98fb-4a6e-aff4-1694d06fd705@h39g2000prh.googlegroups.com> Message-ID: <4eb00a7a$0$6560$9b4e6d93@newsspool4.arcor-online.net> Hi people! I have asked myself why I am not capable sending 2 messages a time to a Socketserver. Why is that?! Here the Server: import SocketServer from ast import literal_eval class MKTest(object): DSX = [] MKTestInst = None def __init__(self,Daten): MKTest.DSX.append(Daten) def getObj(Daten): if MKTest.MKTestInst == None: MKTest.MKTestInst = MKTest(Daten) return MKTest.MKTestInst getObj = staticmethod(getObj) class MySockX(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) data = literal_eval(data) #MKTest.getObj(data[0]) #MKObj = MKTest(data[0]) MKObj = MKTest.getObj(data[0]) data = MKTest.DSX data = '%s' % data self.request.send(data) if __name__ == "__main__": HOST, PORT = "localhost", 9999 server = SocketServer.TCPServer((HOST,PORT),MySockX) server.serve_forever() and the client: import socket data = [100] received = [None,None] HOST,PORT = "localhost",9999 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((HOST, PORT)) sock.send('%s' % data) received[0] = sock.recv(1024) sock.send('%s' % data) received[1] = sock.recv(1024) sock.close() print received The result is: ['[100]', ''] who can help me solving this problem Tamer From gnarlodious at gmail.com Tue Nov 1 11:05:16 2011 From: gnarlodious at gmail.com (Gnarlodious) Date: Tue, 1 Nov 2011 08:05:16 -0700 (PDT) Subject: Assign values from list to list of instances Message-ID: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This works, even though it reads like doggerel. Is there a more pythonesque way using map or comprehension? -- Gnarlie From no at mail.de Tue Nov 1 11:07:09 2011 From: no at mail.de (MrSmile) Date: Tue, 01 Nov 2011 16:07:09 +0100 Subject: sending more then 2 messages at a time to a SocketServer fails Message-ID: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> Hi people! I have asked myself why I am not capable sending 2 messages a time to a Socketserver. Why is that?! Here the Server: import SocketServer from ast import literal_eval class MKTest(object): DSX = [] MKTestInst = None def __init__(self,Daten): MKTest.DSX.append(Daten) def getObj(Daten): if MKTest.MKTestInst == None: MKTest.MKTestInst = MKTest(Daten) return MKTest.MKTestInst getObj = staticmethod(getObj) class MySockX(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) data = literal_eval(data) #MKTest.getObj(data[0]) #MKObj = MKTest(data[0]) MKObj = MKTest.getObj(data[0]) data = MKTest.DSX data = '%s' % data self.request.send(data) if __name__ == "__main__": HOST, PORT = "localhost", 9999 server = SocketServer.TCPServer((HOST,PORT),MySockX) server.serve_forever() and the client: import socket data = [100] received = [None,None] HOST,PORT = "localhost",9999 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((HOST, PORT)) sock.send('%s' % data) received[0] = sock.recv(1024) sock.send('%s' % data) received[1] = sock.recv(1024) sock.close() print received The result is: ['[100]', ''] who can help me solving this problem Tamer From __peter__ at web.de Tue Nov 1 11:22:02 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Nov 2011 16:22:02 +0100 Subject: Assign values from list to list of instances References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: Gnarlodious wrote: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is there a more > pythonesque way using map or comprehension? for order, place in zip(Orders, locus): order.locus = place From d at davea.name Tue Nov 1 11:31:38 2011 From: d at davea.name (Dave Angel) Date: Tue, 01 Nov 2011 11:31:38 -0400 Subject: Assign values from list to list of instances In-Reply-To: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: <4EB010DA.3040400@davea.name> On 11/01/2011 11:05 AM, Gnarlodious wrote: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is there a more > pythonesque way using map or comprehension? > > -- Gnarlie You can do that with the enumerate function, or with zip for index, instance in enumerate(Orders): instance.locus = locus[index] for instance, place in zip(Orders, locus): instance.locus = locus[index] It would be clearer if you used singular for individual items, and plural for the collections, loci [-2, 21, .... orders = [list of order objects ...] for order, locus in zip(orders, loci): order.locus = locus -- DaveA From christopherbl at gmail.com Tue Nov 1 11:33:28 2011 From: christopherbl at gmail.com (cpbl) Date: Tue, 1 Nov 2011 08:33:28 -0700 (PDT) Subject: modified legend appears out of view! It didn't used to. MWE included. Message-ID: <9794fb7a-db8f-48bd-8254-405f4cf23794@s32g2000prj.googlegroups.com> I seem to be using Python 2.7.2+ (latest update of Ubuntu). The following code used to work nicely, but now gives me an unreadable legend. The legend is showing up mostly out of view below and to the left of the figure. Does that happen for you? Is there a regression bug, or am I doing something wrong? The MWE below is adapted from a function I wrote to allow addition of extra comments within a legend box below the normal legend details. Thanks for any help! Chris !/usr/bin/python import pylab as plt from matplotlib.offsetbox import TextArea, VPacker comments='foodlefish' plt.figure(1) plt.plot([1,2],[3,4], label='test') lh=plt.legend(fancybox=True,shadow=False,title='Foodle',loc='best') if lh: lh.get_frame().set_alpha(0.5) fontsize=lh.get_texts()[0].get_fontsize() legendcomment=TextArea('\n'.join(comments), textprops=dict(size=fontsize)) lh._legend_box = VPacker(pad=5, sep=0, children=[lh._legend_box,legendcomment], align="right") # Or should it be centre? lh._legend_box.set_figure(plt.gcf()) plt.show() From buzzard at urubu.freeserve.co.uk Tue Nov 1 11:37:20 2011 From: buzzard at urubu.freeserve.co.uk (duncan smith) Date: Tue, 01 Nov 2011 15:37:20 +0000 Subject: Assign values from list to list of instances In-Reply-To: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: On 01/11/11 15:05, Gnarlodious wrote: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is there a more > pythonesque way using map or comprehension? > for obj, val in zip(Orders, locus): obj.locus = val I'm not sure how worthwhile it is converting the above to a list comprehension (when the list would just be thrown away). Having said that the call to zip creates an unnecessary list. You could use izip or maybe, for i, val in enumerate(locus): Orders[i].locus = val Duncan From ulrich.eckhardt at dominolaser.com Tue Nov 1 11:40:52 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 01 Nov 2011 16:40:52 +0100 Subject: Assign values from list to list of instances In-Reply-To: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: <4hg5o8-kt3.ln1@satorlaser.homedns.org> Am 01.11.2011 16:05, schrieb Gnarlodious: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is there a more > pythonesque way using map or comprehension? Use enumerate: for object, index in enumerate(Orders): object.locus = locus[index] I'm not 100% I understood your description though, but it looks like this would do what you want and be descriptive at the same time. Uli From stefan_ml at behnel.de Tue Nov 1 11:57:02 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 01 Nov 2011 16:57:02 +0100 Subject: C API: Making a context manager In-Reply-To: References: Message-ID: Chris Kaynor, 31.10.2011 19:34: > I am currently rewritting a class using the Python C API to improve > performance of it, however I have not been able to find any > documentation about how to make a context manager using the C API. You should take a look at Cython. It makes these things *so* much easier. > The code I am working to produce is the following (its a method of a class): > > @contextlib.contextmanager > def connected(self, *args, **kwargs): > connection = self.connect(*args, **kwargs) > try: > yield > finally: > connection.disconnect() You can use the above in Cython code unmodified, and it's likely going to be good enough (depending on what kind of connection we are talking about here). In case that's also performance critical, however, it's likely faster to spell it out as a class, i.e. ... def connected(self, *args, **kwargs): return ConnectionManager(self, args, kwargs) cdef class ConnectionManager: cdef object args, kwargs, connection, connect def __init__(self, connector, args, kwargs): self.args, self.kwargs = args, kwargs self.connect = connector.connect def __enter__(self): self.connection = self.connect(*self.args, **self.kwargs) def __exit__(self, *exc): self.connection.disconnect() return True # or False? I always forget which means what Not that much longer either. Stefan From miki.tebeka at gmail.com Tue Nov 1 12:13:21 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Tue, 1 Nov 2011 09:13:21 -0700 (PDT) Subject: sending more then 2 messages at a time to a SocketServer fails In-Reply-To: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> References: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <14258539.1164.1320164001987.JavaMail.geo-discussion-forums@prgt10> MKTest.getObj(data[0]) will return the same object on every call(with the same data that was initialized 1'st time). Any Daten parameter after the 1'st call is ignored. From ckaynor at zindagigames.com Tue Nov 1 12:19:46 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 1 Nov 2011 09:19:46 -0700 Subject: C API: Making a context manager In-Reply-To: References: Message-ID: On Tue, Nov 1, 2011 at 8:57 AM, Stefan Behnel wrote: > Chris Kaynor, 31.10.2011 19:34: >> >> I am currently rewritting a class using the Python C API to improve >> performance of it, however I have not been able to find any >> documentation about how to make a context manager using the C API. > > You should take a look at Cython. It makes these things *so* much easier. Unfortunately, all of the code has to be fully compatible with CPython 2.6 - it needs to function inside of Maya, which has CPython 2.6 embedded, and to which we do not have the source code. While not all parts of our code base are used inside of Maya, most of the performance-critical items are to some degree or another. In this particular case, the connected context manager is not heavily used (outside of unittests) and itself is not performance critical, but the much of the rest of the package (and thus the class) it is part of is. Chris From chen.1381 at gmail.com Tue Nov 1 12:57:56 2011 From: chen.1381 at gmail.com (Wei) Date: Tue, 1 Nov 2011 09:57:56 -0700 (PDT) Subject: Does anyone use Python Tools for visual studio? Message-ID: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> I got several buggy things going on. First, the view of class tree stops expanding after creating more than two classes. Second, after 800 lines of code the classes and methods can't be folded. (meaning the + sign is gone) P.S. there is no warning or errors in my code. From chen.1381 at gmail.com Tue Nov 1 13:01:21 2011 From: chen.1381 at gmail.com (Wei) Date: Tue, 1 Nov 2011 10:01:21 -0700 (PDT) Subject: Does anyone use Python Tools for visual studio? References: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> Message-ID: <202fcd81-b383-4909-8112-33999df09512@t38g2000prg.googlegroups.com> On Nov 1, 12:57?pm, Wei wrote: > I got several buggy things going on. > First, the view of class tree stops expanding after creating more than > two classes. > Second, after 800 lines of code the classes and methods can't be > folded. (meaning the + sign is gone) > P.S. there is no warning or errors in my code. Also, I am using 64 bit win7 professional. From stefan_ml at behnel.de Tue Nov 1 13:03:12 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 01 Nov 2011 18:03:12 +0100 Subject: C API: Making a context manager In-Reply-To: References: Message-ID: Chris Kaynor, 01.11.2011 17:19: > On Tue, Nov 1, 2011 at 8:57 AM, Stefan Behnel wrote: >> Chris Kaynor, 31.10.2011 19:34: >>> I am currently rewritting a class using the Python C API to improve >>> performance of it, however I have not been able to find any >>> documentation about how to make a context manager using the C API. >> >> You should take a look at Cython. It makes these things *so* much easier. > > Unfortunately, all of the code has to be fully compatible with CPython > 2.6 - it needs to function inside of Maya, which has CPython 2.6 > embedded, and to which we do not have the source code. This sounds like you're misunderstanding what Cython is. Cython compiles (and optimises) your Python code into fast C code that uses the C-API (and that can happily call into external C code etc.). So you get basically the same (and sometimes better) speed, but without all the C-level hassle and maintenance issues. The C code that Cython generates is fully compatible with CPython 2.4 up to the latest 3.3, and that includes 2.6. > While not all parts of our code base are used inside of Maya, most of > the performance-critical items are to some degree or another. > > In this particular case, the connected context manager is not heavily > used (outside of unittests) and itself is not performance critical, > but the much of the rest of the package (and thus the class) it is > part of is. In that case, I advise you to leave the context manager code as is, and just compile the module that you are trying to speed up (and which, IIUC is currently written in Python) with Cython, then optimise the parts of it that need more speed by injecting static typing. Here's a quick howto: http://docs.cython.org/src/quickstart/cythonize.html Stefan From abhishek.vit at gmail.com Tue Nov 1 13:31:34 2011 From: abhishek.vit at gmail.com (Abhishek Pratap) Date: Tue, 1 Nov 2011 10:31:34 -0700 Subject: Module for Python and SGE interaction In-Reply-To: References: Message-ID: Hey Guys Pushing this one again just in case it was missed last night. Best, -Abhi On Mon, Oct 31, 2011 at 10:31 PM, Abhishek Pratap wrote: > Hey Guys > > I shud mention I am relative new to the language. Could you please let me > know based on your experience which module could help me with farm out jobs > to our existing clusters(we use SGE here) using python. > > Ideally I would like to do the following. > > 1. Submit #N jobs to cluster > 2. monitor their progress > 3. When all #N finishes, push another set of jobs > > Thanks! > -Abhi > -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Tue Nov 1 13:56:25 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 01 Nov 2011 17:56:25 +0000 Subject: sending more then 2 messages at a time to a SocketServer fails In-Reply-To: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> References: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <4EB032C9.5060104@mrabarnett.plus.com> On 01/11/2011 15:07, MrSmile wrote: > Hi people! > I have asked myself why I am not capable sending 2 messages a time to a > Socketserver. Why is that?! > > > Here the Server: > > import SocketServer > from ast import literal_eval > > class MKTest(object): > DSX = [] > MKTestInst = None > > def __init__(self,Daten): > MKTest.DSX.append(Daten) > > def getObj(Daten): > if MKTest.MKTestInst == None: > MKTest.MKTestInst = MKTest(Daten) > return MKTest.MKTestInst > > getObj = staticmethod(getObj) > > class MySockX(SocketServer.BaseRequestHandler): > def handle(self): > data = self.request.recv(1024) > data = literal_eval(data) > #MKTest.getObj(data[0]) > #MKObj = MKTest(data[0]) > MKObj = MKTest.getObj(data[0]) > data = MKTest.DSX > data = '%s' % data > self.request.send(data) > > if __name__ == "__main__": > HOST, PORT = "localhost", 9999 > server = SocketServer.TCPServer((HOST,PORT),MySockX) > server.serve_forever() > [snip] I think that in the 'handle' function you should be putting the code in a 'while' loop: def handle(self): # The client has opened a socket to the server. while True: data = self.request.recv(1024) if not data: # The client has closed the socket to the server. break ... From duncan.booth at invalid.invalid Tue Nov 1 14:54:09 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 1 Nov 2011 18:54:09 GMT Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' > MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) > > # Untested > def is_ascii_text(text): > for c in text: > n = ord(c) > if n >= len(MASK) or MASK[n] == '\0': return False > return True > > > Optimizing it is left as an exercise :) > #untested LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' MASK = [True if chr(n) in LEGAL else False for n in range(128)] # Untested def is_ascii_text(text): try: return all(MASK[ord(c)] for c in text) except IndexError: return False -- Duncan Booth http://kupuguy.blogspot.com From th982a at googlemail.com Tue Nov 1 15:12:46 2011 From: th982a at googlemail.com (Tamer Higazi) Date: Tue, 01 Nov 2011 20:12:46 +0100 Subject: sending more then 2 messages at a time to a SocketServer fails In-Reply-To: <14258539.1164.1320164001987.JavaMail.geo-discussion-forums@prgt10> References: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> <14258539.1164.1320164001987.JavaMail.geo-discussion-forums@prgt10> Message-ID: <4EB044AE.1020207@googlemail.com> Am 01.11.2011 17:13, schrieb Miki Tebeka: > MKTest.getObj(data[0]) will return the same object on every call(with the same data that was initialized 1'st time). Any Daten parameter after the 1'st call is ignored. Not true! The singleton object has nothing todo. Here one more example for you: Client: import socket data = ['Tamer'] received = [None,None] HOST,PORT = "localhost",9999 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((HOST, PORT)) sock.send('%s' % data) received[0] = sock.recv(1024) sock.send('%s' % data) received[1] = sock.recv(1024) sock.close() print received Server: import SocketServer from ast import literal_eval class MySockX(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) data = literal_eval(data) data = '%s' % data[0] self.request.send('%s %s' % ('Halloaaa',data)) if __name__ == "__main__": HOST, PORT = "localhost", 9999 server = SocketServer.TCPServer((HOST,PORT),MySockX) server.serve_forever() with it's result: ['Halloaaa Tamer', ''] the 2nd argument from the list is EMPTY. Now tell me why?! From th982a at googlemail.com Tue Nov 1 15:14:57 2011 From: th982a at googlemail.com (Tamer Higazi) Date: Tue, 01 Nov 2011 20:14:57 +0100 Subject: Does anyone use Python Tools for visual studio? In-Reply-To: <202fcd81-b383-4909-8112-33999df09512@t38g2000prg.googlegroups.com> References: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> <202fcd81-b383-4909-8112-33999df09512@t38g2000prg.googlegroups.com> Message-ID: <4EB04531.8090207@googlemail.com> buy wingIDE or use PyDEV If you tell me that you are using IronPython then buy wingIDE, there you can make use of the .net classes in python too. Tamer Am 01.11.2011 18:01, schrieb Wei: > On Nov 1, 12:57 pm, Wei wrote: >> I got several buggy things going on. >> First, the view of class tree stops expanding after creating more than >> two classes. >> Second, after 800 lines of code the classes and methods can't be >> folded. (meaning the + sign is gone) >> P.S. there is no warning or errors in my code. > > Also, I am using 64 bit win7 professional. From ian.g.kelly at gmail.com Tue Nov 1 15:25:42 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 1 Nov 2011 13:25:42 -0600 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? In-Reply-To: <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4EAF175A.6060508@davea.name> <4EAF1C40.6030202@davea.name> <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> Message-ID: On Mon, Oct 31, 2011 at 6:32 PM, Patrick Maupin wrote: > On Oct 31, 5:52?pm, Ian Kelly wrote: >>?For instance, split() will split on vertical tab, >> which is not one of the characters the OP wanted. > > That's just the default behavior. ?You can explicitly specify the > separator to split on. ?But it's probably more efficient to just use > translate with deletechars. As I understood it, the point of using the default behavior was to merge whitespace, which cannot be done when the separator is explicitly specified. For example: >>> " ".split() [] >>> " ".split(" ") ['', '', '', '', '', ''] It is easy to check that the first is empty. The second is a bit more annoying and is O(n). Your point about deletechars is good, though, definitely better than a regular expression. From tres.bailey at gmail.com Tue Nov 1 15:26:19 2011 From: tres.bailey at gmail.com (tres.bailey at gmail.com) Date: Tue, 1 Nov 2011 12:26:19 -0700 (PDT) Subject: getting columns attributes in declarative style with sqlalchemy In-Reply-To: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> References: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> Message-ID: <17209707.1599.1320175579736.JavaMail.geo-discussion-forums@vbak12> Hi Gabriele, I'm not an Alchemy expert, but I have used the ColumnProperty of the model/column objects to solve this problem in the past. So to get the column name for the description column in your example above, you would use the following syntax: Country.description.property.columns[0].name And this would avoid having to use additional objects than the one you're working on. The ColumnProperty object (and the Column object attribute it contains) will provide you with information such as column name, type, default vals, primary_key, and nullable. You could also get more generic by iterating through your model object's __table__ attribute and grab each column: [col.name for col in Country.__table__.columns._all_cols] More information can be found here: http://www.sqlalchemy.org/docs/core/schema.html?highlight=schema.column#sqlalchemy.schema.Column and http://www.sqlalchemy.org/docs/orm/internals.html?highlight=columnproperty#sqlalchemy.orm.properties.ColumnProperty From pacopyc at gmail.com Tue Nov 1 15:27:16 2011 From: pacopyc at gmail.com (pacopyc) Date: Tue, 1 Nov 2011 12:27:16 -0700 (PDT) Subject: understand program used to create file Message-ID: Hi, I have about 10000 files .doc and I want know the program used to create them: writer? word? abiword? else? I'd like develop a script python to do this. Is there a module to do it? Can you help me? Thanks From python at mrabarnett.plus.com Tue Nov 1 15:29:50 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 01 Nov 2011 19:29:50 +0000 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? In-Reply-To: References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4EB048AE.2030301@mrabarnett.plus.com> On 01/11/2011 18:54, Duncan Booth wrote: > Steven D'Aprano wrote: > >> LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' >> MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) >> >> # Untested >> def is_ascii_text(text): >> for c in text: >> n = ord(c) >> if n>= len(MASK) or MASK[n] == '\0': return False >> return True >> >> >> Optimizing it is left as an exercise :) >> > > #untested > LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' > MASK = [True if chr(n) in LEGAL else False for n in range(128)] > Instead of: True if chr(n) in LEGAL else False why not: if chr(n) in LEGAL > # Untested > def is_ascii_text(text): > try: > return all(MASK[ord(c)] for c in text) > except IndexError: > return False > From Ric at rdo Tue Nov 1 15:34:46 2011 From: Ric at rdo (Ric at rdo) Date: Tue, 01 Nov 2011 14:34:46 -0500 Subject: Sort items in wxListCtrl Message-ID: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> I am trying to create a small application in wxPython and would like to ask for some help. I am trying to display folders and files in ListCtrl but sorted first folders followed by files (like in a file manager style) but not sure how to do this? Would I need to do this in code somehow or ListCtrl would help me? I am trying to do this and learn at the same time. Would appreciate any advice. Thank you. From tres.bailey at gmail.com Tue Nov 1 15:37:42 2011 From: tres.bailey at gmail.com (tres.bailey at gmail.com) Date: Tue, 1 Nov 2011 12:37:42 -0700 (PDT) Subject: getting columns attributes in declarative style with sqlalchemy In-Reply-To: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> References: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> Message-ID: <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> Sorry for the repost, if it does in fact repost. I'm no SQLAlchemy expert, but I have used the Table and Column attribute objects from the model object to solve a similar problem in the past. You can use the following syntax to do it: [col.name for col in Country.__table__.columns._all_cols] which should return you a list of ['cancelled', 'description']. You can find more information on the attributes you are using here: http://www.sqlalchemy.org/docs/core/schema.html?highlight=schema.column#sqlalchemy.schema.Column and http://www.sqlalchemy.org/docs/core/schema.html?highlight=schema.table#sqlalchemy.schema.Table From stefan_ml at behnel.de Tue Nov 1 15:47:02 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 01 Nov 2011 20:47:02 +0100 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? In-Reply-To: <1320090874.6062.140660992866273@webmail.messagingengine.com> References: <1320090874.6062.140660992866273@webmail.messagingengine.com> Message-ID: python at bdurham.com, 31.10.2011 20:54: > Wondering if there's a fast/efficient built-in way to determine > if a string has non-ASCII chars outside the range ASCII 32-127, > CR, LF, or Tab? > > I know I can look at the chars of a string individually and > compare them against a set of legal chars using standard Python > code (and this works fine), but I will be working with some very > large files in the 100's Gb to several Tb size range so I'd > thought I'd check to see if there was a built-in in C that might > handle this type of check more efficiently. > > Does this sound like a use case for cython or pypy? Cython. For data of that size, likely read from a fast local RAID drive I guess, you certainly don't want to read (part of) the file into a memory buffer, then copy that memory buffer into a Python bytes string, and then search it character by character, copying each of the characters into a new string object just to compare them. Instead, you'd want to use low-level I/O to read a not-so-small part of the file into a memory buffer, run through it looking for unwanted characters, and then read the next chunk, without any further copying. The comparison loop could look like this, for example: cdef unsigned char current_byte cdef unsigned char* byte_buffer = libc.stdlib.malloc(BUFFER_SIZE) # while read chunk ... for current_byte in byte_buffer[:BUFFER_SIZE]: if current_byte < 32 or current_byte > 127: if current_byte not in b'\t\r\n': raise ValueError() What kind of I/O API you use is up to you. You may want to use the functions declared in libc.stdio (ships with Cython). Stefan From d at davea.name Tue Nov 1 16:08:50 2011 From: d at davea.name (Dave Angel) Date: Tue, 01 Nov 2011 16:08:50 -0400 Subject: understand program used to create file In-Reply-To: References: Message-ID: <4EB051D2.4000204@davea.name> On 11/01/2011 03:27 PM, pacopyc wrote: > Hi, I have about 10000 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? > > Thanks If you're on Linux, just use the process module to invoke "file" and examine the results. If you're not, then be more specific about the environment. -- DaveA From gagsl-py2 at yahoo.com.ar Tue Nov 1 16:22:25 2011 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Nov 2011 17:22:25 -0300 Subject: When I use Python under Windows. I found some file handles are not closed, References: Message-ID: En Mon, 31 Oct 2011 12:57:15 -0300, ???(Yonggang Luo) escribi?: > How did detecting where those handlers are created to tracing it and > close > it. > Mainly because I was using C binding library(subvertpy) and file is not > closed. A better place to ask is python-list at python.org Please include the Python version you're using. Also, a small, complete, runnable code example showing the problem would be very valuable. Usually, in building such example, you may well find out where your problem is. -- Gabriel Genellina From duncan.booth at invalid.invalid Tue Nov 1 16:47:26 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 1 Nov 2011 20:47:26 GMT Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: MRAB wrote: > On 01/11/2011 18:54, Duncan Booth wrote: >> Steven D'Aprano wrote: >> >>> LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' >>> MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range (128)) >>> >>> # Untested >>> def is_ascii_text(text): >>> for c in text: >>> n = ord(c) >>> if n>= len(MASK) or MASK[n] == '\0': return False >>> return True >>> >>> >>> Optimizing it is left as an exercise :) >>> >> >> #untested >> LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' >> MASK = [True if chr(n) in LEGAL else False for n in range(128)] >> > Instead of: > > True if chr(n) in LEGAL else False > > why not: > > if chr(n) in LEGAL > I think you meant to drop the 'if' also. MASK = [chr(n) in LEGAL for n in range(128)] But yes, I was concentrating on the function body rather than the initialisation. -- Duncan Booth http://kupuguy.blogspot.com From rosuav at gmail.com Tue Nov 1 16:53:47 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Nov 2011 07:53:47 +1100 Subject: understand program used to create file In-Reply-To: References: Message-ID: On Wed, Nov 2, 2011 at 6:27 AM, pacopyc wrote: > Hi, I have about 10000 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? > Technically, you can't find out just from the file what it was that created it. But if you mean "figure out what type of file each one is" (eg recognize an ODF, a PDF, a DOC, etc), then the easiest way is to read in the first few bytes of the file and look for well-known magic numbers[1]. As Dave says, Linux comes with a command that does exactly that (and a bit more), called 'file'. ChrisA [1] http://en.wikipedia.org/wiki/Magic_number_(programming) From joncle at googlemail.com Tue Nov 1 16:58:42 2011 From: joncle at googlemail.com (Jon Clements) Date: Tue, 1 Nov 2011 13:58:42 -0700 (PDT) Subject: understand program used to create file References: Message-ID: On Nov 1, 7:27?pm, pacopyc wrote: > Hi, I have about 10000 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? > > Thanks My suggestion would be the same as DaveA's. This gives you the format it was *written* in. (Saved a blank OO document as 95/97/XP Word DOC under Linux) jon at forseti:~/filetest$ file * saved-by-OO.doc: CDF V2 Document, Little Endian, Os: Windows, Version 1.0, Code page: -535, Author: jon , Revision Number: 0, Create Time/ Date: Mon Oct 31 20:47:30 2011 I'd be impressed if you could discover the program that did *write* it; I'd imagine you'd need something that understood some meta-data in the format (if the format has a kind of 'created_by' field, for instance), or depend on nuisances which give away that a certain program wrote data in another's native format. Assuming the former, what might be possible: 1) Grab a "magic number" lookup list 2) Grab 8 (I think that should be all that's needed, but hey ummm..) bytes from the start of each file 3) Look it up in the "magic number" list 4) If you got something great, if not compare 7, 6, 5, 4 bytes... etc... until you get a hit or bail out (Or just find a Windows port of 'file') HTH Jon. From brian.curtin at gmail.com Tue Nov 1 17:16:39 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 1 Nov 2011 16:16:39 -0500 Subject: Does anyone use Python Tools for visual studio? In-Reply-To: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> References: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> Message-ID: On Tue, Nov 1, 2011 at 11:57, Wei wrote: > I got several buggy things going on. > First, the view of class tree stops expanding after creating more than > two classes. > Second, after 800 lines of code the classes and methods can't be > folded. (meaning the + sign is gone) > P.S. there is no warning or errors in my code. > -- > http://mail.python.org/mailman/listinfo/python-list > Yes, I use it. If you're having issues with it, you should report them at http://pytools.codeplex.com/ From tjreedy at udel.edu Tue Nov 1 17:33:34 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Nov 2011 17:33:34 -0400 Subject: Assign values from list to list of instances In-Reply-To: References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: On 11/1/2011 11:37 AM, duncan smith wrote: > On 01/11/11 15:05, Gnarlodious wrote: >> I want to assign a list of variables: >> locus=[-2, 21, -10, 2, 12, -11, 0, 3] >> >> updating a list of objects each value to its respective instance: >> >> for order in range(len(Orders)): >> Orders[order].locus=locus[order] >> >> This works, even though it reads like doggerel. Is there a more >> pythonesque way using map or comprehension? >> > > for obj, val in zip(Orders, locus): > obj.locus = val > > > I'm not sure how worthwhile it is converting the above to a list > comprehension (when the list would just be thrown away). Having said > that the call to zip creates an unnecessary list. Not in Py 3 -- Terry Jan Reedy From wonjunchoi001 at gmail.com Tue Nov 1 17:35:11 2011 From: wonjunchoi001 at gmail.com (pyman) Date: Tue, 1 Nov 2011 14:35:11 -0700 (PDT) Subject: proving two formula are same each other! References: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> <4EAFE35A.7080106@davea.name> Message-ID: <965c33e2-8ba4-4278-9517-730ce4639492@d33g2000prb.googlegroups.com> first of all, thank you for trying to understand my issue. do you know sigma? I omitted sigma it means sum... From pauldavidmena at gmail.com Tue Nov 1 18:13:25 2011 From: pauldavidmena at gmail.com (extraspecialbitter) Date: Tue, 1 Nov 2011 15:13:25 -0700 (PDT) Subject: parsing text from "ethtool" command Message-ID: I'm still trying to write that seemingly simple Python script to print out network interfaces (as found in the "ifconfig -a" command) and their speed ("ethtool "). The idea is to loop for each interface and print out its speed. I'm looping correctly, but have some issues parsing the output for all interfaces except for the "pan0" interface. I'm running on eth1, and the "ifconfig -a" command also shows an eth0, and of course lo. My script is trying to match on the string "Speed", but I never seem to successfully enter the "if" clause. First, here is the output of "ethtool eth1": ================= Settings for eth1: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on MDI-X: off Supports Wake-on: pumbag Wake-on: g Current message level: 0x00000001 (1) Link detected: yes ================= The script *should* match on the string "Speed" and then assign "100Mb/ s" to a variable, but is never getting past the second if statement below: ================= #!/usr/bin/python # Quick and dirty script to print out available interfaces and their speed # Initializations output = " Interface: %s Speed: %s" noinfo = "(Speed Unknown)" speed = noinfo import os, socket, types, subprocess fp = os.popen("ifconfig -a") dat=fp.read() dat=dat.split('\n') for line in dat: if line[10:20] == "Link encap": interface=line[:9] cmd = "ethtool " + interface gp = os.popen(cmd) fat=gp.read() fat=fat.split('\n') for line in fat: if line[0:6] == "Speed": try: speed=line[8:] except: speed=noinfo print output % (interface, speed) ================= Again, I appreciate everyone's patience, as I'm obviously I'm a python newbie. Thanks in advance! From whatsjacksemail at gmail.com Tue Nov 1 18:27:02 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Tue, 1 Nov 2011 22:27:02 +0000 Subject: Chaco for real-time plot of PySerial data Message-ID: Hi there, I asked this question on the enthought chaco mailing list some time last by have yet to receive a reply. Thought I'd ask here to see if anyone could shed some light on things for me. I have been considering using chaco / traits for close to a year now and am finally biting the bullet so to speak. What I would really like to do to begin with is to make a real-time plotting application which gets its data from the serial port. Can anyone please point me in the right direction for doing this? Since I didn't get a reply on the chaco list I'm now thinking it might be a dangerous route to go down since it will be difficult to get help. Any recommendations? Thanks very much, Jack -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From miki.tebeka at gmail.com Tue Nov 1 19:14:50 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Tue, 1 Nov 2011 16:14:50 -0700 (PDT) Subject: Sort items in wxListCtrl In-Reply-To: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> Message-ID: <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> Why not use the build in wx.FileDialog? Also, have a look at the demo that comes with wxPython. It has an example with a sortable list control. From miki.tebeka at gmail.com Tue Nov 1 19:19:25 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Tue, 1 Nov 2011 16:19:25 -0700 (PDT) Subject: parsing text from "ethtool" command In-Reply-To: References: Message-ID: <5544686.62.1320189565337.JavaMail.geo-discussion-forums@prog16> In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust. From steve+comp.lang.python at pearwood.info Tue Nov 1 19:24:34 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Nov 2011 23:24:34 GMT Subject: proving two formula are same each other! References: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> Message-ID: <4eb07fb2$0$29968$c3e8da3$5496439d@news.astraweb.com> On Tue, 01 Nov 2011 05:03:17 -0700, pyman wrote: > hello, I need some idea to prove two formula is same. Impossible. As you explained further on, they are different formula. If they are different, they aren't the same. This has nothing to do with Python. In another message, you tell us: "these formula are completely different each other" and give the formula: A formula : f(x,y,z)=3x+4y+2z+3 B formula : f(k,j,t)=2k+3j+2t+1 Perhaps what you mean is that you want to solve for when the two formula give equal results? Here's a simpler example: f(x) = 2x + 1 g(x) = 3x - 2 Solving for x: f(x) = g(x) 2x + 1 = 3x - 2 1 = 3x - 2 - 2x 1 + 2 = 3x - 2x 3 = x so the solution is x = 3, f(3) = 7 = g(3). This is also not easy, since you have SIX variables (x, y, z, k, j, t) and only two equations. This is known as an under-determined system, and means that there is no exact solution. Perhaps something like Mathematica could do something useful with it? Is there some way you can use the same variables in each formula? For example, if x=t, y=j, z=k (or some other combination), then you have a simpler three-dimensional problem: f(x,y,z) = 3x + 4y + 2z + 3 g(x,y,z) = 2z + 3y + 2x + 1 which is still under-determined, but not as badly (now you have three variables and only two equations). In any case, you *might* be able to solve this using numpy. http://numpy.scipy.org/ -- Steven From tjreedy at udel.edu Tue Nov 1 19:27:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Nov 2011 19:27:44 -0400 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? In-Reply-To: <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/1/2011 2:56 AM, Steven D'Aprano wrote: > On Mon, 31 Oct 2011 20:44:45 -0400, Terry Reedy wrote: > > [...] >>> def is_ascii_text(text): >>> for c in text: >>> if c not in LEGAL: >>> return False >>> return True >> >> If text is 3.x bytes, this does not work ;-). OP did not specify bytes >> or unicode or Python version. > > The OP specified *string*. A. People sometimes use 'string' loosely, to include text stored in bytes. B. We are solving slightly different problems. The OP specified terabytes of ascii text on disk that he wants to check for contamination. For that purpose, using 3.x, it is sensible to read the data in binary mode into bytes objects rather than decoding into unicode. (The exception would be if the text uses some 7 bit encoding like UTF-7. But that is relatively unlikely for disk storage.) It is irrelevant to that specified purpose whether one calls the internal implementation type a 'string' or not. While my 3.2 bytes version was only slightly faster, given data in memory, adding decoding time for your string version and any other extra overhead for text mode reading would make the bytes version look even better. I am pretty sure the best disk reading speed would come from reading blocks of 4k*N, for some N, in binary mode. If the Python code were compliled (with Cython, for instance), the process might be input bound, depending on the system. >> 'c in legal' has to get hash(c) and look >> that up in the hash table, possible skipping around a bit if t If text >> is byte string rather than unicode, a simple lookup 'mask[c]', where >> mask is a 0-1 byte array, should be faster (see my other post). > > Oooh, clever! I like! It's not necessary to assume bytes, nor is it > necessary to create a bitmask the size of the entire Unicode range. You are right; I had been thinking it would be. > Here's a version for strings (bytes or unicode in Python 2, unicode in > Python 3): > > LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' > MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) > > # Untested > def is_ascii_text(text): > for c in text: > n = ord(c) > if n>= len(MASK) or MASK[n] == '\0': return False > return True > Optimizing it is left as an exercise :) The test for n >= len() can be accomplished with try:..except IndexError around the loop construct. Then the explicit loop can be replaced with any(), as before. > I *suspect*, even with any optimizations, that this will be slower than > the version using a set. If you suspect that because of the need with true 'strings' for MASK[ord(c)] instead of MASK[c], you are right. Redoing the test runs with unicode strings instead of bytes, the set lookup time is about the same (9.2 seconds) whereas the 100 000 000 ord() calls add over 4 seconds to the MASK lookups, raising them up to 13.1 seconds. -- Terry Jan Reedy From ian.g.kelly at gmail.com Tue Nov 1 19:35:10 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 1 Nov 2011 17:35:10 -0600 Subject: parsing text from "ethtool" command In-Reply-To: <5544686.62.1320189565337.JavaMail.geo-discussion-forums@prog16> References: <5544686.62.1320189565337.JavaMail.geo-discussion-forums@prog16> Message-ID: On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka wrote: > In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust. Or simply: if "Speed" in line: There is no need for a regular expression here. This would also work and be a bit more discriminating: if line.strip().startswith("Speed") BTW, to the OP, note that your condition (line[0:6] == "Speed") cannot match, since line[0:6] is a 6-character slice, while "Speed" is a 5-character string. Cheers, Ian From tjreedy at udel.edu Tue Nov 1 19:41:28 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Nov 2011 19:41:28 -0400 Subject: Module for Python and SGE interaction In-Reply-To: References: Message-ID: On 11/1/2011 1:31 PM, Abhishek Pratap wrote: > On Mon, Oct 31, 2011 at 10:31 PM, Abhishek Pratap > > wrote: > > Hey Guys > > I shud mention I am relative new to the language. Could you please > let me know based on your experience which module could help me with > farm out jobs to our existing clusters(we use SGE here) using python. > > Ideally I would like to do the following. > > 1. Submit #N jobs to cluster > 2. monitor their progress > 3. When all #N finishes, push another set of jobs Have you searched with Google? on pypi.python.org? with what keywords? -- Terry Jan Reedy From Ric at rdo Tue Nov 1 21:13:17 2011 From: Ric at rdo (Ric at rdo) Date: Tue, 01 Nov 2011 20:13:17 -0500 Subject: Sort items in wxListCtrl References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> Message-ID: On Tue, 1 Nov 2011 16:14:50 -0700 (PDT), Miki Tebeka wrote: >Why not use the build in wx.FileDialog? > >Also, have a look at the demo that comes with wxPython. It has an example with a sortable list control. Thanks for responding, How would wx.FileDialog help me in this case? I am trying to display files and directories in the ListCtrl in sorted way. Folders first followed by files. From roy at panix.com Tue Nov 1 21:23:26 2011 From: roy at panix.com (Roy Smith) Date: Tue, 01 Nov 2011 21:23:26 -0400 Subject: sending more then 2 messages to SocketServer fasils References: <7699e647-98fb-4a6e-aff4-1694d06fd705@h39g2000prh.googlegroups.com> <4eb00a7a$0$6560$9b4e6d93@newsspool4.arcor-online.net> Message-ID: In article <4eb00a7a$0$6560$9b4e6d93 at newsspool4.arcor-online.net>, MrSmile wrote: > Hi people! > I have asked myself why I am not capable sending 2 messages a time to a > Socketserver. Why is that?! There's a lot of confusing code here. It would help when asking these kinds of questions to reduce it down to the smallest possible example that demonstrates your problem. I'm not sure what this MTTest class is all about, but I'm guessing it's not essential to demonstrate what's going wrong. Why not just send strings back and forth? Also, it would help to have names that made more sense. I have no idea what a MKTest is, or what DSX means. Names like that make it more difficult to read your code and understand what you probably intended. In any case, I think the problem is a basic misunderstanding of how stream sockets work. You're sending hunks of data with send() calls and expecting that the recv() calls will get the same data. That works with UDP (datagram sockets), but not TCP. There are no record boundaries in TCP. The system could buffer up the data from multiple send() calls and deliver them in a single recv(). Or break up one send() into multiple recv() calls. Or any combination. In any particular situation, the system will probably do whatever is most inconvenient, confusing, and damaging to your program :-) My recommendation is to strip out all the test gunk and get it down to the bare network calls. Send some strings back and forth, and print out what each send() call is sending and what each recv() call receives. Hopefully, things will start to make more sense then. > > > Here the Server: > > import SocketServer > from ast import literal_eval > > class MKTest(object): > DSX = [] > MKTestInst = None > > def __init__(self,Daten): > MKTest.DSX.append(Daten) > > def getObj(Daten): > if MKTest.MKTestInst == None: > MKTest.MKTestInst = MKTest(Daten) > return MKTest.MKTestInst > > getObj = staticmethod(getObj) > > class MySockX(SocketServer.BaseRequestHandler): > def handle(self): > data = self.request.recv(1024) > data = literal_eval(data) > #MKTest.getObj(data[0]) > #MKObj = MKTest(data[0]) > MKObj = MKTest.getObj(data[0]) > data = MKTest.DSX > data = '%s' % data > self.request.send(data) > > if __name__ == "__main__": > HOST, PORT = "localhost", 9999 > server = SocketServer.TCPServer((HOST,PORT),MySockX) > server.serve_forever() > > > > and the client: > > import socket > > data = [100] > received = [None,None] > HOST,PORT = "localhost",9999 > sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > sock.connect((HOST, PORT)) > sock.send('%s' % data) > received[0] = sock.recv(1024) > sock.send('%s' % data) > received[1] = sock.recv(1024) > sock.close() > > print received > > > > The result is: > > ['[100]', ''] > > > > who can help me solving this problem > > > > Tamer From cosmo_general at yahoo.com Tue Nov 1 22:59:10 2011 From: cosmo_general at yahoo.com (Muddy Coder) Date: Tue, 1 Nov 2011 19:59:10 -0700 (PDT) Subject: How filecmp walk into subdirectories? Message-ID: Hi Folks, I tried to compare two directories, each with hundreds of files in multiple level subdirectories, to find out the different files. I used filecmp module to the job as: comp=filecmp.dircmp(adir, bdir) comp.report() It worked, and printed out the identical and different files. However, it did not go through the directory trees, just did the job in the first level. I wonder somebody can help? Thanks in advance! Cosmo From gordon at panix.com Tue Nov 1 23:14:44 2011 From: gordon at panix.com (John Gordon) Date: Wed, 2 Nov 2011 03:14:44 +0000 (UTC) Subject: How filecmp walk into subdirectories? References: Message-ID: In Muddy Coder writes: > I tried to compare two directories, each with hundreds of files in > multiple level subdirectories, to find out the different files. I used > filecmp module to the job as: > comp=filecmp.dircmp(adir, bdir) > comp.report() > It worked, and printed out the identical and different files. However, > it did not go through the directory trees, just did the job in the > first level. I wonder somebody can help? Thanks in advance! report() only prints information on the first-level contents of the two directores, as you saw. It doesn't do subdirectories. If you want subdirectories, use report_full_closure(). -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From wuwei23 at gmail.com Tue Nov 1 23:22:57 2011 From: wuwei23 at gmail.com (alex23) Date: Tue, 1 Nov 2011 20:22:57 -0700 (PDT) Subject: understand program used to create file References: Message-ID: On Nov 2, 5:27?am, pacopyc wrote: > Hi, I have about 10000 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? Word documents store metadata inside of them, one field of which is the program used to create them. This shows you how to use pywin32 to access them: http://www.galalaly.me/index.php/2011/09/use-python-to-parse-microsoft-word-documents-using-pywin32-library/ This won't be a foolproof solution, unfortunately. A random examination of doc files shows that not all of them have the required field set. From kwa at kuwata-lab.com Wed Nov 2 00:02:40 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Wed, 2 Nov 2011 13:02:40 +0900 Subject: Question about metaclass Message-ID: Hi, I want to define a special class which groups functions, like: class Greepting(FuncGroup): def hello(): # no self, no @staticmethod! print("Hello!") def goodbye(): # no self, no @staticmethod! print("Good Bye!") Geeting.hello(): #=> "Hello!" Geeting.goodbye(): #=> "Good Bye!" I tried the following code which converts instance mthods into static method automatically, but I don't get result what I want. (python 2.5.5) import sys from types import FunctionType class MetaClass(type): def __init__(cls, name, bases, dct): ## converts instance methods to static methods automatically for k in dct.keys(): v = dct[k] if isinstance(v, FunctionType): dct[k] = staticmethod(v) print("*** debug: dct[%r] = %r" % (k, dct[k])) #=> class FuncGroup(object): __metaclass__ = MetaClass class Greeting(FuncGroup): def hello(): print("Hello!") def goodbye(): print("Good Bye!") print("*** type(Greeting.hello)=%r" % type(Greeting.hello) #=> print("*** type(Greeting.goodbye)=%r" % type(Greeting.goodbye) #=> Could you give me advice? -- regards, makoto kuwata From ian.g.kelly at gmail.com Wed Nov 2 00:40:17 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 1 Nov 2011 22:40:17 -0600 Subject: Question about metaclass In-Reply-To: References: Message-ID: On Tue, Nov 1, 2011 at 10:02 PM, Makoto Kuwata wrote: > I tried the following code which converts instance mthods into > static method automatically, but I don't get result what I want. > (python 2.5.5) > > ? ?import sys > ? ?from types import FunctionType > > ? ?class MetaClass(type): > ? ? ? ?def __init__(cls, name, bases, dct): > ? ? ? ? ? ?## converts instance methods to static methods automatically > ? ? ? ? ? ?for k in dct.keys(): > ? ? ? ? ? ? ? ?v = dct[k] > ? ? ? ? ? ? ? ?if isinstance(v, FunctionType): > ? ? ? ? ? ? ? ? ? ?dct[k] = staticmethod(v) > ? ? ? ? ? ? ? ? ? ?print("*** debug: dct[%r] = %r" % (k, dct[k])) If you want to customize the dict you need to do it in __new__, not __init__. By the time __init__ is called, the class has already been created. class MetaClass(type): def __new__(mcs, name, bases, dict): for k, v in dict.items(): if isinstance(v, FunctionType): dict[k] = staticmethod(v) return type.__new__(mcs, name, bases, dict) If you were using a more recent Python version, I would suggest using a class decorator instead of a metaclass. You can still do this in Python 2.5, but the syntax will be more awkward. # Python 2.6+ def FuncGroup(class_): for k, v in class_.__dict__.items(): if isinstance(v, FunctionType): setattr(class_, k, staticmethod(v)) return class_ @FuncGroup class Greeting(object): def hello(): print("Hello!") # Python 2.5 class Greeting(object): def hello(): print("Hello!") Greeting = FuncGroup(Greeting) Cheers, Ian From pmaupin at gmail.com Wed Nov 2 00:42:04 2011 From: pmaupin at gmail.com (Patrick Maupin) Date: Tue, 1 Nov 2011 21:42:04 -0700 (PDT) Subject: Question about metaclass References: Message-ID: <2dbd03f2-c93e-4457-8d57-9cc2ebe5223f@k10g2000yqn.googlegroups.com> On Nov 1, 11:02?pm, Makoto Kuwata wrote: > Hi, > > I want to define a special class which groups functions, like: > > ? ? class Greepting(FuncGroup): > ? ? ? ? def hello(): ? ? ? ? ?# no self, no @staticmethod! > ? ? ? ? ? ? print("Hello!") > ? ? ? ? def goodbye(): ? ? ? ?# no self, no @staticmethod! > ? ? ? ? ? ? print("Good Bye!") > > ? ? Geeting.hello(): ? ?#=> "Hello!" > ? ? Geeting.goodbye(): ?#=> "Good Bye!" > > I tried the following code which converts instance mthods into > static method automatically, but I don't get result what I want. > (python 2.5.5) > > ? ? import sys > ? ? from types import FunctionType > > ? ? class MetaClass(type): > ? ? ? ? def __init__(cls, name, bases, dct): > ? ? ? ? ? ? ## converts instance methods to static methods automatically > ? ? ? ? ? ? for k in dct.keys(): > ? ? ? ? ? ? ? ? v = dct[k] > ? ? ? ? ? ? ? ? if isinstance(v, FunctionType): > ? ? ? ? ? ? ? ? ? ? dct[k] = staticmethod(v) > ? ? ? ? ? ? ? ? ? ? print("*** debug: dct[%r] = %r" % (k, dct[k])) > #=> > > ? ? class FuncGroup(object): > ? ? ? ? __metaclass__ = MetaClass > > ? ? class Greeting(FuncGroup): > ? ? ? ? def hello(): > ? ? ? ? ? ? print("Hello!") > ? ? ? ? def goodbye(): > ? ? ? ? ? ? print("Good Bye!") > > ? ? print("*** type(Greeting.hello)=%r" % type(Greeting.hello) > #=> > ? ? print("*** type(Greeting.goodbye)=%r" % type(Greeting.goodbye) > #=> > > Could you give me advice? > > -- > regards, > makoto kuwata I think you need to unwrap the instance methods first: >>> class foo(object): ... def bar(): ... print "Hi there" ... >>> foo.bar2 = staticmethod(foo.bar.im_func) >>> >>> foo.bar2() Hi there >>> From gnarlodious at gmail.com Wed Nov 2 00:52:16 2011 From: gnarlodious at gmail.com (Gnarlodious) Date: Tue, 1 Nov 2011 21:52:16 -0700 (PDT) Subject: Assign values from list to list of instances References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: <99202d33-48d2-4148-942c-bd2210971b28@s35g2000pra.googlegroups.com> On Nov 1, 3:33?pm, Terry Reedy wrote: > > for obj, val in zip(Orders, locus): > > obj.locus = val > > > I'm not sure how worthwhile it is converting the above to a list > > comprehension (when the list would just be thrown away). Having said > > that the call to zip creates an unnecessary list. > > Not in Py 3 Thanks for that tip, this works well in Py3. -- Gnarlie From kwa at kuwata-lab.com Wed Nov 2 00:58:41 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Wed, 2 Nov 2011 13:58:41 +0900 Subject: Question about metaclass In-Reply-To: References: Message-ID: On Wed, Nov 2, 2011 at 1:40 PM, Ian Kelly wrote: > > If you want to customize the dict you need to do it in __new__, not > __init__. ?By the time __init__ is called, the class has already been > created. > > class MetaClass(type): > ? ?def __new__(mcs, name, bases, dict): > ? ? ? ?for k, v in dict.items(): > ? ? ? ? ? ?if isinstance(v, FunctionType): > ? ? ? ? ? ? ? ?dict[k] = staticmethod(v) > ? ? ? ?return type.__new__(mcs, name, bases, dict) Great! It works perfectly! > If you were using a more recent Python version, I would suggest using > a class decorator instead of a metaclass. ?You can still do this in > Python 2.5, but the syntax will be more awkward. > > # Python 2.6+ > def FuncGroup(class_): > ? ?for k, v in class_.__dict__.items(): > ? ? ? ?if isinstance(v, FunctionType): > ? ? ? ? ? ?setattr(class_, k, staticmethod(v)) > ? ?return class_ > > @FuncGroup > class Greeting(object): > ? ?def hello(): > ? ? ? ?print("Hello!") > > # Python 2.5 > class Greeting(object): > ? ?def hello(): > ? ? ? ?print("Hello!") > Greeting = FuncGroup(Greeting) This is so good method. Thank you, Ian. -- regards, makoto kuwata From devplayer at gmail.com Wed Nov 2 01:50:48 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 1 Nov 2011 22:50:48 -0700 (PDT) Subject: How to mix-in __getattr__ after the fact? References: <4630c4d0-86bc-4295-8bbb-6f58415191c8@v15g2000vbm.googlegroups.com> <4EAAF264.1050307@stoneleaf.us> <8bc11029-860e-4d3a-8770-062e16e31514@j39g2000yqc.googlegroups.com> Message-ID: On Oct 31, 8:01?am, dhyams wrote: > Thanks for all of the responses; everyone was exactly correct, and > obeying the binding rules for special methods did work in the example > above. ?Unfortunately, I only have read-only access to the class > itself (it was a VTK class wrapped with SWIG), so I had to find > another way to accomplish what I was after. > Please share what you found as the other way. From jeanmichel at sequans.com Wed Nov 2 07:04:35 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 02 Nov 2011 12:04:35 +0100 Subject: __init__ with multiple list values In-Reply-To: <1acb0d4c-069b-4356-8a9e-cd5640023c2b@g27g2000pre.googlegroups.com> References: <1acb0d4c-069b-4356-8a9e-cd5640023c2b@g27g2000pre.googlegroups.com> Message-ID: <4EB123C3.3040406@sequans.com> Gnarlodious wrote: > Initializing a list of objects with one value: > > class Order: > def __init__(self, ratio): > self.ratio=ratio > def __call__(self): > return self.ratio > > ratio=[1, 2, 3, 4, 5] > Orders=[Order(x) for x in ratio] > > > But now I want to __init__ with 3 values: > > class Order: > def __init__(self, ratio, bias, locus): > self.ratio=ratio > self.bias=bias > self.locus=locus > def __call__(self): > return self.ratio, self.bias, self.locus > > ratio=[1, 2, 3, 4, 5] > bias=[True, False, True, False, True] > locus=['A', 'B', 'C', 'D', 'E'] > Orders=[Order(x,y,z) for x,y,z in [ratio, bias, locus]] > > >>>> ValueError: too many values to unpack (expected 3) >>>> > > How to do it? > > -- Gnarlie > I'm a little off topic but you may want to avoid having inconsistent interfaces for your class methods, especially when it comes to special methods like __init__ and __call__. Having __call__ return a tuple with different length depending on the initialization of the object is a bad idea. You will surely end up in unpacking error in the future. Same things for your attributes, the presence of bias is conditioned by the object creation... Very bad idea :o) o1 = Order([1,2,3]) o2 = Order([1,2,3], [4, 5, 6, [7, 8, 9]) print o1.bias > Unknown attribute ratio, bias, locus = o2.call() ratio, bias, locus = o1.call() > Unpacking error You could do the following : class Order: def __init__(self, ratio, bias=None, locus=None): self.ratio=ratio self.bias=bias self.locus=locus def __call__(self): return self.ratio, self.bias, self.locus It would allow you to create your object with just the ratio and keep a consistent interface. Unpacking the __call__ return will never fail, and if you're interested in keeping only ratios, then you can write ratio, _, _ = o1.call() JM PS : accessing attributes using the __call__ method sounds like a little bit of magic for the lazy guy :o) People expect something to be executed when calling an object, not getting its attributes. It would be better to stick with the classic way : o1.ratio From pauldavidmena at gmail.com Wed Nov 2 08:44:40 2011 From: pauldavidmena at gmail.com (extraspecialbitter) Date: Wed, 2 Nov 2011 05:44:40 -0700 (PDT) Subject: parsing text from "ethtool" command References: <5544686.62.1320189565337.JavaMail.geo-discussion-forums@prog16> Message-ID: On Nov 1, 7:35?pm, Ian Kelly wrote: > On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka wrote: > > In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust. > > Or simply: > > if "Speed" in line: > > There is no need for a regular expression here. ?This would also work > and be a bit more discriminating: > > if line.strip().startswith("Speed") > > BTW, to the OP, note that your condition (line[0:6] == "Speed") cannot > match, since line[0:6] is a 6-character slice, while "Speed" is a > 5-character string. > > Cheers, > Ian Ian, Replacing my regular expression with line.strip().startswith did the trick. Thanks for the tip! Paul From andrea.crotti.0 at gmail.com Wed Nov 2 10:03:09 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 02 Nov 2011 14:03:09 +0000 Subject: leftover pyc files Message-ID: <4EB14D9D.8080309@gmail.com> In our current setup, the script in charge to run our applications also scan all the directories and if it finds any "pyc" file without the corresponding module, it removes it. This was done because when you rename something, the old "pyc" remains there and can cause problems. Is it the only way possible to scan through and remove all of them or is there a smarter way? From jeanmichel at sequans.com Wed Nov 2 10:39:19 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 02 Nov 2011 15:39:19 +0100 Subject: parsing text from "ethtool" command In-Reply-To: References: Message-ID: <4EB15617.4000509@sequans.com> extraspecialbitter wrote: > I'm still trying to write that seemingly simple Python script to print > out network interfaces (as found in the "ifconfig -a" command) and > their speed ("ethtool "). The idea is to loop for each > interface and > print out its speed. I'm looping correctly, but have some issues > parsing the output for all interfaces except for the "pan0" > interface. I'm running on eth1, and the "ifconfig -a" command also > shows an eth0, and of course lo. My script is trying to match on the > string "Speed", but I never seem to successfully enter the "if" > clause. > > First, here is the output of "ethtool eth1": > > ================= > > Settings for eth1: > Supported ports: [ TP ] > Supported link modes: 10baseT/Half 10baseT/Full > 100baseT/Half 100baseT/Full > Supports auto-negotiation: Yes > Advertised link modes: 10baseT/Half 10baseT/Full > 100baseT/Half 100baseT/Full > Advertised pause frame use: No > Advertised auto-negotiation: Yes > Speed: 100Mb/s > Duplex: Full > Port: Twisted Pair > PHYAD: 1 > Transceiver: internal > Auto-negotiation: on > MDI-X: off > Supports Wake-on: pumbag > Wake-on: g > Current message level: 0x00000001 (1) > Link detected: yes > > ================= > > The script *should* match on the string "Speed" and then assign "100Mb/ > s" to a variable, but is never getting past the second if statement > below: > > ================= > > #!/usr/bin/python > > # Quick and dirty script to print out available interfaces and their > speed > > # Initializations > > output = " Interface: %s Speed: %s" > noinfo = "(Speed Unknown)" > speed = noinfo > > import os, socket, types, subprocess > > fp = os.popen("ifconfig -a") > dat=fp.read() > dat=dat.split('\n') > for line in dat: > if line[10:20] == "Link encap": > interface=line[:9] > cmd = "ethtool " + interface > gp = os.popen(cmd) > fat=gp.read() > fat=fat.split('\n') > for line in fat: > if line[0:6] == "Speed": > try: > speed=line[8:] > except: > speed=noinfo > print output % (interface, speed) > > ================= > > Again, I appreciate everyone's patience, as I'm obviously I'm a python > newbie. Thanks in advance! > Hi, without starting a flamewar about regular expression, they sometimes can become usefull and really simplify code: s1 = """eth0 Link encap:Ethernet HWaddr 00:1d:09:2b:d2:be inet addr:192.168.200.176 Bcast:192.168.200.255 Mask:255.255.255.0 inet6 addr: fe80::21d:9ff:fe2b:d2be/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:297475688 errors:0 dropped:7 overruns:0 frame:2 TX packets:248662722 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2795194692 (2.6 GiB) TX bytes:2702265420 (2.5 GiB) Interrupt:17 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:5595504 errors:0 dropped:0 overruns:0 frame:0 TX packets:5595504 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1601266268 (1.4 GiB) TX bytes:1601266268 (1.4 GiB) """ import re itfs = [section for section in s1.split('\n\n') if section and section != '\n'] # list of interfaces sections, filter the empty sections for itf in itfs: match = re.search('^(\w+)', itf) # search the word at the begining of the section interface = match and match.group(1) match = re.search('MTU:(\d+)', itf) # search for the field MTU: and capture its digital value mtu = (match and match.group(1)) or 'MTU not found' print interface, mtu >>> eth0 1500 >>> lo 16436 If you're not familiar with python regexp, I would advise to use kodos.py (google it), it really does help. The strong point about the code above, is that it removes all the tedious if then else logic and the arbitrary slice indexes. JM PS : I cannot test the 'Speed' because it's absent from my ifconfig display, but you should be able to figure it out :o) From __peter__ at web.de Wed Nov 2 11:03:48 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 02 Nov 2011 16:03:48 +0100 Subject: leftover pyc files References: <4EB14D9D.8080309@gmail.com> Message-ID: Andrea Crotti wrote: > In our current setup, the script in charge to run our applications also > scan all the directories and if it finds any "pyc" file without the > corresponding > module, it removes it. > > This was done because when you rename something, the old "pyc" remains > there and can cause problems. > > Is it the only way possible to scan through and remove all of them or is > there a smarter way? Switch to Python3.2 ;) http://docs.python.org/dev/py3k/whatsnew/3.2.html#pep-3147-pyc-repository-directories http://www.python.org/dev/peps/pep-3147/#case-4-legacy-pyc-files-and-source-less-imports From miki.tebeka at gmail.com Wed Nov 2 11:08:48 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 2 Nov 2011 08:08:48 -0700 (PDT) Subject: Sort items in wxListCtrl In-Reply-To: References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> Message-ID: <28740627.642.1320246528964.JavaMail.geo-discussion-forums@pref15> wx.FileDialog shows files and directories. If you need the user to pick one, this is the standard way. Otherwise, if you need custom view on the file system then probably list control is the right way to go. Again, the demo has a working example with sortable list control. From nospam at a.it Wed Nov 2 11:15:27 2011 From: nospam at a.it (Hanss) Date: Wed, 02 Nov 2011 15:15:27 +0000 Subject: getting columns attributes in declarative style with sqlalchemy In-Reply-To: <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> References: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> Message-ID: Il 01/11/2011 19.37, tres.bailey at gmail.com ha scritto: > > I'm no SQLAlchemy expert, but I have used the Table and Column attribute objects from the model object to solve a similar problem in the past. You can use the following syntax to do it: > > [col.name for col in Country.__table__.columns._all_cols] Thank you very much! This is exactly what I was looking for! Thanks! From nospam at a.it Wed Nov 2 11:17:37 2011 From: nospam at a.it (Gabriele) Date: Wed, 02 Nov 2011 15:17:37 +0000 Subject: getting columns attributes in declarative style with sqlalchemy In-Reply-To: <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> References: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> Message-ID: Il 01/11/2011 19.37, tres.bailey at gmail.com ha scritto: > Sorry for the repost, if it does in fact repost. > > I'm no SQLAlchemy expert, but I have used the Table and Column attribute objects from the model object to solve a similar problem in the past. You can use the following syntax to do it: > > [col.name for col in Country.__table__.columns._all_cols] Thank you very much! This is exactly what I was looking for! Thanks! Gabriele From andrea.crotti.0 at gmail.com Wed Nov 2 11:45:43 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 02 Nov 2011 15:45:43 +0000 Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <4EB165A7.3050102@gmail.com> On 11/02/2011 03:03 PM, Peter Otten wrote: > Switch to Python3.2 ;) Yes I saw that and it would be great, unfortunately we're stuck with Python 2.5 :O for some more time. Anyway now the code that does it is a recursive thing ilke def _clean_orphaned_pycs(self, directory, simulate=False): """Remove all the pyc files without a correspondent module """ files = listdir(directory) # going down the tree recursively (like os.walk) for x in files: if x.endswith('.pyc'): py_file = x.split('.pyc')[0] + '.py' if (not simulate) and (py_file not in files): deletable_pyc = path.join(directory, x) print 'DELETING pyc %s as it has no py %s' % \ (deletable_pyc, py_file) remove(deletable_pyc) #TODO: move out these special cases if path.isdir(path.join(directory, x)) \ and x != '.svn' \ and not x.endswith('.egg-info'): self._clean_orphaned_pycs(path.join(directory, x)) Can be done much better probably with os.walk or os.path.walk, any suggestions? From ckaynor at zindagigames.com Wed Nov 2 12:06:37 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 2 Nov 2011 09:06:37 -0700 Subject: leftover pyc files In-Reply-To: <4EB165A7.3050102@gmail.com> References: <4EB14D9D.8080309@gmail.com> <4EB165A7.3050102@gmail.com> Message-ID: If you can at least upgrade to Python 2.6, another option, if you don't mind losing the byte code caching all together (it may worsen load times, however probably not significantly), you can set PYTHONDONTWRITEBYTECODE to prevent the writing of .pyc files. Alternatively, again in 2.6+, you can also specify the -B command-line argument. See http://docs.python.org/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE and http://docs.python.org/using/cmdline.html#cmdoption-unittest-discover-B Chris On Wed, Nov 2, 2011 at 8:45 AM, Andrea Crotti wrote: > On 11/02/2011 03:03 PM, Peter Otten wrote: >> >> Switch to Python3.2 ;) > > Yes I saw that and it would be great, unfortunately we're stuck with Python > 2.5 :O > for some more time. > > Anyway now the code that does it is a recursive thing ilke > def _clean_orphaned_pycs(self, directory, simulate=False): > ? ?"""Remove all the pyc files without a correspondent module > ? ?""" > ? ?files = listdir(directory) > ? ?# going down the tree recursively (like os.walk) > ? ?for x in files: > ? ? ? ?if x.endswith('.pyc'): > ? ? ? ? ? ?py_file = x.split('.pyc')[0] + '.py' > > ? ? ? ? ? ?if (not simulate) and (py_file not in files): > ? ? ? ? ? ? ? ?deletable_pyc = path.join(directory, x) > ? ? ? ? ? ? ? ?print 'DELETING pyc %s as it has no py %s' % \ > ? ? ? ? ? ? ? ? ? ?(deletable_pyc, py_file) > ? ? ? ? ? ? ? ?remove(deletable_pyc) > > ? ? ? ?#TODO: move out these special cases > ? ? ? ?if path.isdir(path.join(directory, x)) \ > ? ? ? ? ? ?and x != '.svn' \ > ? ? ? ? ? ?and not x.endswith('.egg-info'): > > ? ? ? ? ? ?self._clean_orphaned_pycs(path.join(directory, x)) > > > Can be done much better probably with os.walk or os.path.walk, > any suggestions? > -- > http://mail.python.org/mailman/listinfo/python-list > From andrea.crotti.0 at gmail.com Wed Nov 2 12:43:53 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 02 Nov 2011 16:43:53 +0000 Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <4EB165A7.3050102@gmail.com> Message-ID: <4EB17349.6030100@gmail.com> On 11/02/2011 04:06 PM, Chris Kaynor wrote: > If you can at least upgrade to Python 2.6, another option, if you > don't mind losing the byte code caching all together (it may worsen > load times, however probably not significantly), you can set > PYTHONDONTWRITEBYTECODE to prevent the writing of .pyc files. > Alternatively, again in 2.6+, you can also specify the -B command-line > argument. See http://docs.python.org/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE > and http://docs.python.org/using/cmdline.html#cmdoption-unittest-discover-B > > Chris > Unfortunately not possible :( So well the hand-made removal is also fine, maybe if I'm able to run it as a service it should not impact on the run-time either, which would be nice... From Ric at rdo Wed Nov 2 14:50:00 2011 From: Ric at rdo (Ric at rdo) Date: Wed, 02 Nov 2011 13:50:00 -0500 Subject: Sort items in wxListCtrl References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> <28740627.642.1320246528964.JavaMail.geo-discussion-forums@pref15> Message-ID: On Wed, 2 Nov 2011 08:08:48 -0700 (PDT), Miki Tebeka wrote: >wx.FileDialog shows files and directories. If you need the user to pick one, this is the standard way. Otherwise, if you need custom view on the file system then probably list control is the right way to go. Again, the demo has a working example with sortable list control. Thanks, Do you know if List control has an click event that if you double click on a directory displayed in the control an action can occur? Sorry if its right there but I just did not see. From vonkes at gmail.com Wed Nov 2 15:21:03 2011 From: vonkes at gmail.com (vonkes) Date: Wed, 2 Nov 2011 12:21:03 -0700 (PDT) Subject: understand program used to create file References: Message-ID: <46219926-741e-407d-8773-8a5efa81dbc3@q13g2000vbd.googlegroups.com> Ho trovato questo script in una directory dove sono conservati molti demo per python non era funzionante,sono riuscito a capirne le finalit? e cos? l'ho reso funzionante. Esamina un file di testo e analizza il carattere di fine riga. le possibilit? dipendono dal sistema operativo usato. Nei file di testo sotto S.O. Unix il carattere di fine riga in genere ? un CR o carriage return. Sotto Mac questo carattere in genere ? un LF linee feed mentre sotto s.o. windows in genere ? CRLF sulla base di ci? l'applicativo osserva tutti i fine riga e ne fa un confronto. Osservando il sorgente si dovrebbe comprendere come il controllo viene fatto. Nell'ipotesi che ci si voglia divertire e non si dia un nome di file o si dia un nome inesistente, l'applicativo fa il controllo su se stesso e poi da le risposte. Provate: ecco il sorgente: __________ inizio applicativo______________ !/usr/bin/python # -*- coding: utf-8 -*- """Controlla file di testo - Controlla quale sia il carattere di fine riga per determinarne lo stile Se la riga termina con CR abbiamo lo stile UNIX Se " " " " LF abbiamo lo stile MAC Se " " " " CRLF abbiamo lo stile Win/MS-Dos Mettiamo una alternativa all'inserimento del file aggiungiamo una parte di codice che nel caso non venga indicato un nome di file o ne indicassimo uno mancante o assente, vada a cercare il file dal quale siamo partiti cioe' questo stesso che dovrebbe essere contenuto nella variabile argv che come e' noto e' una lista di parametri passati dalla linea di comando e il primo elemento della lista e' proprio il nome di questo applicativo che seppure non ? il classico file di testo anch'esso ha i caratteri di fine riga esattamente come quelli dei classici file di testo e quindi possiamo esaminarli per decidere quale stile seguono. """ #---------- fine commento------------- import sys,os import string def Message(parametro): #print "\nquesta e' la funzione che stampera' Il parametro ricevuto" print "\n:",parametro def ChiediFiledaAprire(message): print "\n"+message nome = raw_input( "\ninserisci il nome di un file di testo completo di estensione \n: ") return nome #pathname = sys.path #print "pathname=",pathname def main(): #print os.listdir(sys.path[0]) while True: name = ChiediFiledaAprire(message='Per controllo del carattere di fine linea presente nel file') if name == "": print "Poiche non hai digitato alcun nome il controllo lo effettuer??\ il controllo sul file "+ sys.argv[0] name = sys.argv[0];break elif not name: print "Attenzione !! Il nome file digitato non esiste, effettuer?? controllo sul file "+sys.argv[0] +" che ?n esecuzione " name = sys.argv[0];break else: break fp = open(name, 'rb') try: data = fp.read() #print "nel file",name," abbiamo trovato",data except MemoryError: Message("Attenzione, Il file e' troppo grande.") sys.exit(0) if len(data) == 0: Message('Il File e vuoto.') sys.exit(0) number_cr = string.count(data, '\r') number_lf = string.count(data, '\n') if number_cr == number_lf == 0: Message('Nel File '+name+' manca il carattere di fine riga.') if number_cr != 0 and chr(10) not in data: Message('Il File '+name+' presenta lo style unix con fine riga = CR') elif number_lf != 0 and chr(13) not in data: Message('Il File '+name+' presenta lo style mac con fine riga = LF') elif number_cr == number_lf: Message('Il File '+name+' presenta lo style Win/MS-Dos con fine riga =CRLF') else: Message('Il File '+name+' presenta un fine riga non riconosciuto (binary file?)') sys.exit(0) #----------------fine applicativo---------- Ciao vonkes From Catherine.M.Moroney at jpl.nasa.gov Wed Nov 2 15:31:48 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Wed, 02 Nov 2011 12:31:48 -0700 Subject: fast copying of large files in python Message-ID: Hello, I'm working on an application that as part of its processing, needs to copy 50 Meg binary files from one NFS mounted disk to another. The simple-minded approach of shutil.copyfile is very slow, and I'm guessing that this is due to the default 16K buffer size. Using shtil.copyfileobj is faster when I set a larger buffer size, but it's still slow compared to a "os.system("cp %s %s" % (f1,f2))" call. Is this because of the overhead entailed in having to open the files in copyfileobj? I'm not worried about portability, so should I just do the os.system call as described above and be done with it? Is that the fastest method in this case? Are there any "pure python" ways of getting the same speed as os.system? Thanks, Catherine From macmanes at gmail.com Wed Nov 2 17:13:34 2011 From: macmanes at gmail.com (Matt) Date: Wed, 2 Nov 2011 14:13:34 -0700 (PDT) Subject: simple file flow question with csv.reader Message-ID: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> Hi All, I am trying to do a really simple file operation, yet, it befuddles me... I have a few hundred .csv files, and to each file, I want to manipulate the data, then save back to the original file. The code below will open up the files, and do the proper manipulations-- but I can't seem to save the files after the manipulation.. How can I save the files-- or do I need to try something else maybe with split, join, etc.. import os import csv for filename in os.listdir("/home/matthew/Desktop/pero.ngs/blast"): with open(filename, 'rw') as f: reader = csv.reader(f) for row in reader: print ">",row[0],row[4],"\n",row[1], "\n", ">", row[2], "\n", row[3] Thanks in advance, Matt From d at davea.name Wed Nov 2 17:26:16 2011 From: d at davea.name (Dave Angel) Date: Wed, 02 Nov 2011 17:26:16 -0400 Subject: fast copying of large files in python In-Reply-To: References: Message-ID: <4EB1B578.801@davea.name> On 11/02/2011 03:31 PM, Catherine Moroney wrote: > Hello, > > I'm working on an application that as part of its processing, needs to > copy 50 Meg binary files from one NFS mounted disk to another. > > The simple-minded approach of shutil.copyfile is very slow, and I'm > guessing that this is due to the default 16K buffer size. Using > shtil.copyfileobj is faster when I set a larger buffer size, but it's > still slow compared to a "os.system("cp %s %s" % (f1,f2))" call. > Is this because of the overhead entailed in having to open the files > in copyfileobj? > > I'm not worried about portability, so should I just do the > os.system call as described above and be done with it? Is that the > fastest method in this case? Are there any "pure python" ways of > getting the same speed as os.system? > > Thanks, > > Catherine I suspect the fastest way would be to use scp, and not try to use your local mount for either file. There are some options on scp that tell it to just connect the (up to) two machines to each other and transfer, where it won't even come to your local machine. I do that sort of thing when I'm connecting over slow internet (and vpn) to two machines that are on the same local subnet. -- DaveA From python.list at tim.thechases.com Wed Nov 2 19:06:39 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 02 Nov 2011 18:06:39 -0500 Subject: simple file flow question with csv.reader In-Reply-To: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> References: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> Message-ID: <4EB1CCFF.4050208@tim.thechases.com> On 11/02/11 16:13, Matt wrote: > Hi All, > > I am trying to do a really simple file operation, yet, it befuddles me... > > I have a few hundred .csv files, and to each file, I want to manipulate the data, then save back to the original file. The code below will open up the files, and do the proper manipulations-- but I can't seem to save the files after the manipulation.. > > How can I save the files-- or do I need to try something else maybe with split, join, etc.. > > > import os > import csv > for filename in os.listdir("/home/matthew/Desktop/pero.ngs/blast"): > with open(filename, 'rw') as f: > reader = csv.reader(f) > for row in reader: > print ">",row[0],row[4],"\n",row[1], "\n",">", row[2], "\n", row[3] Your last line just prints the data to standard-out. You can either pipe the output to a file: python myprog.py > output.txt or you can write them to a single output file: out = file('output.txt', 'w') for filename in os.listdir(...): with open(filename, 'rw') as f: reader = csv.reader(f) for row in reader: out.write(">%s%s\n%s\n>%s\n>%s\n%s" % ( row[0], row[4], row[1], row[2], row[3])) or you can write them to output files on a per-input basis: for filename in os.listdir(SOURCE_LOC): with open(filename, 'r') as f: outname = os.path.join( DEST_LOC, os.path.basename(filename), ) with file(outname, 'wb') as out: for row in reader: out.write(">%s%s\n%s\n>%s\n>%s\n%s" % ( row[0], row[4], row[1], row[2], row[3])) -tkc From tjreedy at udel.edu Wed Nov 2 19:50:36 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Nov 2011 19:50:36 -0400 Subject: simple file flow question with csv.reader In-Reply-To: References: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> Message-ID: On 11/2/2011 7:06 PM, Dennis Lee Bieber wrote: > On Wed, 2 Nov 2011 14:13:34 -0700 (PDT), Matt > declaimed the following in gmane.comp.python.general: > >> I have a few hundred .csv files, and to each file, I want to >> manipulate the data, then save back to the original file. That is dangerous. Better to replace the file with a new one of the same name. > Option 1: Read the file completely into memory (your example is > reading line by line); close the reader and its file; reopen the > file for "wb" (delete, create new); open CSV writer on that file; > write the memory contents. and lose data if your system crashes or freezes during the write. > Option 2: Open a temporary file "wb"; open a CSV writer on the file; > for each line from the reader, update the data, send to the writer; > at end of reader, close reader and file; delete original file; > rename temporary file to the original name. This works best if new file is given a name related to the original name, in case rename fails. Alternative is to rename original x to x.bak, write or rename new file, then delete .bak file. -- Terry Jan Reedy From fzadrozny at appcelerator.com Wed Nov 2 19:52:44 2011 From: fzadrozny at appcelerator.com (Fabio Zadrozny) Date: Wed, 2 Nov 2011 21:52:44 -0200 Subject: PyDev 2.2.4 Released Message-ID: Hi All, PyDev 2.2.4 has been released Details on PyDev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: ------------------------------- **Cython** * Cython is now supported in PyDev (.pyx files may be opened with the PyDev editor). **Globals Token Browser (Ctrl+Shift+T)** * Packages/Modules can now be reached through the globals browser (so, __init__.py files can now be easily gotten through the package they represent) **Handling external files** * External libraries configured in a project appearing in the PyDev Package Explorer * Show in > PyDev Package Explorer working for files that are under the interpreter or external libraries. * Show in > PyDev Package Explorer working for files inside .zip archives. * External files that were opened when Eclipse is closed are properly reopened. **Editor** * New option in the code-formatter to only apply code-formatting on changed lines on save. * from __future__ import now properly appears as first even if grouping is enabled. * it's now possible to have a minimap of the code in the overview ruler (enable in preferences > PyDev > Editor > Overview Ruler Minimap). **Unittest runner** * exc_clear() no longer called if it's not available. * Fixed issue where class tearDown was executed twice. **Debugger** * It's now possible to enable/disable stepping into properties while in the debugger. Menu: Run > Disable step into properties (patch by Hussain Bohra) * Show in outline view activated in debug perspective (patch by Hussain Bohra) * Watch expressions can be properly expanded in the watch view (patch by Hussain Bohra) * Breakpoints in external files are properly shown. * Remote debugger: starting the remote debugger no longer shows a launch configuration * Remote debugger: when the server is stopped, the server socket is properly closed **Minors** * Fixed issue in rename (Alt+Shift+R) / find references (Ctrl+Shift+G) on top level module variables. * Fixed issue where create class/method/field action was not ok because of comment. * Fixed issue where doing create class/method/field action on file with tabs ended up adding spaces. What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python, Jython and IronPython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer Appcelerator http://appcelerator.com/ Aptana http://aptana.com/ PyDev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com From radha at leapship.com Wed Nov 2 20:05:47 2011 From: radha at leapship.com (Radhika Bauerle) Date: Wed, 2 Nov 2011 17:05:47 -0700 Subject: Full time Job opening -Python lead in washington area. Message-ID: Hello eveyone: we are looking for a Python lead in washington area. Strong on Python Strong on OOAD Worked on high performance web application Cheers, Radhika Bauerle. Leapship, Inc. radha at leapship.com 408.355.8462 -- Radhika Bauerle. Leapship, Inc. radha at leapship.com 408.355.8462 -------------- next part -------------- An HTML attachment was scrubbed... URL: From miki.tebeka at gmail.com Wed Nov 2 20:06:33 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 2 Nov 2011 17:06:33 -0700 (PDT) Subject: Sort items in wxListCtrl In-Reply-To: References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> <28740627.642.1320246528964.JavaMail.geo-discussion-forums@pref15> Message-ID: <15871079.2079.1320278793045.JavaMail.geo-discussion-forums@prgt40> You probably want wx.EVT_LEFT_DCLICK, see the ListCtrl demo in the wx demo. From joncle at googlemail.com Wed Nov 2 20:47:02 2011 From: joncle at googlemail.com (Jon Clements) Date: Wed, 2 Nov 2011 17:47:02 -0700 (PDT) Subject: simple file flow question with csv.reader References: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> Message-ID: <6e0fc699-1047-41c6-8387-b9f402e98e2a@w7g2000yqc.googlegroups.com> On Nov 2, 11:50?pm, Terry Reedy wrote: > On 11/2/2011 7:06 PM, Dennis Lee Bieber wrote: > > > On Wed, 2 Nov 2011 14:13:34 -0700 (PDT), Matt > > declaimed the following in gmane.comp.python.general: > > >> I have a few hundred .csv files, and to each file, I want to > >> manipulate the data, then save back to the original file. > > That is dangerous. Better to replace the file with a new one of the same > name. > > > Option 1: ?Read the file completely into memory (your example is > > reading line by line); close the reader and its file; reopen the > > file for "wb" (delete, create new); open CSV writer on that file; > > write the memory contents. > > and lose data if your system crashes or freezes during the write. > > > Option 2: ?Open a temporary file "wb"; open a CSV writer on the file; > > for each line from the reader, update the data, send to the writer; > > at end of reader, close reader and file; delete original file; > > rename temporary file to the original name. > > This works best if new file is given a name related to the original > name, in case rename fails. Alternative is to rename original x to > x.bak, write or rename new file, then delete .bak file. > > -- > Terry Jan Reedy To the OP, I agree with Terry, but will add my 2p. What is this meant to achieve? >>> row = range(10) >>> print ">",row[0],row[4],"\n",row[1], "\n", ">", row[2], "\n", row[3] > 0 4 1 > 2 3 Is something meant to read this afterwards? I'd personally create a subdir called db, create a sqlite3 db, then load all the required fields into it (with a column for filename)... it will either work or fail, then if it succeeds, start overwriting the originals - just a "select * from some_table" will do, using itertools.groupby on the filename column, changing the open() request etc... just my 2p mind you, Jon. From stefan_ml at behnel.de Thu Nov 3 02:59:48 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 03 Nov 2011 07:59:48 +0100 Subject: Full time Job opening -Python lead in washington area. In-Reply-To: References: Message-ID: Radhika Bauerle, 03.11.2011 01:05: > Hello eveyone: Well, and here's the problem already: "everyone". Note that it's commonly considered inappropriate to post job offers on this list. Please use the Python job board instead: http://python.org/community/jobs/ (easy to find by clicking on "python jobs" on the Python.org front page) Stefan From tartley at tartley.com Thu Nov 3 03:49:35 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 00:49:35 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> A task like this is more suited to bash than Python: find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 03:49:35 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 00:49:35 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> A task like this is more suited to bash than Python: find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 03:50:37 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 00:50:37 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <33506962.66.1320306638033.JavaMail.geo-discussion-forums@yqie15> This can be added to git as a post-checkout hook: In your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 03:50:37 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 00:50:37 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <33506962.66.1320306638033.JavaMail.geo-discussion-forums@yqie15> This can be added to git as a post-checkout hook: In your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 04:45:53 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 01:45:53 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <17659765.658.1320309953278.JavaMail.geo-discussion-forums@yqnv12> This can be added to your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 04:45:53 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 01:45:53 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <17659765.658.1320309953278.JavaMail.geo-discussion-forums@yqnv12> This can be added to your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' From jacob.abraham at gmail.com Thu Nov 3 05:22:57 2011 From: jacob.abraham at gmail.com (Jacob Abraham) Date: Thu, 3 Nov 2011 14:52:57 +0530 Subject: Paramiko Question Message-ID: Hi All, I need help with the below mentioned script. The second time I call a.execute, self.transport.open_session() fails with an EOF error. Is this a paramiko bug or am I doing something wrong? import paramiko class Connection(object): def __init__(self, host, username = None, password = None, private_key = None, \ port = 22): self.transport = paramiko.Transport((host, port)) self.live = True self.transport.connect(username = username, password = password) def execute(self, command): channel = self.transport.open_session() channel.exec_command(command) output = channel.makefile('rb', -1).readlines() if output: print output else: print channel.makefile_stderr('rb', -1).readlines() def close(self): if self.live: self.transport.close() self.live = False def __del__(self): self.close() if __name__ == '__main__': a= Connection('ip_or_hostname', 'root', '') print a.execute('version') print a.execute('version') print a.execute('version') a.close() Regards, Jacob Abraham From robert.kern at gmail.com Thu Nov 3 05:56:40 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 03 Nov 2011 09:56:40 +0000 Subject: Chaco for real-time plot of PySerial data In-Reply-To: References: Message-ID: On 11/1/11 10:27 PM, Jack Keegan wrote: > Hi there, > > I asked this question on the enthought chaco mailing list some time last by have > yet to receive a reply. Thought I'd ask here to see if anyone could shed some > light on things for me. I have been considering using chaco / traits for close > to a year now and am finally biting the bullet so to speak. What I would really > like to do to begin with is to make a real-time plotting application which gets > its data from the serial port. Can anyone please point me in the right direction > for doing this? > > Since I didn't get a reply on the chaco list I'm now thinking it might be a > dangerous route to go down since it will be difficult to get help. Any > recommendations? I'm sorry we didn't respond to you. The chaco-users mailing list is not well-subscribed or well-trafficked, but the enthought-dev at enthought.com mailing list is. We haven't done a good job of letting new people know they should be on the chaco-users list to answer questions or updating the documentation to point users to enthought-dev instead. Anyways, to answer your question, we have several examples of how one sets up a plot then updates it with new data: https://github.com/enthought/chaco/tree/master/examples/demo/updating_plot I can't help much with the PySerial part, I'm afraid. Integrating that with the GUI event loop is probably going to be the trickiest bit. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From landa.martin at gmail.com Thu Nov 3 06:07:36 2011 From: landa.martin at gmail.com (Martin Landa) Date: Thu, 3 Nov 2011 03:07:36 -0700 (PDT) Subject: ctypes: catch system exit from C library Message-ID: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> Hi all, in my python application I am calling functions from a C library via `ctypes` interface. Some fns from that C library calls `exit()` on error. It causes that the python application crashes even without any notification. Is it possible to catch library system exit calls from such python application? Thanks in advance, Martin From alec.taylor6 at gmail.com Thu Nov 3 06:19:24 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 3 Nov 2011 21:19:24 +1100 Subject: Database access benchmarks for use in web-frameworks - How does Python compare? Message-ID: Good afternoon, I'm building a large e-commerce site, and it is very important that what I write can: - Handle larger server load - Deliver pages quickly - Make transactions quickly as well as have a small development time (i.e. pre-built modules for e-commerce are available, and extendible). Are there recent accessible statistics available, comparing these metrics across the most popular web-frameworks? (i.e. Symfony, DJango, Rails, ASP.NET &etc) Thanks for all suggestions, Alec Taylor From __peter__ at web.de Thu Nov 3 06:51:48 2011 From: __peter__ at web.de (Peter Otten) Date: Thu, 03 Nov 2011 11:51:48 +0100 Subject: leftover pyc files References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: Jonathan Hartley wrote: > A task like this is more suited to bash than Python: > > find . -name '*.pyc' -exec rm '{}' ';' You forgot to exclude the .svn directory from the search and didn't limit the deletion to pyc-files whose corresponding py-file doesn't exist. How would your line look with these modifications? From duncan.booth at invalid.invalid Thu Nov 3 07:32:35 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 3 Nov 2011 11:32:35 GMT Subject: ctypes: catch system exit from C library References: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> Message-ID: Martin Landa wrote: > Hi all, > > in my python application I am calling functions from a C library via > `ctypes` interface. Some fns from that C library calls `exit()` on > error. It causes that the python application crashes even without any > notification. Is it possible to catch library system exit calls from > such python application? > > Thanks in advance, Martin There is no safe way to do this. An unsafe way would be to install an atexit() handler and longjmp out of it, but that would mess up any other atexit processing and quite likely crash the program. Or you could just move the essential cleanup into atexit() but not attempt to stop the program termination. The clean (but not necessarily easy) solution would be to move all of the code that uses the library into a separate subprocess and then you can catch and handle the subprocess exiting in your main code. -- Duncan Booth http://kupuguy.blogspot.com From ulrich.eckhardt at dominolaser.com Thu Nov 3 08:28:17 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 03 Nov 2011 13:28:17 +0100 Subject: ctypes: catch system exit from C library In-Reply-To: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> References: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> Message-ID: <10eao8-84g.ln1@satorlaser.homedns.org> Am 03.11.2011 11:07, schrieb Martin Landa: > in my python application I am calling functions from a C library via > `ctypes` interface. Some fns from that C library calls `exit()` on > error. Just curious, which library is that? Uli From invalid at invalid.invalid Thu Nov 3 10:16:50 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 3 Nov 2011 14:16:50 +0000 (UTC) Subject: ctypes: catch system exit from C library References: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> <10eao8-84g.ln1@satorlaser.homedns.org> Message-ID: On 2011-11-03, Ulrich Eckhardt wrote: > Am 03.11.2011 11:07, schrieb Martin Landa: >> in my python application I am calling functions from a C library via >> `ctypes` interface. Some fns from that C library calls `exit()` on >> error. > > Just curious, which library is that? And who should we have thrashed and pilloried for writing it that way? -- Grant Edwards grant.b.edwards Yow! BARRY ... That was at the most HEART-WARMING gmail.com rendition of "I DID IT MY WAY" I've ever heard!! From brandon.harris at reelfx.com Thu Nov 3 10:42:08 2011 From: brandon.harris at reelfx.com (Brandon Harris) Date: Thu, 03 Nov 2011 09:42:08 -0500 Subject: Python Pickling Issue Message-ID: <4EB2A840.5060108@reelfx.com> I have written a fairly large DAG with python and I've run into an issue when attempting to pickle the data to disk. It will pickle fine the first time, but if I call pickle again, it throws this error. /usr/lib64/python2.6/copy_reg.py in _reduce_ex(self, proto) 68 else: 69 if base is self.__class__: ---> 70 raise TypeError, "can't pickle %s objects" % base.__name__ 71 state = base(self) 72 args = (self.__class__, base, state) TypeError: can't pickle function objects I'm calling save_file = open('my_file.rsf', 'w') cPickle.dump(self, save_file) I have attempted to pickle the object to a different file after the first time, but the error is still thrown. This wouldn't be very hard to track down if the error gave any indication as to where or what this function it can't pickle is, so if there's any possible way to at least get the name of what's failing to be pickled, that would be a win. Thanks in advance for all replies. Brandon L. Harris From brandon.harris at reelfx.com Thu Nov 3 10:58:51 2011 From: brandon.harris at reelfx.com (Brandon Harris) Date: Thu, 03 Nov 2011 09:58:51 -0500 Subject: Python Pickling Issue In-Reply-To: <4EB2A840.5060108@reelfx.com> References: <4EB2A840.5060108@reelfx.com> Message-ID: <4EB2AC2B.3050301@reelfx.com> After digging around a while I discovered I was attempting to pickle a third party class that can't be pickled. Initially I was removing it before pickling and everything was kosher, but at some point it got back onto the class. Apologies. Brandon L. Harris On 11/03/2011 09:42 AM, Brandon Harris wrote: > I have written a fairly large DAG with python and I've run into an > issue when attempting to pickle the data to disk. > It will pickle fine the first time, but if I call pickle again, it > throws this error. > > /usr/lib64/python2.6/copy_reg.py in _reduce_ex(self, proto) > 68 else: > 69 if base is self.__class__: > ---> 70 raise TypeError, "can't pickle %s objects" % > base.__name__ > 71 state = base(self) > 72 args = (self.__class__, base, state) > > TypeError: can't pickle function objects > > I'm calling > save_file = open('my_file.rsf', 'w') > cPickle.dump(self, save_file) > > I have attempted to pickle the object to a different file after the > first time, but the error is still thrown. > > This wouldn't be very hard to track down if the error gave any > indication as to where or what this function it can't pickle is, so > if there's any possible way to at least get the name of what's failing > to be pickled, that would be a win. > > Thanks in advance for all replies. > > Brandon L. Harris > From python at mrabarnett.plus.com Thu Nov 3 11:38:33 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 03 Nov 2011 15:38:33 +0000 Subject: Paramiko Question In-Reply-To: References: Message-ID: <4EB2B579.5060901@mrabarnett.plus.com> On 03/11/2011 09:22, Jacob Abraham wrote: > Hi All, > > I need help with the below mentioned script. The second time I > call a.execute, self.transport.open_session() fails with an EOF error. > Is this a paramiko bug or am I doing something wrong? > > > import paramiko > > class Connection(object): > def __init__(self, host, username = None, password = None, > private_key = None, \ > port = 22): > self.transport = paramiko.Transport((host, port)) > self.live = True > self.transport.connect(username = username, password = password) > > def execute(self, command): > channel = self.transport.open_session() > channel.exec_command(command) > output = channel.makefile('rb', -1).readlines() > if output: > print output > else: > print channel.makefile_stderr('rb', -1).readlines() > > def close(self): > if self.live: > self.transport.close() > self.live = False > > def __del__(self): > self.close() > > if __name__ == '__main__': > a= Connection('ip_or_hostname', 'root', '') > print a.execute('version') > print a.execute('version') > print a.execute('version') > a.close() > I notice that in the 'execute' method you're opening the session, but not closing it. Could that be the cause of the problem? I also notice that in that method you're printing the output, not returning it, but when you call the execute method you're trying to print the result, which will be None. From davidj411 at gmail.com Thu Nov 3 12:48:58 2011 From: davidj411 at gmail.com (davidj411) Date: Thu, 3 Nov 2011 09:48:58 -0700 (PDT) Subject: AIX installation can't find zlib In-Reply-To: <20000728185514.E266@xs4all.nl> References: <8ls045$1522$1@news.rchland.ibm.com> <20000728185514.E266@xs4all.nl> Message-ID: <5936806.117.1320338938935.JavaMail.geo-discussion-forums@prap37> we using RPM to install python 2.7.x and same issue there, can't import gzip b/c zlib is missing. we used RPM to install zlib, but did not effect python. you mentioned modules and uncommenting something. could you be more specific? also , we are not compiling. would that be required for python after uncommenting zlib? From andrea.crotti.0 at gmail.com Thu Nov 3 13:54:52 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Thu, 03 Nov 2011 17:54:52 +0000 Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <4EB2D56C.6070208@gmail.com> All these ideas (shell and git hooks) are nice, but unfortunately - it's svn not git - it's windows not *nix - we have to remove only the ones without the corresponding *py... From bkamrani at gmail.com Thu Nov 3 14:13:43 2011 From: bkamrani at gmail.com (Behnam) Date: Thu, 3 Nov 2011 11:13:43 -0700 (PDT) Subject: Python advanced course (preferably in NA) Message-ID: Anybody is aware of any advanced course in Python preferably in north america? I've been partly coding in Python for couple of years now and have used PyQt. What I'd like to learn more is a kind of advance OOP in python. Any idea? BTW, I'm not a computer engineer and have mechanical background. Thanks in advance! From ericsnowcurrently at gmail.com Thu Nov 3 14:29:14 2011 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Thu, 3 Nov 2011 12:29:14 -0600 Subject: Python advanced course (preferably in NA) In-Reply-To: References: Message-ID: On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: > Anybody is aware of any advanced course in Python preferably in north > america? > > I've been partly coding in Python for couple of years now and have > used PyQt. What I'd like to learn more is a kind of advance OOP in > python. Any idea? While I don't know specifically, check out the following link (from the Python site): http://wiki.python.org/moin/PythonTraining I have taken a class each (PyCon tutorial) from Raymond Hettinger, David Beazley, and Brian Jones, and found each of them to be outstanding courses. Only David is listed on that page to which I linked, though I know Raymond does courses at least from time to time. I've also heard a talk from Wesley Chun and found him to be fantastic. -eric > > BTW, I'm not a computer engineer and have mechanical background. > > Thanks in advance! > -- > http://mail.python.org/mailman/listinfo/python-list > From scottdware at gmail.com Thu Nov 3 14:46:54 2011 From: scottdware at gmail.com (Scott Ware) Date: Thu, 3 Nov 2011 11:46:54 -0700 (PDT) Subject: Dictionary sorting Message-ID: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Python newbie here. So, when creating dictionaries, I am noticing that each time I print it out, that its not in the same order as when I typed it in. They seem to be getting sorted somehow. Is there a way to not sort them and leave the order as is? Thanks! From gordon at panix.com Thu Nov 3 14:57:27 2011 From: gordon at panix.com (John Gordon) Date: Thu, 3 Nov 2011 18:57:27 +0000 (UTC) Subject: Dictionary sorting References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: In <16245908.783.1320346014867.JavaMail.geo-discussion-forums at yqhd1> Scott Ware writes: > Python newbie here. So, when creating dictionaries, I am noticing that > each time I print it out, that its not in the same order as when I typed > it in. They seem to be getting sorted somehow. Is there a way to not sort > them and leave the order as is? Dictionaries don't maintain the order of the items. If you want to keep track of the order in which the items were inserted, you'll need to do that yourself using a separate mechanism (a list, for example.) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From scottdware at gmail.com Thu Nov 3 15:00:27 2011 From: scottdware at gmail.com (Scott Ware) Date: Thu, 3 Nov 2011 12:00:27 -0700 (PDT) Subject: Dictionary sorting In-Reply-To: References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <9836933.743.1320346827670.JavaMail.geo-discussion-forums@yqbl36> Great! Thanks, John for the quick response! From ckaynor at zindagigames.com Thu Nov 3 15:13:46 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 3 Nov 2011 12:13:46 -0700 Subject: Dictionary sorting In-Reply-To: <9836933.743.1320346827670.JavaMail.geo-discussion-forums@yqbl36> References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <9836933.743.1320346827670.JavaMail.geo-discussion-forums@yqbl36> Message-ID: Note that there are a number of recipes available for free online, and if you are using a newer version of Python (2.7 or higher), the collections module includes an OrderedDict class (http://docs.python.org/library/collections.html#collections.OrderedDict - this also include a library for Python 2.4 and higher as well). Note that there are a lot of different possible behaviors, so any particular recipe may or may not behave exactly as you desire. Chris On Thu, Nov 3, 2011 at 12:00 PM, Scott Ware wrote: > Great! Thanks, John for the quick response! > -- > http://mail.python.org/mailman/listinfo/python-list > From insomnia at gmail.com Thu Nov 3 16:01:36 2011 From: insomnia at gmail.com (insomnia at gmail.com) Date: Thu, 3 Nov 2011 13:01:36 -0700 (PDT) Subject: Dictionary sorting In-Reply-To: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <19322439.785.1320350496479.JavaMail.geo-discussion-forums@yqpp12> Moreover, for on-the-fly ordering you can consider to use sorted() on yourdict.keys(), like: for k in sorted(yourdict.keys()): print k, yourdict[k] I think it has no side effects, except that the orderering can be slow on huge data sets, and that you need to call it every time after updating the dict keys. Regards, insomniac From Catherine.M.Moroney at jpl.nasa.gov Thu Nov 3 17:15:19 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Thu, 03 Nov 2011 14:15:19 -0700 Subject: Python advanced course (preferably in NA) In-Reply-To: References: Message-ID: <4EB30467.5050905@jpl.nasa.gov> I've taken two Python classes from David Beazley and can second Eric's recommendation. The "advanced" class is really advanced and goes into some pretty mind-blowing stuff. The class comes with lots of problems and solutions, and a book of all the slides which are a great reference. Well worth the time and money! Catherine Eric Snow wrote: > On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: >> Anybody is aware of any advanced course in Python preferably in north >> america? >> >> I've been partly coding in Python for couple of years now and have >> used PyQt. What I'd like to learn more is a kind of advance OOP in >> python. Any idea? > > While I don't know specifically, check out the following link (from > the Python site): > > http://wiki.python.org/moin/PythonTraining > > I have taken a class each (PyCon tutorial) from Raymond Hettinger, > David Beazley, and Brian Jones, and found each of them to be > outstanding courses. Only David is listed on that page to which I > linked, though I know Raymond does courses at least from time to time. > I've also heard a talk from Wesley Chun and found him to be > fantastic. > > -eric > > >> BTW, I'm not a computer engineer and have mechanical background. >> >> Thanks in advance! >> -- >> http://mail.python.org/mailman/listinfo/python-list >> From Catherine.M.Moroney at jpl.nasa.gov Thu Nov 3 17:18:20 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Thu, 03 Nov 2011 14:18:20 -0700 Subject: Python advanced course (preferably in NA) In-Reply-To: References: Message-ID: <4EB3051C.2010202@jpl.nasa.gov> I've taken two Python classes from David Beazley and can second Eric's recommendation. The "advanced" class is really advanced and goes into some pretty mind-blowing stuff. The class comes with lots of problems and solutions, and a book of all the slides which are a great reference. Well worth the time and money! Catherine Eric Snow wrote: > On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: >> Anybody is aware of any advanced course in Python preferably in north >> america? >> >> I've been partly coding in Python for couple of years now and have >> used PyQt. What I'd like to learn more is a kind of advance OOP in >> python. Any idea? > > While I don't know specifically, check out the following link (from > the Python site): > > http://wiki.python.org/moin/PythonTraining > > I have taken a class each (PyCon tutorial) from Raymond Hettinger, > David Beazley, and Brian Jones, and found each of them to be > outstanding courses. Only David is listed on that page to which I > linked, though I know Raymond does courses at least from time to time. > I've also heard a talk from Wesley Chun and found him to be > fantastic. > > -eric > > >> BTW, I'm not a computer engineer and have mechanical background. >> >> Thanks in advance! >> -- >> http://mail.python.org/mailman/listinfo/python-list >> From emile at fenx.com Thu Nov 3 17:25:03 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 03 Nov 2011 14:25:03 -0700 Subject: Python advanced course (preferably in NA) In-Reply-To: References: Message-ID: On 11/3/2011 11:13 AM Behnam said... > Anybody is aware of any advanced course in Python preferably in north > america? > > I've been partly coding in Python for couple of years now and have > used PyQt. What I'd like to learn more is a kind of advance OOP in > python. Any idea? This list works well for that. Try answering all OOP related questions as completely as possible and provide example code. Those that know the difference will promptly point out the improved and generally preferred approaches. When no one corrects you, you're done. Only-slightly-tongue-in-cheek-ly y'rs, Emile From lconrad at Go2France.com Thu Nov 3 17:28:34 2011 From: lconrad at Go2France.com (Len Conrad) Date: Thu, 3 Nov 2011 22:28:34 +0100 Subject: Python advanced course (preferably in NA) Message-ID: <201111032228.AA278266012@mail.Go2France.com> http://www.dabeaz.com/pythonmaster.html ---------- Original Message ---------------------------------- From: Emile van Sebille Date: Thu, 03 Nov 2011 14:25:03 -0700 >On 11/3/2011 11:13 AM Behnam said... >> Anybody is aware of any advanced course in Python preferably in north >> america? >> >> I've been partly coding in Python for couple of years now and have >> used PyQt. What I'd like to learn more is a kind of advance OOP in >> python. Any idea? > >This list works well for that. Try answering all OOP related questions >as completely as possible and provide example code. Those that know the >difference will promptly point out the improved and generally preferred >approaches. When no one corrects you, you're done. > >Only-slightly-tongue-in-cheek-ly y'rs, > >Emile > >-- >http://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Thu Nov 3 17:36:15 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Nov 2011 08:36:15 +1100 Subject: leftover pyc files In-Reply-To: <4EB2D56C.6070208@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <4EB2D56C.6070208@gmail.com> Message-ID: On Fri, Nov 4, 2011 at 4:54 AM, Andrea Crotti wrote: > All these ideas (shell and git hooks) are nice, but unfortunately > - it's svn not git > - it's windows not *nix > - we have to remove only the ones without the corresponding *py... Windows? Well, Windows shell scripting isn't quite as rich as bash/csh/etc, but it's possible. I'll leave recursion as an exercise for the reader, but this (untested) should do it for one directory: for %d in (*.pyc) do ( set fn=%d if not exist !fn:~0,-1! del %d ) This needs to be run with 'cmd /v' to enable delayed variable evaluation. Of course, it'd be really easy to do if Windows Batch had anything like decent string manipulation. ChrisA From tjreedy at udel.edu Thu Nov 3 17:36:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 03 Nov 2011 17:36:25 -0400 Subject: Dictionary sorting In-Reply-To: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On 11/3/2011 2:46 PM, Scott Ware wrote: > Python newbie here. So, when creating dictionaries, I am noticing > that each time I print it out, that its not in the same order as when > I typed it in. They seem to be getting sorted somehow. No, the entries are not being sorted at all. > Is there a way to not sort them and leave the order as is? CPython iterates (and prints) dict items in their arbitrary internal hash table order, which depends on the number and entry order of the items. It is a bug to depend on that arbitrary order in any way. If you want to keep the dict sorted by entry order (as far as the user view goes), use collections.OrderedDict. -- Terry Jan Reedy From joshua.landau.ws at gmail.com Thu Nov 3 18:24:09 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Thu, 3 Nov 2011 22:24:09 +0000 Subject: SystemError when defining Message-ID: Try this out (Python 3.2.2 (default, Sep 5 2011, 04:52:19)): global_variable = None > (lambda *, keyword_only=global_variable: None) # Works, as > expected > (lambda: (lambda argument=global_variable: None))() # Works, as > expected > (lambda: (lambda *, keyword_only=global_variable: None))() # Fails??? > (lambda: (lambda argument=fake_variable: None))() # Fails, as > expected > (lambda: (lambda *, keyword_only=fake_variable: None))() # Fails??? Non-lambdas work as expected, but a lambda inside a non-lambda still exhibits this behaviour. Conclusion: When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython is unable to access the global scope and raises SystemError. -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Thu Nov 3 19:01:38 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 03 Nov 2011 18:01:38 -0500 Subject: Dictionary sorting In-Reply-To: References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <4EB31D52.3080707@tim.thechases.com> On 11/03/11 16:36, Terry Reedy wrote: > > Is there a way to not sort them and leave the order as is? > > CPython iterates (and prints) dict items in their arbitrary internal > hash table order, which depends on the number and entry order of the > items. It is a bug to depend on that arbitrary order in any way. Does this "never trust it" hold even for two consecutive iterations over an unchanged dict? I didn't see anything in the docs[1] to make such a claim, but at least from my experience, one can reliably assert d = {} randomly_populate(d) list1 = list(d.iterkeys()) list2 = list(d.iterkeys()) assert list1 == list2 I understand all bets are off if one adds/removes (or maybe changes the values) of the dict between iterations, but I didn't know if what I saw was merely an implementation detail that shouldn't be counted on. -tkc [1] http://docs.python.org/library/stdtypes.html#mapping-types-dict From rosuav at gmail.com Thu Nov 3 19:51:46 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Nov 2011 10:51:46 +1100 Subject: SystemError when defining In-Reply-To: References: Message-ID: On Fri, Nov 4, 2011 at 9:24 AM, Joshua Landau wrote: > Non-lambdas work as expected, but a lambda inside a non-lambda still > exhibits this behaviour. > Conclusion: > When setting defaults to keyword-only arguments in lambdas which are inside > non-global scopes, cPython is unable to access the global scope and raises > SystemError. Fascinating! I did some introspection with this: >>> def foo(): a=1 # to make sure local variables do exist return (lambda *,keyword_only=global_variable: None)() >>> dis.dis(foo) 2 0 LOAD_CONST 1 (1) 3 STORE_FAST 0 (a) 3 6 LOAD_CONST 2 ('keyword_only') 9 LOAD_NAME 0 (global_variable) 12 LOAD_CONST 3 ( at 0x00FC7340, file "", line 3>) 15 MAKE_FUNCTION 256 18 CALL_FUNCTION 0 21 RETURN_VALUE >>> def foo(): a=1 return (lambda argument=global_variable: None)() >>> dis.dis(foo) 2 0 LOAD_CONST 1 (1) 3 STORE_FAST 0 (a) 3 6 LOAD_GLOBAL 0 (global_variable) 9 LOAD_CONST 2 ( at 0x00F95E30, file "", line 3>) 12 MAKE_FUNCTION 1 15 CALL_FUNCTION 0 18 RETURN_VALUE Variations on the theme show that during compilation of foo, the name is normally cemented as either a global or a local - but if it's keyword-only, then a LOAD_NAME opcode is emitted. It's the code for LOAD_NAME that looks for locals, which presumably a lambda doesn't have. ChrisA From rosuav at gmail.com Thu Nov 3 19:59:43 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Nov 2011 10:59:43 +1100 Subject: Dictionary sorting In-Reply-To: <4EB31D52.3080707@tim.thechases.com> References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <4EB31D52.3080707@tim.thechases.com> Message-ID: On Fri, Nov 4, 2011 at 10:01 AM, Tim Chase wrote: > list1 = list(d.iterkeys()) > ?list2 = list(d.iterkeys()) > ?assert list1 == list2 > There is such a guarantee in Python 2. From http://docs.python.org/library/stdtypes.html: "If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond. This allows the creation of (value, key) pairs using zip(): pairs = zip(d.values(), d.keys()). The same relationship holds for the iterkeys() and itervalues() methods: pairs = zip(d.itervalues(), d.iterkeys()) provides the same value for pairs. Another way to create the same list is pairs = [(v, k) for (k, v) in d.iteritems()]." Python 3 does things quite differently (with views), and I can't find a corresponding promise, but I expect that this would still be the case. ChrisA From ben+python at benfinney.id.au Thu Nov 3 20:06:20 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 04 Nov 2011 11:06:20 +1100 Subject: Dictionary sorting References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <8739e4n43n.fsf@benfinney.id.au> Tim Chase writes: > On 11/03/11 16:36, Terry Reedy wrote: > > CPython iterates (and prints) dict items in their arbitrary internal > > hash table order, which depends on the number and entry order of the > > items. It is a bug to depend on that arbitrary order in any way. > > Does this "never trust it" hold even for two consecutive iterations > over an unchanged dict? I didn't see anything in the docs[1] to make > such a claim, Exactly. The order of retrieval is entirely up to the implementation. There is no guarantee that the order will be the same the next time you iterate over the same dict. It is a bug to depend on a reliable order of retrieving the items. > I didn't know if what I saw was merely an implementation detail that > shouldn't be counted on. If the docs don't specify some particular observed behaviour in Python, you should consider it an implementation detail. -- \ ?Pray, v. To ask that the laws of the universe be annulled in | `\ behalf of a single petitioner confessedly unworthy.? ?Ambrose | _o__) Bierce, _The Devil's Dictionary_, 1906 | Ben Finney From drobinow at gmail.com Thu Nov 3 20:14:31 2011 From: drobinow at gmail.com (David Robinow) Date: Thu, 3 Nov 2011 20:14:31 -0400 Subject: leftover pyc files In-Reply-To: <4EB2D56C.6070208@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <4EB2D56C.6070208@gmail.com> Message-ID: On Thu, Nov 3, 2011 at 1:54 PM, Andrea Crotti wrote: > All these ideas (shell and git hooks) are nice, but unfortunately > - it's svn not git > - it's windows not *nix > - we have to remove only the ones without the corresponding *py... > -- > http://mail.python.org/mailman/listinfo/python-list > Barely tested. Change the print functions to removes. Pass the top directory as the argument. import os, sys for dirpath, dirnames, filenames in os.walk(sys.argv[1]): if dirpath.endswith("__pycache__"): thispath = dirpath[:-11] for f in filenames: if f.endswith(".pyc"): if not os.path.exists(os.path.join(thispath,f[:-1])): print("delete " + os.path.join(thispath,f)) else: for f in filenames: if f.endswith(".pyc"): if not os.path.exists(os.path.join(dirpath,f[:-1])): print("delete " + os.path.join(dirpath,f)) #os.remove(os.path.join(dirpath,f)) From anthony.hw.kong at gmail.com Thu Nov 3 20:33:04 2011 From: anthony.hw.kong at gmail.com (Anthony Kong) Date: Thu, 3 Nov 2011 17:33:04 -0700 (PDT) Subject: Design Pattern and Python: Any book recommendation? Your view? Message-ID: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Sorry to resurrect this topic. By google search the last discussion was in 2003. I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy From roy at panix.com Thu Nov 3 21:46:53 2011 From: roy at panix.com (Roy Smith) Date: Thu, 03 Nov 2011 21:46:53 -0400 Subject: Design Pattern and Python: Any book recommendation? Your view? References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: In article <6097694.446.1320366784098.JavaMail.geo-discussion-forums at prap37>, Anthony Kong wrote: > Sorry to resurrect this topic. By google search the last discussion was in > 2003. What? We're bring it up again, SO SOON!? > I would like to find out what is the current prevailing view or consensus (if > any) on the use of Design Pattern in python? > [...] > I myself pretty much subscribe to the view that the nature of python language > actually do away much of the need of the use of DP To a certain extent, I agree. I don't have a huge amount of experience in Design Patterns, but have read (years ago) the obligatory Gang Of Four book. My impression was that much of that book was about how to build sane data structures to do useful things given the uber-bondage constraints of the C++ and Java typing systems. For example, let's look at Singleton. It's a useful pattern. Here's how I would implement Singleton in Python (hand-waving a bit about the syntax details): class Printer: thePrinter = None @staticmethod def get(): if Printer.thePrinter is None: Printer.thePrinter = Printer() return thePrinter def print(self): "print some stuff" whatever That seems to cover everything Singleton needs to do. In your application code, you do: myPrinter = Printer.get() myPrinter.print(....) and you can sleep easy knowing you've got the same Printer instance every time. The GoF version for C++ is filled with minutia about private constructors and assignment operators. All that stuff is important to get right in C++, but it has nothing to do with Singleton, per se. It's just all the gunk you have to worry about to correctly implement Singleton in C++. From clp2 at rebertia.com Thu Nov 3 22:15:02 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 3 Nov 2011 19:15:02 -0700 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: On Thu, Nov 3, 2011 at 5:33 PM, Anthony Kong wrote: > Sorry to resurrect this topic. By google search the last discussion was in 2003. > > I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? I can only speak for myself, but the whole idea of design patterns is broken. The existence of nontrivial design patterns indicates language deficiencies. For more extensive corroborating discussions, see: http://www.codinghorror.com/blog/2005/06/are-design-patterns-how-languages-evolve.html http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures Python thankfully has relatively few/minor deficiencies (so long as one judges it within its dynamic language niche), so design patterns per se aren't too relevant to it. The canonical Python-specific design pattern is Borg (http://code.activestate.com/recipes/66531-singleton-we-dont-need-no-stinkin-singleton-the-bo/ ) [a variation on Singleton], and nowadays it (like its parent, Singleton) is considered to be of dubious utility/advisability. > I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. The closest alternative would be some publication that gave examples of using some of Python's fancier, higher-level features, such as metaclasses and context managers. I haven't been in the market for such a book, so I have no good recommendations to give. Closest I could suggest would be the Language Reference (http://docs.python.org/reference/ ) and relevant PEPs (http://www.python.org/dev/peps/ ; they tend to include examples by way of motivating use-cases). > I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy I am glad you agree. Cheers, Chris -- http://rebertia.com From macmanes at gmail.com Thu Nov 3 22:55:29 2011 From: macmanes at gmail.com (Matt) Date: Thu, 3 Nov 2011 19:55:29 -0700 (PDT) Subject: match, concatenate based on filename Message-ID: <31568428.553.1320375329695.JavaMail.geo-discussion-forums@prgt40> Hi All, I am trying to concatenate several hundred files based on their filename.. Filenames are like this: Q1.HOMOblast.fasta Q1.mus.blast.fasta Q1.query.fasta Q2.HOMOblast.fasta Q2.mus.blast.fasta Q2.query.fasta ... Q1223.HOMOblast.fasta Q1223.mus.blast.fasta Q1223.query.fasta All the Q1's should be concatenated together in a single file = Q1.concat.fasta.. Q2's go together, Q3's and so on... I envision something like for file in os.listdir("/home/matthew/Desktop/pero.ngs/fasta/final/"): if file.startswith("Q%i"): concatenate... But I can't figure out how to iterate this process over Q-numbers 1-1223 Any help appreciate. From pmaupin at gmail.com Thu Nov 3 23:08:42 2011 From: pmaupin at gmail.com (Patrick Maupin) Date: Thu, 3 Nov 2011 20:08:42 -0700 (PDT) Subject: match, concatenate based on filename References: <31568428.553.1320375329695.JavaMail.geo-discussion-forums@prgt40> Message-ID: <483db563-19e7-4219-8854-9a65a8c4a88d@v5g2000vbh.googlegroups.com> On Nov 3, 9:55?pm, Matt wrote: > Hi All, > > I am trying to concatenate several hundred files based on their filename.. ?Filenames are like this: > > Q1.HOMOblast.fasta > Q1.mus.blast.fasta > Q1.query.fasta > Q2.HOMOblast.fasta > Q2.mus.blast.fasta > Q2.query.fasta > ... > Q1223.HOMOblast.fasta > Q1223.mus.blast.fasta > Q1223.query.fasta > > All the Q1's should be concatenated together in a single file = Q1.concat.fasta.. Q2's go together, Q3's and so on... > > I envision something like > > for file in os.listdir("/home/matthew/Desktop/pero.ngs/fasta/final/"): > ? ? ? ? if file.startswith("Q%i"): > ? ? ? ? ? ?concatenate... > > But I can't figure out how to iterate this process over Q-numbers 1-1223 > > Any help appreciate. I haven't tested this, so may have a typo or something, but it's often much cleaner to gather your information, massage it, and then use, than it is to gather it and use it in one go. from collections import defaultdict filedict = defaultdict(list) for fname in sorted(os.listdir(mydir)): if fname.startswith('Q') and '.' in fname: filedict[fname[:fname.find('.')]].append(fname) for prefix, fnames in filedict.iteritems(): #print prefix, fnames concatenate... HTH, Pat From gordon at panix.com Thu Nov 3 23:17:34 2011 From: gordon at panix.com (John Gordon) Date: Fri, 4 Nov 2011 03:17:34 +0000 (UTC) Subject: match, concatenate based on filename References: <31568428.553.1320375329695.JavaMail.geo-discussion-forums@prgt40> Message-ID: In <31568428.553.1320375329695.JavaMail.geo-discussion-forums at prgt40> Matt writes: > But I can't figure out how to iterate this process over Q-numbers 1-1223 for i in xrange(1, 1224): Q = "Q%d" % i file1 = "%s.HOMOblast.fasta" % Q file2 = "%s.mus.blast.fasta" % Q file3 = "%s.query.fasta" % Q target = "%s.concat.fasta" % Q concatenate(file1, file2, file3, target) Assuming that there are exactly three files to be concatenated for each value of i. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From dihedral88888 at googlemail.com Fri Nov 4 02:24:03 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 3 Nov 2011 23:24:03 -0700 (PDT) Subject: Database access benchmarks for use in web-frameworks - How does Python compare? In-Reply-To: References: Message-ID: <292753.379.1320387843748.JavaMail.geo-discussion-forums@prev11> I suggest that the use of dynamical page forwarding to different severs which run the same software package. This can be done in python! From dihedral88888 at googlemail.com Fri Nov 4 02:24:03 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 3 Nov 2011 23:24:03 -0700 (PDT) Subject: Database access benchmarks for use in web-frameworks - How does Python compare? In-Reply-To: References: Message-ID: <292753.379.1320387843748.JavaMail.geo-discussion-forums@prev11> I suggest that the use of dynamical page forwarding to different severs which run the same software package. This can be done in python! From steve+comp.lang.python at pearwood.info Fri Nov 4 02:48:35 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Nov 2011 06:48:35 GMT Subject: leftover pyc files References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <4eb38ac2$0$29968$c3e8da3$5496439d@news.astraweb.com> On Thu, 03 Nov 2011 17:54:52 +0000, Andrea Crotti wrote: > All these ideas (shell and git hooks) are nice, but unfortunately - it's > svn not git > - it's windows not *nix > - we have to remove only the ones without the corresponding *py... Does it matter? The other .pyc files will be recreated when they are next needed. Just nuke all the .pyc files and be done with it. Or if you can't bear having to wait for Python to compile them as needed, you can force compilation by running your test suite (you do have a test suite, don't you?) or by using the compileall.py script. python -m compileall some_directory should do the trick. -- Steven From nobody at nowhere.com Fri Nov 4 04:26:25 2011 From: nobody at nowhere.com (Nobody) Date: Fri, 04 Nov 2011 08:26:25 +0000 Subject: ctypes: catch system exit from C library References: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> <10eao8-84g.ln1@satorlaser.homedns.org> Message-ID: On Thu, 03 Nov 2011 14:16:50 +0000, Grant Edwards wrote: >>> in my python application I am calling functions from a C library via >>> `ctypes` interface. Some fns from that C library calls `exit()` on >>> error. >> Just curious, which library is that? I'm reasonably sure that he's talking about the GRASS libraries. In which, the standard error-handling mechanism is to call G_fatal_error(), which ultimately calls exit(). AKA the "samurai principle": return victorious, or don't return at all. [FWIW, re-writing everying in C++ and using exceptions is not a realistic option]. > And who should we have thrashed and pilloried for writing it that way? No-one. It's a perfectly rational design given the context. GRASS consists of ~350 command-line programs ("modules") in the traditional Unix style (read command-line arguments, do processing, terminate). The libraries exist to support the creation of such modules, and are fit for that particular purpose. Handling errors by having status codes which propagate up the call chain would add a significant amount of code. More importantly, it would push the burden of handling errors onto the authors of the various modules (and historical evidence suggests that checking for (let alone handling) errors is unlikely to occur). The mechanism works fine, so long as you don't try to use the libraries for purposes for which they weren't designed (e.g. long-running programs such as interactive applications or servers). As the story goes ... Patient: "Doctor, when I do this ... it hurts" Doctor: "Well don't do it then!" From stefan_ml at behnel.de Fri Nov 4 04:34:33 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 04 Nov 2011 09:34:33 +0100 Subject: Database access benchmarks for use in web-frameworks - How does Python compare? In-Reply-To: References: Message-ID: Alec Taylor, 03.11.2011 11:19: > I'm building a large e-commerce site, and it is very important that > what I write can: > - Handle larger server load > - Deliver pages quickly > - Make transactions quickly Those are pretty broad requirements. If a framework can satisfy them or not depends more on how you set it up and deploy it (e.g. how many servers you run, what kind of load balancing you use, how you serve your static content, etc.) than the actual framework you choose, I'd say. > as well as have a small development time (i.e. pre-built modules for > e-commerce are available, and extendible). "e-commerce" is also a very broad term. But I'd expect that any of the recent web frameworks (certainly including Django) will satisfy your needs in some way. > Are there recent accessible statistics available, comparing these > metrics across the most popular web-frameworks? (i.e. Symfony, DJango, > Rails, ASP.NET&etc) Not that I know of. Stefan From tartley at tartley.com Fri Nov 4 05:27:58 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Fri, 4 Nov 2011 02:27:58 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> I like to install a Bash shell of some kind on windows boxes I work on, specifically so I can use shell commands like this, just like on any other operating system. Cywin works just fine for this. svn also has hooks, but sadly not a checkout hook: http://svnbook.red-bean.com/en/1.1/ch05s02.html I guess you could write your own two-line wrapper script which does the checkout and then deletes the pyc files. I don't understand why deleting only some pyc files is important. Can't you just delete them all and let Python re generate the ones you need? I once saw someone create the longest python file they could to see how long generating pyc files takes, and it is very very quick indeed. A human could not notice the delay even for the largest of projects. Finally, someone asked about skipping .svn dirs: find has a '-prune' option, you can read about it on the manpage. From tartley at tartley.com Fri Nov 4 05:27:58 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Fri, 4 Nov 2011 02:27:58 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> I like to install a Bash shell of some kind on windows boxes I work on, specifically so I can use shell commands like this, just like on any other operating system. Cywin works just fine for this. svn also has hooks, but sadly not a checkout hook: http://svnbook.red-bean.com/en/1.1/ch05s02.html I guess you could write your own two-line wrapper script which does the checkout and then deletes the pyc files. I don't understand why deleting only some pyc files is important. Can't you just delete them all and let Python re generate the ones you need? I once saw someone create the longest python file they could to see how long generating pyc files takes, and it is very very quick indeed. A human could not notice the delay even for the largest of projects. Finally, someone asked about skipping .svn dirs: find has a '-prune' option, you can read about it on the manpage. From tartley at tartley.com Fri Nov 4 05:29:49 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Fri, 4 Nov 2011 02:29:49 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <8460773.112.1320398989273.JavaMail.geo-discussion-forums@yqie15> Apologies for all my messasges appearing twice. I'm using google groups web ui and have no idea why it's doing that. I'll stop using it. From ulrich.eckhardt at dominolaser.com Fri Nov 4 05:49:07 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 04 Nov 2011 10:49:07 +0100 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: Am 04.11.2011 01:33, schrieb Anthony Kong: > I would like to find out what is the current prevailing view or > consensus (if any) on the use of Design Pattern in python? My consensus with myself is that design patterns are language-agnostic. If I write "class Foo serves as view and controller for class Bar in a model-view-controller (MVC) design", everybody that knows MVC has immediately a very high-level understanding of how those two classes interact. > I am doing some 'fact-finding' in this area on request of my > colleagues. Some of them want to buy a book or two in this subject > area. Hopefully the newsgroup can give me some book recommendation > and insight in this topic. The Gang of Four book on design patterns is one you will probably come across, and there are many that refer to it. > I myself pretty much subscribe to the view that the nature of python > language actually do away much of the need of the use of DP, but it > is just a personal view. It comes form my experience of migrating > from webware4py (webframework based on J2EE/servlet idea) to > cherrypy "webframework based on J2EE/servlet" - apart from J2EE being a specific implementation, this also describes a design pattern, i.e. one where (forgive me if I'm slightly off, this is not actually my field of programming) the UI is browser-based and the program logic runs on a server. Instead of explaining it in many words, you reused the known design pattern to describe it, and that is also IMHO what design patterns are about. They serve as a tool to make software that follows known patterns, so that people that know the pattern will recognize them and then get easier understanding. It also serves as tool when talking about things, you don't have to explain the design when you can refer to a pattern. In that sense, I fully disagree that design patterns are obsolete in Python. However, there are other patterns that are more language-specific, like e.g. RAII in C++, so if you rather meant those, I would agree with you. Cheers! Uli From hniksic at xemacs.org Fri Nov 4 06:20:06 2011 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Fri, 04 Nov 2011 11:20:06 +0100 Subject: Dictionary sorting References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <8739e4n43n.fsf@benfinney.id.au> Message-ID: <87d3d8mbop.fsf@xemacs.org> Ben Finney writes: > Tim Chase writes: > >> On 11/03/11 16:36, Terry Reedy wrote: >> > CPython iterates (and prints) dict items in their arbitrary internal >> > hash table order, which depends on the number and entry order of the >> > items. It is a bug to depend on that arbitrary order in any way. >> >> Does this "never trust it" hold even for two consecutive iterations >> over an unchanged dict? I didn't see anything in the docs[1] to make >> such a claim, > > Exactly. This is false. The docs say: If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond. This allows the creation of (value, key) pairs using zip(): pairs = zip(d.values(), d.keys()). (http://docs.python.org/library/stdtypes.html#mapping-types-dict) > The order of retrieval is entirely up to the implementation. This part is still true, but the order won't change behind your back if you're not touching the dict. From andrea.crotti.0 at gmail.com Fri Nov 4 06:34:11 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 04 Nov 2011 10:34:11 +0000 Subject: leftover pyc files In-Reply-To: <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <4EB3BFA3.4090802@gmail.com> On 11/04/2011 09:27 AM, Jonathan Hartley wrote: > I like to install a Bash shell of some kind on windows boxes I work on, specifically so I can use shell commands like this, just like on any other operating system. Cywin works just fine for this. > > svn also has hooks, but sadly not a checkout hook: > http://svnbook.red-bean.com/en/1.1/ch05s02.html > I guess you could write your own two-line wrapper script which does the checkout and then deletes the pyc files. > > I don't understand why deleting only some pyc files is important. Can't you just delete them all and let Python re generate the ones you need? I once saw someone create the longest python file they could to see how long generating pyc files takes, and it is very very quick indeed. A human could not notice the delay even for the largest of projects. > > Finally, someone asked about skipping .svn dirs: find has a '-prune' option, you can read about it on the manpa Uhm yes it makes sense also to just remove all of them, I don't know why it was done like this but probably for "performance" reasons. I will try both ways, but I would definitively avoid the shell scripting, because it's mainly windows but it has to be multi-platform.. From rosuav at gmail.com Fri Nov 4 06:39:14 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Nov 2011 21:39:14 +1100 Subject: leftover pyc files In-Reply-To: <4EB3BFA3.4090802@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> Message-ID: On Fri, Nov 4, 2011 at 9:34 PM, Andrea Crotti wrote: > Uhm yes it makes sense also to just remove all of them, I don't know why it > was done like this but > probably for "performance" reasons. > > I will try both ways, but I would definitively avoid the shell scripting, > because it's mainly windows > but it has to be multi-platform.. If you're removing them all, you don't need to use a powerful shell. Much much easier! Just recursively del *.pyc and you're done. ChrisA From joshua.landau.ws at gmail.com Fri Nov 4 06:49:39 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Fri, 4 Nov 2011 10:49:39 +0000 Subject: SystemError when defining In-Reply-To: References: Message-ID: On 11/3/11, Chris Angelico wrote: > Fascinating! Awesome to know! > I did some introspection with this: > *snip* > > Variations on the theme show that during compilation of foo, the name > is normally cemented as either a global or a local - but if it's > keyword-only, then a LOAD_NAME opcode is emitted. It's the code for > LOAD_NAME that looks for locals, which presumably a lambda doesn't > have. What is the LOAD_NAME for? The non-keyword default doesn't seem to need it. From andrea.crotti.0 at gmail.com Fri Nov 4 07:00:50 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 04 Nov 2011 11:00:50 +0000 Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> Message-ID: <4EB3C5E2.3020702@gmail.com> On 11/04/2011 10:39 AM, Chris Angelico wrote: > If you're removing them all, you don't need to use a powerful shell. > Much much easier! Just recursively del *.pyc and you're done. ChrisA Discussing with the guy that did it I think it's actually a good idea instead, because removing them *all* means. - remove a few thousand files every time where maybe 0 would be removed otherwise - recompile the same thousand of files It might not be so relevant but for 10 lines of code more I guess it's fine.. From lbrt Fri Nov 4 07:48:02 2011 From: lbrt (lbrt) Date: 04 Nov 2011 11:48:02 GMT Subject: python-based downloader (youtube-dl) missing critical feature ... Message-ID: <1320407282.243739@nntp.aceinnovative.com> python-based youtube-dl ~ http://rg3.github.com/youtube-dl/ ~ is sorely missing a flag in order to indicate the maximum file length of the data feed it would download (well, unless, for some reason, it is considered a "feature"). ~ I wonder what developers were thinking about when they came up this nice piece of code. If you actually look in the code ~ ... data = urllib2.urlopen(basic_request) content_length = data.info()['Content-Length'] ... ~ you will see they get the content length of the actual data feed and they also print the progress status based on the content length ~ Implementing an if statement a la: ~ max_indicated_content_length = self.params.get('max_content_length', None); ~ if( content_length > max_indicated_content_length ){ [do not download, just report "data feed too large"] } else{ [do] } ~ shouldn't be hard at all ~ youtube-dl is under the Creative Commons License copyrighted by 2006-2011 Ricardo Garcia Gonzalez and maintained by him and a group of python developers ~ They are the ones keeping a mental map of that project. It would be a plus if they implement this feature, but anyother python developer can implemented (please, let me know if/when you do) ~ lbrtchx From ben+python at benfinney.id.au Fri Nov 4 08:19:25 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 04 Nov 2011 23:19:25 +1100 Subject: Dictionary sorting References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <8739e4n43n.fsf@benfinney.id.au> <87d3d8mbop.fsf@xemacs.org> Message-ID: <87y5vwkrle.fsf@benfinney.id.au> Hrvoje Niksic writes: > Ben Finney writes: > > > Tim Chase writes: > >> Does this "never trust it" hold even for two consecutive iterations > >> over an unchanged dict? I didn't see anything in the docs[1] to make > >> such a claim, > > > > Exactly. > > This is false. The docs say: > > If items(), keys(), values(), iteritems(), iterkeys(), and > itervalues() are called with no intervening modifications to the > dictionary, the lists will directly correspond. This allows the > creation of (value, key) pairs using zip(): pairs = zip(d.values(), > d.keys()). > > (http://docs.python.org/library/stdtypes.html#mapping-types-dict) Thank you for this correction. -- \ ?Firmness in decision is often merely a form of stupidity. It | `\ indicates an inability to think the same thing out twice.? | _o__) ?Henry L. Mencken | Ben Finney From johnroth1 at gmail.com Fri Nov 4 08:28:23 2011 From: johnroth1 at gmail.com (John Roth) Date: Fri, 4 Nov 2011 05:28:23 -0700 (PDT) Subject: Design Pattern and Python: Any book recommendation? Your view? References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: <0531d3c1-61c6-41f6-a74a-fe3d24a731fb@x2g2000vbd.googlegroups.com> On Nov 3, 6:33?pm, Anthony Kong wrote: > Sorry to resurrect this topic. By google search the last discussion was in 2003. > > I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? > > I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. > > I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy I don't know of a book on design patterns in Python. I've got a couple of observations. The first is that if you use TDD (Test Driven Development) and refactor relentlessly to remove duplication, most of the basic design patterns will emerge naturally from the code as you work. The second is that, as far as I'm concerned, the utility of a design patterns book is in the discussion of what the pattern is good for, and what it isn't good for. That is, as another poster says, language agnostic. John Roth From steve+comp.lang.python at pearwood.info Fri Nov 4 08:32:08 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Nov 2011 12:32:08 GMT Subject: python-based downloader (youtube-dl) missing critical feature ... References: <1320407282.243739@nntp.aceinnovative.com> Message-ID: <4eb3db48$0$29968$c3e8da3$5496439d@news.astraweb.com> On Fri, 04 Nov 2011 11:48:02 +0000, lbrt chx _ gemale wrote: > python-based youtube-dl > ~ > http://rg3.github.com/youtube-dl/ > ~ > is sorely missing a flag in order to indicate the maximum file length > of the data feed it would download (well, unless, for some reason, it > is considered a "feature"). If you are making a feature request, you should make it directly to the project developer, and not here. Since you consider that feature "shouldn't be hard at all" (your words), perhaps you should consider providing a patch? Don't forget the documentation and tests for it. Or did you mean "it shouldn't be hard for me, if somebody else does the work"? > ~ > I wonder what developers were thinking about when they came up this > nice piece of code. If you actually look in the code [...] Lbrtchx, it's possible that English is not your natural language. Please be aware that, in English, "what they were thinking..." is often used sarcastically, as in "they weren't actually thinking". Particularly following your use of scare quotes around "feature". (Even more so for the similar form, "what were they thinking?".) It's probably not going to help you get a feature added to the project if you imply (even by accident) that lack of that feature is an indication that the developer wasn't thinking. -- Steven From goon12 at gmail.com Fri Nov 4 08:41:00 2011 From: goon12 at gmail.com (Joe Riopel) Date: Fri, 4 Nov 2011 08:41:00 -0400 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <0531d3c1-61c6-41f6-a74a-fe3d24a731fb@x2g2000vbd.googlegroups.com> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> <0531d3c1-61c6-41f6-a74a-fe3d24a731fb@x2g2000vbd.googlegroups.com> Message-ID: On Fri, Nov 4, 2011 at 8:28 AM, John Roth wrote: > The first is that if you use TDD (Test Driven Development) and > refactor relentlessly to remove duplication, most of the basic design > patterns will emerge naturally from the code as you work. I agree, and there is a pretty good series of articles on developerWorks that covers this: http://www.ibm.com/developerworks/java/library/j-eaed2/index.html The author used Java in this series, but as Ulrich mentioned, I feel that design patterns (and emergent design) are "language-agnostic.". From phihag at phihag.de Fri Nov 4 08:45:23 2011 From: phihag at phihag.de (Philipp Hagemeister) Date: Fri, 04 Nov 2011 13:45:23 +0100 Subject: python-based downloader (youtube-dl) missing critical feature ... In-Reply-To: <1320407282.243739@nntp.aceinnovative.com> References: <1320407282.243739@nntp.aceinnovative.com> Message-ID: <4EB3DE63.4050900@phihag.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 As already said, you should file your request at https://github.com/rg3/youtube-dl/issue , not here. A few things to note: * Not all sites necessarily send the Content-Length header. * RTMP URLs would have to be treated differently * Sending a Range header might allow for a better implementation. Why do you want to restrict the filesize of the download in the first place? I can't see a use case, but that doesn't mean there isn't one. Due to me not having lots of time at the moment, your best chance to get any youtube-dl feature implemented is providing a patch (in form of a github pull-request, if possible). - -- Philipp (youtube-dl developer) lbrt at mail.python.org wrote: > python-based youtube-dl > ~ > http://rg3.github.com/youtube-dl/ > ~ > is sorely missing a flag in order to indicate the maximum file length of the data feed it would download (well, unless, for some reason, it is considered a "feature"). > ~ > I wonder what developers were thinking about when they came up this nice piece of code. If you actually look in the code > ~ > ... > data = urllib2.urlopen(basic_request) > content_length = data.info()['Content-Length'] > ... > ~ > you will see they get the content length of the actual data feed and they also print the progress status based on the content length > ~ > Implementing an if statement a la: > ~ > max_indicated_content_length = self.params.get('max_content_length', None); > ~ > if( content_length > max_indicated_content_length ){ [do not download, just report "data feed too large"] } > else{ [do] } > ~ > shouldn't be hard at all > ~ > youtube-dl is under the Creative Commons License copyrighted by 2006-2011 Ricardo Garcia Gonzalez and maintained by him and a group of python developers > ~ > They are the ones keeping a mental map of that project. It would be a plus if they implement this feature, but anyother python developer can implemented (please, let me know if/when you do) > ~ > lbrtchx -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEAREKAAYFAk6z3mMACgkQ9eq1gvr7CFyr1wCgpqf8xuORDC4LBVY8WFmtAufG k+AAoIX+mXa7SGLULP2M67IQ34sBgk1o =duyH -----END PGP SIGNATURE----- From andrea.crotti.0 at gmail.com Fri Nov 4 08:46:10 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 04 Nov 2011 12:46:10 +0000 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: <4EB3DE92.7040108@gmail.com> On 11/04/2011 12:33 AM, Anthony Kong wrote: > Sorry to resurrect this topic. By google search the last discussion was in 2003. > > I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? > > I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. > > I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy > > > Well this book is work in progress https://bitbucket.org/BruceEckel/python-3-patterns-idioms/src but it actually looks very interesting From bkamrani at gmail.com Fri Nov 4 09:17:16 2011 From: bkamrani at gmail.com (Behnam) Date: Fri, 4 Nov 2011 06:17:16 -0700 (PDT) Subject: Python advanced course (preferably in NA) References: <4EB3051C.2010202@jpl.nasa.gov> Message-ID: <10127b29-23c5-4929-a20c-8a89ce6e385d@t8g2000yql.googlegroups.com> This was great. Thank you all! /Behnam On Nov 3, 5:18?pm, Catherine Moroney wrote: > I've taken twoPythonclasses from David Beazley and can second > Eric's recommendation. ?The "advanced" class is reallyadvanced > and goes into some pretty mind-blowing stuff. ?The class comes with > lots of problems and solutions, and a book of all the slides which are > a great reference. ?Well worth the time and money! > > Catherine > > > > > > > > Eric Snow wrote: > > On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: > >> Anybody is aware of anyadvancedcourseinPythonpreferably in north > >> america? > > >> I've been partly coding inPythonfor couple of years now and have > >> used PyQt. What I'd like to learn more is a kind of advance OOP in > >>python. Any idea? > > > While I don't know specifically, check out the following link (from > > thePythonsite): > > >http://wiki.python.org/moin/PythonTraining > > > I have taken a class each (PyCon tutorial) from Raymond Hettinger, > > David Beazley, and Brian Jones, and found each of them to be > > outstanding courses. ?Only David is listed on that page to which I > > linked, though I know Raymond does courses at least from time to time. > > ?I've also heard a talk from Wesley Chun and found him to be > > fantastic. > > > -eric > > >> BTW, I'm not a computer engineer and have mechanical background. > > >> Thanks in advance! > >> -- > >>http://mail.python.org/mailman/listinfo/python-list From dihedral88888 at googlemail.com Fri Nov 4 09:31:32 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 4 Nov 2011 06:31:32 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> Message-ID: <24728053.972.1320413492633.JavaMail.geo-discussion-forums@prog16> Uhn, thanks for the easy way Just delete all *.pyc recursively. spend another 5-20 minutes to recompile all to get everything sync.. That is trivial! From dihedral88888 at googlemail.com Fri Nov 4 09:31:32 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 4 Nov 2011 06:31:32 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> Message-ID: <24728053.972.1320413492633.JavaMail.geo-discussion-forums@prog16> Uhn, thanks for the easy way Just delete all *.pyc recursively. spend another 5-20 minutes to recompile all to get everything sync.. That is trivial! From jeanmichel at sequans.com Fri Nov 4 09:31:42 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 04 Nov 2011 14:31:42 +0100 Subject: python-based downloader (youtube-dl) missing critical feature ... In-Reply-To: <4eb3db48$0$29968$c3e8da3$5496439d@news.astraweb.com> References: <1320407282.243739@nntp.aceinnovative.com> <4eb3db48$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4EB3E93E.50500@sequans.com> Steven D'Aprano wrote: > On Fri, 04 Nov 2011 11:48:02 +0000, lbrt chx _ gemale wrote: > > >> python-based youtube-dl >> ~ >> http://rg3.github.com/youtube-dl/ >> ~ >> is sorely missing a flag in order to indicate the maximum file length >> of the data feed it would download (well, unless, for some reason, it >> is considered a "feature"). >> > > If you are making a feature request, you should make it directly to the > project developer, and not here. > > Since you consider that feature "shouldn't be hard at all" (your words), > perhaps you should consider providing a patch? Don't forget the > documentation and tests for it. > > Or did you mean "it shouldn't be hard for me, if somebody else does the > work"? > > > >> ~ >> I wonder what developers were thinking about when they came up this >> nice piece of code. If you actually look in the code >> > [...] > > Lbrtchx, it's possible that English is not your natural language. Please > be aware that, in English, "what they were thinking..." is often used > sarcastically, as in "they weren't actually thinking". Particularly > following your use of scare quotes around "feature". > > (Even more so for the similar form, "what were they thinking?".) > > It's probably not going to help you get a feature added to the project if > you imply (even by accident) that lack of that feature is an indication > that the developer wasn't thinking. > > > Maybe Lbrtchx is one of the Sheldon Cooper's nicknames :o) JM PS : I have the feeling that my nerdy reference will fall flat... From slehar at gmail.com Fri Nov 4 11:10:58 2011 From: slehar at gmail.com (Steven Lehar) Date: Fri, 4 Nov 2011 11:10:58 -0400 Subject: Line continuation issue\ Message-ID: Is this the right place to propose language extensions? My Python code keeps expanding rightwards, it is difficult to keep it contained within reasonable limits. But the standard line continuation \ is positively anti-Pythonic because an *invisible* white space between \ and [CR] will render it useless. How about a new Python symbol, maybe \\ that CAN have following whitespace which is ignored, so that seeing a \\ in the code forces it to continue on the next line. Has this issue been discussed already? slehar -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Fri Nov 4 11:38:32 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 04 Nov 2011 16:38:32 +0100 Subject: Line continuation issue\ References: Message-ID: Steven Lehar wrote: > Is this the right place to propose language extensions? > > My Python code keeps expanding rightwards, it is difficult to keep it > contained within reasonable limits. You should attack this by breaking large expressions into smaller ones and factoring out some of your code into helper functions. > But the standard line continuation \ > is positively anti-Pythonic because an *invisible* white space between \ > and [CR] will render it useless. Useless? You get a SyntaxError, remove the offending whitespace, and that's it. > How about a new Python symbol, maybe \\ that CAN have following whitespace > which is ignored, so that seeing a \\ in the code forces it to continue on > the next line. Did you know that there already is a pythonic alternative that works well in most cases? An open (, [, or { will allow you to continue on the next line, e. g. items = [(foo(item), bar(item)) for row in rows for item in row if baz( alpha=1, beta=item)] no strings attached. From rosuav at gmail.com Fri Nov 4 11:42:11 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Nov 2011 02:42:11 +1100 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: On Sat, Nov 5, 2011 at 2:10 AM, Steven Lehar wrote: > But the standard line continuation \ > is positively anti-Pythonic because an *invisible* white space between \ and > [CR] will render it useless. How's it anti-Pythonic for invisible whitespace differences to be significant? ChrisA *grinning, running, and ducking* From slehar at gmail.com Fri Nov 4 11:53:57 2011 From: slehar at gmail.com (Steven Lehar) Date: Fri, 4 Nov 2011 11:53:57 -0400 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: > How's it anti-Pythonic for invisible whitespace differences to be significant? A central idea of Python was to replace {curly;braces{and;parentheses;}}, which are easily overlooked by the programmer, and use WHITESPACE instead, something that is clearly visible to the programmer, as the defining syntax. Make what is visible to humans significant to the interpreter. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Fri Nov 4 11:56:19 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Nov 2011 02:56:19 +1100 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: On Sat, Nov 5, 2011 at 2:53 AM, Steven Lehar wrote: > > > > How's it anti-Pythonic for invisible whitespace differences to be significant? > A central idea of Python was to replace {curly;braces{and;parentheses;}}, which are easily overlooked by the programmer, and use WHITESPACE instead, something that is clearly visible to the programmer, as the defining syntax. Make what is visible to humans significant to the interpreter. > I refer more to the problems that perpetually plagued Python programmers regarding tabs vs spaces (which I think was finally closed off only in Python 3). ChrisA From k.sahithi2862 at gmail.com Fri Nov 4 12:50:52 2011 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Fri, 4 Nov 2011 09:50:52 -0700 (PDT) Subject: HOT HOT HOT Message-ID: ` FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR ONLY HOT GUYS SEE THIS TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html From lbrt Fri Nov 4 13:37:28 2011 From: lbrt (lbrt) Date: 04 Nov 2011 17:37:28 GMT Subject: short reading materials about anthropological, universal themes for students with no reading habit ... In-Reply-To: <1320407282.243739@nntp.aceinnovative.com> Message-ID: <1320428248.15512@nntp.aceinnovative.com> > A few things to note: > * Not all sites necessarily send the Content-Length header. > * RTMP URLs would have to be treated differently ~ No some don't, but at least for the ones that do (like youtube) it would be a useful feature. The Content-Length header is used in the code anyway ~ > * Sending a Range header might allow for a better implementation. ~ Yes, it would ~ > Why do you want to restrict the filesize of the download in the first > place? I can't see a use case, but that doesn't mean there isn't one. ~ OK, I see your point. Say, you have a list of youtube urls, which feeds you want to download using a script or a playlist someone put together, but you don't want to download files that are too large, which may not be of any use to you. For example, I teach and it doesn't make any sense to use a full movie as part of a class set. So I would like for youtube-dl to let me know which files are larger than a given size (and possibly save them in a file) for me to check the files first My languages are ANSI C, C++ and java. When I was young and silly would blab girls just because they crossed my way, now I don't like to even look into anything that I don't want to invest my time in on an ongoing basis. I would let people that code python and have a mental map of that code base do it themselves lbrtchx From joshua.landau.ws at gmail.com Fri Nov 4 15:10:00 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Fri, 4 Nov 2011 19:10:00 +0000 Subject: SystemError when defining In-Reply-To: References: Message-ID: > > >>> def x(nonlocal_var): ... def y(): ... z = lambda *, keyword_only=nonlocal_var: None ... return y ... >>> x(None)() Traceback (most recent call last): File "", line 1, in File "", line 3, in y SystemError: no locals when loading 'nonlocal_var' >>> dis.dis(x) 2 0 LOAD_CONST 1 ( 0x7f1fa5d57030, file "", line 2>) 3 MAKE_FUNCTION 0 6 STORE_FAST 1 (y) > 4 9 LOAD_FAST 1 (y) 12 RETURN_VALUE >>> dis.dis(x(None)) 3 0 LOAD_CONST 1 ('keyword_only') 3 LOAD_NAME 0 (nonlocal_var) 6 LOAD_CONST 2 ( at > 0x7f1fa626aa48, file "", line 3>) 9 MAKE_FUNCTION 256 12 STORE_FAST 0 (z) 15 LOAD_CONST 0 (None) 18 RETURN_VALUE Conclusion: When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython is unable to access *either the free variables or global scope* and raises SystemError. This is cool, though: > >>> def y(): > ... global_var > ... z = lambda *, keyword_only=global_var: None > ... > >>> y() > >>> >>> dis.dis(y) > 2 0 LOAD_GLOBAL 0 (global_var) > 3 POP_TOP > 3 4 LOAD_CONST 1 ('keyword_only') > 7 LOAD_GLOBAL 0 (global_var) > 10 LOAD_CONST 2 ( at > 0x7f1fa5d4fd78, file "", line 3>) > 13 MAKE_FUNCTION 256 > 16 STORE_FAST 0 (z) > 19 LOAD_CONST 0 (None) > 22 RETURN_VALUE >>> def x(nonlocal_var): > ... def y(): > ... nonlocal_var > ... z = lambda *, keyword_only=nonlocal_var: None > ... return y > ... > >>> x(None)() > >>> What is happening is that LOAD_NAME is trying to access the value 'nonlocal_var' from y.__code__.co_freevars, but compilation doesn't push it there from the lambda, so adding a call to it causes it to work. The change of opcode implies that locality is decided before the opcodes are made, and so not being pushed to co_freevars changes the opcode. AKA: *When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython doesn't push the name to co_freevars.* Now - where shall I report this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Fri Nov 4 15:45:26 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 04 Nov 2011 15:45:26 -0400 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <4EB3DE92.7040108@gmail.com> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> <4EB3DE92.7040108@gmail.com> Message-ID: On 11/4/2011 8:46 AM, Andrea Crotti wrote: > Well this book is work in progress Though not touched since May 2009 > https://bitbucket.org/BruceEckel/python-3-patterns-idioms/src > > but it actually looks very interesting The slightly older .pdf version is a bit bizarre as parts of both text and code are only half-translated from Java. The testing chapter contains obviously untested code like TestDemo.py [sic] with Java lines like id = ++objCounter # this is supposed to increment objCounter TestDemo test1 = TestDemo('test1') # I presume this declares test1 as a TestDemo object and text with Javaisms like *static*, *public*, *private*, *protected*, and *friendly* and "a little review of Java packages". Perhaps the later sections are more useful. -- Terry Jan Reedy From tjreedy at udel.edu Fri Nov 4 16:01:14 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 04 Nov 2011 16:01:14 -0400 Subject: leftover pyc files In-Reply-To: <4EB3C5E2.3020702@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> <4EB3C5E2.3020702@gmail.com> Message-ID: For those not aware, the compiled file caching and import system was changed for 3.2. Given test.py, the compiled file is no longer test.pyc, in the same directory, but (for cpython32) __pycache__/test.cpython-32.pyc. Given the statement 'import test', the __pycache__ directory is only searched (for the name given above) after finding test.py. So if 'test.py' is deleted or renamed to 'mytest.py', an unchanged 'import test' will *fail* instead of importing the obsolete .pyc file. So there is no longer a functional reason to delete such obsolete files. However, the OP is stuck with 2.5. -- Terry Jan Reedy From tjreedy at udel.edu Fri Nov 4 16:06:05 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 04 Nov 2011 16:06:05 -0400 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: On 11/4/2011 11:10 AM, Steven Lehar wrote: > Is this the right place to propose language extensions? Yes, especially for beginners not familiar with previous discussions. > > My Python code keeps expanding rightwards, it is difficult to keep it > contained within reasonable limits. But the standard line continuation \ > is positively anti-Pythonic because an *invisible* white space between \ > and [CR] will render it useless. > > How about a new Python symbol, maybe \\ that CAN have following > whitespace which is ignored, so that seeing a \\ in the code forces it > to continue on the next line. > > Has this issue been discussed already? Yes ;=) Peter already gave the standard answers. -- Terry Jan Reedy From nad at acm.org Fri Nov 4 16:11:14 2011 From: nad at acm.org (Ned Deily) Date: Fri, 04 Nov 2011 13:11:14 -0700 Subject: Design Pattern and Python: Any book recommendation? Your view? References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> <4EB3DE92.7040108@gmail.com> Message-ID: Search for presentations and videos by Alex Martelli. He's the goto (so to speak) person on Python design patterns. Here, for instance: http://code.google.com/edu/languages/#_python_patterns -- Ned Deily, nad at acm.org From steve+comp.lang.python at pearwood.info Fri Nov 4 19:15:01 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Nov 2011 23:15:01 GMT Subject: leftover pyc files References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> <4EB3C5E2.3020702@gmail.com> Message-ID: <4eb471f4$0$29968$c3e8da3$5496439d@news.astraweb.com> On Fri, 04 Nov 2011 16:01:14 -0400, Terry Reedy wrote: > For those not aware, the compiled file caching and import system was > changed for 3.2. Given test.py, the compiled file is no longer test.pyc, > in the same directory, but (for cpython32) > __pycache__/test.cpython-32.pyc. Given the statement 'import test', the > __pycache__ directory is only searched (for the name given above) after > finding test.py. So if 'test.py' is deleted or renamed to 'mytest.py', > an unchanged 'import test' will *fail* instead of importing the obsolete > .pyc file. So there is no longer a functional reason to delete such > obsolete files. However, the OP is stuck with 2.5. Oh, I don't know, removing obsolete and useless crud from your file system seems like a good enough functional reason to me :) However, the behaviour of Python 3.2 is a little more complicated than the above, since it must still support .pyc only software. If you have a .pyc file in the PYTHONPATH, but *outside* of a __pycache__ directory, and it is compiled for the correct version of Python, it will still be imported as usual. I'm not sure what happens if you have two .pyc files, one inside the cache and one outside. -- Steven From tjreedy at udel.edu Fri Nov 4 20:42:02 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 04 Nov 2011 20:42:02 -0400 Subject: SystemError when defining In-Reply-To: References: Message-ID: On 11/4/2011 3:10 PM, Joshua Landau wrote: > > >> def x(nonlocal_var): > ... def y(): > ... z = lambda *, keyword_only=nonlocal_var: None > ... return y > ... > >>> x(None)() ... > SystemError: no locals when loading 'nonlocal_var' ... > Now - where shall I report this? Joshua found bugs.python.org and, 2 hours later, a fix was applied. http://bugs.python.org/issue13343 -- Terry Jan Reedy From joshua.landau.ws at gmail.com Fri Nov 4 21:53:17 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Sat, 5 Nov 2011 01:53:17 +0000 Subject: SystemError when defining In-Reply-To: References: Message-ID: > > Joshua found bugs.python.org and, 2 hours later, a fix was applied. > http://bugs.python.org/**issue13343 > It was impressively fast. Those python devs are like a hawk. Although I wasn't expecting a three-line patch (plus a three line test). -------------- next part -------------- An HTML attachment was scrubbed... URL: From jhsu802701 at gmail.com Sat Nov 5 01:27:58 2011 From: jhsu802701 at gmail.com (Jason Hsu, Mr. Swift Linux) Date: Fri, 4 Nov 2011 22:27:58 -0700 (PDT) Subject: Can I fully replace GNU Bash with Python? Message-ID: This question concerns my process of creating Swift Linux from the base distro (antiX Linux in the past, Linux Mint Debian Edition now). (NOTE: The process I'm describing here is an oversimplification.) All of my development work takes place in the ~/develop directory. This is the directory where I enter the "git clone" command to download the repositories from GitHub. These repositories are 1- build, majorfunction1, majorfunction2, and so on. After I download these repositories, I have the directories ~/develop/1-build, ~/ develop/majorfunction1, ~/develop/majorfunction2, and so on. The ~/develop/1-build directory contains the scripts that build Swift Linux. Each major function needed to create Swift Linux (such as changing web browser configuration files, changing login manager configuration files, etc.) has its own majorfunction# repository. For developing the latest version of Swift Linux, I had the swift.sh script in the ~/develop/1-build directory call scripts in the majorfunction directories with commands like: sh ~/develop/majorfunction1/main.sh sh ~/develop/majorfunction2/main.sh and so on Please note that one can run any of these major functions independently OR as part of the ~/develop/1-build/swift.sh script. The ability to run any major function independently means I can focus on just one function that's not working as it should WITHOUT messing around with other functions. This ability will be especially important when I have an actual team working on Swift Linux. What I'd like to do is replace GNU Bash with Python. I know I can replace the main.sh scripts with main.py scripts. Then the commands in the swift.sh script would be: python ~/develop/majorfunction1/main.py python ~/develop/majorfunction2/main.py and so on Is there a way I can replace the ~/develop/1-build/swift.sh script with a ~/develop/1-build/swift.py script, yet still retain the ability to work on one major function WITHOUT requiring the other major functions and the 1-build directory to be present? From kwa at kuwata-lab.com Sat Nov 5 02:06:55 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Sat, 5 Nov 2011 15:06:55 +0900 Subject: [ANN] pyKook 0.7.0 - task automation tool for Python, similar to Rake or Ant Message-ID: Hi, I have released pyKook 0.7.0. http://pypi.python.org/pypi/Kook/ http://www.kuwata-lab.com/kook/ http://www.kuwata-lab.com/kook/pykook-users-guide.html In this release, you can run commands on remote machines using ssh. This is very useful to deploy your application. pyKook Overview --------------- pyKook is a task automation tool for Python, similar to Rake or Ant. (Kookbook.py): kookbook.default = 'build' ## task @recipe(None, ['hello']) def build(c): """build all""" pass ## file @recipe('hello', ['hello.o']) def file_hello(c): """build 'hello' from 'hello.o'""" system(c%'gcc -o $(product) $(ingred)') ## rule @recipe('*.o', ['$(1).c', '$(1).h']) def file_o(c): system(c%'gcc -c $(ingred)') Command-line: bash> kk # or pykook $ gcc -c hello.c ### *** hello.o (recipe=file_o) $ gcc -c hello.c ### ** hello (recipe=file_hello) $ gcc -o hello hello.o ### * build (recipe=build) See http://www.kuwata-lab.com/kook/pykook-users-guide.html for details. Enhancements in this release ---------------------------- * (EXPERIMENTAL!!) Remote command execution (ssh and sftp) is available. This is very useful to deploy your application into servers. Ex (Kookbook.py):: from kook.remote import Remote remote = Remote( hosts = ['www1', 'www2', 'user3 at www3:10022'], port = 22, user = 'user1', #password = None, # for login, '~/.ssh/id_rsa' and sudo passphrase = None, # only for '~/.ssh/id_rsa' sudo_password = 'xxx', # only for sudo command ) @recipe @remotes(remote) def hostinfo(c): """show hostname""" ssh = c.ssh ssh('hostname') # run command with ssh ssh('whomai') # run command with ssh ssh.sudo('whoami') # run command with sudo @recipe @remotes(remote) def exchange(c): """upload and download files""" ssh = c.ssh with ssh.pushd('work/apps'): ssh.get('file.remote') # download a file ssh.put('file.local') # upload a file ssh.mget('remote.*') # download files ssh.mput('local.*') # upload files Notice that you must configure ssh at first and confirm that you can log into servers without typing password:: bash> ssh user1 at www1 bash> ssh user1 at www2 bash> ssh -p 10022 user3 at www3 bash> kk hostinfo ### * showinfo (recipe=showinfo) [user1 at www1]$ hostame www1 [user1 at www1]$ whoami user1 [user1 at www1]$ sudo whoami root [user2 at www2]$ hostame www2 [user2 at www2]$ whoami user2 [user2 at www2]$ sudo whoami root [user3 at www3]$ hostame www3 [user3 at www3]$ whami user3 [user3 at www3]$ sudo whoami root Currently commands are executed sequencially (not in parallel). * (EXPERIMENTAL!!) Password object supported. Password object asks you to enter password in prompt when necessary. Ex (Kookbook.py):: from kook.remote import Remote, Password remote = Remote( hosts = ['user1 at www1:22'], #password = Password('login'), passphrase = Password('~/.ssh/id_rsa'), sudo_password = Password('sudo command') ) # @recipe @remotes(remote) def remote_test(c): ssh = c.ssh ssh.sudo('whoami') Output example:: bash> kk remote_test ### * remote_test (recipe=remote_test) Password for ~/.ssh/id_rsa: Password for sudo command: [user1 at www1]$ sudo whoami root It is easy to share password object. Ex (Kookbook.py):: from kook.remote import Remote, Password passwd = Password() remote = Remote( hosts = ['user1 at www1:22'], password = passwd, passphrase = passwd, sudo_password = passwd, ) Changes in this release ----------------------- * Category class is changed to convers all instance methods into staticmethods. Ex (Kookbook.py): class apache(Category): @recipe def start(c): system('apachectl start') ## start() is converted into staticmethod assert type(apache.__dict__['start']) == staticmethod from types import FunctionType assert type(apache.start) == FuntionType This makes execution of other recipes in category easier:: class apache(Category): @recipe def start(c): ... @recipe def stop(c): ... @recipe def restart(c): apache.start(c) # execute other recipe apache.stop(c) # execute other recipe * (internal) kook.config.stdout and kook.config.stderr are removed. See http://www.kuwata-lab.com/kook/pykook-CHANGES.txt for details. Have fun! -- regards, makoto kuwata From tjreedy at udel.edu Sat Nov 5 03:50:42 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 05 Nov 2011 03:50:42 -0400 Subject: SystemError when defining In-Reply-To: References: Message-ID: On 11/4/2011 9:53 PM, Joshua Landau wrote: > Joshua found bugs.python.org and, 2 hours > later, a fix was applied. > http://bugs.python.org/__issue13343 > > > It was impressively fast. Those python devs are like a hawk. > Although I wasn't expecting a three-line patch (plus a three line test). We are not always so fast, but the public perception of our speed is skewed by a) the occasional bug that sits on the tracker for years and b) the near invisibility of bugs caught and quickly fixed by a developer without posting an issue on the tracker. In this case, you made a very good report with a minimal reproducible buggy code snippet, plus a report of similar snippets that worked. Then it was quickly seen by someone familiar with the relevant file. -- Terry Jan Reedy From jeanpierreda at gmail.com Sat Nov 5 07:11:42 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sat, 5 Nov 2011 07:11:42 -0400 Subject: Can I fully replace GNU Bash with Python? In-Reply-To: References: Message-ID: > Is there a way I can replace the ~/develop/1-build/swift.sh script > with a ~/develop/1-build/swift.py script, yet still retain the ability > to work on one major function WITHOUT requiring the other major > functions and the 1-build directory to be present? I thought I followed along, but I don't see where the problem is here. Did you try something and it didn't work, or are you asking if in principle it can work? In principle, it can work fine. the mainfunction modules can be importable modules with some functions, or they can be (like they are in sh) runnable scripts called by your build script, or whatever. You can diverge as much as you want from how sh works, or stay as close as you want, down to the level of only interoperating with other python modules by invoking them as programs. Devin On Sat, Nov 5, 2011 at 1:27 AM, Jason Hsu, Mr. Swift Linux wrote: > This question concerns my process of creating Swift Linux from the > base distro (antiX Linux in the past, Linux Mint Debian Edition now). > (NOTE: The process I'm describing here is an oversimplification.) > > All of my development work takes place in the ~/develop directory. > This is the directory where I enter the "git clone" command to > download the repositories from GitHub. ?These repositories are 1- > build, majorfunction1, majorfunction2, and so on. ?After I download > these repositories, I have the directories ~/develop/1-build, ~/ > develop/majorfunction1, ~/develop/majorfunction2, and so on. > > The ~/develop/1-build directory contains the scripts that build Swift > Linux. ?Each major function needed to create Swift Linux (such as > changing web browser configuration files, changing login manager > configuration files, etc.) has its own majorfunction# repository. > > For developing the latest version of Swift Linux, I had the swift.sh > script in the ?~/develop/1-build directory call scripts in the > majorfunction directories with commands like: > sh ~/develop/majorfunction1/main.sh > sh ~/develop/majorfunction2/main.sh > and so on > > Please note that one can run any of these major functions > independently OR as part of the ~/develop/1-build/swift.sh script. > The ability to run any major function independently means I can focus > on just one function that's not working as it should WITHOUT messing > around with other functions. ?This ability will be especially > important when I have an actual team working on Swift Linux. > > What I'd like to do is replace GNU Bash with Python. ?I know I can > replace the main.sh scripts with main.py scripts. ?Then the commands > in the swift.sh script would be: > python ~/develop/majorfunction1/main.py > python ~/develop/majorfunction2/main.py > and so on > > Is there a way I can replace the ~/develop/1-build/swift.sh script > with a ~/develop/1-build/swift.py script, yet still retain the ability > to work on one major function WITHOUT requiring the other major > functions and the 1-build directory to be present? > -- > http://mail.python.org/mailman/listinfo/python-list > From pacopyc at gmail.com Sat Nov 5 08:50:38 2011 From: pacopyc at gmail.com (pacopyc) Date: Sat, 5 Nov 2011 05:50:38 -0700 (PDT) Subject: xml-rpc server on wine Message-ID: <650e9d68-e606-4424-bca7-174295306d82@ht6g2000vbb.googlegroups.com> Hi, I have a XML-RPC server python running on VM Windows (on Linux) and a XML-RPC client python on Linux. Server and client have different IP address. I'd like migrate server on wine. How can communicate server and client? IP address is different or is the same? Can you help me? Thanks From ross at biostat.ucsf.edu Sat Nov 5 15:03:27 2011 From: ross at biostat.ucsf.edu (Ross Boylan) Date: Sat, 05 Nov 2011 12:03:27 -0700 Subject: inserting \ in regular expressions [solved] In-Reply-To: <1319658482.13425.9.camel@corn.betterworld.us> References: <1319658482.13425.9.camel@corn.betterworld.us> Message-ID: <1320519807.18391.5.camel@corn.betterworld.us> On Wed, 2011-10-26 at 12:48 -0700, Ross Boylan wrote: > I want to replace every \ and " (the two characters for backslash and > double quotes) with a \ and the same character, i.e., > \ -> \\ > " -> \" I'd like to thank Ian, Dave, MRAB, and John for their helpful responses. I hadn't realized the interpreter was giving me the repr, and that differed from the str. I've since found one other solution: email.utils.quote() does exactly the substitution I was looking for--not surprising, since I was doing it for email. Here's my little test program: #! /usr/bin/python import email, email.utils, re s0 = r'I am " a silly \quote' print s0 print re.sub(r'(\\|")', r'\\\1', s0) print email.utils.quote(s0) Output I am " a silly \quote I am \" a silly \\quote I am \" a silly \\quote Ross From logic at op.pl Sat Nov 5 15:30:12 2011 From: logic at op.pl (wojciech777) Date: Sat, 5 Nov 2011 12:30:12 -0700 (PDT) Subject: httpd.conf configuration for mod_wsgi.so on wamp (apache)? Message-ID: Hi there. Is there any way to run python web application (or simple web page in web.py) on Windows with wamp without starting built-in wsgi server manually (python run.py). I know there's a documentation on http://webpy.org/install#apachemodwsgi, but it doesn't show where exactly in httpd.conf I should place the commands. In my example I would like to get start page, simply by typing in my browser e.g. http://localhost:8070, and my file is located in: c:/ wamp/ www/xaura/run.py source of run.py: #!/usr/bin/env python import web urls = ('/', 'hello', '', 'hello') class hello: def GET(self): return "Hello, world." app = web.application(urls, globals()) if __name__ == "__main__": app.run() Any help will be appreciated. Thanks Wojciech Ka?mierczak From jehugaleahsa at gmail.com Sat Nov 5 16:11:28 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sat, 5 Nov 2011 13:11:28 -0700 (PDT) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django Message-ID: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> Hello: A new guy showed up at work a few weeks ago and has started talking about replacing a 6 month old project, written in ASP.NET MVC, with an open source solution that can handle massive scaling. I think his primary concern is the "potential" need for massive web farms in the future. In order to prevent high licensing costs, I think he wants to move everything to open source technologies, such as the LAMP stack. I also don't think he truly understands what ASP.NET MVC is and thinks it is the older WebForms. I have been researching open source MVC frameworks and came across Django. It looks like an awesome tool, but I am willing to look at others. I have experience in Python (and enough in PHP to want to avoid it and absolutely none in Ruby) so I think it would be a good language to develop in. I was wondering if there were any ORMs for Python that used POPOs (plain old Python objects). There is a lot of business logic in my system, and so I want to keep my data objects simple and stupid. I want the ORM to be responsible for detecting changes to objects after I send them back to the data layer (rather than during business layer execution). Additionally, being a stateless environment, tracking objects' states isn't very useful anyway. Honestly, I doubt this guy is going to get his wish. The people paying for the application aren't going to be willing to throw 6 months of work down the drain. Never the less, I want to have plenty of research under my belt before being asked what my thoughts are. He was talking about using the Zend Framework with PHP, but I want to avoid that if possible. Django seems like one of the best MVC solutions in the Python arena. I would be willing to replace Django's ORM solution with something else, especially if it supported POPOs. I could even map all of the non-POPOs to POPOs if I needed to, I guess. Finally, I wanted to ask whether anyone has tried having Django call out to Python 3 routines. I am okay using Python 2.7 in Django, if I can have the controllers call business logic implemented in Python 3, accepting POPOs from the data layer. Django would really just be a coordinator: grab data from Django ORM, convert results into POPOs, load up Python 3 module with business logic, passing POPOs, returning POPOs and then converting those to view models. I'm sweating just thinking about it. My guess is that there would be a severe penalty for crossing process boundaries... but any insights would be appreciated. Thanks, Travis Parks From nawijn at gmail.com Sat Nov 5 16:35:55 2011 From: nawijn at gmail.com (Marco Nawijn) Date: Sat, 5 Nov 2011 13:35:55 -0700 (PDT) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> Message-ID: <0fe2f129-bbe2-4c7e-99e7-48f21b87a3bf@c1g2000vbw.googlegroups.com> On Nov 5, 9:11?pm, Travis Parks wrote: > Hello: > > A new guy showed up at work a few weeks ago and has started talking > about replacing a 6 month old project, written in ASP.NET MVC, with an > open source solution that can handle massive scaling. I think his > primary concern is the "potential" need for massive web farms in the > future. In order to prevent high licensing costs, I think he wants to > move everything to open source technologies, such as the LAMP stack. I > also don't think he truly understands what ASP.NET MVC is and thinks > it is the older WebForms. > > I have been researching open source MVC frameworks and came across > Django. It looks like an awesome tool, but I am willing to look at > others. I have experience in Python (and enough in PHP to want to > avoid it and absolutely none in Ruby) so I think it would be a good > language to develop in. > > I was wondering if there were any ORMs for Python that used POPOs > (plain old Python objects). There is a lot of business logic in my > system, and so I want to keep my data objects simple and stupid. I > want the ORM to be responsible for detecting changes to objects after > I send them back to the data layer (rather than during business layer > execution). Additionally, being a stateless environment, tracking > objects' states isn't very useful anyway. > > Honestly, I doubt this guy is going to get his wish. The people paying > for the application aren't going to be willing to throw 6 months of > work down the drain. Never the less, I want to have plenty of research > under my belt before being asked what my thoughts are. He was talking > about using the Zend Framework with PHP, but I want to avoid that if > possible. Django seems like one of the best MVC solutions in the > Python arena. I would be willing to replace Django's ORM solution with > something else, especially if it supported POPOs. I could even map all > of the non-POPOs to POPOs if I needed to, I guess. > > Finally, I wanted to ask whether anyone has tried having Django call > out to Python 3 routines. I am okay using Python 2.7 in Django, if I > can have the controllers call business logic implemented in Python 3, > accepting POPOs from the data layer. Django would really just be a > coordinator: grab data from Django ORM, convert results into POPOs, > load up Python 3 module with business logic, passing POPOs, returning > POPOs and then converting those to view models. I'm sweating just > thinking about it. My guess is that there would be a severe penalty > for crossing process boundaries... but any insights would be > appreciated. > > Thanks, > Travis Parks Hello Travis, I am not an expert in the field, but I have used SQLAlchemy (www.sqlalchemy.org) for a while and was very happy with it. It should be able to scale up to pretty complex applications and large amounts of data. Regards, Marco From rosuav at gmail.com Sat Nov 5 18:09:25 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 6 Nov 2011 09:09:25 +1100 Subject: Python ORMs Supporting POPOs and Substituting Layers in Django In-Reply-To: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> Message-ID: On Sun, Nov 6, 2011 at 7:11 AM, Travis Parks wrote: > Finally, I wanted to ask whether anyone has tried having Django call > out to Python 3 routines. I am okay using Python 2.7 in Django, if I > can have the controllers call business logic implemented in Python 3, > accepting POPOs from the data layer. What you're going to have is completely separate processes; either invoking Python3 and having it terminate after one action, or keeping it running concurrently and passing data between them. Has anyone ever extended AND embedded Python at the same time? Written a Python module that ... executes Python code? Might be a bit tricky, but possibly isolating the Py2 and Py3 code into different C source files would help conserve programmer sanity (at the possible cost of performance). Would be a tricky thing to juggle, but if you can pull it off, you'd be able to - effectively - have a module in Django that's written in Python 3, and directly callable. Propagating parameters and return values would be a matter of unpacking them into C objects and repacking them on the other side. Propagating exceptions would be.... fun? ChrisA From jehugaleahsa at gmail.com Sat Nov 5 23:22:34 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sat, 5 Nov 2011 20:22:34 -0700 (PDT) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> Message-ID: <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> On Nov 5, 4:11?pm, Travis Parks wrote: > Hello: > > A new guy showed up at work a few weeks ago and has started talking > about replacing a 6 month old project, written in ASP.NET MVC, with an > open source solution that can handle massive scaling. I think his > primary concern is the "potential" need for massive web farms in the > future. In order to prevent high licensing costs, I think he wants to > move everything to open source technologies, such as the LAMP stack. I > also don't think he truly understands what ASP.NET MVC is and thinks > it is the older WebForms. > > I have been researching open source MVC frameworks and came across > Django. It looks like an awesome tool, but I am willing to look at > others. I have experience in Python (and enough in PHP to want to > avoid it and absolutely none in Ruby) so I think it would be a good > language to develop in. > > I was wondering if there were any ORMs for Python that used POPOs > (plain old Python objects). There is a lot of business logic in my > system, and so I want to keep my data objects simple and stupid. I > want the ORM to be responsible for detecting changes to objects after > I send them back to the data layer (rather than during business layer > execution). Additionally, being a stateless environment, tracking > objects' states isn't very useful anyway. > > Honestly, I doubt this guy is going to get his wish. The people paying > for the application aren't going to be willing to throw 6 months of > work down the drain. Never the less, I want to have plenty of research > under my belt before being asked what my thoughts are. He was talking > about using the Zend Framework with PHP, but I want to avoid that if > possible. Django seems like one of the best MVC solutions in the > Python arena. I would be willing to replace Django's ORM solution with > something else, especially if it supported POPOs. I could even map all > of the non-POPOs to POPOs if I needed to, I guess. > > Finally, I wanted to ask whether anyone has tried having Django call > out to Python 3 routines. I am okay using Python 2.7 in Django, if I > can have the controllers call business logic implemented in Python 3, > accepting POPOs from the data layer. Django would really just be a > coordinator: grab data from Django ORM, convert results into POPOs, > load up Python 3 module with business logic, passing POPOs, returning > POPOs and then converting those to view models. I'm sweating just > thinking about it. My guess is that there would be a severe penalty > for crossing process boundaries... but any insights would be > appreciated. > > Thanks, > Travis Parks Which web frameworks have people here used and which have they found to be: scalable, RAD compatible, performant, stable and/or providing good community support? I am really trying to get as much feedback as I can, to help form an unbiased opinion in case I need to make a recommendation... or fight an all out battle. From simeon.chaos at gmail.com Sun Nov 6 00:45:39 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Sat, 5 Nov 2011 21:45:39 -0700 (PDT) Subject: What would happen when lisp meets prolog in python? Dao and Dinpy arises! Message-ID: Dao is the new generation programming system implemented by a functional logic solver, unifying code with data, grammar with program, logic with functional, compiling with running. Would you please to have a look at my dao and dinpy? http://pypi.python.org/pypi/daot https://github.com/chaosim/dao The feature of dao and dinpy: * Mix functional and logic programming like prolog and lisp in python. * A most powerful parser is provided, which have the power all of the other parsers do not have. below is the list of some parser and algorithms: parsec(haskell), packrat, earley parser, glr parser, antlr, lex/yacc. What's the magic behind the dao? See samples\sexpression.py and testsexpression.py for a sample. this is the key tips to the dao's dynamic grammar, which will become a most powerful tool: (sexpression, function( # dynamic grammar arises! ([Result], and_p(char('{'), sexpression(Expr2), char('}'), setvalue(Result, eval_(pycall(sexpression2daoexpression, Expr2))))), ([Expr], atom_expression(Expr)), ([Expr], bracketExpression(Expr)), ([Expr], puncExpression(Expr))), # the kernel of dynamic grammar (eval_parse_result, function( ([Result], and_p(sexpression(Expr2), eoi, is_(Result, eval_(pycall(sexpression2daoexpression, Expr2))))))), From frank at chagford.com Sun Nov 6 03:54:48 2011 From: frank at chagford.com (Frank Millman) Date: Sun, 6 Nov 2011 10:54:48 +0200 Subject: Question about 'iterable cursors' Message-ID: Hi all I am using a few DB_API adaptors - ceODBC for Sql Server, psycopg2 for PostgreSQL, and sqlite3 for sqlite3. They all offer the feature that if a cursor executes a SELECT, the cursor returns an iterator which can be used to fetch one row at a time. I have been using this feature for a while and it seems like a 'good thing'. Now I am not so sure. I am using a connection pool to maintain connections to the database. A principle I am following is that a connection must be returned quickly, so that it is available for reuse. I have been happily returning the connection, but keeping the cursor open while processing the rows selected. I now realise that this is dangerous. Therefore I have changed my system to execute fetchall() on the cursor before returning the connection. This obviously loses the benefit of the iterator. I would appreciate confirmation that my thinking is correct on this issue. Or is there any way that I can have my cake and eat it? Thanks Frank Millman From alain at dpt-info.u-strasbg.fr Sun Nov 6 04:16:22 2011 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Sun, 06 Nov 2011 10:16:22 +0100 Subject: Question about 'iterable cursors' References: Message-ID: <87pqh54nmh.fsf@dpt-info.u-strasbg.fr> "Frank Millman" writes: > I am using a few DB_API adaptors - ceODBC for Sql Server, psycopg2 for > PostgreSQL, and sqlite3 for sqlite3. > > They all offer the feature that if a cursor executes a SELECT, the > cursor returns an iterator which can be used to fetch one row at a > time. I have been using this feature for a while and it seems like a > good thing'. > > Now I am not so sure. I am using a connection pool to maintain > connections to the database. A principle I am following is that a > connection must be returned quickly, so that it is available for > reuse. > > I have been happily returning the connection, but keeping the cursor > open while processing the rows selected. I now realise that this is > dangerous. Therefore I have changed my system to execute fetchall() on > the cursor before returning the connection. This obviously loses the > benefit of the iterator. > > I would appreciate confirmation that my thinking is correct on this > issue. Or is there any way that I can have my cake and eat it? Your thinking is correct: you need to keep the connection while processing the cursor. Databases are made to scale, you may well be processing the first lines of the result before the DBMS has even finished scanning tables. View this as a pipe, the cursor being one end of the pipe. The usual setting, fetching one line at a time, lets you overlap your processing with the network transfers. Fetching all data, returning the connection, and then start processing only makes sense if the processing take a lot of time (I mean: a lot more than fetching results), which is a rare case. Unless you are in such an extreme situation, I would suggest leaving the optimization to the connection pool, which is here to solve what you are trying to solve. -- Alain. From frank at chagford.com Sun Nov 6 04:39:56 2011 From: frank at chagford.com (Frank Millman) Date: Sun, 6 Nov 2011 11:39:56 +0200 Subject: Question about 'iterable cursors' References: <87pqh54nmh.fsf@dpt-info.u-strasbg.fr> Message-ID: "Alain Ketterlin" wrote > "Frank Millman" writes: > >> I am using a few DB_API adaptors - ceODBC for Sql Server, psycopg2 for >> PostgreSQL, and sqlite3 for sqlite3. >> >> They all offer the feature that if a cursor executes a SELECT, the >> cursor returns an iterator which can be used to fetch one row at a >> time. I have been using this feature for a while and it seems like a >> good thing'. >> >> Now I am not so sure. I am using a connection pool to maintain >> connections to the database. A principle I am following is that a >> connection must be returned quickly, so that it is available for >> reuse. >> >> I have been happily returning the connection, but keeping the cursor >> open while processing the rows selected. I now realise that this is >> dangerous. Therefore I have changed my system to execute fetchall() on >> the cursor before returning the connection. This obviously loses the >> benefit of the iterator. >> >> I would appreciate confirmation that my thinking is correct on this >> issue. Or is there any way that I can have my cake and eat it? > > Your thinking is correct: you need to keep the connection while > processing the cursor. Databases are made to scale, you may well be > processing the first lines of the result before the DBMS has even > finished scanning tables. View this as a pipe, the cursor being one end > of the pipe. The usual setting, fetching one line at a time, lets you > overlap your processing with the network transfers. > > Fetching all data, returning the connection, and then start processing > only makes sense if the processing take a lot of time (I mean: a lot > more than fetching results), which is a rare case. Unless you are in > such an extreme situation, I would suggest leaving the optimization to > the connection pool, which is here to solve what you are trying to > solve. > Thank you, Alain. That is very clear. So my analysis of the problem is correct, but my solution is wrong. Instead of executing fetchall() and returning the connection, I should retain the connection until I have exhausted the cursor. That makes a lot of sense. Frank From merwin.irc at gmail.com Sun Nov 6 04:44:06 2011 From: merwin.irc at gmail.com (Merwin) Date: Sun, 06 Nov 2011 10:44:06 +0100 Subject: SQLAlchemy DB Migration Message-ID: <4EB656E6.2020805@gmail.com> Hi everybody, I'm looking for a way to migrate SQLAlchemy based database easily. I found Migrate, but finally it's almost the same as doing the migration by hand. If this doesn't exists, do you think that it would be hard to do a simple migration tool which would : - Add/Delete columns from DB if they are not anymore in the models (With a confirmation for deletion) - Add/Delete constraints/sequences on table if they are not on the model too We could also imagine a way to : - Handle column rename, with data copy from one to another - Handle column type change, with proper data conversion Of course, such a system can't be 100% automated, that's not the goal. Human interventation will be needed, but it might be more simpler for simple cases than Migrate. -- Thibaut From huhai102 at gmail.com Sun Nov 6 07:06:13 2011 From: huhai102 at gmail.com (wholesale brand sunglasses) Date: Sun, 6 Nov 2011 04:06:13 -0800 (PST) Subject: nfl jerseys on sale in www.nike-black.com Message-ID: <1eb24ce9-4f70-4cb8-b970-fa2a0236b4f0@h23g2000pra.googlegroups.com> (www.nike-black.com) cheap wholesale nfl jerseys , mlb jerseys ,nhl jerseys , nba jerseys , soccer jerseys . NFL Jerseys Arizona CardinalsAtlanta Falcons JerseysBaltimore Ravens Jerseys Buffalo BillsCarolina PanthersChicago Bears Cincinnati BengalsCleveland BrownsDallas Cowboys Denver BroncosDetriot lionsGreen Bay Packers Houston TexansIndianapolis ColtsJacksonville Jaguars Kansas City ChiefsMiami DolphinsMinnesota Vikings New England PatriotsNew Orleans SaintsNew York Giants New York JetsOakland RaidersPhiladelphia Eagles Pittsburgh SteelersSan Diego ChargersSan Francisco 49ers San Louis RamsTampa Bay BuccaneersTennessee Titans Washington Redskins website: http://www.nike-black.com From kevin.e.kenny at gmail.com Sun Nov 6 08:18:08 2011 From: kevin.e.kenny at gmail.com (Kev) Date: Sun, 6 Nov 2011 05:18:08 -0800 (PST) Subject: How to undo a Python setuptools --prefix path blunder Message-ID: <543f5b85-1248-4039-a12d-5bbcb2fb0f51@o19g2000vbk.googlegroups.com> When I installed Python's setuptools I absent mindedly tacked on a -- prefix path I had been using on another machine: sh setuptools-0.6c11-py2.7.egg --prefix=/opt/python2.7.2 Now after this blunder when I try to install pip I get the following error: [root at kkdev src]# easy_install pip Searching for pip Best match: pip 1.0.2 Processing pip-1.0.2-py2.7.egg pip 1.0.2 is already the active version in easy-install.pth Installing pip script to /usr/bin error: /usr/bin/pip: No such file or directory What's happening is that a symbolic link is being created that points to the folder I specified in the --prefix path which is obviously wrong: [root at kkdev src]# ls -al /usr/bin/pip lrwxrwxrwx 1 root root 24 Nov 5 17:01 /usr/bin/pip -> /opt/ python2.7.2/bin/pip I deleted this link and then re-ran the setuptools installer and specified the correct prefix (my Python install lives in /usr/lib/ python2.7): sh setuptools-0.6c11-py2.7.egg --prefix=/usr I then re-ran easy_install pip and it looked like I'd fixed my finger trouble. However when I went to install virtualenv I encountered the same problem: [root at kkdev src]# pip install virtualenv [uninteresting installer output snipped] Installing virtualenv script to /usr/bin error: /usr/bin/virtualenv: No such file or directory Again the wrong path is being used to create the symbolic link to where virtualenv is installed: [root at kkdev src]# ls -al /usr/bin/virtualenv lrwxrwxrwx 1 root root 31 Nov 5 17:01 /usr/bin/virtualenv -> /opt/ python2.7.2/bin/virtualenv (I'm running Fedora 15 32bit which has Python 2.7.1 installed out of the box) How do I fix/repair this permanently? Thanks Kevin From jfine at pytex.org Sun Nov 6 10:17:54 2011 From: jfine at pytex.org (Jonathan Fine) Date: Sun, 06 Nov 2011 15:17:54 +0000 Subject: A Python script to put CTAN into git (from DVDs) Message-ID: <4EB6A522.3020909@pytex.org> Hi This it to let you know that I'm writing (in Python) a script that places the content of CTAN into a git repository. https://bitbucket.org/jfine/python-ctantools I'm working from the TeX Collection DVDs that are published each year by the TeX user groups, which contain a snapshot of CTAN (about 100,000 files occupying 4Gb), which means I have to unzip folders and do a few other things. CTAN is the Comprehensive TeX Archive Network. CTAN keeps only the latest version of each file, but old CTAN snapshots will provide many earlier versions. I'm working on putting old CTAN files into modern version control. Martin Scharrer is working in the other direction. He's putting new files added to CTAN into Mercurial. http://ctanhg.scharrer-online.de/ My script works already as a proof of concept, but needs more work (and documentation) before it becomes useful. I've requested that follow up goes to comp.text.tex. Longer terms goals are git as * http://en.wikipedia.org/wiki/Content-addressable_storage * a resource editing and linking system If you didn't know, a git tree is much like an immutable JSON object, except that it does not have arrays or numbers. If my project interests you, reply to this message or contact me directly (or both). -- Jonathan From jnareb at gmail.com Sun Nov 6 11:42:23 2011 From: jnareb at gmail.com (Jakub Narebski) Date: Sun, 06 Nov 2011 08:42:23 -0800 (PST) Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: <4EB6A522.3020909@pytex.org> References: <4EB6A522.3020909@pytex.org> Message-ID: Jonathan Fine writes: > Hi > > This it to let you know that I'm writing (in Python) a script that > places the content of CTAN into a git repository. > https://bitbucket.org/jfine/python-ctantools I hope that you meant "repositories" (plural) here, one per tool, rather than putting all of CTAN into single Git repository. > I'm working from the TeX Collection DVDs that are published each year > by the TeX user groups, which contain a snapshot of CTAN (about > 100,000 files occupying 4Gb), which means I have to unzip folders and > do a few other things. There is 'contrib/fast-import/import-zips.py' in git.git repository. If you are not using it, or its equivalent, it might be worth checking out. > CTAN is the Comprehensive TeX Archive Network. CTAN keeps only the > latest version of each file, but old CTAN snapshots will provide many > earlier versions. There was similar effort done in putting CPAN (Comprehensive _Perl_ Archive Network) in Git, hosting repositories on GitHub[1], by the name of gitPAN, see e.g.: "The gitPAN Import is Complete" http://perlisalive.com/articles/36 [1]: https://github.com/gitpan > I'm working on putting old CTAN files into modern version > control. Martin Scharrer is working in the other direction. He's > putting new files added to CTAN into Mercurial. > http://ctanhg.scharrer-online.de/ Nb. thanks to tools such as git-hg and fast-import / fast-export we have quite good interoperability and convertability between Git and Mercurial. P.S. I'd point to reposurgeon tool, which can be used to do fixups after import, but it would probably won't work on such large (set of) repositories. P.P.S. Can you forward it to comp.text.tex? -- Jakub Nar?bski From doctordr22 at gmail.com Sun Nov 6 11:55:30 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 08:55:30 -0800 (PST) Subject: oxycodone no prescription overnight cod delivery buy oxycodone no prescription needed Message-ID: <5793e048-810e-4749-be82-33c8658d0a8a@es7g2000vbb.googlegroups.com> oxycodone cheapest. Lowest prices for oxycodone online. Buy oxycodone online without no prescription. Buy cheap oxycodone next day no prescription! oxycodone BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=oxycodone <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=oxycodone http://buypharmasite.com/?q=Buy+online+oxycodone http://buypharmasite.com/?q=Buy+order+oxycodone http://buypharmasite.com/?q=Buy+oxycodone http://buypharmasite.com/?q=Buy+cheap+oxycodone http://buypharmasite.com/?q=Order+oxycodone http://buypharmasite.com/?q=Online+oxycodone cheap online pharmacy oxycodone oxycodone online saturday delivery online oxycodone and fedex cheap order prescription oxycodone cheap oxycodone by money order buy oxycodone from mexico online oxycodone no prescription usa fedex shipping overnight delivery oxycodone buy oxycodone online without a prescription and no membership no prescription needed oxycodone cod shipped oxycodone not expensive order prescription oxycodone oxycodone money order oxycodone without a perscription online buy oxycodone oxycodone fedex buy no online prescription oxycodone oxycodone pharmacies accepting cod delivery oxycodone online consultant online pharmacy fedex cod oxycodone buy oxycodone no scams oxycodone c.o.d overnight delivery buy oxycodone no prescription cod overnight oxycodone order oxycodone online doctors buy oxycodone on line no prescription oxycodone no prescription usa fedex shipping oxycodone online uk watson brand oxycodone medicine online oxycodone order oxycodone samples sent buy oxycodone no prescription order oxycodone without a prescription oxycodone no prescription drug cheap online order oxycodone get oxycodone over the counter online order oxycodone next day buy oxycodone no perscription cod real oxycodone fed ex oxycodone no prescription cod does cv/ pharmacy carry oxycodone no prescription cod oxycodone cheap oxycodone without rx oxycodone online health insurance lead buy oxycodone online with overnight delivery oxycodone no rx fed ex buy oxycodone without a perscription lowest prices for oxycodone online buy oxycodone paypal online without prescription cheap non prescription oxycodone oxycodone ups oxycodone for cheap buy oxycodone no visa online without prescription cheapest oxycodone cash on delivery oxycodone order a prepaid mastercard buy online oxycodone purchase oxycodone mail order oxycodone without a prescription online with overnight delivery oxycodone from canada buy oxycodone with no rx overnight delivery of oxycodone with no prescription cash on delivery oxycodone no rx oxycodone by cod buy oxycodone over the counter cod overnight overnight oxycodone order oxycodone without prescription from us pharmacy cheap oxycodone free fedex shipping order oxycodone over the counter where to buy oxycodone no prescription no fees only oxycodone free consult cod delivery oxycodone oxycodone no prescription oxycodone online overnight delivery cod order oxycodone over the counter fedex oxycodone saturday delivery buy oxycodone money order oxycodone without prescription mexico buy cheap oxycodone without prescription oxycodone non prescription for next day delivery oxycodone ups delivery only buy oxycodone usa cod oxycodone with next day delivery no prescriptions needed for oxycodone cheap oxycodone overnight prescription oxycodone cheap oxycodone overnight delivery oxycodone non prescription fedex overnight free order oxycodone no creditcard buy cheap oxycodone no Prescription buy oxycodone over the counter fedex oxycodone no doctor presribe needed cheap watson oxycodone online cheap discount oxycodone buy oxycodone without a prescription online cheapest oxycodone free delivery buy oxycodone online overseas buy oxycodone over the counter online not expensive oxycodone next day shipping order oxycodone cod next day delivery oxycodone cheap oxycodone buy in UK oxycodone next day cod fedex oxycodone to buy cheap order oxycodone next day oxycodone oxycodone overnight no consult cheap watson oxycodone no prescription needed oxycodone without prescription medications overnight delivery of oxycodone with no perscription buy oxycodone.com oxycodone cod next day delivery buy cheap discount online oxycodone buy oxycodone drug oxycodone overnight delivery cheap overnight delivery of oxycodone in US no prescription needed purchase oxycodone free next day airoxycodone on line cheap oxycodone without a prescription oxycodone cheap cod oxycodone buy no prepaid cheap oxycodone next day buy oxycodone cod accepted online pharmacies oxycodone saturday delivery buy oxycodone pay pal oxycodone shipped on saturday oxycodone pharmacy cod saturday delivery buy online oxycodone prescriptions free fedex delivery oxycodone oxycodone without prescription cash on delivery buy discount oxycodone oxycodone overnight cheap best oxycodone online pill images of oxycodone oxycodone U.P.S SHIPPING COD oxycodone cod pharmacy buy oxycodone online cod oxycodone cod overnight delivery oxycodone no rx overnight buy oxycodone overnight COD online pharmacy oxycodone cod order oxycodone insurance oxycodone cash delivery cod buy oxycodone cheap cod no rx online pharmacy oxycodone sale nextday oxycodone oxycodone pill oxycodone online ordering oxycodone online without prescription oxycodone no script needed cod overnight how to buy oxycodone online without a prescription cheap oxycodone without prescription cheap oxycodone online no rx saturday delivery order oxycodone over the counter for sale oxycodone next day delivery cod order oxycodone online without prescription no prescription next day delivery oxycodone overnight oxycodone C.O.D oxycodone without prescription oxycodone discount fedex no prescription buy oxycodone amex oxycodone online next day oxycodone shipped with no prescription oxycodone online cheap cheap oxycodone without prescription overnight delivery buy oxycodone over the counter for sale oxycodone no prescriptions needed cod oxycodone fed ex cheap overnight delivery of oxycodone free prescription oxycodone free shipping not expensive legal oxycodone for sale buy oxycodone cod oxycodone for saturday oxycodone price cash for oxycodone cash on delivery oxycodone oxycodone without a prescription and cod delivery buying oxycodone without a prescription order oxycodone no rx buy oxycodone without rx oxycodone cheapest buy oxycodone online pharmacy buy cheap oxycodone overnight delivery oxycodone and online pharmacy oxycodone next day oxycodone drug no prescription where can i buy oxycodone no prescription oxycodone with saturday delivery oxycodone online overnight oxycodone no prescription worldwide buy cheap oxycodone cod ordering oxycodone online Buy oxycodone overnight shipping oxycodone overnight US delivery cheap real oxycodone for sale oxycodone no prescriptions needed COD buy oxycodone no prescription needed oxycodone no prescription overnight cod delivery cheap oxycodone cash on delivery no prescription required for oxycodone order oxycodone c.o.d. not expensive oxycodone prescriptions oxycodone online Cash on Delivery buy oxycodone overnight delivery oxycodone online without presciption buy oxycodone prescription online no prescription saturday delivery oxycodone where to buy cheap oxycodone no prescription oxycodone wo get oxycodone over the counter fedex oxycodone with no rx and free shipping order oxycodone over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 11:59:57 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 08:59:57 -0800 (PST) Subject: how to buy Adderall online without a prescription cheap Adderall online no rx saturday delivery Message-ID: <20144e7f-528f-45cc-8c2d-36f8dd57113c@v8g2000vbe.googlegroups.com> Adderall cheapest. Lowest prices for Adderall online. Buy Adderall online without no prescription. Buy cheap Adderall next day no prescription! Adderall BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Adderall <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Adderall http://buypharmasite.com/?q=Buy+online+Adderall http://buypharmasite.com/?q=Buy+order+Adderall http://buypharmasite.com/?q=Buy+Adderall http://buypharmasite.com/?q=Buy+cheap+Adderall http://buypharmasite.com/?q=Order+Adderall http://buypharmasite.com/?q=Online+Adderall cheap online pharmacy Adderall Adderall online saturday delivery online Adderall and fedex cheap order prescription Adderall cheap Adderall by money order buy Adderall from mexico online Adderall no prescription usa fedex shipping overnight delivery Adderall buy Adderall online without a prescription and no membership no prescription needed Adderall cod shipped Adderall not expensive order prescription Adderall Adderall money order Adderall without a perscription online buy Adderall Adderall fedex buy no online prescription Adderall Adderall pharmacies accepting cod delivery Adderall online consultant online pharmacy fedex cod Adderall buy Adderall no scams Adderall c.o.d overnight delivery buy Adderall no prescription cod overnight Adderall order Adderall online doctors buy Adderall on line no prescription Adderall no prescription usa fedex shipping Adderall online uk watson brand Adderall medicine online Adderall order Adderall samples sent buy Adderall no prescription order Adderall without a prescription Adderall no prescription drug cheap online order Adderall get Adderall over the counter online order Adderall next day buy Adderall no perscription cod real Adderall fed ex Adderall no prescription cod does cv/ pharmacy carry Adderall no prescription cod Adderall cheap Adderall without rx Adderall online health insurance lead buy Adderall online with overnight delivery Adderall no rx fed ex buy Adderall without a perscription lowest prices for Adderall online buy Adderall paypal online without prescription cheap non prescription Adderall Adderall ups Adderall for cheap buy Adderall no visa online without prescription cheapest Adderall cash on delivery Adderall order a prepaid mastercard buy online Adderall purchase Adderall mail order Adderall without a prescription online with overnight delivery Adderall from canada buy Adderall with no rx overnight delivery of Adderall with no prescription cash on delivery Adderall no rx Adderall by cod buy Adderall over the counter cod overnight overnight Adderall order Adderall without prescription from us pharmacy cheap Adderall free fedex shipping order Adderall over the counter where to buy Adderall no prescription no fees only Adderall free consult cod delivery Adderall Adderall no prescription Adderall online overnight delivery cod order Adderall over the counter fedex Adderall saturday delivery buy Adderall money order Adderall without prescription mexico buy cheap Adderall without prescription Adderall non prescription for next day delivery Adderall ups delivery only buy Adderall usa cod Adderall with next day delivery no prescriptions needed for Adderall cheap Adderall overnight prescription Adderall cheap Adderall overnight delivery Adderall non prescription fedex overnight free order Adderall no creditcard buy cheap Adderall no Prescription buy Adderall over the counter fedex Adderall no doctor presribe needed cheap watson Adderall online cheap discount Adderall buy Adderall without a prescription online cheapest Adderall free delivery buy Adderall online overseas buy Adderall over the counter online not expensive Adderall next day shipping order Adderall cod next day delivery Adderall cheap Adderall buy in UK Adderall next day cod fedex Adderall to buy cheap order Adderall next day Adderall Adderall overnight no consult cheap watson Adderall no prescription needed Adderall without prescription medications overnight delivery of Adderall with no perscription buy Adderall.com Adderall cod next day delivery buy cheap discount online Adderall buy Adderall drug Adderall overnight delivery cheap overnight delivery of Adderall in US no prescription needed purchase Adderall free next day airAdderall on line cheap Adderall without a prescription Adderall cheap cod Adderall buy no prepaid cheap Adderall next day buy Adderall cod accepted online pharmacies Adderall saturday delivery buy Adderall pay pal Adderall shipped on saturday Adderall pharmacy cod saturday delivery buy online Adderall prescriptions free fedex delivery Adderall Adderall without prescription cash on delivery buy discount Adderall Adderall overnight cheap best Adderall online pill images of Adderall Adderall U.P.S SHIPPING COD Adderall cod pharmacy buy Adderall online cod Adderall cod overnight delivery Adderall no rx overnight buy Adderall overnight COD online pharmacy Adderall cod order Adderall insurance Adderall cash delivery cod buy Adderall cheap cod no rx online pharmacy Adderall sale nextday Adderall Adderall pill Adderall online ordering Adderall online without prescription Adderall no script needed cod overnight how to buy Adderall online without a prescription cheap Adderall without prescription cheap Adderall online no rx saturday delivery order Adderall over the counter for sale Adderall next day delivery cod order Adderall online without prescription no prescription next day delivery Adderall overnight Adderall C.O.D Adderall without prescription Adderall discount fedex no prescription buy Adderall amex Adderall online next day Adderall shipped with no prescription Adderall online cheap cheap Adderall without prescription overnight delivery buy Adderall over the counter for sale Adderall no prescriptions needed cod Adderall fed ex cheap overnight delivery of Adderall free prescription Adderall free shipping not expensive legal Adderall for sale buy Adderall cod Adderall for saturday Adderall price cash for Adderall cash on delivery Adderall Adderall without a prescription and cod delivery buying Adderall without a prescription order Adderall no rx buy Adderall without rx Adderall cheapest buy Adderall online pharmacy buy cheap Adderall overnight delivery Adderall and online pharmacy Adderall next day Adderall drug no prescription where can i buy Adderall no prescription Adderall with saturday delivery Adderall online overnight Adderall no prescription worldwide buy cheap Adderall cod ordering Adderall online Buy Adderall overnight shipping Adderall overnight US delivery cheap real Adderall for sale Adderall no prescriptions needed COD buy Adderall no prescription needed Adderall no prescription overnight cod delivery cheap Adderall cash on delivery no prescription required for Adderall order Adderall c.o.d. not expensive Adderall prescriptions Adderall online Cash on Delivery buy Adderall overnight delivery Adderall online without presciption buy Adderall prescription online no prescription saturday delivery Adderall where to buy cheap Adderall no prescription Adderall wo get Adderall over the counter fedex Adderall with no rx and free shipping order Adderall over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 12:04:06 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 09:04:06 -0800 (PST) Subject: Novartis pharmacies accepting cod delivery, buy no online prescription Novartis, Novartis no prescription usa fedex shipping Message-ID: <3c6e6a40-cdff-4dfd-8cfe-79508262d0a4@hv4g2000vbb.googlegroups.com> Novartis cheapest. Lowest prices for Novartis online. Buy Novartis online without no prescription. Buy cheap Novartis next day no prescription! Novartis BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Novartis <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Novartis http://buypharmasite.com/?q=Buy+online+Novartis http://buypharmasite.com/?q=Buy+order+Novartis http://buypharmasite.com/?q=Buy+Novartis http://buypharmasite.com/?q=Buy+cheap+Novartis http://buypharmasite.com/?q=Order+Novartis http://buypharmasite.com/?q=Online+Novartis cheap online pharmacy Novartis Novartis online saturday delivery online Novartis and fedex cheap order prescription Novartis cheap Novartis by money order buy Novartis from mexico online Novartis no prescription usa fedex shipping overnight delivery Novartis buy Novartis online without a prescription and no membership no prescription needed Novartis cod shipped Novartis not expensive order prescription Novartis Novartis money order Novartis without a perscription online buy Novartis Novartis fedex buy no online prescription Novartis Novartis pharmacies accepting cod delivery Novartis online consultant online pharmacy fedex cod Novartis buy Novartis no scams Novartis c.o.d overnight delivery buy Novartis no prescription cod overnight Novartis order Novartis online doctors buy Novartis on line no prescription Novartis no prescription usa fedex shipping Novartis online uk watson brand Novartis medicine online Novartis order Novartis samples sent buy Novartis no prescription order Novartis without a prescription Novartis no prescription drug cheap online order Novartis get Novartis over the counter online order Novartis next day buy Novartis no perscription cod real Novartis fed ex Novartis no prescription cod does cv/ pharmacy carry Novartis no prescription cod Novartis cheap Novartis without rx Novartis online health insurance lead buy Novartis online with overnight delivery Novartis no rx fed ex buy Novartis without a perscription lowest prices for Novartis online buy Novartis paypal online without prescription cheap non prescription Novartis Novartis ups Novartis for cheap buy Novartis no visa online without prescription cheapest Novartis cash on delivery Novartis order a prepaid mastercard buy online Novartis purchase Novartis mail order Novartis without a prescription online with overnight delivery Novartis from canada buy Novartis with no rx overnight delivery of Novartis with no prescription cash on delivery Novartis no rx Novartis by cod buy Novartis over the counter cod overnight overnight Novartis order Novartis without prescription from us pharmacy cheap Novartis free fedex shipping order Novartis over the counter where to buy Novartis no prescription no fees only Novartis free consult cod delivery Novartis Novartis no prescription Novartis online overnight delivery cod order Novartis over the counter fedex Novartis saturday delivery buy Novartis money order Novartis without prescription mexico buy cheap Novartis without prescription Novartis non prescription for next day delivery Novartis ups delivery only buy Novartis usa cod Novartis with next day delivery no prescriptions needed for Novartis cheap Novartis overnight prescription Novartis cheap Novartis overnight delivery Novartis non prescription fedex overnight free order Novartis no creditcard buy cheap Novartis no Prescription buy Novartis over the counter fedex Novartis no doctor presribe needed cheap watson Novartis online cheap discount Novartis buy Novartis without a prescription online cheapest Novartis free delivery buy Novartis online overseas buy Novartis over the counter online not expensive Novartis next day shipping order Novartis cod next day delivery Novartis cheap Novartis buy in UK Novartis next day cod fedex Novartis to buy cheap order Novartis next day Novartis Novartis overnight no consult cheap watson Novartis no prescription needed Novartis without prescription medications overnight delivery of Novartis with no perscription buy Novartis.com Novartis cod next day delivery buy cheap discount online Novartis buy Novartis drug Novartis overnight delivery cheap overnight delivery of Novartis in US no prescription needed purchase Novartis free next day airNovartis on line cheap Novartis without a prescription Novartis cheap cod Novartis buy no prepaid cheap Novartis next day buy Novartis cod accepted online pharmacies Novartis saturday delivery buy Novartis pay pal Novartis shipped on saturday Novartis pharmacy cod saturday delivery buy online Novartis prescriptions free fedex delivery Novartis Novartis without prescription cash on delivery buy discount Novartis Novartis overnight cheap best Novartis online pill images of Novartis Novartis U.P.S SHIPPING COD Novartis cod pharmacy buy Novartis online cod Novartis cod overnight delivery Novartis no rx overnight buy Novartis overnight COD online pharmacy Novartis cod order Novartis insurance Novartis cash delivery cod buy Novartis cheap cod no rx online pharmacy Novartis sale nextday Novartis Novartis pill Novartis online ordering Novartis online without prescription Novartis no script needed cod overnight how to buy Novartis online without a prescription cheap Novartis without prescription cheap Novartis online no rx saturday delivery order Novartis over the counter for sale Novartis next day delivery cod order Novartis online without prescription no prescription next day delivery Novartis overnight Novartis C.O.D Novartis without prescription Novartis discount fedex no prescription buy Novartis amex Novartis online next day Novartis shipped with no prescription Novartis online cheap cheap Novartis without prescription overnight delivery buy Novartis over the counter for sale Novartis no prescriptions needed cod Novartis fed ex cheap overnight delivery of Novartis free prescription Novartis free shipping not expensive legal Novartis for sale buy Novartis cod Novartis for saturday Novartis price cash for Novartis cash on delivery Novartis Novartis without a prescription and cod delivery buying Novartis without a prescription order Novartis no rx buy Novartis without rx Novartis cheapest buy Novartis online pharmacy buy cheap Novartis overnight delivery Novartis and online pharmacy Novartis next day Novartis drug no prescription where can i buy Novartis no prescription Novartis with saturday delivery Novartis online overnight Novartis no prescription worldwide buy cheap Novartis cod ordering Novartis online Buy Novartis overnight shipping Novartis overnight US delivery cheap real Novartis for sale Novartis no prescriptions needed COD buy Novartis no prescription needed Novartis no prescription overnight cod delivery cheap Novartis cash on delivery no prescription required for Novartis order Novartis c.o.d. not expensive Novartis prescriptions Novartis online Cash on Delivery buy Novartis overnight delivery Novartis online without presciption buy Novartis prescription online no prescription saturday delivery Novartis where to buy cheap Novartis no prescription Novartis wo get Novartis over the counter fedex Novartis with no rx and free shipping order Novartis over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 12:08:25 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 09:08:25 -0800 (PST) Subject: Methylphenidate non prescription fedex overnight free no prescriptions needed for Methylphenidate Methylphenidate without prescription mexico Message-ID: <30310bce-b34f-4e84-b20b-78aa531ca8e0@ek5g2000vbb.googlegroups.com> Methylphenidate cheapest. Lowest prices for Methylphenidate online. Buy Methylphenidate online without no prescription. Buy cheap Methylphenidate next day no prescription! Methylphenidate BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Methylphenidate <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Methylphenidate http://buypharmasite.com/?q=Buy+online+Methylphenidate http://buypharmasite.com/?q=Buy+order+Methylphenidate http://buypharmasite.com/?q=Buy+Methylphenidate http://buypharmasite.com/?q=Buy+cheap+Methylphenidate http://buypharmasite.com/?q=Order+Methylphenidate http://buypharmasite.com/?q=Online+Methylphenidate cheap online pharmacy Methylphenidate Methylphenidate online saturday delivery online Methylphenidate and fedex cheap order prescription Methylphenidate cheap Methylphenidate by money order buy Methylphenidate from mexico online Methylphenidate no prescription usa fedex shipping overnight delivery Methylphenidate buy Methylphenidate online without a prescription and no membership no prescription needed Methylphenidate cod shipped Methylphenidate not expensive order prescription Methylphenidate Methylphenidate money order Methylphenidate without a perscription online buy Methylphenidate Methylphenidate fedex buy no online prescription Methylphenidate Methylphenidate pharmacies accepting cod delivery Methylphenidate online consultant online pharmacy fedex cod Methylphenidate buy Methylphenidate no scams Methylphenidate c.o.d overnight delivery buy Methylphenidate no prescription cod overnight Methylphenidate order Methylphenidate online doctors buy Methylphenidate on line no prescription Methylphenidate no prescription usa fedex shipping Methylphenidate online uk watson brand Methylphenidate medicine online Methylphenidate order Methylphenidate samples sent buy Methylphenidate no prescription order Methylphenidate without a prescription Methylphenidate no prescription drug cheap online order Methylphenidate get Methylphenidate over the counter online order Methylphenidate next day buy Methylphenidate no perscription cod real Methylphenidate fed ex Methylphenidate no prescription cod does cv/ pharmacy carry Methylphenidate no prescription cod Methylphenidate cheap Methylphenidate without rx Methylphenidate online health insurance lead buy Methylphenidate online with overnight delivery Methylphenidate no rx fed ex buy Methylphenidate without a perscription lowest prices for Methylphenidate online buy Methylphenidate paypal online without prescription cheap non prescription Methylphenidate Methylphenidate ups Methylphenidate for cheap buy Methylphenidate no visa online without prescription cheapest Methylphenidate cash on delivery Methylphenidate order a prepaid mastercard buy online Methylphenidate purchase Methylphenidate mail order Methylphenidate without a prescription online with overnight delivery Methylphenidate from canada buy Methylphenidate with no rx overnight delivery of Methylphenidate with no prescription cash on delivery Methylphenidate no rx Methylphenidate by cod buy Methylphenidate over the counter cod overnight overnight Methylphenidate order Methylphenidate without prescription from us pharmacy cheap Methylphenidate free fedex shipping order Methylphenidate over the counter where to buy Methylphenidate no prescription no fees only Methylphenidate free consult cod delivery Methylphenidate Methylphenidate no prescription Methylphenidate online overnight delivery cod order Methylphenidate over the counter fedex Methylphenidate saturday delivery buy Methylphenidate money order Methylphenidate without prescription mexico buy cheap Methylphenidate without prescription Methylphenidate non prescription for next day delivery Methylphenidate ups delivery only buy Methylphenidate usa cod Methylphenidate with next day delivery no prescriptions needed for Methylphenidate cheap Methylphenidate overnight prescription Methylphenidate cheap Methylphenidate overnight delivery Methylphenidate non prescription fedex overnight free order Methylphenidate no creditcard buy cheap Methylphenidate no Prescription buy Methylphenidate over the counter fedex Methylphenidate no doctor presribe needed cheap watson Methylphenidate online cheap discount Methylphenidate buy Methylphenidate without a prescription online cheapest Methylphenidate free delivery buy Methylphenidate online overseas buy Methylphenidate over the counter online not expensive Methylphenidate next day shipping order Methylphenidate cod next day delivery Methylphenidate cheap Methylphenidate buy in UK Methylphenidate next day cod fedex Methylphenidate to buy cheap order Methylphenidate next day Methylphenidate Methylphenidate overnight no consult cheap watson Methylphenidate no prescription needed Methylphenidate without prescription medications overnight delivery of Methylphenidate with no perscription buy Methylphenidate.com Methylphenidate cod next day delivery buy cheap discount online Methylphenidate buy Methylphenidate drug Methylphenidate overnight delivery cheap overnight delivery of Methylphenidate in US no prescription needed purchase Methylphenidate free next day airMethylphenidate on line cheap Methylphenidate without a prescription Methylphenidate cheap cod Methylphenidate buy no prepaid cheap Methylphenidate next day buy Methylphenidate cod accepted online pharmacies Methylphenidate saturday delivery buy Methylphenidate pay pal Methylphenidate shipped on saturday Methylphenidate pharmacy cod saturday delivery buy online Methylphenidate prescriptions free fedex delivery Methylphenidate Methylphenidate without prescription cash on delivery buy discount Methylphenidate Methylphenidate overnight cheap best Methylphenidate online pill images of Methylphenidate Methylphenidate U.P.S SHIPPING COD Methylphenidate cod pharmacy buy Methylphenidate online cod Methylphenidate cod overnight delivery Methylphenidate no rx overnight buy Methylphenidate overnight COD online pharmacy Methylphenidate cod order Methylphenidate insurance Methylphenidate cash delivery cod buy Methylphenidate cheap cod no rx online pharmacy Methylphenidate sale nextday Methylphenidate Methylphenidate pill Methylphenidate online ordering Methylphenidate online without prescription Methylphenidate no script needed cod overnight how to buy Methylphenidate online without a prescription cheap Methylphenidate without prescription cheap Methylphenidate online no rx saturday delivery order Methylphenidate over the counter for sale Methylphenidate next day delivery cod order Methylphenidate online without prescription no prescription next day delivery Methylphenidate overnight Methylphenidate C.O.D Methylphenidate without prescription Methylphenidate discount fedex no prescription buy Methylphenidate amex Methylphenidate online next day Methylphenidate shipped with no prescription Methylphenidate online cheap cheap Methylphenidate without prescription overnight delivery buy Methylphenidate over the counter for sale Methylphenidate no prescriptions needed cod Methylphenidate fed ex cheap overnight delivery of Methylphenidate free prescription Methylphenidate free shipping not expensive legal Methylphenidate for sale buy Methylphenidate cod Methylphenidate for saturday Methylphenidate price cash for Methylphenidate cash on delivery Methylphenidate Methylphenidate without a prescription and cod delivery buying Methylphenidate without a prescription order Methylphenidate no rx buy Methylphenidate without rx Methylphenidate cheapest buy Methylphenidate online pharmacy buy cheap Methylphenidate overnight delivery Methylphenidate and online pharmacy Methylphenidate next day Methylphenidate drug no prescription where can i buy Methylphenidate no prescription Methylphenidate with saturday delivery Methylphenidate online overnight Methylphenidate no prescription worldwide buy cheap Methylphenidate cod ordering Methylphenidate online Buy Methylphenidate overnight shipping Methylphenidate overnight US delivery cheap real Methylphenidate for sale Methylphenidate no prescriptions needed COD buy Methylphenidate no prescription needed Methylphenidate no prescription overnight cod delivery cheap Methylphenidate cash on delivery no prescription required for Methylphenidate order Methylphenidate c.o.d. not expensive Methylphenidate prescriptions Methylphenidate online Cash on Delivery buy Methylphenidate overnight delivery Methylphenidate online without presciption buy Methylphenidate prescription online no prescription saturday delivery Methylphenidate where to buy cheap Methylphenidate no prescription Methylphenidate wo get Methylphenidate over the counter fedex Methylphenidate with no rx and free shipping order Methylphenidate over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 12:11:24 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 09:11:24 -0800 (PST) Subject: buy vicodin online without a prescription and no membership | vicodin no prescription usa fedex shipping Message-ID: <78b8fe50-3adc-498c-a02a-9947c06dce25@o19g2000vbk.googlegroups.com> vicodin cheapest. Lowest prices for vicodin online. Buy vicodin online without no prescription. Buy cheap vicodin next day no prescription! vicodin BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=vicodin <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=vicodin http://buypharmasite.com/?q=Buy+online+vicodin http://buypharmasite.com/?q=Buy+order+vicodin http://buypharmasite.com/?q=Buy+vicodin http://buypharmasite.com/?q=Buy+cheap+vicodin http://buypharmasite.com/?q=Order+vicodin http://buypharmasite.com/?q=Online+vicodin cheap online pharmacy vicodin vicodin online saturday delivery online vicodin and fedex cheap order prescription vicodin cheap vicodin by money order buy vicodin from mexico online vicodin no prescription usa fedex shipping overnight delivery vicodin buy vicodin online without a prescription and no membership no prescription needed vicodin cod shipped vicodin not expensive order prescription vicodin vicodin money order vicodin without a perscription online buy vicodin vicodin fedex buy no online prescription vicodin vicodin pharmacies accepting cod delivery vicodin online consultant online pharmacy fedex cod vicodin buy vicodin no scams vicodin c.o.d overnight delivery buy vicodin no prescription cod overnight vicodin order vicodin online doctors buy vicodin on line no prescription vicodin no prescription usa fedex shipping vicodin online uk watson brand vicodin medicine online vicodin order vicodin samples sent buy vicodin no prescription order vicodin without a prescription vicodin no prescription drug cheap online order vicodin get vicodin over the counter online order vicodin next day buy vicodin no perscription cod real vicodin fed ex vicodin no prescription cod does cv/ pharmacy carry vicodin no prescription cod vicodin cheap vicodin without rx vicodin online health insurance lead buy vicodin online with overnight delivery vicodin no rx fed ex buy vicodin without a perscription lowest prices for vicodin online buy vicodin paypal online without prescription cheap non prescription vicodin vicodin ups vicodin for cheap buy vicodin no visa online without prescription cheapest vicodin cash on delivery vicodin order a prepaid mastercard buy online vicodin purchase vicodin mail order vicodin without a prescription online with overnight delivery vicodin from canada buy vicodin with no rx overnight delivery of vicodin with no prescription cash on delivery vicodin no rx vicodin by cod buy vicodin over the counter cod overnight overnight vicodin order vicodin without prescription from us pharmacy cheap vicodin free fedex shipping order vicodin over the counter where to buy vicodin no prescription no fees only vicodin free consult cod delivery vicodin vicodin no prescription vicodin online overnight delivery cod order vicodin over the counter fedex vicodin saturday delivery buy vicodin money order vicodin without prescription mexico buy cheap vicodin without prescription vicodin non prescription for next day delivery vicodin ups delivery only buy vicodin usa cod vicodin with next day delivery no prescriptions needed for vicodin cheap vicodin overnight prescription vicodin cheap vicodin overnight delivery vicodin non prescription fedex overnight free order vicodin no creditcard buy cheap vicodin no Prescription buy vicodin over the counter fedex vicodin no doctor presribe needed cheap watson vicodin online cheap discount vicodin buy vicodin without a prescription online cheapest vicodin free delivery buy vicodin online overseas buy vicodin over the counter online not expensive vicodin next day shipping order vicodin cod next day delivery vicodin cheap vicodin buy in UK vicodin next day cod fedex vicodin to buy cheap order vicodin next day vicodin vicodin overnight no consult cheap watson vicodin no prescription needed vicodin without prescription medications overnight delivery of vicodin with no perscription buy vicodin.com vicodin cod next day delivery buy cheap discount online vicodin buy vicodin drug vicodin overnight delivery cheap overnight delivery of vicodin in US no prescription needed purchase vicodin free next day airvicodin on line cheap vicodin without a prescription vicodin cheap cod vicodin buy no prepaid cheap vicodin next day buy vicodin cod accepted online pharmacies vicodin saturday delivery buy vicodin pay pal vicodin shipped on saturday vicodin pharmacy cod saturday delivery buy online vicodin prescriptions free fedex delivery vicodin vicodin without prescription cash on delivery buy discount vicodin vicodin overnight cheap best vicodin online pill images of vicodin vicodin U.P.S SHIPPING COD vicodin cod pharmacy buy vicodin online cod vicodin cod overnight delivery vicodin no rx overnight buy vicodin overnight COD online pharmacy vicodin cod order vicodin insurance vicodin cash delivery cod buy vicodin cheap cod no rx online pharmacy vicodin sale nextday vicodin vicodin pill vicodin online ordering vicodin online without prescription vicodin no script needed cod overnight how to buy vicodin online without a prescription cheap vicodin without prescription cheap vicodin online no rx saturday delivery order vicodin over the counter for sale vicodin next day delivery cod order vicodin online without prescription no prescription next day delivery vicodin overnight vicodin C.O.D vicodin without prescription vicodin discount fedex no prescription buy vicodin amex vicodin online next day vicodin shipped with no prescription vicodin online cheap cheap vicodin without prescription overnight delivery buy vicodin over the counter for sale vicodin no prescriptions needed cod vicodin fed ex cheap overnight delivery of vicodin free prescription vicodin free shipping not expensive legal vicodin for sale buy vicodin cod vicodin for saturday vicodin price cash for vicodin cash on delivery vicodin vicodin without a prescription and cod delivery buying vicodin without a prescription order vicodin no rx buy vicodin without rx vicodin cheapest buy vicodin online pharmacy buy cheap vicodin overnight delivery vicodin and online pharmacy vicodin next day vicodin drug no prescription where can i buy vicodin no prescription vicodin with saturday delivery vicodin online overnight vicodin no prescription worldwide buy cheap vicodin cod ordering vicodin online Buy vicodin overnight shipping vicodin overnight US delivery cheap real vicodin for sale vicodin no prescriptions needed COD buy vicodin no prescription needed vicodin no prescription overnight cod delivery cheap vicodin cash on delivery no prescription required for vicodin order vicodin c.o.d. not expensive vicodin prescriptions vicodin online Cash on Delivery buy vicodin overnight delivery vicodin online without presciption buy vicodin prescription online no prescription saturday delivery vicodin where to buy cheap vicodin no prescription vicodin wo get vicodin over the counter fedex vicodin with no rx and free shipping order vicodin over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 12:14:28 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 09:14:28 -0800 (PST) Subject: cheap Tramadol without prescription overnight delivery | order Tramadol online without prescription Message-ID: <1f306d71-a178-4905-9c88-69621b9765d9@gk10g2000vbb.googlegroups.com> Tramadol cheapest. Lowest prices for Tramadol online. Buy Tramadol online without no prescription. Buy cheap Tramadol next day no prescription! Tramadol BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Tramadol <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Tramadol http://buypharmasite.com/?q=Buy+online+Tramadol http://buypharmasite.com/?q=Buy+order+Tramadol http://buypharmasite.com/?q=Buy+Tramadol http://buypharmasite.com/?q=Buy+cheap+Tramadol http://buypharmasite.com/?q=Order+Tramadol http://buypharmasite.com/?q=Online+Tramadol cheap online pharmacy Tramadol Tramadol online saturday delivery online Tramadol and fedex cheap order prescription Tramadol cheap Tramadol by money order buy Tramadol from mexico online Tramadol no prescription usa fedex shipping overnight delivery Tramadol buy Tramadol online without a prescription and no membership no prescription needed Tramadol cod shipped Tramadol not expensive order prescription Tramadol Tramadol money order Tramadol without a perscription online buy Tramadol Tramadol fedex buy no online prescription Tramadol Tramadol pharmacies accepting cod delivery Tramadol online consultant online pharmacy fedex cod Tramadol buy Tramadol no scams Tramadol c.o.d overnight delivery buy Tramadol no prescription cod overnight Tramadol order Tramadol online doctors buy Tramadol on line no prescription Tramadol no prescription usa fedex shipping Tramadol online uk watson brand Tramadol medicine online Tramadol order Tramadol samples sent buy Tramadol no prescription order Tramadol without a prescription Tramadol no prescription drug cheap online order Tramadol get Tramadol over the counter online order Tramadol next day buy Tramadol no perscription cod real Tramadol fed ex Tramadol no prescription cod does cv/ pharmacy carry Tramadol no prescription cod Tramadol cheap Tramadol without rx Tramadol online health insurance lead buy Tramadol online with overnight delivery Tramadol no rx fed ex buy Tramadol without a perscription lowest prices for Tramadol online buy Tramadol paypal online without prescription cheap non prescription Tramadol Tramadol ups Tramadol for cheap buy Tramadol no visa online without prescription cheapest Tramadol cash on delivery Tramadol order a prepaid mastercard buy online Tramadol purchase Tramadol mail order Tramadol without a prescription online with overnight delivery Tramadol from canada buy Tramadol with no rx overnight delivery of Tramadol with no prescription cash on delivery Tramadol no rx Tramadol by cod buy Tramadol over the counter cod overnight overnight Tramadol order Tramadol without prescription from us pharmacy cheap Tramadol free fedex shipping order Tramadol over the counter where to buy Tramadol no prescription no fees only Tramadol free consult cod delivery Tramadol Tramadol no prescription Tramadol online overnight delivery cod order Tramadol over the counter fedex Tramadol saturday delivery buy Tramadol money order Tramadol without prescription mexico buy cheap Tramadol without prescription Tramadol non prescription for next day delivery Tramadol ups delivery only buy Tramadol usa cod Tramadol with next day delivery no prescriptions needed for Tramadol cheap Tramadol overnight prescription Tramadol cheap Tramadol overnight delivery Tramadol non prescription fedex overnight free order Tramadol no creditcard buy cheap Tramadol no Prescription buy Tramadol over the counter fedex Tramadol no doctor presribe needed cheap watson Tramadol online cheap discount Tramadol buy Tramadol without a prescription online cheapest Tramadol free delivery buy Tramadol online overseas buy Tramadol over the counter online not expensive Tramadol next day shipping order Tramadol cod next day delivery Tramadol cheap Tramadol buy in UK Tramadol next day cod fedex Tramadol to buy cheap order Tramadol next day Tramadol Tramadol overnight no consult cheap watson Tramadol no prescription needed Tramadol without prescription medications overnight delivery of Tramadol with no perscription buy Tramadol.com Tramadol cod next day delivery buy cheap discount online Tramadol buy Tramadol drug Tramadol overnight delivery cheap overnight delivery of Tramadol in US no prescription needed purchase Tramadol free next day airTramadol on line cheap Tramadol without a prescription Tramadol cheap cod Tramadol buy no prepaid cheap Tramadol next day buy Tramadol cod accepted online pharmacies Tramadol saturday delivery buy Tramadol pay pal Tramadol shipped on saturday Tramadol pharmacy cod saturday delivery buy online Tramadol prescriptions free fedex delivery Tramadol Tramadol without prescription cash on delivery buy discount Tramadol Tramadol overnight cheap best Tramadol online pill images of Tramadol Tramadol U.P.S SHIPPING COD Tramadol cod pharmacy buy Tramadol online cod Tramadol cod overnight delivery Tramadol no rx overnight buy Tramadol overnight COD online pharmacy Tramadol cod order Tramadol insurance Tramadol cash delivery cod buy Tramadol cheap cod no rx online pharmacy Tramadol sale nextday Tramadol Tramadol pill Tramadol online ordering Tramadol online without prescription Tramadol no script needed cod overnight how to buy Tramadol online without a prescription cheap Tramadol without prescription cheap Tramadol online no rx saturday delivery order Tramadol over the counter for sale Tramadol next day delivery cod order Tramadol online without prescription no prescription next day delivery Tramadol overnight Tramadol C.O.D Tramadol without prescription Tramadol discount fedex no prescription buy Tramadol amex Tramadol online next day Tramadol shipped with no prescription Tramadol online cheap cheap Tramadol without prescription overnight delivery buy Tramadol over the counter for sale Tramadol no prescriptions needed cod Tramadol fed ex cheap overnight delivery of Tramadol free prescription Tramadol free shipping not expensive legal Tramadol for sale buy Tramadol cod Tramadol for saturday Tramadol price cash for Tramadol cash on delivery Tramadol Tramadol without a prescription and cod delivery buying Tramadol without a prescription order Tramadol no rx buy Tramadol without rx Tramadol cheapest buy Tramadol online pharmacy buy cheap Tramadol overnight delivery Tramadol and online pharmacy Tramadol next day Tramadol drug no prescription where can i buy Tramadol no prescription Tramadol with saturday delivery Tramadol online overnight Tramadol no prescription worldwide buy cheap Tramadol cod ordering Tramadol online Buy Tramadol overnight shipping Tramadol overnight US delivery cheap real Tramadol for sale Tramadol no prescriptions needed COD buy Tramadol no prescription needed Tramadol no prescription overnight cod delivery cheap Tramadol cash on delivery no prescription required for Tramadol order Tramadol c.o.d. not expensive Tramadol prescriptions Tramadol online Cash on Delivery buy Tramadol overnight delivery Tramadol online without presciption buy Tramadol prescription online no prescription saturday delivery Tramadol where to buy cheap Tramadol no prescription Tramadol wo get Tramadol over the counter fedex Tramadol with no rx and free shipping order Tramadol over the counter cod overnight From gheskett at wdtv.com Sun Nov 6 13:14:43 2011 From: gheskett at wdtv.com (gene heskett) Date: Sun, 6 Nov 2011 13:14:43 -0500 Subject: Python lesson please Message-ID: <201111061314.43744.gheskett@wdtv.com> Greetings experts: I just dl'd the duqu driver finder script from a link to NSS on /., and fixed enough of the tabs in it to make it run error-free. At least python isn't having a litter of cows over the indentation now. But it also runs instantly on linux. This line looks suspect to me: rootdir = sys.argv[1] And I have a suspicion it is null on a linux box. How can I fix that best? Thanks. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Most of the fear that spoils our life comes from attacking difficulties before we get to them. -- Dr. Frank Crane From jfine at pytex.org Sun Nov 6 13:19:39 2011 From: jfine at pytex.org (Jonathan Fine) Date: Sun, 06 Nov 2011 18:19:39 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> Message-ID: <4EB6CFBB.2090901@pytex.org> On 06/11/11 16:42, Jakub Narebski wrote: > Jonathan Fine writes: > >> Hi >> >> This it to let you know that I'm writing (in Python) a script that >> places the content of CTAN into a git repository. >> https://bitbucket.org/jfine/python-ctantools > > I hope that you meant "repositories" (plural) here, one per tool, > rather than putting all of CTAN into single Git repository. There are complex dependencies among LaTeX macro packages, and TeX is often distributed and installed from a DVD. So it makes sense here to put *all* the content of a DVD into a repository. Once you've done that, it is then possible and sensible to select suitable interesting subsets, such as releases of a particular package. Users could even define their own subsets, such as "all resources needed to process this file, exactly as it processes on my machine". In addition, many TeX users have a TeX DVD. If they import it into a git repository (using for example my script) then the update from 2011 to 2012 would require much less bandwidth. Finally, I'd rather be working within git that modified copy of the ISO when doing the subsetting. I'm pretty sure that I can manage to pull the small repositories from the big git-CTAN repository. But as I proceed, perhaps I'll change my mind (smile). >> I'm working from the TeX Collection DVDs that are published each year >> by the TeX user groups, which contain a snapshot of CTAN (about >> 100,000 files occupying 4Gb), which means I have to unzip folders and >> do a few other things. > > There is 'contrib/fast-import/import-zips.py' in git.git repository. > If you are not using it, or its equivalent, it might be worth checking > out. Well, I didn't know about that. I took a look, and it doesn't do what I want. I need to walk the tree (on a mounted ISO) and unpack some (but not all) zip files as I come across them. For details see: https://bitbucket.org/jfine/python-ctantools/src/tip/ctantools/filetools.py In addition, I don't want to make a commit. I just want to make a ref at the end of building the tree. This is because I want the import of a TeX DVD to give effectively identical results for all users, and so any commit information would be effectively constant. >> CTAN is the Comprehensive TeX Archive Network. CTAN keeps only the >> latest version of each file, but old CTAN snapshots will provide many >> earlier versions. > > There was similar effort done in putting CPAN (Comprehensive _Perl_ > Archive Network) in Git, hosting repositories on GitHub[1], by the name > of gitPAN, see e.g.: > > "The gitPAN Import is Complete" > http://perlisalive.com/articles/36 > > [1]: https://github.com/gitpan This is really good to know!!! Not only has this been done already, for similar reasons, but github is hosting it. Life is easier when there is a good example to follow. >> I'm working on putting old CTAN files into modern version >> control. Martin Scharrer is working in the other direction. He's >> putting new files added to CTAN into Mercurial. >> http://ctanhg.scharrer-online.de/ > > Nb. thanks to tools such as git-hg and fast-import / fast-export > we have quite good interoperability and convertability between > Git and Mercurial. > > P.S. I'd point to reposurgeon tool, which can be used to do fixups > after import, but it would probably won't work on such large (set of) > repositories. Thank you for the pointer to reposurgeon. My approach is a bit different. First, get all the files into git, and then 'edit the tree' to create new trees. And then commit worthwhile new trees. As I recall the first 'commit' to the git repository for the Linux kernel was just a tree, with a reference to that tree as a tag. But no commit. > P.P.S. Can you forward it to comp.text.tex? Done. -- Jonathan From jfine at pytex.org Sun Nov 6 13:19:39 2011 From: jfine at pytex.org (Jonathan Fine) Date: Sun, 06 Nov 2011 18:19:39 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> Message-ID: <4EB6CFBB.2090901@pytex.org> On 06/11/11 16:42, Jakub Narebski wrote: > Jonathan Fine writes: > >> Hi >> >> This it to let you know that I'm writing (in Python) a script that >> places the content of CTAN into a git repository. >> https://bitbucket.org/jfine/python-ctantools > > I hope that you meant "repositories" (plural) here, one per tool, > rather than putting all of CTAN into single Git repository. There are complex dependencies among LaTeX macro packages, and TeX is often distributed and installed from a DVD. So it makes sense here to put *all* the content of a DVD into a repository. Once you've done that, it is then possible and sensible to select suitable interesting subsets, such as releases of a particular package. Users could even define their own subsets, such as "all resources needed to process this file, exactly as it processes on my machine". In addition, many TeX users have a TeX DVD. If they import it into a git repository (using for example my script) then the update from 2011 to 2012 would require much less bandwidth. Finally, I'd rather be working within git that modified copy of the ISO when doing the subsetting. I'm pretty sure that I can manage to pull the small repositories from the big git-CTAN repository. But as I proceed, perhaps I'll change my mind (smile). >> I'm working from the TeX Collection DVDs that are published each year >> by the TeX user groups, which contain a snapshot of CTAN (about >> 100,000 files occupying 4Gb), which means I have to unzip folders and >> do a few other things. > > There is 'contrib/fast-import/import-zips.py' in git.git repository. > If you are not using it, or its equivalent, it might be worth checking > out. Well, I didn't know about that. I took a look, and it doesn't do what I want. I need to walk the tree (on a mounted ISO) and unpack some (but not all) zip files as I come across them. For details see: https://bitbucket.org/jfine/python-ctantools/src/tip/ctantools/filetools.py In addition, I don't want to make a commit. I just want to make a ref at the end of building the tree. This is because I want the import of a TeX DVD to give effectively identical results for all users, and so any commit information would be effectively constant. >> CTAN is the Comprehensive TeX Archive Network. CTAN keeps only the >> latest version of each file, but old CTAN snapshots will provide many >> earlier versions. > > There was similar effort done in putting CPAN (Comprehensive _Perl_ > Archive Network) in Git, hosting repositories on GitHub[1], by the name > of gitPAN, see e.g.: > > "The gitPAN Import is Complete" > http://perlisalive.com/articles/36 > > [1]: https://github.com/gitpan This is really good to know!!! Not only has this been done already, for similar reasons, but github is hosting it. Life is easier when there is a good example to follow. >> I'm working on putting old CTAN files into modern version >> control. Martin Scharrer is working in the other direction. He's >> putting new files added to CTAN into Mercurial. >> http://ctanhg.scharrer-online.de/ > > Nb. thanks to tools such as git-hg and fast-import / fast-export > we have quite good interoperability and convertability between > Git and Mercurial. > > P.S. I'd point to reposurgeon tool, which can be used to do fixups > after import, but it would probably won't work on such large (set of) > repositories. Thank you for the pointer to reposurgeon. My approach is a bit different. First, get all the files into git, and then 'edit the tree' to create new trees. And then commit worthwhile new trees. As I recall the first 'commit' to the git repository for the Linux kernel was just a tree, with a reference to that tree as a tag. But no commit. > P.P.S. Can you forward it to comp.text.tex? Done. -- Jonathan From drsalists at gmail.com Sun Nov 6 15:00:59 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 6 Nov 2011 12:00:59 -0800 Subject: RSS feed creation? Message-ID: Is there an opensource Python tool for creating RSS feeds, that doesn't require large dependencies? I found feedformatter.py on pypi, but it seems a little old, and its sole automated test gives a traceback. Is there a better starting point? (I'd of course prefer something that'll run on 3.x and 2.x, but will settle for either) -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Sun Nov 6 15:21:12 2011 From: d at davea.name (Dave Angel) Date: Sun, 06 Nov 2011 15:21:12 -0500 Subject: Python lesson please In-Reply-To: <201111061314.43744.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> Message-ID: <4EB6EC38.20708@davea.name> On 11/06/2011 01:14 PM, gene heskett wrote: > Greetings experts: > > I just dl'd the duqu driver finder script from a link to NSS on /., and > fixed enough of the tabs in it to make it run error-free. At least python > isn't having a litter of cows over the indentation now. > > But it also runs instantly on linux. > > This line looks suspect to me: > rootdir = sys.argv[1] > > And I have a suspicion it is null on a linux box. > > How can I fix that best? > > Thanks. > > Cheers, Gene Nothing wrong with that line, assuming the user of the script happened to provide an argument for rootpath. Probably it should be preceded by a a conditional: if len(argv) <2: tell.user.that.she's.missing.the.rootdir.parameter else: rootdir = sys.argv[1] etc. What does the help text show when you run the script with the --help argument? -- DaveA From jnareb at gmail.com Sun Nov 6 15:28:33 2011 From: jnareb at gmail.com (Jakub Narebski) Date: 06 Nov 2011 21:28:33 +0100 Subject: A Python script to put CTAN into git (from DVDs) References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> Message-ID: Jonathan Fine writes: > On 06/11/11 16:42, Jakub Narebski wrote: >> Jonathan Fine writes: >> >>> This it to let you know that I'm writing (in Python) a script that >>> places the content of CTAN into a git repository. >>> https://bitbucket.org/jfine/python-ctantools >> >> I hope that you meant "repositories" (plural) here, one per tool, >> rather than putting all of CTAN into single Git repository. [moved] >> There was similar effort done in putting CPAN (Comprehensive _Perl_ >> Archive Network) in Git, hosting repositories on GitHub[1], by the name >> of gitPAN, see e.g.: >> >> "The gitPAN Import is Complete" >> http://perlisalive.com/articles/36 >> >> [1]: https://github.com/gitpan [/moved] > There are complex dependencies among LaTeX macro packages, and TeX is > often distributed and installed from a DVD. So it makes sense here to > put *all* the content of a DVD into a repository. Note that for gitPAN each "distribution" (usually but not always corresponding to single Perl module) is in separate repository. The dependencies are handled by CPAN / CPANPLUS / cpanm client (i.e. during install). Putting all DVD (is it "TeX Live" DVD by the way?) into single repository would put quite a bit of stress to git; it was created for software development (although admittedly of large project like Linux kernel), not 4GB+ trees. > Once you've done that, it is then possible and sensible to select > suitable interesting subsets, such as releases of a particular > package. Users could even define their own subsets, such as "all > resources needed to process this file, exactly as it processes on my > machine". This could be handled using submodules, by having superrepository that consist solely of references to other repositories by the way of submodules... plus perhaps some administrativa files (like README for whole CTAN, or search tool, or DVD install, etc.) This could be the used to get for example contents of DVD from 2010. But even though submodules (c.f. Subversion svn:external, Mecurial forest extension, etc.) are in Git for quite a bit of time, it doesn't have best user interface. > In addition, many TeX users have a TeX DVD. If they import it into a > git repository (using for example my script) then the update from 2011 > to 2012 would require much less bandwidth. ??? > Finally, I'd rather be working within git that modified copy of the > ISO when doing the subsetting. I'm pretty sure that I can manage to > pull the small repositories from the big git-CTAN repository. No you cannot. It is all or nothing; there is no support for partial _clone_ (yet), and it looks like it is a hard problem. Nb. there is support for partial _checkout_, but this is something different. > But as I proceed, perhaps I'll change my mind (smile). > >>> I'm working from the TeX Collection DVDs that are published each year >>> by the TeX user groups, which contain a snapshot of CTAN (about >>> 100,000 files occupying 4Gb), which means I have to unzip folders and >>> do a few other things. >> >> There is 'contrib/fast-import/import-zips.py' in git.git repository. >> If you are not using it, or its equivalent, it might be worth checking >> out. > > Well, I didn't know about that. I took a look, and it doesn't do what > I want. I need to walk the tree (on a mounted ISO) and unpack some > (but not all) zip files as I come across them. For details see: > https://bitbucket.org/jfine/python-ctantools/src/tip/ctantools/filetools.py > > In addition, I don't want to make a commit. I just want to make a ref > at the end of building the tree. This is because I want the import of > a TeX DVD to give effectively identical results for all users, and so > any commit information would be effectively constant. Commit = tree + parent + metadata. I think you would very much want to have linear sequence of trees, ordered via DAG of commits. "Naked" trees are rather bad idea, I think. > As I recall the first 'commit' to the git repository for the Linux > kernel was just a tree, with a reference to that tree as a tag. But > no commit. That was a bad accident that there is a tag that points directly to a tree of _initial import_, not something to copy. -- Jakub Nar?bski From jnareb at gmail.com Sun Nov 6 15:29:28 2011 From: jnareb at gmail.com (Jakub Narebski) Date: Sun, 06 Nov 2011 12:29:28 -0800 (PST) Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: <4EB6CFBB.2090901@pytex.org> References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> Message-ID: The following message is a courtesy copy of an article that has been posted to comp.lang.python,comp.text.tex as well. Jonathan Fine writes: > On 06/11/11 16:42, Jakub Narebski wrote: >> Jonathan Fine writes: >> >>> This it to let you know that I'm writing (in Python) a script that >>> places the content of CTAN into a git repository. >>> https://bitbucket.org/jfine/python-ctantools >> >> I hope that you meant "repositories" (plural) here, one per tool, >> rather than putting all of CTAN into single Git repository. [moved] >> There was similar effort done in putting CPAN (Comprehensive _Perl_ >> Archive Network) in Git, hosting repositories on GitHub[1], by the name >> of gitPAN, see e.g.: >> >> "The gitPAN Import is Complete" >> http://perlisalive.com/articles/36 >> >> [1]: https://github.com/gitpan [/moved] > There are complex dependencies among LaTeX macro packages, and TeX is > often distributed and installed from a DVD. So it makes sense here to > put *all* the content of a DVD into a repository. Note that for gitPAN each "distribution" (usually but not always corresponding to single Perl module) is in separate repository. The dependencies are handled by CPAN / CPANPLUS / cpanm client (i.e. during install). Putting all DVD (is it "TeX Live" DVD by the way?) into single repository would put quite a bit of stress to git; it was created for software development (although admittedly of large project like Linux kernel), not 4GB+ trees. > Once you've done that, it is then possible and sensible to select > suitable interesting subsets, such as releases of a particular > package. Users could even define their own subsets, such as "all > resources needed to process this file, exactly as it processes on my > machine". This could be handled using submodules, by having superrepository that consist solely of references to other repositories by the way of submodules... plus perhaps some administrativa files (like README for whole CTAN, or search tool, or DVD install, etc.) This could be the used to get for example contents of DVD from 2010. But even though submodules (c.f. Subversion svn:external, Mecurial forest extension, etc.) are in Git for quite a bit of time, it doesn't have best user interface. > In addition, many TeX users have a TeX DVD. If they import it into a > git repository (using for example my script) then the update from 2011 > to 2012 would require much less bandwidth. ??? > Finally, I'd rather be working within git that modified copy of the > ISO when doing the subsetting. I'm pretty sure that I can manage to > pull the small repositories from the big git-CTAN repository. No you cannot. It is all or nothing; there is no support for partial _clone_ (yet), and it looks like it is a hard problem. Nb. there is support for partial _checkout_, but this is something different. > But as I proceed, perhaps I'll change my mind (smile). > >>> I'm working from the TeX Collection DVDs that are published each year >>> by the TeX user groups, which contain a snapshot of CTAN (about >>> 100,000 files occupying 4Gb), which means I have to unzip folders and >>> do a few other things. >> >> There is 'contrib/fast-import/import-zips.py' in git.git repository. >> If you are not using it, or its equivalent, it might be worth checking >> out. > > Well, I didn't know about that. I took a look, and it doesn't do what > I want. I need to walk the tree (on a mounted ISO) and unpack some > (but not all) zip files as I come across them. For details see: > https://bitbucket.org/jfine/python-ctantools/src/tip/ctantools/filetools.py > > In addition, I don't want to make a commit. I just want to make a ref > at the end of building the tree. This is because I want the import of > a TeX DVD to give effectively identical results for all users, and so > any commit information would be effectively constant. Commit = tree + parent + metadata. I think you would very much want to have linear sequence of trees, ordered via DAG of commits. "Naked" trees are rather bad idea, I think. > As I recall the first 'commit' to the git repository for the Linux > kernel was just a tree, with a reference to that tree as a tag. But > no commit. That was a bad accident that there is a tag that points directly to a tree of _initial import_, not something to copy. -- Jakub Nar?bski From cs at zip.com.au Sun Nov 6 15:34:29 2011 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 7 Nov 2011 07:34:29 +1100 Subject: Python lesson please In-Reply-To: <201111061314.43744.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> Message-ID: <20111106203429.GA4790@cskk.homeip.net> On 06Nov2011 13:14, gene heskett wrote: | Greetings experts: | | I just dl'd the duqu driver finder script from a link to NSS on /., and | fixed enough of the tabs in it to make it run error-free. At least python | isn't having a litter of cows over the indentation now. | | But it also runs instantly on linux. | | This line looks suspect to me: | rootdir = sys.argv[1] | | And I have a suspicion it is null on a linux box. That line collects the first command line argument. sys.argv is the command line; argv[0] is the command name, argv[1] the first argument and so forth. Also, if there is no first argument then trying to access argv[1] will raise an IndexError exception, not return a null value. If you're this new to python, note that easy debugging statements can be written: print >>sys.stderr, "the value of foo is", foo and so forth. Perhaps more relevantly: If you have unmangled a lot of tabs, remember that control flow is indentation based in python, and you may have broken some logic. (For this reason a number of us set our editors to work only in spaces). Anyway, while changing: statement1 statement2 into: statement1 statement2 will usually make python complain, changing: if some test here: statement1 statement2 into: if some test here: statement1 statement2 just means that statement2 is no longer inside the if-statement, and elicit no compaints. But will elicit bugs! Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The ZZR-1100 is not the bike for me, but the day they invent "nerf" roads and ban radars I'll be the first in line......AMCN From gheskett at wdtv.com Sun Nov 6 18:10:03 2011 From: gheskett at wdtv.com (gene heskett) Date: Sun, 6 Nov 2011 18:10:03 -0500 Subject: Python lesson please In-Reply-To: <4EB6EC38.20708@davea.name> References: <201111061314.43744.gheskett@wdtv.com> <4EB6EC38.20708@davea.name> Message-ID: <201111061810.03728.gheskett@wdtv.com> On Sunday, November 06, 2011 06:07:36 PM Dave Angel did opine: > On 11/06/2011 01:14 PM, gene heskett wrote: > > Greetings experts: > > > > I just dl'd the duqu driver finder script from a link to NSS on /., > > and fixed enough of the tabs in it to make it run error-free. At > > least python isn't having a litter of cows over the indentation now. > > > > But it also runs instantly on linux. > > > > This line looks suspect to me: > > rootdir = sys.argv[1] > > > > And I have a suspicion it is null on a linux box. > > > > How can I fix that best? > > > > Thanks. > > > > Cheers, Gene > > Nothing wrong with that line, assuming the user of the script happened > to provide an argument for rootpath. Probably it should be preceded by > a a conditional: > > if len(argv) <2: > tell.user.that.she's.missing.the.rootdir.parameter > else: > rootdir = sys.argv[1] > etc. > > What does the help text show when you run the script with the --help > argument? It has no --help: [root at coyote gene]# ./duqu-drivers-detect.py --help [root at coyote gene]# Sorry. Thanks & Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Expedience is the best teacher. From devplayer at gmail.com Sun Nov 6 18:23:02 2011 From: devplayer at gmail.com (DevPlayer) Date: Sun, 6 Nov 2011 15:23:02 -0800 (PST) Subject: Usefulness of the "not in" operator References: <4e902932$0$23273$426a34cc@news.free.fr> <87ehyn8xlp.fsf@dpt-info.u-strasbg.fr> <4acd4e59-cf83-47f5-ac6c-ee0cbec8aa34@u13g2000vbx.googlegroups.com> <4e9a6614$0$29971$c3e8da3$5496439d@news.astraweb.com> Message-ID: <35178454-e3e3-4268-8841-8709c93a4719@g7g2000vbv.googlegroups.com> On Oct 16, 12:05?am, Steven D'Aprano wrote: > On Sat, 15 Oct 2011 15:04:24 -0700, DevPlayer wrote: > > I thought "x not in y" was later added as syntax sugar for "not x in y" > > meaning they used the same set of tokens. (Too lazy to check the actual > > tokens) Stated in response to OP wanting a seperate token for "not in" verse "is not". > Whether the compiler has a special token for "not in" is irrelevant. I don't know. > Perhaps it uses one token, or two, or none at all because a > pre-processor changes "x not in y" to "not x in y". That's > an implementation detail. I agree. > What's important is whether it is valid syntax or not, and how it is > implemented. I agree. > As it turns out, the Python compiler does not distinguish the two forms: > > >>> from dis import dis > >>> dis(compile('x not in y', '', 'single')) > > ? 1 ? ? ? ? ? 0 LOAD_NAME ? ? ? ? ? ? ? ?0 (x) > ? ? ? ? ? ? ? 3 LOAD_NAME ? ? ? ? ? ? ? ?1 (y) > ? ? ? ? ? ? ? 6 COMPARE_OP ? ? ? ? ? ? ? 7 (not in) > ? ? ? ? ? ? ? 9 PRINT_EXPR > ? ? ? ? ? ? ?10 LOAD_CONST ? ? ? ? ? ? ? 0 (None) > ? ? ? ? ? ? ?13 RETURN_VALUE ? ? ? ?>>> dis(compile('not x in y', '', 'single')) > > ? 1 ? ? ? ? ? 0 LOAD_NAME ? ? ? ? ? ? ? ?0 (x) > ? ? ? ? ? ? ? 3 LOAD_NAME ? ? ? ? ? ? ? ?1 (y) > ? ? ? ? ? ? ? 6 COMPARE_OP ? ? ? ? ? ? ? 7 (not in) > ? ? ? ? ? ? ? 9 PRINT_EXPR > ? ? ? ? ? ? ?10 LOAD_CONST ? ? ? ? ? ? ? 0 (None) > ? ? ? ? ? ? ?13 RETURN_VALUE So cool! Thanks for showing how to do that. I tried to say implementing a seperate method was not efficient. > Also for what it is worth, "x not in y" goes back to at least Python 1.5, > and possibly even older. (I don't have any older versions available to > test.) So "not in" was added as an alternative (just a long time ago). I too am glad they added it. > (2) Instead of writing "True if blah else False", write "bool(blah)". Good tip! I like. > > > class Y(object): > > ? ? def __contains__(self, x): > > ? ? ? ? for item in y: > > ? ? ? ? if x == y: > > ? ? ? ? ? ? return True > > ? ? ? ? return False > > You don't have to define a __contains__ method if you just want to test > each item sequentially. All you need is to obey the sequence protocol and > define a __getitem__ that works in the conventional way: Didn't intend to show how to implement __contains__ using "==" and __not_contains__ "<>" in python but to show that python didn't benefit from the not_in loop as much as for example assembly language does it's loop (x86 LOOPE/LOOPZ vs LOOPNZ/LOOPNE). > > >>> class Test: > > ... ? ? def __init__(self, args): > ... ? ? ? ? ? ? self._data = list(args) > ... ? ? def __getitem__(self, i): > ... ? ? ? ? ? ? return self._data[i] > ...>>> t = Test("abcde") > >>> "c" in t > True > >>> "x" in t > False Another new thing for me. > > Defining a specialist __contains__ method is only necessary for non- > sequences, or if you have some fast method for testing whether an item is > in the object quickly. If all you do is test each element one at a time, > in numeric order, don't bother writing __contains__. > > > And if you wanted "x not in y" to be a different token you'd have to ADD > > Tokens are irrelevant. "x not in y" is defined to be the same as "not x > in y" no matter what. > You can't define "not in" to do something completely different. I agree they are not implemented differently. I agree that they shouldn't be implemented differently. I disagree they can not be implemented differently. I think they can. But I see no reason too. > > class Y(object): > > ? ? def __not_contained__(self, x): > > ? ? ? ? for item in self: > > ? ? ? ? ? ? if x == y: > > ? ? ? ? ? ? ? ? return False > > ? ? ? ? return True > > > AND with __not_contained__() you'd always have to iterate the entire > > sequence to make sure even the last item doesn't match. > > SO with one token "x not in y" you DON'T have to itterate through the > > entire sequence thus it is more effiecient. > That's not correct. > Steven I tried to prove my point and failded and instead proved (to myself) you are correct. It is not more efficient. Also I should have used if <> y: continue to have better tried to make the point but it wouldn't have mattered. I still would have been wrong. But I did walk away from this topic with some goodie tips. Thanks Steven. From d at davea.name Sun Nov 6 18:27:23 2011 From: d at davea.name (Dave Angel) Date: Sun, 06 Nov 2011 18:27:23 -0500 Subject: Python lesson please In-Reply-To: <201111061810.03728.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <4EB6EC38.20708@davea.name> <201111061810.03728.gheskett@wdtv.com> Message-ID: <4EB717DB.2000303@davea.name> On 11/06/2011 06:10 PM, gene heskett wrote: > On Sunday, November 06, 2011 06:07:36 PM Dave Angel did opine: > >> On 11/06/2011 01:14 PM, gene heskett wrote: >>> Greetings experts: >>> >>> I just dl'd the duqu driver finder script from a link to NSS on /., >>> and fixed enough of the tabs in it to make it run error-free. At >>> least python isn't having a litter of cows over the indentation now. >>> >>> But it also runs instantly on linux. >>> >>> This line looks suspect to me: >>> rootdir = sys.argv[1] >>> >>> And I have a suspicion it is null on a linux box. >>> >>> How can I fix that best? >>> >>> Thanks. >>> >>> Cheers, Gene >> >> Nothing wrong with that line, assuming the user of the script happened >> to provide an argument for rootpath. Probably it should be preceded by >> a a conditional: >> >> if len(argv)<2: >> tell.user.that.she's.missing.the.rootdir.parameter >> else: >> rootdir = sys.argv[1] >> etc. >> >> What does the help text show when you run the script with the --help >> argument? > > It has no --help: > [root at coyote gene]# ./duqu-drivers-detect.py --help > [root at coyote gene]# > > Sorry. > > Thanks& Cheers, Gene So is there any documentation? If not, your first job is to guess what it's supposed to do, figure out if you care, and then document it. In the process you'll probably find a few bugs. First bug is it silently quits when you run it with no arguments. Is that true? If so, figure out where it quits, since it clearly never reaches the line you quote. Actually I'd probably start with the assumption that you might have messed up the tab expansion somewhere. How did you expand the tabs? Perhaps by using the Linux expands utility? Or did you do it manually? -- DaveA From fraveydank at gmail.com Sun Nov 6 18:54:46 2011 From: fraveydank at gmail.com (David Riley) Date: Sun, 6 Nov 2011 18:54:46 -0500 Subject: Python lesson please In-Reply-To: <20111106203429.GA4790@cskk.homeip.net> References: <201111061314.43744.gheskett@wdtv.com> <20111106203429.GA4790@cskk.homeip.net> Message-ID: <2FF5E7E0-B119-4906-91A7-93A095E8D620@gmail.com> On Nov 6, 2011, at 3:34 PM, Cameron Simpson wrote: > Perhaps more relevantly: > > If you have unmangled a lot of tabs, remember that control flow is > indentation based in python, and you may have broken some logic. > (For this reason a number of us set our editors to work only in spaces). I would absolutely check this first. I can't count the number of programs I've screwed up in difficult-to-detect ways because I've converted from tabs to spaces incorrectly. It's how I've finally learned to let a program/script do it for me, because Python is the first language I've used with significant leading whitespace. - Dave From jiayuaw at yahoo.com.sg Sun Nov 6 20:26:43 2011 From: jiayuaw at yahoo.com.sg (Kristen Aw) Date: Mon, 7 Nov 2011 09:26:43 +0800 (SGT) Subject: question about Tkinter delete Message-ID: <1320629203.53499.YahooMailNeo@web77904.mail.sg1.yahoo.com> Hi all I don't understand why I get this error. I'm trying to delete the existing points, then redraw them after this bit of code to 'animate' my simulation. def update(self, point1, point2): ? ? ? ? # Deletes existing points ? ? ? ? if self.point1: ? ? ? ? ? ? self.w.delete(point1) ? ? ? ? ? ? self.master.update_idletasks() ? ? ? ? if self.point2: ? ? ? ? ? ? self.w.delete(point2) ? ? ? ? ? ? self.master.update_idletasks() #draw new point # . . . The error message that I get is: . . .?in update ? ? self.w.delete(point1) ? File "C:\PYTHON26\LIB\LIB-TK\Tkinter.py", line 2181, in delete ? ? self.tk.call((self._w, 'delete') + args) TclError: invalid command name ".44593760" -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Sun Nov 6 21:54:16 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Nov 2011 02:54:16 GMT Subject: Python lesson please References: Message-ID: <4eb74858$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sun, 06 Nov 2011 13:14:43 -0500, gene heskett wrote: > I just dl'd the duqu driver finder script from a link to NSS on /., and > fixed enough of the tabs in it to make it run error-free. At least > python isn't having a litter of cows over the indentation now. Presumably the script should be working. If it is known to be not working, then you probably need to fix a lot more than just indentation. If this is "pre-alpha, doesn't even compile" software, then good luck, you'll need to read the source and understand it to make it work. It's not sufficient to just get it to a point where you can say "Cool, it compiles!" by fixing some indentation. If this is supposed to be working, there's a reason why it's not working for you. Perhaps you are trying to use it with the wrong version of Python. Perhaps the download is corrupted. Fix those before mangling indentation in random ways: start with a fresh, uncorrupted download. Check that the md5 sum matches that provided by the download site (assuming they provide one). Find out what version of Python is supported, and use that. > This line looks suspect to me: > rootdir = sys.argv[1] What makes you think that line is suspect? It looks fine to me. > And I have a suspicion it is null on a linux box. This is Python, not bash. Sys arguments are not filled in with "null", whatever you think "null" is. (The None built-in? The empty string?) Have you tried giving the script an argument when you call it? If in doubt, call it with "." (the current directory) as argument. My wild guess is that you actually need to supply a meaningful directory path before the script will do anything, and until then, it will silently fail. Which is terrible design. > How can I fix that best? If it's not broken, it doesn't need to be fixed. Don't make assumptions about what code needs to be fixed based on nothing more than gut feeling. -- Steven From kwa at kuwata-lab.com Sun Nov 6 23:12:58 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Mon, 7 Nov 2011 13:12:58 +0900 Subject: [ANN] Oktest.py 0.10.0 released - a new-style testing library Message-ID: Hi, I released Oktest.py 0.10.0. http://packages.python.org/Oktest/ http://www.kuwata-lab.com/oktest/ Oktest.py is a new-style testing library for Python. :: from oktest import ok, NG ok (x) > 0 # same as assertTrue(x > 0) ok (s) == 'foo' # same as assertEqual(s, 'foo') ok (s) != 'foo' # same as assertNotEqual(s, 'foo') ok (f).raises(ValueError) # same as assertRaises(ValueError, f) ok (u'foo').is_a(unicode) # same as assertTrue(isinstance(u'foo', unicode)) NG (u'foo').is_a(int) # same as assertTrue(not isinstance(u'foo', int)) ok ('A.txt').is_file() # same as assertTrue(os.path.isfile('A.txt')) NG ('A.txt').is_dir() # same as assertTrue(not os.path.isdir('A.txt')) See http://www.kuwata-lab.com/oktest/oktest-py_users-guide.html for details. Changes and Enhancements ------------------------ * [change] 'oktest.spec()' is obsoleted completely. It will print warning message if you use it. * [change] 'oktest.helper' module is renamed to 'oktest.util'. ('oktest.helper' is still available for backward compabibility.) * [enhance] Add 'oktest.main()' which is a replacement of 'oktest.run()'. Using 'oktest.main()' instead of 'oktest.run()', command options are available. ex:: ## for example: $ python test/foobar_test.py -sp -f test='*keyword*' ## is almost same as: $ python -m oktest test/foobar_test.py -sp -f test='*keyword*' * [enhance] Add 'oktest.fail(message)' which is same as 'unittest.fail(message)'. ex:: from oktest import fail fail("not impelmented yet") # will raise AssertionError * [enhance] (Experimental) Add '@todo' decorator which is equivarent to '@unittest.expectedFailure'. ex:: from oktest import ok, test, todo def add(x, y): return 0 # not implemented yet! class AddTest(unittest.TestCase): @test("returns sum of arguments.") @todo # equivarent to @unittest.expectedFailure def _(self): ok (10, 20) == 30 ## will be failed expectedly ## (because not implemented yet) Expected failure of assertion is reported as '[TODO]', not '[Failed]'. * [enhance] (Experimental) Test context supported. It helps you to describe specification in structured style. ex:: from oktest import ok, test from oktest.context import subject, situation class SampleTestCase(unittest.TestCase): SUBJECT = "class 'Sample'" with subject("method1()"): with situation("when condition:"): @test("spec1") def _(self): ... @test("spec2") def _(self): ... with situation("else:"): @test("spec3") def _(self): ... Output exmple:: $ python test/example_test.py * class 'Sample' + method1() + when condition: - [ok] spec1 - [ok] spec2 + else: - [ok] spec3 ## total:3, passed:3, failed:0, error:0, skipped:0 (elapsed 0.000) -- regards, makoto kuwata From nagle at animats.com Mon Nov 7 01:04:43 2011 From: nagle at animats.com (John Nagle) Date: Sun, 06 Nov 2011 22:04:43 -0800 Subject: Question about 'iterable cursors' In-Reply-To: References: <87pqh54nmh.fsf@dpt-info.u-strasbg.fr> Message-ID: <4eb77503$0$1692$742ec2ed@news.sonic.net> On 11/6/2011 12:04 PM, Dennis Lee Bieber wrote: > On Sun, 6 Nov 2011 11:39:56 +0200, "Frank Millman" > declaimed the following in gmane.comp.python.general: > >> >> So my analysis of the problem is correct, but my solution is wrong. >> >> Instead of executing fetchall() and returning the connection, I should >> retain the connection until I have exhausted the cursor. >> >> That makes a lot of sense. >> > Especially if all you are processing are read-only activities. > > If you have a connection/cursor doing write operations, you may not > be able to commit those writes until all reading cursors have closed. > (Read the documentation on the SQLite3 locking system -- though the > newest version has added a second type of locking which may complicate > the matter. The original/normal scheme has potential readers "outside" > SQLite3, active readers "inside" SQLite3 -- when an active reader cursor > advances to a pending write, it blocks all the potential readers from > entering, but is itself blocked until all other active readers have > exited) Right. The scarce resource is database locks, not connections. Especially with SQLite, which has, by necessity, a rather brutal locking strategy. Realize that SQLite is not a high-performance multi-user database. You use SQLite to store your browser preferences, not your customer database. If you're doing enough transactions from multiple processes that performance is an issue, you need to move up to MySQL or Postgres. If almost all transactions are SELECTs, performance may not be too bad, but if there are INSERT and UPDATE transactions on the same table, performance will be awful. John Nagle From mcepl at redhat.com Mon Nov 7 01:50:36 2011 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 07 Nov 2011 07:50:36 +0100 Subject: How to undo a Python setuptools --prefix path blunder In-Reply-To: <543f5b85-1248-4039-a12d-5bbcb2fb0f51@o19g2000vbk.googlegroups.com> References: <543f5b85-1248-4039-a12d-5bbcb2fb0f51@o19g2000vbk.googlegroups.com> Message-ID: Dne 6.11.2011 14:18, Kev napsal(a): > Again the wrong path is being used to create the symbolic link to > where virtualenv is installed: http://packages.python.org/distribute/easy_install.html#administrator-installation for list of additional configuration files which might go wrong (namely *.pth and distutils.cfg). Is that it? Mat?j From stefan_ml at behnel.de Mon Nov 7 02:22:37 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Nov 2011 08:22:37 +0100 Subject: RSS feed creation? In-Reply-To: References: Message-ID: Dan Stromberg, 06.11.2011 21:00: > Is there an opensource Python tool for creating RSS feeds, that doesn't > require large dependencies? > > I found feedformatter.py on pypi, but it seems a little old, and its sole > automated test gives a traceback. > > Is there a better starting point? > > (I'd of course prefer something that'll run on 3.x and 2.x, but will settle > for either) I'd just go with ElementTree and builder.py. http://effbot.org/zone/element-builder.htm http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py Building an RSS-API on top of that is so trivial that it's not worth any further dependencies anyway. Not sure if this version of builder.py runs in Py3, but it certainly won't be hard to fix even if it doesn't currently. Stefan From stefan_ml at behnel.de Mon Nov 7 03:24:59 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Nov 2011 09:24:59 +0100 Subject: RSS feed creation? In-Reply-To: References: Message-ID: Stefan Behnel, 07.11.2011 08:22: > Dan Stromberg, 06.11.2011 21:00: >> Is there an opensource Python tool for creating RSS feeds, that doesn't >> require large dependencies? >> >> I found feedformatter.py on pypi, but it seems a little old, and its sole >> automated test gives a traceback. >> >> Is there a better starting point? >> >> (I'd of course prefer something that'll run on 3.x and 2.x, but will settle >> for either) > > I'd just go with ElementTree and builder.py. > > http://effbot.org/zone/element-builder.htm > > http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py Hmm, interesting, that last link doesn't seem to work for me anymore. Here's a copy, however: http://svn.effbot.org/public/stuff/sandbox/elementlib/builder.py There's also an extended version for lxml.etree: https://raw.github.com/lxml/lxml/master/src/lxml/builder.py You'll quickly see if it works as expected with plain ET when you use it. It should in general. > Building an RSS-API on top of that is so trivial that it's not worth any > further dependencies anyway. Not sure if this version of builder.py runs in > Py3, but it certainly won't be hard to fix even if it doesn't currently. Stefan From __peter__ at web.de Mon Nov 7 04:00:02 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 10:00:02 +0100 Subject: Python lesson please References: <201111061314.43744.gheskett@wdtv.com> Message-ID: gene heskett wrote: > Greetings experts: > > I just dl'd the duqu driver finder script from a link to NSS on /., and > fixed enough of the tabs in it to make it run error-free. At least python > isn't having a litter of cows over the indentation now. > > But it also runs instantly on linux. > > This line looks suspect to me: > rootdir = sys.argv[1] > > And I have a suspicion it is null on a linux box. > > How can I fix that best? Are you talking about this one? https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns.py With a current checkout I don't get any tab-related (nor other) errors, so I would prefer to run the script as-is. Also, the README clearly states that you have to invoke it with python DuquDriverPatterns.py ./directoryOfMalware and the line you are quoting then puts the value "./directoryOfMalware" into the rootdir variable. If you want to normalize the code to 4-space indents I recomment that you use http://hg.python.org/cpython/file/bbc929bc2224/Tools/scripts/reindent.py On Ubuntu (and probably any other Debian-based distro) you'll find a version of that in /usr/share/doc/python2.6/examples/Tools/scripts/reindent.py or similar once you've installed the python-examples package. From __peter__ at web.de Mon Nov 7 04:22:28 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 10:22:28 +0100 Subject: question about Tkinter delete References: <1320629203.53499.YahooMailNeo@web77904.mail.sg1.yahoo.com> Message-ID: Kristen Aw wrote: > I don't understand why I get this error. I'm trying to delete the existing points, then redraw them after this bit of code to 'animate' my simulation. > > def update(self, point1, point2): > # Deletes existing points > if self.point1: > self.w.delete(point1) > self.master.update_idletasks() > if self.point2: > self.w.delete(point2) > self.master.update_idletasks() > #draw new point > # . . . > > The error message that I get is: > . . . in update > self.w.delete(point1) > File "C:\PYTHON26\LIB\LIB-TK\Tkinter.py", line 2181, in delete > self.tk.call((self._w, 'delete') + args) > TclError: invalid command name ".44593760" Your snippet and your problem description are both a bit short to be sure. Is self.w a Tkinter.Canvas widget? It seems the canvas doesn't exist anymore when you're trying to delete objects on it. Here's a demonstration: >>> import Tkinter as tk >>> root = tk.Tk() >>> canvas = tk.Canvas(root, height=100, width=100) >>> canvas.delete("123") >>> canvas.destroy() >>> canvas.delete("123") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 2184, in delete self.tk.call((self._w, 'delete') + args) _tkinter.TclError: invalid command name ".139675427025264" From gheskett at wdtv.com Mon Nov 7 06:22:39 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 06:22:39 -0500 Subject: Python lesson please In-Reply-To: References: <201111061314.43744.gheskett@wdtv.com> Message-ID: <201111070622.39473.gheskett@wdtv.com> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > gene heskett wrote: > > Greetings experts: > > > > I just dl'd the duqu driver finder script from a link to NSS on /., > > and fixed enough of the tabs in it to make it run error-free. At > > least python isn't having a litter of cows over the indentation now. > > > > But it also runs instantly on linux. > > > > This line looks suspect to me: > > rootdir = sys.argv[1] > > > > And I have a suspicion it is null on a linux box. > > > > How can I fix that best? > > Are you talking about this one? > > https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns > .py Yes. My save as renamed it, still has about 30k of tabs in it. But I pulled it again, using the 'raw' link, saved it, no extra tabs. But it still doesn't work for linux. My python is 2.6.6 > With a current checkout I don't get any tab-related (nor other) errors, > so I would prefer to run the script as-is. Also, the README clearly > states that you have to invoke it with > > python DuquDriverPatterns.py ./directoryOfMalware > > and the line you are quoting then puts the value "./directoryOfMalware" > into the rootdir variable. If only it would... Using this version, the failure is silent and instant. Besides, the malware could be anyplace on the system. But it needs to skip /dev since it hangs on the midi tree, /mnt and /media because they are not part of the running system even if disks are mounted there. > If you want to normalize the code to 4-space indents I recomment that > you use > > http://hg.python.org/cpython/file/bbc929bc2224/Tools/scripts/reindent.py Got it, where does it normally live? I apparently have a python-2.6.6 install. > On Ubuntu (and probably any other Debian-based distro) you'll find a > version of that in > PCLos is rpm based, lots of mandriva stuff in it. > /usr/share/doc/python2.6/examples/Tools/scripts/reindent.py > Path does not exist. Ends at /usr/share/doc from there I have: gene at coyote doc]$ ls|grep python gimp-python-2.6.11/ gnome-python-gconf-2.28.1/ gnome-python-gnomeprint-2.32.0/ gnome-python-gtksourceview-2.32.0/ libxml2-python-2.7.8/ python-2.6.6/ python3-3.2.1/ python3-docs-3.2.1/ python-cairo-1.10.0/ python-configobj-4.7.2/ python-decorator-3.3.1/ python-docs-2.6.6/ python-enchant-1.5.3/ python-gobject-2.28.6/ python-gpgme-0.1/ python-gtksourceview-2.10.0/ python-libxml2dom-0.4.7/ python-lxml-2.2.8/ python-markupsafe-0.9.3/ python-notify-0.1.1/ python-paramiko-1.7.6/ python-paste-1.7.4/ python-pkg-resources-0.6c11/ python-psyco-1.6/ python-pybluez-0.18/ python-pycrypto-2.3/ python-pygments-1.3.1/ python-pytools-2011.3/ python-pyxml-0.8.4/ python-rhpl-0.212/ python-sexy-0.1.9/ python-simpletal-4.2/ python-sympy-0.6.7/ python-utmp-0.8/ The python-2.6.6 and 3.2.1 directories only contain a README.mdv > or similar once you've installed the python-examples package. On PCLos it doesn't even exist in the repo's. Good links, thank you. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: "Elvis is my copilot." -- Cal Keegan From gabor.farkas at gmail.com Mon Nov 7 07:53:05 2011 From: gabor.farkas at gmail.com (=?ISO-8859-1?Q?G=E1bor_Farkas?=) Date: Mon, 7 Nov 2011 13:53:05 +0100 Subject: logging: handle everything EXCEPT certain loggers Message-ID: hi, is there a way to setup log-handlers in a way that they log logs from every logger, exept certain ones? basically i want the handler to handle everything, except log-records that were generated by loggers from "something.*" can this be done? i tried to create filters, but the log-record does not have access to his logger, so i cannot filter based on it's "path". right now the only idea i have is to setup a filter for the "something.*" path, have it mark somehow the log-records, and then create a filter on the global level, that will drop such log-records. is there a simpler solution? thanks, gabor From andreas.perstinger at gmx.net Mon Nov 7 08:14:05 2011 From: andreas.perstinger at gmx.net (Andreas Perstinger) Date: Mon, 07 Nov 2011 14:14:05 +0100 Subject: Python lesson please In-Reply-To: <201111070622.39473.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> Message-ID: <4EB7D99D.5010604@gmx.net> On 2011-11-07 12:22, gene heskett wrote: > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: >> Are you talking about this one? >> >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns >> .py > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > pulled it again, using the 'raw' link, saved it, no extra tabs. > > But it still doesn't work for linux. My python is 2.6.6 Go to the directory where you've downloaded the file and type: python DuquDriverPatterns.py . What output do you get? Bye, Andreas From d at davea.name Mon Nov 7 08:30:15 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 08:30:15 -0500 Subject: Python lesson please In-Reply-To: <201111070622.39473.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> Message-ID: <4EB7DD67.5070606@davea.name> On 11/07/2011 06:22 AM, gene heskett wrote: > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > >> Are you talking about this one? >> >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns >> .py > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > pulled it again, using the 'raw' link, saved it, no extra tabs. > > But it still doesn't work for linux. My python is 2.6.6 > To start with, what's the md5 of the file you downloaded and are testing? I get c4592a187f8f7880d3b685537e3bf9a5 from md5sum. If you get something different, one of us changed the file, or you got it before today. The whole tab issue is a red-herring in this case. But I don't see how you can find 30k tabs in a thousand lines. And if I were going to detab it, I'd pick 4 spaces, so the code doesn't stretch across the page. > >> python DuquDriverPatterns.py ./directoryOfMalware >> >> and the line you are quoting then puts the value "./directoryOfMalware" >> into the rootdir variable. > If only it would... Using this version, the failure is silent and instant. > Besides, the malware could be anyplace on the system. But it needs to skip > /dev since it hangs on the midi tree, /mnt and /media because they are not > part of the running system even if disks are mounted there. > First, run it on the current directory, and it should list the files in that directory: I ran it in the directory I unzipped it into, so there are two files, the README and the source file itself. $ python DuquDriverPatterns.py . Scanning ./README: No match for pattern #0 on file named: README No match for pattern #1 on file named: README No match for pattern #2 on file named: README etc. The only way I can see to get NO output is to run it on an empty directory: $mkdir junk $ python DuquDriverPatterns.py junk As for skipping certain directories, we can deal with that as soon as you get proper behavior for any subtree of directories. Have you tried adding a print ("Hello World " + rootdir) just before the for root, subFolders, files in os.walk(rootdir): line ? Or putting a print len(files) just after it (indented, of course) ? -- DaveA From jeanmichel at sequans.com Mon Nov 7 08:39:17 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 07 Nov 2011 14:39:17 +0100 Subject: logging: handle everything EXCEPT certain loggers In-Reply-To: References: Message-ID: <4EB7DF85.7060909@sequans.com> G?bor Farkas wrote: > hi, > > is there a way to setup log-handlers in a way that they log logs from > every logger, exept certain ones? > > basically i want the handler to handle everything, except log-records > that were generated by loggers from "something.*" > can this be done? > > i tried to create filters, but the log-record does not have access to > his logger, so i cannot filter based on it's "path". > > right now the only idea i have is to setup a filter for the > "something.*" path, have it mark somehow the log-records, > and then create a filter on the global level, that will drop such > log-records. is there a simpler solution? > > thanks, > gabor > Are you sure ? LogRecord objects have a name attribute. You could do something like return 'IdontWantYou' not in record.name in your filter. JM From huhai101 at gmail.com Mon Nov 7 09:02:57 2011 From: huhai101 at gmail.com (wholesale nfl) Date: Mon, 7 Nov 2011 06:02:57 -0800 (PST) Subject: (www.nike-black.com) cheap wholesale nfl jerseys, mlb jerseys , nhl jerseys, nba jerseys Message-ID: <36edf286-d093-4ed4-9d96-15e8ad8a43ff@i13g2000prg.googlegroups.com> (www.nike-black.com) cheap wholesale nfl jerseys, mlb jerseys , nhl jerseys, nba jerseys NFL Football Jerseys 2011 Super Bowl NFL Hats NCAA Jerseys Customized NFL Jerseys Hot NFL Jerseys (www.nike-black.com) Women NFL Jerseys Youth NFL Jerseys Super Bowl Jerseys Pro Bowl Jerseys New NFL Jerseys Arizona Cardinals (www.nike-black.com) Atlanta Falcons Baltimore Ravens Buffalo Bills Carolina Panthers Chicago Bears Cincinnati Bengals Cleveland Browns (www.nike-black.com) Dallas Cowboys Denver Broncos Detroit Lions Green Bay Packers Houston Texans Indianapolis Colts (www.nike-black.com) Jacksonville Jaguars Kansas City Chiefs Miami Dolphins Minnesota Vikings New England Patriots New Orleans Saints New York Giants New York Jets Oakland Raiders Philadelphia Eagles (www.nike-black.com) Pittsburgh Steelers San Diego Chargers San Francisco 49ers Seattle Seahawks (www.nike-black.com) St.Louis Rams Tampa Bay Buccaneers Tennessee Titans Washington Redskins website: http://www.nike-black.com From huhai101 at gmail.com Mon Nov 7 09:02:57 2011 From: huhai101 at gmail.com (wholesale nfl) Date: Mon, 7 Nov 2011 06:02:57 -0800 (PST) Subject: (www.nike-black.com) cheap wholesale nfl jerseys, mlb jerseys , nhl jerseys, nba jerseys Message-ID: <3e9c772e-7e74-423b-9a24-9fc81b54fefc@i13g2000prg.googlegroups.com> (www.nike-black.com) cheap wholesale nfl jerseys, mlb jerseys , nhl jerseys, nba jerseys NFL Football Jerseys 2011 Super Bowl NFL Hats NCAA Jerseys Customized NFL Jerseys Hot NFL Jerseys (www.nike-black.com) Women NFL Jerseys Youth NFL Jerseys Super Bowl Jerseys Pro Bowl Jerseys New NFL Jerseys Arizona Cardinals (www.nike-black.com) Atlanta Falcons Baltimore Ravens Buffalo Bills Carolina Panthers Chicago Bears Cincinnati Bengals Cleveland Browns (www.nike-black.com) Dallas Cowboys Denver Broncos Detroit Lions Green Bay Packers Houston Texans Indianapolis Colts (www.nike-black.com) Jacksonville Jaguars Kansas City Chiefs Miami Dolphins Minnesota Vikings New England Patriots New Orleans Saints New York Giants New York Jets Oakland Raiders Philadelphia Eagles (www.nike-black.com) Pittsburgh Steelers San Diego Chargers San Francisco 49ers Seattle Seahawks (www.nike-black.com) St.Louis Rams Tampa Bay Buccaneers Tennessee Titans Washington Redskins website: http://www.nike-black.com From __peter__ at web.de Mon Nov 7 09:15:53 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 15:15:53 +0100 Subject: Python lesson please References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> Message-ID: gene heskett wrote: > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > >> gene heskett wrote: >> > Greetings experts: >> > >> > I just dl'd the duqu driver finder script from a link to NSS on /., >> > and fixed enough of the tabs in it to make it run error-free. At >> > least python isn't having a litter of cows over the indentation now. >> > >> > But it also runs instantly on linux. >> > >> > This line looks suspect to me: >> > rootdir = sys.argv[1] >> > >> > And I have a suspicion it is null on a linux box. >> > >> > How can I fix that best? >> >> Are you talking about this one? >> >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns >> .py > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > pulled it again, using the 'raw' link, saved it, no extra tabs. > > But it still doesn't work for linux. My python is 2.6.6 Maybe the browser messes up things. Try installing git and then make a clone: $ git clone git://github.com/halsten/Duqu-detectors >> With a current checkout I don't get any tab-related (nor other) errors, >> so I would prefer to run the script as-is. Also, the README clearly >> states that you have to invoke it with >> >> python DuquDriverPatterns.py ./directoryOfMalware >> >> and the line you are quoting then puts the value "./directoryOfMalware" >> into the rootdir variable. > > If only it would... Using this version, the failure is silent and > instant. The actual code which comprises only the last 30 lines of the script looks like it is written by a newbie. Try replacing the bare except: with something noisy along the lines of except Exception as e: print e continue > Besides, the malware could be anyplace on the system. But it needs to > skip /dev since it hangs on the midi tree, /mnt and /media because they > are not part of the running system even if disks are mounted there. I don't think the script is meant to find malware on a running system. Rather you would mount a suspicious harddisk and pass the mountpoint to the script. Of course I'm only guessing... >> or similar once you've installed the python-examples package. > > On PCLos it doesn't even exist in the repo's. Maybe it's in python's srpm, or in a python-dev.rpm or similar. If all else fails you can download the source distribution from python.org at http://www.python.org/download/releases/2.6.7/ From gabor.farkas at gmail.com Mon Nov 7 09:18:35 2011 From: gabor.farkas at gmail.com (=?ISO-8859-1?Q?G=E1bor_Farkas?=) Date: Mon, 7 Nov 2011 15:18:35 +0100 Subject: logging: handle everything EXCEPT certain loggers In-Reply-To: <4EB7DF85.7060909@sequans.com> References: <4EB7DF85.7060909@sequans.com> Message-ID: 2011/11/7 Jean-Michel Pichavant : > G?bor Farkas wrote: >> >> is there a way to setup log-handlers in a way that they log logs from >> every logger, exept certain ones? >> >> i tried to create filters, but the log-record does not have access to >> his logger, so i cannot filter based on it's "path". > > Are you sure ? > LogRecord objects have a name attribute. You could do something like > > return 'IdontWantYou' not in record.name > > in your filter. d'oh .. thanks, i somehow overlooked the name attribute. it's exactly what i need. thanks, gabor From jaroslav.dobrek at gmail.com Mon Nov 7 09:23:12 2011 From: jaroslav.dobrek at gmail.com (Jaroslav Dobrek) Date: Mon, 7 Nov 2011 06:23:12 -0800 (PST) Subject: read from file with mixed encodings in Python3 Message-ID: <406195f9-d51f-416a-b32c-e9ab07e219c7@n13g2000vbv.googlegroups.com> Hello, in Python3, I often have this problem: I want to do something with every line of a file. Like Python3, I presuppose that every line is encoded in utf-8. If this isn't the case, I would like Python3 to do something specific (like skipping the line, writing the line to standard error, ...) Like so: try: .... except UnicodeDecodeError: ... Yet, there is no place for this construction. If I simply do: for line in f: print(line) this will result in a UnicodeDecodeError if some line is not utf-8, but I can't tell Python3 to stop: This will not work: for line in f: try: print(line) except UnicodeDecodeError: ... because the UnicodeDecodeError is caused in the "for line in f"-part. How can I catch such exceptions? Note that recoding the file before opening it is not an option, because often files contain many different strings in many different encodings. Jaroslav From d at davea.name Mon Nov 7 09:33:33 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 09:33:33 -0500 Subject: read from file with mixed encodings in Python3 In-Reply-To: <406195f9-d51f-416a-b32c-e9ab07e219c7@n13g2000vbv.googlegroups.com> References: <406195f9-d51f-416a-b32c-e9ab07e219c7@n13g2000vbv.googlegroups.com> Message-ID: <4EB7EC3D.4070809@davea.name> On 11/07/2011 09:23 AM, Jaroslav Dobrek wrote: > Hello, > > in Python3, I often have this problem: I want to do something with > every line of a file. Like Python3, I presuppose that every line is > encoded in utf-8. If this isn't the case, I would like Python3 to do > something specific (like skipping the line, writing the line to > standard error, ...) > > Like so: > > try: > .... > except UnicodeDecodeError: > ... > > Yet, there is no place for this construction. If I simply do: > > for line in f: > print(line) > > this will result in a UnicodeDecodeError if some line is not utf-8, > but I can't tell Python3 to stop: > > This will not work: > > for line in f: > try: > print(line) > except UnicodeDecodeError: > ... > > because the UnicodeDecodeError is caused in the "for line in f"-part. > > How can I catch such exceptions? > > Note that recoding the file before opening it is not an option, > because often files contain many different strings in many different > encodings. > > Jaroslav A file with mixed encodings isn't a text file. So open it with 'rb' mode, and use read() on it. Find your own line-endings, since a given '\n' byte may or may not be a line-ending. Once you've got something that looks like a line, explicitly decode it using utf-8. Some invalid lines will give an exception and some will not. But perhaps you've got some other gimmick to tell the encoding for each line. -- DaveA From __peter__ at web.de Mon Nov 7 09:42:47 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 15:42:47 +0100 Subject: read from file with mixed encodings in Python3 References: <406195f9-d51f-416a-b32c-e9ab07e219c7@n13g2000vbv.googlegroups.com> Message-ID: Jaroslav Dobrek wrote: > Hello, > > in Python3, I often have this problem: I want to do something with > every line of a file. Like Python3, I presuppose that every line is > encoded in utf-8. If this isn't the case, I would like Python3 to do > something specific (like skipping the line, writing the line to > standard error, ...) > > Like so: > > try: > .... > except UnicodeDecodeError: > ... > > Yet, there is no place for this construction. If I simply do: > > for line in f: > print(line) > > this will result in a UnicodeDecodeError if some line is not utf-8, > but I can't tell Python3 to stop: > > This will not work: > > for line in f: > try: > print(line) > except UnicodeDecodeError: > ... > > because the UnicodeDecodeError is caused in the "for line in f"-part. > > How can I catch such exceptions? > > Note that recoding the file before opening it is not an option, > because often files contain many different strings in many different > encodings. I don't see those files often, but I think they are all seriously broken. There's no way to recover the information from files with unknown mixed encodings. However, here's an approach that may sometimes work: >>> with open("tmp.txt", "rb") as f: ... for line in f: ... try: ... line = "UTF-8 " + line.decode("utf-8") ... except UnicodeDecodeError: ... line = "Latin-1 " + line.decode("latin-1") ... print(line, end="") ... UTF-8 ??? Latin-1 ??? UTF-8 ??? From gordon at panix.com Mon Nov 7 10:33:03 2011 From: gordon at panix.com (John Gordon) Date: Mon, 7 Nov 2011 15:33:03 +0000 (UTC) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: In <415d875d-bc6d-4e69-bcf8-39754b45030a at n18g2000vbv.googlegroups.com> Travis Parks writes: > Which web frameworks have people here used and which have they found > to be: scalable, RAD compatible, performant, stable and/or providing > good community support? I am really trying to get as much feedback as I've used Django and it seems to be a very nice framework. However I've only done one project so I haven't delved too deeply. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From gheskett at wdtv.com Mon Nov 7 11:30:16 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 11:30:16 -0500 Subject: Python lesson please In-Reply-To: <4EB7D99D.5010604@gmx.net> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7D99D.5010604@gmx.net> Message-ID: <201111071130.16751.gheskett@wdtv.com> On Monday, November 07, 2011 10:38:32 AM Andreas Perstinger did opine: > On 2011-11-07 12:22, gene heskett wrote: > > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > >> Are you talking about this one? > >> > >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatt > >> erns .py > > > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > > pulled it again, using the 'raw' link, saved it, no extra tabs. > > > > But it still doesn't work for linux. My python is 2.6.6 > > Go to the directory where you've downloaded the file and type: > > python DuquDriverPatterns.py . > > What output do you get? Well now, I'll be dipped. It scanned that directory, took it perhaps 15 minutes, without finding anything. So I gave it two dots & its munching its way through the ../Mail/inbox now. Why the hell can't it be given a valid absolute path without editing it directly into the rootdir = statement? This may be a usable tool, but I think that before it was committed to a daily cron script, we would need some history as to where to look for such shenanigans as its certainly not fast enough to turn it loose to scan the whole system on a daily basis. This on a quad core 2.1Ghz phenom, 4 gigs of dram. And I just found one of its Achilles heels, it is now stuck on a pipe file at /home/gene/.kde4/share/apps/kaffeine/dvbpipe: prw------- 1 gene gene 0 Sep 24 18:50 dvbpipe.m2t| And using no cpu. I was going to ctl+c it but this is where, after several such, that it took the machine down yesterday. But it appears as only one process to htop (I keep a copy of it running as root here) and that killed it clean, no crash. So, it needs an exception (or likely several) of file types to stay away from, starting with pipes like the above. But I am not the one to carve that code as I have NDI how to go about writing a check stanza for that condition in python. Perhaps winderz does not have 'pipe' files so the authors never got caught out on this? The only windows experience I have is the copy of xp that was on the lappy I bought back in 2005 or so to take with me when I am on the road (I am a broadcast engineer who gets sent here and there to "put out the fires" when the station is off the air. Despite being retired for 9 years now at 77 yo, my phone still rings occasionally) I went straight from amigados-3.2 to redhat-5.0 in the late '90's, bypassing windows completely. I built the redhat machine from scratch. The lappy's xp, used only for warranty testing, got overwritten by mandriva 2008 when the warranty had expired. You could call me anti-M$ I think. :) > Bye, Andreas Thanks for listening, Andreas. Now I wonder how to get a message back to the authors that its broken in at least two aspects... Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: From gheskett at wdtv.com Mon Nov 7 11:40:12 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 11:40:12 -0500 Subject: Python lesson please In-Reply-To: <4EB7DD67.5070606@davea.name> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7DD67.5070606@davea.name> Message-ID: <201111071140.12374.gheskett@wdtv.com> On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine: Back on the list.. > On 11/07/2011 06:22 AM, gene heskett wrote: > > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > > > > > >> Are you talking about this one? > >> > >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatte > >> rns .py > > > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > > pulled it again, using the 'raw' link, saved it, no extra tabs. > > > > But it still doesn't work for linux. My python is 2.6.6 > > To start with, what's the md5 of the file you downloaded and are > testing? I get c4592a187f8f7880d3b685537e3bf9a5 [root at coyote Download]# md5sum DuquDriverPatterns.py c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as yours. > from md5sum. If you get something different, one of us changed the > file, or you got it before today. > > The whole tab issue is a red-herring in this case. But I don't see how > you can find 30k tabs in a thousand lines. And if I were going to detab > it, I'd pick 4 spaces, so the code doesn't stretch across the page. Down toward the bottom of the file, the tab indentations were as high as 33 leading tabs per line. Each stanza of the data was tab indented 2 additional tabs from the one above it in the original file. 30k was perhaps a poor SWAG, but 10 to 15k seems an entirely reasonable guess. > > > > > >> python DuquDriverPatterns.py ./directoryOfMalware > >> > >> and the line you are quoting then puts the value > >> "./directoryOfMalware" into the rootdir variable. > > > > If only it would... Using this version, the failure is silent and > > instant. Besides, the malware could be anyplace on the system. But > > it needs to skip /dev since it hangs on the midi tree, /mnt and > > /media because they are not part of the running system even if disks > > are mounted there. > > First, run it on the current directory, and it should list the files in > that directory: > > I ran it in the directory I unzipped it into, so there are two files, > the README and the source file itself. > > $ python DuquDriverPatterns.py . > Scanning ./README: > No match for pattern #0 on file named: README > No match for pattern #1 on file named: README > No match for pattern #2 on file named: README > > etc. > > The only way I can see to get NO output is to run it on an empty > directory: $mkdir junk > $ python DuquDriverPatterns.py junk > > As for skipping certain directories, we can deal with that as soon as > you get proper behavior for any subtree of directories. > > Have you tried adding a print ("Hello World " + rootdir) just before the > > for root, subFolders, files in os.walk(rootdir): > > line ? Or putting a print len(files) just after it (indented, of > course) ? No, I did try to print the value of rootdir though, indented the same, and got a null printout, not even a line feed. Thanks Dave. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: The older I grow, the less important the comma becomes. Let the reader catch his own breath. -- Elizabeth Clarkson Zwart From awilliam at whitemice.org Mon Nov 7 11:54:52 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 07 Nov 2011 11:54:52 -0500 Subject: RSS feed creation? In-Reply-To: References: Message-ID: <1320684893.8941.9.camel@linux-yu4c.site> On Mon, 2011-11-07 at 08:22 +0100, Stefan Behnel wrote: > Dan Stromberg, 06.11.2011 21:00: > > Is there an opensource Python tool for creating RSS feeds, that doesn't > > require large dependencies? > > I found feedformatter.py on pypi, but it seems a little old, and its sole > > automated test gives a traceback. > > Is there a better starting point? > > (I'd of course prefer something that'll run on 3.x and 2.x, but will settle > > for either) > I'd just go with ElementTree and builder.py. > http://effbot.org/zone/element-builder.htm +1 RSS is just XML, just use the XML toolchain. And use to check what you create. From awilliam at whitemice.org Mon Nov 7 11:57:10 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 07 Nov 2011 11:57:10 -0500 Subject: xml-rpc server on wine In-Reply-To: <650e9d68-e606-4424-bca7-174295306d82@ht6g2000vbb.googlegroups.com> References: <650e9d68-e606-4424-bca7-174295306d82@ht6g2000vbb.googlegroups.com> Message-ID: <1320685031.8941.11.camel@linux-yu4c.site> On Sat, 2011-11-05 at 05:50 -0700, pacopyc wrote: > Hi, I have a XML-RPC server python running on VM Windows (on Linux) > and a XML-RPC client python on Linux. Server and client have different > IP address. I'd like migrate server on wine. How can communicate > server and client? IP address is different or is the same? > Can you help me? Not really, this doesn't have much of anything to do with Python. If you run a network application on wine [assuming that even works] the application will have the same IP/interface as any other application or service running on the host. Wine is not a 'virtualization' solution. From josephmeiring at gmail.com Mon Nov 7 12:12:13 2011 From: josephmeiring at gmail.com (JoeM) Date: Mon, 7 Nov 2011 09:12:13 -0800 (PST) Subject: Extracting elements over multiple lists? Message-ID: Howdy, If I have a few lists like a=[1,2,3,4,5] b=["one", "two", "three", "four", "five"] c=["cat", "dog", "parrot", "clam", "ferret"] what is the most pythonic method of removing the first element from all of the lists? A list comprehension such as [arr[1:] for arr in a,b,c] gives a single 2d list, which is not what I'm shooting for. Any suggestions? From gordon at panix.com Mon Nov 7 12:37:27 2011 From: gordon at panix.com (John Gordon) Date: Mon, 7 Nov 2011 17:37:27 +0000 (UTC) Subject: Extracting elements over multiple lists? References: Message-ID: In JoeM writes: > a=[1,2,3,4,5] > b=["one", "two", "three", "four", "five"] > c=["cat", "dog", "parrot", "clam", "ferret"] > what is the most pythonic method of removing the first element from > all of the lists? for arr in [a,b,c]: arr.pop(0) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From gordon at panix.com Mon Nov 7 12:44:15 2011 From: gordon at panix.com (John Gordon) Date: Mon, 7 Nov 2011 17:44:15 +0000 (UTC) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: In John Gordon writes: > In <415d875d-bc6d-4e69-bcf8-39754b45030a at n18g2000vbv.googlegroups.com> Travis Parks writes: > > Which web frameworks have people here used and which have they found > > to be: scalable, RAD compatible, performant, stable and/or providing > > good community support? I am really trying to get as much feedback as > I've used Django and it seems to be a very nice framework. However I've > only done one project so I haven't delved too deeply. You are probably looking for more detail than "It's a nice framework" :-) The database model in Django is powerful; it allows you to do queries in native Python code without delving into backend SQL stuff. I don't know how scalable/performant the database model is, as the one project I worked on didn't deal with a ton of data. (But I'd be surprised if it had poor performance.) The URL dispatcher provides a very nice and logical way to associate a given URL with a given method call. Community support is excellent. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From moky.math at gmail.com Mon Nov 7 12:44:59 2011 From: moky.math at gmail.com (Laurent Claessens) Date: Mon, 07 Nov 2011 18:44:59 +0100 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: Le 07/11/2011 18:12, JoeM a ?crit : > Howdy, > > If I have a few lists like > > a=[1,2,3,4,5] > b=["one", "two", "three", "four", "five"] > c=["cat", "dog", "parrot", "clam", "ferret"] > > what is the most pythonic method of removing the first element from > all of the lists? Do you want to remove the first item of each list, or to create new lists that contain the same as a,b,c but with one element less ? Something like what you wrote : [arr[1:] for arr in a,b,c] will create *new* lists. Assuming you don't want new lists, I would do : a=[1,2,3,4,5] b=["one", "two", "three", "four", "five"] c=["cat", "dog", "parrot", "clam", "ferret"] for x in [a,b,c]: x.remove(x[0]) print a print b print c I think that writing >>> [x.remove(x[0]) for x in [a,b,c]] instead of the for loop is cheating ... but it also does the job. Have a good after noon Laurent From josephmeiring at gmail.com Mon Nov 7 13:01:42 2011 From: josephmeiring at gmail.com (JoeM) Date: Mon, 7 Nov 2011 10:01:42 -0800 (PST) Subject: Extracting elements over multiple lists? References: Message-ID: Thanks guys, I was just looking for a one line solution instead of a for loop if possible. Why do you consider [x.remove(x[0]) for x in [a,b,c]] cheating? It seems compact and elegant enough for me. Cheers From d at davea.name Mon Nov 7 13:14:50 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 13:14:50 -0500 Subject: Python lesson please In-Reply-To: <201111071140.12374.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7DD67.5070606@davea.name> <201111071140.12374.gheskett@wdtv.com> Message-ID: <4EB8201A.6080401@davea.name> On 11/07/2011 11:40 AM, gene heskett wrote: > On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine: > Back on the list.. >> On 11/07/2011 06:22 AM, gene heskett wrote: >>> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: >>> >>> >>>> Are you talking about this one? >>>> >>>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatte >>>> rns .py >>> >>> Yes. My save as renamed it, still has about 30k of tabs in it. But I >>> pulled it again, using the 'raw' link, saved it, no extra tabs. >>> >>> But it still doesn't work for linux. My python is 2.6.6 >> >> To start with, what's the md5 of the file you downloaded and are >> testing? I get c4592a187f8f7880d3b685537e3bf9a5 > > [root at coyote Download]# md5sum DuquDriverPatterns.py > c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as yours. > >> from md5sum. If you get something different, one of us changed the >> file, or you got it before today. >> >> The whole tab issue is a red-herring in this case. But I don't see how >> you can find 30k tabs in a thousand lines. And if I were going to detab >> it, I'd pick 4 spaces, so the code doesn't stretch across the page. > > Down toward the bottom of the file, the tab indentations were as high as 33 > leading tabs per line. Each stanza of the data was tab indented 2 > additional tabs from the one above it in the original file. 30k was > perhaps a poor SWAG, but 10 to 15k seems an entirely reasonable guess. > What program are you using to read the file and support that claim? Neither emacs nor gedit shows more than one leading tab on any line I looked. And if you set tabs to 4 columns, the file looks quite reasonable. Doing a quick scan I see max of 5 tabs on any single line, and 1006 total. maxtabs = 0 totaltabs = 0 f = open("DuquDriverPatterns.py", "r") for line in f: cline = line.replace("\t", "") tabs = len(line) - len(cline) if tabs: print tabs maxtabs = max(maxtabs, tabs) totaltabs += tabs print "max=", maxtabs print "total=", totaltabs >>> >>> >>>> python DuquDriverPatterns.py ./directoryOfMalware >>>> >>>> and the line you are quoting then puts the value >>>> "./directoryOfMalware" into the rootdir variable. >>> >>> If only it would... Using this version, the failure is silent and >>> instant. The only way I've been able to make it "silent and instant" was to give it the name of an empty directory, or a typo representing no directory at all. >>> Besides, the malware could be anyplace on the system. But >>> it needs to skip /dev since it hangs on the midi tree, /mnt and >>> /media because they are not part of the running system even if disks >>> are mounted there. >> >> First, run it on the current directory, and it should list the files in >> that directory: >> >> I ran it in the directory I unzipped it into, so there are two files, >> the README and the source file itself. >> >> $ python DuquDriverPatterns.py . >> Scanning ./README: >> No match for pattern #0 on file named: README >> No match for pattern #1 on file named: README >> No match for pattern #2 on file named: README >> >> etc. >> >> The only way I can see to get NO output is to run it on an empty >> directory: $mkdir junk >> $ python DuquDriverPatterns.py junk >> >> As for skipping certain directories, we can deal with that as soon as >> you get proper behavior for any subtree of directories. >> >> Have you tried adding a print ("Hello World " + rootdir) just before the >> >> for root, subFolders, files in os.walk(rootdir): >> >> line ? Or putting a print len(files) just after it (indented, of >> course) ? > > No, I did try to print the value of rootdir though, indented the same, and > got a null printout, not even a line feed. > If you had put the print I suggested, it would at least print the words "Hello World". Since it did not, you probably didn't actually add the line where I suggested. > Thanks Dave. > > Cheers, Gene In another message you said it doesn't work on absolute file paths. But it does. You can replace any relative directory name with the absolute version, and it won't change the behavior. I suspect you were caught up by a typo for the absolute path string. -- DaveA From gordon at panix.com Mon Nov 7 13:22:00 2011 From: gordon at panix.com (John Gordon) Date: Mon, 7 Nov 2011 18:22:00 +0000 (UTC) Subject: Extracting elements over multiple lists? References: Message-ID: In JoeM writes: > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > [x.remove(x[0]) for x in [a,b,c]] > cheating? It seems compact and elegant enough for me. I wouldn't call it cheating, but that solution does a fair bit of unneccessary work (creating a list comprehension that is never used.) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From __peter__ at web.de Mon Nov 7 13:33:01 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 19:33:01 +0100 Subject: Extracting elements over multiple lists? References: Message-ID: JoeM wrote: > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > > [x.remove(x[0]) for x in [a,b,c]] > > cheating? It seems compact and elegant enough for me. I think it's a misconception that you are avoiding the for-loop. You move it into [...] and declare it more elegant, but in reality you are creating a throwaway list of None-s. You are adding cruft to your code. That is not only superfluous, but also misleading. A simple for-loop like for x in a, b, c: del x[0] on the other hand makes your intention crystal-clear. From jeanmichel at sequans.com Mon Nov 7 13:51:31 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 07 Nov 2011 19:51:31 +0100 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: <4EB828B3.1020509@sequans.com> JoeM wrote: > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > > [x.remove(x[0]) for x in [a,b,c]] > > cheating? It seems compact and elegant enough for me. > > > > Cheers > This is a one liner, but since you asked something *pythonic*, John's solution is the best imo: for arr in [a,b,c]: arr.pop(0) (Peter's "del" solution is quite close, but I find the 'del' statement tricky in python and will mislead many python newcomers) JM From Juan.Declet-Barreto at MesaAZ.gov Mon Nov 7 14:43:05 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Mon, 7 Nov 2011 12:43:05 -0700 Subject: memory management Message-ID: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> Hi, Can anyone provide links or basic info on memory management, variable dereferencing, or the like? I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directories, but when I set it loose on a directory with thousands of dirs/subdirs, it crashes the DOS session and also the Python shell (when I run it from the shell). This makes it difficult to figure out if the allocated memory or heap space for the DOS/shell session have overflown, or why it is crashing. Juan Declet-Barreto [cid:image001.png at 01CC9D4A.CB6B9D70] GIS Specialist, Information Technology Dept. City of Mesa Office: 480.644.4751 juan.declet-barreto at mesaaz.gov [cid:image002.png at 01CC9D4A.CB6B9D70] -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 1454 bytes Desc: image001.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.png Type: image/png Size: 11402 bytes Desc: image002.png URL: From gheskett at wdtv.com Mon Nov 7 15:00:49 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 15:00:49 -0500 Subject: Python lesson please In-Reply-To: <4EB8201A.6080401@davea.name> References: <201111061314.43744.gheskett@wdtv.com> <201111071140.12374.gheskett@wdtv.com> <4EB8201A.6080401@davea.name> Message-ID: <201111071500.49230.gheskett@wdtv.com> On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine: > On 11/07/2011 11:40 AM, gene heskett wrote: > > On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine: > > Back on the list.. > > > >> On 11/07/2011 06:22 AM, gene heskett wrote: > >>> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > >>> > >>> > >>>> Are you talking about this one? > >>>> > >>>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPat > >>>> te rns .py > >>> > >>> Yes. My save as renamed it, still has about 30k of tabs in it. But > >>> I pulled it again, using the 'raw' link, saved it, no extra tabs. > >>> > >>> But it still doesn't work for linux. My python is 2.6.6 > >> > >> To start with, what's the md5 of the file you downloaded and are > >> testing? I get c4592a187f8f7880d3b685537e3bf9a5 > > > > [root at coyote Download]# md5sum DuquDriverPatterns.py > > c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as > > yours. > > > >> from md5sum. If you get something different, one of us changed the > >> file, or you got it before today. > >> > >> The whole tab issue is a red-herring in this case. But I don't see > >> how you can find 30k tabs in a thousand lines. And if I were going > >> to detab it, I'd pick 4 spaces, so the code doesn't stretch across > >> the page. > > > > Down toward the bottom of the file, the tab indentations were as high > > as 33 leading tabs per line. Each stanza of the data was tab > > indented 2 additional tabs from the one above it in the original > > file. 30k was perhaps a poor SWAG, but 10 to 15k seems an entirely > > reasonable guess. > > What program are you using to read the file and support that claim? vim. But remember, this first one started out as a copy/paste from the firefox-7.0.1 screen. > Neither emacs nor gedit shows more than one leading tab on any line I > looked. And if you set tabs to 4 columns, the file looks quite > reasonable. Doing a quick scan I see max of 5 tabs on any single line, > and 1006 total. I have no tabs left in the operative code, the python interpreter was having a cow if even one was in that last 30-35 lines of code. > > > maxtabs = 0 > totaltabs = 0 > f = open("DuquDriverPatterns.py", "r") > for line in f: > > cline = line.replace("\t", "") > tabs = len(line) - len(cline) > if tabs: > print tabs > maxtabs = max(maxtabs, tabs) > totaltabs += tabs > > print "max=", maxtabs > print "total=", totaltabs > > >>> > The only way I've been able to make it "silent and instant" was to give > it the name of an empty directory, or a typo representing no directory > at all. > [...] > >> line ? Or putting a print len(files) just after it (indented, of > >> course) ? > > > > No, I did try to print the value of rootdir though, indented the same, > > and got a null printout, not even a line feed. Indented the same as the rootdir statement itself, which in python would seem to make it immediately sequential to the roodir = statement. > If you had put the print I suggested, it would at least print the words > "Hello World". Since it did not, you probably didn't actually add the > line where I suggested. > > > Thanks Dave. > > > > Cheers, Gene > > In another message you said it doesn't work on absolute file paths. But > it does. You can replace any relative directory name with the absolute > version, and it won't change the behavior. I suspect you were caught up > by a typo for the absolute path string. I am gene, running as gene, what could be wrong with giving it /home/gene as the argument? I have another dir in /home/amanda, that I build the alpha and beta amanda stuff in. Let me try that. And again, this works but I forgot about the .ccache directory, so it will take a while to finish. Now, as a python lesson to me, I will do a blink compare between the 2 files this evening & see what I munged. ATM, I am working on a gunstock for as long as my feet and back can stand the standing, so sitting here is a 'break' from that. Yeah, I occasionally call myself a JOAT. ;-) Thanks Dave. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Experience is that marvelous thing that enables you recognize a mistake when you make it again. -- Franklin P. Jones From d at davea.name Mon Nov 7 15:06:25 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 15:06:25 -0500 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: <4EB83A41.9050802@davea.name> On 11/07/2011 01:01 PM, JoeM wrote: > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > > [x.remove(x[0]) for x in [a,b,c]] > > cheating? It seems compact and elegant enough for me. > > > > Cheers Are you considering the possibility that two of these names might reference the same list? a = [42, 44, 6, 19, 48] b = a c = b for x in [a,b,c]: x.remove(x[0]) now a will have [19,48] as its content. -- DaveA From davea at dejaviewphoto.com Mon Nov 7 15:19:53 2011 From: davea at dejaviewphoto.com (Dave Angel) Date: Mon, 07 Nov 2011 15:19:53 -0500 Subject: memory management In-Reply-To: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> Message-ID: <4EB83D69.2000409@dejaviewphoto.com> On 11/07/2011 02:43 PM, Juan Declet-Barreto wrote: > Hi, > > Can anyone provide links or basic info on memory management, variable dereferencing, or the like? I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directories, but when I set it loose on a directory with thousands of dirs/subdirs, it crashes the DOS session and also the Python shell (when I run it from the shell). This makes it difficult to figure out if the allocated memory or heap space for the DOS/shell session have overflown, or why it is crashing. > > Juan Declet-Barreto [ciId:image001.png at 01CC9D4A.CB6B9D70] I don't have any reference to point you to, but CPython's memory management is really pretty simple. However, it's important to tell us the build of Python, as there are several, with very different memory rules. For example Jython, which is Python running in a Java VM, lets the java garbage collector handle things, and it's entirely different. Likewise, the OS may be relevant. You're using Windows-kind of terminology, but that doesn't prove you're on Windows, nor does it say what version. Assuming 32 bit CPython 2.7 on XP, the principles are simple. When an object is no longer accessible, it gets garbage collected*. So if you build a list inside a function, and the only reference is from a function's local var, then the whole list will be freed when the function exits. The mistakes many people make are unnecessarily using globals, and using lists when iterables would work just as well. The tool on XP to tell how much memory is in use is the task manager. As you point out, its hard to catch a short-running app in the act. So you want to add a counter to your code (global), and see how high it gets when it crashes. Then put a test in your code for the timer value, and do an "input" somewhat earlier. At that point, see how much memory the program is actually using. Now, when an object is freed, a new one of the same size is likely to immediately re-use the space. But if they're all different sizes, it's somewhat statistical. You might get fragmentation, for example. When Python's pool is full, it asks the OS for more (perhaps using swap space), but I don't think it ever gives it back. So your memory use is a kind of ceiling case. That's why it's problematic to build a huge data structure, and then walk through it, then delete it. The script will probably continue to show the peak memory use, indefinitely. * (technically, this is ref counted. When the ref reaches zero the object is freed. Real gc is more lazy scanning) From jfine at pytex.org Mon Nov 7 15:21:49 2011 From: jfine at pytex.org (Jonathan Fine) Date: Mon, 07 Nov 2011 20:21:49 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> Message-ID: <4EB83DDD.1080103@pytex.org> On 06/11/11 20:28, Jakub Narebski wrote: > Note that for gitPAN each "distribution" (usually but not always > corresponding to single Perl module) is in separate repository. > The dependencies are handled by CPAN / CPANPLUS / cpanm client > (i.e. during install). Thank you for your interest, Jakub, and also for this information. With TeX there's a difficult which Perl, I think, does not have. With TeX we process documents, which may demand specific versions of packages. LaTeX users are concerned that move on to a later version will cause documents to break. > Putting all DVD (is it "TeX Live" DVD by the way?) into single > repository would put quite a bit of stress to git; it was created for > software development (although admittedly of large project like Linux > kernel), not 4GB+ trees. I'm impressed by how well git manages it. It took about 15 minutes to build the 4GB tree, and it was disk speed rather than CPU which was the bottleneck. >> Once you've done that, it is then possible and sensible to select >> suitable interesting subsets, such as releases of a particular >> package. Users could even define their own subsets, such as "all >> resources needed to process this file, exactly as it processes on my >> machine". > > This could be handled using submodules, by having superrepository that > consist solely of references to other repositories by the way of > submodules... plus perhaps some administrativa files (like README for > whole CTAN, or search tool, or DVD install, etc.) > > This could be the used to get for example contents of DVD from 2010. We may be at cross purposes. My first task is get the DVD tree into git, performing necessary transformations such as expanding zip files along the way. Breaking the content into submodules can, I believe, be done afterwards. With DVDs from several years it could take several hours to load everything into git. For myself, I'd like to do that once, more or less as a batch process, and then move on to the more interesting topics. Getting the DVD contents into git is already a significant piece of work. Once done, I can them move on to what you're interested in, which is organising the material. And I hope that others in the TeX community will get involved with that, because I'm not building this repository just for myself. > But even though submodules (c.f. Subversion svn:external, Mecurial > forest extension, etc.) are in Git for quite a bit of time, it doesn't > have best user interface. > >> In addition, many TeX users have a TeX DVD. If they import it into a >> git repository (using for example my script) then the update from 2011 >> to 2012 would require much less bandwidth. > > ??? A quick way to bring your TeX distribution up to date is to do a delta with a later distribution, and download the difference. That's what git does, and it does it well. So I'm keen to convert a TeX DVD into a git repository, and then differences can be downloaded. >> Finally, I'd rather be working within git that modified copy of the >> ISO when doing the subsetting. I'm pretty sure that I can manage to >> pull the small repositories from the big git-CTAN repository. > > No you cannot. It is all or nothing; there is no support for partial > _clone_ (yet), and it looks like it is a hard problem. > > Nb. there is support for partial _checkout_, but this is something > different. From what I know, I'm confident that I can achieve what I want using git. I'm also confident that my approach is not closing off any possible approached. But if I'm wrong you'll be able to say: I told you so. > Commit = tree + parent + metadata. Actually, any number of parents, including none. What metadata do I have to provide? At this time nothing, I think, beyond that provided by the name of a reference (to the root of a tree). > I think you would very much want to have linear sequence of trees, > ordered via DAG of commits. "Naked" trees are rather bad idea, I think. > >> As I recall the first 'commit' to the git repository for the Linux >> kernel was just a tree, with a reference to that tree as a tag. But >> no commit. > > That was a bad accident that there is a tag that points directly to a > tree of _initial import_, not something to copy. Because git is a distributed version control system, anyone who wants to can create such a directed acyclic graph of commits. And if it's useful I'll gladly add it to my copy of the repository. best regards Jonathan From jfine at pytex.org Mon Nov 7 15:21:49 2011 From: jfine at pytex.org (Jonathan Fine) Date: Mon, 07 Nov 2011 20:21:49 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> Message-ID: <4EB83DDD.1080103@pytex.org> On 06/11/11 20:28, Jakub Narebski wrote: > Note that for gitPAN each "distribution" (usually but not always > corresponding to single Perl module) is in separate repository. > The dependencies are handled by CPAN / CPANPLUS / cpanm client > (i.e. during install). Thank you for your interest, Jakub, and also for this information. With TeX there's a difficult which Perl, I think, does not have. With TeX we process documents, which may demand specific versions of packages. LaTeX users are concerned that move on to a later version will cause documents to break. > Putting all DVD (is it "TeX Live" DVD by the way?) into single > repository would put quite a bit of stress to git; it was created for > software development (although admittedly of large project like Linux > kernel), not 4GB+ trees. I'm impressed by how well git manages it. It took about 15 minutes to build the 4GB tree, and it was disk speed rather than CPU which was the bottleneck. >> Once you've done that, it is then possible and sensible to select >> suitable interesting subsets, such as releases of a particular >> package. Users could even define their own subsets, such as "all >> resources needed to process this file, exactly as it processes on my >> machine". > > This could be handled using submodules, by having superrepository that > consist solely of references to other repositories by the way of > submodules... plus perhaps some administrativa files (like README for > whole CTAN, or search tool, or DVD install, etc.) > > This could be the used to get for example contents of DVD from 2010. We may be at cross purposes. My first task is get the DVD tree into git, performing necessary transformations such as expanding zip files along the way. Breaking the content into submodules can, I believe, be done afterwards. With DVDs from several years it could take several hours to load everything into git. For myself, I'd like to do that once, more or less as a batch process, and then move on to the more interesting topics. Getting the DVD contents into git is already a significant piece of work. Once done, I can them move on to what you're interested in, which is organising the material. And I hope that others in the TeX community will get involved with that, because I'm not building this repository just for myself. > But even though submodules (c.f. Subversion svn:external, Mecurial > forest extension, etc.) are in Git for quite a bit of time, it doesn't > have best user interface. > >> In addition, many TeX users have a TeX DVD. If they import it into a >> git repository (using for example my script) then the update from 2011 >> to 2012 would require much less bandwidth. > > ??? A quick way to bring your TeX distribution up to date is to do a delta with a later distribution, and download the difference. That's what git does, and it does it well. So I'm keen to convert a TeX DVD into a git repository, and then differences can be downloaded. >> Finally, I'd rather be working within git that modified copy of the >> ISO when doing the subsetting. I'm pretty sure that I can manage to >> pull the small repositories from the big git-CTAN repository. > > No you cannot. It is all or nothing; there is no support for partial > _clone_ (yet), and it looks like it is a hard problem. > > Nb. there is support for partial _checkout_, but this is something > different. From what I know, I'm confident that I can achieve what I want using git. I'm also confident that my approach is not closing off any possible approached. But if I'm wrong you'll be able to say: I told you so. > Commit = tree + parent + metadata. Actually, any number of parents, including none. What metadata do I have to provide? At this time nothing, I think, beyond that provided by the name of a reference (to the root of a tree). > I think you would very much want to have linear sequence of trees, > ordered via DAG of commits. "Naked" trees are rather bad idea, I think. > >> As I recall the first 'commit' to the git repository for the Linux >> kernel was just a tree, with a reference to that tree as a tag. But >> no commit. > > That was a bad accident that there is a tag that points directly to a > tree of _initial import_, not something to copy. Because git is a distributed version control system, anyone who wants to can create such a directed acyclic graph of commits. And if it's useful I'll gladly add it to my copy of the repository. best regards Jonathan From Juan.Declet-Barreto at MesaAZ.gov Mon Nov 7 15:33:09 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Mon, 7 Nov 2011 13:33:09 -0700 Subject: memory management In-Reply-To: <4EB83D69.2000409@dejaviewphoto.com> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> Message-ID: <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. -----Original Message----- From: Dave Angel [mailto:davea at dejaviewphoto.com] Sent: Monday, November 07, 2011 1:20 PM To: Juan Declet-Barreto Cc: python-list at python.org Subject: Re: memory management On 11/07/2011 02:43 PM, Juan Declet-Barreto wrote: > Hi, > > Can anyone provide links or basic info on memory management, variable dereferencing, or the like? I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directories, but when I set it loose on a directory with thousands of dirs/subdirs, it crashes the DOS session and also the Python shell (when I run it from the shell). This makes it difficult to figure out if the allocated memory or heap space for the DOS/shell session have overflown, or why it is crashing. > > Juan Declet-Barreto [ciId:image001.png at 01CC9D4A.CB6B9D70] I don't have any reference to point you to, but CPython's memory management is really pretty simple. However, it's important to tell us the build of Python, as there are several, with very different memory rules. For example Jython, which is Python running in a Java VM, lets the java garbage collector handle things, and it's entirely different. Likewise, the OS may be relevant. You're using Windows-kind of terminology, but that doesn't prove you're on Windows, nor does it say what version. Assuming 32 bit CPython 2.7 on XP, the principles are simple. When an object is no longer accessible, it gets garbage collected*. So if you build a list inside a function, and the only reference is from a function's local var, then the whole list will be freed when the function exits. The mistakes many people make are unnecessarily using globals, and using lists when iterables would work just as well. The tool on XP to tell how much memory is in use is the task manager. As you point out, its hard to catch a short-running app in the act. So you want to add a counter to your code (global), and see how high it gets when it crashes. Then put a test in your code for the timer value, and do an "input" somewhat earlier. At that point, see how much memory the program is actually using. Now, when an object is freed, a new one of the same size is likely to immediately re-use the space. But if they're all different sizes, it's somewhat statistical. You might get fragmentation, for example. When Python's pool is full, it asks the OS for more (perhaps using swap space), but I don't think it ever gives it back. So your memory use is a kind of ceiling case. That's why it's problematic to build a huge data structure, and then walk through it, then delete it. The script will probably continue to show the peak memory use, indefinitely. * (technically, this is ref counted. When the ref reaches zero the object is freed. Real gc is more lazy scanning) From stefan-usenet at bytereef.org Mon Nov 7 15:47:16 2011 From: stefan-usenet at bytereef.org (Stefan Krah) Date: Mon, 7 Nov 2011 21:47:16 +0100 Subject: memory management In-Reply-To: <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> Message-ID: <20111107204716.GA14201@sleipnir.bytereef.org> Juan Declet-Barreto wrote: > Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which > ships with ESRI's ArcGIS. In addition, I am using some functions in the > arcgisscripting Python geoprocessing module for geographic information > systems (GIS) applications, which can complicate things. I am currently > isolating standard library Python code (e.g., os.walk()) from the > arcgisscripting module to evaluate in which module the environment > crash is occurring. It might be a good idea to check if the problem also occurs with Python 2.7 since Python 2.5 is no longer maintained. Stefan Krah From d at davea.name Mon Nov 7 15:50:19 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 15:50:19 -0500 Subject: memory management In-Reply-To: <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> Message-ID: <4EB8448B.7030709@davea.name> On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: > Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. You top-posted. In this mailing list, one should type new information after the quoted information, not before. Perhaps a pre-emptive strike is in order. On the assumption that it may be a memory problem, how about you turn the app inside out. Instead of walking the entire tree, getting a list with all the paths, and then working on the list, how about doing the work on each file as you get it. Or even make your own generator from os.walk, so the app can call your logic on each file, and never have all the file (name)s in memory at the same time. Generator: def filelist(top, criteria): for a, b, c in os.walk(): for fiile in files: apply some criteria yield file Now the main app can iterate through this "list" in the usual way for filename in filelist(top, "*.txt"): dosomething... -- DaveA From brenNOSPAMbarn at NObrenSPAMbarn.net Mon Nov 7 16:00:53 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Mon, 7 Nov 2011 21:00:53 +0000 (UTC) Subject: all() is slow? Message-ID: I noticed this (Python 2.6.5 on Windows XP): >>> import random, timeit >>> def myAll(x): ... for a in x: ... if a not in (True, False): ... return False ... return True >>> x = [random.choice([True, False]) for a in xrange(0, 5000000)] >>> timeit.timeit('myAll(x)', 'from __main__ import myAll, x', number=10) 0: 9.7685158309226452 >>> timeit.timeit('all(a in (True, False) for a in x)', 'from __main__ import x', number=10) 1: 12.348196768024984 >>> x = [random.randint(0,100) for a in xrange(0, 5000000)] >>> def myAll(x): ... for a in x: ... if not a <= 100: ... return False ... return True >>> timeit.timeit('myAll(x)', 'from __main__ import myAll, x', number=10) 4: 2.8248207523582209 >>> timeit.timeit('all(a <= 100 for a in x)', 'gc.enable(); from __main__ import x', number=10) 5: 4.6433557896324942 What is the point of the all() function being a builtin if it's slower than writing a function to do the check myself? -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From ramit.prasad at jpmorgan.com Mon Nov 7 16:34:08 2011 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Mon, 7 Nov 2011 16:34:08 -0500 Subject: python-based downloader (youtube-dl) missing critical feature ... In-Reply-To: <4EB3E93E.50500@sequans.com> References: <1320407282.243739@nntp.aceinnovative.com> <4eb3db48$0$29968$c3e8da3$5496439d@news.astraweb.com> <4EB3E93E.50500@sequans.com> Message-ID: <0604E20B5F6F2F4784C9C8C71C5DD4DD2FDF6DD8E0@EMARC112VS01.exchad.jpmchase.net> >Maybe Lbrtchx is one of the Sheldon Cooper's nicknames :o) > >JM > >PS : I have the feeling that my nerdy reference will fall flat... Not completely ;) Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From clp2 at rebertia.com Mon Nov 7 16:39:57 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 7 Nov 2011 13:39:57 -0800 Subject: all() is slow? In-Reply-To: References: Message-ID: On Mon, Nov 7, 2011 at 1:00 PM, OKB (not okblacke) wrote: > ? ? ? ?What is the point of the all() function being a builtin if it's > slower than writing a function to do the check myself? Regardless of whether it's slower (which I expect someone will be along to debunk or explain shortly), do you really want to have to write an additional boilerplate function or block of code /every single time/ you want to do such a check? The runtime speed difference is unlikely to be worth your time as a developer in many cases. And by Murphy's Law, you *will* make errors writing these repetitive code blocks (e.g. forget to negate the conditional), whereas reusing all() makes that much less likely. The trade-off is run-time speed for developer productivity/convenience; Python tends to lean towards the latter (to varying degrees). Cheers, Chris From rosuav at gmail.com Mon Nov 7 16:40:56 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 08:40:56 +1100 Subject: memory management In-Reply-To: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> Message-ID: On Tue, Nov 8, 2011 at 6:43 AM, Juan Declet-Barreto wrote: > > I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directories, but when I set it loose on a directory with thousands of dirs/subdirs, it crashes the DOS session and also the Python shell (when I run it from the shell). This seems a little unusual - it crashes more than its own process? If you use Start... Run and type in "cmd" (or use the "Command Prompt" icon, whereever that is), and invoke Python from there, it crashes cmd as well as Python? If so, I'd be suspecting either some really weird bug in the Python interpreter (try upgrading to 2.7), or a hardware fault in your computer (try running MemTest or running it on a different computer). ChrisA From codewarrior0 at gmail.com Mon Nov 7 16:46:25 2011 From: codewarrior0 at gmail.com (david vierra) Date: Mon, 7 Nov 2011 13:46:25 -0800 (PST) Subject: all() is slow? References: Message-ID: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> On Nov 7, 11:00?am, "OKB (not okblacke)" wrote: > ? ? ? ? What is the point of the all() function being a builtin if it's > slower than writing a function to do the check myself? > But, you didn't write an all() function. You wrote a more specialized allBoolean() function. I think this comparison is more fair to the builtin all(): >>> def myAll(x): ... for a in x: ... if not a: return False ... return True ... >>> timeit.timeit('myAll(a in (True, False) for a in x)', 'from __main__ import myAll, x', number=10) 14.510986388627998 >>> timeit.timeit('all(a in (True, False) for a in x)', 'from __main__ import x', number=10) 12.209779342432576 From jnareb at gmail.com Mon Nov 7 16:50:23 2011 From: jnareb at gmail.com (Jakub Narebski) Date: Mon, 07 Nov 2011 13:50:23 -0800 (PST) Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: <4EB83DDD.1080103@pytex.org> References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> <4EB83DDD.1080103@pytex.org> Message-ID: The following message is a courtesy copy of an article that has been posted to comp.text.tex as well. Jonathan Fine writes: > On 06/11/11 20:28, Jakub Narebski wrote: > > > Note that for gitPAN each "distribution" (usually but not always > > corresponding to single Perl module) is in separate repository. > > The dependencies are handled by CPAN / CPANPLUS / cpanm client > > (i.e. during install). > > Thank you for your interest, Jakub, and also for this information. > With TeX there's a difficult which Perl, I think, does not have. With > TeX we process documents, which may demand specific versions of > packages. LaTeX users are concerned that move on to a later version > will cause documents to break. How you can demand specific version of package? In the "\usepackage[options]{packages}[version]" LaTeX command the argument specifies _minimal_ (oldest) version. The same is true for Perl "use Module VERSION LIST". Nevertheless while with "use Module VERSION" / "use Module VERSION LIST" you can request minimal version of Perl Module, the META build-time spec can include requirement of exact version of required package: http://p3rl.org/CPAN::Meta::Spec Version Ranges ~~~~~~~~~~~~~~ Some fields (prereq, optional_features) indicate the particular version(s) of some other module that may be required as a prerequisite. This section details the Version Range type used to provide this information. The simplest format for a Version Range is just the version number itself, e.g. 2.4. This means that *at least* version 2.4 must be present. To indicate that *any* version of a prerequisite is okay, even if the prerequisite doesn't define a version at all, use the version 0. Alternatively, a version range *may* use the operators < (less than), <= (less than or equal), > (greater than), >= (greater than or equal), == (equal), and != (not equal). For example, the specification < 2.0 means that any version of the prerequisite less than 2.0 is suitable. For more complicated situations, version specifications *may* be AND-ed together using commas. The specification >= 1.2, != 1.5, < 2.0 indicates a version that must be *at least* 1.2, *less than* 2.0, and *not equal to* 1.5. > > Putting all DVD (is it "TeX Live" DVD by the way?) into single > > repository would put quite a bit of stress to git; it was created for > > software development (although admittedly of large project like Linux > > kernel), not 4GB+ trees. > > I'm impressed by how well git manages it. It took about 15 minutes to > build the 4GB tree, and it was disk speed rather than CPU which was > the bottleneck. I still think that using modified contrib/fast-import/import-zips.py (or import-tars.perl, or import-directories.perl) would be a better solution here... [...] > We may be at cross purposes. My first task is get the DVD tree into > git, performing necessary transformations such as expanding zip files > along the way. Breaking the content into submodules can, I believe, > be done afterwards. 'reposurgeon' might help there... or might not. Same with git-subtree tool. But now I understand that you are just building tree objects, and creating references to them (with implicit ordering given by names, I guess). This is to be a start of further work, isn't it? > With DVDs from several years it could take several hours to load > everything into git. For myself, I'd like to do that once, more or > less as a batch process, and then move on to the more interesting > topics. Getting the DVD contents into git is already a significant > piece of work. > > Once done, I can them move on to what you're interested in, which is > organising the material. And I hope that others in the TeX community > will get involved with that, because I'm not building this repository > just for myself. [...] > > > In addition, many TeX users have a TeX DVD. If they import it into a > > > git repository (using for example my script) then the update from 2011 > > > to 2012 would require much less bandwidth. > > > > ??? > > A quick way to bring your TeX distribution up to date is to do a delta > with a later distribution, and download the difference. That's what > git does, and it does it well. So I'm keen to convert a TeX DVD into > a git repository, and then differences can be downloaded. Here perhaps you should take a look at git-based 'bup' backup system. Anyway I am not sure if for git to be able to generate deltas well you have to have DAG of commits, so Git can notice what you have and what you have not. Trees might be not enough here. (!) > > Commit = tree + parent + metadata. > > Actually, any number of parents, including none. What metadata do I > have to provide? At this time nothing, I think, beyond that provided > by the name of a reference (to the root of a tree). Metadata = commit message (here you can e.g. put the official name of DVD), author and committer info (name, email, date and time, timezone; date and time you can get from mtime / creation time of DVD). [cut] -- Jakub Nar?bski From jfine at pytex.org Mon Nov 7 17:03:09 2011 From: jfine at pytex.org (Jonathan Fine) Date: Mon, 07 Nov 2011 22:03:09 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> <4EB83DDD.1080103@pytex.org> Message-ID: <4EB8559D.8080704@pytex.org> On 07/11/11 21:49, Jakub Narebski wrote: [snip] > But now I understand that you are just building tree objects, and > creating references to them (with implicit ordering given by names, > I guess). This is to be a start of further work, isn't it? Yes, that's exactly the point, and my apologies if I was not clear enough. I'll post again when I've finished the script and performed placed several years of DVD into git. Then the discussion will be more concrete - we have this tree, how do we make it more useful. Thank you for your contributions, particularly telling me about gitpan. -- Jonathan From garyfallidis at gmail.com Mon Nov 7 17:06:40 2011 From: garyfallidis at gmail.com (Eleftherios Garyfallidis) Date: Mon, 7 Nov 2011 23:06:40 +0100 Subject: ctypes accessing functions with double pointers Message-ID: Hello, Is it possible using ctypes to call C functions from a shared object containing double pointers e.g. int foo(float **i) and if yes how? Best wishes, Eleftherios -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Nov 7 17:06:56 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 09:06:56 +1100 Subject: all() is slow? In-Reply-To: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On Tue, Nov 8, 2011 at 8:46 AM, david vierra wrote: > But, you didn't write an all() function. ?You wrote a more specialized > allBoolean() function. I think this comparison is more fair to the > builtin all(): So really, it's not "all() is slow" but "function calls are slow". Maybe it'd be worthwhile making an all-factory: def my_all(code,lst): exec("""def tmp_all(x): for a in x: if not ("""+code+"""): return False return True """) return tmp_all(lst) timeit.timeit('my_all("a in (True, False)",x)','from __main__ import my_all,x',number=10) Bad code imho, but it _is_ faster than both the original and the builtin. ChrisA From clp2 at rebertia.com Mon Nov 7 17:29:46 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 7 Nov 2011 14:29:46 -0800 Subject: ctypes accessing functions with double pointers In-Reply-To: References: Message-ID: On Mon, Nov 7, 2011 at 2:06 PM, Eleftherios Garyfallidis wrote: > Hello, > > Is it possible using ctypes to call C functions from a shared object > containing double pointers e.g. int foo(float **i) and if yes how? (Untested conjecture:) import ctypes # ...create ctypes_wrapped_foo... the_float = ctypes.c_float(42.1) float_ptr = ctypes.byref(the_float) i = ctypes.byref(float_ptr) result_integer = ctypes_wrapped_foo(i) Cheers, Chris From joshua.landau.ws at gmail.com Mon Nov 7 17:51:21 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Mon, 7 Nov 2011 22:51:21 +0000 Subject: all() is slow? In-Reply-To: References: Message-ID: See these all vs myAll tests: %~> python all_test 0.5427970886230469 1.1579840183258057 3.3052260875701904 3.4992029666900635 3.303942918777466 1.7343430519104004 3.18320894241333 1.6191949844360352 In the first pair and the second pair, the pairs receive the same input. The builtin all outperforms the user-defined. In the second pair, the builtin receives a generator whereas the function just runs. A generator has to be called once every iteration, and this significantly slows it. The main use of "all" is ease, though, as mentioned before. The second is speed when testing lists/generators that don't need to be wrapped. Note: %~> pypy all_test 0.0657250881195 0.0579369068146 0.751952171326 0.657609939575 0.748466968536 0.0586581230164 0.801791906357 0.0550608634949 If speed is your concern, there are simple solutions. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Mon Nov 7 19:06:53 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 07 Nov 2011 19:06:53 -0500 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: On 11/7/2011 1:22 PM, John Gordon wrote: > In JoeM writes: > >> Thanks guys, I was just looking for a one line solution instead of a >> for loop if possible. Why do you consider > >> [x.remove(x[0]) for x in [a,b,c]] > >> cheating? It seems compact and elegant enough for me. It looks like incomplete code with 'somelists = ' or other context omitted. It saves no keypresses '[',...,SPACE,...,']' versus ...,':',ENTER,TAB,... . (TAB with a decent Python aware editor.) > I wouldn't call it cheating, but that solution does a fair bit of > unneccessary work (creating a list comprehension that is never used.) The comprehension ( the code) is used, but the result is not. If the source iterator has a large number of items rather than 3, the throwaway list could become an issue. Example. fin = open('source.txt') fout= open('dest.txt, 'w') for line in fin: fout.write(line.strip()) # versus [fout.write(line.strip()) for line in fin] If source.txt has 100 millions lines, the 'clever' code looks less clever ;=). Comprehensions are intended for creating collections (that one actually wants) and for normal Python coding are best used for that. -- Terry Jan Reedy From tjreedy at udel.edu Mon Nov 7 19:17:09 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 07 Nov 2011 19:17:09 -0500 Subject: memory management In-Reply-To: <20111107204716.GA14201@sleipnir.bytereef.org> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> <20111107204716.GA14201@sleipnir.bytereef.org> Message-ID: On 11/7/2011 3:47 PM, Stefan Krah wrote: > Juan Declet-Barreto wrote: >> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which >> ships with ESRI's ArcGIS. In addition, I am using some functions in the >> arcgisscripting Python geoprocessing module for geographic information >> systems (GIS) applications, which can complicate things. I am currently >> isolating standard library Python code (e.g., os.walk()) from the >> arcgisscripting module to evaluate in which module the environment >> crash is occurring. What *exactly* do you mean by "crash"? > It might be a good idea to check if the problem also occurs with Python 2.7 > since Python 2.5 is no longer maintained. And 2.7 has hundreds of more recent bug fixes. Just one could make a difference. -- Terry Jan Reedy From tjreedy at udel.edu Mon Nov 7 19:23:50 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 07 Nov 2011 19:23:50 -0500 Subject: Python lesson please In-Reply-To: <201111071130.16751.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7D99D.5010604@gmx.net> <201111071130.16751.gheskett@wdtv.com> Message-ID: On 11/7/2011 11:30 AM, gene heskett wrote: > Perhaps winderz does not have 'pipe' files so the authors never got caught > out on this? Last I know, Windows not only had no pipe files but also no real in-memory pipes. Maybe one or both of those has changed. -- Terry Jan Reedy From gheskett at wdtv.com Mon Nov 7 19:36:46 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 19:36:46 -0500 Subject: Python lesson please In-Reply-To: References: <201111061314.43744.gheskett@wdtv.com> <201111071130.16751.gheskett@wdtv.com> Message-ID: <201111071936.46138.gheskett@wdtv.com> On Monday, November 07, 2011 07:34:05 PM Terry Reedy did opine: > On 11/7/2011 11:30 AM, gene heskett wrote: > > Perhaps winderz does not have 'pipe' files so the authors never got > > caught out on this? > > Last I know, Windows not only had no pipe files but also no real > in-memory pipes. Maybe one or both of those has changed. Sheesh.. How the heck do you get anything done on winderz then. :( Answer not needed as they regularly reinvent the wheel because everything has to be self contained, poorly IMO. Most of their wheels ride a bit rough. ;) Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: I believe that professional wrestling is clean and everything else in the world is fixed. -- Frank Deford, sports writer From jehugaleahsa at gmail.com Mon Nov 7 21:21:52 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 7 Nov 2011 18:21:52 -0800 (PST) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: On Nov 7, 12:44?pm, John Gordon wrote: > In John Gordon writes: > > > In <415d875d-bc6d-4e69-bcf8-39754b450... at n18g2000vbv.googlegroups.com> Travis Parks writes: > > > Which web frameworks have people here used and which have they found > > > to be: scalable, RAD compatible, performant, stable and/or providing > > > good community support? I am really trying to get as much feedback as > > I've used Django and it seems to be a very nice framework. ?However I've > > only done one project so I haven't delved too deeply. > > You are probably looking for more detail than "It's a nice framework" :-) > > The database model in Django is powerful; it allows you to do queries in > native Python code without delving into backend SQL stuff. > > I don't know how scalable/performant the database model is, as the one > project I worked on didn't deal with a ton of data. ?(But I'd be surprised > if it had poor performance.) > > The URL dispatcher provides a very nice and logical way to associate a > given URL with a given method call. > > Community support is excellent. > > -- > John Gordon ? ? ? ? ? ? ? ? ? A is for Amy, who fell down the stairs > gor... at panix.com ? ? ? ? ? ? ?B is for Basil, assaulted by bears > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -- Edward Gorey, "The Gashlycrumb Tinies" I started the battle today. The "new guy" was trying to sell me on CodeIgnitor. I haven't looked at it, but it is PHP, so I really want to avoid it. The good thing is that all of his "friends" have been telling him to get into Python. I have been trying to convince him that PHP isn't cut out for background services and is mostly a front- end language. Python is much more geared towards hardcore data processing. Why write the system in two languages? I have been spending a lot of time looking at the Pyramid project: the next generation of the Pylons project. It looks powerful, but it seems to be a lot more complex than Django. From lie.1296 at gmail.com Mon Nov 7 23:17:14 2011 From: lie.1296 at gmail.com (Lie Ryan) Date: Tue, 08 Nov 2011 15:17:14 +1100 Subject: How to mix-in __getattr__ after the fact? In-Reply-To: <8bc11029-860e-4d3a-8770-062e16e31514@j39g2000yqc.googlegroups.com> References: <4630c4d0-86bc-4295-8bbb-6f58415191c8@v15g2000vbm.googlegroups.com> <4EAAF264.1050307@stoneleaf.us> <8bc11029-860e-4d3a-8770-062e16e31514@j39g2000yqc.googlegroups.com> Message-ID: On 10/31/2011 11:01 PM, dhyams wrote: > > Thanks for all of the responses; everyone was exactly correct, and > obeying the binding rules for special methods did work in the example > above. Unfortunately, I only have read-only access to the class > itself (it was a VTK class wrapped with SWIG), so I had to find > another way to accomplish what I was after. > As a big huge hack, you can always write a wrapper class: class Wrapper(object): def __init__(self, *args, **kwargs): self.__object = MySWIGClass(*args, **kwargs) def __getattr__(self, attr): try: return getattr(self.__object, attr) except AttributeError: ... From kwa at kuwata-lab.com Mon Nov 7 23:32:46 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Tue, 8 Nov 2011 13:32:46 +0900 Subject: easy_install doesn't install non-package *.py file Message-ID: I got trouble about easy_install command. My package: README.rst setup.py foobar/ foobar/__init__.py foobar/data/ foobar/data/template.py In the above example, 'foobar/data/template.py' is just a template data file (= not a python module file). (notice that 'foobar/data/__init__.py' doesn't exist.) In this case, 'foobar/data/template.py' file is NOT installed when trying 'easy_install foobar'. This is trouble what I got. I found that: * foobar.tar.gz created by 'easy_install sdist' contains 'foobar/data/template.py' correctly. * foobar.egg created by 'easy_install bdist' doesn't contain 'foobar/data/template.py' file. Question: how can I enforce easy_install command to install 'foobar/data/template.py' (or non-package *.py file)? -- regars, makoto kuwata From cs at zip.com.au Mon Nov 7 23:59:00 2011 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 8 Nov 2011 15:59:00 +1100 Subject: Python lesson please In-Reply-To: <201111071500.49230.gheskett@wdtv.com> References: <201111071500.49230.gheskett@wdtv.com> Message-ID: <20111108045900.GA12613@cskk.homeip.net> On 07Nov2011 15:00, gene heskett wrote: | On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine: | > On 11/07/2011 11:40 AM, gene heskett wrote: | > > Down toward the bottom of the file, the tab indentations were as high | > > as 33 leading tabs per line. Each stanza of the data was tab | > > indented 2 additional tabs from the one above it in the original | > > file. 30k was perhaps a poor SWAG, but 10 to 15k seems an entirely | > > reasonable guess. | > | > What program are you using to read the file and support that claim? | | vim. But remember, this first one started out as a copy/paste from the | firefox-7.0.1 screen. I don't suppose you had autoident turned on? I hate using cu/paste to fetch data; _always_ use a "download" link, or use the browser's "save page as" facility. But still, if your MD5 checksums now match... Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Footnotes that extend to a second page are an abject failure of design. - Bringhurst, _The Elements of Typographic Style_ From lie.1296 at gmail.com Tue Nov 8 00:09:56 2011 From: lie.1296 at gmail.com (Lie Ryan) Date: Tue, 08 Nov 2011 16:09:56 +1100 Subject: Python ORMs Supporting POPOs and Substituting Layers in Django In-Reply-To: References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: On 11/08/2011 01:21 PM, Travis Parks wrote: > On Nov 7, 12:44 pm, John Gordon wrote: >> In John Gordon writes: >> >>> In<415d875d-bc6d-4e69-bcf8-39754b450... at n18g2000vbv.googlegroups.com> Travis Parks writes: >>>> Which web frameworks have people here used and which have they found >>>> to be: scalable, RAD compatible, performant, stable and/or providing >>>> good community support? I am really trying to get as much feedback as >>> I've used Django and it seems to be a very nice framework. However I've >>> only done one project so I haven't delved too deeply. >> >> You are probably looking for more detail than "It's a nice framework" :-) >> >> The database model in Django is powerful; it allows you to do queries in >> native Python code without delving into backend SQL stuff. >> >> I don't know how scalable/performant the database model is, as the one >> project I worked on didn't deal with a ton of data. (But I'd be surprised >> if it had poor performance.) >> >> The URL dispatcher provides a very nice and logical way to associate a >> given URL with a given method call. >> >> Community support is excellent. >> >> -- >> John Gordon A is for Amy, who fell down the stairs >> gor... at panix.com B is for Basil, assaulted by bears >> -- Edward Gorey, "The Gashlycrumb Tinies" > > I started the battle today. The "new guy" was trying to sell me on > CodeIgnitor. I haven't looked at it, but it is PHP, so I really want > to avoid it. The good thing is that all of his "friends" have been > telling him to get into Python. I have been trying to convince him > that PHP isn't cut out for background services and is mostly a front- > end language. Python is much more geared towards hardcore data > processing. Why write the system in two languages? > > I have been spending a lot of time looking at the Pyramid project: the > next generation of the Pylons project. It looks powerful, but it seems > to be a lot more complex than Django. CodeIgniter is a very fine framework, however it builds on top of a shitty excuse of a language called PHP. I've found that Django has a much better debugging tools; when a Django page produces an exception, it would always produce a useful error page. I haven't been able to do the same in CodeIgniter (nor in any PHP framework I've used, I'm starting to think it's a language limitation); often when you have errors, PHP would just silently return empty or partial pages even with all the debugging flags on. IMO, Python has a much nicer choice of built-in data structure for data processing. Python has a much more mature object-orientation, e.g. I prefer writing l.append(x) rather than array_push(l, x). I think these qualities are what makes you think Python is much, much more suitable for data processing than PHP; and I wholesomely agree. Database abstraction-wise, Django's ORM wins hands down against CodeIgniter's ActiveRecord. CodeIgniter's ActiveRecord is basically just a thin wrapper that abstracts the perks of various database engine. Django's ORM is a full blown ORM, it handles foreign key relationships in OO way. The only disadvantage of Django's ORM is that since it's written in Python, if you need to write a program working on the same database that doesn't use Django nor Python, then you'll have a problem since you'll have to duplicate the foreign key relationships. With all the bashing of PHP, PHP do have a few advantages. PHP and CodeIgniter is much easier to set up and running than Django; and the ability to create a .php file and have it running without having to write the routing file is sometimes a bliss. And PHP are often used as their own templating language; in contrast with Django which uses a separate templating language. Having a full blown language as your templating language can be a double-edged sword, but it is useful nevertheless for experimental work. IMO, while it is easier to get up and running in PHP, in the long run Python is much better in almost any other aspects. From simeon.chaos at gmail.com Tue Nov 8 00:10:59 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Mon, 7 Nov 2011 21:10:59 -0800 (PST) Subject: overview on dao Message-ID: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> Dao is a a functional logic solver (similar to lambdaProlog, Curry) written in python. The links related to dao are here: pypi distribution and document: http://pypi.python.org/pypi/daot code repository: https://github.com/chaosim/dao dao groups on google: Group name: daot, Group home page: http://groups.google.com/group/daot, Group email address: daot at googlegroups.com old stuffs: http://code.google.com/p/daot(old, deprecated) google+ pages: https://plus.google.com/112050694070234685790 Dao has the features such as * lisp style programming: * call/cc, block/return-from, unwind-protect, catch/throw; Dao is implemented by continuation passing style, so it is natural to implement such stuff. And I have some little improvement to the trampoline technology because I need it coexist with the technology of using yield statement to implement unifying and backtracking. The code for evaluating lisp style expression is borrowed from the book "Lisp in Small Pieces" wrote by Christian Queinnec and Ecole Polytechnique. * function and macro; The concept of function and macro in dao become more general than in lisp, because we can define them with multiple rules and take advantage of unifying and backtracking. * eval, so called meta circular evaluation. * prolog style programming: * logic variable and unify; * backtracking; * findall, repeat/fail, call, once, and so on; * cut. At first, unify is implemented by using exception, and backtracking by using two continuations(succeed continuation and fail continuation) technology, borrowed the code from pypy prolog. Now, the fail continuation is removed, and both unifying and backtracking is implemented by using 'yield' statement, which I learned from YieldProlog (http://yieldprolog.sourceforge.net). Dao run faster than before by using yield statement, removing class definition of continuation, and not boxing atomic and list values(compare to pypy prolog without translation or jit). Up to now I do not use the pypy's translation or jit feature to speedup, and all of the tests in dao 0.7.3 run in about two minutes. * many other useful builtins that simulate lisp and prolog primitives. * some builtins that cooperate with python. * builtin parser, which is the most powerful parser I have seen. The parser in dao is basically a recursive decent parser with backtracking, but It also support direct or indirect left recursive rules by using memorization when needed. The programmer can toggle memorization of any command that is not left recursive. the grammar in dao is some similar to DCG(definite clause grammar), but is more flexible than DCG. It have the expressive power beyond context free or sensitive grammar, parsing expression grammar. Dao can be used to parse any object, not limiting to text. Many builtin terminal and combinative parsing primitives are provided. In dao, I have found and implemented the unrivalled technology to uniting parser and evaluator by the meta circular evaluation. So Dao can be used to implement a programming language in which the syntax is dynamic, that is to say, the syntax can be defined on the fly by the programmer easily. A little sample to demonstrate this technology is given in the files dao/samples/sexpression.py and dao/dao/tests/ testsexpresson.py. ------------------------------------------------------------------------- Dinpy: a child language born and live in python. Dinpy can be looked as the syntax sugar for dao in python. It arises accidentally when I wrote tests for dao. A detailed introduction is as follows: I hate the too many parentheses when I wrote tests for the 'let' statement of lisp, so I replace embedded tuples with dict for the bindings, and after the spark of inspiration, the door to dinpy was open. I learned a new method for inventing a new language from it: use the syntax based on the operator of the mother language for building the child language. -------------------------------------------------------------------------- I have written some Chinese documents for dao, but few English. The Chinese document is not complete yet. With the functional logic programming and dynamic grammar on the shoulders of the great python, many possibilities arises with dao, such as parsing, inventing embedded DSL with operator syntax, independent domain specific language or general language, text processing, natural language processing, expert system, artificial intelligence, web application, and so on. Now: * I hope more people know and use dao. Or maybe something wrong in dao prevent it being used in real application, and I hope to know what it is. * Maybe anyone have interest and time to join in developing dao or writing some documents or articles? * More tests are needed always, and I hope to get some bug report from any other people. * the benchmarks of the dao, comparation with similar package, and so on. * I have a long todo list, I hope someone else can join in dao project. From lie.1296 at gmail.com Tue Nov 8 00:29:25 2011 From: lie.1296 at gmail.com (Lie Ryan) Date: Tue, 08 Nov 2011 16:29:25 +1100 Subject: Question about 'iterable cursors' In-Reply-To: <4eb77503$0$1692$742ec2ed@news.sonic.net> References: <87pqh54nmh.fsf@dpt-info.u-strasbg.fr> <4eb77503$0$1692$742ec2ed@news.sonic.net> Message-ID: On 11/07/2011 05:04 PM, John Nagle wrote: > Realize that SQLite is not a high-performance multi-user database. > You use SQLite to store your browser preferences, not your customer > database. I agree with SQLite is not multi-user; I disagree that SQLite is not a high-performance database. In single user cases, SQLite should far outperform a client-server-based database engine since it doesn't have the client-server overhead. From simeon.chaos at gmail.com Tue Nov 8 00:34:55 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Mon, 7 Nov 2011 21:34:55 -0800 (PST) Subject: simpler over view on dao: a functional logic solver with builtin parsing power, and dinpy, the sugar syntax for dao in python Message-ID: Dao is a a functional logic solver (similar to lambdaProlog, Curry) written in python. The links related to dao are here: pypi distribution and document: http://pypi.python.org/pypi/daot code repository: https://github.com/chaosim/dao dao groups on google: http://groups.google.com/group/daot, daot at googlegroups.com old stuffs: http://code.google.com/p/daot(old, deprecated) google+ pages: https://plus.google.com/112050694070234685790 Dao has the features such as * lisp style programming: * call/cc, block/return-from, unwind-protect, catch/throw; * function and macro; * eval, so called meta circular evaluation. * prolog style programming: * logic variable and unify; * backtracking; * findall, repeat/fail, call, once, and so on; * cut. * many other useful builtins that simulate lisp and prolog primitives. * some builtins that cooperate with python. * builtin parser, which is the most powerful parser I have seen, it support the features as below: * paramater grammar, similar to DCG( definite clause grammar), but more flexible * dynamic grammar, * left recursive * memoriaziont parsing result * many builtins, include terminal and cominative matchers. ------------------------------------------------------------------------- Dinpy: a child language born and live in python. Dinpy can be looked as the syntax sugar for dao in python. A piece of code in dinpy is listed as below: parse_text(char(x1)+any(~char('b')+some(char(x1)))+eoi, 'abaaaa'), let( i<<0 ). do[ repeat, prin(i), ++i, iff(i<3).do[fail] ], letr( a << fun(x) [ and_p(b(x),c(x)) ] [ d(x) ], b << fun(1) ['b1'] (4) ['b4'], c << fun(4) ['c4'], d << fun(3) ['d3'], ).do[ a(x), prin(x) ], each(i)[1:3]. loop[prin(i)], i << 0, loop[ i << i+1, prin(i)].when(i==3), case(1). of(1)[prin(1)]. of(2)[prin(2)] -------------------------------------------------------------------------- Some Chinese documents for dao is written, but few English. The Chinese document is not complete yet. With the functional logic programming and dynamic grammar on the shoulders of the great python, many possibilities arises with dao, such as parsing, inventing embedded DSL with operator syntax, independent domain specific language or general language, text processing, natural language processing, expert system, artificial intelligence, web application, and so on. Now: * I hope more people know and use dao. Or maybe something wrong in dao prevent it being used in real application, and I hope to know what it is. * Maybe anyone have interest and time to join in developing dao or writing some documents or articles? * More tests are needed always, and I hope to get some bug report from any other people. * the benchmarks of the dao, comparation with similar package, and so on. * I have a long todo list, I hope someone else can join in dao project. From steve+comp.lang.python at pearwood.info Tue Nov 8 00:58:17 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Nov 2011 05:58:17 GMT Subject: How to mix-in __getattr__ after the fact? References: <4630c4d0-86bc-4295-8bbb-6f58415191c8@v15g2000vbm.googlegroups.com> <4EAAF264.1050307@stoneleaf.us> <8bc11029-860e-4d3a-8770-062e16e31514@j39g2000yqc.googlegroups.com> Message-ID: <4eb8c4f9$0$29988$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Nov 2011 15:17:14 +1100, Lie Ryan wrote: > On 10/31/2011 11:01 PM, dhyams wrote: >> >> Thanks for all of the responses; everyone was exactly correct, and >> obeying the binding rules for special methods did work in the example >> above. Unfortunately, I only have read-only access to the class itself >> (it was a VTK class wrapped with SWIG), so I had to find another way to >> accomplish what I was after. >> >> > As a big huge hack, you can always write a wrapper class: > > class Wrapper(object): > def __init__(self, *args, **kwargs): > self.__object = MySWIGClass(*args, **kwargs) > def __getattr__(self, attr): > try: > return getattr(self.__object, attr) > except AttributeError: > ... That's not a hack, that's a well-respected design pattern called Delegation. http://rosettacode.org/wiki/Delegate http://en.wikipedia.org/wiki/Delegation_pattern In this case, you've implemented about half of automatic delegation: http://code.activestate.com/recipes/52295 which used to be much more important in Python prior to the type/class unification in version 2.2. To also delegate special dunder methods using new-style classes, see this: http://code.activestate.com/recipes/252151 -- Steven From gheskett at wdtv.com Tue Nov 8 01:29:46 2011 From: gheskett at wdtv.com (gene heskett) Date: Tue, 8 Nov 2011 01:29:46 -0500 Subject: Python lesson please In-Reply-To: <20111108045900.GA12613@cskk.homeip.net> References: <201111071500.49230.gheskett@wdtv.com> <20111108045900.GA12613@cskk.homeip.net> Message-ID: <201111080129.46728.gheskett@wdtv.com> On Tuesday, November 08, 2011 12:53:20 AM Cameron Simpson did opine: > On 07Nov2011 15:00, gene heskett wrote: > | On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine: > | > On 11/07/2011 11:40 AM, gene heskett wrote: > | > > Down toward the bottom of the file, the tab indentations were as > | > > high as 33 leading tabs per line. Each stanza of the data was > | > > tab indented 2 additional tabs from the one above it in the > | > > original file. 30k was perhaps a poor SWAG, but 10 to 15k seems > | > > an entirely reasonable guess. > | > > | > What program are you using to read the file and support that claim? > | > | vim. But remember, this first one started out as a copy/paste from > | the firefox-7.0.1 screen. > > I don't suppose you had autoident turned on? > I think it is. I gave up turning it off long ago because it was always on on the next launch. Today I've forgotten how to turn it off. Like hitting oneself in the head with a hammer, it feels so good when you stop. :) > I hate using cu/paste to fetch data; _always_ use a "download" link, or > use the browser's "save page as" facility. Which would have saved all the html codes too, this code was being displayed in a window of the main window. > But still, if your MD5 checksums now match... Not on that file, but on the next pull it was, and works now. And on the first file, the blink compare disclosed I had some indentation wrong, and that there was a lowercase b in front of all the opening double quotes used that I didn't get originally. I have no clue what this: b"hex data" means to python. > Cheers, Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: To love is good, love being difficult. From rosuav at gmail.com Tue Nov 8 01:42:20 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 17:42:20 +1100 Subject: Python lesson please In-Reply-To: <201111080129.46728.gheskett@wdtv.com> References: <201111071500.49230.gheskett@wdtv.com> <20111108045900.GA12613@cskk.homeip.net> <201111080129.46728.gheskett@wdtv.com> Message-ID: On Tue, Nov 8, 2011 at 5:29 PM, gene heskett wrote: > Not on that file, but on the next pull it was, and works now. ?And on the > first file, the blink compare disclosed I had some indentation wrong, and > that there was a lowercase b in front of all the opening double quotes used > that I didn't get originally. ?I have no clue what this: > ? ? ? ?b"hex data" means to python. That's the repr() of a Bytes string (as opposed to a Unicode string) in Python 3. If that's your only issue, I'd say you have it working fine under Python 3; if there are other problems, try running it under Python 2.7. ChrisA From moky.math at gmail.com Tue Nov 8 02:07:39 2011 From: moky.math at gmail.com (Laurent Claessens) Date: Tue, 08 Nov 2011 08:07:39 +0100 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: Le 07/11/2011 19:01, JoeM a ?crit : > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > > [x.remove(x[0]) for x in [a,b,c]] > > cheating? It seems compact and elegant enough for me. I have the feeling that it does not do what I expect it does just by seeing the line. It is list comprehension, but the point is absolutely not in creating a list. I'd say it breaks the rule ?Explicit is better than implicit.? while ?Special cases aren't special enough to break the rules.? But well... could be a matter of taste; I prefer the loop. Laurent From rosuav at gmail.com Tue Nov 8 02:35:32 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 18:35:32 +1100 Subject: Python ORMs Supporting POPOs and Substituting Layers in Django In-Reply-To: References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: On Tue, Nov 8, 2011 at 4:09 PM, Lie Ryan wrote: > IMO, Python has a much nicer choice of built-in data structure for data > processing. Python has a much more mature object-orientation, e.g. I prefer > writing l.append(x) rather than array_push(l, x). I think these qualities > are what makes you think Python is much, much more suitable for data > processing than PHP; and I wholesomely agree. > Two more examples where Python's lists are superior to PHP's arrays. Array literal syntax feels like a function call, but list literals are slim and easy to use inside expressions (try creating a nested array as a function argument - you'll get a forest of parens). Also, dereferencing an array only works on an array variable - if you have a function that returns an array, you can't dereference it directly: $foo = func()[1]; # doesn't work $foo = func(); $foo=$foo[1]; # works I much prefer the "everything's an object" notion. C's array literals are just as weird (although in C, you can directly dereference a literal character array - "ABCDEFG"[note_idx] will give you a note name as a char)... much easier when a variable name is just an expression, a function call is an expression, a literal is an expression, and you can work with them all the same way. ChrisA From vaira20ster at gmail.com Tue Nov 8 05:05:53 2011 From: vaira20ster at gmail.com (vaira muthu) Date: Tue, 8 Nov 2011 15:35:53 +0530 Subject: file extension while saving Python files Message-ID: Team, In Python IDE, while we save the script, it will prompt the save Dialog. If we specify the filename as "Test". Then file will be saved without extension as "Test" and not "Test.py". Is it possible to save the script with .py extension automatically (as Test.py)? Thanks, vairamuthu. From lycka at carmen.se Tue Nov 8 05:50:53 2011 From: lycka at carmen.se (=?ISO-8859-1?Q?Magnus_Lyck=E5?=) Date: Tue, 08 Nov 2011 11:50:53 +0100 Subject: file extension while saving Python files In-Reply-To: References: Message-ID: On 2011-11-08 11:05, vaira muthu wrote: > In Python IDE, ... Which Python IDE? There are dozens: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments From hfaber at invalid.net Tue Nov 8 07:09:20 2011 From: hfaber at invalid.net (Henrik Faber) Date: Tue, 08 Nov 2011 13:09:20 +0100 Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On 07.11.2011 23:06, Chris Angelico wrote: > On Tue, Nov 8, 2011 at 8:46 AM, david vierra wrote: >> But, you didn't write an all() function. You wrote a more specialized >> allBoolean() function. I think this comparison is more fair to the >> builtin all(): > > So really, it's not "all() is slow" but "function calls are slow". > Maybe it'd be worthwhile making an all-factory: PLEASE say you're joking. If I saw code like that on any of our project, this would definitely qualify for a DailyWTF. Regards, Henrik From rosuav at gmail.com Tue Nov 8 07:14:09 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 23:14:09 +1100 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On Tue, Nov 8, 2011 at 11:09 PM, Henrik Faber wrote: > On 07.11.2011 23:06, Chris Angelico wrote: >> So really, it's not "all() is slow" but "function calls are slow". >> Maybe it'd be worthwhile making an all-factory: > > PLEASE say you're joking. If I saw code like that on any of our project, > this would definitely qualify for a DailyWTF. For the benefit of anyone who was actually in doubt: YES, I was joking. Do *not* put code like this into any production project. But it's still fun to write bad code once in a while. It's like Mythbusters getting to crash cars. Fun partly _because_ it's something you normally don't want to do. ChrisA From d at davea.name Tue Nov 8 07:58:19 2011 From: d at davea.name (Dave Angel) Date: Tue, 08 Nov 2011 07:58:19 -0500 Subject: Python ORMs Supporting POPOs and Substituting Layers in Django In-Reply-To: References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: <4EB9276B.7070207@davea.name> On 11/08/2011 02:35 AM, Chris Angelico wrote: > On Tue, Nov 8, 2011 at 4:09 PM, Lie Ryan wrote: > > I much prefer the "everything's an object" notion. C's array literals > are just as weird (although in C, you can directly dereference a > literal character array - "ABCDEFG"[note_idx] will give you a note > name as a char) Hey, in C you can also do note_idx["ABCDEFG"] and get the selected character as if you had written what you showed. Plenty of opportunity in C to write illegible code. -- DaveA From gnarlodious at gmail.com Tue Nov 8 08:20:51 2011 From: gnarlodious at gmail.com (Gnarlodious) Date: Tue, 8 Nov 2011 05:20:51 -0800 (PST) Subject: Help catching error message Message-ID: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> What I say is this: def SaveEvents(self,events): try: plistlib.writePlist(events, self.path+'/Data/Events.plist') # None if OK except IOError: return "IOError: [Errno 13] Apache can't write Events.plist file" Note that success returns"None" while failure returns a string. I catch the error like this: errorStatus=Data.Dict.SaveEvents(Data.Plist.Events) if errorStatus: content=errorStatus It works, but isn there a more elegant way to do it? As in, one line? I can imagine if success returned nothing then content would remain unchanged. Isn't there a built-in way to send an error string back and then catch it as a variable name? This is Py3 inside WSGI. -- Gnarlie From garyfallidis at gmail.com Tue Nov 8 08:21:29 2011 From: garyfallidis at gmail.com (Eleftherios Garyfallidis) Date: Tue, 8 Nov 2011 14:21:29 +0100 Subject: ctypes accessing functions with double pointers In-Reply-To: References: Message-ID: Thank you Chris :-) On Mon, Nov 7, 2011 at 11:29 PM, Chris Rebert wrote: > On Mon, Nov 7, 2011 at 2:06 PM, Eleftherios Garyfallidis > wrote: > > Hello, > > > > Is it possible using ctypes to call C functions from a shared object > > containing double pointers e.g. int foo(float **i) and if yes how? > > (Untested conjecture:) > > import ctypes > # ...create ctypes_wrapped_foo... > the_float = ctypes.c_float(42.1) > float_ptr = ctypes.byref(the_float) > i = ctypes.byref(float_ptr) > result_integer = ctypes_wrapped_foo(i) > > Cheers, > Chris > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon at panix.com Tue Nov 8 10:17:19 2011 From: gordon at panix.com (John Gordon) Date: Tue, 8 Nov 2011 15:17:19 +0000 (UTC) Subject: file extension while saving Python files References: Message-ID: In vaira muthu writes: > Team, > In Python IDE, while we save the script, it will prompt the save > Dialog. If we specify the filename as "Test". Then file will be saved > without extension as "Test" and not "Test.py". Is there a drop-down list selection for specifying the file type? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From rajcspalani at gmail.com Tue Nov 8 10:53:52 2011 From: rajcspalani at gmail.com (mannan) Date: Tue, 8 Nov 2011 07:53:52 -0800 (PST) Subject: file extension while saving Python files In-Reply-To: References: Message-ID: <6395.778.1320767632967.JavaMail.geo-discussion-forums@prap37> if it is not a python ide then, you have to explicitly specify the extension. From rajcspalani at gmail.com Tue Nov 8 10:53:52 2011 From: rajcspalani at gmail.com (mannan) Date: Tue, 8 Nov 2011 07:53:52 -0800 (PST) Subject: file extension while saving Python files In-Reply-To: References: Message-ID: <6395.778.1320767632967.JavaMail.geo-discussion-forums@prap37> if it is not a python ide then, you have to explicitly specify the extension. From jeanmichel at sequans.com Tue Nov 8 12:15:40 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 08 Nov 2011 18:15:40 +0100 Subject: Help catching error message In-Reply-To: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> Message-ID: <4EB963BC.7080506@sequans.com> Gnarlodious wrote: > What I say is this: > > def SaveEvents(self,events): > try: > plistlib.writePlist(events, self.path+'/Data/Events.plist') # > None if OK > except IOError: > return "IOError: [Errno 13] Apache can't write Events.plist > file" > > Note that success returns"None" while failure returns a string. > > I catch the error like this: > > errorStatus=Data.Dict.SaveEvents(Data.Plist.Events) > if errorStatus: content=errorStatus > > It works, but isn there a more elegant way to do it? As in, one line? > I can imagine if success returned nothing then content would remain > unchanged. Isn't there a built-in way to send an error string back and > then catch it as a variable name? > > This is Py3 inside WSGI. > > -- Gnarlie > Hi, There's no need to rephrase an exception unless you want to *add* information. def saveEvents(self,events): plistlib.writePlist(events, self.path+'/Data/Events.plist') try: Data.Dict.SaveEvents(Data.Plist.Events) except IOError, exc: # i'm using python 2.5, this except clause may have changed in py3 content = str(exc) JM From jeanmichel at sequans.com Tue Nov 8 12:24:30 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 08 Nov 2011 18:24:30 +0100 Subject: Help catching error message In-Reply-To: <4EB963BC.7080506@sequans.com> References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> <4EB963BC.7080506@sequans.com> Message-ID: <4EB965CE.4020300@sequans.com> Jean-Michel Pichavant wrote: > Gnarlodious wrote: >> What I say is this: >> >> def SaveEvents(self,events): >> try: >> plistlib.writePlist(events, self.path+'/Data/Events.plist') # >> None if OK >> except IOError: >> return "IOError: [Errno 13] Apache can't write Events.plist >> file" >> >> Note that success returns"None" while failure returns a string. >> >> I catch the error like this: >> >> errorStatus=Data.Dict.SaveEvents(Data.Plist.Events) >> if errorStatus: content=errorStatus >> >> It works, but isn there a more elegant way to do it? As in, one line? >> I can imagine if success returned nothing then content would remain >> unchanged. Isn't there a built-in way to send an error string back and >> then catch it as a variable name? >> >> This is Py3 inside WSGI. >> >> -- Gnarlie >> > Hi, > > There's no need to rephrase an exception unless you want to *add* > information. > > def saveEvents(self,events): > plistlib.writePlist(events, self.path+'/Data/Events.plist') > try: Data.Dict.SaveEvents(Data.Plist.Events) > except IOError, exc: # i'm using python 2.5, this except clause may > have changed in py3 > content = str(exc) > > JM > looks like for whatever reason the formating has gone crazy. http://www.copypastecode.com/100088/ jm From nad at acm.org Tue Nov 8 12:28:28 2011 From: nad at acm.org (Ned Deily) Date: Tue, 08 Nov 2011 09:28:28 -0800 Subject: file extension while saving Python files References: Message-ID: In article , vaira muthu wrote: > In Python IDE, while we save the script, it will prompt the save > Dialog. If we specify the filename as "Test". Then file will be saved > without extension as "Test" and not "Test.py". > > Is it possible to save the script with .py extension automatically (as > Test.py)? If the IDE you are referring to is IDLE, there is an issue recently opened that requests this change: http://bugs.python.org/issue10364 -- Ned Deily, nad at acm.org From tjreedy at udel.edu Tue Nov 8 14:09:18 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 08 Nov 2011 14:09:18 -0500 Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: On 11/7/2011 11:32 PM, Makoto Kuwata wrote: > I got trouble about easy_install command. > > My package: > > README.rst > setup.py > foobar/ > foobar/__init__.py > foobar/data/ > foobar/data/template.py > > In the above example, 'foobar/data/template.py' is just a > template data file (= not a python module file). Then why is it .py? If it is just data, use .txt. If .py, it should be python code run either directly or imported, though I suppose you could exec it. (I have no idea how renaming would affect your problem.) > (notice that 'foobar/data/__init__.py' doesn't exist.) I did, and no, I do not know the answer to your question. -- Terry Jan Reedy From anikom15 at gmail.com Tue Nov 8 14:11:58 2011 From: anikom15 at gmail.com (Westley =?iso-8859-1?Q?Mart=EDnez?=) Date: Tue, 8 Nov 2011 11:11:58 -0800 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: <20111108191158.GA21926@kubrick> On Fri, Nov 04, 2011 at 11:10:58AM -0400, Steven Lehar wrote: > Is this the right place to propose language extensions? > > My Python code keeps expanding rightwards, it is difficult to keep it > contained within reasonable limits. But the standard line continuation \ > is positively anti-Pythonic because an *invisible* white space between \ > and [CR] will render it useless. > > How about a new Python symbol, maybe \\ that CAN have following whitespace > which is ignored, so that seeing a \\ in the code forces it to continue on > the next line. > > Has this issue been discussed already? > > slehar Use subroutines. From ramit.prasad at jpmorgan.com Tue Nov 8 14:34:30 2011 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 8 Nov 2011 14:34:30 -0500 Subject: xml-rpc server on wine In-Reply-To: <1320685031.8941.11.camel@linux-yu4c.site> References: <650e9d68-e606-4424-bca7-174295306d82@ht6g2000vbb.googlegroups.com> <1320685031.8941.11.camel@linux-yu4c.site> Message-ID: <0604E20B5F6F2F4784C9C8C71C5DD4DD2FDF6DE578@EMARC112VS01.exchad.jpmchase.net> >> Hi, I have a XML-RPC server python running on VM Windows (on Linux) >> and a XML-RPC client python on Linux. Server and client have different >> IP address. I'd like migrate server on wine. How can communicate >> server and client? IP address is different or is the same? >> Can you help me? >Not really, this doesn't have much of anything to do with Python. If >you run a network application on wine [assuming that even works] the >application will have the same IP/interface as any other application or >service running on the host. Wine is not a 'virtualization' solution. Unless you have a specific need to run it in a virtual machine (which WINE is not), why not run it directly from Linux? I generally prefer to use a DNS name or hostname to connect instead of IP because the IP addresses can be dynamic (especially when you start accessing it from outside your local network). Even internally, I tend to use hostnames and not IP addresses, but mostly because it is faster/easier for me to type (I assign static IPs internally). Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From steve+comp.lang.python at pearwood.info Tue Nov 8 17:16:33 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Nov 2011 22:16:33 GMT Subject: Help catching error message References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> Message-ID: <4eb9aa41$0$29970$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Nov 2011 05:20:51 -0800, Gnarlodious wrote: > What I say is this: > > def SaveEvents(self,events): > try: > plistlib.writePlist(events, self.path+'/Data/Events.plist') # > None if OK > except IOError: > return "IOError: [Errno 13] Apache can't write Events.plist > file" > > Note that success returns"None" while failure returns a string. I started off writing a sarcastic response about people who refuse to learn idiomatic Python and instead insist on writing (e.g.) Java or PHPP in Python. But then I eventually got to the *very last line* of your post where you noted that you were doing this in WSGI. For future reference, when writing unidiomatic code *deliberately*, please say so up front, at the start of your message rather than at the end, and save your readers (or at least *me*) from jumping to the wrong conclusion. Change the function to this: def SaveEvents(self,events): try: plistlib.writePlist(events, self.path+'/Data/Events.plist') return '' except IOError as e: return str(e) # or if you prefer, your own custom error string # "IOError: [Errno 13] Apache can't write Events.plist file" I return a string in both cases so that you can, if you choose, use the output of SaveEvents anywhere where a string is expected without worrying about whether it returns None or a string: content = Data.Dict.SaveEvents(Data.Plist.Events) # content will be the empty string if no error, otherwise error message. If you don't care about that, just delete the return '' line and the function will fall back on returning None by default. Either way, you can also use it like this: content = Data.Dict.SaveEvents(Data.Plist.Events) or content This will leave content unchanged if no error is returned, otherwise it will replace the value. Note that content must have an initial value to start with (presumably the empty string). -- Steven From no at mail.de Tue Nov 8 17:19:13 2011 From: no at mail.de (MrSmile) Date: Tue, 08 Nov 2011 23:19:13 +0100 Subject: getting command line in python Message-ID: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Hi people! I am looking for a way to get the command line in the script. Let us say I am in the folder "/tmp" okay! now from /tmp I execute in the console this: python /home/tamer/MyApp/MyScript.py in the app itself, I want to grep the path and the scriptname itself, like: /home/tamer/MyApp is being somewhere available. Tamer From irmen.NOSPAM at xs4all.nl Tue Nov 8 17:24:58 2011 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Tue, 08 Nov 2011 23:24:58 +0100 Subject: getting command line in python In-Reply-To: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <4eb9ac3b$0$6908$e4fe514c@news2.news.xs4all.nl> On 8-11-2011 23:19, MrSmile wrote: > Hi people! > I am looking for a way to get the command line in the script. > > Let us say I am in the folder "/tmp" okay! > > now from /tmp I execute in the console this: > python /home/tamer/MyApp/MyScript.py > > in the app itself, I want to grep the path and the scriptname itself, > like: /home/tamer/MyApp is being somewhere available. > > > Tamer sys.argv Irmen From clp2 at rebertia.com Tue Nov 8 17:32:30 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 8 Nov 2011 14:32:30 -0800 Subject: getting command line in python In-Reply-To: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Message-ID: On Tue, Nov 8, 2011 at 2:19 PM, MrSmile wrote: > Hi people! > I am looking for a way to get the command line in the script. > > Let us say I am in the folder "/tmp" okay! > > now from /tmp I execute in the console this: > python /home/tamer/MyApp/MyScript.py > > in the app itself, I want to grep the path and the scriptname itself, > like: /home/tamer/MyApp is being somewhere available. Under your example conditions: sys.argv[0] will be "/home/tamer/MyApp/MyScript.py". (A) os.getcwd() will return "/tmp". (B) The `os.path` module is also very relevant: http://docs.python.org/library/os.path.html Cheers, Chris -- http://rebertia.com (A): http://docs.python.org/library/sys.html#sys.argv (B): http://docs.python.org/library/os.html#os.getcwd From cs at zip.com.au Tue Nov 8 17:32:38 2011 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 9 Nov 2011 09:32:38 +1100 Subject: getting command line in python In-Reply-To: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <20111108223238.GA24364@cskk.homeip.net> On 08Nov2011 23:19, MrSmile wrote: | I am looking for a way to get the command line in the script. | | Let us say I am in the folder "/tmp" okay! | | now from /tmp I execute in the console this: | python /home/tamer/MyApp/MyScript.py | | in the app itself, I want to grep the path and the scriptname itself, | like: /home/tamer/MyApp is being somewhere available. Have you looked in sys.argv[0]? -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ It is not true that life is one damn thing after another -- it's one damn thing over and over. - Edna St. Vincent Millay From no at mail.de Tue Nov 8 17:36:13 2011 From: no at mail.de (MrSmile) Date: Tue, 08 Nov 2011 23:36:13 +0100 Subject: getting command line in python In-Reply-To: References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <4eb9aedd$0$6567$9b4e6d93@newsspool4.arcor-online.net> Thank you all, that was it that I was searching for you. Tamer Am 08.11.2011 23:32, schrieb Cameron Simpson: > On 08Nov2011 23:19, MrSmile wrote: > | I am looking for a way to get the command line in the script. > | > | Let us say I am in the folder "/tmp" okay! > | > | now from /tmp I execute in the console this: > | python /home/tamer/MyApp/MyScript.py > | > | in the app itself, I want to grep the path and the scriptname itself, > | like: /home/tamer/MyApp is being somewhere available. > > Have you looked in sys.argv[0]? From jjposner at optimum.net Tue Nov 8 17:51:27 2011 From: jjposner at optimum.net (John Posner) Date: Tue, 08 Nov 2011 17:51:27 -0500 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: <4EB9B26F.3050704@optimum.net> On 2:59 PM, Chris Angelico wrote: >>> So really, it's not "all() is slow" but "function calls are slow". >>> Maybe it'd be worthwhile making an all-factory: >> PLEASE say you're joking. If I saw code like that on any of our project, >> this would definitely qualify for a DailyWTF. > For the benefit of anyone who was actually in doubt: YES, I was > joking. Do *not* put code like this into any production project. Because an all-factory would produce code smell? :-) From tim at akwebsoft.com Tue Nov 8 18:54:12 2011 From: tim at akwebsoft.com (Tim Johnson) Date: Tue, 8 Nov 2011 14:54:12 -0900 Subject: Decouplable CMS in python? Message-ID: <20111108235412.GK3736@akwebsoft.com> :)I'm sure decouplable is a word. If not it should be. I have written my own framework. This has been a work in progress as a consequence of projects that I have done over the last 10 years. I need a CMS that sits "on top of" the framework. One of the starting points that I have considered is finding a fairly simple, but well-written CMS in python and adapting it. It may very well turn out that I would have to start from 'scratch', nevertheless, reviewing code for such a simple CMS would be informative. I'm thinking that, as an example - django-cms - would be too complex, regardless of its merits. Any recommendations? thanks -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com From python.list at tim.thechases.com Tue Nov 8 18:56:48 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 08 Nov 2011 17:56:48 -0600 Subject: all() is slow? In-Reply-To: <4EB9B26F.3050704@optimum.net> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4EB9B26F.3050704@optimum.net> Message-ID: <4EB9C1C0.2050302@tim.thechases.com> On 11/08/2011 04:51 PM, John Posner wrote: > On 2:59 PM, Chris Angelico wrote: > >>>> So really, it's not "all() is slow" but "function calls are slow". >>>> Maybe it'd be worthwhile making an all-factory: >>> PLEASE say you're joking. If I saw code like that on any of our project, >>> this would definitely qualify for a DailyWTF. >> For the benefit of anyone who was actually in doubt: YES, I was >> joking. Do *not* put code like this into any production project. > > Because an all-factory would produce code smell? :-) Groan...that word-play is the pits! :) -tkc From simeon.chaos at gmail.com Tue Nov 8 19:13:12 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Tue, 8 Nov 2011 16:13:12 -0800 (PST) Subject: overview on dao References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> Message-ID: <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> On Nov 9, 1:52?am, Dennis Lee Bieber wrote: > On Mon, 7 Nov 2011 21:10:59 -0800 (PST), Simeon Chaos > declaimed the following in > gmane.comp.python.general: > > > Dao is a a functional logic solver (similar to lambdaProlog, Curry) > > written in python. The links related to dao are here: > > ? ? ? ? Unfortunately the name is in conflict with M$ DAO (Data Access > Objects), the precursor to ADO. Every time I see "Dao" my mind goes "JET > database". > -- > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ Yeah, here "dao" is from The book of Dao" by Laozi, means the way of the world go. From jeanpierreda at gmail.com Tue Nov 8 19:44:18 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 8 Nov 2011 19:44:18 -0500 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: Clearly what we need is a modern hygienic macro system to avoid this exec mess! defmacro defall(name, cond): def name(lst): for a in lst: if not cond: return False return True invoke defall(all, cond) Only slightly tongue in cheek. We have that stupid exec trick in the Python stdlib. It has to die. http://hg.python.org/cpython/file/6bf07db23445/Lib/collections/__init__.py#l240 Devin On Mon, Nov 7, 2011 at 5:06 PM, Chris Angelico wrote: > On Tue, Nov 8, 2011 at 8:46 AM, david vierra wrote: >> But, you didn't write an all() function. ?You wrote a more specialized >> allBoolean() function. I think this comparison is more fair to the >> builtin all(): > > So really, it's not "all() is slow" but "function calls are slow". > Maybe it'd be worthwhile making an all-factory: > > def my_all(code,lst): > ? ?exec("""def tmp_all(x): > ? ? ? ?for a in x: > ? ? ? ? ? ?if not ("""+code+"""): return False > ? ? ? ?return True > """) > ? ?return tmp_all(lst) > timeit.timeit('my_all("a in (True, False)",x)','from __main__ import > my_all,x',number=10) > > Bad code imho, but it _is_ faster than both the original and the builtin. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > From python at mrabarnett.plus.com Tue Nov 8 19:55:35 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 09 Nov 2011 00:55:35 +0000 Subject: overview on dao In-Reply-To: <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> Message-ID: <4EB9CF87.6060202@mrabarnett.plus.com> On 09/11/2011 00:13, Simeon Chaos wrote: > On Nov 9, 1:52 am, Dennis Lee Bieber wrote: >> On Mon, 7 Nov 2011 21:10:59 -0800 (PST), Simeon Chaos >> declaimed the following in >> gmane.comp.python.general: >> >>> Dao is a a functional logic solver (similar to lambdaProlog, Curry) >>> written in python. The links related to dao are here: >> >> Unfortunately the name is in conflict with M$ DAO (Data Access >> Objects), the precursor to ADO. Every time I see "Dao" my mind goes "JET >> database". >> -- >> Wulfraed Dennis Lee Bieber AF6VN >> wlfr... at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > Yeah, here "dao" is from The book of Dao" by Laozi, means the way of > the world go. Perhaps you should call it "LaoZiDao". From rosuav at gmail.com Tue Nov 8 20:19:42 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Nov 2011 12:19:42 +1100 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On Wed, Nov 9, 2011 at 11:44 AM, Devin Jeanpierre wrote: > Clearly what we need is a modern hygienic macro system to avoid this exec mess! > > defmacro defall(name, cond): > ? ?def name(lst): > ? ? ? ?for a in lst: > ? ? ? ? ? ?if not cond: > ? ? ? ? ? ? ? ?return False > ? ? ? ?return True #define defall(name,cond) def name(lst): \ for a in lst: \ if not cond: return False \ return True gcc -E myprog.pyi -o myprog.py There's no code you can't make more opaque using the C preprocessor. Python doesn't have inline functions? Ha! In your FACE, evil Python development cabal! You can't tell ME what I can't do! ChrisA PS. Don't try this at home. We have years of experience with bad code. Don't write code like this unless you have a life insurance policy that covers angry mobs. From clp2 at rebertia.com Tue Nov 8 20:30:48 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 8 Nov 2011 17:30:48 -0800 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On Tue, Nov 8, 2011 at 5:19 PM, Chris Angelico wrote: > On Wed, Nov 9, 2011 at 11:44 AM, Devin Jeanpierre > wrote: >> Clearly what we need is a modern hygienic macro system to avoid this exec mess! >> >> defmacro defall(name, cond): >> ? ?def name(lst): >> ? ? ? ?for a in lst: >> ? ? ? ? ? ?if not cond: >> ? ? ? ? ? ? ? ?return False >> ? ? ? ?return True > > #define defall(name,cond) def name(lst): \ > ? ?for a in lst: \ > ? ? ? ?if not cond: return False \ > ? ?return True > > gcc -E myprog.pyi -o myprog.py > > There's no code you can't make more opaque using the C preprocessor. > > Python doesn't have inline functions? Ha! In your FACE, evil Python > development cabal! You can't tell ME what I can't do! > > ChrisA > PS. Don't try this at home. We have years of experience with bad code. > Don't write code like this unless you have a life insurance policy > that covers angry mobs. Burn him! Witch! Witch! Burn him! His code turned me into a newt! -- Sent nailed to a coconut carried by swallow. From gnarlodious at gmail.com Tue Nov 8 20:48:57 2011 From: gnarlodious at gmail.com (Gnarlodious) Date: Tue, 8 Nov 2011 17:48:57 -0800 (PST) Subject: Help catching error message References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> <4eb9aa41$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 8, 3:16?pm, Steven D'Aprano wrote: > content = Data.Dict.SaveEvents(Data.Plist.Events) or content > > This will leave content unchanged if no error is returned, otherwise it > will replace the value. Ah, the 'or' operator does it. Thank you, that is exactly what I was looking for. I should confess, I am not a programmer and don't even know what "idiomatic" means in this context. I don't know Java or PHP, only a little Forth from the HP calculator era. Advanced topics I just skip over because I don't understand them. But I am learning slowly and appreciate the help. -- Rachel http://Sectrum.com From steve+comp.lang.python at pearwood.info Tue Nov 8 21:47:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Nov 2011 02:47:30 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Nov 2011 19:44:18 -0500, Devin Jeanpierre wrote: > We have that stupid exec trick in the Python stdlib. It has to die. > > http://hg.python.org/cpython/file/6bf07db23445/Lib/collections/__init__.py#l240 http://bugs.python.org/issue3974 http://blog.ccpgames.com/kristjan/2011/05/28/namedtuple-and-exec/ If it were someone other than Raymond Hettinger responsible for the use of exec in namedtuple, I'd be a lot more suspicious of it. -- Steven From steve+comp.lang.python at pearwood.info Tue Nov 8 21:57:28 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Nov 2011 02:57:28 GMT Subject: Help catching error message References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> <4eb9aa41$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4eb9ec18$0$29988$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Nov 2011 17:48:57 -0800, Gnarlodious wrote: > On Nov 8, 3:16?pm, Steven D'Aprano wrote: > >> content = Data.Dict.SaveEvents(Data.Plist.Events) or content >> >> This will leave content unchanged if no error is returned, otherwise it >> will replace the value. > Ah, the 'or' operator does it. Thank you, that is exactly what I was > looking for. > > I should confess, I am not a programmer and don't even know what > "idiomatic" means in this context. I don't know Java or PHP, only a > little Forth from the HP calculator era. Advanced topics I just skip > over because I don't understand them. But I am learning slowly and > appreciate the help. Idiomatic in this context means that the code follows standard styles, patterns or techniques commonly accepted by most good programmers of the language. This implies that the code works with the language, playing to its strengths, rather than against it. Non-idiomatic code tends to be slower than it could be, or harder to read, or harder to maintain, or all three. Idiomatic is relative to the language: what is idiomatic for one language may not be for another. For instance, if I were to ask "How do I do something with each item of a list?", the idiomatic way in Python would be: for item in some_list: do_something_with(item) rather than: for i in range(len(some_list)): item = some_list[index] do_something_with(item) and especially not this: index = 0 while index < len(some_list): item = some_list[index] do_something_with(item) index += 1 Regards, -- Steven From mcepl at redhat.com Wed Nov 9 05:20:08 2011 From: mcepl at redhat.com (Matej Cepl) Date: Wed, 09 Nov 2011 11:20:08 +0100 Subject: getting command line in python In-Reply-To: <4eb9aedd$0$6567$9b4e6d93@newsspool4.arcor-online.net> References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> <4eb9aedd$0$6567$9b4e6d93@newsspool4.arcor-online.net> Message-ID: Dne 8.11.2011 23:36, MrSmile napsal(a): > Thank you all, that was it that I was searching for you. Except that most likely it wasn't the right answer. Take a look at http://docs.python.org/library/argparse.html (or optparse, if you are on Python < 2.7). Best, Mat?j From simeon.chaos at gmail.com Wed Nov 9 06:17:28 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Wed, 9 Nov 2011 03:17:28 -0800 (PST) Subject: overview on dao References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> Message-ID: <96a0fc78-aa96-4830-bc26-b3efbb75e65b@f3g2000pri.googlegroups.com> On Nov 9, 8:55?am, MRAB wrote: > On 09/11/2011 00:13, Simeon Chaos wrote: > > > > > > > > > > > On Nov 9, 1:52 am, Dennis Lee Bieber ?wrote: > >> On Mon, 7 Nov 2011 21:10:59 -0800 (PST), Simeon Chaos > >> ?declaimed the following in > >> gmane.comp.python.general: > > >>> Dao is a a functional logic solver (similar to lambdaProlog, Curry) > >>> written in python. The links related to dao are here: > > >> ? ? ? ? ?Unfortunately the name is in conflict with M$ DAO (Data Access > >> Objects), the precursor to ADO. Every time I see "Dao" my mind goes "JET > >> database". > >> -- > >> ? ? ? ? ?Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > >> ? ? ? ? ?wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ > > > Yeah, ?here "dao" is from The book of Dao" by Laozi, means the way of > > the world go. > > Perhaps you should call it "LaoZiDao". I just prefer shorter name. From Juan.Declet-Barreto at MesaAZ.gov Wed Nov 9 09:53:02 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Wed, 9 Nov 2011 07:53:02 -0700 Subject: memory management In-Reply-To: <4EB8448B.7030709@davea.name> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> <4EB8448B.7030709@davea.name> Message-ID: <3CB1190388197146B35D522652EAB501014CDF2323@MESAMAIL01.acctcom.mesa> After some exception catching, I have found that my program is throwing a MemoryError exception numerous times (~7 iterations of the main loop that processes list elements) until python25\python.exe crashes (Windows XP environment). I implemented Dave Angel's suggestions re: processing each list element (a file) as I get it. So my question would be how to begin troubleshooting the conditions under which the exception is raised. Is there any more information in the exception object about how much memory is being consumed, or any other indicators as to what led to the exception? -juan -----Original Message----- From: Dave Angel [mailto:d at davea.name] Sent: Monday, November 07, 2011 1:50 PM To: Juan Declet-Barreto Cc: python-list at python.org Subject: Re: memory management On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: > Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. You top-posted. In this mailing list, one should type new information after the quoted information, not before. Perhaps a pre-emptive strike is in order. On the assumption that it may be a memory problem, how about you turn the app inside out. Instead of walking the entire tree, getting a list with all the paths, and then working on the list, how about doing the work on each file as you get it. Or even make your own generator from os.walk, so the app can call your logic on each file, and never have all the file (name)s in memory at the same time. Generator: def filelist(top, criteria): for a, b, c in os.walk(): for fiile in files: apply some criteria yield file Now the main app can iterate through this "list" in the usual way for filename in filelist(top, "*.txt"): dosomething... -- DaveA From hansmu at xs4all.nl Wed Nov 9 10:41:08 2011 From: hansmu at xs4all.nl (Hans Mulder) Date: Wed, 09 Nov 2011 16:41:08 +0100 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: <4eba9f14$0$6987$e4fe514c@news2.news.xs4all.nl> On 9/11/11 02:30:48, Chris Rebert wrote: > Burn him! Witch! Witch! Burn him! > His code turned me into a newt! > -- > Sent nailed to a coconut carried by swallow. Is that a European swallow or an African swallow? -- HansM From dihedral88888 at googlemail.com Wed Nov 9 10:56:01 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Wed, 9 Nov 2011 07:56:01 -0800 (PST) Subject: file extension while saving Python files In-Reply-To: References: Message-ID: <18518506.120.1320854161026.JavaMail.geo-discussion-forums@pref15> In testing and debug it is better that a program can be easily modified and easy to set break point and dump values. Thus an interpreter environment is more convenient. But in the final version a compiler can speed up a lot! From Juan.Declet-Barreto at MesaAZ.gov Wed Nov 9 14:08:09 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Wed, 9 Nov 2011 12:08:09 -0700 Subject: guppy Message-ID: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> I am trying to build guppy on Python 2.5, but am getting an "initializer element is not constant" error from gcc. I have found very little on this issue in the fora when looking for the general cause of the error; there is even less that is specific to a guppy build on Python 2.5. One recommendation I have seen is recompiling Python, but apparently that brings up the possibility of rendering it incompatible with non-standard packages like arcpy or arcgisscripting, which are critical to my application. I am using Cygwin. -----Original Message----- From: Dominic Binks [mailto:dbinks at codeaurora.org] Sent: Wednesday, November 09, 2011 9:31 AM To: Juan Declet-Barreto Subject: Re: memory management On 11/9/2011 6:53 AM, Juan Declet-Barreto wrote: > After some exception catching, I have found that my program is throwing a MemoryError exception numerous times (~7 iterations of the main loop that processes list elements) until python25\python.exe crashes (Windows XP environment). I implemented Dave Angel's suggestions re: processing each list element (a file) as I get it. > > So my question would be how to begin troubleshooting the conditions under which the exception is raised. Is there any more information in the exception object about how much memory is being consumed, or any other indicators as to what led to the exception? > > -juan > > -----Original Message----- > From: Dave Angel [mailto:d at davea.name] > Sent: Monday, November 07, 2011 1:50 PM > To: Juan Declet-Barreto > Cc: python-list at python.org > Subject: Re: memory management > > On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: >> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. > You top-posted. In this mailing list, one should type new information after the quoted information, not before. > > Perhaps a pre-emptive strike is in order. On the assumption that it may be a memory problem, how about you turn the app inside out. Instead of walking the entire tree, getting a list with all the paths, and then working on the list, how about doing the work on each file as you get it. Or even make your own generator from os.walk, so the app can call your logic on each file, and never have all the file (name)s in memory at the same time. > > > Generator: > > def filelist(top, criteria): > for a, b, c in os.walk(): > for fiile in files: > apply some criteria > yield file > > > Now the main app can iterate through this "list" in the usual way > > for filename in filelist(top, "*.txt"): > dosomething... > > > Look for a tool called heapy. I had a process that was consuming 10+G of RAM to run. Using heapy I identified the culprit and reduced down to a more manageable 400M. Dominic -- Dominic Binks: dbinks at codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum From lists at cheimes.de Wed Nov 9 14:20:30 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 09 Nov 2011 20:20:30 +0100 Subject: guppy In-Reply-To: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> Message-ID: Am 09.11.2011 20:08, schrieb Juan Declet-Barreto: > I am trying to build guppy on Python 2.5, but am getting an "initializer element is not constant" error from gcc. I have found very little on this issue in the fora when looking for the general cause of the error; there is even less that is specific to a guppy build on Python 2.5. > > One recommendation I have seen is recompiling Python, but apparently that brings up the possibility of rendering it incompatible with non-standard packages like arcpy or arcgisscripting, which are critical to my application. > > I am using Cygwin. Please show us the full error message with context. Are you using a Cygwin build of Python or a native Windows build? What GCC version and flavor are you using? I'm not sure if Cygwin is even supported. I recommend that you use MinGW with GCC 4.x if you can't afford VS 2003. Christian From benjamin.kaplan at case.edu Wed Nov 9 14:28:11 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 9 Nov 2011 14:28:11 -0500 Subject: guppy In-Reply-To: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> Message-ID: On Wed, Nov 9, 2011 at 2:08 PM, Juan Declet-Barreto wrote: > > I am trying to build guppy on Python 2.5, but am getting an "initializer element is not constant" error from gcc. I have found very little on this issue in the fora when looking for the general cause of the error; there is even less that is specific to a guppy build on Python 2.5. > > One recommendation I have seen is recompiling Python, but apparently that brings up the possibility of rendering it incompatible with non-standard packages like arcpy or arcgisscripting, which are critical to my application. > > I am using Cygwin. > > Mixing Cygwin libraries and normal Windows libraries usually doesn't always work too well. Are you using a Cygwin-compiled version of Python? > > -----Original Message----- > From: Dominic Binks [mailto:dbinks at codeaurora.org] > Sent: Wednesday, November 09, 2011 9:31 AM > To: Juan Declet-Barreto > Subject: Re: memory management > > On 11/9/2011 6:53 AM, Juan Declet-Barreto wrote: > > After some exception catching, I have found that my program is throwing a MemoryError exception numerous times (~7 iterations of the main loop that processes list elements) until python25\python.exe crashes (Windows XP environment). ? I implemented Dave Angel's suggestions re: processing each list element (a file) as I get it. > > > > So my question would be how to begin troubleshooting the conditions under which the exception is raised. Is there any more information in the exception object about how much memory is being consumed, or any other indicators as to what led to the exception? > > > > -juan > > > > -----Original Message----- > > From: Dave Angel [mailto:d at davea.name] > > Sent: Monday, November 07, 2011 1:50 PM > > To: Juan Declet-Barreto > > Cc: python-list at python.org > > Subject: Re: memory management > > > > On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: > >> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. > > You top-posted. ?In this mailing list, one should type new information after the quoted information, not before. > > > > Perhaps a pre-emptive strike is in order. ?On the assumption that it may be a memory problem, how about you turn the app inside out. ?Instead of walking the entire tree, getting a list with all the paths, and then working on the list, how about doing the work on each file as you get it. ?Or even make your own generator from os.walk, so the app can call your logic on each file, and never have all the file (name)s in memory at the same time. > > > > > > Generator: > > > > def ?filelist(top, criteria): > > ? ? ? ? for ?a, b, c in os.walk(): > > ? ? ? ? ? ? ? ?for fiile in files: > > ? ? ? ? ? ? ? ? ? ? ?apply some criteria > > ? ? ? ? ? ? ? ? ? ? ?yield file > > > > > > Now the main app can iterate through this "list" in the usual way > > > > for filename in filelist(top, "*.txt"): > > ? ? ? ? ?dosomething... > > > > > > > > Look for a tool called heapy. ?I had a process that was consuming 10+G of RAM to run. ?Using heapy I identified the culprit and reduced down to a more manageable 400M. > > Dominic > > -- > Dominic Binks: dbinks at codeaurora.org > Employee of Qualcomm Innovation Center, Inc. > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum > -- > http://mail.python.org/mailman/listinfo/python-list From Juan.Declet-Barreto at MesaAZ.gov Wed Nov 9 14:38:03 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Wed, 9 Nov 2011 12:38:03 -0700 Subject: guppy In-Reply-To: References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> Message-ID: <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> I am using Cygwin build of Python2.6. This Cygwin install has both a Cygwin gcc (versions 3.4.4 and 4.5.3) and mingw32 (3.4.4), as listed in lib/gcc/. I also tried the mingw32 shell separately, but I get the same results even when I pass the "-c mingw32" option. The error is reproduced below: $ python setup.py build running build running build_py running build_ext building 'guppy.sets.setsc' extension gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/python2.6 -c src/sets/sets.c -o build/temp.cygwin-1.7.9-i686-2.6/src/sets/sets.o src/sets/sets.c:68:5: error: initializer element is not constant src/sets/sets.c:68:5: error: (near initialization for `nysets_heapdefs[0].type') src/sets/sets.c:69:5: error: initializer element is not constant src/sets/sets.c:69:5: error: (near initialization for `nysets_heapdefs[1].type') src/sets/sets.c:70:5: error: initializer element is not constant src/sets/sets.c:70:5: error: (near initialization for `nysets_heapdefs[2].type') error: command 'gcc' failed with exit status 1 -----Original Message----- From: python-list-bounces+juan.declet-barreto=mesaaz.gov at python.org [mailto:python-list-bounces+juan.declet-barreto=mesaaz.gov at python.org] On Behalf Of Christian Heimes Sent: Wednesday, November 09, 2011 12:21 PM To: python-list at python.org Subject: Re: guppy Am 09.11.2011 20:08, schrieb Juan Declet-Barreto: > I am trying to build guppy on Python 2.5, but am getting an "initializer element is not constant" error from gcc. I have found very little on this issue in the fora when looking for the general cause of the error; there is even less that is specific to a guppy build on Python 2.5. > > One recommendation I have seen is recompiling Python, but apparently that brings up the possibility of rendering it incompatible with non-standard packages like arcpy or arcgisscripting, which are critical to my application. > > I am using Cygwin. Please show us the full error message with context. Are you using a Cygwin build of Python or a native Windows build? What GCC version and flavor are you using? I'm not sure if Cygwin is even supported. I recommend that you use MinGW with GCC 4.x if you can't afford VS 2003. Christian -- http://mail.python.org/mailman/listinfo/python-list From lists at cheimes.de Wed Nov 9 15:38:02 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 09 Nov 2011 21:38:02 +0100 Subject: guppy In-Reply-To: <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> Message-ID: Am 09.11.2011 20:38, schrieb Juan Declet-Barreto: > I am using Cygwin build of Python2.6. This Cygwin install has both a Cygwin gcc (versions 3.4.4 and 4.5.3) and mingw32 (3.4.4), as listed in lib/gcc/. > > I also tried the mingw32 shell separately, but I get the same results even when I pass the "-c mingw32" option. > > The error is reproduced below: > > $ python setup.py build > running build > running build_py > running build_ext > building 'guppy.sets.setsc' extension > gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/python2.6 -c src/sets/sets.c -o build/temp.cygwin-1.7.9-i686-2.6/src/sets/sets.o > src/sets/sets.c:68:5: error: initializer element is not constant > src/sets/sets.c:68:5: error: (near initialization for `nysets_heapdefs[0].type') > src/sets/sets.c:69:5: error: initializer element is not constant > src/sets/sets.c:69:5: error: (near initialization for `nysets_heapdefs[1].type') > src/sets/sets.c:70:5: error: initializer element is not constant > src/sets/sets.c:70:5: error: (near initialization for `nysets_heapdefs[2].type') > > error: command 'gcc' failed with exit status 1 static NyHeapDef nysets_heapdefs[] = { {0, 0, (NyHeapDef_SizeGetter) mutbitset_indisize}, {0, 0, 0, cplbitset_traverse}, {0, 0, nodeset_indisize, nodeset_traverse, nodeset_relate}, {0} }; nysets_heapdefs[0].type = &NyMutBitSet_Type; nysets_heapdefs[1].type = &NyCplBitSet_Type; nysets_heapdefs[2].type = &NyNodeSet_Type; The code looks fine to me and compiles with GCC 4.6. It seems your GCC chokes on "nysets_heapdefs[0].type = &NyMutBitSet_Type;". It's not a file local static but an extern declaration. Are you sure that you are using a recent version of GCC 4.x? I had some issues with GCC 3.x in the past. Cygwin has GCC 3.x as default gcc. For Python 2.6 you can use the free VS 2008 Express version. I've compiled guppy for 32bit Python 2.7 a couple of days ago w/o any issue From nagle at animats.com Wed Nov 9 17:16:23 2011 From: nagle at animats.com (John Nagle) Date: Wed, 09 Nov 2011 14:16:23 -0800 Subject: all() is slow? In-Reply-To: References: Message-ID: <4ebafbb7$0$1724$742ec2ed@news.sonic.net> On 11/7/2011 1:00 PM, OKB (not okblacke) wrote: > I noticed this (Python 2.6.5 on Windows XP): CPython is slow. It's a naive interpreter. There's almost no optimization during compilation. Try PyPy or Shed Skin. John Nagle From jeanpierreda at gmail.com Wed Nov 9 18:01:16 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Nov 2011 18:01:16 -0500 Subject: all() is slow? In-Reply-To: <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: > If it were someone other than Raymond Hettinger responsible for the use > of exec in namedtuple, I'd be a lot more suspicious of it. I'm not going to be less suspicious based on a name. It reads like insanity, and the justification was terrible. Devin On Tue, Nov 8, 2011 at 9:47 PM, Steven D'Aprano wrote: > On Tue, 08 Nov 2011 19:44:18 -0500, Devin Jeanpierre wrote: > >> We have that stupid exec trick in the Python stdlib. It has to die. >> >> http://hg.python.org/cpython/file/6bf07db23445/Lib/collections/__init__.py#l240 > > > http://bugs.python.org/issue3974 > http://blog.ccpgames.com/kristjan/2011/05/28/namedtuple-and-exec/ > > If it were someone other than Raymond Hettinger responsible for the use > of exec in namedtuple, I'd be a lot more suspicious of it. > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From steve+comp.lang.python at pearwood.info Wed Nov 9 18:11:51 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Nov 2011 23:11:51 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Nov 2011 18:01:16 -0500, Devin Jeanpierre wrote: >> If it were someone other than Raymond Hettinger responsible for the use >> of exec in namedtuple, I'd be a lot more suspicious of it. > > I'm not going to be less suspicious based on a name. Neither am I. I am less suspicious based on a reputation. Raymond is a well-known, trusted senior Python developer who knows what he is doing. > It reads like > insanity, and the justification was terrible. It reads fine, and the justification is perfectly valid. You're right to be cautious of exec. You're wrong to be phobic about it. What do you think is going to happen? The exec call inside namedtuple is going to creep out of the module in the wee hours of the night, contaminating other functions and modules while you sleep? Be serious. If you have an actual concrete security vulnerability caused by the use of exec inside namedtuple, or some other bug, then say so. Otherwise, your paranoia is unjustified. -- Steven From rosuav at gmail.com Wed Nov 9 18:15:07 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Nov 2011 10:15:07 +1100 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 10, 2011 at 10:01 AM, Devin Jeanpierre wrote: >> If it were someone other than Raymond Hettinger responsible for the use >> of exec in namedtuple, I'd be a lot more suspicious of it. > > I'm not going to be less suspicious based on a name. It reads like > insanity, and the justification was terrible. It's said that code exists foremost for humans to read, and only incidentally for computers to execute. I believe that this is inverted for library code; as long as the _interface_ is clean, you can get away with some messy internals, because it's going to be executed far more often than actually read. Python programmers can use namedtuples happily without knowing that the implementation uses exec. The justification is, if I understand correctly, that the alternative is worse. That's plenty of justification imho. ChrisA From kwa at kuwata-lab.com Wed Nov 9 19:58:15 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Thu, 10 Nov 2011 09:58:15 +0900 Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: On Wed, Nov 9, 2011 at 4:09 AM, Terry Reedy wrote: > On 11/7/2011 11:32 PM, Makoto Kuwata wrote: >> >> I got trouble about easy_install command. >> >> My package: >> >> ? README.rst >> ? setup.py >> ? foobar/ >> ? foobar/__init__.py >> ? foobar/data/ >> ? foobar/data/template.py >> >> In the above example, 'foobar/data/template.py' is just a >> template data file (= not a python module file). > > Then why is it .py? If it is just data, use .txt. If .py, it should be > python code run either directly or imported, though I suppose you could exec > it. (I have no idea how renaming would affect your problem.) > I want to use template names according to language, such as template.py, template.html, template.rst, template.js, and so on. My question is "how to include non-python files into egg file?" I may change file name suffix from '.py' to '.py.template', but it doesn't solve my problem. -- regards, makoto kuwata From jeanpierreda at gmail.com Wed Nov 9 20:26:56 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Nov 2011 20:26:56 -0500 Subject: all() is slow? In-Reply-To: <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: > Neither am I. I am less suspicious based on a reputation. Raymond is a > well-known, trusted senior Python developer who knows what he is doing. I don't really know anything about him or why people respect him, so I have no reason to share your faith. > It reads fine, and the justification is perfectly valid. Well. It reads fine in a certain sense, in that I can figure out what's going on (although I have some troubles figuring out why the heck certain things are in the code). The issue is that what's going on is otherworldly: this is not a Python pattern, this is not a normal approach. To me, that means it does not read fine. The use of exec also results in (seemingly) arbitrary constraints on the input. Like, why can't "--" be a name? Because exec? Is there some other reason? I don't like the use of exec, and I don't like the justification (it seems handwavy). I pointed this out in a thread full of people saying "never EVER use exec this way", so it's obviously not just me that thinks this is awful. > You're right to be cautious of exec. You're wrong to be phobic about it. > What do you think is going to happen? I think somebody will read it and think this is a good idea. Devin On Wed, Nov 9, 2011 at 6:11 PM, Steven D'Aprano wrote: > On Wed, 09 Nov 2011 18:01:16 -0500, Devin Jeanpierre wrote: > >>> If it were someone other than Raymond Hettinger responsible for the use >>> of exec in namedtuple, I'd be a lot more suspicious of it. >> >> I'm not going to be less suspicious based on a name. > > Neither am I. I am less suspicious based on a reputation. Raymond is a > well-known, trusted senior Python developer who knows what he is doing. > > >> It reads like >> insanity, and the justification was terrible. > > It reads fine, and the justification is perfectly valid. > > You're right to be cautious of exec. You're wrong to be phobic about it. > What do you think is going to happen? The exec call inside namedtuple is > going to creep out of the module in the wee hours of the night, > contaminating other functions and modules while you sleep? Be serious. If > you have an actual concrete security vulnerability caused by the use of > exec inside namedtuple, or some other bug, then say so. Otherwise, your > paranoia is unjustified. > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanpierreda at gmail.com Wed Nov 9 20:35:02 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Nov 2011 20:35:02 -0500 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: > Well. It reads fine in a certain sense, in that I can figure out > what's going on (although I have some troubles figuring out why the > heck certain things are in the code). The issue is that what's going > on is otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. Sorry for the double post, but I think I damaged my statement a little in the edit process here. I have a hard time reading the code, and the implications of using exec on how initialization works is not obvious. I do believe that this solution is significantly less readable than it would be in a language with "real" macros, or using an alternate dict-based approach. I don't mean to just say "it's different, therefore it's wrong" -- it takes more than just being unusual (not that the unusualness helps). Devin On Wed, Nov 9, 2011 at 8:26 PM, Devin Jeanpierre wrote: >> Neither am I. I am less suspicious based on a reputation. Raymond is a >> well-known, trusted senior Python developer who knows what he is doing. > > I don't really know anything about him or why people respect him, so I > have no reason to share your faith. > >> It reads fine, and the justification is perfectly valid. > > Well. It reads fine in a certain sense, in that I can figure out > what's going on (although I have some troubles figuring out why the > heck certain things are in the code). The issue is that what's going > on is otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. > > The use of exec also results in (seemingly) arbitrary constraints on > the input. Like, why can't "--" be a name? Because exec? Is there some > other reason? > > I don't like the use of exec, and I don't like the justification (it > seems handwavy). I pointed this out in a thread full of people saying > "never EVER use exec this way", so it's obviously not just me that > thinks this is awful. > >> You're right to be cautious of exec. You're wrong to be phobic about it. >> What do you think is going to happen? > > I think somebody will read it and think this is a good idea. > > Devin > > > On Wed, Nov 9, 2011 at 6:11 PM, Steven D'Aprano > wrote: >> On Wed, 09 Nov 2011 18:01:16 -0500, Devin Jeanpierre wrote: >> >>>> If it were someone other than Raymond Hettinger responsible for the use >>>> of exec in namedtuple, I'd be a lot more suspicious of it. >>> >>> I'm not going to be less suspicious based on a name. >> >> Neither am I. I am less suspicious based on a reputation. Raymond is a >> well-known, trusted senior Python developer who knows what he is doing. >> >> >>> It reads like >>> insanity, and the justification was terrible. >> >> It reads fine, and the justification is perfectly valid. >> >> You're right to be cautious of exec. You're wrong to be phobic about it. >> What do you think is going to happen? The exec call inside namedtuple is >> going to creep out of the module in the wee hours of the night, >> contaminating other functions and modules while you sleep? Be serious. If >> you have an actual concrete security vulnerability caused by the use of >> exec inside namedtuple, or some other bug, then say so. Otherwise, your >> paranoia is unjustified. >> >> >> >> -- >> Steven >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > From drobinow at gmail.com Wed Nov 9 21:06:26 2011 From: drobinow at gmail.com (David Robinow) Date: Wed, 9 Nov 2011 21:06:26 -0500 Subject: guppy In-Reply-To: <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> Message-ID: On Wed, Nov 9, 2011 at 2:38 PM, Juan Declet-Barreto wrote: > I am using Cygwin build of Python2.6. ?This Cygwin install has both a Cygwin gcc (versions 3.4.4 and 4.5.3) and mingw32 (3.4.4), as listed in lib/gcc/. > > I also tried the mingw32 shell separately, but I get the same results even when I pass the "-c mingw32" option. > > The error is reproduced below: > ... It works for me. guppy 0.1.9 gcc 4.5.3 Python 2.6.5 cygwin 1.7.9 [I have no idea if it works as intended. I don't use guppy.] From ian.g.kelly at gmail.com Wed Nov 9 21:10:27 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 9 Nov 2011 19:10:27 -0700 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Nov 9, 2011 at 6:26 PM, Devin Jeanpierre wrote: > The use of exec also results in (seemingly) arbitrary constraints on > the input. Like, why can't "--" be a name? Because exec? Is there some > other reason? That's by design, not because of exec. The names are supposed to be actual Python names, things that can used to designate keyword arguments ("MyTuple(foo=42)") or to retrieve elements using attribute lookup ("my_tuple.foo"). Using "--" as a name would be a syntax error in either of those cases. Cheers, Ian From kwa at kuwata-lab.com Wed Nov 9 22:25:06 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Thu, 10 Nov 2011 12:25:06 +0900 Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: On Thu, Nov 10, 2011 at 9:58 AM, Makoto Kuwata wrote: > On Wed, Nov 9, 2011 at 4:09 AM, Terry Reedy wrote: >> On 11/7/2011 11:32 PM, Makoto Kuwata wrote: >>> >>> I got trouble about easy_install command. >>> >>> My package: >>> >>> ? README.rst >>> ? setup.py >>> ? foobar/ >>> ? foobar/__init__.py >>> ? foobar/data/ >>> ? foobar/data/template.py >>> >>> In the above example, 'foobar/data/template.py' is just a >>> template data file (= not a python module file). >> >> Then why is it .py? If it is just data, use .txt. If .py, it should be >> python code run either directly or imported, though I suppose you could exec >> it. (I have no idea how renaming would affect your problem.) >> > > I want to use template names according to language, > such as template.py, template.html, template.rst, template.js, and so on. > > My question is "how to include non-python files into egg file?" > I may change file name suffix from '.py' to '.py.template', > but it doesn't solve my problem. I create sample project to explain my trouble. Sample project source code: https://bitbucket.org/kwatch/helloworld/src When 'python setup.py sdist', all files are copied correctly. https://bitbucket.org/kwatch/helloworld/wiki/python_setup.py_sdist $ python setup.py sdist .... hard linking helloworld/__init__.py -> HelloWorld-0.1.0/helloworld hard linking helloworld/foo.py -> HelloWorld-0.1.0/helloworld hard linking helloworld/sub/__init__.py -> HelloWorld-0.1.0/helloworld/sub hard linking helloworld/sub/bar.py -> HelloWorld-0.1.0/helloworld/sub .... But when 'python setup.py bdist_egg', some files are not copied. https://bitbucket.org/kwatch/helloworld/wiki/python_setup.py_bdist_egg $ python setup.py bdist # 'helloworld/sub/{__init__,bar}.py' are not copied! .... copying build/lib/helloworld/__init__.py -> build/bdist.macosx-10.4-x86_64/egg/helloworld copying build/lib/helloworld/foo.py -> build/bdist.macosx-10.4-x86_64/egg/helloworld .... Could you help me? -- regards, makoto kuwata From wuwei23 at gmail.com Wed Nov 9 22:50:42 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 9 Nov 2011 19:50:42 -0800 (PST) Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2f026694-0905-49f8-bcae-7e4d55df5d49@z22g2000prd.googlegroups.com> On Nov 10, 11:26?am, Devin Jeanpierre wrote: > I don't really know anything about him or why people respect him, so I > have no reason to share your faith. But you're happy to accept the opinions of random posters saying "exec is evil"? (And it's really not a good idea to be proud of your ignorance...) > Like, why can't "--" be a name? Why would you ever want it to be? > I don't like the use of exec, and I don't like the justification (it > seems handwavy). As opposed to your in-depth critique? > I pointed this out in a thread full of people saying > "never EVER use exec this way", so it's obviously not just me that > thinks this is awful. No, instead you have a thread full of people happy to criticise something for which they're providing no alternative implementation. You can't exactly say _why_ it's bad, other than other people have echoed it, but you won't actually do anything about it. > I think somebody will read it and think this is a good idea. Just as I thought. From wuwei23 at gmail.com Wed Nov 9 22:52:35 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 9 Nov 2011 19:52:35 -0800 (PST) Subject: all() is slow? References: <4ebafbb7$0$1724$742ec2ed@news.sonic.net> Message-ID: <8f077318-a150-4ca2-b6e6-5f8dfcd85d8d@u10g2000prl.googlegroups.com> On Nov 10, 8:16?am, John Nagle wrote: > ? ? ?CPython is slow. It's a naive interpreter. ?There's > almost no optimization during compilation. ?Try PyPy > or Shed Skin. Sometimes people need to understand the performance characteristics of CPython because it's what they have to use. Pointing them at alternative implementations isn't an answer. From jeanpierreda at gmail.com Wed Nov 9 23:40:25 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Nov 2011 23:40:25 -0500 Subject: all() is slow? In-Reply-To: <2f026694-0905-49f8-bcae-7e4d55df5d49@z22g2000prd.googlegroups.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <2f026694-0905-49f8-bcae-7e4d55df5d49@z22g2000prd.googlegroups.com> Message-ID: > (And it's really not a good idea to be proud of your > ignorance...) I wasn't bragging. > But you're happy to accept the opinions of random posters saying "exec > is evil"? [...] > As opposed to your in-depth critique? [...] > No, instead you have a thread full of people happy to criticise > something for which they're providing no alternative implementation. > You can't exactly say _why_ it's bad, other than other people have > echoed it, but you won't actually do anything about it. I said it was bad because I found it difficult to read and it was "weird". I also mentioned that it's conceivable that it has security flaws, but that's not as big a deal. I believe I also said that it was bad because it resulted in """arbitrary""" limitations in functionality. So, yes, I did say why it's bad, and it's not just because other people say so. My reasons are weak, but that's a different story. I also mentioned the alternative implementation, which uses a dict. There was even already a patch submitted to make namedtuple work this way, so I don't think I had to be too specific. R. Hettinger rejected this patch, which was what I was referring to when I was referring to handwaviness. So, no. > Just as I thought. Woo condescension. Devin On Wed, Nov 9, 2011 at 10:50 PM, alex23 wrote: > On Nov 10, 11:26?am, Devin Jeanpierre wrote: >> I don't really know anything about him or why people respect him, so I >> have no reason to share your faith. > > But you're happy to accept the opinions of random posters saying "exec > is evil"? (And it's really not a good idea to be proud of your > ignorance...) > >> Like, why can't "--" be a name? > > Why would you ever want it to be? > >> I don't like the use of exec, and I don't like the justification (it >> seems handwavy). > > As opposed to your in-depth critique? > >> I pointed this out in a thread full of people saying >> "never EVER use exec this way", so it's obviously not just me that >> thinks this is awful. > > No, instead you have a thread full of people happy to criticise > something for which they're providing no alternative implementation. > You can't exactly say _why_ it's bad, other than other people have > echoed it, but you won't actually do anything about it. > >> I think somebody will read it and think this is a good idea. > > Just as I thought. > -- > http://mail.python.org/mailman/listinfo/python-list > From paulalgray71 at gmail.com Thu Nov 10 00:29:56 2011 From: paulalgray71 at gmail.com (paula gray) Date: Thu, 10 Nov 2011 00:29:56 -0500 Subject: mailing list Message-ID: -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Nov 10 00:32:24 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Nov 2011 16:32:24 +1100 Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: On Thu, Nov 10, 2011 at 11:58 AM, Makoto Kuwata wrote: > I want to use template names according to language, > such as template.py, template.html, template.rst, template.js, and so on. > You may have another problem here. Everyone and everything that looks at these will expect them to be Python, HTML, etc files. If they're not, it may cause confusion in other ways. Can you switch it around, py.template and html.template etc? ChrisA From steve+comp.lang.python at pearwood.info Thu Nov 10 02:35:48 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 07:35:48 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <2f026694-0905-49f8-bcae-7e4d55df5d49@z22g2000prd.googlegroups.com> Message-ID: <4ebb7ed3$0$29988$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Nov 2011 19:50:42 -0800, alex23 wrote: >> I pointed this out in a thread full of people saying "never EVER use >> exec this way", so it's obviously not just me that thinks this is >> awful. > > No, instead you have a thread full of people happy to criticise > something for which they're providing no alternative implementation. You > can't exactly say _why_ it's bad, other than other people have echoed > it, but you won't actually do anything about it. In fairness there are alternative implementations. They are not identical to the version using exec. There is at least one use-case for *not* using exec, even at the cost of functionality: a restricted Python environment without exec. On the other hand, a restricted Python without exec is not actually Python. -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 10 02:48:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 07:48:49 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Nov 2011 20:26:56 -0500, Devin Jeanpierre wrote: >> Neither am I. I am less suspicious based on a reputation. Raymond is a >> well-known, trusted senior Python developer who knows what he is doing. > > I don't really know anything about him or why people respect him, so I > have no reason to share your faith. That's fine. I don't expect you to take my word on it (and why should you, I could be an idiot or a sock-puppet), but you could always try googling for "Raymond Hettinger python" and see what comes up. He is not some fly-by Python coder who snuck some dubious n00b code into the standard library when no-one was looking :) The mere fact that it was accepted into the standard library should tell you that core Python developers consider it an acceptable technique. That's not to say the technique is uncontroversial. But there are still people who dislike "x if flag else y" and @decorator syntax -- controversy, in and of itself, isn't necessarily a reason to avoid certain idioms. Are you familiar with the idea of "code smell"? http://www.codinghorror.com/blog/2006/05/code-smells.html http://www.joelonsoftware.com/articles/Wrong.html I would agree that the use of exec is a code smell. But that doesn't mean it is wrong or bad, merely that it needs a second look before accepting it. There's a world of difference between "You MUST NOT use exec" and "You SHOULD NOT use exec". See RFC 2119 if you are unclear on the difference: http://www.ietf.org/rfc/rfc2119.txt >> It reads fine, and the justification is perfectly valid. > > Well. It reads fine in a certain sense, in that I can figure out what's > going on (although I have some troubles figuring out why the heck > certain things are in the code). The issue is that what's going on is > otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. There's nothing inside the template being exec'ed that couldn't be found in non-exec code. So if you're having trouble figuring out parts of the code, the presence of the exec is not the problem. Having said that, dynamic code generation is well known for often being harder to read than "ordinary" code. But then, pointers are hard too. > The use of exec also results in (seemingly) arbitrary constraints on the > input. Like, why can't "--" be a name? Because exec? Is there some other > reason? Because Python doesn't allow "--" to be an attribute name, and so namedtuple doesn't let you try: t = namedtuple("T", "foo -- bar")(1, 2, 3) print(t.foo) print(t.--) print(t.bar) -- Steven From simeon.chaos at gmail.com Thu Nov 10 03:35:06 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Thu, 10 Nov 2011 00:35:06 -0800 (PST) Subject: dao 0.7.4 released Message-ID: <20d8f55c-6803-4574-92c8-1704b4918b99@p20g2000prm.googlegroups.com> ---------------------------- What's new in dao 0.7.4? ---------------------------- *Release date: 2011-11-10 * new in code: * quasiquote, unquote, unquote_slicing is implemented. * directly evaluate sexpression in solver * some builtins for define, set and get global, outer and local var * lisp style macro: expand and eval on UserMacro From jeanpierreda at gmail.com Thu Nov 10 03:51:10 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 10 Nov 2011 03:51:10 -0500 Subject: all() is slow? In-Reply-To: <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: > I don't expect you to take my word on it (and why should you, I could be > an idiot or a sock-puppet), but you could always try googling for > "Raymond Hettinger python" and see what comes up. He is not some fly-by > Python coder who snuck some dubious n00b code into the standard library > when no-one was looking :) Alright, I know *something* about him. I knew he was a core developer, and that he was responsible for namedtuple. I also discovered (when I looked up his activestate profile) some other stuff he wrote. I don't really know anything about him outside of that -- i.e. I have no idea what parts of Python he's contributed things to in the past that could make me go, "oh, wow, _he_ did that?" and so on. I don't really feel like a few minutes research would give me the right feel, it generally has to come up organically. Anyway, if we step back, for a trustworthy developer who wrote something seemingly-crazy, I should be willing to suspend judgement until I see the relevant facts about something that the developer might have and I don't. But he did give the facts, ( http://bugs.python.org/issue3974 again) , and I'm not convinced. Things can go terribly wrong when abusing exec e.g. http://www.gossamer-threads.com/lists/python/bugs/568206 . That shouldn't ever happen with a function such as this. exec opens doors that should not be opened without a really good reason, and those reasons don't strike me that way. > The mere fact that it was accepted into the standard library should tell > you that core Python developers consider it an acceptable technique. I've seen core developers rail against the namedtuple source code. In fairness, I don't believe exec was the subject of the rant -- nonetheless its presence isn't evidence of general support, and even if it were, my tastes have always differed from that of the core developers. > That's not to say the technique is uncontroversial. But there are still > people who dislike "x if flag else y" and @decorator syntax -- > controversy, in and of itself, isn't necessarily a reason to avoid > certain idioms. I think there's somewhat a difference in magnitude of objections between using exec as a hacked-together macro system, and using "x if flag else y" when if statements would do. If the exec trick is reasonable, we should normalize it in the form of a real, useful macro system, that can protect us against exec's many flaws (code injection, accidental syntax errors, etc.) and tell future programmers how to do this safely and in a semi-approvable way. > I would agree that the use of exec is a code smell. But that doesn't mean > it is wrong or bad, merely that it needs a second look before accepting > it. There's a world of difference between "You MUST NOT use exec" and > "You SHOULD NOT use exec". Do I really need a second look? I see exec, I wonder what it's doing. It isn't doing anything that couldn't be done subjectively better with e.g. a dict, so I disapprove of the usage of exec. > There's nothing inside the template being exec'ed that couldn't be found > in non-exec code. So if you're having trouble figuring out parts of the > code, the presence of the exec is not the problem. There's more overhead going back and forth to the template, and there's related things that I can't be sure are because of exec or because of design decisions, etc. It makes code reading more challenging, even if it's still possible. That said, sure, some of these are problems with whatever else he's done. > Having said that, dynamic code generation is well known for often being > harder to read than "ordinary" code. But then, pointers are hard too. And on the other other hand, Python lacks explicit support for both pointers and code generation (unless you count strings and ctypes). > Because Python doesn't allow "--" to be an attribute name, and so > namedtuple doesn't let you try: > > t = namedtuple("T", "foo -- bar")(1, 2, 3) > print(t.foo) > print(t.--) > print(t.bar) '--' is a valid attribute name on virtually any object that supports attribute setting (e.g. function objects). Of course, you need to use setattr() and getattr(). Is this really the reason, or is it a limitation caused primarily by the usage of exec and the need to prevent code injection? If somebody added this feature later on, would this create a security vulnerability in certain projects that used namedtuple in certain ways? Devin On Thu, Nov 10, 2011 at 2:48 AM, Steven D'Aprano wrote: > On Wed, 09 Nov 2011 20:26:56 -0500, Devin Jeanpierre wrote: > >>> Neither am I. I am less suspicious based on a reputation. Raymond is a >>> well-known, trusted senior Python developer who knows what he is doing. >> >> I don't really know anything about him or why people respect him, so I >> have no reason to share your faith. > > That's fine. > > I don't expect you to take my word on it (and why should you, I could be > an idiot or a sock-puppet), but you could always try googling for > "Raymond Hettinger python" and see what comes up. He is not some fly-by > Python coder who snuck some dubious n00b code into the standard library > when no-one was looking :) > > The mere fact that it was accepted into the standard library should tell > you that core Python developers consider it an acceptable technique. > That's not to say the technique is uncontroversial. But there are still > people who dislike "x if flag else y" and @decorator syntax -- > controversy, in and of itself, isn't necessarily a reason to avoid > certain idioms. > > > Are you familiar with the idea of "code smell"? > > http://www.codinghorror.com/blog/2006/05/code-smells.html > http://www.joelonsoftware.com/articles/Wrong.html > > I would agree that the use of exec is a code smell. But that doesn't mean > it is wrong or bad, merely that it needs a second look before accepting > it. There's a world of difference between "You MUST NOT use exec" and > "You SHOULD NOT use exec". > > See RFC 2119 if you are unclear on the difference: > > http://www.ietf.org/rfc/rfc2119.txt > > > >>> It reads fine, and the justification is perfectly valid. >> >> Well. It reads fine in a certain sense, in that I can figure out what's >> going on (although I have some troubles figuring out why the heck >> certain things are in the code). The issue is that what's going on is >> otherworldly: this is not a Python pattern, this is not a normal >> approach. To me, that means it does not read fine. > > There's nothing inside the template being exec'ed that couldn't be found > in non-exec code. So if you're having trouble figuring out parts of the > code, the presence of the exec is not the problem. > > Having said that, dynamic code generation is well known for often being > harder to read than "ordinary" code. But then, pointers are hard too. > > > >> The use of exec also results in (seemingly) arbitrary constraints on the >> input. Like, why can't "--" be a name? Because exec? Is there some other >> reason? > > Because Python doesn't allow "--" to be an attribute name, and so > namedtuple doesn't let you try: > > t = namedtuple("T", "foo -- bar")(1, 2, 3) > print(t.foo) > print(t.--) > print(t.bar) > > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From tartley at tartley.com Thu Nov 10 04:08:12 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 10 Nov 2011 01:08:12 -0800 (PST) Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: <5611883.2927.1320916092038.JavaMail.geo-discussion-forums@yqni5> Hey. I don't know the details, but your setup.py needs to use either the 'package_data' or the 'data_files' entry in the dict you pass to setup. These can specify files you want included in the sdist which aren't package files. There are many complications with using them though. One of them in particular (I don't remember which one) installs the files you specify in a different place depending on whether the user is installing the sdist from local files (python setup.py install) or using pip, so be sure to test both ways. From tartley at tartley.com Thu Nov 10 04:08:12 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 10 Nov 2011 01:08:12 -0800 (PST) Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: <5611883.2927.1320916092038.JavaMail.geo-discussion-forums@yqni5> Hey. I don't know the details, but your setup.py needs to use either the 'package_data' or the 'data_files' entry in the dict you pass to setup. These can specify files you want included in the sdist which aren't package files. There are many complications with using them though. One of them in particular (I don't remember which one) installs the files you specify in a different place depending on whether the user is installing the sdist from local files (python setup.py install) or using pip, so be sure to test both ways. From baptiste.lepilleur at gmail.com Thu Nov 10 05:51:15 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Thu, 10 Nov 2011 11:51:15 +0100 Subject: How to derive from datetime.timezone class? Message-ID: Hi, I want to sub-class the datetime.timezone class, but when I derive from datetime.timezone I get an error message "TypeError: type 'datetime.timezone' is not an acceptable base type". Why do I get this error? Is there something specific to do to avoid it? Below is an example of code: Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> datetime.timezone >>> class Utc(datetime.timezone): ... pass ... Traceback (most recent call last): File "", line 1, in TypeError: type 'datetime.timezone' is not an acceptable base type Baptiste. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 08:15:39 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 21:15:39 +0800 Subject: The python implementation of the "relationships between classes". Message-ID: Greetings: As you know, there are several kinds of relationships between classes in the UML -- dependency, association, aggregation, composition. Q1. Is there any article or code example on its implementation in python? Q2. For example, in composition model, the container object may be responsible for the handling of embedded objects' lifecycle. What is the python pattern of such implementation? would it be adding __del__ to the container class to del embedded objects or something else? Thanks! Biao -------------- next part -------------- An HTML attachment was scrubbed... URL: From gheskett at wdtv.com Thu Nov 10 08:20:54 2011 From: gheskett at wdtv.com (gene heskett) Date: Thu, 10 Nov 2011 08:20:54 -0500 Subject: all() is slow? In-Reply-To: References: <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201111100820.54520.gheskett@wdtv.com> On Thursday, November 10, 2011 08:13:13 AM Devin Jeanpierre did opine: > > I don't expect you to take my word on it (and why should you, I could > > be an idiot or a sock-puppet), but you could always try googling for > > "Raymond Hettinger python" and see what comes up. He is not some > > fly-by Python coder who snuck some dubious n00b code into the > > standard library when no-one was looking :) > > Alright, I know *something* about him. I knew he was a core developer, > and that he was responsible for namedtuple. I also discovered (when I > looked up his activestate profile) some other stuff he wrote. I don't > really know anything about him outside of that -- i.e. I have no idea > what parts of Python he's contributed things to in the past that could > make me go, "oh, wow, _he_ did that?" and so on. I don't really feel > like a few minutes research would give me the right feel, it generally > has to come up organically. > > Anyway, if we step back, for a trustworthy developer who wrote > something seemingly-crazy, I should be willing to suspend judgement > until I see the relevant facts about something that the developer > might have and I don't. But he did give the facts, > ( http://bugs.python.org/issue3974 again) , and I'm not convinced. > > Things can go terribly wrong when abusing exec e.g. > http://www.gossamer-threads.com/lists/python/bugs/568206 . That > shouldn't ever happen with a function such as this. exec opens doors > that should not be opened without a really good reason, and those > reasons don't strike me that way. If, in the sense that this python 'exec' essentially duplicates the bash version, then I have found it quite useful, it was taught to me several years ago by another teacher who was a long time Solaris fan, and if it were to go away, I have several bash scripts running here right now that would require major re-writes. > > The mere fact that it was accepted into the standard library should > > tell you that core Python developers consider it an acceptable > > technique. Well, its certainly not a new concept. All the major 'shell interpreters' have it, why not python? > I've seen core developers rail against the namedtuple source code. In > fairness, I don't believe exec was the subject of the rant -- > nonetheless its presence isn't evidence of general support, and even > if it were, my tastes have always differed from that of the core > developers. > > > That's not to say the technique is uncontroversial. But there are > > still people who dislike "x if flag else y" and @decorator syntax -- > > controversy, in and of itself, isn't necessarily a reason to avoid > > certain idioms. > > I think there's somewhat a difference in magnitude of objections > between using exec as a hacked-together macro system, and using "x if > flag else y" when if statements would do. > > If the exec trick is reasonable, we should normalize it in the form of > a real, useful macro system, that can protect us against exec's many > flaws (code injection, accidental syntax errors, etc.) and tell future > programmers how to do this safely and in a semi-approvable way. > > > I would agree that the use of exec is a code smell. But that doesn't > > mean it is wrong or bad, merely that it needs a second look before > > accepting it. There's a world of difference between "You MUST NOT use > > exec" and "You SHOULD NOT use exec". > > Do I really need a second look? I see exec, I wonder what it's doing. > It isn't doing anything that couldn't be done subjectively better with > e.g. a dict, so I disapprove of the usage of exec. > > > There's nothing inside the template being exec'ed that couldn't be > > found in non-exec code. So if you're having trouble figuring out > > parts of the code, the presence of the exec is not the problem. > > There's more overhead going back and forth to the template, and > there's related things that I can't be sure are because of exec or > because of design decisions, etc. It makes code reading more > challenging, even if it's still possible. That said, sure, some of > these are problems with whatever else he's done. > > > Having said that, dynamic code generation is well known for often > > being harder to read than "ordinary" code. But then, pointers are > > hard too. > > And on the other other hand, Python lacks explicit support for both > pointers and code generation (unless you count strings and ctypes). > > > Because Python doesn't allow "--" to be an attribute name, and so > > namedtuple doesn't let you try: > > > > t = namedtuple("T", "foo -- bar")(1, 2, 3) > > print(t.foo) > > print(t.--) > > print(t.bar) > > '--' is a valid attribute name on virtually any object that supports > attribute setting (e.g. function objects). Of course, you need to use > setattr() and getattr(). Is this really the reason, or is it a > limitation caused primarily by the usage of exec and the need to > prevent code injection? If somebody added this feature later on, would > this create a security vulnerability in certain projects that used > namedtuple in certain ways? > > Devin > > On Thu, Nov 10, 2011 at 2:48 AM, Steven D'Aprano > > wrote: > > On Wed, 09 Nov 2011 20:26:56 -0500, Devin Jeanpierre wrote: > >>> Neither am I. I am less suspicious based on a reputation. Raymond is > >>> a well-known, trusted senior Python developer who knows what he is > >>> doing. > >> > >> I don't really know anything about him or why people respect him, so > >> I have no reason to share your faith. > > > > That's fine. > > > > I don't expect you to take my word on it (and why should you, I could > > be an idiot or a sock-puppet), but you could always try googling for > > "Raymond Hettinger python" and see what comes up. He is not some > > fly-by Python coder who snuck some dubious n00b code into the > > standard library when no-one was looking :) > > > > The mere fact that it was accepted into the standard library should > > tell you that core Python developers consider it an acceptable > > technique. That's not to say the technique is uncontroversial. But > > there are still people who dislike "x if flag else y" and @decorator > > syntax -- controversy, in and of itself, isn't necessarily a reason > > to avoid certain idioms. > > > > > > Are you familiar with the idea of "code smell"? > > > > http://www.codinghorror.com/blog/2006/05/code-smells.html > > http://www.joelonsoftware.com/articles/Wrong.html > > > > I would agree that the use of exec is a code smell. But that doesn't > > mean it is wrong or bad, merely that it needs a second look before > > accepting it. There's a world of difference between "You MUST NOT use > > exec" and "You SHOULD NOT use exec". > > > > See RFC 2119 if you are unclear on the difference: > > > > http://www.ietf.org/rfc/rfc2119.txt > > > >>> It reads fine, and the justification is perfectly valid. > >> > >> Well. It reads fine in a certain sense, in that I can figure out > >> what's going on (although I have some troubles figuring out why the > >> heck certain things are in the code). The issue is that what's going > >> on is otherworldly: this is not a Python pattern, this is not a > >> normal approach. To me, that means it does not read fine. > > > > There's nothing inside the template being exec'ed that couldn't be > > found in non-exec code. So if you're having trouble figuring out > > parts of the code, the presence of the exec is not the problem. > > > > Having said that, dynamic code generation is well known for often > > being harder to read than "ordinary" code. But then, pointers are > > hard too. > > > >> The use of exec also results in (seemingly) arbitrary constraints on > >> the input. Like, why can't "--" be a name? Because exec? Is there > >> some other reason? > > > > Because Python doesn't allow "--" to be an attribute name, and so > > namedtuple doesn't let you try: > > > > t = namedtuple("T", "foo -- bar")(1, 2, 3) > > print(t.foo) > > print(t.--) > > print(t.bar) > > > > > > > > > > -- > > Steven > > -- > > http://mail.python.org/mailman/listinfo/python-list Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: >Ever heard of .cshrc? That's a city in Bosnia. Right? (Discussion in comp.os.linux.misc on the intuitiveness of commands.) From rosuav at gmail.com Thu Nov 10 08:26:37 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Nov 2011 00:26:37 +1100 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 12:15 AM, Jerry Zhang wrote: > For example, in composition model, the container object may be responsible > for the handling of embedded objects' lifecycle. What is the python pattern > of such implementation? Here's an example: class Test(object): def __init__(self): self.lst=[1,2,3] self.map={"foo":12,"bar":34} This is a container that has a list and a dictionary in it. When an instance of the container is destroyed, its list and dictionary will be destroyed too (assuming nobody's made other references to them). You don't need to code anything explicitly for that. Chris Angelico From jerry.scofield at gmail.com Thu Nov 10 08:58:41 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 21:58:41 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: Hi Chris, Firstly thanks for your quick reply. 1. Your code example gives a point, but i may not reach my question yet, maybe because i did not make myself understood yet. Here is a more detail example question. I have a classes sets described by UML, which could be refered as Cls_A, Cls_B, CLs_C, Cls_D, Cls_E. There are four relationship between them--dependency, association, aggregation, composition. What i need to do is define all of the classes by python, and,of course, the class definition should describe there relationship correctly. For example, implement composition relationship between Cls_A and Cls_B, which may means a instance of Cls_B is created and destroyed by a Cls_A instance, My code may be like this(not sure since i am not quite familiar with python yet): Cls_a: def __init__(self): self.at1 = 1 Cls_b: def __init__(self): self.com1 = Cls_a() def __del__(self): del self.com1 Is it a right implementation for composition? and i need also do other relationship definition into class, like dependency, association, aggregation... Is there any article or code example on the relationships implementation? Thanks! Biao 2011/11/10 Chris Angelico > On Fri, Nov 11, 2011 at 12:15 AM, Jerry Zhang > wrote: > > For example, in composition model, the container object may be > responsible > > for the handling of embedded objects' lifecycle. What is the python > pattern > > of such implementation? > > Here's an example: > > class Test(object): > def __init__(self): > self.lst=[1,2,3] > self.map={"foo":12,"bar":34} > > This is a container that has a list and a dictionary in it. When an > instance of the container is destroyed, its list and dictionary will > be destroyed too (assuming nobody's made other references to them). > You don't need to code anything explicitly for that. > > Chris Angelico > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Nov 10 09:09:07 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Nov 2011 01:09:07 +1100 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang wrote: > Cls_a: > ? ? def __init__(self): > ? ? ? ? self.at1 = 1 > Cls_b: > ? ? def __init__(self): > ? ? ? ? self.com1 = Cls_a() > ? ? def __del__(self): > ? ? ? ? del self.com1 > Is it a right implementation for composition? Yes, except that you don't need to explicitly del it. Python (at least, CPython) is reference-counted; your Cls_b object owns a reference to the Cls_a object, so (assuming nothing else has a reference) that Cls_a will be happily cleaned up when the Cls_b is. Python doesn't really talk about "composition" etc. It's much simpler: everything's an object, and you have references to that object. A named variable is a reference to some object. A member on an object is, too. Whenever an object is expired, all objects that it references lose one reference, and if that was the sole reference, those objects get expired too. It's a change of thinking, perhaps, but not a difficult one in my opinion; and it's so easy to work with when you grok it. ChrisA From jerry.scofield at gmail.com Thu Nov 10 09:25:35 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 22:25:35 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: 2011/11/10 Chris Angelico > On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang > wrote: > > Cls_a: > > def __init__(self): > > self.at1 = 1 > > Cls_b: > > def __init__(self): > > self.com1 = Cls_a() > > def __del__(self): > > del self.com1 > > Is it a right implementation for composition? > > Yes, except that you don't need to explicitly del it. Python (at > least, CPython) is reference-counted; your Cls_b object owns a > reference to the Cls_a object, so (assuming nothing else has a > reference) that Cls_a will be happily cleaned up when the Cls_b is. > > Python doesn't really talk about "composition" etc. It's much simpler: > everything's an object, and you have references to that object. A > named variable is a reference to some object. A member on an object > is, too. Whenever an object is expired, all objects that it references > lose one reference, and if that was the sole reference, those objects > get expired too. It's a change of thinking, perhaps, but not a > difficult one in my opinion; and it's so easy to work with when you > grok it. > Unfortunately there is a difference between composition and aggregation in my real word, and my application really care this since it is trying to simulate this real world model, so my system should track this difference accurately, otherwise the system may not work well. For example, a. the Cls_arm and Cls_body may be composition, but not aggregation. My app must ensure that " one arm instance only live with one body instance, if the body instance die, the arm instance must die. b. the Cls_auto and the Cls_tyre may be aggregation. "One tyre still can live even the auto is dead." Meanwhile, I have a ZODB running, which stores all the living objects. > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 09:31:36 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 22:31:36 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: 2011/11/10 Jerry Zhang > > > 2011/11/10 Chris Angelico > >> On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang >> wrote: >> > Cls_a: >> > def __init__(self): >> > self.at1 = 1 >> > Cls_b: >> > def __init__(self): >> > self.com1 = Cls_a() >> > def __del__(self): >> > del self.com1 >> > Is it a right implementation for composition? >> >> Yes, except that you don't need to explicitly del it. Python (at >> least, CPython) is reference-counted; your Cls_b object owns a >> reference to the Cls_a object, so (assuming nothing else has a >> reference) that Cls_a will be happily cleaned up when the Cls_b is. >> >> Python doesn't really talk about "composition" etc. It's much simpler: >> everything's an object, and you have references to that object. A >> named variable is a reference to some object. A member on an object >> is, too. Whenever an object is expired, all objects that it references >> lose one reference, and if that was the sole reference, those objects >> get expired too. It's a change of thinking, perhaps, but not a >> difficult one in my opinion; and it's so easy to work with when you >> grok it. >> > > Unfortunately there is a difference between composition and aggregation in > my real word, and my application really care this since it is trying to > simulate this real world model, so my system should track this difference accurately, > otherwise the system may not work well. > > For example, > a. the Cls_arm and Cls_body may be composition, but not aggregation. My > app must ensure that " one arm instance only live with one body instance, > if the body instance die, the arm instance must die. > b. the Cls_auto and the Cls_tyre may be aggregation. "One tyre still can > live even the auto is dead." > > Meanwhile, I have a ZODB running, which stores all the living objects. > So lifecycle should be ensured by class definition. I originally thought this topic would be talked somewhere since many python OOP designer should have met this, or am i wrong on some point? > > >> ChrisA >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iamforufriends at gmail.com Thu Nov 10 09:35:34 2011 From: iamforufriends at gmail.com (sweet girl) Date: Thu, 10 Nov 2011 06:35:34 -0800 (PST) Subject: she want a boy friend for dating Message-ID: she want a boy friend for dating http://alturl.com/b5ikf http://alturl.com/b5ikf http://alturl.com/b5ikf http://alturl.com/b5ikf From vs at it.uu.se Thu Nov 10 09:47:43 2011 From: vs at it.uu.se (Virgil Stokes) Date: Thu, 10 Nov 2011 15:47:43 +0100 Subject: Agent-based modeling Message-ID: <4EBBE40F.9030009@it.uu.se> Python seems like a good language to use for agent-based modeling. However, before starting to work on a Python package for this, I would be very interested in knowing about any existing Python code for agent-based modeling. --V -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 10:16:14 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 23:16:14 +0800 Subject: Agent-based modeling In-Reply-To: <4EBBE40F.9030009@it.uu.se> References: <4EBBE40F.9030009@it.uu.se> Message-ID: 2011/11/10 Virgil Stokes > Python seems like a good language to use for agent-based modeling. > However, before starting to work on a Python package for this, I would be > very interested in knowing about any existing Python code for agent-based > modeling. > I am assuming you are talking about the pattern design -- agent pattern, right? > > > --V > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Thu Nov 10 10:44:29 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Thu, 10 Nov 2011 15:44:29 +0000 Subject: simple import hook Message-ID: <4EBBF15D.9090401@gmail.com> So I would really like to accomplish the following: run a program normally and keep track of all the imports that were actually done. I studied the PEP 302, but I'm still a bit confused about how to do it. I thought that instead of implementing everything I could just record the request and then delegate to the "imp" module, so I did this: class MyLoader(object): """ Loader object """ def __init__(self): self.loaded = set() def find_module(self, module_name, package=None): print("requesting %s" % module_name) self.loaded.add(module_name) return self def load_module(self, fullname): #XXX: the find_module is actually doing nothing, since # everything is delegated to the "imp" module fp, pathname, stuff = imp.find_module(fullname) imp.load_module(fullname, fp, pathname, stuff) myl = MyLoader() sys.meta_path.append(myl) try: import random import os print(random.random()) Which doesn't work, and very strangely it doesn't even look deterministic! Sometimes it stops at first import sometimes it's able to do a few of them. How can that be? And how could I do solve my problem? From tim.wintle at teamrubber.com Thu Nov 10 11:09:08 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Thu, 10 Nov 2011 16:09:08 +0000 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: <1320941348.7601.57.camel@tim-laptop> On Thu, 2011-11-10 at 22:25 +0800, Jerry Zhang wrote: > > > 2011/11/10 Chris Angelico > On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang > wrote: > > Cls_a: > > def __init__(self): > > self.at1 = 1 > > Cls_b: > > def __init__(self): > > self.com1 = Cls_a() > > def __del__(self): > > del self.com1 > > Is it a right implementation for composition? > > > Yes, except that you don't need to explicitly del it. Python > (at > least, CPython) is reference-counted; your Cls_b object owns a > reference to the Cls_a object, so (assuming nothing else has a > reference) that Cls_a will be happily cleaned up when the > Cls_b is. > > Python doesn't really talk about "composition" etc. It's much > simpler: > everything's an object, and you have references to that > object. A > named variable is a reference to some object. A member on an > object > is, too. Whenever an object is expired, all objects that it > references > lose one reference, and if that was the sole reference, those > objects > get expired too. It's a change of thinking, perhaps, but not a > difficult one in my opinion; and it's so easy to work with > when you > grok it. > > > Unfortunately there is a difference between composition and > aggregation in my real word, and my application really care this since > it is trying to simulate this real world model, so my system should > track this difference accurately, otherwise the system may not work > well. You might want to look into weak references: http://docs.python.org/library/weakref.html Although I agree with Chris that it sounds like your code might be easier with a change of perspective (I've not done much UML, but the way you're describing things sounds like a java-ish way of looking at it to me) > For example, > a. the Cls_arm and Cls_body may be composition, but not aggregation. > My app must ensure that " one arm instance only live with one body > instance, if the body instance die, the arm instance must die. > b. the Cls_auto and the Cls_tyre may be aggregation. "One tyre still > can live even the auto is dead." That behaviour isn't really hard-coded as part of the language in python, as it's not required for memory management in the same way it would be in C++ or langauges without GCs. As long as no objects other than body objects hold a reference to arm objects then the arm object will be deleted. For The tyre object to be deleted when the auto object is deleted, there would have to be no references left to the tyre object. If there aren't any references then you can't know if it exists or not anyway, so the distinction isn't useful. > Meanwhile, I have a ZODB running, which stores all the living > objects. The ZODB is append only and stores all objects. Deleting references to an object (which would causes deletion of standard python objects) won't delete it from the zodb, it'll just delete the references. From k.sahithi2862 at gmail.com Thu Nov 10 11:34:07 2011 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Thu, 10 Nov 2011 08:34:07 -0800 (PST) Subject: WORLD BEST PICS Message-ID: <9094454c-45ad-45d4-834d-43cbf645df87@i13g2000prg.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html From vs at it.uu.se Thu Nov 10 12:15:37 2011 From: vs at it.uu.se (Virgil Stokes) Date: Thu, 10 Nov 2011 18:15:37 +0100 Subject: Agent-based modeling In-Reply-To: References: <4EBBE40F.9030009@it.uu.se> Message-ID: <4EBC06B9.6030201@it.uu.se> On 10-Nov-2011 16:16, Jerry Zhang wrote: > > > 2011/11/10 Virgil Stokes > > > Python seems like a good language to use for agent-based modeling. > However, before starting to work on a Python package for this, I would be > very interested in knowing about any existing Python code for agent-based > modeling. > > > I am assuming you are talking about the pattern design -- agent pattern, right? > > > > --V > > -- > http://mail.python.org/mailman/listinfo/python-list > > Sorry Jerry if my email was unclear. I am referring to agent-based modeling as defined at http://en.wikipedia.org/wiki/Agent-based_model -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at cheimes.de Thu Nov 10 12:23:15 2011 From: lists at cheimes.de (Christian Heimes) Date: Thu, 10 Nov 2011 18:23:15 +0100 Subject: The python implementation of the "relationships between classes". In-Reply-To: <1320941348.7601.57.camel@tim-laptop> References: <1320941348.7601.57.camel@tim-laptop> Message-ID: Am 10.11.2011 17:09, schrieb Tim Wintle: >> Meanwhile, I have a ZODB running, which stores all the living >> objects. > > The ZODB is append only and stores all objects. Deleting references to > an object (which would causes deletion of standard python objects) won't > delete it from the zodb, it'll just delete the references. That's not entirely correct. In fact you *CAN* delete references to objects that are stored in ZODB. An unreferenced object is no longer accessible from future transactions. The object is only available from the transaction history log and thus still stored in the database file until the ZODB is packed. Once the ZODB is packed, all unreferenced objects are gone for good. ZODB is much more than a simple pickle jar. It's a transparent and poweful object database that behaves like an ordinary tree of Python objects. From andrea.crotti.0 at gmail.com Thu Nov 10 12:46:07 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Thu, 10 Nov 2011 17:46:07 +0000 Subject: simple import hook In-Reply-To: References: <4EBBF15D.9090401@gmail.com> Message-ID: <4EBC0DDF.9000708@gmail.com> On 11/10/2011 05:02 PM, Eric Snow wrote: > > Yeah, I'm working on a reference for imports in Python. They're just > a little too mysterious relative to the rest of the language. But > it's not too helpful yet. In the meantime... Yes it's quite mysterious, and it's actually not as hard as it looks.. Anyway I'm glad to say that I reached what I basically wanted. This script actually compiles the code and runs it, reporting the imports done in the end. Any suggestion is still welcome :) """ This script is used to analyse the imports which are actually being done """ import argparse import os import sys class CollectImports(object): """ Loader object """ def __init__(self): self.loaded = set() def __str__(self): return str(self.loaded) def find_module(self, module_name, package=None): print("requesting %s" % module_name) self.loaded.add(module_name) if __name__ == '__main__': parser = argparse.ArgumentParser(description='analyse the imports made') parser.add_argument('script') parser.add_argument('arguments', nargs='*') ns = parser.parse_args() progname = ns.script sys.path.insert(0, os.path.dirname(progname)) cl = CollectImports() # TODO: maybe we can create a with clause also for this thing sys.meta_path.append(cl) # TODO: catch the exit signal and present the output code = compile(open(progname).read(), progname, 'exec') exec(code) print("imports done: %s" % str(cl)) > That _is_ pretty strange. > > After what I recommended above, are you still getting the wierdness? > It could just be a side-effect of your use of the imp functions. in > load_module(), so getting rid of it would help. > > What version of Python are you using? If not 2.7 or 3.2, do you get > the same problem when you run the code under one of those latest > versions? > > Even when the number of imports is different, are they always in the > same order? Highly unlikely, but if you say no then this is extra > fishy. > It was python 2.7 on Arch-linux, but thanks to your suggestions everything was actually fixed.. From jerry.scofield at gmail.com Thu Nov 10 13:06:18 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 02:06:18 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: <1320941348.7601.57.camel@tim-laptop> References: <1320941348.7601.57.camel@tim-laptop> Message-ID: 2011/11/11 Tim Wintle > On Thu, 2011-11-10 at 22:25 +0800, Jerry Zhang wrote: > > > > > > 2011/11/10 Chris Angelico > > On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang > > wrote: > > > Cls_a: > > > def __init__(self): > > > self.at1 = 1 > > > Cls_b: > > > def __init__(self): > > > self.com1 = Cls_a() > > > def __del__(self): > > > del self.com1 > > > Is it a right implementation for composition? > > > > > > Yes, except that you don't need to explicitly del it. Python > > (at > > least, CPython) is reference-counted; your Cls_b object owns a > > reference to the Cls_a object, so (assuming nothing else has a > > reference) that Cls_a will be happily cleaned up when the > > Cls_b is. > > > > Python doesn't really talk about "composition" etc. It's much > > simpler: > > everything's an object, and you have references to that > > object. A > > named variable is a reference to some object. A member on an > > object > > is, too. Whenever an object is expired, all objects that it > > references > > lose one reference, and if that was the sole reference, those > > objects > > get expired too. It's a change of thinking, perhaps, but not a > > difficult one in my opinion; and it's so easy to work with > > when you > > grok it. > > > > > > Unfortunately there is a difference between composition and > > aggregation in my real word, and my application really care this since > > it is trying to simulate this real world model, so my system should > > track this difference accurately, otherwise the system may not work > > well. > > You might want to look into weak references: > http://docs.python.org/library/weakref.html > > Although I agree with Chris that it sounds like your code might be > easier with a change of perspective (I've not done much UML, but the way > you're describing things sounds like a java-ish way of looking at it to > me) > > > For example, > > a. the Cls_arm and Cls_body may be composition, but not aggregation. > > My app must ensure that " one arm instance only live with one body > > instance, if the body instance die, the arm instance must die. > > b. the Cls_auto and the Cls_tyre may be aggregation. "One tyre still > > can live even the auto is dead." > > That behaviour isn't really hard-coded as part of the language in > python, as it's not required for memory management in the same way it > would be in C++ or langauges without GCs. > > As long as no objects other than body objects hold a reference to arm > objects then the arm object will be deleted. > > For The tyre object to be deleted when the auto object is deleted, there > would have to be no references left to the tyre object. If there aren't > any references then you can't know if it exists or not anyway, so the > distinction isn't useful. > I just did an example code to describe what i am looking for. /*------------------------------------------------------------------------------------------------*/ # ... class Head: def __init__(self): self.size = 5 class Hat: def __init__(self): self.color = red def took_on(self, body): self.body = body def took_off(self, body): del self.body class Body: def __init__(self): self.head = Head() def take_on_hat(self, hat): self.hat = hat hat.take_on(self) def take_off_hat(self): hat.take_off(self) del self.hat def go_to_heaven(self): take_off_hat(self) del self.head /*----------------------------------------------------------------------------------------------------------*/ In this example, Head and body are COMPOSITION, which means a. A head only live with one body, it can not live with other body. It can not even live without body b. If the body go to die, the head also go to die. Body and Hat are aggregation, which means a. A hat live isolate with body, its life circle is isolate b. A hat only live with one body at a specific time, it can not live with two body(association would be more than one) So when the body die, the clean dead should include take_off Hat and del Head, otherwise, the code definition is not prciselly describing the relationship, which may cause a mess system, for example, a body has dead, but one hat is still associated with a unreferenced body. A point on this issue, maybe python is smart that the take_off_hat(self) is not needed in go_to_heaven() method(i am not sure yet), but the del self.head is sure needed, otherwise, we will have a no_body_head in our ZODB, that is extremely horrible, right? All of these points one, the four kinds of class relationship in UML precisely describe the real word, if the implementation is not precisely, you will have unexpected results. Of course, python may be smart to achieve such goal with less effort, that is why i am asking for a code example for all of the four relationships. > > > Meanwhile, I have a ZODB running, which stores all the living > > objects. > > The ZODB is append only and stores all objects. Deleting references to > an object (which would causes deletion of standard python objects) won't > delete it from the zodb, it'll just delete the references. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 13:13:37 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 02:13:37 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <1320941348.7601.57.camel@tim-laptop> Message-ID: 2011/11/11 Christian Heimes > Am 10.11.2011 17:09, schrieb Tim Wintle: > >> Meanwhile, I have a ZODB running, which stores all the living > >> objects. > > > > The ZODB is append only and stores all objects. Deleting references to > > an object (which would causes deletion of standard python objects) won't > > delete it from the zodb, it'll just delete the references. > > That's not entirely correct. In fact you *CAN* delete references to > objects that are stored in ZODB. An unreferenced object is no longer > accessible from future transactions. The object is only available from > the transaction history log and thus still stored in the database file > until the ZODB is packed. Once the ZODB is packed, all unreferenced > objects are gone for good. > > ZODB is much more than a simple pickle jar. It's a transparent and > poweful object database that behaves like an ordinary tree of Python > objects. > > I am verifying the ZODB solution, not clear yet, anyway, your points regarding this sounds reasonable to me. i am almost sure the python and ZODB designer has already did a good job to make us handle such case easily, all i am trying to do is find the right path. Thanks a lot. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From numansenm at gmail.com Thu Nov 10 13:25:41 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:25:41 -0800 (PST) Subject: buy Paxil online without a prescription and no membership no prescription needed Paxil Message-ID: <23d833f3-ab6a-4f07-a1f3-428908ce0252@w3g2000vbw.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Paxil/Paxil pills with every Order ______________________________________________________________________ BUY Paxil ONLINE http://buypharmasite.com/?q=Paxil CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Paxil ONLINE http://buypharmasite.com/?q=Paxil CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Paxil Paxil online saturday delivery online Paxil and fedex cheap order prescription Paxil cheap Paxil by money order buy Paxil from mexico online Paxil no prescription usa fedex shipping overnight delivery Paxil buy Paxil online without a prescription and no membership no prescription needed Paxil cod shipped Paxil not expensive order prescription Paxil Paxil money order Paxil without a perscription online buy Paxil Paxil fedex buy no online prescription Paxil Paxil pharmacies accepting cod delivery Paxil online consultant online pharmacy fedex cod Paxil buy Paxil no scams Paxil c.o.d overnight delivery buy Paxil no prescription cod overnight Paxil order Paxil online doctors buy Paxil on line no prescription Paxil no prescription usa fedex shipping Paxil online uk watson brand Paxil medicine online Paxil order Paxil samples sent buy Paxil no prescription order Paxil without a prescription Paxil no prescription drug cheap online order Paxil get Paxil over the counter online order Paxil next day buy Paxil no perscription cod real Paxil fed ex Paxil no prescription cod does cv/ pharmacy carry Paxil no prescription cod Paxil cheap Paxil without rx Paxil online health insurance lead buy Paxil online with overnight delivery Paxil no rx fed ex buy Paxil without a perscription lowest prices for Paxil online buy Paxil paypal online without prescription cheap non prescription Paxil Paxil ups Paxil for cheap buy Paxil no visa online without prescription cheapest Paxil cash on delivery Paxil order a prepaid mastercard buy online Paxil purchase Paxil mail order Paxil without a prescription online with overnight delivery Paxil from canada buy Paxil with no rx overnight delivery of Paxil with no prescription cash on delivery Paxil no rx Paxil by cod buy Paxil over the counter cod overnight overnight Paxil order Paxil without prescription from us pharmacy cheap Paxil free fedex shipping order Paxil over the counter where to buy Paxil no prescription no fees only Paxil free consult cod delivery Paxil Paxil no prescription Paxil online overnight delivery cod order Paxil over the counter fedex Paxil saturday delivery buy Paxil money order Paxil without prescription mexico buy cheap Paxil without prescription Paxil non prescription for next day delivery Paxil ups delivery only buy Paxil usa cod Paxil with next day delivery no prescriptions needed for Paxil cheap Paxil overnight prescription Paxil cheap Paxil overnight delivery Paxil non prescription fedex overnight free order Paxil no creditcard buy cheap Paxil no Prescription buy Paxil over the counter fedex Paxil no doctor presribe needed cheap watson Paxil online cheap discount Paxil buy Paxil without a prescription online cheapest Paxil free delivery buy Paxil online overseas buy Paxil over the counter online not expensive Paxil next day shipping order Paxil cod next day delivery Paxil cheap Paxil buy in UK Paxil next day cod fedex Paxil to buy cheap order Paxil next day Paxil Paxil overnight no consult cheap watson Paxil no prescription needed Paxil without prescription medications overnight delivery of Paxil with no perscription buy Paxil.com Paxil cod next day delivery buy cheap discount online Paxil buy Paxil drug Paxil overnight delivery cheap overnight delivery of Paxil in US no prescription needed purchase Paxil free next day airPaxil on line cheap Paxil without a prescription Paxil cheap cod Paxil buy no prepaid cheap Paxil next day buy Paxil cod accepted online pharmacies Paxil saturday delivery buy Paxil pay pal Paxil shipped on saturday Paxil pharmacy cod saturday delivery buy online Paxil prescriptions free fedex delivery Paxil Paxil without prescription cash on delivery buy discount Paxil Paxil overnight cheap best Paxil online pill images of Paxil Paxil U.P.S SHIPPING COD Paxil cod pharmacy buy Paxil online cod Paxil cod overnight delivery Paxil no rx overnight buy Paxil overnight COD online pharmacy Paxil cod order Paxil insurance Paxil cash delivery cod buy Paxil cheap cod no rx online pharmacy Paxil sale nextday Paxil Paxil pill Paxil online ordering Paxil online without prescription Paxil no script needed cod overnight how to buy Paxil online without a prescription cheap Paxil without prescription cheap Paxil online no rx saturday delivery order Paxil over the counter for sale Paxil next day delivery cod order Paxil online without prescription no prescription next day delivery Paxil overnight Paxil C.O.D Paxil without prescription Paxil discount fedex no prescription buy Paxil amex Paxil online next day Paxil shipped with no prescription Paxil online cheap cheap Paxil without prescription overnight delivery buy Paxil over the counter for sale Paxil no prescriptions needed cod Paxil fed ex cheap overnight delivery of Paxil free prescription Paxil free shipping not expensive legal Paxil for sale buy Paxil cod Paxil for saturday Paxil price cash for Paxil cash on delivery Paxil Paxil without a prescription and cod delivery buying Paxil without a prescription order Paxil no rx buy Paxil without rx Paxil cheapest buy Paxil online pharmacy buy cheap Paxil overnight delivery Paxil and online pharmacy Paxil next day Paxil drug no prescription where can i buy Paxil no prescription Paxil with saturday delivery Paxil online overnight Paxil no prescription worldwide buy cheap Paxil cod ordering Paxil online Buy Paxil overnight shipping Paxil overnight US delivery cheap real Paxil for sale Paxil no prescriptions needed COD buy Paxil no prescription needed Paxil no prescription overnight cod delivery cheap Paxil cash on delivery no prescription required for Paxil order Paxil c.o.d. not expensive Paxil prescriptions Paxil online Cash on Delivery buy Paxil overnight delivery Paxil online without presciption buy Paxil prescription online no prescription saturday delivery Paxil where to buy cheap Paxil no prescription Paxil wo get Paxil over the counter fedex Paxil with no rx and free shipping order Paxil over the counter cod overnight Paxil Fedex Without Prescription Paxil Online With Next Day Shipping Buy Cheap Paxil online | purchase Paxil without prescription online | Paxil Online Prescriptions With No Membership Paxil Cheap next day | Buy Cheap Paxil fedex overnight | original Paxil pill | Purchase Paxil pharmacy r x online | Paxil cod Orders | Buy Paxil online pharmacy | Paxil cod ne xt day delivery | order Paxil online no membership overnight shipping | B uy Cheap Paxil Online No Prescription Order Paxil cod next day delivery | Paxil Discount cards | Buy genuine Paxil online | buying Paxil without a prescription | Where To Buy Paxil No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Paxil fedex without prescription | U ltram consumer information | pills Cheap generic Paxil | Buy Paxil onlin e no prescription | Paxil Buy | Buy Cheap Paxil Online No Prescription B uy Paxil online | purchase Paxil without prescription | Buying Paxil On line Without Prescription Paxil Overnight COD no prescription | Cheap onli ne Buy Paxil | Low Price Paxil Saturday Delivery No Prescription Paxil w ithout a prescription no generics | Buy Paxil Without Prescription Paxil overnight | Buy With No Prescription Paxil Online Order Paxil no rx overn ight delivery | Order Paxil Saturday Delivery No Prescription Paxil onlin e no prescription | Paxil Discount cards | Buy Paxil no script | Paxil by phone no script | Buy Paxil Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Paxil online without a prescription and no me mbership | Buy Without Prescription Paxil Online buy no prescription Ultra m | Order Paxil Cheap no membership fees no prescription | Paxil order n o script | Paxil lowest cost | online Buy Paxil | Overnight Paxil With out A Prescription Paxil Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Paxil Without A Prescription no script Paxil | Paxil Buy phone | Paxil paid with mastercard | Paxil With No Prescript ion Paxil to purchase | Order Paxil online with no prescription | Paxil Buying online Paxil drugs | Paxil free Overnight fedex delivery | Ultra m best online pharmacy | purchase Paxil without a prescription overnight d elivery | Buy Paxil online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Paxil From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Paxil next day | Where To Buy Paxil No Prescription No Fees Paxil ups cod | Order Paxil cash on delive ry | Paxil overnight shipping no prescription | purchase Paxil without p rescription online | Buy Paxil online without dr approval | Buy Paxil on line without dr approval | Paxil ups | Paxil Buy | Buy Paxil in Idaho | Paxil cheapest | Buy Paxil pay with mastercard | ordering Buy Paxil online | Paxil Overnight COD no prescription | Paxil order cod | Paxil No Prescription Paxil overnight delivery Cheap | Paxil order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Paxil usa online pharmacy | U ltram free consultation | how to Order Paxil without doctors | Purchase U ltram online | comprar Paxil | No Prescription Required For Paxil Paxil cod ordering | Cheap Paxil without prescription | Buy Cheap Paxil fast | Paxil Buy | Buy Paxil online without a prescription and no membership | Cheap Paxil without prescription overnight delivery | cash on delivery online prescriptions Paxil | Paxil with no prescription | ordering Ultra m online without a prescription | Paxil Cheap order | Paxil online no pr escription | No Prescription Needed Paxil Low Price Paxil With No Prescri ption Buy Paxil Online Without Prescription buy no prescription Paxil | B uy Paxil online discount | Paxil order cod | Order Cheap Paxil very Buy without prescription | Paxil cod next day delivery | Order Paxil Online Without Prescription Paxil free Overnight fedex delivery | Cheap Paxil b y money Order | Buy Paxil online discount | overnight Paxil | 8 Buy Ult ram online | Cheap Paxil c.o.d. | Buy Paxil Tablets Without Prescription Overnight Paxil for sale | Buy Paxil online sales | natural Paxil | U ltram manufacturer | Paxil Online No Prescription Paxil adiction | geniu ne Paxil no prescription | Paxil Pharmacy Cod Saturday Delivery With No P rescription Paxil Buy phone | Buy Paxil online prescription | Order Ultr am without prescription from us pharmacy | Buy real Paxil with mastercard | Paxil without a rx | doctor online prescription Paxil | Paxil Free O vernight Fedex Delivery order Paxil online cash on delivery | Cheap Paxil next day | Buy Paxil Cheap online us pharmacy | Paxil delivery to uk fe dex Overnight | Find Cheap Paxil no prescription | online pharmacy Paxil | Buy Paxil Online Without A Prescription And No Membership Paxil to pur chase | Paxil Same Day Delivery No Prescription Paxil by phone no script | Buy Paxil without | discount Paxil overnight | Buy Cheap Paxil, Buy Cheap Paxil online | Paxil Buy fedex | Paxil shipped with no prescripti on | Buy Paxil online money order | purchase Paxil without a prescriptio n | Paxil ups cod | Buy Paxil Online No Prescription Buy Paxil online | Paxil with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Paxil cod | how to get Paxil prescription | Low Price Paxil With No Prescription Buy the Cheapest Paxil online index | prescription U ltram | Order Paxil No Prescription Order Paxil medicine online without p rescription | Low Price Paxil Saturday Delivery No Prescription Cheap Ultr am overnight | Paxil Online No Prescription Paxil online cash on delivery | Fedex Paxil Without Prescription Buy Paxil online usa | Paxil for sa le without a prescription | to Buy Paxil without a prescription | Paxil Overnight no script mastercard accepted | Buy Cheap Paxil No Prescription Cheap Paxil free consultant | Buy Paxil Cheap online us pharmacy | Buy C heap Paxil No Prescription Paxil lowest cost | Where To Buy Paxil No Pre scription No Fees Cheapest Paxil Online Without Prescription cheapest Ultra m | Paxil amphetimine | Buy Paxil 120 tabs | Buy Paxil Without A Presc ription Or Membership Paxil Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Paxil | Paxil conversion | overnight Paxil ups cod | Buy Paxil online Cheap | Paxil No Script Required Express Delivery With No P rescription Paxil free consultation u.s. pharmacy | Paxil cod no script | Paxil ups cod | Paxil online no prescription | purchase Paxil with co d | Canadian Paxil Pills No Prescription Buy Paxil in North Carolina | buy Paxil in Denmark, buy Paxil in Egypt, buy Paxil in Israel, buy Paxil in Ireland, buy Paxil in Spain, buy Paxil in Italy, buy Paxil in Canada, buy Paxil in Cyprus, buy Paxil in Mexico, buy Paxil in Netherlands, buy Paxil in New zealand, buy Paxil in Kingston, buy Paxil in Australia, buy Paxil in AU, buy Paxil in New South Wales, buy Paxil in NSW, buy Paxil i n Sydney, buy Paxil in Brisbane, buy Paxil in South Australia, buy Paxil in Hobart, buy Paxil in the United states, buy Paxil in Finland, buy Ultra m in France, buy Paxil in Chekhiya, buy Paxil in Switzerland, buy Paxil i n Sweden, buy Paxil in Alberta, buy Paxil in Labrador, buy Paxil in Toron to, buy Paxil in Ottawa, buy Paxil in Mississauga, buy Paxil in Hamilton, buy Paxil in Brampton, buy Paxil in London, buy Paxil in Markham, buy Ul tram in Vaughan, buy Paxil in Windsor, buy Paxil in Kitchener, buy Paxil in Montreal, buy Paxil in Mauricie, buy Paxil in Vancouver, buy Paxil in Victoria, buy Paxil in Kelowna, buy Paxil in Abbotsford, buy Paxil in Kam loops, buy Paxil in Nanaimo, buy Paxil in Vernon, buy Paxil in Lethbridge , buy Paxil in United Kingdom, buy Paxil in England, buy Paxil in Wales, buy Paxil in Scotland, buy Paxil in Northern Ireland, buy Paxil in Belfas t, buy Paxil in Cardiff, buy Paxil in London, buy Paxil in Glasgow, buy U ltram in Liverpool, buy Paxil in Leeds, buy Paxil in Victoria, buy Paxil in Melbourne, buy Paxil in Western Australia, buy Paxil in Perth, buy Ultr am in Alabama, buy Paxil in Arizona, buy Paxil in Arkansas, buy Paxil in California, buy Paxil in Colorado, buy Paxil in Connecticut, buy Paxil in Delaware, buy Paxil in Florida, buy Paxil in Georgia, buy Paxil in Hawai i, buy Paxil in Idaho, buy Paxil in Illinois, buy Paxil in Indiana, buy U ltram in Iowa, buy Paxil in Kansas, buy Paxil in Kentucky, buy Paxil in L ouisiana, buy Paxil in Maine, buy Paxil in Montana, buy Paxil in Nebraska , buy Paxil in Nevada, buy Paxil in New Jersey, buy Paxil in New Mexico, buy Paxil in New York, buy Paxil in North Carolina, buy Paxil in North Da kota, buy Paxil in Ohio, buy Paxil in Oklahoma, buy Paxil in Texas, buy U ltram in Utah, buy Paxil in Vermont, buy Paxil in Virginia, buy Paxil in Washington, buy Paxil in West Virginia, buy Paxil in Wisconsin, buy Paxil in Wyoming, buy Paxil in Montgomery, buy Paxil in Juneau, buy Paxil in P hoenix, buy Paxil in Little Rock, buy Paxil in Sacramento, buy Paxil in D enver, buy Paxil in Hartford, buy Paxil in Dover, buy Paxil in Tallahasse e, buy Paxil in Atlanta, buy Paxil in Springfield, buy Paxil in Indianapo lis, buy Paxil in Des Moines, buy Paxil in Annapolis, buy Paxil in Boston , buy Paxil in Lansing, buy Paxil in Helena, buy Paxil in Lincoln, buy Ul tram in Santa Fe, buy Paxil in Albany, buy Paxil in Raleigh, buy Paxil in Bismarck, buy Paxil in Columbus, buy Paxil in Salem, buy Paxil in Columb ia, buy Paxil in Salt Lake City, buy Paxil in Montpelier, buy Paxil in Ch arleston, buy Paxil in Madison, buy Paxil in Cheyenne, buy Paxil in Austr alia, buy Paxil in Austria, buy Paxil in Argentina, buy Paxil in Belgium, buy Paxil in Bulgaria, buy Paxil in Brasilia, buy Paxil in Great britain , buy Paxil in Hungary, buy Paxil in Germany, buy Paxil in Greece, buy Ul tram in South Africa, buy Paxil in Japan From numansenm at gmail.com Thu Nov 10 13:28:13 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:28:13 -0800 (PST) Subject: buy Oxycontin paypal online without prescription | Oxycontin online health insurance lead Message-ID: <48ea0afa-6e46-482f-a868-e6035699754a@z20g2000yqc.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Oxycontin/Oxycontin pills with every Order ______________________________________________________________________ BUY Oxycontin ONLINE http://buypharmasite.com/?q=Oxycontin CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Oxycontin ONLINE http://buypharmasite.com/?q=Oxycontin CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Oxycontin Oxycontin online saturday delivery online Oxycontin and fedex cheap order prescription Oxycontin cheap Oxycontin by money order buy Oxycontin from mexico online Oxycontin no prescription usa fedex shipping overnight delivery Oxycontin buy Oxycontin online without a prescription and no membership no prescription needed Oxycontin cod shipped Oxycontin not expensive order prescription Oxycontin Oxycontin money order Oxycontin without a perscription online buy Oxycontin Oxycontin fedex buy no online prescription Oxycontin Oxycontin pharmacies accepting cod delivery Oxycontin online consultant online pharmacy fedex cod Oxycontin buy Oxycontin no scams Oxycontin c.o.d overnight delivery buy Oxycontin no prescription cod overnight Oxycontin order Oxycontin online doctors buy Oxycontin on line no prescription Oxycontin no prescription usa fedex shipping Oxycontin online uk watson brand Oxycontin medicine online Oxycontin order Oxycontin samples sent buy Oxycontin no prescription order Oxycontin without a prescription Oxycontin no prescription drug cheap online order Oxycontin get Oxycontin over the counter online order Oxycontin next day buy Oxycontin no perscription cod real Oxycontin fed ex Oxycontin no prescription cod does cv/ pharmacy carry Oxycontin no prescription cod Oxycontin cheap Oxycontin without rx Oxycontin online health insurance lead buy Oxycontin online with overnight delivery Oxycontin no rx fed ex buy Oxycontin without a perscription lowest prices for Oxycontin online buy Oxycontin paypal online without prescription cheap non prescription Oxycontin Oxycontin ups Oxycontin for cheap buy Oxycontin no visa online without prescription cheapest Oxycontin cash on delivery Oxycontin order a prepaid mastercard buy online Oxycontin purchase Oxycontin mail order Oxycontin without a prescription online with overnight delivery Oxycontin from canada buy Oxycontin with no rx overnight delivery of Oxycontin with no prescription cash on delivery Oxycontin no rx Oxycontin by cod buy Oxycontin over the counter cod overnight overnight Oxycontin order Oxycontin without prescription from us pharmacy cheap Oxycontin free fedex shipping order Oxycontin over the counter where to buy Oxycontin no prescription no fees only Oxycontin free consult cod delivery Oxycontin Oxycontin no prescription Oxycontin online overnight delivery cod order Oxycontin over the counter fedex Oxycontin saturday delivery buy Oxycontin money order Oxycontin without prescription mexico buy cheap Oxycontin without prescription Oxycontin non prescription for next day delivery Oxycontin ups delivery only buy Oxycontin usa cod Oxycontin with next day delivery no prescriptions needed for Oxycontin cheap Oxycontin overnight prescription Oxycontin cheap Oxycontin overnight delivery Oxycontin non prescription fedex overnight free order Oxycontin no creditcard buy cheap Oxycontin no Prescription buy Oxycontin over the counter fedex Oxycontin no doctor presribe needed cheap watson Oxycontin online cheap discount Oxycontin buy Oxycontin without a prescription online cheapest Oxycontin free delivery buy Oxycontin online overseas buy Oxycontin over the counter online not expensive Oxycontin next day shipping order Oxycontin cod next day delivery Oxycontin cheap Oxycontin buy in UK Oxycontin next day cod fedex Oxycontin to buy cheap order Oxycontin next day Oxycontin Oxycontin overnight no consult cheap watson Oxycontin no prescription needed Oxycontin without prescription medications overnight delivery of Oxycontin with no perscription buy Oxycontin.com Oxycontin cod next day delivery buy cheap discount online Oxycontin buy Oxycontin drug Oxycontin overnight delivery cheap overnight delivery of Oxycontin in US no prescription needed purchase Oxycontin free next day airOxycontin on line cheap Oxycontin without a prescription Oxycontin cheap cod Oxycontin buy no prepaid cheap Oxycontin next day buy Oxycontin cod accepted online pharmacies Oxycontin saturday delivery buy Oxycontin pay pal Oxycontin shipped on saturday Oxycontin pharmacy cod saturday delivery buy online Oxycontin prescriptions free fedex delivery Oxycontin Oxycontin without prescription cash on delivery buy discount Oxycontin Oxycontin overnight cheap best Oxycontin online pill images of Oxycontin Oxycontin U.P.S SHIPPING COD Oxycontin cod pharmacy buy Oxycontin online cod Oxycontin cod overnight delivery Oxycontin no rx overnight buy Oxycontin overnight COD online pharmacy Oxycontin cod order Oxycontin insurance Oxycontin cash delivery cod buy Oxycontin cheap cod no rx online pharmacy Oxycontin sale nextday Oxycontin Oxycontin pill Oxycontin online ordering Oxycontin online without prescription Oxycontin no script needed cod overnight how to buy Oxycontin online without a prescription cheap Oxycontin without prescription cheap Oxycontin online no rx saturday delivery order Oxycontin over the counter for sale Oxycontin next day delivery cod order Oxycontin online without prescription no prescription next day delivery Oxycontin overnight Oxycontin C.O.D Oxycontin without prescription Oxycontin discount fedex no prescription buy Oxycontin amex Oxycontin online next day Oxycontin shipped with no prescription Oxycontin online cheap cheap Oxycontin without prescription overnight delivery buy Oxycontin over the counter for sale Oxycontin no prescriptions needed cod Oxycontin fed ex cheap overnight delivery of Oxycontin free prescription Oxycontin free shipping not expensive legal Oxycontin for sale buy Oxycontin cod Oxycontin for saturday Oxycontin price cash for Oxycontin cash on delivery Oxycontin Oxycontin without a prescription and cod delivery buying Oxycontin without a prescription order Oxycontin no rx buy Oxycontin without rx Oxycontin cheapest buy Oxycontin online pharmacy buy cheap Oxycontin overnight delivery Oxycontin and online pharmacy Oxycontin next day Oxycontin drug no prescription where can i buy Oxycontin no prescription Oxycontin with saturday delivery Oxycontin online overnight Oxycontin no prescription worldwide buy cheap Oxycontin cod ordering Oxycontin online Buy Oxycontin overnight shipping Oxycontin overnight US delivery cheap real Oxycontin for sale Oxycontin no prescriptions needed COD buy Oxycontin no prescription needed Oxycontin no prescription overnight cod delivery cheap Oxycontin cash on delivery no prescription required for Oxycontin order Oxycontin c.o.d. not expensive Oxycontin prescriptions Oxycontin online Cash on Delivery buy Oxycontin overnight delivery Oxycontin online without presciption buy Oxycontin prescription online no prescription saturday delivery Oxycontin where to buy cheap Oxycontin no prescription Oxycontin wo get Oxycontin over the counter fedex Oxycontin with no rx and free shipping order Oxycontin over the counter cod overnight Oxycontin Fedex Without Prescription Oxycontin Online With Next Day Shipping Buy Cheap Oxycontin online | purchase Oxycontin without prescription online | Oxycontin Online Prescriptions With No Membership Oxycontin Cheap next day | Buy Cheap Oxycontin fedex overnight | original Oxycontin pill | Purchase Oxycontin pharmacy r x online | Oxycontin cod Orders | Buy Oxycontin online pharmacy | Oxycontin cod ne xt day delivery | order Oxycontin online no membership overnight shipping | B uy Cheap Oxycontin Online No Prescription Order Oxycontin cod next day delivery | Oxycontin Discount cards | Buy genuine Oxycontin online | buying Oxycontin without a prescription | Where To Buy Oxycontin No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Oxycontin fedex without prescription | U ltram consumer information | pills Cheap generic Oxycontin | Buy Oxycontin onlin e no prescription | Oxycontin Buy | Buy Cheap Oxycontin Online No Prescription B uy Oxycontin online | purchase Oxycontin without prescription | Buying Oxycontin On line Without Prescription Oxycontin Overnight COD no prescription | Cheap onli ne Buy Oxycontin | Low Price Oxycontin Saturday Delivery No Prescription Oxycontin w ithout a prescription no generics | Buy Oxycontin Without Prescription Oxycontin overnight | Buy With No Prescription Oxycontin Online Order Oxycontin no rx overn ight delivery | Order Oxycontin Saturday Delivery No Prescription Oxycontin onlin e no prescription | Oxycontin Discount cards | Buy Oxycontin no script | Oxycontin by phone no script | Buy Oxycontin Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Oxycontin online without a prescription and no me mbership | Buy Without Prescription Oxycontin Online buy no prescription Ultra m | Order Oxycontin Cheap no membership fees no prescription | Oxycontin order n o script | Oxycontin lowest cost | online Buy Oxycontin | Overnight Oxycontin With out A Prescription Oxycontin Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Oxycontin Without A Prescription no script Oxycontin | Oxycontin Buy phone | Oxycontin paid with mastercard | Oxycontin With No Prescript ion Oxycontin to purchase | Order Oxycontin online with no prescription | Oxycontin Buying online Oxycontin drugs | Oxycontin free Overnight fedex delivery | Ultra m best online pharmacy | purchase Oxycontin without a prescription overnight d elivery | Buy Oxycontin online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Oxycontin From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Oxycontin next day | Where To Buy Oxycontin No Prescription No Fees Oxycontin ups cod | Order Oxycontin cash on delive ry | Oxycontin overnight shipping no prescription | purchase Oxycontin without p rescription online | Buy Oxycontin online without dr approval | Buy Oxycontin on line without dr approval | Oxycontin ups | Oxycontin Buy | Buy Oxycontin in Idaho | Oxycontin cheapest | Buy Oxycontin pay with mastercard | ordering Buy Oxycontin online | Oxycontin Overnight COD no prescription | Oxycontin order cod | Oxycontin No Prescription Oxycontin overnight delivery Cheap | Oxycontin order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Oxycontin usa online pharmacy | U ltram free consultation | how to Order Oxycontin without doctors | Purchase U ltram online | comprar Oxycontin | No Prescription Required For Oxycontin Oxycontin cod ordering | Cheap Oxycontin without prescription | Buy Cheap Oxycontin fast | Oxycontin Buy | Buy Oxycontin online without a prescription and no membership | Cheap Oxycontin without prescription overnight delivery | cash on delivery online prescriptions Oxycontin | Oxycontin with no prescription | ordering Ultra m online without a prescription | Oxycontin Cheap order | Oxycontin online no pr escription | No Prescription Needed Oxycontin Low Price Oxycontin With No Prescri ption Buy Oxycontin Online Without Prescription buy no prescription Oxycontin | B uy Oxycontin online discount | Oxycontin order cod | Order Cheap Oxycontin very Buy without prescription | Oxycontin cod next day delivery | Order Oxycontin Online Without Prescription Oxycontin free Overnight fedex delivery | Cheap Oxycontin b y money Order | Buy Oxycontin online discount | overnight Oxycontin | 8 Buy Ult ram online | Cheap Oxycontin c.o.d. | Buy Oxycontin Tablets Without Prescription Overnight Oxycontin for sale | Buy Oxycontin online sales | natural Oxycontin | U ltram manufacturer | Oxycontin Online No Prescription Oxycontin adiction | geniu ne Oxycontin no prescription | Oxycontin Pharmacy Cod Saturday Delivery With No P rescription Oxycontin Buy phone | Buy Oxycontin online prescription | Order Ultr am without prescription from us pharmacy | Buy real Oxycontin with mastercard | Oxycontin without a rx | doctor online prescription Oxycontin | Oxycontin Free O vernight Fedex Delivery order Oxycontin online cash on delivery | Cheap Oxycontin next day | Buy Oxycontin Cheap online us pharmacy | Oxycontin delivery to uk fe dex Overnight | Find Cheap Oxycontin no prescription | online pharmacy Oxycontin | Buy Oxycontin Online Without A Prescription And No Membership Oxycontin to pur chase | Oxycontin Same Day Delivery No Prescription Oxycontin by phone no script | Buy Oxycontin without | discount Oxycontin overnight | Buy Cheap Oxycontin, Buy Cheap Oxycontin online | Oxycontin Buy fedex | Oxycontin shipped with no prescripti on | Buy Oxycontin online money order | purchase Oxycontin without a prescriptio n | Oxycontin ups cod | Buy Oxycontin Online No Prescription Buy Oxycontin online | Oxycontin with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Oxycontin cod | how to get Oxycontin prescription | Low Price Oxycontin With No Prescription Buy the Cheapest Oxycontin online index | prescription U ltram | Order Oxycontin No Prescription Order Oxycontin medicine online without p rescription | Low Price Oxycontin Saturday Delivery No Prescription Cheap Ultr am overnight | Oxycontin Online No Prescription Oxycontin online cash on delivery | Fedex Oxycontin Without Prescription Buy Oxycontin online usa | Oxycontin for sa le without a prescription | to Buy Oxycontin without a prescription | Oxycontin Overnight no script mastercard accepted | Buy Cheap Oxycontin No Prescription Cheap Oxycontin free consultant | Buy Oxycontin Cheap online us pharmacy | Buy C heap Oxycontin No Prescription Oxycontin lowest cost | Where To Buy Oxycontin No Pre scription No Fees Cheapest Oxycontin Online Without Prescription cheapest Ultra m | Oxycontin amphetimine | Buy Oxycontin 120 tabs | Buy Oxycontin Without A Presc ription Or Membership Oxycontin Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Oxycontin | Oxycontin conversion | overnight Oxycontin ups cod | Buy Oxycontin online Cheap | Oxycontin No Script Required Express Delivery With No P rescription Oxycontin free consultation u.s. pharmacy | Oxycontin cod no script | Oxycontin ups cod | Oxycontin online no prescription | purchase Oxycontin with co d | Canadian Oxycontin Pills No Prescription Buy Oxycontin in North Carolina | buy Oxycontin in Denmark, buy Oxycontin in Egypt, buy Oxycontin in Israel, buy Oxycontin in Ireland, buy Oxycontin in Spain, buy Oxycontin in Italy, buy Oxycontin in Canada, buy Oxycontin in Cyprus, buy Oxycontin in Mexico, buy Oxycontin in Netherlands, buy Oxycontin in New zealand, buy Oxycontin in Kingston, buy Oxycontin in Australia, buy Oxycontin in AU, buy Oxycontin in New South Wales, buy Oxycontin in NSW, buy Oxycontin i n Sydney, buy Oxycontin in Brisbane, buy Oxycontin in South Australia, buy Oxycontin in Hobart, buy Oxycontin in the United states, buy Oxycontin in Finland, buy Ultra m in France, buy Oxycontin in Chekhiya, buy Oxycontin in Switzerland, buy Oxycontin i n Sweden, buy Oxycontin in Alberta, buy Oxycontin in Labrador, buy Oxycontin in Toron to, buy Oxycontin in Ottawa, buy Oxycontin in Mississauga, buy Oxycontin in Hamilton, buy Oxycontin in Brampton, buy Oxycontin in London, buy Oxycontin in Markham, buy Ul tram in Vaughan, buy Oxycontin in Windsor, buy Oxycontin in Kitchener, buy Oxycontin in Montreal, buy Oxycontin in Mauricie, buy Oxycontin in Vancouver, buy Oxycontin in Victoria, buy Oxycontin in Kelowna, buy Oxycontin in Abbotsford, buy Oxycontin in Kam loops, buy Oxycontin in Nanaimo, buy Oxycontin in Vernon, buy Oxycontin in Lethbridge , buy Oxycontin in United Kingdom, buy Oxycontin in England, buy Oxycontin in Wales, buy Oxycontin in Scotland, buy Oxycontin in Northern Ireland, buy Oxycontin in Belfas t, buy Oxycontin in Cardiff, buy Oxycontin in London, buy Oxycontin in Glasgow, buy U ltram in Liverpool, buy Oxycontin in Leeds, buy Oxycontin in Victoria, buy Oxycontin in Melbourne, buy Oxycontin in Western Australia, buy Oxycontin in Perth, buy Ultr am in Alabama, buy Oxycontin in Arizona, buy Oxycontin in Arkansas, buy Oxycontin in California, buy Oxycontin in Colorado, buy Oxycontin in Connecticut, buy Oxycontin in Delaware, buy Oxycontin in Florida, buy Oxycontin in Georgia, buy Oxycontin in Hawai i, buy Oxycontin in Idaho, buy Oxycontin in Illinois, buy Oxycontin in Indiana, buy U ltram in Iowa, buy Oxycontin in Kansas, buy Oxycontin in Kentucky, buy Oxycontin in L ouisiana, buy Oxycontin in Maine, buy Oxycontin in Montana, buy Oxycontin in Nebraska , buy Oxycontin in Nevada, buy Oxycontin in New Jersey, buy Oxycontin in New Mexico, buy Oxycontin in New York, buy Oxycontin in North Carolina, buy Oxycontin in North Da kota, buy Oxycontin in Ohio, buy Oxycontin in Oklahoma, buy Oxycontin in Texas, buy U ltram in Utah, buy Oxycontin in Vermont, buy Oxycontin in Virginia, buy Oxycontin in Washington, buy Oxycontin in West Virginia, buy Oxycontin in Wisconsin, buy Oxycontin in Wyoming, buy Oxycontin in Montgomery, buy Oxycontin in Juneau, buy Oxycontin in P hoenix, buy Oxycontin in Little Rock, buy Oxycontin in Sacramento, buy Oxycontin in D enver, buy Oxycontin in Hartford, buy Oxycontin in Dover, buy Oxycontin in Tallahasse e, buy Oxycontin in Atlanta, buy Oxycontin in Springfield, buy Oxycontin in Indianapo lis, buy Oxycontin in Des Moines, buy Oxycontin in Annapolis, buy Oxycontin in Boston , buy Oxycontin in Lansing, buy Oxycontin in Helena, buy Oxycontin in Lincoln, buy Ul tram in Santa Fe, buy Oxycontin in Albany, buy Oxycontin in Raleigh, buy Oxycontin in Bismarck, buy Oxycontin in Columbus, buy Oxycontin in Salem, buy Oxycontin in Columb ia, buy Oxycontin in Salt Lake City, buy Oxycontin in Montpelier, buy Oxycontin in Ch arleston, buy Oxycontin in Madison, buy Oxycontin in Cheyenne, buy Oxycontin in Austr alia, buy Oxycontin in Austria, buy Oxycontin in Argentina, buy Oxycontin in Belgium, buy Oxycontin in Bulgaria, buy Oxycontin in Brasilia, buy Oxycontin in Great britain , buy Oxycontin in Hungary, buy Oxycontin in Germany, buy Oxycontin in Greece, buy Ul tram in South Africa, buy Oxycontin in Japan From numansenm at gmail.com Thu Nov 10 13:30:07 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:30:07 -0800 (PST) Subject: Oxycodone without a prescription online with overnight delivery | buy Oxycodone no visa online without prescription Message-ID: ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Oxycodone/Oxycodone pills with every Order ______________________________________________________________________ BUY Oxycodone ONLINE http://buypharmasite.com/?q=Oxycodone CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Oxycodone ONLINE http://buypharmasite.com/?q=Oxycodone CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Oxycodone Oxycodone online saturday delivery online Oxycodone and fedex cheap order prescription Oxycodone cheap Oxycodone by money order buy Oxycodone from mexico online Oxycodone no prescription usa fedex shipping overnight delivery Oxycodone buy Oxycodone online without a prescription and no membership no prescription needed Oxycodone cod shipped Oxycodone not expensive order prescription Oxycodone Oxycodone money order Oxycodone without a perscription online buy Oxycodone Oxycodone fedex buy no online prescription Oxycodone Oxycodone pharmacies accepting cod delivery Oxycodone online consultant online pharmacy fedex cod Oxycodone buy Oxycodone no scams Oxycodone c.o.d overnight delivery buy Oxycodone no prescription cod overnight Oxycodone order Oxycodone online doctors buy Oxycodone on line no prescription Oxycodone no prescription usa fedex shipping Oxycodone online uk watson brand Oxycodone medicine online Oxycodone order Oxycodone samples sent buy Oxycodone no prescription order Oxycodone without a prescription Oxycodone no prescription drug cheap online order Oxycodone get Oxycodone over the counter online order Oxycodone next day buy Oxycodone no perscription cod real Oxycodone fed ex Oxycodone no prescription cod does cv/ pharmacy carry Oxycodone no prescription cod Oxycodone cheap Oxycodone without rx Oxycodone online health insurance lead buy Oxycodone online with overnight delivery Oxycodone no rx fed ex buy Oxycodone without a perscription lowest prices for Oxycodone online buy Oxycodone paypal online without prescription cheap non prescription Oxycodone Oxycodone ups Oxycodone for cheap buy Oxycodone no visa online without prescription cheapest Oxycodone cash on delivery Oxycodone order a prepaid mastercard buy online Oxycodone purchase Oxycodone mail order Oxycodone without a prescription online with overnight delivery Oxycodone from canada buy Oxycodone with no rx overnight delivery of Oxycodone with no prescription cash on delivery Oxycodone no rx Oxycodone by cod buy Oxycodone over the counter cod overnight overnight Oxycodone order Oxycodone without prescription from us pharmacy cheap Oxycodone free fedex shipping order Oxycodone over the counter where to buy Oxycodone no prescription no fees only Oxycodone free consult cod delivery Oxycodone Oxycodone no prescription Oxycodone online overnight delivery cod order Oxycodone over the counter fedex Oxycodone saturday delivery buy Oxycodone money order Oxycodone without prescription mexico buy cheap Oxycodone without prescription Oxycodone non prescription for next day delivery Oxycodone ups delivery only buy Oxycodone usa cod Oxycodone with next day delivery no prescriptions needed for Oxycodone cheap Oxycodone overnight prescription Oxycodone cheap Oxycodone overnight delivery Oxycodone non prescription fedex overnight free order Oxycodone no creditcard buy cheap Oxycodone no Prescription buy Oxycodone over the counter fedex Oxycodone no doctor presribe needed cheap watson Oxycodone online cheap discount Oxycodone buy Oxycodone without a prescription online cheapest Oxycodone free delivery buy Oxycodone online overseas buy Oxycodone over the counter online not expensive Oxycodone next day shipping order Oxycodone cod next day delivery Oxycodone cheap Oxycodone buy in UK Oxycodone next day cod fedex Oxycodone to buy cheap order Oxycodone next day Oxycodone Oxycodone overnight no consult cheap watson Oxycodone no prescription needed Oxycodone without prescription medications overnight delivery of Oxycodone with no perscription buy Oxycodone.com Oxycodone cod next day delivery buy cheap discount online Oxycodone buy Oxycodone drug Oxycodone overnight delivery cheap overnight delivery of Oxycodone in US no prescription needed purchase Oxycodone free next day airOxycodone on line cheap Oxycodone without a prescription Oxycodone cheap cod Oxycodone buy no prepaid cheap Oxycodone next day buy Oxycodone cod accepted online pharmacies Oxycodone saturday delivery buy Oxycodone pay pal Oxycodone shipped on saturday Oxycodone pharmacy cod saturday delivery buy online Oxycodone prescriptions free fedex delivery Oxycodone Oxycodone without prescription cash on delivery buy discount Oxycodone Oxycodone overnight cheap best Oxycodone online pill images of Oxycodone Oxycodone U.P.S SHIPPING COD Oxycodone cod pharmacy buy Oxycodone online cod Oxycodone cod overnight delivery Oxycodone no rx overnight buy Oxycodone overnight COD online pharmacy Oxycodone cod order Oxycodone insurance Oxycodone cash delivery cod buy Oxycodone cheap cod no rx online pharmacy Oxycodone sale nextday Oxycodone Oxycodone pill Oxycodone online ordering Oxycodone online without prescription Oxycodone no script needed cod overnight how to buy Oxycodone online without a prescription cheap Oxycodone without prescription cheap Oxycodone online no rx saturday delivery order Oxycodone over the counter for sale Oxycodone next day delivery cod order Oxycodone online without prescription no prescription next day delivery Oxycodone overnight Oxycodone C.O.D Oxycodone without prescription Oxycodone discount fedex no prescription buy Oxycodone amex Oxycodone online next day Oxycodone shipped with no prescription Oxycodone online cheap cheap Oxycodone without prescription overnight delivery buy Oxycodone over the counter for sale Oxycodone no prescriptions needed cod Oxycodone fed ex cheap overnight delivery of Oxycodone free prescription Oxycodone free shipping not expensive legal Oxycodone for sale buy Oxycodone cod Oxycodone for saturday Oxycodone price cash for Oxycodone cash on delivery Oxycodone Oxycodone without a prescription and cod delivery buying Oxycodone without a prescription order Oxycodone no rx buy Oxycodone without rx Oxycodone cheapest buy Oxycodone online pharmacy buy cheap Oxycodone overnight delivery Oxycodone and online pharmacy Oxycodone next day Oxycodone drug no prescription where can i buy Oxycodone no prescription Oxycodone with saturday delivery Oxycodone online overnight Oxycodone no prescription worldwide buy cheap Oxycodone cod ordering Oxycodone online Buy Oxycodone overnight shipping Oxycodone overnight US delivery cheap real Oxycodone for sale Oxycodone no prescriptions needed COD buy Oxycodone no prescription needed Oxycodone no prescription overnight cod delivery cheap Oxycodone cash on delivery no prescription required for Oxycodone order Oxycodone c.o.d. not expensive Oxycodone prescriptions Oxycodone online Cash on Delivery buy Oxycodone overnight delivery Oxycodone online without presciption buy Oxycodone prescription online no prescription saturday delivery Oxycodone where to buy cheap Oxycodone no prescription Oxycodone wo get Oxycodone over the counter fedex Oxycodone with no rx and free shipping order Oxycodone over the counter cod overnight Oxycodone Fedex Without Prescription Oxycodone Online With Next Day Shipping Buy Cheap Oxycodone online | purchase Oxycodone without prescription online | Oxycodone Online Prescriptions With No Membership Oxycodone Cheap next day | Buy Cheap Oxycodone fedex overnight | original Oxycodone pill | Purchase Oxycodone pharmacy r x online | Oxycodone cod Orders | Buy Oxycodone online pharmacy | Oxycodone cod ne xt day delivery | order Oxycodone online no membership overnight shipping | B uy Cheap Oxycodone Online No Prescription Order Oxycodone cod next day delivery | Oxycodone Discount cards | Buy genuine Oxycodone online | buying Oxycodone without a prescription | Where To Buy Oxycodone No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Oxycodone fedex without prescription | U ltram consumer information | pills Cheap generic Oxycodone | Buy Oxycodone onlin e no prescription | Oxycodone Buy | Buy Cheap Oxycodone Online No Prescription B uy Oxycodone online | purchase Oxycodone without prescription | Buying Oxycodone On line Without Prescription Oxycodone Overnight COD no prescription | Cheap onli ne Buy Oxycodone | Low Price Oxycodone Saturday Delivery No Prescription Oxycodone w ithout a prescription no generics | Buy Oxycodone Without Prescription Oxycodone overnight | Buy With No Prescription Oxycodone Online Order Oxycodone no rx overn ight delivery | Order Oxycodone Saturday Delivery No Prescription Oxycodone onlin e no prescription | Oxycodone Discount cards | Buy Oxycodone no script | Oxycodone by phone no script | Buy Oxycodone Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Oxycodone online without a prescription and no me mbership | Buy Without Prescription Oxycodone Online buy no prescription Ultra m | Order Oxycodone Cheap no membership fees no prescription | Oxycodone order n o script | Oxycodone lowest cost | online Buy Oxycodone | Overnight Oxycodone With out A Prescription Oxycodone Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Oxycodone Without A Prescription no script Oxycodone | Oxycodone Buy phone | Oxycodone paid with mastercard | Oxycodone With No Prescript ion Oxycodone to purchase | Order Oxycodone online with no prescription | Oxycodone Buying online Oxycodone drugs | Oxycodone free Overnight fedex delivery | Ultra m best online pharmacy | purchase Oxycodone without a prescription overnight d elivery | Buy Oxycodone online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Oxycodone From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Oxycodone next day | Where To Buy Oxycodone No Prescription No Fees Oxycodone ups cod | Order Oxycodone cash on delive ry | Oxycodone overnight shipping no prescription | purchase Oxycodone without p rescription online | Buy Oxycodone online without dr approval | Buy Oxycodone on line without dr approval | Oxycodone ups | Oxycodone Buy | Buy Oxycodone in Idaho | Oxycodone cheapest | Buy Oxycodone pay with mastercard | ordering Buy Oxycodone online | Oxycodone Overnight COD no prescription | Oxycodone order cod | Oxycodone No Prescription Oxycodone overnight delivery Cheap | Oxycodone order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Oxycodone usa online pharmacy | U ltram free consultation | how to Order Oxycodone without doctors | Purchase U ltram online | comprar Oxycodone | No Prescription Required For Oxycodone Oxycodone cod ordering | Cheap Oxycodone without prescription | Buy Cheap Oxycodone fast | Oxycodone Buy | Buy Oxycodone online without a prescription and no membership | Cheap Oxycodone without prescription overnight delivery | cash on delivery online prescriptions Oxycodone | Oxycodone with no prescription | ordering Ultra m online without a prescription | Oxycodone Cheap order | Oxycodone online no pr escription | No Prescription Needed Oxycodone Low Price Oxycodone With No Prescri ption Buy Oxycodone Online Without Prescription buy no prescription Oxycodone | B uy Oxycodone online discount | Oxycodone order cod | Order Cheap Oxycodone very Buy without prescription | Oxycodone cod next day delivery | Order Oxycodone Online Without Prescription Oxycodone free Overnight fedex delivery | Cheap Oxycodone b y money Order | Buy Oxycodone online discount | overnight Oxycodone | 8 Buy Ult ram online | Cheap Oxycodone c.o.d. | Buy Oxycodone Tablets Without Prescription Overnight Oxycodone for sale | Buy Oxycodone online sales | natural Oxycodone | U ltram manufacturer | Oxycodone Online No Prescription Oxycodone adiction | geniu ne Oxycodone no prescription | Oxycodone Pharmacy Cod Saturday Delivery With No P rescription Oxycodone Buy phone | Buy Oxycodone online prescription | Order Ultr am without prescription from us pharmacy | Buy real Oxycodone with mastercard | Oxycodone without a rx | doctor online prescription Oxycodone | Oxycodone Free O vernight Fedex Delivery order Oxycodone online cash on delivery | Cheap Oxycodone next day | Buy Oxycodone Cheap online us pharmacy | Oxycodone delivery to uk fe dex Overnight | Find Cheap Oxycodone no prescription | online pharmacy Oxycodone | Buy Oxycodone Online Without A Prescription And No Membership Oxycodone to pur chase | Oxycodone Same Day Delivery No Prescription Oxycodone by phone no script | Buy Oxycodone without | discount Oxycodone overnight | Buy Cheap Oxycodone, Buy Cheap Oxycodone online | Oxycodone Buy fedex | Oxycodone shipped with no prescripti on | Buy Oxycodone online money order | purchase Oxycodone without a prescriptio n | Oxycodone ups cod | Buy Oxycodone Online No Prescription Buy Oxycodone online | Oxycodone with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Oxycodone cod | how to get Oxycodone prescription | Low Price Oxycodone With No Prescription Buy the Cheapest Oxycodone online index | prescription U ltram | Order Oxycodone No Prescription Order Oxycodone medicine online without p rescription | Low Price Oxycodone Saturday Delivery No Prescription Cheap Ultr am overnight | Oxycodone Online No Prescription Oxycodone online cash on delivery | Fedex Oxycodone Without Prescription Buy Oxycodone online usa | Oxycodone for sa le without a prescription | to Buy Oxycodone without a prescription | Oxycodone Overnight no script mastercard accepted | Buy Cheap Oxycodone No Prescription Cheap Oxycodone free consultant | Buy Oxycodone Cheap online us pharmacy | Buy C heap Oxycodone No Prescription Oxycodone lowest cost | Where To Buy Oxycodone No Pre scription No Fees Cheapest Oxycodone Online Without Prescription cheapest Ultra m | Oxycodone amphetimine | Buy Oxycodone 120 tabs | Buy Oxycodone Without A Presc ription Or Membership Oxycodone Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Oxycodone | Oxycodone conversion | overnight Oxycodone ups cod | Buy Oxycodone online Cheap | Oxycodone No Script Required Express Delivery With No P rescription Oxycodone free consultation u.s. pharmacy | Oxycodone cod no script | Oxycodone ups cod | Oxycodone online no prescription | purchase Oxycodone with co d | Canadian Oxycodone Pills No Prescription Buy Oxycodone in North Carolina | buy Oxycodone in Denmark, buy Oxycodone in Egypt, buy Oxycodone in Israel, buy Oxycodone in Ireland, buy Oxycodone in Spain, buy Oxycodone in Italy, buy Oxycodone in Canada, buy Oxycodone in Cyprus, buy Oxycodone in Mexico, buy Oxycodone in Netherlands, buy Oxycodone in New zealand, buy Oxycodone in Kingston, buy Oxycodone in Australia, buy Oxycodone in AU, buy Oxycodone in New South Wales, buy Oxycodone in NSW, buy Oxycodone i n Sydney, buy Oxycodone in Brisbane, buy Oxycodone in South Australia, buy Oxycodone in Hobart, buy Oxycodone in the United states, buy Oxycodone in Finland, buy Ultra m in France, buy Oxycodone in Chekhiya, buy Oxycodone in Switzerland, buy Oxycodone i n Sweden, buy Oxycodone in Alberta, buy Oxycodone in Labrador, buy Oxycodone in Toron to, buy Oxycodone in Ottawa, buy Oxycodone in Mississauga, buy Oxycodone in Hamilton, buy Oxycodone in Brampton, buy Oxycodone in London, buy Oxycodone in Markham, buy Ul tram in Vaughan, buy Oxycodone in Windsor, buy Oxycodone in Kitchener, buy Oxycodone in Montreal, buy Oxycodone in Mauricie, buy Oxycodone in Vancouver, buy Oxycodone in Victoria, buy Oxycodone in Kelowna, buy Oxycodone in Abbotsford, buy Oxycodone in Kam loops, buy Oxycodone in Nanaimo, buy Oxycodone in Vernon, buy Oxycodone in Lethbridge , buy Oxycodone in United Kingdom, buy Oxycodone in England, buy Oxycodone in Wales, buy Oxycodone in Scotland, buy Oxycodone in Northern Ireland, buy Oxycodone in Belfas t, buy Oxycodone in Cardiff, buy Oxycodone in London, buy Oxycodone in Glasgow, buy U ltram in Liverpool, buy Oxycodone in Leeds, buy Oxycodone in Victoria, buy Oxycodone in Melbourne, buy Oxycodone in Western Australia, buy Oxycodone in Perth, buy Ultr am in Alabama, buy Oxycodone in Arizona, buy Oxycodone in Arkansas, buy Oxycodone in California, buy Oxycodone in Colorado, buy Oxycodone in Connecticut, buy Oxycodone in Delaware, buy Oxycodone in Florida, buy Oxycodone in Georgia, buy Oxycodone in Hawai i, buy Oxycodone in Idaho, buy Oxycodone in Illinois, buy Oxycodone in Indiana, buy U ltram in Iowa, buy Oxycodone in Kansas, buy Oxycodone in Kentucky, buy Oxycodone in L ouisiana, buy Oxycodone in Maine, buy Oxycodone in Montana, buy Oxycodone in Nebraska , buy Oxycodone in Nevada, buy Oxycodone in New Jersey, buy Oxycodone in New Mexico, buy Oxycodone in New York, buy Oxycodone in North Carolina, buy Oxycodone in North Da kota, buy Oxycodone in Ohio, buy Oxycodone in Oklahoma, buy Oxycodone in Texas, buy U ltram in Utah, buy Oxycodone in Vermont, buy Oxycodone in Virginia, buy Oxycodone in Washington, buy Oxycodone in West Virginia, buy Oxycodone in Wisconsin, buy Oxycodone in Wyoming, buy Oxycodone in Montgomery, buy Oxycodone in Juneau, buy Oxycodone in P hoenix, buy Oxycodone in Little Rock, buy Oxycodone in Sacramento, buy Oxycodone in D enver, buy Oxycodone in Hartford, buy Oxycodone in Dover, buy Oxycodone in Tallahasse e, buy Oxycodone in Atlanta, buy Oxycodone in Springfield, buy Oxycodone in Indianapo lis, buy Oxycodone in Des Moines, buy Oxycodone in Annapolis, buy Oxycodone in Boston , buy Oxycodone in Lansing, buy Oxycodone in Helena, buy Oxycodone in Lincoln, buy Ul tram in Santa Fe, buy Oxycodone in Albany, buy Oxycodone in Raleigh, buy Oxycodone in Bismarck, buy Oxycodone in Columbus, buy Oxycodone in Salem, buy Oxycodone in Columb ia, buy Oxycodone in Salt Lake City, buy Oxycodone in Montpelier, buy Oxycodone in Ch arleston, buy Oxycodone in Madison, buy Oxycodone in Cheyenne, buy Oxycodone in Austr alia, buy Oxycodone in Austria, buy Oxycodone in Argentina, buy Oxycodone in Belgium, buy Oxycodone in Bulgaria, buy Oxycodone in Brasilia, buy Oxycodone in Great britain , buy Oxycodone in Hungary, buy Oxycodone in Germany, buy Oxycodone in Greece, buy Ul tram in South Africa, buy Oxycodone in Japan From numansenm at gmail.com Thu Nov 10 13:32:23 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:32:23 -0800 (PST) Subject: Ritalin without prescription medications | Ritalin no prescription usa fedex shipping | buy no online prescription Ritalin Message-ID: <1ed9a1b0-48a8-4d01-997a-3a7bf87cf96e@d5g2000yqg.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Ritalin/Ritalin pills with every Order ______________________________________________________________________ BUY Ritalin ONLINE http://buypharmasite.com/?q=Ritalin CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Ritalin ONLINE http://buypharmasite.com/?q=Ritalin CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Ritalin Ritalin online saturday delivery online Ritalin and fedex cheap order prescription Ritalin cheap Ritalin by money order buy Ritalin from mexico online Ritalin no prescription usa fedex shipping overnight delivery Ritalin buy Ritalin online without a prescription and no membership no prescription needed Ritalin cod shipped Ritalin not expensive order prescription Ritalin Ritalin money order Ritalin without a perscription online buy Ritalin Ritalin fedex buy no online prescription Ritalin Ritalin pharmacies accepting cod delivery Ritalin online consultant online pharmacy fedex cod Ritalin buy Ritalin no scams Ritalin c.o.d overnight delivery buy Ritalin no prescription cod overnight Ritalin order Ritalin online doctors buy Ritalin on line no prescription Ritalin no prescription usa fedex shipping Ritalin online uk watson brand Ritalin medicine online Ritalin order Ritalin samples sent buy Ritalin no prescription order Ritalin without a prescription Ritalin no prescription drug cheap online order Ritalin get Ritalin over the counter online order Ritalin next day buy Ritalin no perscription cod real Ritalin fed ex Ritalin no prescription cod does cv/ pharmacy carry Ritalin no prescription cod Ritalin cheap Ritalin without rx Ritalin online health insurance lead buy Ritalin online with overnight delivery Ritalin no rx fed ex buy Ritalin without a perscription lowest prices for Ritalin online buy Ritalin paypal online without prescription cheap non prescription Ritalin Ritalin ups Ritalin for cheap buy Ritalin no visa online without prescription cheapest Ritalin cash on delivery Ritalin order a prepaid mastercard buy online Ritalin purchase Ritalin mail order Ritalin without a prescription online with overnight delivery Ritalin from canada buy Ritalin with no rx overnight delivery of Ritalin with no prescription cash on delivery Ritalin no rx Ritalin by cod buy Ritalin over the counter cod overnight overnight Ritalin order Ritalin without prescription from us pharmacy cheap Ritalin free fedex shipping order Ritalin over the counter where to buy Ritalin no prescription no fees only Ritalin free consult cod delivery Ritalin Ritalin no prescription Ritalin online overnight delivery cod order Ritalin over the counter fedex Ritalin saturday delivery buy Ritalin money order Ritalin without prescription mexico buy cheap Ritalin without prescription Ritalin non prescription for next day delivery Ritalin ups delivery only buy Ritalin usa cod Ritalin with next day delivery no prescriptions needed for Ritalin cheap Ritalin overnight prescription Ritalin cheap Ritalin overnight delivery Ritalin non prescription fedex overnight free order Ritalin no creditcard buy cheap Ritalin no Prescription buy Ritalin over the counter fedex Ritalin no doctor presribe needed cheap watson Ritalin online cheap discount Ritalin buy Ritalin without a prescription online cheapest Ritalin free delivery buy Ritalin online overseas buy Ritalin over the counter online not expensive Ritalin next day shipping order Ritalin cod next day delivery Ritalin cheap Ritalin buy in UK Ritalin next day cod fedex Ritalin to buy cheap order Ritalin next day Ritalin Ritalin overnight no consult cheap watson Ritalin no prescription needed Ritalin without prescription medications overnight delivery of Ritalin with no perscription buy Ritalin.com Ritalin cod next day delivery buy cheap discount online Ritalin buy Ritalin drug Ritalin overnight delivery cheap overnight delivery of Ritalin in US no prescription needed purchase Ritalin free next day airRitalin on line cheap Ritalin without a prescription Ritalin cheap cod Ritalin buy no prepaid cheap Ritalin next day buy Ritalin cod accepted online pharmacies Ritalin saturday delivery buy Ritalin pay pal Ritalin shipped on saturday Ritalin pharmacy cod saturday delivery buy online Ritalin prescriptions free fedex delivery Ritalin Ritalin without prescription cash on delivery buy discount Ritalin Ritalin overnight cheap best Ritalin online pill images of Ritalin Ritalin U.P.S SHIPPING COD Ritalin cod pharmacy buy Ritalin online cod Ritalin cod overnight delivery Ritalin no rx overnight buy Ritalin overnight COD online pharmacy Ritalin cod order Ritalin insurance Ritalin cash delivery cod buy Ritalin cheap cod no rx online pharmacy Ritalin sale nextday Ritalin Ritalin pill Ritalin online ordering Ritalin online without prescription Ritalin no script needed cod overnight how to buy Ritalin online without a prescription cheap Ritalin without prescription cheap Ritalin online no rx saturday delivery order Ritalin over the counter for sale Ritalin next day delivery cod order Ritalin online without prescription no prescription next day delivery Ritalin overnight Ritalin C.O.D Ritalin without prescription Ritalin discount fedex no prescription buy Ritalin amex Ritalin online next day Ritalin shipped with no prescription Ritalin online cheap cheap Ritalin without prescription overnight delivery buy Ritalin over the counter for sale Ritalin no prescriptions needed cod Ritalin fed ex cheap overnight delivery of Ritalin free prescription Ritalin free shipping not expensive legal Ritalin for sale buy Ritalin cod Ritalin for saturday Ritalin price cash for Ritalin cash on delivery Ritalin Ritalin without a prescription and cod delivery buying Ritalin without a prescription order Ritalin no rx buy Ritalin without rx Ritalin cheapest buy Ritalin online pharmacy buy cheap Ritalin overnight delivery Ritalin and online pharmacy Ritalin next day Ritalin drug no prescription where can i buy Ritalin no prescription Ritalin with saturday delivery Ritalin online overnight Ritalin no prescription worldwide buy cheap Ritalin cod ordering Ritalin online Buy Ritalin overnight shipping Ritalin overnight US delivery cheap real Ritalin for sale Ritalin no prescriptions needed COD buy Ritalin no prescription needed Ritalin no prescription overnight cod delivery cheap Ritalin cash on delivery no prescription required for Ritalin order Ritalin c.o.d. not expensive Ritalin prescriptions Ritalin online Cash on Delivery buy Ritalin overnight delivery Ritalin online without presciption buy Ritalin prescription online no prescription saturday delivery Ritalin where to buy cheap Ritalin no prescription Ritalin wo get Ritalin over the counter fedex Ritalin with no rx and free shipping order Ritalin over the counter cod overnight Ritalin Fedex Without Prescription Ritalin Online With Next Day Shipping Buy Cheap Ritalin online | purchase Ritalin without prescription online | Ritalin Online Prescriptions With No Membership Ritalin Cheap next day | Buy Cheap Ritalin fedex overnight | original Ritalin pill | Purchase Ritalin pharmacy r x online | Ritalin cod Orders | Buy Ritalin online pharmacy | Ritalin cod ne xt day delivery | order Ritalin online no membership overnight shipping | B uy Cheap Ritalin Online No Prescription Order Ritalin cod next day delivery | Ritalin Discount cards | Buy genuine Ritalin online | buying Ritalin without a prescription | Where To Buy Ritalin No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Ritalin fedex without prescription | U ltram consumer information | pills Cheap generic Ritalin | Buy Ritalin onlin e no prescription | Ritalin Buy | Buy Cheap Ritalin Online No Prescription B uy Ritalin online | purchase Ritalin without prescription | Buying Ritalin On line Without Prescription Ritalin Overnight COD no prescription | Cheap onli ne Buy Ritalin | Low Price Ritalin Saturday Delivery No Prescription Ritalin w ithout a prescription no generics | Buy Ritalin Without Prescription Ritalin overnight | Buy With No Prescription Ritalin Online Order Ritalin no rx overn ight delivery | Order Ritalin Saturday Delivery No Prescription Ritalin onlin e no prescription | Ritalin Discount cards | Buy Ritalin no script | Ritalin by phone no script | Buy Ritalin Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Ritalin online without a prescription and no me mbership | Buy Without Prescription Ritalin Online buy no prescription Ultra m | Order Ritalin Cheap no membership fees no prescription | Ritalin order n o script | Ritalin lowest cost | online Buy Ritalin | Overnight Ritalin With out A Prescription Ritalin Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Ritalin Without A Prescription no script Ritalin | Ritalin Buy phone | Ritalin paid with mastercard | Ritalin With No Prescript ion Ritalin to purchase | Order Ritalin online with no prescription | Ritalin Buying online Ritalin drugs | Ritalin free Overnight fedex delivery | Ultra m best online pharmacy | purchase Ritalin without a prescription overnight d elivery | Buy Ritalin online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Ritalin From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Ritalin next day | Where To Buy Ritalin No Prescription No Fees Ritalin ups cod | Order Ritalin cash on delive ry | Ritalin overnight shipping no prescription | purchase Ritalin without p rescription online | Buy Ritalin online without dr approval | Buy Ritalin on line without dr approval | Ritalin ups | Ritalin Buy | Buy Ritalin in Idaho | Ritalin cheapest | Buy Ritalin pay with mastercard | ordering Buy Ritalin online | Ritalin Overnight COD no prescription | Ritalin order cod | Ritalin No Prescription Ritalin overnight delivery Cheap | Ritalin order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Ritalin usa online pharmacy | U ltram free consultation | how to Order Ritalin without doctors | Purchase U ltram online | comprar Ritalin | No Prescription Required For Ritalin Ritalin cod ordering | Cheap Ritalin without prescription | Buy Cheap Ritalin fast | Ritalin Buy | Buy Ritalin online without a prescription and no membership | Cheap Ritalin without prescription overnight delivery | cash on delivery online prescriptions Ritalin | Ritalin with no prescription | ordering Ultra m online without a prescription | Ritalin Cheap order | Ritalin online no pr escription | No Prescription Needed Ritalin Low Price Ritalin With No Prescri ption Buy Ritalin Online Without Prescription buy no prescription Ritalin | B uy Ritalin online discount | Ritalin order cod | Order Cheap Ritalin very Buy without prescription | Ritalin cod next day delivery | Order Ritalin Online Without Prescription Ritalin free Overnight fedex delivery | Cheap Ritalin b y money Order | Buy Ritalin online discount | overnight Ritalin | 8 Buy Ult ram online | Cheap Ritalin c.o.d. | Buy Ritalin Tablets Without Prescription Overnight Ritalin for sale | Buy Ritalin online sales | natural Ritalin | U ltram manufacturer | Ritalin Online No Prescription Ritalin adiction | geniu ne Ritalin no prescription | Ritalin Pharmacy Cod Saturday Delivery With No P rescription Ritalin Buy phone | Buy Ritalin online prescription | Order Ultr am without prescription from us pharmacy | Buy real Ritalin with mastercard | Ritalin without a rx | doctor online prescription Ritalin | Ritalin Free O vernight Fedex Delivery order Ritalin online cash on delivery | Cheap Ritalin next day | Buy Ritalin Cheap online us pharmacy | Ritalin delivery to uk fe dex Overnight | Find Cheap Ritalin no prescription | online pharmacy Ritalin | Buy Ritalin Online Without A Prescription And No Membership Ritalin to pur chase | Ritalin Same Day Delivery No Prescription Ritalin by phone no script | Buy Ritalin without | discount Ritalin overnight | Buy Cheap Ritalin, Buy Cheap Ritalin online | Ritalin Buy fedex | Ritalin shipped with no prescripti on | Buy Ritalin online money order | purchase Ritalin without a prescriptio n | Ritalin ups cod | Buy Ritalin Online No Prescription Buy Ritalin online | Ritalin with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Ritalin cod | how to get Ritalin prescription | Low Price Ritalin With No Prescription Buy the Cheapest Ritalin online index | prescription U ltram | Order Ritalin No Prescription Order Ritalin medicine online without p rescription | Low Price Ritalin Saturday Delivery No Prescription Cheap Ultr am overnight | Ritalin Online No Prescription Ritalin online cash on delivery | Fedex Ritalin Without Prescription Buy Ritalin online usa | Ritalin for sa le without a prescription | to Buy Ritalin without a prescription | Ritalin Overnight no script mastercard accepted | Buy Cheap Ritalin No Prescription Cheap Ritalin free consultant | Buy Ritalin Cheap online us pharmacy | Buy C heap Ritalin No Prescription Ritalin lowest cost | Where To Buy Ritalin No Pre scription No Fees Cheapest Ritalin Online Without Prescription cheapest Ultra m | Ritalin amphetimine | Buy Ritalin 120 tabs | Buy Ritalin Without A Presc ription Or Membership Ritalin Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Ritalin | Ritalin conversion | overnight Ritalin ups cod | Buy Ritalin online Cheap | Ritalin No Script Required Express Delivery With No P rescription Ritalin free consultation u.s. pharmacy | Ritalin cod no script | Ritalin ups cod | Ritalin online no prescription | purchase Ritalin with co d | Canadian Ritalin Pills No Prescription Buy Ritalin in North Carolina | buy Ritalin in Denmark, buy Ritalin in Egypt, buy Ritalin in Israel, buy Ritalin in Ireland, buy Ritalin in Spain, buy Ritalin in Italy, buy Ritalin in Canada, buy Ritalin in Cyprus, buy Ritalin in Mexico, buy Ritalin in Netherlands, buy Ritalin in New zealand, buy Ritalin in Kingston, buy Ritalin in Australia, buy Ritalin in AU, buy Ritalin in New South Wales, buy Ritalin in NSW, buy Ritalin i n Sydney, buy Ritalin in Brisbane, buy Ritalin in South Australia, buy Ritalin in Hobart, buy Ritalin in the United states, buy Ritalin in Finland, buy Ultra m in France, buy Ritalin in Chekhiya, buy Ritalin in Switzerland, buy Ritalin i n Sweden, buy Ritalin in Alberta, buy Ritalin in Labrador, buy Ritalin in Toron to, buy Ritalin in Ottawa, buy Ritalin in Mississauga, buy Ritalin in Hamilton, buy Ritalin in Brampton, buy Ritalin in London, buy Ritalin in Markham, buy Ul tram in Vaughan, buy Ritalin in Windsor, buy Ritalin in Kitchener, buy Ritalin in Montreal, buy Ritalin in Mauricie, buy Ritalin in Vancouver, buy Ritalin in Victoria, buy Ritalin in Kelowna, buy Ritalin in Abbotsford, buy Ritalin in Kam loops, buy Ritalin in Nanaimo, buy Ritalin in Vernon, buy Ritalin in Lethbridge , buy Ritalin in United Kingdom, buy Ritalin in England, buy Ritalin in Wales, buy Ritalin in Scotland, buy Ritalin in Northern Ireland, buy Ritalin in Belfas t, buy Ritalin in Cardiff, buy Ritalin in London, buy Ritalin in Glasgow, buy U ltram in Liverpool, buy Ritalin in Leeds, buy Ritalin in Victoria, buy Ritalin in Melbourne, buy Ritalin in Western Australia, buy Ritalin in Perth, buy Ultr am in Alabama, buy Ritalin in Arizona, buy Ritalin in Arkansas, buy Ritalin in California, buy Ritalin in Colorado, buy Ritalin in Connecticut, buy Ritalin in Delaware, buy Ritalin in Florida, buy Ritalin in Georgia, buy Ritalin in Hawai i, buy Ritalin in Idaho, buy Ritalin in Illinois, buy Ritalin in Indiana, buy U ltram in Iowa, buy Ritalin in Kansas, buy Ritalin in Kentucky, buy Ritalin in L ouisiana, buy Ritalin in Maine, buy Ritalin in Montana, buy Ritalin in Nebraska , buy Ritalin in Nevada, buy Ritalin in New Jersey, buy Ritalin in New Mexico, buy Ritalin in New York, buy Ritalin in North Carolina, buy Ritalin in North Da kota, buy Ritalin in Ohio, buy Ritalin in Oklahoma, buy Ritalin in Texas, buy U ltram in Utah, buy Ritalin in Vermont, buy Ritalin in Virginia, buy Ritalin in Washington, buy Ritalin in West Virginia, buy Ritalin in Wisconsin, buy Ritalin in Wyoming, buy Ritalin in Montgomery, buy Ritalin in Juneau, buy Ritalin in P hoenix, buy Ritalin in Little Rock, buy Ritalin in Sacramento, buy Ritalin in D enver, buy Ritalin in Hartford, buy Ritalin in Dover, buy Ritalin in Tallahasse e, buy Ritalin in Atlanta, buy Ritalin in Springfield, buy Ritalin in Indianapo lis, buy Ritalin in Des Moines, buy Ritalin in Annapolis, buy Ritalin in Boston , buy Ritalin in Lansing, buy Ritalin in Helena, buy Ritalin in Lincoln, buy Ul tram in Santa Fe, buy Ritalin in Albany, buy Ritalin in Raleigh, buy Ritalin in Bismarck, buy Ritalin in Columbus, buy Ritalin in Salem, buy Ritalin in Columb ia, buy Ritalin in Salt Lake City, buy Ritalin in Montpelier, buy Ritalin in Ch arleston, buy Ritalin in Madison, buy Ritalin in Cheyenne, buy Ritalin in Austr alia, buy Ritalin in Austria, buy Ritalin in Argentina, buy Ritalin in Belgium, buy Ritalin in Bulgaria, buy Ritalin in Brasilia, buy Ritalin in Great britain , buy Ritalin in Hungary, buy Ritalin in Germany, buy Ritalin in Greece, buy Ul tram in South Africa, buy Ritalin in Japan From numansenm at gmail.com Thu Nov 10 13:36:34 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:36:34 -0800 (PST) Subject: overnight delivery of Levitra in US no prescription needed | Levitra without prescription medications Message-ID: ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Levitra/Levitra pills with every Order ______________________________________________________________________ BUY Levitra ONLINE http://buypharmasite.com/?q=Levitra CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Levitra ONLINE http://buypharmasite.com/?q=Levitra CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Levitra Levitra online saturday delivery online Levitra and fedex cheap order prescription Levitra cheap Levitra by money order buy Levitra from mexico online Levitra no prescription usa fedex shipping overnight delivery Levitra buy Levitra online without a prescription and no membership no prescription needed Levitra cod shipped Levitra not expensive order prescription Levitra Levitra money order Levitra without a perscription online buy Levitra Levitra fedex buy no online prescription Levitra Levitra pharmacies accepting cod delivery Levitra online consultant online pharmacy fedex cod Levitra buy Levitra no scams Levitra c.o.d overnight delivery buy Levitra no prescription cod overnight Levitra order Levitra online doctors buy Levitra on line no prescription Levitra no prescription usa fedex shipping Levitra online uk watson brand Levitra medicine online Levitra order Levitra samples sent buy Levitra no prescription order Levitra without a prescription Levitra no prescription drug cheap online order Levitra get Levitra over the counter online order Levitra next day buy Levitra no perscription cod real Levitra fed ex Levitra no prescription cod does cv/ pharmacy carry Levitra no prescription cod Levitra cheap Levitra without rx Levitra online health insurance lead buy Levitra online with overnight delivery Levitra no rx fed ex buy Levitra without a perscription lowest prices for Levitra online buy Levitra paypal online without prescription cheap non prescription Levitra Levitra ups Levitra for cheap buy Levitra no visa online without prescription cheapest Levitra cash on delivery Levitra order a prepaid mastercard buy online Levitra purchase Levitra mail order Levitra without a prescription online with overnight delivery Levitra from canada buy Levitra with no rx overnight delivery of Levitra with no prescription cash on delivery Levitra no rx Levitra by cod buy Levitra over the counter cod overnight overnight Levitra order Levitra without prescription from us pharmacy cheap Levitra free fedex shipping order Levitra over the counter where to buy Levitra no prescription no fees only Levitra free consult cod delivery Levitra Levitra no prescription Levitra online overnight delivery cod order Levitra over the counter fedex Levitra saturday delivery buy Levitra money order Levitra without prescription mexico buy cheap Levitra without prescription Levitra non prescription for next day delivery Levitra ups delivery only buy Levitra usa cod Levitra with next day delivery no prescriptions needed for Levitra cheap Levitra overnight prescription Levitra cheap Levitra overnight delivery Levitra non prescription fedex overnight free order Levitra no creditcard buy cheap Levitra no Prescription buy Levitra over the counter fedex Levitra no doctor presribe needed cheap watson Levitra online cheap discount Levitra buy Levitra without a prescription online cheapest Levitra free delivery buy Levitra online overseas buy Levitra over the counter online not expensive Levitra next day shipping order Levitra cod next day delivery Levitra cheap Levitra buy in UK Levitra next day cod fedex Levitra to buy cheap order Levitra next day Levitra Levitra overnight no consult cheap watson Levitra no prescription needed Levitra without prescription medications overnight delivery of Levitra with no perscription buy Levitra.com Levitra cod next day delivery buy cheap discount online Levitra buy Levitra drug Levitra overnight delivery cheap overnight delivery of Levitra in US no prescription needed purchase Levitra free next day airLevitra on line cheap Levitra without a prescription Levitra cheap cod Levitra buy no prepaid cheap Levitra next day buy Levitra cod accepted online pharmacies Levitra saturday delivery buy Levitra pay pal Levitra shipped on saturday Levitra pharmacy cod saturday delivery buy online Levitra prescriptions free fedex delivery Levitra Levitra without prescription cash on delivery buy discount Levitra Levitra overnight cheap best Levitra online pill images of Levitra Levitra U.P.S SHIPPING COD Levitra cod pharmacy buy Levitra online cod Levitra cod overnight delivery Levitra no rx overnight buy Levitra overnight COD online pharmacy Levitra cod order Levitra insurance Levitra cash delivery cod buy Levitra cheap cod no rx online pharmacy Levitra sale nextday Levitra Levitra pill Levitra online ordering Levitra online without prescription Levitra no script needed cod overnight how to buy Levitra online without a prescription cheap Levitra without prescription cheap Levitra online no rx saturday delivery order Levitra over the counter for sale Levitra next day delivery cod order Levitra online without prescription no prescription next day delivery Levitra overnight Levitra C.O.D Levitra without prescription Levitra discount fedex no prescription buy Levitra amex Levitra online next day Levitra shipped with no prescription Levitra online cheap cheap Levitra without prescription overnight delivery buy Levitra over the counter for sale Levitra no prescriptions needed cod Levitra fed ex cheap overnight delivery of Levitra free prescription Levitra free shipping not expensive legal Levitra for sale buy Levitra cod Levitra for saturday Levitra price cash for Levitra cash on delivery Levitra Levitra without a prescription and cod delivery buying Levitra without a prescription order Levitra no rx buy Levitra without rx Levitra cheapest buy Levitra online pharmacy buy cheap Levitra overnight delivery Levitra and online pharmacy Levitra next day Levitra drug no prescription where can i buy Levitra no prescription Levitra with saturday delivery Levitra online overnight Levitra no prescription worldwide buy cheap Levitra cod ordering Levitra online Buy Levitra overnight shipping Levitra overnight US delivery cheap real Levitra for sale Levitra no prescriptions needed COD buy Levitra no prescription needed Levitra no prescription overnight cod delivery cheap Levitra cash on delivery no prescription required for Levitra order Levitra c.o.d. not expensive Levitra prescriptions Levitra online Cash on Delivery buy Levitra overnight delivery Levitra online without presciption buy Levitra prescription online no prescription saturday delivery Levitra where to buy cheap Levitra no prescription Levitra wo get Levitra over the counter fedex Levitra with no rx and free shipping order Levitra over the counter cod overnight Levitra Fedex Without Prescription Levitra Online With Next Day Shipping Buy Cheap Levitra online | purchase Levitra without prescription online | Levitra Online Prescriptions With No Membership Levitra Cheap next day | Buy Cheap Levitra fedex overnight | original Levitra pill | Purchase Levitra pharmacy r x online | Levitra cod Orders | Buy Levitra online pharmacy | Levitra cod ne xt day delivery | order Levitra online no membership overnight shipping | B uy Cheap Levitra Online No Prescription Order Levitra cod next day delivery | Levitra Discount cards | Buy genuine Levitra online | buying Levitra without a prescription | Where To Buy Levitra No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Levitra fedex without prescription | U ltram consumer information | pills Cheap generic Levitra | Buy Levitra onlin e no prescription | Levitra Buy | Buy Cheap Levitra Online No Prescription B uy Levitra online | purchase Levitra without prescription | Buying Levitra On line Without Prescription Levitra Overnight COD no prescription | Cheap onli ne Buy Levitra | Low Price Levitra Saturday Delivery No Prescription Levitra w ithout a prescription no generics | Buy Levitra Without Prescription Levitra overnight | Buy With No Prescription Levitra Online Order Levitra no rx overn ight delivery | Order Levitra Saturday Delivery No Prescription Levitra onlin e no prescription | Levitra Discount cards | Buy Levitra no script | Levitra by phone no script | Buy Levitra Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Levitra online without a prescription and no me mbership | Buy Without Prescription Levitra Online buy no prescription Ultra m | Order Levitra Cheap no membership fees no prescription | Levitra order n o script | Levitra lowest cost | online Buy Levitra | Overnight Levitra With out A Prescription Levitra Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Levitra Without A Prescription no script Levitra | Levitra Buy phone | Levitra paid with mastercard | Levitra With No Prescript ion Levitra to purchase | Order Levitra online with no prescription | Levitra Buying online Levitra drugs | Levitra free Overnight fedex delivery | Ultra m best online pharmacy | purchase Levitra without a prescription overnight d elivery | Buy Levitra online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Levitra From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Levitra next day | Where To Buy Levitra No Prescription No Fees Levitra ups cod | Order Levitra cash on delive ry | Levitra overnight shipping no prescription | purchase Levitra without p rescription online | Buy Levitra online without dr approval | Buy Levitra on line without dr approval | Levitra ups | Levitra Buy | Buy Levitra in Idaho | Levitra cheapest | Buy Levitra pay with mastercard | ordering Buy Levitra online | Levitra Overnight COD no prescription | Levitra order cod | Levitra No Prescription Levitra overnight delivery Cheap | Levitra order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Levitra usa online pharmacy | U ltram free consultation | how to Order Levitra without doctors | Purchase U ltram online | comprar Levitra | No Prescription Required For Levitra Levitra cod ordering | Cheap Levitra without prescription | Buy Cheap Levitra fast | Levitra Buy | Buy Levitra online without a prescription and no membership | Cheap Levitra without prescription overnight delivery | cash on delivery online prescriptions Levitra | Levitra with no prescription | ordering Ultra m online without a prescription | Levitra Cheap order | Levitra online no pr escription | No Prescription Needed Levitra Low Price Levitra With No Prescri ption Buy Levitra Online Without Prescription buy no prescription Levitra | B uy Levitra online discount | Levitra order cod | Order Cheap Levitra very Buy without prescription | Levitra cod next day delivery | Order Levitra Online Without Prescription Levitra free Overnight fedex delivery | Cheap Levitra b y money Order | Buy Levitra online discount | overnight Levitra | 8 Buy Ult ram online | Cheap Levitra c.o.d. | Buy Levitra Tablets Without Prescription Overnight Levitra for sale | Buy Levitra online sales | natural Levitra | U ltram manufacturer | Levitra Online No Prescription Levitra adiction | geniu ne Levitra no prescription | Levitra Pharmacy Cod Saturday Delivery With No P rescription Levitra Buy phone | Buy Levitra online prescription | Order Ultr am without prescription from us pharmacy | Buy real Levitra with mastercard | Levitra without a rx | doctor online prescription Levitra | Levitra Free O vernight Fedex Delivery order Levitra online cash on delivery | Cheap Levitra next day | Buy Levitra Cheap online us pharmacy | Levitra delivery to uk fe dex Overnight | Find Cheap Levitra no prescription | online pharmacy Levitra | Buy Levitra Online Without A Prescription And No Membership Levitra to pur chase | Levitra Same Day Delivery No Prescription Levitra by phone no script | Buy Levitra without | discount Levitra overnight | Buy Cheap Levitra, Buy Cheap Levitra online | Levitra Buy fedex | Levitra shipped with no prescripti on | Buy Levitra online money order | purchase Levitra without a prescriptio n | Levitra ups cod | Buy Levitra Online No Prescription Buy Levitra online | Levitra with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Levitra cod | how to get Levitra prescription | Low Price Levitra With No Prescription Buy the Cheapest Levitra online index | prescription U ltram | Order Levitra No Prescription Order Levitra medicine online without p rescription | Low Price Levitra Saturday Delivery No Prescription Cheap Ultr am overnight | Levitra Online No Prescription Levitra online cash on delivery | Fedex Levitra Without Prescription Buy Levitra online usa | Levitra for sa le without a prescription | to Buy Levitra without a prescription | Levitra Overnight no script mastercard accepted | Buy Cheap Levitra No Prescription Cheap Levitra free consultant | Buy Levitra Cheap online us pharmacy | Buy C heap Levitra No Prescription Levitra lowest cost | Where To Buy Levitra No Pre scription No Fees Cheapest Levitra Online Without Prescription cheapest Ultra m | Levitra amphetimine | Buy Levitra 120 tabs | Buy Levitra Without A Presc ription Or Membership Levitra Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Levitra | Levitra conversion | overnight Levitra ups cod | Buy Levitra online Cheap | Levitra No Script Required Express Delivery With No P rescription Levitra free consultation u.s. pharmacy | Levitra cod no script | Levitra ups cod | Levitra online no prescription | purchase Levitra with co d | Canadian Levitra Pills No Prescription Buy Levitra in North Carolina | buy Levitra in Denmark, buy Levitra in Egypt, buy Levitra in Israel, buy Levitra in Ireland, buy Levitra in Spain, buy Levitra in Italy, buy Levitra in Canada, buy Levitra in Cyprus, buy Levitra in Mexico, buy Levitra in Netherlands, buy Levitra in New zealand, buy Levitra in Kingston, buy Levitra in Australia, buy Levitra in AU, buy Levitra in New South Wales, buy Levitra in NSW, buy Levitra i n Sydney, buy Levitra in Brisbane, buy Levitra in South Australia, buy Levitra in Hobart, buy Levitra in the United states, buy Levitra in Finland, buy Ultra m in France, buy Levitra in Chekhiya, buy Levitra in Switzerland, buy Levitra i n Sweden, buy Levitra in Alberta, buy Levitra in Labrador, buy Levitra in Toron to, buy Levitra in Ottawa, buy Levitra in Mississauga, buy Levitra in Hamilton, buy Levitra in Brampton, buy Levitra in London, buy Levitra in Markham, buy Ul tram in Vaughan, buy Levitra in Windsor, buy Levitra in Kitchener, buy Levitra in Montreal, buy Levitra in Mauricie, buy Levitra in Vancouver, buy Levitra in Victoria, buy Levitra in Kelowna, buy Levitra in Abbotsford, buy Levitra in Kam loops, buy Levitra in Nanaimo, buy Levitra in Vernon, buy Levitra in Lethbridge , buy Levitra in United Kingdom, buy Levitra in England, buy Levitra in Wales, buy Levitra in Scotland, buy Levitra in Northern Ireland, buy Levitra in Belfas t, buy Levitra in Cardiff, buy Levitra in London, buy Levitra in Glasgow, buy U ltram in Liverpool, buy Levitra in Leeds, buy Levitra in Victoria, buy Levitra in Melbourne, buy Levitra in Western Australia, buy Levitra in Perth, buy Ultr am in Alabama, buy Levitra in Arizona, buy Levitra in Arkansas, buy Levitra in California, buy Levitra in Colorado, buy Levitra in Connecticut, buy Levitra in Delaware, buy Levitra in Florida, buy Levitra in Georgia, buy Levitra in Hawai i, buy Levitra in Idaho, buy Levitra in Illinois, buy Levitra in Indiana, buy U ltram in Iowa, buy Levitra in Kansas, buy Levitra in Kentucky, buy Levitra in L ouisiana, buy Levitra in Maine, buy Levitra in Montana, buy Levitra in Nebraska , buy Levitra in Nevada, buy Levitra in New Jersey, buy Levitra in New Mexico, buy Levitra in New York, buy Levitra in North Carolina, buy Levitra in North Da kota, buy Levitra in Ohio, buy Levitra in Oklahoma, buy Levitra in Texas, buy U ltram in Utah, buy Levitra in Vermont, buy Levitra in Virginia, buy Levitra in Washington, buy Levitra in West Virginia, buy Levitra in Wisconsin, buy Levitra in Wyoming, buy Levitra in Montgomery, buy Levitra in Juneau, buy Levitra in P hoenix, buy Levitra in Little Rock, buy Levitra in Sacramento, buy Levitra in D enver, buy Levitra in Hartford, buy Levitra in Dover, buy Levitra in Tallahasse e, buy Levitra in Atlanta, buy Levitra in Springfield, buy Levitra in Indianapo lis, buy Levitra in Des Moines, buy Levitra in Annapolis, buy Levitra in Boston , buy Levitra in Lansing, buy Levitra in Helena, buy Levitra in Lincoln, buy Ul tram in Santa Fe, buy Levitra in Albany, buy Levitra in Raleigh, buy Levitra in Bismarck, buy Levitra in Columbus, buy Levitra in Salem, buy Levitra in Columb ia, buy Levitra in Salt Lake City, buy Levitra in Montpelier, buy Levitra in Ch arleston, buy Levitra in Madison, buy Levitra in Cheyenne, buy Levitra in Austr alia, buy Levitra in Austria, buy Levitra in Argentina, buy Levitra in Belgium, buy Levitra in Bulgaria, buy Levitra in Brasilia, buy Levitra in Great britain , buy Levitra in Hungary, buy Levitra in Germany, buy Levitra in Greece, buy Ul tram in South Africa, buy Levitra in Japan From numansenm at gmail.com Thu Nov 10 13:37:28 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:37:28 -0800 (PST) Subject: Lowest prices for Alprazolam online. Buy Alprazolam online without prescription. Buy Cheap Alprazolam next day no prescription! Message-ID: <57b92492-2577-4f47-9ea1-2ecb53b4b628@w1g2000vba.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Alprazolam/Alprazolam pills with every Order ______________________________________________________________________ BUY Alprazolam ONLINE http://buypharmasite.com/?q=Alprazolam CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Alprazolam ONLINE http://buypharmasite.com/?q=Alprazolam CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Alprazolam Alprazolam online saturday delivery online Alprazolam and fedex cheap order prescription Alprazolam cheap Alprazolam by money order buy Alprazolam from mexico online Alprazolam no prescription usa fedex shipping overnight delivery Alprazolam buy Alprazolam online without a prescription and no membership no prescription needed Alprazolam cod shipped Alprazolam not expensive order prescription Alprazolam Alprazolam money order Alprazolam without a perscription online buy Alprazolam Alprazolam fedex buy no online prescription Alprazolam Alprazolam pharmacies accepting cod delivery Alprazolam online consultant online pharmacy fedex cod Alprazolam buy Alprazolam no scams Alprazolam c.o.d overnight delivery buy Alprazolam no prescription cod overnight Alprazolam order Alprazolam online doctors buy Alprazolam on line no prescription Alprazolam no prescription usa fedex shipping Alprazolam online uk watson brand Alprazolam medicine online Alprazolam order Alprazolam samples sent buy Alprazolam no prescription order Alprazolam without a prescription Alprazolam no prescription drug cheap online order Alprazolam get Alprazolam over the counter online order Alprazolam next day buy Alprazolam no perscription cod real Alprazolam fed ex Alprazolam no prescription cod does cv/ pharmacy carry Alprazolam no prescription cod Alprazolam cheap Alprazolam without rx Alprazolam online health insurance lead buy Alprazolam online with overnight delivery Alprazolam no rx fed ex buy Alprazolam without a perscription lowest prices for Alprazolam online buy Alprazolam paypal online without prescription cheap non prescription Alprazolam Alprazolam ups Alprazolam for cheap buy Alprazolam no visa online without prescription cheapest Alprazolam cash on delivery Alprazolam order a prepaid mastercard buy online Alprazolam purchase Alprazolam mail order Alprazolam without a prescription online with overnight delivery Alprazolam from canada buy Alprazolam with no rx overnight delivery of Alprazolam with no prescription cash on delivery Alprazolam no rx Alprazolam by cod buy Alprazolam over the counter cod overnight overnight Alprazolam order Alprazolam without prescription from us pharmacy cheap Alprazolam free fedex shipping order Alprazolam over the counter where to buy Alprazolam no prescription no fees only Alprazolam free consult cod delivery Alprazolam Alprazolam no prescription Alprazolam online overnight delivery cod order Alprazolam over the counter fedex Alprazolam saturday delivery buy Alprazolam money order Alprazolam without prescription mexico buy cheap Alprazolam without prescription Alprazolam non prescription for next day delivery Alprazolam ups delivery only buy Alprazolam usa cod Alprazolam with next day delivery no prescriptions needed for Alprazolam cheap Alprazolam overnight prescription Alprazolam cheap Alprazolam overnight delivery Alprazolam non prescription fedex overnight free order Alprazolam no creditcard buy cheap Alprazolam no Prescription buy Alprazolam over the counter fedex Alprazolam no doctor presribe needed cheap watson Alprazolam online cheap discount Alprazolam buy Alprazolam without a prescription online cheapest Alprazolam free delivery buy Alprazolam online overseas buy Alprazolam over the counter online not expensive Alprazolam next day shipping order Alprazolam cod next day delivery Alprazolam cheap Alprazolam buy in UK Alprazolam next day cod fedex Alprazolam to buy cheap order Alprazolam next day Alprazolam Alprazolam overnight no consult cheap watson Alprazolam no prescription needed Alprazolam without prescription medications overnight delivery of Alprazolam with no perscription buy Alprazolam.com Alprazolam cod next day delivery buy cheap discount online Alprazolam buy Alprazolam drug Alprazolam overnight delivery cheap overnight delivery of Alprazolam in US no prescription needed purchase Alprazolam free next day airAlprazolam on line cheap Alprazolam without a prescription Alprazolam cheap cod Alprazolam buy no prepaid cheap Alprazolam next day buy Alprazolam cod accepted online pharmacies Alprazolam saturday delivery buy Alprazolam pay pal Alprazolam shipped on saturday Alprazolam pharmacy cod saturday delivery buy online Alprazolam prescriptions free fedex delivery Alprazolam Alprazolam without prescription cash on delivery buy discount Alprazolam Alprazolam overnight cheap best Alprazolam online pill images of Alprazolam Alprazolam U.P.S SHIPPING COD Alprazolam cod pharmacy buy Alprazolam online cod Alprazolam cod overnight delivery Alprazolam no rx overnight buy Alprazolam overnight COD online pharmacy Alprazolam cod order Alprazolam insurance Alprazolam cash delivery cod buy Alprazolam cheap cod no rx online pharmacy Alprazolam sale nextday Alprazolam Alprazolam pill Alprazolam online ordering Alprazolam online without prescription Alprazolam no script needed cod overnight how to buy Alprazolam online without a prescription cheap Alprazolam without prescription cheap Alprazolam online no rx saturday delivery order Alprazolam over the counter for sale Alprazolam next day delivery cod order Alprazolam online without prescription no prescription next day delivery Alprazolam overnight Alprazolam C.O.D Alprazolam without prescription Alprazolam discount fedex no prescription buy Alprazolam amex Alprazolam online next day Alprazolam shipped with no prescription Alprazolam online cheap cheap Alprazolam without prescription overnight delivery buy Alprazolam over the counter for sale Alprazolam no prescriptions needed cod Alprazolam fed ex cheap overnight delivery of Alprazolam free prescription Alprazolam free shipping not expensive legal Alprazolam for sale buy Alprazolam cod Alprazolam for saturday Alprazolam price cash for Alprazolam cash on delivery Alprazolam Alprazolam without a prescription and cod delivery buying Alprazolam without a prescription order Alprazolam no rx buy Alprazolam without rx Alprazolam cheapest buy Alprazolam online pharmacy buy cheap Alprazolam overnight delivery Alprazolam and online pharmacy Alprazolam next day Alprazolam drug no prescription where can i buy Alprazolam no prescription Alprazolam with saturday delivery Alprazolam online overnight Alprazolam no prescription worldwide buy cheap Alprazolam cod ordering Alprazolam online Buy Alprazolam overnight shipping Alprazolam overnight US delivery cheap real Alprazolam for sale Alprazolam no prescriptions needed COD buy Alprazolam no prescription needed Alprazolam no prescription overnight cod delivery cheap Alprazolam cash on delivery no prescription required for Alprazolam order Alprazolam c.o.d. not expensive Alprazolam prescriptions Alprazolam online Cash on Delivery buy Alprazolam overnight delivery Alprazolam online without presciption buy Alprazolam prescription online no prescription saturday delivery Alprazolam where to buy cheap Alprazolam no prescription Alprazolam wo get Alprazolam over the counter fedex Alprazolam with no rx and free shipping order Alprazolam over the counter cod overnight Alprazolam Fedex Without Prescription Alprazolam Online With Next Day Shipping Buy Cheap Alprazolam online | purchase Alprazolam without prescription online | Alprazolam Online Prescriptions With No Membership Alprazolam Cheap next day | Buy Cheap Alprazolam fedex overnight | original Alprazolam pill | Purchase Alprazolam pharmacy r x online | Alprazolam cod Orders | Buy Alprazolam online pharmacy | Alprazolam cod ne xt day delivery | order Alprazolam online no membership overnight shipping | B uy Cheap Alprazolam Online No Prescription Order Alprazolam cod next day delivery | Alprazolam Discount cards | Buy genuine Alprazolam online | buying Alprazolam without a prescription | Where To Buy Alprazolam No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Alprazolam fedex without prescription | U ltram consumer information | pills Cheap generic Alprazolam | Buy Alprazolam onlin e no prescription | Alprazolam Buy | Buy Cheap Alprazolam Online No Prescription B uy Alprazolam online | purchase Alprazolam without prescription | Buying Alprazolam On line Without Prescription Alprazolam Overnight COD no prescription | Cheap onli ne Buy Alprazolam | Low Price Alprazolam Saturday Delivery No Prescription Alprazolam w ithout a prescription no generics | Buy Alprazolam Without Prescription Alprazolam overnight | Buy With No Prescription Alprazolam Online Order Alprazolam no rx overn ight delivery | Order Alprazolam Saturday Delivery No Prescription Alprazolam onlin e no prescription | Alprazolam Discount cards | Buy Alprazolam no script | Alprazolam by phone no script | Buy Alprazolam Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Alprazolam online without a prescription and no me mbership | Buy Without Prescription Alprazolam Online buy no prescription Ultra m | Order Alprazolam Cheap no membership fees no prescription | Alprazolam order n o script | Alprazolam lowest cost | online Buy Alprazolam | Overnight Alprazolam With out A Prescription Alprazolam Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Alprazolam Without A Prescription no script Alprazolam | Alprazolam Buy phone | Alprazolam paid with mastercard | Alprazolam With No Prescript ion Alprazolam to purchase | Order Alprazolam online with no prescription | Alprazolam Buying online Alprazolam drugs | Alprazolam free Overnight fedex delivery | Ultra m best online pharmacy | purchase Alprazolam without a prescription overnight d elivery | Buy Alprazolam online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Alprazolam From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Alprazolam next day | Where To Buy Alprazolam No Prescription No Fees Alprazolam ups cod | Order Alprazolam cash on delive ry | Alprazolam overnight shipping no prescription | purchase Alprazolam without p rescription online | Buy Alprazolam online without dr approval | Buy Alprazolam on line without dr approval | Alprazolam ups | Alprazolam Buy | Buy Alprazolam in Idaho | Alprazolam cheapest | Buy Alprazolam pay with mastercard | ordering Buy Alprazolam online | Alprazolam Overnight COD no prescription | Alprazolam order cod | Alprazolam No Prescription Alprazolam overnight delivery Cheap | Alprazolam order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Alprazolam usa online pharmacy | U ltram free consultation | how to Order Alprazolam without doctors | Purchase U ltram online | comprar Alprazolam | No Prescription Required For Alprazolam Alprazolam cod ordering | Cheap Alprazolam without prescription | Buy Cheap Alprazolam fast | Alprazolam Buy | Buy Alprazolam online without a prescription and no membership | Cheap Alprazolam without prescription overnight delivery | cash on delivery online prescriptions Alprazolam | Alprazolam with no prescription | ordering Ultra m online without a prescription | Alprazolam Cheap order | Alprazolam online no pr escription | No Prescription Needed Alprazolam Low Price Alprazolam With No Prescri ption Buy Alprazolam Online Without Prescription buy no prescription Alprazolam | B uy Alprazolam online discount | Alprazolam order cod | Order Cheap Alprazolam very Buy without prescription | Alprazolam cod next day delivery | Order Alprazolam Online Without Prescription Alprazolam free Overnight fedex delivery | Cheap Alprazolam b y money Order | Buy Alprazolam online discount | overnight Alprazolam | 8 Buy Ult ram online | Cheap Alprazolam c.o.d. | Buy Alprazolam Tablets Without Prescription Overnight Alprazolam for sale | Buy Alprazolam online sales | natural Alprazolam | U ltram manufacturer | Alprazolam Online No Prescription Alprazolam adiction | geniu ne Alprazolam no prescription | Alprazolam Pharmacy Cod Saturday Delivery With No P rescription Alprazolam Buy phone | Buy Alprazolam online prescription | Order Ultr am without prescription from us pharmacy | Buy real Alprazolam with mastercard | Alprazolam without a rx | doctor online prescription Alprazolam | Alprazolam Free O vernight Fedex Delivery order Alprazolam online cash on delivery | Cheap Alprazolam next day | Buy Alprazolam Cheap online us pharmacy | Alprazolam delivery to uk fe dex Overnight | Find Cheap Alprazolam no prescription | online pharmacy Alprazolam | Buy Alprazolam Online Without A Prescription And No Membership Alprazolam to pur chase | Alprazolam Same Day Delivery No Prescription Alprazolam by phone no script | Buy Alprazolam without | discount Alprazolam overnight | Buy Cheap Alprazolam, Buy Cheap Alprazolam online | Alprazolam Buy fedex | Alprazolam shipped with no prescripti on | Buy Alprazolam online money order | purchase Alprazolam without a prescriptio n | Alprazolam ups cod | Buy Alprazolam Online No Prescription Buy Alprazolam online | Alprazolam with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Alprazolam cod | how to get Alprazolam prescription | Low Price Alprazolam With No Prescription Buy the Cheapest Alprazolam online index | prescription U ltram | Order Alprazolam No Prescription Order Alprazolam medicine online without p rescription | Low Price Alprazolam Saturday Delivery No Prescription Cheap Ultr am overnight | Alprazolam Online No Prescription Alprazolam online cash on delivery | Fedex Alprazolam Without Prescription Buy Alprazolam online usa | Alprazolam for sa le without a prescription | to Buy Alprazolam without a prescription | Alprazolam Overnight no script mastercard accepted | Buy Cheap Alprazolam No Prescription Cheap Alprazolam free consultant | Buy Alprazolam Cheap online us pharmacy | Buy C heap Alprazolam No Prescription Alprazolam lowest cost | Where To Buy Alprazolam No Pre scription No Fees Cheapest Alprazolam Online Without Prescription cheapest Ultra m | Alprazolam amphetimine | Buy Alprazolam 120 tabs | Buy Alprazolam Without A Presc ription Or Membership Alprazolam Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Alprazolam | Alprazolam conversion | overnight Alprazolam ups cod | Buy Alprazolam online Cheap | Alprazolam No Script Required Express Delivery With No P rescription Alprazolam free consultation u.s. pharmacy | Alprazolam cod no script | Alprazolam ups cod | Alprazolam online no prescription | purchase Alprazolam with co d | Canadian Alprazolam Pills No Prescription Buy Alprazolam in North Carolina | buy Alprazolam in Denmark, buy Alprazolam in Egypt, buy Alprazolam in Israel, buy Alprazolam in Ireland, buy Alprazolam in Spain, buy Alprazolam in Italy, buy Alprazolam in Canada, buy Alprazolam in Cyprus, buy Alprazolam in Mexico, buy Alprazolam in Netherlands, buy Alprazolam in New zealand, buy Alprazolam in Kingston, buy Alprazolam in Australia, buy Alprazolam in AU, buy Alprazolam in New South Wales, buy Alprazolam in NSW, buy Alprazolam i n Sydney, buy Alprazolam in Brisbane, buy Alprazolam in South Australia, buy Alprazolam in Hobart, buy Alprazolam in the United states, buy Alprazolam in Finland, buy Ultra m in France, buy Alprazolam in Chekhiya, buy Alprazolam in Switzerland, buy Alprazolam i n Sweden, buy Alprazolam in Alberta, buy Alprazolam in Labrador, buy Alprazolam in Toron to, buy Alprazolam in Ottawa, buy Alprazolam in Mississauga, buy Alprazolam in Hamilton, buy Alprazolam in Brampton, buy Alprazolam in London, buy Alprazolam in Markham, buy Ul tram in Vaughan, buy Alprazolam in Windsor, buy Alprazolam in Kitchener, buy Alprazolam in Montreal, buy Alprazolam in Mauricie, buy Alprazolam in Vancouver, buy Alprazolam in Victoria, buy Alprazolam in Kelowna, buy Alprazolam in Abbotsford, buy Alprazolam in Kam loops, buy Alprazolam in Nanaimo, buy Alprazolam in Vernon, buy Alprazolam in Lethbridge , buy Alprazolam in United Kingdom, buy Alprazolam in England, buy Alprazolam in Wales, buy Alprazolam in Scotland, buy Alprazolam in Northern Ireland, buy Alprazolam in Belfas t, buy Alprazolam in Cardiff, buy Alprazolam in London, buy Alprazolam in Glasgow, buy U ltram in Liverpool, buy Alprazolam in Leeds, buy Alprazolam in Victoria, buy Alprazolam in Melbourne, buy Alprazolam in Western Australia, buy Alprazolam in Perth, buy Ultr am in Alabama, buy Alprazolam in Arizona, buy Alprazolam in Arkansas, buy Alprazolam in California, buy Alprazolam in Colorado, buy Alprazolam in Connecticut, buy Alprazolam in Delaware, buy Alprazolam in Florida, buy Alprazolam in Georgia, buy Alprazolam in Hawai i, buy Alprazolam in Idaho, buy Alprazolam in Illinois, buy Alprazolam in Indiana, buy U ltram in Iowa, buy Alprazolam in Kansas, buy Alprazolam in Kentucky, buy Alprazolam in L ouisiana, buy Alprazolam in Maine, buy Alprazolam in Montana, buy Alprazolam in Nebraska , buy Alprazolam in Nevada, buy Alprazolam in New Jersey, buy Alprazolam in New Mexico, buy Alprazolam in New York, buy Alprazolam in North Carolina, buy Alprazolam in North Da kota, buy Alprazolam in Ohio, buy Alprazolam in Oklahoma, buy Alprazolam in Texas, buy U ltram in Utah, buy Alprazolam in Vermont, buy Alprazolam in Virginia, buy Alprazolam in Washington, buy Alprazolam in West Virginia, buy Alprazolam in Wisconsin, buy Alprazolam in Wyoming, buy Alprazolam in Montgomery, buy Alprazolam in Juneau, buy Alprazolam in P hoenix, buy Alprazolam in Little Rock, buy Alprazolam in Sacramento, buy Alprazolam in D enver, buy Alprazolam in Hartford, buy Alprazolam in Dover, buy Alprazolam in Tallahasse e, buy Alprazolam in Atlanta, buy Alprazolam in Springfield, buy Alprazolam in Indianapo lis, buy Alprazolam in Des Moines, buy Alprazolam in Annapolis, buy Alprazolam in Boston , buy Alprazolam in Lansing, buy Alprazolam in Helena, buy Alprazolam in Lincoln, buy Ul tram in Santa Fe, buy Alprazolam in Albany, buy Alprazolam in Raleigh, buy Alprazolam in Bismarck, buy Alprazolam in Columbus, buy Alprazolam in Salem, buy Alprazolam in Columb ia, buy Alprazolam in Salt Lake City, buy Alprazolam in Montpelier, buy Alprazolam in Ch arleston, buy Alprazolam in Madison, buy Alprazolam in Cheyenne, buy Alprazolam in Austr alia, buy Alprazolam in Austria, buy Alprazolam in Argentina, buy Alprazolam in Belgium, buy Alprazolam in Bulgaria, buy Alprazolam in Brasilia, buy Alprazolam in Great britain , buy Alprazolam in Hungary, buy Alprazolam in Germany, buy Alprazolam in Greece, buy Ul tram in South Africa, buy Alprazolam in Japan From numansenm at gmail.com Thu Nov 10 13:38:37 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:38:37 -0800 (PST) Subject: Buying Alprazolam in UK! Alprazolam Online UK! Alprazolam no prescription! Buy Alprazolam meds Online! Message-ID: <1653db5a-5b5b-4d48-84e2-cf5a3bff2b27@y12g2000vba.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Alprazolam/Alprazolam pills with every Order ______________________________________________________________________ BUY Alprazolam ONLINE http://buypharmasite.com/?q=Alprazolam CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Alprazolam ONLINE http://buypharmasite.com/?q=Alprazolam CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Alprazolam Alprazolam online saturday delivery online Alprazolam and fedex cheap order prescription Alprazolam cheap Alprazolam by money order buy Alprazolam from mexico online Alprazolam no prescription usa fedex shipping overnight delivery Alprazolam buy Alprazolam online without a prescription and no membership no prescription needed Alprazolam cod shipped Alprazolam not expensive order prescription Alprazolam Alprazolam money order Alprazolam without a perscription online buy Alprazolam Alprazolam fedex buy no online prescription Alprazolam Alprazolam pharmacies accepting cod delivery Alprazolam online consultant online pharmacy fedex cod Alprazolam buy Alprazolam no scams Alprazolam c.o.d overnight delivery buy Alprazolam no prescription cod overnight Alprazolam order Alprazolam online doctors buy Alprazolam on line no prescription Alprazolam no prescription usa fedex shipping Alprazolam online uk watson brand Alprazolam medicine online Alprazolam order Alprazolam samples sent buy Alprazolam no prescription order Alprazolam without a prescription Alprazolam no prescription drug cheap online order Alprazolam get Alprazolam over the counter online order Alprazolam next day buy Alprazolam no perscription cod real Alprazolam fed ex Alprazolam no prescription cod does cv/ pharmacy carry Alprazolam no prescription cod Alprazolam cheap Alprazolam without rx Alprazolam online health insurance lead buy Alprazolam online with overnight delivery Alprazolam no rx fed ex buy Alprazolam without a perscription lowest prices for Alprazolam online buy Alprazolam paypal online without prescription cheap non prescription Alprazolam Alprazolam ups Alprazolam for cheap buy Alprazolam no visa online without prescription cheapest Alprazolam cash on delivery Alprazolam order a prepaid mastercard buy online Alprazolam purchase Alprazolam mail order Alprazolam without a prescription online with overnight delivery Alprazolam from canada buy Alprazolam with no rx overnight delivery of Alprazolam with no prescription cash on delivery Alprazolam no rx Alprazolam by cod buy Alprazolam over the counter cod overnight overnight Alprazolam order Alprazolam without prescription from us pharmacy cheap Alprazolam free fedex shipping order Alprazolam over the counter where to buy Alprazolam no prescription no fees only Alprazolam free consult cod delivery Alprazolam Alprazolam no prescription Alprazolam online overnight delivery cod order Alprazolam over the counter fedex Alprazolam saturday delivery buy Alprazolam money order Alprazolam without prescription mexico buy cheap Alprazolam without prescription Alprazolam non prescription for next day delivery Alprazolam ups delivery only buy Alprazolam usa cod Alprazolam with next day delivery no prescriptions needed for Alprazolam cheap Alprazolam overnight prescription Alprazolam cheap Alprazolam overnight delivery Alprazolam non prescription fedex overnight free order Alprazolam no creditcard buy cheap Alprazolam no Prescription buy Alprazolam over the counter fedex Alprazolam no doctor presribe needed cheap watson Alprazolam online cheap discount Alprazolam buy Alprazolam without a prescription online cheapest Alprazolam free delivery buy Alprazolam online overseas buy Alprazolam over the counter online not expensive Alprazolam next day shipping order Alprazolam cod next day delivery Alprazolam cheap Alprazolam buy in UK Alprazolam next day cod fedex Alprazolam to buy cheap order Alprazolam next day Alprazolam Alprazolam overnight no consult cheap watson Alprazolam no prescription needed Alprazolam without prescription medications overnight delivery of Alprazolam with no perscription buy Alprazolam.com Alprazolam cod next day delivery buy cheap discount online Alprazolam buy Alprazolam drug Alprazolam overnight delivery cheap overnight delivery of Alprazolam in US no prescription needed purchase Alprazolam free next day airAlprazolam on line cheap Alprazolam without a prescription Alprazolam cheap cod Alprazolam buy no prepaid cheap Alprazolam next day buy Alprazolam cod accepted online pharmacies Alprazolam saturday delivery buy Alprazolam pay pal Alprazolam shipped on saturday Alprazolam pharmacy cod saturday delivery buy online Alprazolam prescriptions free fedex delivery Alprazolam Alprazolam without prescription cash on delivery buy discount Alprazolam Alprazolam overnight cheap best Alprazolam online pill images of Alprazolam Alprazolam U.P.S SHIPPING COD Alprazolam cod pharmacy buy Alprazolam online cod Alprazolam cod overnight delivery Alprazolam no rx overnight buy Alprazolam overnight COD online pharmacy Alprazolam cod order Alprazolam insurance Alprazolam cash delivery cod buy Alprazolam cheap cod no rx online pharmacy Alprazolam sale nextday Alprazolam Alprazolam pill Alprazolam online ordering Alprazolam online without prescription Alprazolam no script needed cod overnight how to buy Alprazolam online without a prescription cheap Alprazolam without prescription cheap Alprazolam online no rx saturday delivery order Alprazolam over the counter for sale Alprazolam next day delivery cod order Alprazolam online without prescription no prescription next day delivery Alprazolam overnight Alprazolam C.O.D Alprazolam without prescription Alprazolam discount fedex no prescription buy Alprazolam amex Alprazolam online next day Alprazolam shipped with no prescription Alprazolam online cheap cheap Alprazolam without prescription overnight delivery buy Alprazolam over the counter for sale Alprazolam no prescriptions needed cod Alprazolam fed ex cheap overnight delivery of Alprazolam free prescription Alprazolam free shipping not expensive legal Alprazolam for sale buy Alprazolam cod Alprazolam for saturday Alprazolam price cash for Alprazolam cash on delivery Alprazolam Alprazolam without a prescription and cod delivery buying Alprazolam without a prescription order Alprazolam no rx buy Alprazolam without rx Alprazolam cheapest buy Alprazolam online pharmacy buy cheap Alprazolam overnight delivery Alprazolam and online pharmacy Alprazolam next day Alprazolam drug no prescription where can i buy Alprazolam no prescription Alprazolam with saturday delivery Alprazolam online overnight Alprazolam no prescription worldwide buy cheap Alprazolam cod ordering Alprazolam online Buy Alprazolam overnight shipping Alprazolam overnight US delivery cheap real Alprazolam for sale Alprazolam no prescriptions needed COD buy Alprazolam no prescription needed Alprazolam no prescription overnight cod delivery cheap Alprazolam cash on delivery no prescription required for Alprazolam order Alprazolam c.o.d. not expensive Alprazolam prescriptions Alprazolam online Cash on Delivery buy Alprazolam overnight delivery Alprazolam online without presciption buy Alprazolam prescription online no prescription saturday delivery Alprazolam where to buy cheap Alprazolam no prescription Alprazolam wo get Alprazolam over the counter fedex Alprazolam with no rx and free shipping order Alprazolam over the counter cod overnight Alprazolam Fedex Without Prescription Alprazolam Online With Next Day Shipping Buy Cheap Alprazolam online | purchase Alprazolam without prescription online | Alprazolam Online Prescriptions With No Membership Alprazolam Cheap next day | Buy Cheap Alprazolam fedex overnight | original Alprazolam pill | Purchase Alprazolam pharmacy r x online | Alprazolam cod Orders | Buy Alprazolam online pharmacy | Alprazolam cod ne xt day delivery | order Alprazolam online no membership overnight shipping | B uy Cheap Alprazolam Online No Prescription Order Alprazolam cod next day delivery | Alprazolam Discount cards | Buy genuine Alprazolam online | buying Alprazolam without a prescription | Where To Buy Alprazolam No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Alprazolam fedex without prescription | U ltram consumer information | pills Cheap generic Alprazolam | Buy Alprazolam onlin e no prescription | Alprazolam Buy | Buy Cheap Alprazolam Online No Prescription B uy Alprazolam online | purchase Alprazolam without prescription | Buying Alprazolam On line Without Prescription Alprazolam Overnight COD no prescription | Cheap onli ne Buy Alprazolam | Low Price Alprazolam Saturday Delivery No Prescription Alprazolam w ithout a prescription no generics | Buy Alprazolam Without Prescription Alprazolam overnight | Buy With No Prescription Alprazolam Online Order Alprazolam no rx overn ight delivery | Order Alprazolam Saturday Delivery No Prescription Alprazolam onlin e no prescription | Alprazolam Discount cards | Buy Alprazolam no script | Alprazolam by phone no script | Buy Alprazolam Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Alprazolam online without a prescription and no me mbership | Buy Without Prescription Alprazolam Online buy no prescription Ultra m | Order Alprazolam Cheap no membership fees no prescription | Alprazolam order n o script | Alprazolam lowest cost | online Buy Alprazolam | Overnight Alprazolam With out A Prescription Alprazolam Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Alprazolam Without A Prescription no script Alprazolam | Alprazolam Buy phone | Alprazolam paid with mastercard | Alprazolam With No Prescript ion Alprazolam to purchase | Order Alprazolam online with no prescription | Alprazolam Buying online Alprazolam drugs | Alprazolam free Overnight fedex delivery | Ultra m best online pharmacy | purchase Alprazolam without a prescription overnight d elivery | Buy Alprazolam online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Alprazolam From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Alprazolam next day | Where To Buy Alprazolam No Prescription No Fees Alprazolam ups cod | Order Alprazolam cash on delive ry | Alprazolam overnight shipping no prescription | purchase Alprazolam without p rescription online | Buy Alprazolam online without dr approval | Buy Alprazolam on line without dr approval | Alprazolam ups | Alprazolam Buy | Buy Alprazolam in Idaho | Alprazolam cheapest | Buy Alprazolam pay with mastercard | ordering Buy Alprazolam online | Alprazolam Overnight COD no prescription | Alprazolam order cod | Alprazolam No Prescription Alprazolam overnight delivery Cheap | Alprazolam order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Alprazolam usa online pharmacy | U ltram free consultation | how to Order Alprazolam without doctors | Purchase U ltram online | comprar Alprazolam | No Prescription Required For Alprazolam Alprazolam cod ordering | Cheap Alprazolam without prescription | Buy Cheap Alprazolam fast | Alprazolam Buy | Buy Alprazolam online without a prescription and no membership | Cheap Alprazolam without prescription overnight delivery | cash on delivery online prescriptions Alprazolam | Alprazolam with no prescription | ordering Ultra m online without a prescription | Alprazolam Cheap order | Alprazolam online no pr escription | No Prescription Needed Alprazolam Low Price Alprazolam With No Prescri ption Buy Alprazolam Online Without Prescription buy no prescription Alprazolam | B uy Alprazolam online discount | Alprazolam order cod | Order Cheap Alprazolam very Buy without prescription | Alprazolam cod next day delivery | Order Alprazolam Online Without Prescription Alprazolam free Overnight fedex delivery | Cheap Alprazolam b y money Order | Buy Alprazolam online discount | overnight Alprazolam | 8 Buy Ult ram online | Cheap Alprazolam c.o.d. | Buy Alprazolam Tablets Without Prescription Overnight Alprazolam for sale | Buy Alprazolam online sales | natural Alprazolam | U ltram manufacturer | Alprazolam Online No Prescription Alprazolam adiction | geniu ne Alprazolam no prescription | Alprazolam Pharmacy Cod Saturday Delivery With No P rescription Alprazolam Buy phone | Buy Alprazolam online prescription | Order Ultr am without prescription from us pharmacy | Buy real Alprazolam with mastercard | Alprazolam without a rx | doctor online prescription Alprazolam | Alprazolam Free O vernight Fedex Delivery order Alprazolam online cash on delivery | Cheap Alprazolam next day | Buy Alprazolam Cheap online us pharmacy | Alprazolam delivery to uk fe dex Overnight | Find Cheap Alprazolam no prescription | online pharmacy Alprazolam | Buy Alprazolam Online Without A Prescription And No Membership Alprazolam to pur chase | Alprazolam Same Day Delivery No Prescription Alprazolam by phone no script | Buy Alprazolam without | discount Alprazolam overnight | Buy Cheap Alprazolam, Buy Cheap Alprazolam online | Alprazolam Buy fedex | Alprazolam shipped with no prescripti on | Buy Alprazolam online money order | purchase Alprazolam without a prescriptio n | Alprazolam ups cod | Buy Alprazolam Online No Prescription Buy Alprazolam online | Alprazolam with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Alprazolam cod | how to get Alprazolam prescription | Low Price Alprazolam With No Prescription Buy the Cheapest Alprazolam online index | prescription U ltram | Order Alprazolam No Prescription Order Alprazolam medicine online without p rescription | Low Price Alprazolam Saturday Delivery No Prescription Cheap Ultr am overnight | Alprazolam Online No Prescription Alprazolam online cash on delivery | Fedex Alprazolam Without Prescription Buy Alprazolam online usa | Alprazolam for sa le without a prescription | to Buy Alprazolam without a prescription | Alprazolam Overnight no script mastercard accepted | Buy Cheap Alprazolam No Prescription Cheap Alprazolam free consultant | Buy Alprazolam Cheap online us pharmacy | Buy C heap Alprazolam No Prescription Alprazolam lowest cost | Where To Buy Alprazolam No Pre scription No Fees Cheapest Alprazolam Online Without Prescription cheapest Ultra m | Alprazolam amphetimine | Buy Alprazolam 120 tabs | Buy Alprazolam Without A Presc ription Or Membership Alprazolam Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Alprazolam | Alprazolam conversion | overnight Alprazolam ups cod | Buy Alprazolam online Cheap | Alprazolam No Script Required Express Delivery With No P rescription Alprazolam free consultation u.s. pharmacy | Alprazolam cod no script | Alprazolam ups cod | Alprazolam online no prescription | purchase Alprazolam with co d | Canadian Alprazolam Pills No Prescription Buy Alprazolam in North Carolina | buy Alprazolam in Denmark, buy Alprazolam in Egypt, buy Alprazolam in Israel, buy Alprazolam in Ireland, buy Alprazolam in Spain, buy Alprazolam in Italy, buy Alprazolam in Canada, buy Alprazolam in Cyprus, buy Alprazolam in Mexico, buy Alprazolam in Netherlands, buy Alprazolam in New zealand, buy Alprazolam in Kingston, buy Alprazolam in Australia, buy Alprazolam in AU, buy Alprazolam in New South Wales, buy Alprazolam in NSW, buy Alprazolam i n Sydney, buy Alprazolam in Brisbane, buy Alprazolam in South Australia, buy Alprazolam in Hobart, buy Alprazolam in the United states, buy Alprazolam in Finland, buy Ultra m in France, buy Alprazolam in Chekhiya, buy Alprazolam in Switzerland, buy Alprazolam i n Sweden, buy Alprazolam in Alberta, buy Alprazolam in Labrador, buy Alprazolam in Toron to, buy Alprazolam in Ottawa, buy Alprazolam in Mississauga, buy Alprazolam in Hamilton, buy Alprazolam in Brampton, buy Alprazolam in London, buy Alprazolam in Markham, buy Ul tram in Vaughan, buy Alprazolam in Windsor, buy Alprazolam in Kitchener, buy Alprazolam in Montreal, buy Alprazolam in Mauricie, buy Alprazolam in Vancouver, buy Alprazolam in Victoria, buy Alprazolam in Kelowna, buy Alprazolam in Abbotsford, buy Alprazolam in Kam loops, buy Alprazolam in Nanaimo, buy Alprazolam in Vernon, buy Alprazolam in Lethbridge , buy Alprazolam in United Kingdom, buy Alprazolam in England, buy Alprazolam in Wales, buy Alprazolam in Scotland, buy Alprazolam in Northern Ireland, buy Alprazolam in Belfas t, buy Alprazolam in Cardiff, buy Alprazolam in London, buy Alprazolam in Glasgow, buy U ltram in Liverpool, buy Alprazolam in Leeds, buy Alprazolam in Victoria, buy Alprazolam in Melbourne, buy Alprazolam in Western Australia, buy Alprazolam in Perth, buy Ultr am in Alabama, buy Alprazolam in Arizona, buy Alprazolam in Arkansas, buy Alprazolam in California, buy Alprazolam in Colorado, buy Alprazolam in Connecticut, buy Alprazolam in Delaware, buy Alprazolam in Florida, buy Alprazolam in Georgia, buy Alprazolam in Hawai i, buy Alprazolam in Idaho, buy Alprazolam in Illinois, buy Alprazolam in Indiana, buy U ltram in Iowa, buy Alprazolam in Kansas, buy Alprazolam in Kentucky, buy Alprazolam in L ouisiana, buy Alprazolam in Maine, buy Alprazolam in Montana, buy Alprazolam in Nebraska , buy Alprazolam in Nevada, buy Alprazolam in New Jersey, buy Alprazolam in New Mexico, buy Alprazolam in New York, buy Alprazolam in North Carolina, buy Alprazolam in North Da kota, buy Alprazolam in Ohio, buy Alprazolam in Oklahoma, buy Alprazolam in Texas, buy U ltram in Utah, buy Alprazolam in Vermont, buy Alprazolam in Virginia, buy Alprazolam in Washington, buy Alprazolam in West Virginia, buy Alprazolam in Wisconsin, buy Alprazolam in Wyoming, buy Alprazolam in Montgomery, buy Alprazolam in Juneau, buy Alprazolam in P hoenix, buy Alprazolam in Little Rock, buy Alprazolam in Sacramento, buy Alprazolam in D enver, buy Alprazolam in Hartford, buy Alprazolam in Dover, buy Alprazolam in Tallahasse e, buy Alprazolam in Atlanta, buy Alprazolam in Springfield, buy Alprazolam in Indianapo lis, buy Alprazolam in Des Moines, buy Alprazolam in Annapolis, buy Alprazolam in Boston , buy Alprazolam in Lansing, buy Alprazolam in Helena, buy Alprazolam in Lincoln, buy Ul tram in Santa Fe, buy Alprazolam in Albany, buy Alprazolam in Raleigh, buy Alprazolam in Bismarck, buy Alprazolam in Columbus, buy Alprazolam in Salem, buy Alprazolam in Columb ia, buy Alprazolam in Salt Lake City, buy Alprazolam in Montpelier, buy Alprazolam in Ch arleston, buy Alprazolam in Madison, buy Alprazolam in Cheyenne, buy Alprazolam in Austr alia, buy Alprazolam in Austria, buy Alprazolam in Argentina, buy Alprazolam in Belgium, buy Alprazolam in Bulgaria, buy Alprazolam in Brasilia, buy Alprazolam in Great britain , buy Alprazolam in Hungary, buy Alprazolam in Germany, buy Alprazolam in Greece, buy Ul tram in South Africa, buy Alprazolam in Japan From numansenm at gmail.com Thu Nov 10 13:39:57 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:39:57 -0800 (PST) Subject: Buy Tadalafil Online without script, Tadalafil prescription from doctors Online, Order Tadalafil without prescription from us pharmacy Message-ID: <012233dd-474c-47e5-88bf-0c26a4a9e2bf@f29g2000yqa.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Tadalafil/Tadalafil pills with every Order ______________________________________________________________________ BUY Tadalafil ONLINE http://buypharmasite.com/?q=Tadalafil CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Tadalafil ONLINE http://buypharmasite.com/?q=Tadalafil CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Tadalafil Tadalafil online saturday delivery online Tadalafil and fedex cheap order prescription Tadalafil cheap Tadalafil by money order buy Tadalafil from mexico online Tadalafil no prescription usa fedex shipping overnight delivery Tadalafil buy Tadalafil online without a prescription and no membership no prescription needed Tadalafil cod shipped Tadalafil not expensive order prescription Tadalafil Tadalafil money order Tadalafil without a perscription online buy Tadalafil Tadalafil fedex buy no online prescription Tadalafil Tadalafil pharmacies accepting cod delivery Tadalafil online consultant online pharmacy fedex cod Tadalafil buy Tadalafil no scams Tadalafil c.o.d overnight delivery buy Tadalafil no prescription cod overnight Tadalafil order Tadalafil online doctors buy Tadalafil on line no prescription Tadalafil no prescription usa fedex shipping Tadalafil online uk watson brand Tadalafil medicine online Tadalafil order Tadalafil samples sent buy Tadalafil no prescription order Tadalafil without a prescription Tadalafil no prescription drug cheap online order Tadalafil get Tadalafil over the counter online order Tadalafil next day buy Tadalafil no perscription cod real Tadalafil fed ex Tadalafil no prescription cod does cv/ pharmacy carry Tadalafil no prescription cod Tadalafil cheap Tadalafil without rx Tadalafil online health insurance lead buy Tadalafil online with overnight delivery Tadalafil no rx fed ex buy Tadalafil without a perscription lowest prices for Tadalafil online buy Tadalafil paypal online without prescription cheap non prescription Tadalafil Tadalafil ups Tadalafil for cheap buy Tadalafil no visa online without prescription cheapest Tadalafil cash on delivery Tadalafil order a prepaid mastercard buy online Tadalafil purchase Tadalafil mail order Tadalafil without a prescription online with overnight delivery Tadalafil from canada buy Tadalafil with no rx overnight delivery of Tadalafil with no prescription cash on delivery Tadalafil no rx Tadalafil by cod buy Tadalafil over the counter cod overnight overnight Tadalafil order Tadalafil without prescription from us pharmacy cheap Tadalafil free fedex shipping order Tadalafil over the counter where to buy Tadalafil no prescription no fees only Tadalafil free consult cod delivery Tadalafil Tadalafil no prescription Tadalafil online overnight delivery cod order Tadalafil over the counter fedex Tadalafil saturday delivery buy Tadalafil money order Tadalafil without prescription mexico buy cheap Tadalafil without prescription Tadalafil non prescription for next day delivery Tadalafil ups delivery only buy Tadalafil usa cod Tadalafil with next day delivery no prescriptions needed for Tadalafil cheap Tadalafil overnight prescription Tadalafil cheap Tadalafil overnight delivery Tadalafil non prescription fedex overnight free order Tadalafil no creditcard buy cheap Tadalafil no Prescription buy Tadalafil over the counter fedex Tadalafil no doctor presribe needed cheap watson Tadalafil online cheap discount Tadalafil buy Tadalafil without a prescription online cheapest Tadalafil free delivery buy Tadalafil online overseas buy Tadalafil over the counter online not expensive Tadalafil next day shipping order Tadalafil cod next day delivery Tadalafil cheap Tadalafil buy in UK Tadalafil next day cod fedex Tadalafil to buy cheap order Tadalafil next day Tadalafil Tadalafil overnight no consult cheap watson Tadalafil no prescription needed Tadalafil without prescription medications overnight delivery of Tadalafil with no perscription buy Tadalafil.com Tadalafil cod next day delivery buy cheap discount online Tadalafil buy Tadalafil drug Tadalafil overnight delivery cheap overnight delivery of Tadalafil in US no prescription needed purchase Tadalafil free next day airTadalafil on line cheap Tadalafil without a prescription Tadalafil cheap cod Tadalafil buy no prepaid cheap Tadalafil next day buy Tadalafil cod accepted online pharmacies Tadalafil saturday delivery buy Tadalafil pay pal Tadalafil shipped on saturday Tadalafil pharmacy cod saturday delivery buy online Tadalafil prescriptions free fedex delivery Tadalafil Tadalafil without prescription cash on delivery buy discount Tadalafil Tadalafil overnight cheap best Tadalafil online pill images of Tadalafil Tadalafil U.P.S SHIPPING COD Tadalafil cod pharmacy buy Tadalafil online cod Tadalafil cod overnight delivery Tadalafil no rx overnight buy Tadalafil overnight COD online pharmacy Tadalafil cod order Tadalafil insurance Tadalafil cash delivery cod buy Tadalafil cheap cod no rx online pharmacy Tadalafil sale nextday Tadalafil Tadalafil pill Tadalafil online ordering Tadalafil online without prescription Tadalafil no script needed cod overnight how to buy Tadalafil online without a prescription cheap Tadalafil without prescription cheap Tadalafil online no rx saturday delivery order Tadalafil over the counter for sale Tadalafil next day delivery cod order Tadalafil online without prescription no prescription next day delivery Tadalafil overnight Tadalafil C.O.D Tadalafil without prescription Tadalafil discount fedex no prescription buy Tadalafil amex Tadalafil online next day Tadalafil shipped with no prescription Tadalafil online cheap cheap Tadalafil without prescription overnight delivery buy Tadalafil over the counter for sale Tadalafil no prescriptions needed cod Tadalafil fed ex cheap overnight delivery of Tadalafil free prescription Tadalafil free shipping not expensive legal Tadalafil for sale buy Tadalafil cod Tadalafil for saturday Tadalafil price cash for Tadalafil cash on delivery Tadalafil Tadalafil without a prescription and cod delivery buying Tadalafil without a prescription order Tadalafil no rx buy Tadalafil without rx Tadalafil cheapest buy Tadalafil online pharmacy buy cheap Tadalafil overnight delivery Tadalafil and online pharmacy Tadalafil next day Tadalafil drug no prescription where can i buy Tadalafil no prescription Tadalafil with saturday delivery Tadalafil online overnight Tadalafil no prescription worldwide buy cheap Tadalafil cod ordering Tadalafil online Buy Tadalafil overnight shipping Tadalafil overnight US delivery cheap real Tadalafil for sale Tadalafil no prescriptions needed COD buy Tadalafil no prescription needed Tadalafil no prescription overnight cod delivery cheap Tadalafil cash on delivery no prescription required for Tadalafil order Tadalafil c.o.d. not expensive Tadalafil prescriptions Tadalafil online Cash on Delivery buy Tadalafil overnight delivery Tadalafil online without presciption buy Tadalafil prescription online no prescription saturday delivery Tadalafil where to buy cheap Tadalafil no prescription Tadalafil wo get Tadalafil over the counter fedex Tadalafil with no rx and free shipping order Tadalafil over the counter cod overnight Tadalafil Fedex Without Prescription Tadalafil Online With Next Day Shipping Buy Cheap Tadalafil online | purchase Tadalafil without prescription online | Tadalafil Online Prescriptions With No Membership Tadalafil Cheap next day | Buy Cheap Tadalafil fedex overnight | original Tadalafil pill | Purchase Tadalafil pharmacy r x online | Tadalafil cod Orders | Buy Tadalafil online pharmacy | Tadalafil cod ne xt day delivery | order Tadalafil online no membership overnight shipping | B uy Cheap Tadalafil Online No Prescription Order Tadalafil cod next day delivery | Tadalafil Discount cards | Buy genuine Tadalafil online | buying Tadalafil without a prescription | Where To Buy Tadalafil No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Tadalafil fedex without prescription | U ltram consumer information | pills Cheap generic Tadalafil | Buy Tadalafil onlin e no prescription | Tadalafil Buy | Buy Cheap Tadalafil Online No Prescription B uy Tadalafil online | purchase Tadalafil without prescription | Buying Tadalafil On line Without Prescription Tadalafil Overnight COD no prescription | Cheap onli ne Buy Tadalafil | Low Price Tadalafil Saturday Delivery No Prescription Tadalafil w ithout a prescription no generics | Buy Tadalafil Without Prescription Tadalafil overnight | Buy With No Prescription Tadalafil Online Order Tadalafil no rx overn ight delivery | Order Tadalafil Saturday Delivery No Prescription Tadalafil onlin e no prescription | Tadalafil Discount cards | Buy Tadalafil no script | Tadalafil by phone no script | Buy Tadalafil Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Tadalafil online without a prescription and no me mbership | Buy Without Prescription Tadalafil Online buy no prescription Ultra m | Order Tadalafil Cheap no membership fees no prescription | Tadalafil order n o script | Tadalafil lowest cost | online Buy Tadalafil | Overnight Tadalafil With out A Prescription Tadalafil Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Tadalafil Without A Prescription no script Tadalafil | Tadalafil Buy phone | Tadalafil paid with mastercard | Tadalafil With No Prescript ion Tadalafil to purchase | Order Tadalafil online with no prescription | Tadalafil Buying online Tadalafil drugs | Tadalafil free Overnight fedex delivery | Ultra m best online pharmacy | purchase Tadalafil without a prescription overnight d elivery | Buy Tadalafil online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Tadalafil From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Tadalafil next day | Where To Buy Tadalafil No Prescription No Fees Tadalafil ups cod | Order Tadalafil cash on delive ry | Tadalafil overnight shipping no prescription | purchase Tadalafil without p rescription online | Buy Tadalafil online without dr approval | Buy Tadalafil on line without dr approval | Tadalafil ups | Tadalafil Buy | Buy Tadalafil in Idaho | Tadalafil cheapest | Buy Tadalafil pay with mastercard | ordering Buy Tadalafil online | Tadalafil Overnight COD no prescription | Tadalafil order cod | Tadalafil No Prescription Tadalafil overnight delivery Cheap | Tadalafil order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Tadalafil usa online pharmacy | U ltram free consultation | how to Order Tadalafil without doctors | Purchase U ltram online | comprar Tadalafil | No Prescription Required For Tadalafil Tadalafil cod ordering | Cheap Tadalafil without prescription | Buy Cheap Tadalafil fast | Tadalafil Buy | Buy Tadalafil online without a prescription and no membership | Cheap Tadalafil without prescription overnight delivery | cash on delivery online prescriptions Tadalafil | Tadalafil with no prescription | ordering Ultra m online without a prescription | Tadalafil Cheap order | Tadalafil online no pr escription | No Prescription Needed Tadalafil Low Price Tadalafil With No Prescri ption Buy Tadalafil Online Without Prescription buy no prescription Tadalafil | B uy Tadalafil online discount | Tadalafil order cod | Order Cheap Tadalafil very Buy without prescription | Tadalafil cod next day delivery | Order Tadalafil Online Without Prescription Tadalafil free Overnight fedex delivery | Cheap Tadalafil b y money Order | Buy Tadalafil online discount | overnight Tadalafil | 8 Buy Ult ram online | Cheap Tadalafil c.o.d. | Buy Tadalafil Tablets Without Prescription Overnight Tadalafil for sale | Buy Tadalafil online sales | natural Tadalafil | U ltram manufacturer | Tadalafil Online No Prescription Tadalafil adiction | geniu ne Tadalafil no prescription | Tadalafil Pharmacy Cod Saturday Delivery With No P rescription Tadalafil Buy phone | Buy Tadalafil online prescription | Order Ultr am without prescription from us pharmacy | Buy real Tadalafil with mastercard | Tadalafil without a rx | doctor online prescription Tadalafil | Tadalafil Free O vernight Fedex Delivery order Tadalafil online cash on delivery | Cheap Tadalafil next day | Buy Tadalafil Cheap online us pharmacy | Tadalafil delivery to uk fe dex Overnight | Find Cheap Tadalafil no prescription | online pharmacy Tadalafil | Buy Tadalafil Online Without A Prescription And No Membership Tadalafil to pur chase | Tadalafil Same Day Delivery No Prescription Tadalafil by phone no script | Buy Tadalafil without | discount Tadalafil overnight | Buy Cheap Tadalafil, Buy Cheap Tadalafil online | Tadalafil Buy fedex | Tadalafil shipped with no prescripti on | Buy Tadalafil online money order | purchase Tadalafil without a prescriptio n | Tadalafil ups cod | Buy Tadalafil Online No Prescription Buy Tadalafil online | Tadalafil with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Tadalafil cod | how to get Tadalafil prescription | Low Price Tadalafil With No Prescription Buy the Cheapest Tadalafil online index | prescription U ltram | Order Tadalafil No Prescription Order Tadalafil medicine online without p rescription | Low Price Tadalafil Saturday Delivery No Prescription Cheap Ultr am overnight | Tadalafil Online No Prescription Tadalafil online cash on delivery | Fedex Tadalafil Without Prescription Buy Tadalafil online usa | Tadalafil for sa le without a prescription | to Buy Tadalafil without a prescription | Tadalafil Overnight no script mastercard accepted | Buy Cheap Tadalafil No Prescription Cheap Tadalafil free consultant | Buy Tadalafil Cheap online us pharmacy | Buy C heap Tadalafil No Prescription Tadalafil lowest cost | Where To Buy Tadalafil No Pre scription No Fees Cheapest Tadalafil Online Without Prescription cheapest Ultra m | Tadalafil amphetimine | Buy Tadalafil 120 tabs | Buy Tadalafil Without A Presc ription Or Membership Tadalafil Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Tadalafil | Tadalafil conversion | overnight Tadalafil ups cod | Buy Tadalafil online Cheap | Tadalafil No Script Required Express Delivery With No P rescription Tadalafil free consultation u.s. pharmacy | Tadalafil cod no script | Tadalafil ups cod | Tadalafil online no prescription | purchase Tadalafil with co d | Canadian Tadalafil Pills No Prescription Buy Tadalafil in North Carolina | buy Tadalafil in Denmark, buy Tadalafil in Egypt, buy Tadalafil in Israel, buy Tadalafil in Ireland, buy Tadalafil in Spain, buy Tadalafil in Italy, buy Tadalafil in Canada, buy Tadalafil in Cyprus, buy Tadalafil in Mexico, buy Tadalafil in Netherlands, buy Tadalafil in New zealand, buy Tadalafil in Kingston, buy Tadalafil in Australia, buy Tadalafil in AU, buy Tadalafil in New South Wales, buy Tadalafil in NSW, buy Tadalafil i n Sydney, buy Tadalafil in Brisbane, buy Tadalafil in South Australia, buy Tadalafil in Hobart, buy Tadalafil in the United states, buy Tadalafil in Finland, buy Ultra m in France, buy Tadalafil in Chekhiya, buy Tadalafil in Switzerland, buy Tadalafil i n Sweden, buy Tadalafil in Alberta, buy Tadalafil in Labrador, buy Tadalafil in Toron to, buy Tadalafil in Ottawa, buy Tadalafil in Mississauga, buy Tadalafil in Hamilton, buy Tadalafil in Brampton, buy Tadalafil in London, buy Tadalafil in Markham, buy Ul tram in Vaughan, buy Tadalafil in Windsor, buy Tadalafil in Kitchener, buy Tadalafil in Montreal, buy Tadalafil in Mauricie, buy Tadalafil in Vancouver, buy Tadalafil in Victoria, buy Tadalafil in Kelowna, buy Tadalafil in Abbotsford, buy Tadalafil in Kam loops, buy Tadalafil in Nanaimo, buy Tadalafil in Vernon, buy Tadalafil in Lethbridge , buy Tadalafil in United Kingdom, buy Tadalafil in England, buy Tadalafil in Wales, buy Tadalafil in Scotland, buy Tadalafil in Northern Ireland, buy Tadalafil in Belfas t, buy Tadalafil in Cardiff, buy Tadalafil in London, buy Tadalafil in Glasgow, buy U ltram in Liverpool, buy Tadalafil in Leeds, buy Tadalafil in Victoria, buy Tadalafil in Melbourne, buy Tadalafil in Western Australia, buy Tadalafil in Perth, buy Ultr am in Alabama, buy Tadalafil in Arizona, buy Tadalafil in Arkansas, buy Tadalafil in California, buy Tadalafil in Colorado, buy Tadalafil in Connecticut, buy Tadalafil in Delaware, buy Tadalafil in Florida, buy Tadalafil in Georgia, buy Tadalafil in Hawai i, buy Tadalafil in Idaho, buy Tadalafil in Illinois, buy Tadalafil in Indiana, buy U ltram in Iowa, buy Tadalafil in Kansas, buy Tadalafil in Kentucky, buy Tadalafil in L ouisiana, buy Tadalafil in Maine, buy Tadalafil in Montana, buy Tadalafil in Nebraska , buy Tadalafil in Nevada, buy Tadalafil in New Jersey, buy Tadalafil in New Mexico, buy Tadalafil in New York, buy Tadalafil in North Carolina, buy Tadalafil in North Da kota, buy Tadalafil in Ohio, buy Tadalafil in Oklahoma, buy Tadalafil in Texas, buy U ltram in Utah, buy Tadalafil in Vermont, buy Tadalafil in Virginia, buy Tadalafil in Washington, buy Tadalafil in West Virginia, buy Tadalafil in Wisconsin, buy Tadalafil in Wyoming, buy Tadalafil in Montgomery, buy Tadalafil in Juneau, buy Tadalafil in P hoenix, buy Tadalafil in Little Rock, buy Tadalafil in Sacramento, buy Tadalafil in D enver, buy Tadalafil in Hartford, buy Tadalafil in Dover, buy Tadalafil in Tallahasse e, buy Tadalafil in Atlanta, buy Tadalafil in Springfield, buy Tadalafil in Indianapo lis, buy Tadalafil in Des Moines, buy Tadalafil in Annapolis, buy Tadalafil in Boston , buy Tadalafil in Lansing, buy Tadalafil in Helena, buy Tadalafil in Lincoln, buy Ul tram in Santa Fe, buy Tadalafil in Albany, buy Tadalafil in Raleigh, buy Tadalafil in Bismarck, buy Tadalafil in Columbus, buy Tadalafil in Salem, buy Tadalafil in Columb ia, buy Tadalafil in Salt Lake City, buy Tadalafil in Montpelier, buy Tadalafil in Ch arleston, buy Tadalafil in Madison, buy Tadalafil in Cheyenne, buy Tadalafil in Austr alia, buy Tadalafil in Austria, buy Tadalafil in Argentina, buy Tadalafil in Belgium, buy Tadalafil in Bulgaria, buy Tadalafil in Brasilia, buy Tadalafil in Great britain , buy Tadalafil in Hungary, buy Tadalafil in Germany, buy Tadalafil in Greece, buy Ul tram in South Africa, buy Tadalafil in Japan From ethan at stoneleaf.us Thu Nov 10 13:43:32 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 10 Nov 2011 10:43:32 -0800 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4EBC1B54.6000308@stoneleaf.us> Devin Jeanpierre wrote: > Well. It reads fine in a certain sense, in that I can figure out > what's going on (although I have some troubles figuring out why the > heck certain things are in the code). The issue is that what's going > on is otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. Certainly it's a Python pattern -- it's what you do to dynamically generate code. > The use of exec also results in (seemingly) arbitrary constraints on > the input. Like, why can't "--" be a name? Because exec? Is there some > other reason? '--' not being allowed for a name has *nothing* to do with exec, and everything to do with `--` not being a valid Python identifier. > '--' is a valid attribute name on virtually any object that supports > attribute setting (e.g. function objects). Of course, you need to use > setattr() and getattr(). Is this really the reason, or is it a > limitation caused primarily by the usage of exec and the need to > prevent code injection? If somebody added this feature later on, would > this create a security vulnerability in certain projects that used > namedtuple in certain ways? So you think somevar = getattr(my_named_tuple, '--') is more readable than somevar = my_named_tuple.spam ? ~Ethan~ From tkpmep at hotmail.com Thu Nov 10 13:56:25 2011 From: tkpmep at hotmail.com (tkpmep at hotmail.com) Date: Thu, 10 Nov 2011 10:56:25 -0800 (PST) Subject: Working with databases (ODBC and ORMs) in Python 3.2 Message-ID: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> We are in the process of trying to decide between Python 2.7 and 3.2 with a view to making a 5-10 year commitment to the right platform, and would appreciate some guidance on how best to connect to SQL databases in 3.2. ceODBC 2.01 provides an ODBC driver for Python 3.2, does anyone have experience using it? Also, are there any ORMs (object relational mapper)s that work well with 3,2? Thanks in advance Thomas Philips From tjreedy at udel.edu Thu Nov 10 14:25:40 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Nov 2011 14:25:40 -0500 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/10/2011 3:51 AM, Devin Jeanpierre wrote: >> Because Python doesn't allow "--" to be an attribute name, and so >> namedtuple doesn't let you try: >> >> t = namedtuple("T", "foo -- bar")(1, 2, 3) >> print(t.foo) >> print(t.--) >> print(t.bar) > > '--' is a valid attribute name on virtually any object that supports > attribute setting (e.g. function objects). ob.-- is not valid Python because '--' is not a name. > Of course, you need to use setattr() and getattr(). I consider the fact that CPython's setattr accepts non-name strings to be a bit of a bug. Or if you will, leniency for speed. (A unicode name check in Py3 would be much more expensive than an ascii name check in Py2.) I would consider it legitimate for another implementation to only accept names and to use a specialized name_dict for attribute dictionaries. So I consider it quite legitimate for namedtuple to requires real names for the fields. The whole point is to allow ob.name access to tuple members. Someone who plans to use set/getattr with arbitrary strings should just use a dict instead of a tuple. -- Terry Jan Reedy From benjamin.kaplan at case.edu Thu Nov 10 14:32:24 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Thu, 10 Nov 2011 14:32:24 -0500 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <1320941348.7601.57.camel@tim-laptop> Message-ID: On Thu, Nov 10, 2011 at 1:06 PM, Jerry Zhang wrote: > > > I just did an example code to describe what i am looking for. > /*------------------------------------------------------------------------------------------------*/ > # ... > > class Head: > ??? def __init__(self): > ??????? self.size = 5 > > class Hat: > ??? def __init__(self): > ??????? self.color = red > ??? def took_on(self, body): > ??????? self.body = body > ??? def took_off(self, body): > ??????? del self.body > > class Body: > ??? def __init__(self): > ??????? self.head = Head() > ??? def take_on_hat(self, hat): > ??????? self.hat = hat > ??????? hat.take_on(self) > ??? def take_off_hat(self): > ??????? hat.take_off(self) > ??????? del self.hat > ??? def go_to_heaven(self): > ??????? take_off_hat(self) > ??????? del self.head > /*----------------------------------------------------------------------------------------------------------*/ > > In this example, Head and body are COMPOSITION, which means > a. A head only live with one body, it can not live with other body. It can > not even live without body > b. If the body go to die, the head also go to die. > > Body and Hat are aggregation, which means > a. A hat live isolate with body, its life circle is isolate > b. A hat only live with one body at a specific time, it can not live with > two body(association would be more than one) > > So when the body die, the clean dead should include take_off Hat and del > Head, otherwise, the code definition is not prciselly describing the > relationship, which may cause a mess system, for example, a body has dead, > but one hat is still associated with a unreferenced body. > A point on this issue, maybe python is smart that the take_off_hat(self) is > not needed in go_to_heaven() method(i am not sure yet), but the del > self.head is sure needed, otherwise, we will have a no_body_head in our > ZODB, that is extremely horrible, right? > > All of these points one, the four kinds of class relationship in UML > precisely describe the real word, if the implementation is not precisely, > you will have unexpected results. > Of course, python may be smart to achieve such goal with less effort, that > is why i am asking for a code example for all of the four relationships. You're still misunderstanding Python's object model. del does NOT delete an object. It deletes a name. The only way for an object to be deleted is for it to be inaccessible (there are no references to it, or there are no reachable references to it). >>> foo = object() >>> bar = foo >>> foo >>> bar >>> del foo >>> bar >>> foo Traceback (most recent call last): File "", line 1, in foo NameError: name 'foo' is not defined There is no way to force the go_to_heaven method to delete the head unless you can make sure that all other references to the head are weak references. If you need strictly-enforced relationships, Python is probably not the right language for the job- you'll be better off with C++ or Java. From brenNOSPAMbarn at NObrenSPAMbarn.net Thu Nov 10 14:35:29 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Thu, 10 Nov 2011 19:35:29 +0000 (UTC) Subject: all() is slow? References: <4ebafbb7$0$1724$742ec2ed@news.sonic.net> Message-ID: John Nagle wrote: > On 11/7/2011 1:00 PM, OKB (not okblacke) wrote: >> I noticed this (Python 2.6.5 on Windows XP): > > CPython is slow. It's a naive interpreter. There's > almost no optimization during compilation. Try PyPy > or Shed Skin. PyPy is interesting, but I use various libraries that make use of C extension modules. I'm not going to compile them all myself, which is apparently what I would need to do for PyPy. PyPy or other implementations won't work for me unless they're completely drop-in replacements for the interpreter. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From tjreedy at udel.edu Thu Nov 10 14:38:58 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Nov 2011 14:38:58 -0500 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: On 11/10/2011 9:31 AM, Jerry Zhang wrote: > Unfortunately there is a difference between composition and > aggregation in my real word, and my application really care this > since it is trying to simulate this real world model, so my system > should track this difference accurately, otherwise the system may > not work well. > > For example, > a. the Cls_arm and Cls_body may be composition, but not aggregation. > My app must ensure that " one arm instance only live with one body > instance, if the body instance die, the arm instance must die. Create the arm as a private member '_arm' of body and make sure that no method of body passes out a reference to the arm. (In Python, outside code can still grab a reference to the private attribute, but that is a coding bug.) I will point out that in the real world, dead donor transplants are based on the fact the parts of the body do NOT have to die when the composition does. I will not be surprised if we someday see arm transplants. -- Terry Jan Reedy From ethan at stoneleaf.us Thu Nov 10 15:31:23 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 10 Nov 2011 12:31:23 -0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <1320941348.7601.57.camel@tim-laptop> Message-ID: <4EBC349B.5030209@stoneleaf.us> Benjamin Kaplan wrote: > You're still misunderstanding Python's object model. del does NOT > delete an object. It deletes a name. The only way for an object to be > deleted is for it to be inaccessible (there are no references to it, > or there are no reachable references to it). >>>> foo = object() >>>> bar = foo >>>> foo > >>>> bar > >>>> del foo >>>> bar > >>>> foo > > Traceback (most recent call last): > File "", line 1, in > foo > NameError: name 'foo' is not defined > > > There is no way to force the go_to_heaven method to delete the head > unless you can make sure that all other references to the head are > weak references. If you need strictly-enforced relationships, Python > is probably not the right language for the job- you'll be better off > with C++ or Java. Having said all that, you could do something like: class BodyPart(object): _alive = True def __nonzero__(self): return self._alive def die(self): self._alive = False class Head(BodyPart): "will contain things like Brain, Eyes, etc" size = 5 class Body(BodyPart): def __init__(self): self._head = Head() def go_to_heaven(self): self._head.die() self.die() John_Doe = Body() if John_Doe: print "John Doe is alive!" John_Doe.go_to_heaven() if John_Doe: print "uh oh - something wrong" else: print "John Doe is no longer with us" print "and his head is %s" % ('alive' if John_Doe._head else 'dead') From nathan.alexander.rice at gmail.com Thu Nov 10 15:35:22 2011 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 10 Nov 2011 15:35:22 -0500 Subject: Working with databases (ODBC and ORMs) in Python 3.2 In-Reply-To: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> References: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> Message-ID: For now, get started in Python 2.7. Write code with an eye to 3.x portability, and you will be fine. You probably won't see 3.x overtake 2.x for at least 3-4 years, and a decent amount of stuff is still 2.x only. Since it sounds like you are a windows/net shop, go ahead and use Iron Python. SQL Alchemy is your one stop shop. It is basically 3.x compatible, but see my previous statement about 3.x. I haven't used SQL Alchemy with SQL Server but honestly, SQL Alchemy is THE showcase python library -- I doubt you will run into any issues. Just google "sqlalchemy sql server", I'm sure there's a blog post explaining the specifics in detail. Nathan On Thu, Nov 10, 2011 at 1:56 PM, tkpmep at hotmail.com wrote: > We are in the process of trying to decide between Python 2.7 and 3.2 > with a view to making a 5-10 year commitment to the right platform, > and would appreciate some guidance on how best to connect to SQL > databases in 3.2. ceODBC 2.01 provides an ODBC driver for Python 3.2, > does anyone have experience using it? Also, are there any ORMs (object > relational mapper)s that work well with 3,2? > > Thanks in advance > > Thomas Philips > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanpierreda at gmail.com Thu Nov 10 15:37:05 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 10 Nov 2011 15:37:05 -0500 Subject: all() is slow? In-Reply-To: <4EBC1B54.6000308@stoneleaf.us> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: > '--' not being allowed for a name has *nothing* to do with exec, and > everything to do with `--` not being a valid Python identifier. The only reason valid python identifiers come into it at all is because they get pasted into a string where identifiers would go, and that string is passed to exec(). So really, does it have "nothing" to do with exec? Or does your argument eventually boil down to the use of exec? > is more readable than Of course not. I do, however, think that it's conceivable that I'd want to key a namedtuple by an invalid identifier, and to do that, yes, I'd need to use getattr(). Devin On Thu, Nov 10, 2011 at 1:43 PM, Ethan Furman wrote: > Devin Jeanpierre wrote: >> >> Well. It reads fine in a certain sense, in that I can figure out >> what's going on (although I have some troubles figuring out why the >> heck certain things are in the code). The issue is that what's going >> on is otherworldly: this is not a Python pattern, this is not a normal >> approach. To me, that means it does not read fine. > > Certainly it's a Python pattern -- it's what you do to dynamically generate > code. > > >> The use of exec also results in (seemingly) arbitrary constraints on >> the input. Like, why can't "--" be a name? Because exec? Is there some >> other reason? > > '--' not being allowed for a name has *nothing* to do with exec, and > everything to do with `--` not being a valid Python identifier. > > >> '--' is a valid attribute name on virtually any object that supports >> attribute setting (e.g. function objects). Of course, you need to use >> setattr() and getattr(). Is this really the reason, or is it a >> limitation caused primarily by the usage of exec and the need to >> prevent code injection? If somebody added this feature later on, would >> this create a security vulnerability in certain projects that used >> namedtuple in certain ways? > > So you think > > ? ?somevar = getattr(my_named_tuple, '--') > > is more readable than > > ? ?somevar = my_named_tuple.spam > > ? > > ~Ethan~ > -- > http://mail.python.org/mailman/listinfo/python-list > From kwa at kuwata-lab.com Thu Nov 10 15:38:53 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Fri, 11 Nov 2011 05:38:53 +0900 Subject: easy_install doesn't install non-package *.py file In-Reply-To: <5611883.2927.1320916092038.JavaMail.geo-discussion-forums@yqni5> References: <5611883.2927.1320916092038.JavaMail.geo-discussion-forums@yqni5> Message-ID: On Thu, Nov 10, 2011 at 6:08 PM, Jonathan Hartley wrote: > Hey. I don't know the details, but your setup.py needs to use either the 'package_data' or the 'data_files' entry in the dict you pass to setup. These can specify files you want included in the sdist which aren't package files. > > There are many complications with using them though. One of them in particular (I don't remember which one) installs the files you specify in a different place depending on whether the user is installing the sdist from local files (python setup.py install) or using pip, so be sure to test both ways. 'package_data' is the solution for my trouble. Thank you very much, Jonathan. -- regards, makoto kuwata From ian.g.kelly at gmail.com Thu Nov 10 16:19:18 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 10 Nov 2011 14:19:18 -0700 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: On Thu, Nov 10, 2011 at 1:37 PM, Devin Jeanpierre wrote: > Of course not. I do, however, think that it's conceivable that I'd > want to key a namedtuple by an invalid identifier, and to do that, > yes, I'd need to use getattr(). Care to give a real use case? You could even go a step further and use, say, arbitrary ints as names if you're willing to give up getattr() and use "ob.__class__.__dict__[42].__get__(ob, ob.__class__)" everywhere instead. The fact that somebody might conceivably want to do this doesn't make it a good idea, though. I do find it a bit funny that you're criticizing a somewhat smelly implementation detail by complaining that it doesn't support an equally smelly feature. Cheers, Ian From ethan at stoneleaf.us Thu Nov 10 16:47:48 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 10 Nov 2011 13:47:48 -0800 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: <4EBC4684.8070308@stoneleaf.us> Devin Jeanpierre wrote: > The only reason valid python identifiers come into it at all is > because they get pasted into a string where identifiers would go, and > that string is passed to exec(). > > So really, does it have "nothing" to do with exec? Or does your > argument eventually boil down to the use of exec? As I recall the big reason for namedtuples was things like sys.version_info[1] # behind door number one is... being much more readable as sys.version_info.minor In other words, the tuple offsets are named -- hence, namedtuples. And only valid identifiers will work. So, no, it has nothing to do with 'exec', and everything to do with the problem namedtuple was designed to solve. ~Ethan~ From rowen at uw.edu Thu Nov 10 16:52:17 2011 From: rowen at uw.edu (Russell E. Owen) Date: Thu, 10 Nov 2011 13:52:17 -0800 Subject: Decorator question: prefer class, but only function works Message-ID: I am trying to write a decorator that times an instance method and writes the results to a class member variable. For example: def timeMethod(func): def wrapper(self, *args, **keyArgs): t1 = time.time() res = func(self, *args, **keyArgs) duration = time.time() - t1 self.timings[func.__name__] = duration return res return wrapper This works, but I'm not very happy with the way self.timings is obtained. I first tried to write this as a class (for readability), and this did NOT work: class timeMethod(object): def __init__(self, func): self.func = func def __call__(self, *args, **keyArgs): t1 = time.time() res = self.func(*args, **keyArgs) duration = time.time() - t1 args[0].timings.set(self.func.__name__, duration) return res In the first case the wrapper is called as an unbound function, so it works. But in the second case the wrapper is called as a bound method -- thus args[0] is not func's class instance, and I can't get to the timings attribute. Unfortunately they are both pretty ugly. Is there a cleaner way to access the the instance of which func is a member? I was very disappointed it was not available when timeMethod was called/instantiated. -- Russell From kwa at kuwata-lab.com Thu Nov 10 16:54:02 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Fri, 11 Nov 2011 06:54:02 +0900 Subject: [ANN] pyKook 0.7.1 - task automation tool for Python, similar to Rake or Ant Message-ID: I have released pyKook 0.7.1.http://pypi.python.org/pypi/Kook/http://www.kuwata-lab.com/kook/http://www.kuwata-lab.com/kook/pykook-users-guide.html pyKook is a task automation tool for Python, similar to Rake or Ant. Bugfix in this release---------------------- * Fixed to include 'kook/books/*.py' into .egg file --regads,makoto kuwata On Sat, Nov 5, 2011 at 3:06 PM, Makoto Kuwata wrote: > Hi, > > I have released pyKook 0.7.0. > http://pypi.python.org/pypi/Kook/ > http://www.kuwata-lab.com/kook/ > http://www.kuwata-lab.com/kook/pykook-users-guide.html > > In this release, you can run commands on remote machines using ssh. > This is very useful to deploy your application. > > > pyKook Overview > --------------- > > pyKook is a task automation tool for Python, similar to Rake or Ant. > > (Kookbook.py): > > ? ?kookbook.default = 'build' > > ? ?## task > ? ?@recipe(None, ['hello']) > ? ?def build(c): > ? ? ? ?"""build all""" > ? ? ? ?pass > > ? ?## file > ? ?@recipe('hello', ['hello.o']) > ? ?def file_hello(c): > ? ? ? ?"""build 'hello' from 'hello.o'""" > ? ? ? ?system(c%'gcc -o $(product) $(ingred)') > > ? ?## rule > ? ?@recipe('*.o', ['$(1).c', '$(1).h']) > ? ?def file_o(c): > ? ? ? ?system(c%'gcc -c $(ingred)') > > > Command-line: > > ? ?bash> kk ? ? # or pykook > ? ?$ gcc -c hello.c > ? ?### *** hello.o (recipe=file_o) > ? ?$ gcc -c hello.c > ? ?### ** hello (recipe=file_hello) > ? ?$ gcc -o hello hello.o > ? ?### * build (recipe=build) > > See http://www.kuwata-lab.com/kook/pykook-users-guide.html for details. > > > Enhancements in this release > ---------------------------- > > * (EXPERIMENTAL!!) Remote command execution (ssh and sftp) is available. > ?This is very useful to deploy your application into servers. > > ?Ex (Kookbook.py):: > > ? ? ? ?from kook.remote import Remote > ? ? ? ?remote = Remote( > ? ? ? ? ? ?hosts ? ?= ['www1', 'www2', 'user3 at www3:10022'], > ? ? ? ? ? ?port ? ? = 22, > ? ? ? ? ? ?user ? ? = 'user1', > ? ? ? ? ? ?#password = None, ? ? ?# for login, '~/.ssh/id_rsa' and sudo > ? ? ? ? ? ?passphrase = None, ? ? # only for '~/.ssh/id_rsa' > ? ? ? ? ? ?sudo_password = 'xxx', # only for sudo command > ? ? ? ?) > > ? ? ? ?@recipe > ? ? ? ?@remotes(remote) > ? ? ? ?def hostinfo(c): > ? ? ? ? ? ?"""show hostname""" > ? ? ? ? ? ?ssh = c.ssh > ? ? ? ? ? ?ssh('hostname') ? ? ? ?# run command with ssh > ? ? ? ? ? ?ssh('whomai') ? ? ? ? ?# run command with ssh > ? ? ? ? ? ?ssh.sudo('whoami') ? ? # run command with sudo > > ? ? ? ?@recipe > ? ? ? ?@remotes(remote) > ? ? ? ?def exchange(c): > ? ? ? ? ? ?"""upload and download files""" > ? ? ? ? ? ?ssh = c.ssh > ? ? ? ? ? ?with ssh.pushd('work/apps'): > ? ? ? ? ? ? ? ?ssh.get('file.remote') ? ?# download a file > ? ? ? ? ? ? ? ?ssh.put('file.local') ? ? # upload a file > ? ? ? ? ? ? ? ?ssh.mget('remote.*') ? ? ?# download files > ? ? ? ? ? ? ? ?ssh.mput('local.*') ? ? ? # upload files > > ?Notice that you must configure ssh at first and confirm that > ?you can log into servers without typing password:: > > ? ? ? ?bash> ssh user1 at www1 > ? ? ? ?bash> ssh user1 at www2 > ? ? ? ?bash> ssh -p 10022 user3 at www3 > ? ? ? ?bash> kk hostinfo > ? ? ? ?### * showinfo (recipe=showinfo) > ? ? ? ?[user1 at www1]$ hostame > ? ? ? ?www1 > ? ? ? ?[user1 at www1]$ whoami > ? ? ? ?user1 > ? ? ? ?[user1 at www1]$ sudo whoami > ? ? ? ?root > ? ? ? ?[user2 at www2]$ hostame > ? ? ? ?www2 > ? ? ? ?[user2 at www2]$ whoami > ? ? ? ?user2 > ? ? ? ?[user2 at www2]$ sudo whoami > ? ? ? ?root > ? ? ? ?[user3 at www3]$ hostame > ? ? ? ?www3 > ? ? ? ?[user3 at www3]$ whami > ? ? ? ?user3 > ? ? ? ?[user3 at www3]$ sudo whoami > ? ? ? ?root > > ?Currently commands are executed sequencially (not in parallel). > > * (EXPERIMENTAL!!) Password object supported. > ?Password object asks you to enter password in prompt when necessary. > > ?Ex (Kookbook.py):: > > ? ? ? ?from kook.remote import Remote, Password > ? ? ? ?remote = Remote( > ? ? ? ? ? ?hosts ? ? ? ? = ['user1 at www1:22'], > ? ? ? ? ? ?#password ? ? = Password('login'), > ? ? ? ? ? ?passphrase ? ?= Password('~/.ssh/id_rsa'), > ? ? ? ? ? ?sudo_password = Password('sudo command') > ? ? ? ?) > ? ? ? ?# > ? ? ? ?@recipe > ? ? ? ?@remotes(remote) > ? ? ? ?def remote_test(c): > ? ? ? ? ? ?ssh = c.ssh > ? ? ? ? ? ?ssh.sudo('whoami') > > ?Output example:: > > ? ? ? ?bash> kk remote_test > ? ? ? ?### * remote_test (recipe=remote_test) > ? ? ? ?Password for ~/.ssh/id_rsa: > ? ? ? ?Password for sudo command: > ? ? ? ?[user1 at www1]$ sudo whoami > ? ? ? ?root > > ?It is easy to share password object. > > ?Ex (Kookbook.py):: > > ? ? ? ?from kook.remote import Remote, Password > ? ? ? ?passwd = Password() > ? ? ? ?remote = Remote( > ? ? ? ? ? ?hosts ? ? ? ? = ['user1 at www1:22'], > ? ? ? ? ? ?password ? ? ?= passwd, > ? ? ? ? ? ?passphrase ? ?= passwd, > ? ? ? ? ? ?sudo_password = passwd, > ? ? ? ?) > > > Changes in this release > ----------------------- > > * Category class is changed to convers all instance methods into staticmethods. > > ?Ex (Kookbook.py): > > ? ? ? ?class apache(Category): > ? ? ? ? ? ?@recipe > ? ? ? ? ? ?def start(c): > ? ? ? ? ? ? ? system('apachectl start') > > ? ? ? ?## start() is converted into staticmethod > ? ? ? ?assert type(apache.__dict__['start']) == staticmethod > ? ? ? ?from types import FunctionType > ? ? ? ?assert type(apache.start) == FuntionType > > ?This makes execution of other recipes in category easier:: > > ? ? ? ?class apache(Category): > ? ? ? ? ? ?@recipe > ? ? ? ? ? ?def start(c): > ? ? ? ? ? ? ? ... > ? ? ? ? ? ?@recipe > ? ? ? ? ? ?def stop(c): > ? ? ? ? ? ? ? ... > ? ? ? ? ? ?@recipe > ? ? ? ? ? ?def restart(c): > ? ? ? ? ? ? ? apache.start(c) ? ?# execute other recipe > ? ? ? ? ? ? ? apache.stop(c) ? ? # execute other recipe > > * (internal) kook.config.stdout and kook.config.stderr are removed. > > > > See http://www.kuwata-lab.com/kook/pykook-CHANGES.txt for details. > > > Have fun! > > -- > regards, > makoto kuwata > From ian.g.kelly at gmail.com Thu Nov 10 17:35:14 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 10 Nov 2011 15:35:14 -0700 Subject: Decorator question: prefer class, but only function works In-Reply-To: References: Message-ID: On Thu, Nov 10, 2011 at 2:52 PM, Russell E. Owen wrote: > I am trying to write a decorator that times an instance method and > writes the results to a class member variable. For example: > > def timeMethod(func): > ? ?def wrapper(self, *args, **keyArgs): > ? ? ? ?t1 = time.time() > ? ? ? ?res = func(self, *args, **keyArgs) > ? ? ? ?duration = time.time() - t1 > ? ? ? ?self.timings[func.__name__] = duration > ? ? ? ?return res > ? ?return wrapper > > This works, but I'm not very happy with the way self.timings is obtained. What do you feel is wrong with it? You probably should use sum(os.times()[:2]) instead, which (assuming your script is single-threaded) will more accurately count the actual CPU time spent in the function rather than real time, which could be quite different if the CPU is busy. Also, why do you need this? If you're just trying to evaluate the speed of your code, you should consider using a proper profiler or the timeit module. The former will tell you how much time is spent in each function, while the latter runs the code a large number of times in a loop, which gives you better precision for quick methods. > I first tried to write this as a class (for readability), and this did > NOT work: > > class timeMethod(object): > ? ?def __init__(self, func): > ? ? ? ?self.func = func > ? ?def __call__(self, *args, **keyArgs): > ? ? ? ?t1 = time.time() > ? ? ? ?res = self.func(*args, **keyArgs) > ? ? ? ?duration = time.time() - t1 > ? ? ? ?args[0].timings.set(self.func.__name__, duration) > ? ? ? ?return res > > In the first case the wrapper is called as an unbound function, so it > works. But in the second case the wrapper is called as a bound method -- > thus args[0] is not func's class instance, and I can't get to the > timings attribute. I prefer the function version myself, but to make this work you could add something like this (untested) to make your wrapper class a descriptor that tacks on the self argument: def __get__(self, instance, owner): from functools import partial if instance is None: return self return partial(self, instance) HTH, Ian From cra5370 at g.rit.edu Thu Nov 10 17:40:18 2011 From: cra5370 at g.rit.edu (CAMERON ALLEY) Date: Thu, 10 Nov 2011 14:40:18 -0800 (PST) Subject: No matter what I do, IDLE will not work... Message-ID: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Lemme preface this post by saying the following - I've taken my computer to the local IT office on RIT campus, asked a Computer Science professor specializing in Python, and posted my question on answers.yahoo.com (I don't know why I expected that to work...). I've also googled my problem multiple times and have not come up with anything newer than about 4 years ago. Okay, so the problem. I tried to install Python 2.7 about two months ago on both my laptop and iMac. Both are running up-to-date Mac OS X 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My laptop installed python 2.7 and ran it perfectly, first time. My desktop... not so much. How to recreate the issue on iMac - try to open IDLE, or in terminal, type the following: python import turtle turtle.up() This is what's displayed in terminal: COMPUTERNAME:~ USER$ python Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import turtle >>> turtle.up() CGColor with 1 components Abort trap COMPUTERNAME:~ USER$ It also pops up a Problem Report for Python Python quit unexpectedly. Click Reopen to open the application again. This report will be sent to Apple automatically. Problem Details and System Configuration Process: Python [33535] Path: /Library/Frameworks/Python.framework/Versions/2.7/ Resources/Python.app/Contents/MacOS/Python Identifier: org.python.python Version: 2.7.2 (2.7.2) Code Type: X86-64 (Native) Parent Process: bash [33532] Date/Time: 2011-11-10 17:31:58.424 -0500 OS Version: Mac OS X 10.6.8 (10K549) Report Version: 6 Interval Since Last Report: 1141508 sec Crashes Since Last Report: 2 Per-App Interval Since Last Report: 2 sec Per-App Crashes Since Last Report: 2 Anonymous UUID: C667A2E4-5530-4A3E-B6E3- B38E970458E5 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Application Specific Information: abort() called Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 libSystem.B.dylib 0x00007fff89bd40b6 __kill + 10 1 libSystem.B.dylib 0x00007fff89c749f6 abort + 83 2 Tcl 0x000000010067f9ef Tcl_Panic + 0 3 Tcl 0x000000010067fa91 Tcl_Panic + 162 4 Tk 0x00000001010ac5a7 TkpGetColor + 383 5 Tk 0x00000001010b9a2a TkpMenuInit + 156 6 Tk 0x000000010103c36c TkMenuInit + 88 7 Tk 0x00000001010bc68b - [TKApplication(TKMenus) _setupMenus] + 53 8 Tk 0x00000001010b6d27 - [TKApplication(TKInit) _setup:] + 56 9 Tk 0x00000001010b7260 TkpInit + 545 10 Tk 0x000000010102da26 Initialize + 1678 11 _tkinter.so 0x00000001005fccfb Tcl_AppInit + 75 12 _tkinter.so 0x00000001005fa153 Tkinter_Create + 915 13 org.python.python 0x00000001000c102d PyEval_EvalFrameEx + 22397 14 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 15 org.python.python 0x000000010003da80 function_call + 176 16 org.python.python 0x000000010000c5e2 PyObject_Call + 98 17 org.python.python 0x000000010001ebcb instancemethod_call + 363 18 org.python.python 0x000000010000c5e2 PyObject_Call + 98 19 org.python.python 0x00000001000be5f3 PyEval_EvalFrameEx + 11587 20 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 21 org.python.python 0x000000010003da80 function_call + 176 22 org.python.python 0x000000010000c5e2 PyObject_Call + 98 23 org.python.python 0x000000010001ebcb instancemethod_call + 363 24 org.python.python 0x000000010000c5e2 PyObject_Call + 98 25 org.python.python 0x00000001000ba5f7 PyEval_CallObjectWithKeywords + 87 26 org.python.python 0x0000000100021e5e PyInstance_New + 126 27 org.python.python 0x000000010000c5e2 PyObject_Call + 98 28 org.python.python 0x00000001000be5f3 PyEval_EvalFrameEx + 11587 29 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 30 org.python.python 0x000000010003da80 function_call + 176 31 org.python.python 0x000000010000c5e2 PyObject_Call + 98 32 org.python.python 0x000000010001ebcb instancemethod_call + 363 33 org.python.python 0x000000010000c5e2 PyObject_Call + 98 34 org.python.python 0x0000000100077a68 slot_tp_init + 88 35 org.python.python 0x0000000100074e65 type_call + 245 36 org.python.python 0x000000010000c5e2 PyObject_Call + 98 37 org.python.python 0x00000001000be5f3 PyEval_EvalFrameEx + 11587 38 org.python.python 0x00000001000c1ebe PyEval_EvalFrameEx + 26126 39 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 40 org.python.python 0x000000010003da80 function_call + 176 41 org.python.python 0x000000010000c5e2 PyObject_Call + 98 42 org.python.python 0x000000010001ebcb instancemethod_call + 363 43 org.python.python 0x000000010000c5e2 PyObject_Call + 98 44 org.python.python 0x0000000100077a68 slot_tp_init + 88 45 org.python.python 0x0000000100074e65 type_call + 245 46 org.python.python 0x000000010000c5e2 PyObject_Call + 98 47 org.python.python 0x00000001000be5f3 PyEval_EvalFrameEx + 11587 48 org.python.python 0x00000001000c1ebe PyEval_EvalFrameEx + 26126 49 org.python.python 0x00000001000c1ebe PyEval_EvalFrameEx + 26126 50 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 51 org.python.python 0x00000001000c2e46 PyEval_EvalCode + 54 52 org.python.python 0x00000001000e769c PyRun_InteractiveOneFlags + 380 53 org.python.python 0x00000001000e78fe PyRun_InteractiveLoopFlags + 78 54 org.python.python 0x00000001000e80e1 PyRun_AnyFileExFlags + 161 55 org.python.python 0x00000001000fe77c Py_Main + 2940 56 org.python.python 0x0000000100000f14 0x100000000 + 3860 Thread 1: Dispatch queue: com.apple.libdispatch-manager 0 libSystem.B.dylib 0x00007fff89b9ec0a kevent + 10 1 libSystem.B.dylib 0x00007fff89ba0add _dispatch_mgr_invoke + 154 2 libSystem.B.dylib 0x00007fff89ba07b4 _dispatch_queue_invoke + 185 3 libSystem.B.dylib 0x00007fff89ba02de _dispatch_worker_thread2 + 252 4 libSystem.B.dylib 0x00007fff89b9fc08 _pthread_wqthread + 353 5 libSystem.B.dylib 0x00007fff89b9faa5 start_wqthread + 13 Thread 2: 0 libSystem.B.dylib 0x00007fff89b9fa2a __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff89b9fe3c _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff89b9faa5 start_wqthread + 13 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000000000000 rbx: 0x00007fff7116b2f8 rcx: 0x00007fff5fbfc0e8 rdx: 0x0000000000000000 rdi: 0x00000000000082ff rsi: 0x0000000000000006 rbp: 0x00007fff5fbfc100 rsp: 0x00007fff5fbfc0e8 r8: 0x00007fff7116ea60 r9: 0x0000000000000000 r10: 0x00007fff89bd00fa r11: 0x0000000000000206 r12: 0x00000001006ecb20 r13: 0x0000000000000001 r14: 0x00000001010e1f77 r15: 0x0000000000000000 rip: 0x00007fff89bd40b6 rfl: 0x0000000000000206 cr2: 0x00000001135b54f3 ............... ............... ............... Model: iMac7,1, BootROM IM71.007A.B03, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.20f4 Graphics: ATI Radeon HD 2600 Pro, ATI,RadeonHD2600, PCIe, 256 MB Memory Module: global_name AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x88), Broadcom BCM43xx 1.0 (5.10.131.42.4) Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports Network Service: Built-in Ethernet, Ethernet, en0 Network Service: AirPort, AirPort, en1 Serial ATA Device: WDC WD3200AAJS-40RYA0, 298.09 GB Parallel ATA Device: OPTIARC DVD RW AD-5630A, 406.7 MB USB Device: Built-in iSight, 0x05ac (Apple Inc.), 0x8502, 0xfd400000 / 2 USB Device: Bluetooth USB Host Controller, 0x05ac (Apple Inc.), 0x8206, 0x1a100000 / 2 USB Device: Razer Naga, 0x1532, 0x0015, 0x1d100000 / 2 USB Device: IR Receiver, 0x05ac (Apple Inc.), 0x8242, 0x5d100000 / 2 I have tried copying every framework possible from the laptop to the iMac, done several reinstalls, and pretty much everything else I and the IT people on campus could think of to no avail. I'm pretty close to paying 20-30 bucks for a call to Apple and ask for help, because I'm tired of programming on a 13-inch screen while my 20-inch desktop is sitting right next to me just playing pandora... P.S. To those who might say "just use your imac as another monitor!" I can't. I've already asked Apple about that - the iMac is too old. HELP!!! From steve+comp.lang.python at pearwood.info Thu Nov 10 17:48:51 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 22:48:51 GMT Subject: The python implementation of the "relationships between classes". References: Message-ID: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Nov 2011 14:38:58 -0500, Terry Reedy wrote: > I will point out that in the real world, dead donor transplants are > based on the fact the parts of the body do NOT have to die when the > composition does. I will not be surprised if we someday see arm > transplants. And Guido's Time Machine strikes again... not only have there been arm transplants, but the first DOUBLE arm transplant was three years ago: http://www.dailymail.co.uk/health/article-1039587/Worlds-double-arm-transplant-man-gets-teenagers-limbs.html There have been successful *face* transplants. Nothing will surprise me now until they do a brain or head transplant. -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 10 17:56:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 22:56:41 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: <4ebc56a9$0$29970$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Nov 2011 14:19:18 -0700, Ian Kelly wrote: > On Thu, Nov 10, 2011 at 1:37 PM, Devin Jeanpierre > wrote: >> Of course not. I do, however, think that it's conceivable that I'd want >> to key a namedtuple by an invalid identifier, and to do that, yes, I'd >> need to use getattr(). > > Care to give a real use case? A common use-case is for accessing fields from an external data source, using the same field names. For example, you might have a database with a field called "class", or a CSV file with columns "0-10", "11-20", etc. Personally, I wouldn't bother using attributes to access fields, I'd use a dict, but some people think it's important to use attribute access. > You could even go a step further and use, > say, arbitrary ints as names if you're willing to give up getattr() and > use "ob.__class__.__dict__[42].__get__(ob, ob.__class__)" everywhere > instead. The fact that somebody might conceivably want to do this > doesn't make it a good idea, though. Obviously you would write a helper function rather than repeat that mess in-line everywhere. -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 10 18:07:23 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 23:07:23 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Nov 2011 15:37:05 -0500, Devin Jeanpierre wrote: >> '--' not being allowed for a name has *nothing* to do with exec, and >> everything to do with `--` not being a valid Python identifier. > > The only reason valid python identifiers come into it at all is because > they get pasted into a string where identifiers would go, and that > string is passed to exec(). That is patently untrue. If you were implementing namedtuple without exec, you would still (or at least you *should*) prevent the user from passing invalid identifiers as attribute names. What's the point of allowing attribute names you can't actually *use* as attribute names? You could remove the validation, allowing users to pass invalid field names, but that would be a lousy API. If you want field names that aren't valid identifiers, the right solution is a dict, not attributes. Here's a re-implementation using a metaclass: http://pastebin.com/AkG1gbGC and a diff from the Python bug tracker removing exec from namedtuple: http://bugs.python.org/file11608/new_namedtuples.diff You will notice both of them keep the field name validation. -- Steven From gordon at panix.com Thu Nov 10 18:11:23 2011 From: gordon at panix.com (John Gordon) Date: Thu, 10 Nov 2011 23:11:23 +0000 (UTC) Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: In <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df at e3g2000vbs.googlegroups.com> CAMERON ALLEY writes: > Okay, so the problem. I tried to install Python 2.7 about two months > ago on both my laptop and iMac. Both are running up-to-date Mac OS X > 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My > laptop installed python 2.7 and ran it perfectly, first time. My > desktop... not so much. IDLE is a separate program from Python itself, right? It's a GUI, or an IDE, or a shell or something. (Your session output doesn't seem to involve IDLE at all, so I am wondering why you mentioned it.) By typing "python" on your desktop, are you running plain Python, or are you running IDLE? Did you install Python and IDLE on the desktop machine separately? Did both installations succeed? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From ckaynor at zindagigames.com Thu Nov 10 18:14:23 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 10 Nov 2011 15:14:23 -0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 10, 2011 at 2:48 PM, Steven D'Aprano wrote: > On Thu, 10 Nov 2011 14:38:58 -0500, Terry Reedy wrote: > >> I will point out that in the real world, dead donor transplants are >> based on the fact the parts of the body do NOT have to die when the >> composition does. I will not be surprised if we someday see arm >> transplants. > > And Guido's Time Machine strikes again... not only have there been arm > transplants, but the first DOUBLE arm transplant was three years ago: > > http://www.dailymail.co.uk/health/article-1039587/Worlds-double-arm-transplant-man-gets-teenagers-limbs.html > > > There have been successful *face* transplants. Nothing will surprise me > now until they do a brain or head transplant. > Continuing this OT discussion, would it be a brain transplant, or a full body transplant? > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From cra5370 at g.rit.edu Thu Nov 10 18:27:49 2011 From: cra5370 at g.rit.edu (CAMERON ALLEY) Date: Thu, 10 Nov 2011 15:27:49 -0800 (PST) Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: <10a05a56-bd2a-4036-963a-b003453f58a9@cc2g2000vbb.googlegroups.com> On Nov 10, 6:11?pm, John Gordon wrote: > In <3c2688bd-4f87-4eb1-9b40-3cb536a2d... at e3g2000vbs.googlegroups.com> CAMERON ALLEY writes: > > > Okay, so the problem. I tried to install Python 2.7 about two months > > ago on both my laptop and iMac. Both are running up-to-date Mac OS X > > 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My > > laptop installed python 2.7 and ran it perfectly, first time. My > > desktop... not so much. > > IDLE is a separate program from Python itself, right? ?It's a GUI, or an > IDE, or a shell or something. > > (Your session output doesn't seem to involve IDLE at all, so I am > wondering why you mentioned it.) > > By typing "python" on your desktop, are you running plain Python, or > are you running IDLE? > > Did you install Python and IDLE on the desktop machine separately? > Did both installations succeed? > > -- > John Gordon ? ? ? ? ? ? ? ? ? A is for Amy, who fell down the stairs > gor... at panix.com ? ? ? ? ? ? ?B is for Basil, assaulted by bears > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -- Edward Gorey, "The Gashlycrumb Tinies" Thanks for the prompt response - yes, IDLE is a seperate program from python, however included in the Python 2.7.2 folder when downloaded from python.org. It's an IDE. I mentioned it, because when I try to open it, I also get an error report, so I figured it wouldn't be coincidence. I'm not typing "python" on my desktop, I'm typing it in terminal with no change of default directory. It runs plain python THROUGH terminal, and when I import turtle, and call turtle.up() it should in theory display an image of whatever I asked turtle to draw (in this case nothing, but the window should still pop up.) I installed two things on the desktop - python2.7.2 from python.org and the respective ActiveTK. Both succeeded. From rosuav at gmail.com Thu Nov 10 18:39:12 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Nov 2011 10:39:12 +1100 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor wrote: > Continuing this OT discussion, would it be a brain transplant, or a > full body transplant? It's just a rebinding. You don't move the body, you just bind your name to a new body. It's perfectly legal to have two names bound to one body (cf Dr Jekyll and Mr Hyde); if you murder Mr Hyde, you can still access the body through the other name. ChrisA From tjreedy at udel.edu Thu Nov 10 18:45:06 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Nov 2011 18:45:06 -0500 Subject: No matter what I do, IDLE will not work... In-Reply-To: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: On 11/10/2011 5:40 PM, CAMERON ALLEY wrote: > Okay, so the problem. I tried to install Python 2.7 about two months > ago on both my laptop and iMac. Both are running up-to-date Mac OS X > 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My > laptop installed python 2.7 and ran it perfectly, first time. My > desktop... not so much. You issue has nothing to do with IDLE and perhaps all to do with the buggy tcl/tk that comes with OSX 10.6. The Python module tkinter is the tk interface for Python (hence the name). The turtle module and IDLE both use tkinter. Searching all tracker issues (open and closed) for 'max tcl' turns up (among several others) http://bugs.python.org/issue10907 http://bugs.python.org/issue10969 http://bugs.python.org/issue12269 The latter 2, especially, might tell you what to do. -- Terry Jan Reedy From nad at acm.org Thu Nov 10 19:27:33 2011 From: nad at acm.org (Ned Deily) Date: Thu, 10 Nov 2011 16:27:33 -0800 Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: In article <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df at e3g2000vbs.googlegroups.com>, CAMERON ALLEY wrote: > Lemme preface this post by saying the following - I've taken my > computer to the local IT office on RIT campus, asked a Computer > Science professor specializing in Python, and posted my question on > answers.yahoo.com (I don't know why I expected that to work...). I've > also googled my problem multiple times and have not come up with > anything newer than about 4 years ago. > > Okay, so the problem. I tried to install Python 2.7 about two months > ago on both my laptop and iMac. Both are running up-to-date Mac OS X > 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My > laptop installed python 2.7 and ran it perfectly, first time. My > desktop... not so much. > > How to recreate the issue on iMac - try to open IDLE, or in terminal, > type the following: > python > import turtle > turtle.up() > > This is what's displayed in terminal: > > COMPUTERNAME:~ USER$ python > Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import turtle > >>> turtle.up() > CGColor with 1 components > Abort trap > COMPUTERNAME:~ USER$ That's an odd one; I've not seen a crash like that before. From the crash dump, it is clear that the crash is happening inside of Tk, not Python, and, judging from the symbol names, it has something to do with menu initialization and colors. Try running the same Turtle test using the Apple-supplied Python 2.6 /usr/bin/python2.6 The Apple-supplied Tcl/Tk that it uses is known to have a number of serious problems and should not be used for serious work but, for me, it will bring up the turtle window in Tk without crashing. If it crashes the same way that 2.7.2 does, then that would be pretty solid corroboration that the problem is not in Python and more likely an issue with Tk. My first question would be do you have some third-party OS X app or extension installed that alters or colors menus? I know there used to be some popular ones out there in the past. If not, try opening System Preferences, select Displays, select Color, and check which display profile is selected. Perhaps try selecting another. And are you using a specific language in System Preferences -> Languages & Text -> Language? If that doesn't help, try running the following commands in a terminal window: source /Library/Frameworks/Tk.framework/Versions/8.5/tkConfig.sh echo $TK_VERSION $TK_PATCH_LEVEL You should see something like: 8.5 .11 If not, double check that you really are using the latest ActiveState Tcl/Tk 8.5 installer from here: http://www.activestate.com/activetcl/downloads Then try the failing turtle commads again and in the crash report, verify that /Library/Frameworks/Tk.framework/Versions/8.5/ appear as framework paths and *not* /System/Library/Frameworks/Tk.framework/Versions/8.5/. Try the following command which may not work if you don't have Xcode tools installed: otool -L $(python2.7 -c 'import _tkinter; print(_tkinter.__file__)') The paths reported again should start with /Library/Frameworks/Tk.framework and not /System/Library/Frameworks/Tk.framework. If none of that works, you could try installing the other python.org 2.7.2 installer, the 32-bit-only one, which is linked to the older Tcl/Tk 8.4, which uses Carbon interfaces rather than Cocoa, and see what happens with it. In any case, please report back what you find and, if necessary, open an issue on the Python bug tracker: http://bugs.python.org/ Thanks! -- Ned Deily, nad at acm.org From gagou7 at gmail.com Thu Nov 10 19:49:05 2011 From: gagou7 at gmail.com (Gagou Final Fantasy) Date: Thu, 10 Nov 2011 16:49:05 -0800 (PST) Subject: Solution Message-ID: A common problem when you generate executable on Windows 7 and deploy on Windows XP. According with the py2exe tutorial, you need include the MVC DLL. But the tutorial is old and the script given search only in one directory. Before, the directory contained all DLL and the manifest, but nowadays it contains only the DLL. You need to specify another directory for the manifest file. If you don't do that, you will have this kind of error: "this application has failed to start because the application configuration is incorrect" If you are on Windows 7 64 bits, you need the Microsoft Visual C runtime DLL. Don't forget the manifest that isn't in the same directory in Windows 7. You need to adapt the script like this: data_files = [("VC90", glob(r'C:\Windows\winsxs \x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\*.*')), ("VC90", glob(r'C:\Windows\winsxs\Manifests \x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest')) ] setup( data_files=data_files, console = [{'script': "C:\test\my_program.py"}], zipfile = None, ) Now you can deploy the "dist" directory that contains all files and dependencies. From jerry.scofield at gmail.com Thu Nov 10 20:30:41 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 09:30:41 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <1320941348.7601.57.camel@tim-laptop> Message-ID: 2011/11/11 Benjamin Kaplan > On Thu, Nov 10, 2011 at 1:06 PM, Jerry Zhang > wrote: > > > > > > I just did an example code to describe what i am looking for. > > > /*------------------------------------------------------------------------------------------------*/ > > # ... > > > > class Head: > > def __init__(self): > > self.size = 5 > > > > class Hat: > > def __init__(self): > > self.color = red > > def took_on(self, body): > > self.body = body > > def took_off(self, body): > > del self.body > > > > class Body: > > def __init__(self): > > self.head = Head() > > def take_on_hat(self, hat): > > self.hat = hat > > hat.take_on(self) > > def take_off_hat(self): > > hat.take_off(self) > > del self.hat > > def go_to_heaven(self): > > take_off_hat(self) > > del self.head > > > /*----------------------------------------------------------------------------------------------------------*/ > > > > In this example, Head and body are COMPOSITION, which means > > a. A head only live with one body, it can not live with other body. It > can > > not even live without body > > b. If the body go to die, the head also go to die. > > > > Body and Hat are aggregation, which means > > a. A hat live isolate with body, its life circle is isolate > > b. A hat only live with one body at a specific time, it can not live with > > two body(association would be more than one) > > > > So when the body die, the clean dead should include take_off Hat and del > > Head, otherwise, the code definition is not prciselly describing the > > relationship, which may cause a mess system, for example, a body has > dead, > > but one hat is still associated with a unreferenced body. > > A point on this issue, maybe python is smart that the take_off_hat(self) > is > > not needed in go_to_heaven() method(i am not sure yet), but the del > > self.head is sure needed, otherwise, we will have a no_body_head in our > > ZODB, that is extremely horrible, right? > > > > All of these points one, the four kinds of class relationship in UML > > precisely describe the real word, if the implementation is not precisely, > > you will have unexpected results. > > Of course, python may be smart to achieve such goal with less effort, > that > > is why i am asking for a code example for all of the four relationships. > > You're still misunderstanding Python's object model. del does NOT > delete an object. It deletes a name. The only way for an object to be > deleted is for it to be inaccessible (there are no references to it, > or there are no reachable references to it). > >>> foo = object() > >>> bar = foo > >>> foo > > >>> bar > > >>> del foo > >>> bar > > >>> foo > > Traceback (most recent call last): > File "", line 1, in > foo > NameError: name 'foo' is not defined > > > There is no way to force the go_to_heaven method to delete the head > unless you can make sure that all other references to the head are > weak references. If you need strictly-enforced relationships, Python > is probably not the right language for the job- you'll be better off > with C++ or Java. > Thanks for your reply, but i know your point on this before post this issue. "doing the the job of python's garbage collecting" system is not i want. What i am trying to do is a python implementation of the real "composition implementation". > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 20:34:30 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 09:34:30 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: 2011/11/11 Terry Reedy > On 11/10/2011 9:31 AM, Jerry Zhang wrote: > > Unfortunately there is a difference between composition and >> aggregation in my real word, and my application really care this >> since it is trying to simulate this real world model, so my system >> should track this difference accurately, otherwise the system may >> not work well. >> >> For example, >> a. the Cls_arm and Cls_body may be composition, but not aggregation. >> My app must ensure that " one arm instance only live with one body >> instance, if the body instance die, the arm instance must die. >> > > Create the arm as a private member '_arm' of body and make sure that no > method of body passes out a reference to the arm. (In Python, outside code > can still grab a reference to the private attribute, but that is a coding > bug.) > > I will point out that in the real world, dead donor transplants are based > on the fact the parts of the body do NOT have to die when the composition > does. I will not be surprised if we someday see arm transplants. Thanks for your comment. Actually you are mixing the concept. That is aggregation implementation, which also points out there is difference between aggregation and composition implementation. You already know that. > > > -- > Terry Jan Reedy > > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 20:43:33 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 09:43:33 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: 2011/11/11 Chris Angelico > On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor > wrote: > > Continuing this OT discussion, would it be a brain transplant, or a > > full body transplant? > > It's just a rebinding. You don't move the body, you just bind your > name to a new body. It's perfectly legal to have two names bound to > one body (cf Dr Jekyll and Mr Hyde); if you murder Mr Hyde, you can > still access the body through the other name. > > This is association, not aggregation or composition. You already realized that there is difference between these relationship(depending on your application requirement). and you are trying to tell me to code a aggregation and the composition with the same code. > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 20:54:22 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 09:54:22 +0800 Subject: Working with databases (ODBC and ORMs) in Python 3.2 In-Reply-To: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> References: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> Message-ID: 2011/11/11 tkpmep at hotmail.com > We are in the process of trying to decide between Python 2.7 and 3.2 > with a view to making a 5-10 year commitment to the right platform, > and would appreciate some guidance on how best to connect to SQL > databases in 3.2. ceODBC 2.01 provides an ODBC driver for Python 3.2, > does anyone have experience using it? Also, are there any ORMs (object > relational mapper)s that work well with 3,2? > I am in the similar situation as you. I abandon the MySQL + python3.x solution, since translate between fields of tables(SQL table) and objects attributes is destroying my OOP world. I choose the ZODB + python2.x solution, python3.x does not support ZODB yet. > > Thanks in advance > > Thomas Philips > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 21:42:45 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 10:42:45 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: A general description of my issue. To my understand, python's feature such as "name-reference-object" and "garbage collection" system did some of work for you, it makes your life easier, but you still need to add your explicit application in your code. For example, Composition implementation: you may need to do 5 job with C++, but only 2 job with python, the other 3 job is done by python implicitly. association implementation: You need 3 job with C++, but 1 with python. it seems python's object's lifecycle handling has reached this level, all you should do is just "associating and de-association". Here is exactly of my question, for composition, the best code may be you do 2 job explicitly, 3 job done by python implicitly. Code_Zero. 1 job(by you) + 4(by python) does NOT work. Code_one. 2 job(by you) + 3(by python) works. That is the best one. Code_two. 3 job( by you) + 2 (by python) works too, Code_three. 4 job(by you) + 1(by python) works too. Since i am not familiar with python yet, my code most likely would gets into Code_two or Code_three(Code_Zero is also possible for new guys like me), though they also work, they are bad code. What i am looking for is the Code_one example, i thought many OOP application designer may have met this issue, so a good Code_one reference is the best choice to start this project. 2011/11/11 Jerry Zhang > > > 2011/11/11 Chris Angelico > >> On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor >> wrote: >> > Continuing this OT discussion, would it be a brain transplant, or a >> > full body transplant? >> >> It's just a rebinding. You don't move the body, you just bind your >> name to a new body. It's perfectly legal to have two names bound to >> one body (cf Dr Jekyll and Mr Hyde); if you murder Mr Hyde, you can >> still access the body through the other name. >> >> This is association, not aggregation or composition. You already realized > that there is difference between these relationship(depending on your > application requirement). and you are trying to tell me to code a > aggregation and the composition with the same code. > > > >> ChrisA >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From laurent.payot at gmail.com Thu Nov 10 23:03:05 2011 From: laurent.payot at gmail.com (Laurent) Date: Thu, 10 Nov 2011 20:03:05 -0800 (PST) Subject: property decorator and inheritance Message-ID: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> Hi. I couldn't find a way to overwrite a property declared using a decorator in a parent class. I can only do this if I use the "classic" property() method along with a getter function. Here's an example: #!/usr/bin/python3 class Polite: def __init__(self): self._greeting = "Hello" def get_greeting(self, suffix=", my dear."): return self._greeting + suffix greeting1 = property(get_greeting) @property def greeting2(self, suffix=", my dear."): return self._greeting + suffix class Rude(Polite): @property def greeting1(self): return self.get_greeting(suffix=", stupid.") @property def greeting2(self): return super().greeting2(suffix=", stupid.") p = Polite() r = Rude() print("p.greeting1 =", p.greeting1) print("p.greeting2 =", p.greeting2) print("r.greeting1 =", r.greeting1) print("r.greeting2 =", r.greeting2) # TypeError: 'str' object is not callable In this example I can easily overwrite the greeting1 property. But the inherited greeting2 doesn't seem to be a property but a mere string. I use a lot of properties decorators for simple properties in a project and I hate mixing them with a couple of "undecorated" properties that have to be overwritten in child classes. I tried using @greeting2.getter decorator and tricks like this but inheritance overwriting failed every time I used decorators. Can someone tell me a way to use decorator-declared properties that can be overwritten in child classes?? That would be nice. From cra5370 at g.rit.edu Thu Nov 10 23:25:55 2011 From: cra5370 at g.rit.edu (CAMERON ALLEY) Date: Thu, 10 Nov 2011 20:25:55 -0800 (PST) Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: <960bb3e9-a1b4-4495-9334-e1a35f9b40f5@e3g2000vbs.googlegroups.com> On Nov 10, 7:27?pm, Ned Deily wrote: > That's an odd one; I've not seen a crash like that before. ?From the > crash dump, it is clear that the crash is happening inside of Tk, not > Python, and, judging from the symbol names, it has something to do with > menu initialization and colors. > > Try running the same Turtle test using the Apple-supplied Python 2.6 > > ? /usr/bin/python2.6 > > The Apple-supplied Tcl/Tk that it uses is known to have a number of > serious problems and should not be used for serious work but, for me, it > will bring up the turtle window in Tk without crashing. ?If it crashes > the same way that 2.7.2 does, then that would be pretty solid > corroboration that the problem is not in Python and more likely an issue > with Tk. > > My first question would be do you have some third-party OS X app or > extension installed that alters or colors menus? ?I know there used to > be some popular ones out there in the past. ?If not, try opening System > Preferences, select Displays, select Color, and check which display > profile is selected. ?Perhaps try selecting another. ?And are you using > a specific language in System Preferences -> Languages & Text -> > Language? > > If that doesn't help, try running the following commands in a terminal > window: > > ? source /Library/Frameworks/Tk.framework/Versions/8.5/tkConfig.sh > ? echo $TK_VERSION $TK_PATCH_LEVEL > > You should see something like: > > ? 8.5 .11 > > If not, double check that you really are using the latest ActiveState > Tcl/Tk 8.5 installer from here: > > ?http://www.activestate.com/activetcl/downloads > > Then try the failing turtle commads again and in the crash report, > verify that ?/Library/Frameworks/Tk.framework/Versions/8.5/ appear as > framework paths and *not* > /System/Library/Frameworks/Tk.framework/Versions/8.5/. > > Try the following command which may not work if you don't have Xcode > tools installed: > > ? otool -L $(python2.7 -c 'import _tkinter; print(_tkinter.__file__)') > > The paths reported again should start with > /Library/Frameworks/Tk.framework and not > /System/Library/Frameworks/Tk.framework. > > If none of that works, you could try installing the other python.org > 2.7.2 installer, the 32-bit-only one, which is linked to the older > Tcl/Tk 8.4, which uses Carbon interfaces rather than Cocoa, and see what > happens with it. > > In any case, please report back what you find and, if necessary, open an > issue on the Python bug tracker: > ?http://bugs.python.org/ > > Thanks! > > -- > ?Ned Deily, > ?n... at acm.org Thanks so much for your incredibly in-depth response Ned! I've tried everything you've suggested and here's what I've found: The error occurs with the old python as well, but this MIGHT be because at some point during my many attempts at fixing this issue I could have deleted an old tk framework. It's funny you mention the theming - before snow leapord, I had leapord installed and used magnifique to theme my computer. I then upgraded to snow leapord and (like a novice) tried to use magnifique again only to find it crashed my system because it's not compatible with snow leapord. I did a reinstall of the OS though, and everything was fine. (this was about 2 years ago). I also recently installed Crystal Black on here, however I've been having this issue since before that. Other than that, no specific theming or color changing schemes come to mind... Oh actually there is something called Nocturne I used to use... Not sure if any of these could be affecting this. There's only one color profile, and no bizarre language being used. When I typed that in terminal, I saw 8.5.11 - this was the recommended activestate by python.org. Should I get 8.5.11? I tried the failing turtle commands, and in the crash report /Library/ Frameworks/Tk.framework/Versions/8.5/ only appears once (when doing a cmd+f search) and does not have /System/ in front of it. I'm going to try installing the 32 bit 2.7.2 installer next, and I'll be back to let you know how it goes. Thanks a lot! Cameron From jeanpierreda at gmail.com Thu Nov 10 23:35:32 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 10 Nov 2011 23:35:32 -0500 Subject: all() is slow? In-Reply-To: <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: > You will notice both of them keep the field name validation. There are lots of reasons for that to be the case. To me, the most likely one just seems to be that you don't want to remove more than necessary when changing the way something works under the hood -- both for compatibility reasons, and because you want the patch to get accepted and want the least number of objectionable changes. I guess you disagree. > That is patently untrue. If you were implementing namedtuple without > exec, you would still (or at least you *should*) prevent the user from > passing invalid identifiers as attribute names. What's the point of > allowing attribute names you can't actually *use* as attribute names? Then why doesn't Python do this anywhere else? e.g. why can I setattr(obj, 'a#b') when obj is any other mutable type? I just don't believe this reasoning is what happened, I suppose. And there's no way for you to convince me, or me to convince you, without R. Hettinger stepping in here and verifying one side of the story. This is subjective supposition, and that was supposed to be my most objective opposition. To go off on another tangent, though, I don't really understand how you guys can think this is reasonable, though. I don't get this philosophy of restricting inputs that would otherwise be perfectly valid, just for concerns that you have that users might not share -- especially when it's valid everywhere else that the concept shows up. It seems totally inconsistent with the attitude expressed above (by you!) towards exec, which is that it's ok to be cautious of something, but something else to forbid it outright. Of course, as I said before, I don't agree with core python developers on lots of things. I guess this is just another thing I just don't understand. Devin On Thu, Nov 10, 2011 at 6:07 PM, Steven D'Aprano wrote: > On Thu, 10 Nov 2011 15:37:05 -0500, Devin Jeanpierre wrote: > >>> '--' not being allowed for a name has *nothing* to do with exec, and >>> everything to do with `--` not being a valid Python identifier. >> >> The only reason valid python identifiers come into it at all is because >> they get pasted into a string where identifiers would go, and that >> string is passed to exec(). > > That is patently untrue. If you were implementing namedtuple without > exec, you would still (or at least you *should*) prevent the user from > passing invalid identifiers as attribute names. What's the point of > allowing attribute names you can't actually *use* as attribute names? > > You could remove the validation, allowing users to pass invalid field > names, but that would be a lousy API. If you want field names that aren't > valid identifiers, the right solution is a dict, not attributes. > > Here's a re-implementation using a metaclass: > > http://pastebin.com/AkG1gbGC > > and a diff from the Python bug tracker removing exec from namedtuple: > > http://bugs.python.org/file11608/new_namedtuples.diff > > > You will notice both of them keep the field name validation. > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From cra5370 at g.rit.edu Thu Nov 10 23:38:28 2011 From: cra5370 at g.rit.edu (CAMERON ALLEY) Date: Thu, 10 Nov 2011 20:38:28 -0800 (PST) Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> <960bb3e9-a1b4-4495-9334-e1a35f9b40f5@e3g2000vbs.googlegroups.com> Message-ID: <415ed0ec-65a5-41df-b81e-d74786c74073@s5g2000vbe.googlegroups.com> IT WORKS!!!! I didn't change my activestate, but I downloaded python 3.2.2 with the 32 bit installer and it works! Perfectally!! Sir you're my savior, thank you so much. I don't know how you did it but you just made my day :) Thanks again From wuwei23 at gmail.com Thu Nov 10 23:43:30 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 10 Nov 2011 20:43:30 -0800 (PST) Subject: property decorator and inheritance References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> Message-ID: On Nov 11, 2:03?pm, Laurent wrote: > Hi. I couldn't find a way to overwrite a property declared using a decorator in a parent class. > class Polite: > ? ? @property > ? ? def greeting2(self, suffix=", my dear."): > ? ? ? ? return self._greeting + suffix Here you set up greeting2 as a property. > class Rude(Polite): > ? ? @property > ? ? def greeting2(self): > ? ? ? ? return super().greeting2(suffix=", stupid.") Here you call Polite.greeting2 as a function. > print("r.greeting2 =", r.greeting2) # TypeError: 'str' object is not callable And here it's telling you that you're trying to treat a string - the output of Polite.greeting2 - as a function. The problem isn't that you cannot override greeting2 on Rude, it's that you can't treat properties as functions, so you can't pass in a new suffix. Instead, break the suffix out as a class attribute, then each descendent just needs to override that attribute: class Polite(object): suffix = ', my dear' @property def greeting(self): return 'Hello' + self.suffix class Rude(Polite): suffix = ', stupid' From laurent.payot at gmail.com Fri Nov 11 00:17:11 2011 From: laurent.payot at gmail.com (Laurent) Date: Thu, 10 Nov 2011 21:17:11 -0800 (PST) Subject: property decorator and inheritance In-Reply-To: References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> Message-ID: <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Yes using a separate class variable would transfer the problem to the class level. But adding 10 class variables if I have 10 properties would be ugly. Maybe I should reformulate the subject of this thread to "is there some python magic to pass parameters to decorator-declared properties ?" From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Nov 11 00:40:09 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Fri, 11 Nov 2011 05:40:09 +0000 (UTC) Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: Devin Jeanpierre wrote: >> '--' not being allowed for a name has *nothing* to do with exec, and >> everything to do with `--` not being a valid Python identifier. > > The only reason valid python identifiers come into it at all is > because they get pasted into a string where identifiers would go, and > that string is passed to exec(). The whole point of named tuples is to be able to access the members via attribute access as in "obj.attr". Things like "obj.--" are not valid Python syntax, so you can't use "--" as the name of a namedtuple field. Yes, you can do "getattr(obj, '--')" if you want, but it's quite reasonable for namedtuple to refrain from catering to that sort of perverse usage. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Nov 11 00:54:50 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Fri, 11 Nov 2011 05:54:50 +0000 (UTC) Subject: property decorator and inheritance References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Message-ID: Laurent wrote: > Yes using a separate class variable would transfer the problem to > the class level. But adding 10 class variables if I have 10 > properties would be ugly. Maybe I should reformulate the subject of > this thread to "is there some python magic to pass parameters to > decorator-declared properties ?" You can't have it both ways. If you want myObj.greeting2 # No parentheses To evaluate to a string (which it will if it's a property as you set it up), then it is necessarily true that myObj.greeting2(somearg) is going to try to call that string, which isn't going to work. If you need to be able to pass in parameters, then you need greeting2 to be a real method, not a property, and you need to get the greeting string with myObj.greeting2() # Parentheses All this is as it should be. The whole point of properties is that outside functions accessing them don't "know" that a getter function is called behind the scenes. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From clp2 at rebertia.com Fri Nov 11 00:58:21 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 10 Nov 2011 21:58:21 -0800 Subject: property decorator and inheritance In-Reply-To: <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Message-ID: On Thu, Nov 10, 2011 at 9:17 PM, Laurent wrote: > Yes using a separate class variable would transfer the problem to the class level. But adding 10 class variables if I have 10 properties would be ugly. Maybe I should reformulate the subject of this thread to "is there some python magic to pass parameters to decorator-declared properties ?" Apparently, yes: >>> class Foo(object): ... @property ... def bar(self, arg1='baz', arg2='qux'): ... return arg1, arg2 ... >>> Foo.bar.fget(Foo(), 'spam', 'eggs') ('spam', 'eggs') >>> Though I do not like this trick at all. Cheers, Chris -- http://rebertia.com From nad at acm.org Fri Nov 11 01:51:29 2011 From: nad at acm.org (Ned Deily) Date: Thu, 10 Nov 2011 22:51:29 -0800 Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> <960bb3e9-a1b4-4495-9334-e1a35f9b40f5@e3g2000vbs.googlegroups.com> <415ed0ec-65a5-41df-b81e-d74786c74073@s5g2000vbe.googlegroups.com> Message-ID: In article <415ed0ec-65a5-41df-b81e-d74786c74073 at s5g2000vbe.googlegroups.com>, CAMERON ALLEY wrote: > IT WORKS!!!! I didn't change my activestate, but I downloaded python > 3.2.2 with the 32 bit installer and it works! Perfectally!! > > Sir you're my savior, thank you so much. > > I don't know how you did it but you just made my day :) The 32-bit-installer links to the older Carbon-based Tcl/Tk 8.4 which is very different under the covers from the Tcl/Tk 8.5 used by the Apple-supplied Pythons and the python.org 64-bit installer. So there's *something* on your system that interferes with the Cocoa Tcl/Tk 8.5. If you want to pursue it, you might ask on the OS X Tcl mailing list. Good luck! http://dir.gmane.org/gmane.comp.lang.tcl.mac -- Ned Deily, nad at acm.org From laurent.payot at gmail.com Fri Nov 11 04:41:39 2011 From: laurent.payot at gmail.com (Laurent) Date: Fri, 11 Nov 2011 01:41:39 -0800 (PST) Subject: property decorator and inheritance In-Reply-To: References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <1571989.1239.1321004499667.JavaMail.geo-discussion-forums@yqpp12> Hey yes it's working that way. But I don't like it very much either. If as OKB said the whole point is that outside functions can't detect a property then I'm going to stick with the non-decorator way. Thanks anyway. From laurent.payot at gmail.com Fri Nov 11 04:41:39 2011 From: laurent.payot at gmail.com (Laurent) Date: Fri, 11 Nov 2011 01:41:39 -0800 (PST) Subject: property decorator and inheritance In-Reply-To: References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <1571989.1239.1321004499667.JavaMail.geo-discussion-forums@yqpp12> Hey yes it's working that way. But I don't like it very much either. If as OKB said the whole point is that outside functions can't detect a property then I'm going to stick with the non-decorator way. Thanks anyway. From ss27051980 at gmail.com Fri Nov 11 06:23:08 2011 From: ss27051980 at gmail.com (Suresh Sharma) Date: Fri, 11 Nov 2011 16:53:08 +0530 Subject: No matter what I do, IDLE will not work... Message-ID: <14bljwe7ffx67yysd6rfhxr9.1321010588320@email.android.com> Hello all, I need to know how to connect python 3.2 with mysql db i am newbie and appreciate your help to enhance my skills. I googled a lot but nothing came up Ned Deily wrote: >In article ><415ed0ec-65a5-41df-b81e-d74786c74073 at s5g2000vbe.googlegroups.com>, > CAMERON ALLEY wrote: >> IT WORKS!!!! I didn't change my activestate, but I downloaded python >> 3.2.2 with the 32 bit installer and it works! Perfectally!! >> >> Sir you're my savior, thank you so much. >> >> I don't know how you did it but you just made my day :) > >The 32-bit-installer links to the older Carbon-based Tcl/Tk 8.4 which is >very different under the covers from the Tcl/Tk 8.5 used by the >Apple-supplied Pythons and the python.org 64-bit installer. So there's >*something* on your system that interferes with the Cocoa Tcl/Tk 8.5. >If you want to pursue it, you might ask on the OS X Tcl mailing list. >Good luck! > >http://dir.gmane.org/gmane.comp.lang.tcl.mac > >-- > Ned Deily, > nad at acm.org > >-- >http://mail.python.org/mailman/listinfo/python-list From moura.mario at gmail.com Fri Nov 11 08:31:35 2011 From: moura.mario at gmail.com (macm) Date: Fri, 11 Nov 2011 05:31:35 -0800 (PST) Subject: Get keys from a dicionary Message-ID: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Hi Folks I pass a nested dictionary to a function. def Dicty( dict[k1][k2] ): print k1 print k2 There is a fast way (trick) to get k1 and k2 as string. Whithout loop all dict. Just it! Regards macm From joncle at googlemail.com Fri Nov 11 11:09:30 2011 From: joncle at googlemail.com (Jon Clements) Date: Fri, 11 Nov 2011 08:09:30 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> On Nov 11, 1:31?pm, macm wrote: > Hi Folks > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > ? ? ? ? print k1 > ? ? ? ? print k2 > > There is a fast way (trick) to get k1 and k2 as string. > > Whithout loop all dict. Just it! > > Regards > > macm I've tried to understand this, but can't tell if it's a question or statement, and even then can't tell what the question or statement is... Care to eloborate? From gordon at panix.com Fri Nov 11 11:25:19 2011 From: gordon at panix.com (John Gordon) Date: Fri, 11 Nov 2011 16:25:19 +0000 (UTC) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: In <8f5215a8-d08f-4355-a5a2-77fcaa32c92d at j10g2000vbe.googlegroups.com> macm writes: > I pass a nested dictionary to a function. > def Dicty( dict[k1][k2] ): That's not valid syntax. > print k1 > print k2 > There is a fast way (trick) to get k1 and k2 as string. Are you stating this can be done, or are you asking if it can be done? Questions usually end with a question mark. (Are you a native English speaker?) > Whithout loop all dict. Just it! print "%s" % x -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From moura.mario at gmail.com Fri Nov 11 11:33:27 2011 From: moura.mario at gmail.com (macm) Date: Fri, 11 Nov 2011 08:33:27 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> Message-ID: Hi Sorry ! My mistake. >>> myDict = {} >>> myDict['foo'] = {} >>> myDict['foo']['bar'] = 'works' ----- >>> def myFunction( MyObj ): ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] ['bar']) ... # I want inspect this MyObj ... # what keys was pass ... print MyObj.keys() ## WRONG ... # So What I want is : ... # return foo bar ---------------- >>> result = myFunction( myDict['foo']['bar'] ) >>> result Should print : ... foo bar Best Regards macm On Nov 11, 2:09?pm, Jon Clements wrote: > On Nov 11, 1:31?pm, macm wrote: > > > Hi Folks > > > I pass a nested dictionary to a function. > > > def Dicty( dict[k1][k2] ): > > ? ? ? ? print k1 > > ? ? ? ? print k2 > > > There is a fast way (trick) to get k1 and k2 as string. > > > Whithout loop all dict. Just it! > > > Regards > > > macm > > I've tried to understand this, but can't tell if it's a question or > statement, and even then can't tell what the question or statement > is... > > Care to eloborate? From moura.mario at gmail.com Fri Nov 11 11:36:55 2011 From: moura.mario at gmail.com (macm) Date: Fri, 11 Nov 2011 08:36:55 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: <09bf2935-00e6-4ecb-a5fe-71566155f995@q16g2000yqn.googlegroups.com> On Nov 11, 2:25?pm, John Gordon wrote: > In <8f5215a8-d08f-4355-a5a2-77fcaa32c... at j10g2000vbe.googlegroups.com> macm writes: > > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > > That's not valid syntax. > > > ? ?print k1 > > ? ?print k2 > > There is a fast way (trick) to get k1 and k2 as string. > > Are you stating this can be done, or are you asking if it can be done? > Questions usually end with a question mark. ?(Are you a native English > speaker?) > > > Whithout loop all dict. Just it! > > print "%s" % x > > -- > John Gordon ? ? ? ? ? ? ? ? ? A is for Amy, who fell down the stairs > gor... at panix.com ? ? ? ? ? ? ?B is for Basil, assaulted by bears > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -- Edward Gorey, "The Gashlycrumb Tinies" Hi John I am not a native English speaker. Sorry bad english. Regards macm From moura.mario at gmail.com Fri Nov 11 11:38:41 2011 From: moura.mario at gmail.com (macm) Date: Fri, 11 Nov 2011 08:38:41 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> Message-ID: Ok Sorry!! Sorry the noise!! def func(object): print "%s" % object Regards On Nov 11, 2:33?pm, macm wrote: > Hi > > Sorry ! My mistake. > > >>> myDict = {} > >>> myDict['foo'] = {} > >>> myDict['foo']['bar'] = 'works' > > ----- > > >>> def myFunction( MyObj ): > > ... ? ? # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] > ['bar']) > ... ? ? # I want inspect this MyObj > ... ? ? # what keys was pass > ... ? ? print MyObj.keys() ## WRONG > ... ? ? # So What I want is : > ... ? ? # return foo bar > > ---------------- > > >>> result = myFunction( myDict['foo']['bar'] ) > >>> result > > Should print : > > ... foo bar > > Best Regards > > macm > > On Nov 11, 2:09?pm, Jon Clements wrote: > > > > > > > > > On Nov 11, 1:31?pm, macm wrote: > > > > Hi Folks > > > > I pass a nested dictionary to a function. > > > > def Dicty( dict[k1][k2] ): > > > ? ? ? ? print k1 > > > ? ? ? ? print k2 > > > > There is a fast way (trick) to get k1 and k2 as string. > > > > Whithout loop all dict. Just it! > > > > Regards > > > > macm > > > I've tried to understand this, but can't tell if it's a question or > > statement, and even then can't tell what the question or statement > > is... > > > Care to eloborate? From d at davea.name Fri Nov 11 11:47:21 2011 From: d at davea.name (Dave Angel) Date: Fri, 11 Nov 2011 11:47:21 -0500 Subject: Get keys from a dicionary In-Reply-To: References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> Message-ID: <4EBD5199.3010507@davea.name> On 11/11/2011 11:33 AM, macm wrote: > Hi > > Sorry ! My mistake. > >>>> myDict = {} >>>> myDict['foo'] = {} >>>> myDict['foo']['bar'] = 'works' > ----- > >>>> def myFunction( MyObj ): > ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] > ['bar']) No, it's not. It's a string "works". There's no dictionary passed to myFunction(), so it cannot do what you ask, slow or fast. There are games you can play with introspection, but they are neither portable nor reliable. > ... # I want inspect this MyObj > ... # what keys was pass > ... print MyObj.keys() ## WRONG > ... # So What I want is : > ... # return foo bar > > ---------------- > >>>> result = myFunction( myDict['foo']['bar'] ) >>>> result > Should print : > > ... foo bar > > Best Regards > > macm Can you tell us the exact assignment, to see whether this is supposed to be a practical question, or a way to try to learn more about Python internals. -- DaveA From robin at reportlab.com Fri Nov 11 11:52:25 2011 From: robin at reportlab.com (Robin Becker) Date: Fri, 11 Nov 2011 16:52:25 +0000 Subject: bug python2.3+zipimport+ubuntu 10.04 amd_64 Message-ID: <4EBD52C9.7000408@chamonix.reportlab.co.uk> I'm trying to run some aged software on a new machine which runs Linux app2.reportlab.com 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC 2011 x86_64 GNU/Linux Ubuntu 10.04.2 LTS The software is required to use python 2.3 so first I've had some problems building python itself. Apparently to get rid of segfaults during the build we need the configure args to include BASECFLAGS=-U_FORTIFY_SOURCE that certainly fixes the python build errors. Now when we come to run the aged application we get this $ ./xxx.cgi Traceback (most recent call last): File "/home/rptlab/website/develop.reportlab.com/cgi-bin/xxx.cgi", line 7, in ? from fastwebapp import FastWebApp OverflowError: signed integer is greater than maximum this appears to be related to the use of a zip import. > sys.path.insert(0,os.path.join(os.getcwd(),"fastapp.zip")) > from fastwebapp import FastWebApp if we unpack the zip and remove the path insert the application appears to run fine. Googling appears to indicate that others have seen this error but on a different hardware and trying to remove optimizations from the python build has had variable success. Anyone had any real success with this problem? The last version of the test machinery ran 32bit freebsd and we had no problems on that hardware. -- Robin Becker From gordon at panix.com Fri Nov 11 12:28:52 2011 From: gordon at panix.com (John Gordon) Date: Fri, 11 Nov 2011 17:28:52 +0000 (UTC) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> Message-ID: In macm writes: > >>> myDict = {} > >>> myDict['foo'] = {} > >>> myDict['foo']['bar'] = 'works' > ----- > >>> def myFunction( MyObj ): > ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] > ['bar']) > ... # I want inspect this MyObj > ... # what keys was pass > ... print MyObj.keys() ## WRONG > ... # So What I want is : > ... # return foo bar > ---------------- > >>> result = myFunction( myDict['foo']['bar'] ) > >>> result > Should print : > ... foo bar I don't think there's a simple way to do what you want. You could inspect the whole dictionary to find the keys that map to a given value, like so: def MyFunction(mydict, x): for k1 in mydict: for k2 in mydict[k1]: if mydict[k1][k2] == x: return "%s %s" % (k1, k2) >>> print MyFunction(myDict, 'works') >>> foo bar -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From gelonida at gmail.com Fri Nov 11 12:29:59 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 18:29:59 +0100 Subject: Get keys from a dicionary In-Reply-To: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: On 11/11/2011 02:31 PM, macm wrote: > Hi Folks > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > print k1 > print k2 > > There is a fast way (trick) to get k1 and k2 as string. > > Whithout loop all dict. Just it! > > Regards > > macm I think the answer to the question, that I don't really understand is: No. This cannot be done. However we might help you if you copy a COMPLETE standalone example of your problem and if you try to re-explain once more what exactly you want to do. Ideally tell us even why you want to do it. Perhaps the solution is something completely different. Below I'm doing some guess work: nesteddict = { 'a': { 'A' : 'value1 a_A' , 'B' : 'value2 a_B' }, 'b': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, 'c': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, } def mymagic_function(value): print 'the value is <%s>', value print('There is really no way knowing from where this value came\n' 'except if you tell me in which dictionary you are supposed\n' 'and if I just try to find all matches\n' ) value = nesteddict['a']['B'] mymagic_function(value) From robin at reportlab.com Fri Nov 11 12:44:22 2011 From: robin at reportlab.com (Robin Becker) Date: Fri, 11 Nov 2011 17:44:22 +0000 Subject: bug python2.3+zipimport+ubuntu 10.04 amd_64 In-Reply-To: <4EBD52C9.7000408@chamonix.reportlab.co.uk> References: <4EBD52C9.7000408@chamonix.reportlab.co.uk> Message-ID: <4EBD5EF6.3040203@chamonix.reportlab.co.uk> OK it seems there's a bug in zipimport.c that was fixed in 2.4. I copied across the 2.4 version and after removing a single new error check the rebuilt python 2.3 works fine. There was supposed to be a patch here http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/zipimport.c?r1=1.16&r2=1.17 but it's a dead link. -- Robin Becker On 11/11/2011 16:52, Robin Becker wrote: > I'm trying to run some aged software on a new machine which runs > > Linux app2.reportlab.com 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC > 2011 x86_64 GNU/Linux Ubuntu 10.04.2 LTS > > The software is required to use python 2.3 so first I've had some problems > building python itself. Apparently to get rid of segfaults during the build we > need the configure args to include > > BASECFLAGS=-U_FORTIFY_SOURCE > > that certainly fixes the python build errors. > > Now when we come to run the aged application we get this > > $ ./xxx.cgi > Traceback (most recent call last): > File "/home/rptlab/website/develop.reportlab.com/cgi-bin/xxx.cgi", line 7, in ? > from fastwebapp import FastWebApp > OverflowError: signed integer is greater than maximum > > > this appears to be related to the use of a zip import. > > > sys.path.insert(0,os.path.join(os.getcwd(),"fastapp.zip")) > > from fastwebapp import FastWebApp > > if we unpack the zip and remove the path insert the application appears to run > fine. > > Googling appears to indicate that others have seen this error but on a different > hardware and trying to remove optimizations from the python build has had > variable success. > > Anyone had any real success with this problem? The last version of the test > machinery ran 32bit freebsd and we had no problems on that hardware. From robin at reportlab.com Fri Nov 11 12:44:22 2011 From: robin at reportlab.com (Robin Becker) Date: Fri, 11 Nov 2011 17:44:22 +0000 Subject: bug python2.3+zipimport+ubuntu 10.04 amd_64 In-Reply-To: <4EBD52C9.7000408@chamonix.reportlab.co.uk> References: <4EBD52C9.7000408@chamonix.reportlab.co.uk> Message-ID: <4EBD5EF6.3040203@chamonix.reportlab.co.uk> OK it seems there's a bug in zipimport.c that was fixed in 2.4. I copied across the 2.4 version and after removing a single new error check the rebuilt python 2.3 works fine. There was supposed to be a patch here http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/zipimport.c?r1=1.16&r2=1.17 but it's a dead link. -- Robin Becker On 11/11/2011 16:52, Robin Becker wrote: > I'm trying to run some aged software on a new machine which runs > > Linux app2.reportlab.com 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC > 2011 x86_64 GNU/Linux Ubuntu 10.04.2 LTS > > The software is required to use python 2.3 so first I've had some problems > building python itself. Apparently to get rid of segfaults during the build we > need the configure args to include > > BASECFLAGS=-U_FORTIFY_SOURCE > > that certainly fixes the python build errors. > > Now when we come to run the aged application we get this > > $ ./xxx.cgi > Traceback (most recent call last): > File "/home/rptlab/website/develop.reportlab.com/cgi-bin/xxx.cgi", line 7, in ? > from fastwebapp import FastWebApp > OverflowError: signed integer is greater than maximum > > > this appears to be related to the use of a zip import. > > > sys.path.insert(0,os.path.join(os.getcwd(),"fastapp.zip")) > > from fastwebapp import FastWebApp > > if we unpack the zip and remove the path insert the application appears to run > fine. > > Googling appears to indicate that others have seen this error but on a different > hardware and trying to remove optimizations from the python build has had > variable success. > > Anyone had any real success with this problem? The last version of the test > machinery ran 32bit freebsd and we had no problems on that hardware. From gelonida at gmail.com Fri Nov 11 12:45:00 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 18:45:00 +0100 Subject: Get keys from a dicionary In-Reply-To: References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: On 11/11/2011 02:31 PM, macm wrote: > > Hi Folks > > > > I pass a nested dictionary to a function. > > > > def Dicty( dict[k1][k2] ): > > print k1 > > print k2 > > > > There is a fast way (trick) to get k1 and k2 as string. > > > > Whithout loop all dict. Just it! > > > > Regards > > > > macm If my guessing was correct is this what you are looking for? nesteddict = { 'a': { 'A' : 'value1 a_A' , 'B' : 'value2 a_B' }, 'b': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, 'c': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, } def find_in_nested_dict(adict, avalue): results = [] for key1, sub_dict in adict.items(): for key2, value in sub_dict.items(): if avalue == value: results.append( (key1, key2) ) return results def mk_lookup(adict): lookup = {} for key1, sub_dict in adict.items(): for key2, value in sub_dict.items(): entry = lookup.get(value, []) entry.append( (key1, key2) ) lookup[value] = entry return lookup # good if you just want so search one value value = nesteddict['c']['B'] keys = find_in_nested_dict(nesteddict, value) print "found %r in %r" % (value, keys) # if you need many lookups perhaps better to 'precalculate a # 'reversed' dict lookup = mk_lookup(nesteddict) keys = lookup[value] print "found %r in %r" % (value, keys) From gordon at panix.com Fri Nov 11 12:51:57 2011 From: gordon at panix.com (John Gordon) Date: Fri, 11 Nov 2011 17:51:57 +0000 (UTC) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: In Gelonida N writes: > > > There is a fast way (trick) to get k1 and k2 as string. > > > > > > Whithout loop all dict. Just it! > If my guessing was correct is this what you are looking for? He said he didn't want to loop over the dict contents. Without that, I don't think there's an answer for him. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From sky378 at gmail.com Fri Nov 11 13:44:27 2011 From: sky378 at gmail.com (Arjuna Software) Date: Fri, 11 Nov 2011 10:44:27 -0800 (PST) Subject: SMS api for python References: <07a0a94e-2b96-4149-a18c-2cf2836351d8@f3g2000pri.googlegroups.com> Message-ID: <23f5c569-a131-4ffc-9ded-b07bcaffc83b@n38g2000yqm.googlegroups.com> On Oct 21, 3:10?am, Pankaj wrote: > I want to make an api that would recieve the SMS text from the user > and process it then send the result back to the use. Is there any api > that I can use to do this?? Send SMS Text messages using SMS API: http://www.txtimpact.com/sms-gateway-api.asp TxtImpact SMS API, you have access to powerful text messaging functionality for integration into your existing and new web and enterprise applications. Text Messaging API or SMS API can enable application to receive and send SMS text messages utilising txtimpact advanced SMS gateway API or Text Messaging API. TxtImpact provides simple HTTP interface for clients to send and receive messages from mobile phone users. HTTP POST can be used in all modern programming languages including ASP, ASP.NET, C++, C#, PHP, VB, VB.NET, command lines, SSH & cURL. From sky378 at gmail.com Fri Nov 11 13:44:41 2011 From: sky378 at gmail.com (Arjuna Software) Date: Fri, 11 Nov 2011 10:44:41 -0800 (PST) Subject: SMS api for python References: <07a0a94e-2b96-4149-a18c-2cf2836351d8@f3g2000pri.googlegroups.com> Message-ID: <5f098d1d-adf3-4c4c-83eb-31a7621a8e21@o13g2000vbo.googlegroups.com> On Oct 21, 4:41?am, Chris Rebert wrote: > On Fri, Oct 21, 2011 at 12:10 AM, Pankaj wrote: > > I want to make an api that would recieve the SMS text from the user > > and process it then send the result back to the use. Is there any api > > that I can use to do this?? > > There would seem to be several options:http://pypi.python.org/pypi?%3Aaction=search&term=sms&submit=search > > Cheers, > Chris Send SMS Text messages using SMS API: http://www.txtimpact.com/sms-gateway-api.asp TxtImpact SMS API, you have access to powerful text messaging functionality for integration into your existing and new web and enterprise applications. Text Messaging API or SMS API can enable application to receive and send SMS text messages utilising txtimpact advanced SMS gateway API or Text Messaging API. TxtImpact provides simple HTTP interface for clients to send and receive messages from mobile phone users. HTTP POST can be used in all modern programming languages including ASP, ASP.NET, C++, C#, PHP, VB, VB.NET, command lines, SSH & cURL. From ethan at stoneleaf.us Fri Nov 11 13:47:13 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 11 Nov 2011 10:47:13 -0800 Subject: How to dynamically create a derived type in the Python C-API Message-ID: <4EBD6DB1.2070600@stoneleaf.us> Asking on behalf of Sven Marnach: --------------------------------------------------------------------- Assume we have the type Noddy as defined in the tutorial on writing C extension modules for Python. Now we want to create a derived type, overwriting only the __new__() method of Noddy. Currently I use the following approach (error checking stripped for readability): PyTypeObject *BrownNoddyType = (PyTypeObject *)PyType_Type.tp_alloc(&PyType_Type, 0); BrownNoddyType->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; BrownNoddyType->tp_name = "noddy.BrownNoddy"; BrownNoddyType->tp_doc = "BrownNoddy objects"; BrownNoddyType->tp_base = &NoddyType; BrownNoddyType->tp_new = BrownNoddy_new; PyType_Ready(BrownNoddyType); This works, but I'm not sure if it is The Right Way To Do It. I would have expected that I have to set the Py_TPFLAGS_HEAPTYPE flag, too, because I dynamically allocate the type object on the heap, but doing so leads to a segfault in the interpreter. I also thought about explicitly calling type() using PyObject_Call() or similar, but I discarded the idea. I would need to wrap the function BrownNoddy_new() in a Python function object and create a dictionary mapping __new__ to this function object, which seems silly. What is the best way to go about this? Is my approach correct? Is there an interface function I missed? --------------------------------------------------------------------- ~Ethan~ From cv33cv33cv33 at gmail.com Fri Nov 11 14:04:06 2011 From: cv33cv33cv33 at gmail.com (BV) Date: Fri, 11 Nov 2011 11:04:06 -0800 (PST) Subject: DISCOVER ISLAM - THE FASTEST GROWING RELIGION IN THE WORLD !!!!!!!!!!!! Message-ID: DISCOVER ISLAM - THE FASTEST GROWING RELIGION IN THE WORLD Did you read about Islam from it,s original sources? Is the information about Islam that published at International Media is correct ? Excuse me!! Would you stop for a moment?! O...man...Haven't you thought-one day- about yourself ? Who has made it? Have you seen a design which hasn't a designer ?! Have you seen a wonderful,delicate work without a worker ?! It's you and the whole universe!.. Who has made them all ?!! You know who ?.. It's "ALLAH",prise be to him. Just think for a moment. How are you going to be after death ?! Can you believe that this exact system of the universe and all of these great creation will end in in nothing...just after death! Have you thought, for a second, How to save your soul from Allah's punishment?! Haven't you thought about what is the right religion?! Read ... and think deeply before you answer.. It is religion of Islam. It is the religion that Mohammad-peace upon him- the last prophet, had been sent by. It is the religion that the right Bible- which is not distorted-has preached. Just have a look at The Bible of (Bernaba). Don't be emstional. Be rational and judge.. Just look..listen...compare..and then judge and say your word. We advise you visiting : http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://www.chatislamonline.org/ar http://www.dar-us-salam.com http://youtubeislam.com From ethan at stoneleaf.us Fri Nov 11 15:08:13 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 11 Nov 2011 12:08:13 -0800 Subject: How to dynamically create a derived type in the Python C-API In-Reply-To: <4EBD6DB1.2070600@stoneleaf.us> References: <4EBD6DB1.2070600@stoneleaf.us> Message-ID: <4EBD80AD.5020201@stoneleaf.us> The question is on StackOverflow if you want to answer it directly: http://stackoverflow.com/questions/8066438 ~Ethan~ From gelonida at gmail.com Fri Nov 11 15:27:49 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 21:27:49 +0100 Subject: resolving module name conflicts. Message-ID: Hi, I got some code. - This code contains a package named tests - there are at least 100 references in different python files importing from above mentioned tests package. - the code also imports pytz at one place I get following warning message: /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: Module tests was already imported from /home/user/myproject/tests/__init__.pyc, but /usr/lib/python2.6/dist-packages is being added to sys.path from pkg_resources import resource_stream Is there any way to tell pytz to import it's own tests package and tell the rest of the code to import the other? Python version is 2.6.5 Thanks in advance for any suggestion. From emile at fenx.com Fri Nov 11 16:31:03 2011 From: emile at fenx.com (Emile van Sebille) Date: Fri, 11 Nov 2011 13:31:03 -0800 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On 11/11/2011 12:27 PM Gelonida N said... > > > Hi, > > I got some code. > - This code contains a package named tests > - there are at least 100 references in different python files > importing from above mentioned tests package. > - the code also imports pytz at one place > > I get following warning message: > > /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: > Module tests was already imported from > /home/user/myproject/tests/__init__.pyc, but > /usr/lib/python2.6/dist-packages is being added to sys.path > from pkg_resources import resource_stream > > > Is there any way to tell pytz to import it's own tests package and tell > the rest of the code to import the other? > > Python version is 2.6.5 > > > Thanks in advance for any suggestion. Start with http://docs.python.org/whatsnew/2.5.html#pep-328-absolute-and-relative-imports Emile From ericsnowcurrently at gmail.com Fri Nov 11 16:34:07 2011 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Fri, 11 Nov 2011 14:34:07 -0700 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 1:27 PM, Gelonida N wrote: > > > Hi, > > I got some code. > - This code contains a package named tests > - there are at least 100 references in different python files > ? ? ? ?importing from above mentioned tests package. > - the code also imports pytz at one place > > I get following warning message: > > /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: > Module tests was already imported from > /home/user/myproject/tests/__init__.pyc, but > /usr/lib/python2.6/dist-packages is being added to sys.path > ?from pkg_resources import resource_stream > > > Is there any way to tell pytz to import it's own tests package and tell > the rest of the code to import the other? This sounds like a problem caused by using relative imports. Each import statement is made relative to some top-level module. The import mechanism looks for it in the directories in sys.path (first match wins). The interpreter adds the empty string to the beginning of sys.path, by default. The empty string represents the current working directory. An import referencing a module found there is called a relative import. Solution: If possible, make sure each of your import statements is absolute (the top-level module is in one of the [legit] sys.path directories). Then do one of the following: * sys.path.remove(''); * call your script from a directory without any python modules in it; * call os.chdir(...) in your script to change CWD before making any imports. This also means you shouldn't "test" your modules by just running them as scripts. Instead, write a separate test script that imports each of your modules absolutely (and maybe actually test them too ). As of 2.5, Python's from...import syntax supports explicit relative imports, with absolute imports as the default (sort of). In 2.5 and 2.6 the feature is optional, so you must add "from __future__ import absolute_import" to enable it. See PEP 328[1]. The relative import syntax means that you don't have to hard-code the name of the packages in your imports, which helps with brevity and portability. The problem is that the empty string is still added to the from of sys.path. I'm going to have to find out more about that one. Hope that helps. -eric [1] http://www.python.org/dev/peps/pep-0328/ > > Python version is 2.6.5 > > > Thanks in advance for any suggestion. > > > > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From ericsnowcurrently at gmail.com Fri Nov 11 16:51:12 2011 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Fri, 11 Nov 2011 14:51:12 -0700 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 2:34 PM, Eric Snow wrote: > The problem is that the empty string is still added to the from of > sys.path. ?I'm going to have to find out more about that one. Okay, don't know how I missed it but the docs for sys.path[1] spell it out: "As initialized upon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to search modules in the current directory first." So if you run a module as a script, that empty string will be added to sys.path and all imports will first check the directory you were in when you ran Python... -eric [1] http://docs.python.org/library/sys.html#sys.path From miki.tebeka at gmail.com Fri Nov 11 17:07:16 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Fri, 11 Nov 2011 14:07:16 -0800 (PST) Subject: SMS api for python In-Reply-To: <07a0a94e-2b96-4149-a18c-2cf2836351d8@f3g2000pri.googlegroups.com> References: <07a0a94e-2b96-4149-a18c-2cf2836351d8@f3g2000pri.googlegroups.com> Message-ID: <5179557.1489.1321049236343.JavaMail.geo-discussion-forums@prgt40> You can use services like https://www.tropo.com/home.jsp or http://www.twilio.com/ From gelonida at gmail.com Fri Nov 11 17:11:38 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 23:11:38 +0100 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On 11/11/2011 10:31 PM, Emile van Sebille wrote: > On 11/11/2011 12:27 PM Gelonida N said... >> Is there any way to tell pytz to import it's own tests package and tell >> the rest of the code to import the other? >> >> Python version is 2.6.5 >> >> >> Thanks in advance for any suggestion. > > Start with > http://docs.python.org/whatsnew/2.5.html#pep-328-absolute-and-relative-imports > Thanks Emile / Thanks Eric The from __future__ import absolute_import is already used in most files of this project but only used for importing some other modules. All the 'tests' modules are still imported with absolute imports. 'tests' is also a top level module of the existing project and being imported from top level scripts (scripts in the python path directory) Relative imports don't work on top level scripts as it would raise > ValueError: Attempted relative import in non-pack This is a legacy project where many tools assume a certain directory structure and where I'm kind of hesitant to move files into differnt directories. What's probably the most painless fix would be - force only certain (older?) versions of pytz (which don't expose this issue) to be installed. - rename tests into something else. However this will affect loads of files. and I had to check whether there are no shell scripts or custom executables, which depend on 'tests' being called 'tests' Pytz is only imported by one module, so I wondered if there were any tricks to 'change sys.path' prior to importing pytz and to make sure, that the projects 'tests' package and pytz's 'tests' package could co-exist. What I wondered is whether there was a way to fix the issue without having to 'touch' all the 100+ import statements spread over the project. In the long term I suggest, that the project's code will be changed such that it will no more conflict with pytz's tests package. (either rename the package, transform it to a sub package, ... ???), From gelonida at gmail.com Fri Nov 11 17:47:14 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 23:47:14 +0100 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On 11/11/2011 10:51 PM, Eric Snow wrote: > On Fri, Nov 11, 2011 at 2:34 PM, Eric Snow wrote: > > So if you run a module as a script, that empty string will be added to > sys.path and all imports will first check the directory you were in > when you ran Python... > Yes that's normal (and for the rest of the code required behaviour :-( ) The top level directory is no module, but just contains scripts requiring, that '.' is in the python path. In fact theissue can be reproduced rather easily. Everything seems to work, but I don't like having this warning. Especially as the project contains a hook, which raises an alert as soon as any module tries to send data to stderr. (reporting this as potential failure of the application) $ mkdir newdir $ cd newdir $ python -c 'import pytz ; print pytz.VERSION' 2010b $ mkdir tests $ echo print 1234 > tests/__init__.py $ python -c 'import pytz ; print pytz.VERSION' 2010b $ python -c 'import tests ; import pytz ; print pytz.VERSION ; reload(tests)' 1234 /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: Module tests was already imported from tests/__init__.pyc, but /usr/lib/python2.6/dist-packages is being added to sys.path from pkg_resources import resource_stream 2010b 1234 $ What does pytz want to tell me ????? From jehugaleahsa at gmail.com Fri Nov 11 19:20:09 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Fri, 11 Nov 2011 16:20:09 -0800 (PST) Subject: xmlrpclib date times and a trailing Z Message-ID: <7d3e9e96-687f-4081-990e-46b7bb386925@d5g2000yqg.googlegroups.com> I am trying to connect to Marchex's a call tracking software using xmlrpclib. I was able to get some code working, but I ran into a problem dealing with transfering datetimes. When I construct a xmlrpclib.ServerProxy, I am setting the use_datetime flag to indicate that I want to automatically convert back and forth between date times in the datetime library. I have a working version that doesn't use this flag, and I have to convert from the xmlrpclib.DateTime type to the datetime.datetime type manually, via string parsing. The thing is, Marchex's API returns date's with a trailing Z, after the time component. I did some research and this is supposed to be an indicator that UTC was used. However, it doesn't seem like the xmlrpclib likes it very much. It looks like it is using this code internally: time.strptime(data, "%Y %m%dT%H:%M:%S") This code doesn't look like it handles time zones at all. I guess, is there a way to tell xmlrpclib to include time zones when parsing date times? Thanks, Travis Parks From steve+comp.lang.python at pearwood.info Fri Nov 11 19:42:46 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Nov 2011 00:42:46 GMT Subject: resolving module name conflicts. References: Message-ID: <4ebdc106$0$29970$c3e8da3$5496439d@news.astraweb.com> On Fri, 11 Nov 2011 23:11:38 +0100, Gelonida N wrote: > Pytz is only imported by one module, so I wondered if there were any > tricks to 'change sys.path' prior to importing pytz sys.path is just a list of paths. You can import the sys module and manipulate it any way you like. -- Steven From steve+comp.lang.python at pearwood.info Fri Nov 11 20:18:26 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Nov 2011 01:18:26 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Nov 2011 23:35:32 -0500, Devin Jeanpierre wrote: >> That is patently untrue. If you were implementing namedtuple without >> exec, you would still (or at least you *should*) prevent the user from >> passing invalid identifiers as attribute names. What's the point of >> allowing attribute names you can't actually *use* as attribute names? > > Then why doesn't Python do this anywhere else? e.g. why can I > setattr(obj, 'a#b') when obj is any other mutable type? That is implementation-specific behaviour and not documented behaviour for Python. If you try it in (say) IronPython or Jython, you may or may not see the same behaviour. The docs for getattr state: getattr(x, 'foobar') is equivalent to x.foobar which implies that getattr(x, 'a!b') should be equivalent to x.a!b which will give a syntax error. The fact that CPython does less validation is arguably a bug and not something that you should rely on: it is *not* a promise of the language. As Terry Reedy already mentioned, the namespace used in classes and instances are ordinary generic dicts, which don't perform any name validation. That's done for speed. Other implementations may use namespaces that enforce legal names for attributes, and __slots__ already does: >>> class X(object): ... __slots__ = ['a', 'b!'] ... Traceback (most recent call last): File "", line 1, in TypeError: Error when calling the metaclass bases __slots__ must be identifiers [...] > To go off on another tangent, though, I don't really understand how you > guys can think this is reasonable, though. I don't get this philosophy > of restricting inputs that would otherwise be perfectly valid But they aren't perfectly valid. They are invalid inputs. Just because getattr and setattr in CPython allow you to create attributes with invalid names doesn't mean that everything else should be equally as slack. -- Steven From gelonida at gmail.com Fri Nov 11 20:46:49 2011 From: gelonida at gmail.com (Gelonida N) Date: Sat, 12 Nov 2011 02:46:49 +0100 Subject: resolving module name conflicts. (pytz version 2010b) In-Reply-To: <4ebdc106$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <4ebdc106$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/12/2011 01:42 AM, Steven D'Aprano wrote: > On Fri, 11 Nov 2011 23:11:38 +0100, Gelonida N wrote: > >> Pytz is only imported by one module, so I wondered if there were any >> tricks to 'change sys.path' prior to importing pytz > > sys.path is just a list of paths. You can import the sys module and > manipulate it any way you like. > Hmmm, I think I didn't express myself really well. What I meant is: Is there any successful trick, which can get rid of my warning. I don't feel comfortable with warnings, that I don't understand. Please see below example (which can easily be reproduced, if you have the right (wrong) version of pytz. $ mkdir newdir $ cd newdir $ python -c 'import pytz ; print pytz.VERSION' 2010b $ mkdir tests $ echo print 1234 > tests/__init__.py $ python -c 'import pytz ; print pytz.VERSION' 2010b $ python -c 'import tests ; import pytz ; print pytz.VERSION ; reload(tests)' 1234 /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: Module tests was already imported from tests/__init__.pyc, but /usr/lib/python2.6/dist-packages is being added to sys.path from pkg_resources import resource_stream 2010b 1234 $ What does pytz want to tell me ????? From candide at free.invalid Sat Nov 12 06:56:17 2011 From: candide at free.invalid (candide) Date: Sat, 12 Nov 2011 12:56:17 +0100 Subject: Use and usefulness of the as syntax Message-ID: <4ebe5ee6$0$25872$426a74cc@news.free.fr> First, could you confirm the following syntax import foo as f equivalent to import foo f = foo Now, I was wondering about the usefulness in everyday programming of the as syntax within an import statement. Here are some instances retrieved from real code of such a syntax import numpy as np import math as _math import pickle as pickle -- In the first case, the syntax is motivated by brevity need, isn't it ? -- The second case seems to be rather widespread and causes math attribute to be private but I don't figure out why this matters. -- In the last case, I can see no point So what is the pragmatics of the as syntax ? Thanks for clarification. From rosuav at gmail.com Sat Nov 12 07:27:56 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Nov 2011 23:27:56 +1100 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: On Sat, Nov 12, 2011 at 10:56 PM, candide wrote: > import foo as f > > equivalent to > > import foo > f = foo > Not quite, it's closer to: import foo f = foo del foo without the fiddling around. What the 'import... as' syntax gives is a way to separate the thing loaded from the name bound to. Suppose importing were done thus: foo = import("foo.py") Then you'd have a standard convention of always importing into a variable of the same name (loose terminology, but you know what I mean), with the option of importing as something completely different. The "import... as" syntax gives the same power, without forcing you to repeat yourself in the common situation. ChrisA From arnodel at gmail.com Sat Nov 12 07:29:26 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Sat, 12 Nov 2011 12:29:26 +0000 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: On 12 November 2011 11:56, candide wrote: > First, could you confirm the following syntax > > import foo as f > > equivalent to > > import foo > f = foo > > > > Now, I was wondering about the usefulness in everyday programming of the as > syntax within an import statement. Here are some instances retrieved from > real code of such a syntax > > import numpy as np > > import math as _math > > import pickle as pickle > > > -- In the first case, the syntax is motivated by brevity need, isn't it ? Correct! > -- The second case seems to be rather widespread and causes math attribute > to be private but I don't figure out why this matters. This way math doesn't get bound in the global namespace when doing "from module import *" > -- In the last case, I can see no point Neither can I > So what is the pragmatics of the as syntax ? It can also help when you want to import two different modules with the same name. -- Arnaud From python.list at tim.thechases.com Sat Nov 12 07:43:06 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 12 Nov 2011 06:43:06 -0600 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: <4EBE69DA.2060501@tim.thechases.com> On 11/12/11 05:56, candide wrote: > First, could you confirm the following syntax > > import foo as f > > equivalent to > > import foo > f = foo and the issuing "del foo" > Now, I was wondering about the usefulness in everyday programming of the > as syntax within an import statement. Here are some instances retrieved > from real code of such a syntax > > import numpy as np > import math as _math > import pickle as pickle > > -- In the last case, I can see no point Without context, I'm guessing the last one is merely keeping parity in a block that reads: try: import cPickle as pickle except ImportError: import pickle as pickle > So what is the pragmatics of the as syntax ? The most common use-case I see is your first: to shorten a frequently-used namespace. I do this frequently with import Tkinter as tk which makes it obvious where things are coming from. I hate trying to track down variable-names if one did something like from Tkinter import * The second big use case I see regularly is the full example (above): try to import a faster/native module that shares an interface with a pure-python implementation. However in the above, the "import pickle as pickle" is a uselessly redundant. -tkc From rafadurancastaneda at gmail.com Sat Nov 12 07:48:04 2011 From: rafadurancastaneda at gmail.com (=?ISO-8859-1?Q?Rafael_Dur=E1n_Casta=F1eda?=) Date: Sat, 12 Nov 2011 13:48:04 +0100 Subject: Use and usefulness of the as syntax In-Reply-To: <4EBE69DA.2060501@tim.thechases.com> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> <4EBE69DA.2060501@tim.thechases.com> Message-ID: <4EBE6B04.6040900@gmail.com> El 12/11/11 13:43, Tim Chase escribi?: > I hate trying to track down variable-names if one did something like > > from Tkinter import * > +1 From tim.wintle at teamrubber.com Sat Nov 12 08:03:29 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Sat, 12 Nov 2011 13:03:29 +0000 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: <1321103009.23677.32.camel@tim-laptop> On Sat, 2011-11-12 at 12:56 +0100, candide wrote: > So what is the pragmatics of the as syntax ? Another case: try: import json except: import simplejson as json (same goes for several modules where the C implementation may or may not be available) Tim From mwilson at the-wire.com Sat Nov 12 08:59:40 2011 From: mwilson at the-wire.com (Mel Wilson) Date: Sat, 12 Nov 2011 08:59:40 -0500 Subject: Use and usefulness of the as syntax References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: candide wrote: > First, could you confirm the following syntax > > import foo as f > > equivalent to > > import foo > f = foo > > > > Now, I was wondering about the usefulness in everyday programming of the > as syntax within an import statement. [ ... ] It gives you an out in a case like Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> os = 5 # number of 'o's >>> import os as opsys >>> os 5 >>> opsys (This is an instance of what arnaud mentioned.) Mel. From numansenm at gmail.com Sat Nov 12 09:31:27 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Sat, 12 Nov 2011 06:31:27 -0800 (PST) Subject: soma cheapest. Lowest prices for soma online. Buy soma online without no prescription. Buy cheap soma next day no prescription! Message-ID: soma cheapest. Lowest prices for soma online. Buy soma online without no prescription. Buy cheap soma next day no prescription! soma BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=soma <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=soma http://buypharmasite.com/?q=Buy+online+soma http://buypharmasite.com/?q=Buy+order+soma http://buypharmasite.com/?q=Buy+soma http://buypharmasite.com/?q=Buy+cheap+soma http://buypharmasite.com/?q=Order+soma http://buypharmasite.com/?q=Online+soma cheap online pharmacy soma soma online saturday delivery online soma and fedex cheap order prescription soma cheap soma by money order buy soma from mexico online soma no prescription usa fedex shipping overnight delivery soma buy soma online without a prescription and no membership no prescription needed soma cod shipped soma not expensive order prescription soma soma money order soma without a perscription online buy soma soma fedex buy no online prescription soma soma pharmacies accepting cod delivery soma online consultant online pharmacy fedex cod soma buy soma no scams soma c.o.d overnight delivery buy soma no prescription cod overnight soma order soma online doctors buy soma on line no prescription soma no prescription usa fedex shipping soma online uk watson brand soma medicine online soma order soma samples sent buy soma no prescription order soma without a prescription soma no prescription drug cheap online order soma get soma over the counter online order soma next day buy soma no perscription cod real soma fed ex soma no prescription cod does cv/ pharmacy carry soma no prescription cod soma cheap soma without rx soma online health insurance lead buy soma online with overnight delivery soma no rx fed ex buy soma without a perscription lowest prices for soma online buy soma paypal online without prescription cheap non prescription soma soma ups soma for cheap buy soma no visa online without prescription cheapest soma cash on delivery soma order a prepaid mastercard buy online soma purchase soma mail order soma without a prescription online with overnight delivery soma from canada buy soma with no rx overnight delivery of soma with no prescription cash on delivery soma no rx soma by cod buy soma over the counter cod overnight overnight soma order soma without prescription from us pharmacy cheap soma free fedex shipping order soma over the counter where to buy soma no prescription no fees only soma free consult cod delivery soma soma no prescription soma online overnight delivery cod order soma over the counter fedex soma saturday delivery buy soma money order soma without prescription mexico buy cheap soma without prescription soma non prescription for next day delivery soma ups delivery only buy soma usa cod soma with next day delivery no prescriptions needed for soma cheap soma overnight prescription soma cheap soma overnight delivery soma non prescription fedex overnight free order soma no creditcard buy cheap soma no Prescription buy soma over the counter fedex soma no doctor presribe needed cheap watson soma online cheap discount soma buy soma without a prescription online cheapest soma free delivery buy soma online overseas buy soma over the counter online not expensive soma next day shipping order soma cod next day delivery soma cheap soma buy in UK soma next day cod fedex soma to buy cheap order soma next day soma soma overnight no consult cheap watson soma no prescription needed soma without prescription medications overnight delivery of soma with no perscription buy soma.com soma cod next day delivery buy cheap discount online soma buy soma drug soma overnight delivery cheap overnight delivery of soma in US no prescription needed purchase soma free next day airsoma on line cheap soma without a prescription soma cheap cod soma buy no prepaid cheap soma next day buy soma cod accepted online pharmacies soma saturday delivery buy soma pay pal soma shipped on saturday soma pharmacy cod saturday delivery buy online soma prescriptions free fedex delivery soma soma without prescription cash on delivery buy discount soma soma overnight cheap best soma online pill images of soma soma U.P.S SHIPPING COD soma cod pharmacy buy soma online cod soma cod overnight delivery soma no rx overnight buy soma overnight COD online pharmacy soma cod order soma insurance soma cash delivery cod buy soma cheap cod no rx online pharmacy soma sale nextday soma soma pill soma online ordering soma online without prescription soma no script needed cod overnight how to buy soma online without a prescription cheap soma without prescription cheap soma online no rx saturday delivery order soma over the counter for sale soma next day delivery cod order soma online without prescription no prescription next day delivery soma overnight soma C.O.D soma without prescription soma discount fedex no prescription buy soma amex soma online next day soma shipped with no prescription soma online cheap cheap soma without prescription overnight delivery buy soma over the counter for sale soma no prescriptions needed cod soma fed ex cheap overnight delivery of soma free prescription soma free shipping not expensive legal soma for sale buy soma cod soma for saturday soma price cash for soma cash on delivery soma soma without a prescription and cod delivery buying soma without a prescription order soma no rx buy soma without rx soma cheapest buy soma online pharmacy buy cheap soma overnight delivery soma and online pharmacy soma next day soma drug no prescription where can i buy soma no prescription soma with saturday delivery soma online overnight soma no prescription worldwide buy cheap soma cod ordering soma online Buy soma overnight shipping soma overnight US delivery cheap real soma for sale soma no prescriptions needed COD buy soma no prescription needed soma no prescription overnight cod delivery cheap soma cash on delivery no prescription required for soma order soma c.o.d. not expensive soma prescriptions soma online Cash on Delivery buy soma overnight delivery soma online without presciption buy soma prescription online no prescription saturday delivery soma where to buy cheap soma no prescription soma wo get soma over the counter fedex soma with no rx and free shipping order soma over the counter cod overnight From numansenm at gmail.com Sat Nov 12 09:33:31 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Sat, 12 Nov 2011 06:33:31 -0800 (PST) Subject: Alprazolam Without Prescription Shipped Overnight Express | Buy Alprazolam Without A Prescription Or Membership Message-ID: <3f5a13c5-6149-4006-a6e0-5a7fb3c4e894@p16g2000yqd.googlegroups.com> Alprazolam cheapest. Lowest prices for Alprazolam online. Buy Alprazolam online without no prescription. Buy cheap Alprazolam next day no prescription! Alprazolam BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Alprazolam <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Alprazolam http://buypharmasite.com/?q=Buy+online+Alprazolam http://buypharmasite.com/?q=Buy+order+Alprazolam http://buypharmasite.com/?q=Buy+Alprazolam http://buypharmasite.com/?q=Buy+cheap+Alprazolam http://buypharmasite.com/?q=Order+Alprazolam http://buypharmasite.com/?q=Online+Alprazolam cheap online pharmacy Alprazolam Alprazolam online saturday delivery online Alprazolam and fedex cheap order prescription Alprazolam cheap Alprazolam by money order buy Alprazolam from mexico online Alprazolam no prescription usa fedex shipping overnight delivery Alprazolam buy Alprazolam online without a prescription and no membership no prescription needed Alprazolam cod shipped Alprazolam not expensive order prescription Alprazolam Alprazolam money order Alprazolam without a perscription online buy Alprazolam Alprazolam fedex buy no online prescription Alprazolam Alprazolam pharmacies accepting cod delivery Alprazolam online consultant online pharmacy fedex cod Alprazolam buy Alprazolam no scams Alprazolam c.o.d overnight delivery buy Alprazolam no prescription cod overnight Alprazolam order Alprazolam online doctors buy Alprazolam on line no prescription Alprazolam no prescription usa fedex shipping Alprazolam online uk watson brand Alprazolam medicine online Alprazolam order Alprazolam samples sent buy Alprazolam no prescription order Alprazolam without a prescription Alprazolam no prescription drug cheap online order Alprazolam get Alprazolam over the counter online order Alprazolam next day buy Alprazolam no perscription cod real Alprazolam fed ex Alprazolam no prescription cod does cv/ pharmacy carry Alprazolam no prescription cod Alprazolam cheap Alprazolam without rx Alprazolam online health insurance lead buy Alprazolam online with overnight delivery Alprazolam no rx fed ex buy Alprazolam without a perscription lowest prices for Alprazolam online buy Alprazolam paypal online without prescription cheap non prescription Alprazolam Alprazolam ups Alprazolam for cheap buy Alprazolam no visa online without prescription cheapest Alprazolam cash on delivery Alprazolam order a prepaid mastercard buy online Alprazolam purchase Alprazolam mail order Alprazolam without a prescription online with overnight delivery Alprazolam from canada buy Alprazolam with no rx overnight delivery of Alprazolam with no prescription cash on delivery Alprazolam no rx Alprazolam by cod buy Alprazolam over the counter cod overnight overnight Alprazolam order Alprazolam without prescription from us pharmacy cheap Alprazolam free fedex shipping order Alprazolam over the counter where to buy Alprazolam no prescription no fees only Alprazolam free consult cod delivery Alprazolam Alprazolam no prescription Alprazolam online overnight delivery cod order Alprazolam over the counter fedex Alprazolam saturday delivery buy Alprazolam money order Alprazolam without prescription mexico buy cheap Alprazolam without prescription Alprazolam non prescription for next day delivery Alprazolam ups delivery only buy Alprazolam usa cod Alprazolam with next day delivery no prescriptions needed for Alprazolam cheap Alprazolam overnight prescription Alprazolam cheap Alprazolam overnight delivery Alprazolam non prescription fedex overnight free order Alprazolam no creditcard buy cheap Alprazolam no Prescription buy Alprazolam over the counter fedex Alprazolam no doctor presribe needed cheap watson Alprazolam online cheap discount Alprazolam buy Alprazolam without a prescription online cheapest Alprazolam free delivery buy Alprazolam online overseas buy Alprazolam over the counter online not expensive Alprazolam next day shipping order Alprazolam cod next day delivery Alprazolam cheap Alprazolam buy in UK Alprazolam next day cod fedex Alprazolam to buy cheap order Alprazolam next day Alprazolam Alprazolam overnight no consult cheap watson Alprazolam no prescription needed Alprazolam without prescription medications overnight delivery of Alprazolam with no perscription buy Alprazolam.com Alprazolam cod next day delivery buy cheap discount online Alprazolam buy Alprazolam drug Alprazolam overnight delivery cheap overnight delivery of Alprazolam in US no prescription needed purchase Alprazolam free next day airAlprazolam on line cheap Alprazolam without a prescription Alprazolam cheap cod Alprazolam buy no prepaid cheap Alprazolam next day buy Alprazolam cod accepted online pharmacies Alprazolam saturday delivery buy Alprazolam pay pal Alprazolam shipped on saturday Alprazolam pharmacy cod saturday delivery buy online Alprazolam prescriptions free fedex delivery Alprazolam Alprazolam without prescription cash on delivery buy discount Alprazolam Alprazolam overnight cheap best Alprazolam online pill images of Alprazolam Alprazolam U.P.S SHIPPING COD Alprazolam cod pharmacy buy Alprazolam online cod Alprazolam cod overnight delivery Alprazolam no rx overnight buy Alprazolam overnight COD online pharmacy Alprazolam cod order Alprazolam insurance Alprazolam cash delivery cod buy Alprazolam cheap cod no rx online pharmacy Alprazolam sale nextday Alprazolam Alprazolam pill Alprazolam online ordering Alprazolam online without prescription Alprazolam no script needed cod overnight how to buy Alprazolam online without a prescription cheap Alprazolam without prescription cheap Alprazolam online no rx saturday delivery order Alprazolam over the counter for sale Alprazolam next day delivery cod order Alprazolam online without prescription no prescription next day delivery Alprazolam overnight Alprazolam C.O.D Alprazolam without prescription Alprazolam discount fedex no prescription buy Alprazolam amex Alprazolam online next day Alprazolam shipped with no prescription Alprazolam online cheap cheap Alprazolam without prescription overnight delivery buy Alprazolam over the counter for sale Alprazolam no prescriptions needed cod Alprazolam fed ex cheap overnight delivery of Alprazolam free prescription Alprazolam free shipping not expensive legal Alprazolam for sale buy Alprazolam cod Alprazolam for saturday Alprazolam price cash for Alprazolam cash on delivery Alprazolam Alprazolam without a prescription and cod delivery buying Alprazolam without a prescription order Alprazolam no rx buy Alprazolam without rx Alprazolam cheapest buy Alprazolam online pharmacy buy cheap Alprazolam overnight delivery Alprazolam and online pharmacy Alprazolam next day Alprazolam drug no prescription where can i buy Alprazolam no prescription Alprazolam with saturday delivery Alprazolam online overnight Alprazolam no prescription worldwide buy cheap Alprazolam cod ordering Alprazolam online Buy Alprazolam overnight shipping Alprazolam overnight US delivery cheap real Alprazolam for sale Alprazolam no prescriptions needed COD buy Alprazolam no prescription needed Alprazolam no prescription overnight cod delivery cheap Alprazolam cash on delivery no prescription required for Alprazolam order Alprazolam c.o.d. not expensive Alprazolam prescriptions Alprazolam online Cash on Delivery buy Alprazolam overnight delivery Alprazolam online without presciption buy Alprazolam prescription online no prescription saturday delivery Alprazolam where to buy cheap Alprazolam no prescription Alprazolam wo get Alprazolam over the counter fedex Alprazolam with no rx and free shipping order Alprazolam over the counter cod overnight From numansenm at gmail.com Sat Nov 12 09:35:49 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Sat, 12 Nov 2011 06:35:49 -0800 (PST) Subject: Buying CODEINE Without A Prescription | CODEINE Without Prescription Or Membership Message-ID: <3137318f-99d0-4008-8aa7-9bce00344e0b@n6g2000vbg.googlegroups.com> CODEINE cheapest. Lowest prices for CODEINE online. Buy CODEINE online without no prescription. Buy cheap CODEINE next day no prescription! CODEINE BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=CODEINE <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=CODEINE http://buypharmasite.com/?q=Buy+online+CODEINE http://buypharmasite.com/?q=Buy+order+CODEINE http://buypharmasite.com/?q=Buy+CODEINE http://buypharmasite.com/?q=Buy+cheap+CODEINE http://buypharmasite.com/?q=Order+CODEINE http://buypharmasite.com/?q=Online+CODEINE cheap online pharmacy CODEINE CODEINE online saturday delivery online CODEINE and fedex cheap order prescription CODEINE cheap CODEINE by money order buy CODEINE from mexico online CODEINE no prescription usa fedex shipping overnight delivery CODEINE buy CODEINE online without a prescription and no membership no prescription needed CODEINE cod shipped CODEINE not expensive order prescription CODEINE CODEINE money order CODEINE without a perscription online buy CODEINE CODEINE fedex buy no online prescription CODEINE CODEINE pharmacies accepting cod delivery CODEINE online consultant online pharmacy fedex cod CODEINE buy CODEINE no scams CODEINE c.o.d overnight delivery buy CODEINE no prescription cod overnight CODEINE order CODEINE online doctors buy CODEINE on line no prescription CODEINE no prescription usa fedex shipping CODEINE online uk watson brand CODEINE medicine online CODEINE order CODEINE samples sent buy CODEINE no prescription order CODEINE without a prescription CODEINE no prescription drug cheap online order CODEINE get CODEINE over the counter online order CODEINE next day buy CODEINE no perscription cod real CODEINE fed ex CODEINE no prescription cod does cv/ pharmacy carry CODEINE no prescription cod CODEINE cheap CODEINE without rx CODEINE online health insurance lead buy CODEINE online with overnight delivery CODEINE no rx fed ex buy CODEINE without a perscription lowest prices for CODEINE online buy CODEINE paypal online without prescription cheap non prescription CODEINE CODEINE ups CODEINE for cheap buy CODEINE no visa online without prescription cheapest CODEINE cash on delivery CODEINE order a prepaid mastercard buy online CODEINE purchase CODEINE mail order CODEINE without a prescription online with overnight delivery CODEINE from canada buy CODEINE with no rx overnight delivery of CODEINE with no prescription cash on delivery CODEINE no rx CODEINE by cod buy CODEINE over the counter cod overnight overnight CODEINE order CODEINE without prescription from us pharmacy cheap CODEINE free fedex shipping order CODEINE over the counter where to buy CODEINE no prescription no fees only CODEINE free consult cod delivery CODEINE CODEINE no prescription CODEINE online overnight delivery cod order CODEINE over the counter fedex CODEINE saturday delivery buy CODEINE money order CODEINE without prescription mexico buy cheap CODEINE without prescription CODEINE non prescription for next day delivery CODEINE ups delivery only buy CODEINE usa cod CODEINE with next day delivery no prescriptions needed for CODEINE cheap CODEINE overnight prescription CODEINE cheap CODEINE overnight delivery CODEINE non prescription fedex overnight free order CODEINE no creditcard buy cheap CODEINE no Prescription buy CODEINE over the counter fedex CODEINE no doctor presribe needed cheap watson CODEINE online cheap discount CODEINE buy CODEINE without a prescription online cheapest CODEINE free delivery buy CODEINE online overseas buy CODEINE over the counter online not expensive CODEINE next day shipping order CODEINE cod next day delivery CODEINE cheap CODEINE buy in UK CODEINE next day cod fedex CODEINE to buy cheap order CODEINE next day CODEINE CODEINE overnight no consult cheap watson CODEINE no prescription needed CODEINE without prescription medications overnight delivery of CODEINE with no perscription buy CODEINE.com CODEINE cod next day delivery buy cheap discount online CODEINE buy CODEINE drug CODEINE overnight delivery cheap overnight delivery of CODEINE in US no prescription needed purchase CODEINE free next day airCODEINE on line cheap CODEINE without a prescription CODEINE cheap cod CODEINE buy no prepaid cheap CODEINE next day buy CODEINE cod accepted online pharmacies CODEINE saturday delivery buy CODEINE pay pal CODEINE shipped on saturday CODEINE pharmacy cod saturday delivery buy online CODEINE prescriptions free fedex delivery CODEINE CODEINE without prescription cash on delivery buy discount CODEINE CODEINE overnight cheap best CODEINE online pill images of CODEINE CODEINE U.P.S SHIPPING COD CODEINE cod pharmacy buy CODEINE online cod CODEINE cod overnight delivery CODEINE no rx overnight buy CODEINE overnight COD online pharmacy CODEINE cod order CODEINE insurance CODEINE cash delivery cod buy CODEINE cheap cod no rx online pharmacy CODEINE sale nextday CODEINE CODEINE pill CODEINE online ordering CODEINE online without prescription CODEINE no script needed cod overnight how to buy CODEINE online without a prescription cheap CODEINE without prescription cheap CODEINE online no rx saturday delivery order CODEINE over the counter for sale CODEINE next day delivery cod order CODEINE online without prescription no prescription next day delivery CODEINE overnight CODEINE C.O.D CODEINE without prescription CODEINE discount fedex no prescription buy CODEINE amex CODEINE online next day CODEINE shipped with no prescription CODEINE online cheap cheap CODEINE without prescription overnight delivery buy CODEINE over the counter for sale CODEINE no prescriptions needed cod CODEINE fed ex cheap overnight delivery of CODEINE free prescription CODEINE free shipping not expensive legal CODEINE for sale buy CODEINE cod CODEINE for saturday CODEINE price cash for CODEINE cash on delivery CODEINE CODEINE without a prescription and cod delivery buying CODEINE without a prescription order CODEINE no rx buy CODEINE without rx CODEINE cheapest buy CODEINE online pharmacy buy cheap CODEINE overnight delivery CODEINE and online pharmacy CODEINE next day CODEINE drug no prescription where can i buy CODEINE no prescription CODEINE with saturday delivery CODEINE online overnight CODEINE no prescription worldwide buy cheap CODEINE cod ordering CODEINE online Buy CODEINE overnight shipping CODEINE overnight US delivery cheap real CODEINE for sale CODEINE no prescriptions needed COD buy CODEINE no prescription needed CODEINE no prescription overnight cod delivery cheap CODEINE cash on delivery no prescription required for CODEINE order CODEINE c.o.d. not expensive CODEINE prescriptions CODEINE online Cash on Delivery buy CODEINE overnight delivery CODEINE online without presciption buy CODEINE prescription online no prescription saturday delivery CODEINE where to buy cheap CODEINE no prescription CODEINE wo get CODEINE over the counter fedex CODEINE with no rx and free shipping order CODEINE over the counter cod overnight From tavares at fe.up.pt Sat Nov 12 10:05:05 2011 From: tavares at fe.up.pt (tavares at fe.up.pt) Date: Sat, 12 Nov 2011 07:05:05 -0800 (PST) Subject: =?windows-1252?Q?CMBBE2012_=96_Special_Session_on_=93Computational_Me?= =?windows-1252?Q?thods_for_Bio=2D_Imaging_and_Visualization=94?= Message-ID: Dear Colleague, Within the 10th International Symposium on Biomechanics and Biomedical Engineering - CMBBE2012 (http://www.cmbbe2012.cf.ac.uk), to be held in Berlin, Germany, on April 11-14, 2012, we are organizing the Special Session on ?Computational Methods for Bio- Imaging and Visualization?. Due to your research activities in the related fields, we would like to invite you to submit an abstract to our special session. Your contribution is mostly welcomed, and we would be honoured if you could accept this invitation. TOPICS OF INTEREST (not restricted to): - Applications of Bio- Imaging and Visualization; - Computational Vision; - Computer Aided Diagnosis, Surgery, Therapy, and Treatment; - Image Acquisition; - Image Processing and Analysis; - Image Segmentation, Matching and Registration; - Medical Imaging; - Motion and Deformation Analysis; - Physics of Bio-Imaging; - Scientific Visualization; - Shape Reconstruction; - Simulation and Animation; - Software Development; - Telemedicine Systems and their Applications. IMPORTANT DATES: - Abstract submission cut off: December 16, 2011; - Meeting: April 11-14, 2012. ABSTRACT SUBMISSION: Please, go to the abstract submission page (http:// www.cmbbe2012.cf.ac.uk/abstract%20-%20author.asp) and select the Special Session ?SS5 - Computational Methods for Bio- Imaging and Visualization?. With kind regards, Jo?o Manuel R. S. Tavares, University of Porto, Portugal, tavares at fe.up.pt (Organizer of the Special Session on ?Computational Methods for Bio- Imaging and Visualization?) From jehugaleahsa at gmail.com Sat Nov 12 11:11:21 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sat, 12 Nov 2011 08:11:21 -0800 (PST) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: On Nov 8, 12:09?am, Lie Ryan wrote: > On 11/08/2011 01:21 PM, Travis Parks wrote: > > > > > > > On Nov 7, 12:44 pm, John Gordon ?wrote: > >> In ?John Gordon ?writes: > > >>> In<415d875d-bc6d-4e69-bcf8-39754b450... at n18g2000vbv.googlegroups.com> ?Travis Parks ?writes: > >>>> Which web frameworks have people here used and which have they found > >>>> to be: scalable, RAD compatible, performant, stable and/or providing > >>>> good community support? I am really trying to get as much feedback as > >>> I've used Django and it seems to be a very nice framework. ?However I've > >>> only done one project so I haven't delved too deeply. > > >> You are probably looking for more detail than "It's a nice framework" :-) > > >> The database model in Django is powerful; it allows you to do queries in > >> native Python code without delving into backend SQL stuff. > > >> I don't know how scalable/performant the database model is, as the one > >> project I worked on didn't deal with a ton of data. ?(But I'd be surprised > >> if it had poor performance.) > > >> The URL dispatcher provides a very nice and logical way to associate a > >> given URL with a given method call. > > >> Community support is excellent. > > >> -- > >> John Gordon ? ? ? ? ? ? ? ? ? A is for Amy, who fell down the stairs > >> gor... at panix.com ? ? ? ? ? ? ?B is for Basil, assaulted by bears > >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- Edward Gorey, "The Gashlycrumb Tinies" > > > I started the battle today. The "new guy" was trying to sell me on > > CodeIgnitor. I haven't looked at it, but it is PHP, so I really want > > to avoid it. The good thing is that all of his "friends" have been > > telling him to get into Python. I have been trying to convince him > > that PHP isn't cut out for background services and is mostly a front- > > end language. Python is much more geared towards hardcore data > > processing. Why write the system in two languages? > > > I have been spending a lot of time looking at the Pyramid project: the > > next generation of the Pylons project. It looks powerful, but it seems > > to be a lot more complex than Django. > > CodeIgniter is a very fine framework, however it builds on top of a > shitty excuse of a language called PHP. > > I've found that Django has a much better debugging tools; when a Django > page produces an exception, it would always produce a useful error page. > I haven't been able to do the same in CodeIgniter (nor in any PHP > framework I've used, I'm starting to think it's a language limitation); > often when you have errors, PHP would just silently return empty or > partial pages even with all the debugging flags on. > > IMO, Python has a much nicer choice of built-in data structure for data > processing. Python has a much more mature object-orientation, e.g. I > prefer writing l.append(x) rather than array_push(l, x). I think these > qualities are what makes you think Python is much, much more suitable > for data processing than PHP; and I wholesomely agree. > > Database abstraction-wise, Django's ORM wins hands down against > CodeIgniter's ActiveRecord. CodeIgniter's ActiveRecord is basically just > a thin wrapper that abstracts the perks of various database engine. > Django's ORM is a full blown ORM, it handles foreign key relationships > in OO way. The only disadvantage of Django's ORM is that since it's > written in Python, if you need to write a program working on the same > database that doesn't use Django nor Python, then you'll have a problem > since you'll have to duplicate the foreign key relationships. > > With all the bashing of PHP, PHP do have a few advantages. PHP and > CodeIgniter is much easier to set up and running than Django; and the > ability to create a .php file and have it running without having to > write the routing file is sometimes a bliss. And PHP are often used as > their own templating language; in contrast with Django which uses a > separate templating language. Having a full blown language as your > templating language can be a double-edged sword, but it is useful > nevertheless for experimental work. > > IMO, while it is easier to get up and running in PHP, in the long run > Python is much better in almost any other aspects.- Hide quoted text - > > - Show quoted text - The good thing is that I got the new guy to convert his thinking towards Python. He did a little research of his own and realized what he was missing. He and I have been writing some tools in Python, accessing social networking sites, and have been pleasantly surprised by Python's rich support for web protocols. Even yesterday, I wrote some code using xmlrpclib and it blew the equivalent C# code out of the water. urllib2 and urlparse make it really easy to work against RESTful services. It seems like most of Google's APIs have a Python variant. We are thinking we will go along with Pyramid, rather than Django. It was a really hard decision to make. Django has a lot of community support and is integrated with PyDev in eclipse. Nonetheless, we are anticipating the need for massive through-put on our web servers, so we want to make sure we don't have to change gears 2 years down the road when we have 100,000+ users. Furthermore, it seems like Django doesn't allow for customization - we might want to switch between ORMs and the template engine. It is going to be an interesting process of moving from an ASP.NET MVC application to 100% Python. We'll see how well we can scaffold them together. From krzysztof.berniak at gmail.com Sat Nov 12 13:54:12 2011 From: krzysztof.berniak at gmail.com (Krzysztof Berniak) Date: Sat, 12 Nov 2011 19:54:12 +0100 Subject: export output from gnuplot to python Message-ID: Hi all, I'm writing script in python, which fitting exponencial curve to data ( f(x) = a*exp(x*b). To this problem, I use gnuplot in my script. Gnuplot display parameters ( a +/- delta a; b +/- delta b) How Can I use/save this parameters in python variables in next steps of my script, def main(): ... plot = Gnuplot.Gnuplot() plot('f1(x) = a1*exp(b1*x)') plot('a1 = 300; b1 = 0.005;') plot('fit f1(x) "data.txt" using 1:2 via a1, b1') print "first parameter", a1 print "second parameter", b1 # is it feasible ? Or there is another way to see the results ( parameter a1 and b1) of gnuplot by python ... #plot('set terminal postscript') #plot('set output "output.p s"') regards and please help, Cristopher -------------- next part -------------- An HTML attachment was scrubbed... URL: From lbrt Sat Nov 12 14:06:32 2011 From: lbrt (lbrt) Date: 12 Nov 2011 19:06:32 GMT Subject: youtube-dl: way to deal with the size cap issue + new errors + issues ... Message-ID: <1321124792.454176@nntp.aceinnovative.com> ~ I did find my way (through a silly hack) to get all files within a size range without waiting for youtube-dl to be "enhanced". You could simply run youtube-dl in simulate mode and then parse that data to get the info ~ $ youtube-dl --help | grep simulate -s, --simulate do not download the video and do not write anything to disk -g, --get-url simulate, quiet but print URL -e, --get-title simulate, quiet but print title --get-thumbnail simulate, quiet but print thumbnail URL --get-description simulate, quiet but print video description --get-filename simulate, quiet but print output filename --get-format simulate, quiet but print output format ~ it turns out I needed the data anyway and %(uploader)s %(stitle)s and %(ext)s are helpful as well, for example, in case you decide to skip a certain uploader ~ I have also been getting errors reporting: ~ RTMP download detected but "rtmpdump" could not be run ~ What does it mean? Is it a youtube thing or a python/youtube-dl one (or both)? Could you fix that with some flag? ~ It would be very helpful if you could redirect youtube-dl errors to a separate file you would indicate via a flag ~ lbrtchx comp.lang.python: youtube-dl: way to deal with the size cap issue + new errors + issues ... ~ // __ ERROR: RTMP download detected but "rtmpdump" could not be run ~ downloading: http://www.youtube.com/watch?v=TD-66LHJF9E [youtube] Setting language [youtube] TD-66LHJF9E: Downloading video webpage [youtube] TD-66LHJF9E: Downloading video info webpage [youtube] TD-66LHJF9E: Extracting video information [youtube] RTMP download detected [download] Destination: ./LionsgateMovies-TD-66LHJF9E_Trading_Mom.flv ERROR: RTMP download detected but "rtmpdump" could not be run ~ downloading: http://www.youtube.com/watch?v=Ft5fFOktUno [youtube] Setting language [youtube] Ft5fFOktUno: Downloading video webpage [youtube] Ft5fFOktUno: Downloading video info webpage [youtube] Ft5fFOktUno: Extracting video information [youtube] RTMP download detected [download] Destination: ./LionsgateMovies-Ft5fFOktUno_Speed_Racer_The_Movie.flv ERROR: RTMP download detected but "rtmpdump" could not be run ~ downloading: http://www.youtube.com/watch?v=wRbAGrIjCr4 [youtube] Setting language [youtube] wRbAGrIjCr4: Downloading video webpage [youtube] wRbAGrIjCr4: Downloading video info webpage [youtube] wRbAGrIjCr4: Extracting video information [youtube] RTMP download detected [download] Destination: ./LionsgateMovies-wRbAGrIjCr4_Jonah_A_VeggieTales_Movie.flv ERROR: RTMP download detected but "rtmpdump" could not be run ~ downloading: http://www.youtube.com/watch?v=yU0KpRBkeMY [youtube] Setting language [youtube] yU0KpRBkeMY: Downloading video webpage [youtube] yU0KpRBkeMY: Downloading video info webpage [youtube] yU0KpRBkeMY: Extracting video information [youtube] RTMP download detected [download] Destination: ./LionsgateMovies-yU0KpRBkeMY_Hercules_In_New_York.flv ERROR: RTMP download detected but "rtmpdump" could not be run ~ From haraldarminmassa at gmail.com Sat Nov 12 18:53:06 2011 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Sun, 13 Nov 2011 00:53:06 +0100 Subject: occupywallst.org is looking for Python programmers Message-ID: just got this from Richard: Justine told me they are looking for Python programmers. (It involves Django also.) so, if anyone is interested to help them out, please contact Justine. Best wishes Harald -- Harald Armin Massa no fx, no carrier pigeon - From steve+comp.lang.python at pearwood.info Sat Nov 12 18:54:00 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Nov 2011 23:54:00 GMT Subject: youtube-dl: way to deal with the size cap issue + new errors + issues ... References: <1321124792.454176@nntp.aceinnovative.com> Message-ID: <4ebf0718$0$29970$c3e8da3$5496439d@news.astraweb.com> On Sat, 12 Nov 2011 19:06:32 +0000, lbrt chx _ gemale wrote: > I have also been getting errors reporting: > ~ > RTMP download detected but "rtmpdump" could not be run > ~ > What does it mean? Is it a youtube thing or a python/youtube-dl one (or > both)? Could you fix that with some flag? Try installing rtmpdump. BTW, your first call before asking here about random problems should be to use the search engine of your choice to google for more information: https://duckduckgo.com/html/?q=rtmpdump -- Steven From ramapraba2653 at gmail.com Sun Nov 13 00:56:56 2011 From: ramapraba2653 at gmail.com (SUPREME) Date: Sat, 12 Nov 2011 21:56:56 -0800 (PST) Subject: SOUTH INDIAN HOT ACTRESS Message-ID: FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From jeanpierreda at gmail.com Sun Nov 13 01:28:31 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 13 Nov 2011 01:28:31 -0500 Subject: all() is slow? In-Reply-To: <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: > which implies that getattr(x, 'a!b') should be equivalent to x.a!b No, it does not. The documentation states equivalence for two particular values, and there is no way to deduce truth for all cases from that. In fact, if it _was_ trying to say it was true for any attribute value, then your example would be proof that the documentation is incorrect, since CPython breaks that equivalence. Devin On Fri, Nov 11, 2011 at 8:18 PM, Steven D'Aprano wrote: > On Thu, 10 Nov 2011 23:35:32 -0500, Devin Jeanpierre wrote: > >>> That is patently untrue. If you were implementing namedtuple without >>> exec, you would still (or at least you *should*) prevent the user from >>> passing invalid identifiers as attribute names. What's the point of >>> allowing attribute names you can't actually *use* as attribute names? >> >> Then why doesn't Python do this anywhere else? e.g. why can I >> setattr(obj, 'a#b') when obj is any other mutable type? > > That is implementation-specific behaviour and not documented behaviour > for Python. If you try it in (say) IronPython or Jython, you may or may > not see the same behaviour. > > The docs for getattr state: > > ? ?getattr(x, 'foobar') is equivalent to x.foobar > > > which implies that getattr(x, 'a!b') should be equivalent to x.a!b which > will give a syntax error. The fact that CPython does less validation is > arguably a bug and not something that you should rely on: it is *not* a > promise of the language. > > As Terry Reedy already mentioned, the namespace used in classes and > instances are ordinary generic dicts, which don't perform any name > validation. That's done for speed. Other implementations may use > namespaces that enforce legal names for attributes, and __slots__ already > does: > >>>> class X(object): > ... ? ? __slots__ = ['a', 'b!'] > ... > Traceback (most recent call last): > ?File "", line 1, in > TypeError: Error when calling the metaclass bases > ? ?__slots__ must be identifiers > > > [...] >> To go off on another tangent, though, I don't really understand how you >> guys can think this is reasonable, though. I don't get this philosophy >> of restricting inputs that would otherwise be perfectly valid > > But they aren't perfectly valid. They are invalid inputs. Just because > getattr and setattr in CPython allow you to create attributes with > invalid names doesn't mean that everything else should be equally as > slack. > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From oleg.rimko at gmail.com Sun Nov 13 03:55:16 2011 From: oleg.rimko at gmail.com (0xfn) Date: Sun, 13 Nov 2011 00:55:16 -0800 (PST) Subject: Use and usefulness of the as syntax References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> <4EBE69DA.2060501@tim.thechases.com> Message-ID: <54b0617a-3456-4878-819c-f79b388232ea@u6g2000vbg.googlegroups.com> On Nov 12, 7:48?am, Rafael Dur?n Casta?eda wrote: > El 12/11/11 13:43, Tim Chase escribi?:> ? I hate trying to track down variable-names if one did something like > > > ? from Tkinter import * > > +1 Really, this questionable code is always mentioned as example in Tkinter tuts. IMHO much better is >>> import Tkinter as tk In common case `as` is useful when: 1. You `import ThirdPartyModuleWithTerriblyLongName as tpm` 2. Whant to free some common variable name, which is engaged by module name by default (right what Mel Wilson has pictured) From anssi.kaariainen at thl.fi Sun Nov 13 07:28:16 2011 From: anssi.kaariainen at thl.fi (=?iso-8859-1?Q?K=E4=E4ri=E4inen_Anssi?=) Date: Sun, 13 Nov 2011 14:28:16 +0200 Subject: Dynamically altering __init__ In-Reply-To: References: , , Message-ID: I wrote: """ I will post a link to a complete example once I have done the AST transformations etc. I hope this will be useful to readers of this list. I didn't find such an example, so maybe the next asker will find it... """ Finally got time to do this. The example can be found at: https://github.com/akaariai/ast_model In the example I rewrote a small part of Django's model __init__ to use: self.field1, self.field2, ... = args instead of: for f_name, val in izip(field_names, args): setattr(self, f_name, val) The speedup of that rewrote is about 50% for a model having 10 fields. The example implementation might not be optimal, but it seems to work. I hope it will be useful to the readers of this list. It was a nice learning experience for me. Thanks for your help, - Anssi K??ri?inen From steve+comp.lang.python at pearwood.info Sun Nov 13 08:30:37 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Nov 2011 13:30:37 GMT Subject: How to indent blocks when readline completion is on? Message-ID: <4ebfc67c$0$29970$c3e8da3$5496439d@news.astraweb.com> I have set up readline completion as described here: http://docs.python.org/library/rlcompleter.html Now how do I indent blocks in the interactive interpreter? If I press the TAB key, the completer prompts me instead of indenting: >>> readline.parse_and_bind("tab: complete") >>> while True: ... Display all 182 possibilities? (y or n) ... Surely I'm not stuck with indenting by manually typing spaces? I thought I could add a wrapper around the rlcompleter method, like this: >>> import readline >>> import rlcompleter >>> readline.parse_and_bind("tab: complete") >>> completer = readline.get_completer() >>> def wrapped_completer(text, state): ... if not text or text.isspace(): ... return "\t" ... else: ... return completer(text, state) ... >>> readline.set_completer(wrapped_completer) Completion appears to work if I have something in the line to start with, e.g. if I type "whi" TAB "Tr" TAB I get "while True", but if I press TAB on an empty line (intending to get an actual tab character for indentation), it plays merry havoc with my session. All keyboard input appears to be dead, eventually I used Ctrl-Z to interrupt the process and killed it from the shell. -- Steven From anacrolix at gmail.com Sun Nov 13 08:32:39 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Mon, 14 Nov 2011 00:32:39 +1100 Subject: socket.socket.makefile Message-ID: I'm writing an alternative socket module, and have come across the code for the makefile call, which mentions the following: (XXX refactor to share code?) http://hg.python.org/cpython/file/27adb952813b/Lib/socket.py#l149 Has this been refactored elsewhere? Is there something I can use to wrap the SocketIO inheriting from RawIOBase in all the variants the io.open/socket.makefile functions return for me? From rosuav at gmail.com Sun Nov 13 09:40:28 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Nov 2011 01:40:28 +1100 Subject: How to indent blocks when readline completion is on? In-Reply-To: <4ebfc67c$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <4ebfc67c$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Nov 14, 2011 at 12:30 AM, Steven D'Aprano wrote: > I thought I could add a wrapper around the rlcompleter method, like this: > >>>> import readline >>>> import rlcompleter >>>> readline.parse_and_bind("tab: complete") >>>> completer = readline.get_completer() >>>> def wrapped_completer(text, state): > ... ? ? if not text or text.isspace(): > ... ? ? ? ? return "\t" > ... ? ? else: > ... ? ? ? ? return completer(text, state) > ... >>>> readline.set_completer(wrapped_completer) Attempting to duplicate this failed in my Py3 (no readline module - probably I didn't have the dev version when I built that Python), but in Py2, I can see the same issue. The wrapped_completer function is called repeatedly with successive values for 'state', and it needs to return None at some point to indicate that there are no more possibilities. (Why isn't it specced to simply return an iterable?) >>> def wrapped_completer(text, state): ... if not text or text.isspace(): ... if state: return None ... return "\t" ... else: ... return completer(text, state) ... This function appears (to me!) to do what you're looking for; it allows me to enter tabs while still using tab completion. However, I seem to have some slightly different tab-completion settings somewhere (for instance, typing "whi" produces "while" with no space after it, so I need to type " Tr" not "Tr"), so this may not work on your setup. ChrisA From jehugaleahsa at gmail.com Sun Nov 13 12:37:25 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sun, 13 Nov 2011 09:37:25 -0800 (PST) Subject: xmlrpclib date times and a trailing Z References: <7d3e9e96-687f-4081-990e-46b7bb386925@d5g2000yqg.googlegroups.com> Message-ID: <8009b627-be86-495f-85d7-8fac6522fe8d@y12g2000vba.googlegroups.com> On Nov 11, 7:20?pm, Travis Parks wrote: > I am trying to connect to Marchex's a call tracking software using > xmlrpclib. I was able to get some code working, but I ran into a > problem dealing with transfering datetimes. > > When I construct a xmlrpclib.ServerProxy, I am setting the > use_datetime flag to indicate that I want to automatically convert > back and forth between date times in the datetime library. > > I have a working version that doesn't use this flag, and I have to > convert from the xmlrpclib.DateTime type to the datetime.datetime type > manually, via string parsing. > > The thing is, Marchex's API returns date's with a trailing Z, after > the time component. I did some research and this is supposed to be an > indicator that UTC was used. However, it doesn't seem like the > xmlrpclib likes it very much. > > It looks like it is using this code internally: time.strptime(data, "%Y > %m%dT%H:%M:%S") > > This code doesn't look like it handles time zones at all. I guess, is > there a way to tell xmlrpclib to include time zones when parsing date > times? > > Thanks, > Travis Parks I did some chatting on IRC and it seems that the date/time format is not very well defined in XML RPC specs. So, basically, Marchex is using a format that the XML RPC library doesn't support. Strangely, Marchex supports incoming dates with the format yyyyMMddThhmmss. It just spits dates back out with yyyy-MM-ddThh:mm:ssZ. The ISO8601 standard seems to be used a lot, so it is surprising the library doesn't try multiple formats, at least. I find it strange that the library, in light of the fact that date formats aren't standardized, doesn't provide the ability to configure this. I also find it strange that the library doesn't incorporate Basic Authentication using urllib2, but instead rolls its own method of putting username:password@ before the netloc. I wish Python's libraries acted more like an integrated framework than just unrelated libraries. I suppose I am spoiled from years of working with all-in-one frameworks managed by a single group. That is not the way C/C++ works or how Linux works. The power generated by using a conglomeration of unrelated libraries is indisputable, even if it can be a productivity killer and just plain confusing. From wolftracks at invalid.com Sun Nov 13 12:46:18 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sun, 13 Nov 2011 09:46:18 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 Message-ID: For many months I had sporadically used 2.5.2 under Win 7, then something went awry. I tried an uninstall/install and it didn't get any better. I thought I'd take another shot at it today. The uninstall went OK, but c:\python25 remained with several py files and a folder, Lib. I went ahead with the install and got a msg that asked if I wanted to write over the python25 folder. I figured maybe I should ask about this. It's probably OK. Yes, I know I have an old version of Python, but I need it occasionally. Comments? From steve at sprangle.com Sun Nov 13 13:17:59 2011 From: steve at sprangle.com (Steve Edlefsen) Date: Sun, 13 Nov 2011 11:17:59 -0700 Subject: can't decompress data; zlib not available Message-ID: <4EC009D7.90100@sprangle.com> Hi, I'm trying to install a tool for Plone called ZopeSkel, but when I run the setup file ez_setup.py, I get dr_shred at merle:~$ ez_setup.py Downloading http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg Traceback (most recent call last): File "/home/dr_shred/python/ez_setup.py", line 279, in ? main(sys.argv[1:]) File "/home/dr_shred/python/ez_setup.py", line 213, in main from setuptools.command.easy_install import main zipimport.ZipImportError: can't decompress data; zlib not available I believe this means the python installation didn't include zlib. Python was installed with Plone and has the following config directory: dr_shred at merle:/usr/local/Plone/Python-2.6/lib/python2.6/config$ ls -l total 10208 -rw-r--r-- 1 root root 2139 2011-10-24 17:53 config.c -rw-r--r-- 1 root root 1507 2011-10-24 17:53 config.c.in -rwxr-xr-x 1 root root 7122 2011-10-24 17:53 install-sh -rw-r--r-- 1 root root 10342706 2011-10-24 17:53 libpython2.6.a -rw-r--r-- 1 root root 42568 2011-10-24 17:53 Makefile -rwxr-xr-x 1 root root 7431 2011-10-24 17:53 makesetup -rw-r--r-- 1 root root 6528 2011-10-24 17:53 python.o -rw-r--r-- 1 root root 18265 2011-10-24 17:53 Setup -rw-r--r-- 1 root root 368 2011-10-24 17:53 Setup.config -rw-r--r-- 1 root root 41 2011-10-24 17:53 Setup.local There's no readme file, or anything to describe how it all works. The Setup file has an entry zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz which appears to install zlib when python is reinstalled. Except I can't run make without errors and there is no configuration file. How do I reinstall python to include zlib? Many Thanks, Steve Edlefsen From jason.swails at gmail.com Sun Nov 13 13:27:05 2011 From: jason.swails at gmail.com (Jason Swails) Date: Sun, 13 Nov 2011 13:27:05 -0500 Subject: (n00b) Tkinter trouble Message-ID: Hello, I'm trying my hand at creating a Tkinter application, but not having much luck. I'm trying to have my top level window be a series of buttons with different options on them. Every time a button is pressed, it opens up a new window with options. While that new window is open, all of the buttons on the original window are disabled. However, I want all of those buttons to become active again once I quit my new window. I can't seem to reactivate those buttons no matter what I do. This is the approach I'm trying: #!/usr/bin/env python from Tkinter import * class ActionButton(Button): def __init__(self, frame, text): self.frame = frame Button.__init__(self, master=self.frame, text=text, command=self.execute) def execute(self): window = Toplevel() new_button = ActionButton(window, '2nd level button') quit_button = Button(window, text='Quit!', command=window.destroy) window.buttons = [new_button, quit_button] for button in window.buttons: button.pack() # Deactivate buttons from containing shell for button in self.frame.buttons: button.config(state=DISABLED) window.mainloop() for button in self.frame.buttons: button.config(state=ACTIVE) top = Tk() top_button = ActionButton(top, 'Button on top!') top_button.pack() quit_button = Button(top, text='Quit', command=top.destroy) quit_button.pack() top.buttons = [top_button, quit_button] top.mainloop() I'm really kind of running around in the dark here, so any advice or explanation is appreciated. Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From irmen at -NOSPAM-xs4all.nl Sun Nov 13 14:08:32 2011 From: irmen at -NOSPAM-xs4all.nl (Irmen de Jong) Date: Sun, 13 Nov 2011 20:08:32 +0100 Subject: Uninstalling Py 2.5.2 from Windows 7 In-Reply-To: References: Message-ID: <4ec015b0$0$6927$e4fe514c@news2.news.xs4all.nl> On 13-11-11 18:46, W. eWatson wrote: > For many months I had sporadically used 2.5.2 under Win 7, then > something went awry. I tried an uninstall/install and it didn't get any > better. I thought I'd take another shot at it today. The uninstall went > OK, but c:\python25 remained with several py files and a folder, Lib. I > went ahead with the install and got a msg that asked if I wanted to > write over the python25 folder. > > I figured maybe I should ask about this. It's probably OK. Yes, I know I > have an old version of Python, but I need it occasionally. > > Comments? Just go ahead and manually delete c:\python25 and everything in it. But make sure that the leftover stuff in there is something you won't need again, or that you can get back by re-installing the third party library that it was part of. Then re-install from the 2.5.2 msi. (Or perhaps 2.5.4). Irmen From tim.wintle at teamrubber.com Sun Nov 13 16:55:05 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Sun, 13 Nov 2011 21:55:05 +0000 Subject: can't decompress data; zlib not available In-Reply-To: <4EC009D7.90100@sprangle.com> References: <4EC009D7.90100@sprangle.com> Message-ID: <1321221305.12661.6.camel@tim-laptop> On Sun, 2011-11-13 at 11:17 -0700, Steve Edlefsen wrote: > > which appears to install zlib when python is reinstalled. Except I > can't run make without errors and there is no configuration file. > > How do I reinstall python to include zlib? Which OS are you on? Linux? BSD? How did you install Plone? First I'd check if there's a module shadowing the builtin zlib module - i.e. if you've got a local file called "zlib.py" which is getting imported by mistake. Fairly much all *nix systems will have a python installation out of the box - it looks like you need python2.6 I've never had a missing zlib module - but it's possible that it might be missing if you don't have the zlib/deflate headers installed - if they're not available then I'd try installing them and then reinstalling the package you started with. Tim Wintle From tjreedy at udel.edu Sun Nov 13 17:08:53 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Nov 2011 17:08:53 -0500 Subject: Uninstalling Py 2.5.2 from Windows 7 In-Reply-To: References: Message-ID: On 11/13/2011 12:46 PM, W. eWatson wrote: > For many months I had sporadically used 2.5.2 under Win 7, then > something went awry. I tried an uninstall/install and it didn't get any > better. I thought I'd take another shot at it today. The uninstall went > OK, but c:\python25 remained with several py files and a folder, Lib. I > went ahead with the install and got a msg that asked if I wanted to > write over the python25 folder. Uninstall (should) only uninstall files that it installed and directories that are empty. The 'several py files' should be files that you or some third-party software installed. I personally put everything I write under /pythonxy in a subdirectory thereof that install and uninstall pay no attention to. The Lib directory contains all the python-coded stdlib modules. Unless you know there is something that you wrote that you want, I would delete it before re-installing. I suspect that current installers work a bit better than 2.5. I would definitely use the latest 2.5.z that comes with an installer and not 2.5.2. They are all the same version of the language. The only difference is bug fixes. -- Terry Jan Reedy From tjreedy at udel.edu Sun Nov 13 17:16:38 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Nov 2011 17:16:38 -0500 Subject: Use and usefulness of the as syntax In-Reply-To: <54b0617a-3456-4878-819c-f79b388232ea@u6g2000vbg.googlegroups.com> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> <4EBE69DA.2060501@tim.thechases.com> <54b0617a-3456-4878-819c-f79b388232ea@u6g2000vbg.googlegroups.com> Message-ID: On 11/13/2011 3:55 AM, 0xfn wrote: > On Nov 12, 7:48 am, Rafael Dur?n Casta?eda > wrote: >> El 12/11/11 13:43, Tim Chase escribi?:> I hate trying to track down variable-names if one did something like >> >>> from Tkinter import * >> >> +1 > > Really, this questionable code is always mentioned as example in > Tkinter tuts. I see it is still in the 3.2 tkinter doc, near the top. > IMHO much better is >>>> import Tkinter as tk My opinion also. I will think about changing it someday, but then all the examples will need to be changed ;-). So it will not be trivial. -- Terry Jan Reedy From goldtech at worldpost.com Sun Nov 13 17:37:01 2011 From: goldtech at worldpost.com (goldtech) Date: Sun, 13 Nov 2011 14:37:01 -0800 (PST) Subject: Trying to write beautifulsoup result to a file and get error message Message-ID: If I try: ... soup = BeautifulSoup(ft3) f = open(r'c:\NewFolder\clean4.html', "w") f.write(soup) f.close() I get error message: Traceback (most recent call last): File "C:\Documents and Settings\user01\Desktop\py\tb1a.py", line 203, in f.write(soup) TypeError: expected a character buffer object I want to write beautiful soup's result to a file, I am doing something wrong. Help appreciated. Thanks From python at mrabarnett.plus.com Sun Nov 13 18:31:52 2011 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 13 Nov 2011 23:31:52 +0000 Subject: Trying to write beautifulsoup result to a file and get error message In-Reply-To: References: Message-ID: <4EC05368.1060408@mrabarnett.plus.com> On 13/11/2011 22:37, goldtech wrote: > If I try: > ... > soup = BeautifulSoup(ft3) > f = open(r'c:\NewFolder\clean4.html', "w") > f.write(soup) > f.close() > > I get error message: > > Traceback (most recent call last): > File "C:\Documents and Settings\user01\Desktop\py\tb1a.py", line > 203, in > f.write(soup) > TypeError: expected a character buffer object > > I want to write beautiful soup's result to a file, I am doing > something wrong. Help appreciated. > What do you mean by "beautiful soup's result"? The original HTML is text, and you want it to write some text to the file, but what exactly are you expecting it to write? From wolftracks at invalid.com Sun Nov 13 19:06:50 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sun, 13 Nov 2011 16:06:50 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 In-Reply-To: References: Message-ID: On 11/13/2011 2:08 PM, Terry Reedy wrote: > On 11/13/2011 12:46 PM, W. eWatson wrote: >> For many months I had sporadically used 2.5.2 under Win 7, then >> something went awry. I tried an uninstall/install and it didn't get any >> better. I thought I'd take another shot at it today. The uninstall went >> OK, but c:\python25 remained with several py files and a folder, Lib. I >> went ahead with the install and got a msg that asked if I wanted to >> write over the python25 folder. > > Uninstall (should) only uninstall files that it installed and > directories that are empty. The 'several py files' should be files that > you or some third-party software installed. I personally put everything > I write under /pythonxy in a subdirectory thereof that install and > uninstall pay no attention to. The Lib directory contains all the > python-coded stdlib modules. Unless you know there is something that you > wrote that you want, I would delete it before re-installing. > > I suspect that current installers work a bit better than 2.5. I would > definitely use the latest 2.5.z that comes with an installer and not > 2.5.2. They are all the same version of the language. The only > difference is bug fixes. > Thanks to both of you. Deleting python25 folder. Nothing of personal use in it. From wolftracks at invalid.com Sun Nov 13 19:17:11 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sun, 13 Nov 2011 16:17:11 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 In-Reply-To: References: Message-ID: Well, let be a careful a little more. I have PIL, numpy, scipy, pymatplotlib and pyephem installed, I think. There are Remove....exe files in the python25 folder for them. There's also a Removepy2exe.exe. Probably that was somehow used to get out py2.5. From kwa at kuwata-lab.com Sun Nov 13 19:27:35 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Mon, 14 Nov 2011 09:27:35 +0900 Subject: [ANN] PikoTest.py - a small testing library Message-ID: I released PikoTest.py 0.1.0. http://pypi.python.org/pypi/PicoTest PikoTest.py is a samll testing library for Python. Features: * Structured Test * Setup/Teardown * Fixture Injection * Skip Test * TODO Example:: from __future__ import with_statement import picotest test = picotest.new() with test("type 'str'"): with test("operator '*'"): @test("repeats string N times.") def _(self): self.assertEqual("AAA", "A" * 3) @test("returns empty string when N is negative.") def _(self): self.assertEqual("", "A" * -1) if __name__ == '__main__': picotest.main() Output example:: $ python -m picotest -h # show help $ python example_test.py # or python -m picotest example_test.py #### example_test.py * type 'str' * operator '*' - [passed] repeats string N times. - [passed] returns empty string when N is negative. ## total:2, passed:2, failed:0, error:0, skipped:0, todo:0 See http://pypi.python.org/pypi/PicoTest for details. -- regards, makoto kuwata From vugluskr at vugluskr.org.ua Sun Nov 13 19:58:44 2011 From: vugluskr at vugluskr.org.ua (=?UTF-8?B?0JHQvtCz0YPQvSDQlNC80LjRgtGA0LjQuQ==?=) Date: Mon, 14 Nov 2011 02:58:44 +0200 Subject: Slave to master auto linking. Message-ID: <4EC067C4.7040009@vugluskr.org.ua> Hello. I try make some weird thing. I want to get from code like this: class master: ... class slave: ... m = master() s = m.slave() s.master is m Last expression must be true. I want link "master" to be set automatically by master object while creating slave object. Additional requirement - "master" link must be available for constructor of slave object. Best what I can get is: import functools from weakref import WeakKeyDictionary from threading import RLock class meth_wrap(object): def __init__(self, func): object.__init__(self) self.func = func functools.update_wrapper(self, func, updated=()) class lazy_attr(meth_wrap): def __get__(self, obj, type=None): if obj is None: return self val = self.func(obj) setattr(obj, self.__name__, val) return val class slave_mixin(object): @lazy_attr def master(self): m = slave_gen._unbound_master assert m is not None, '"Slave" object can\'t find master link. Is it was correctly created? obj:%s' % repr(self) return m class slave_gen(meth_wrap): _storage = WeakKeyDictionary() # ???????????? ????????? _unbound_master = None _lock = RLock() def __get__(self, mobj, type=None): if mobj is None: return self.func d = { 'm': mobj, 'w': self} obj = self.delay_init() self._storage[obj] = d functools.update_wrapper(obj, self.func, updated=()) return obj class delay_init(object): def __call__(self, *args, **kw_args): d = slave_gen._storage[self] slave_gen._lock.acquire() try: slave_gen._unbound_master = d['m'] obj = d['w'].func(*args, **kw_args) obj.master = d['m'] slave_gen._unbound_master = None finally: slave_gen._lock.release() return obj def __getattr__(self, attr): d = slave_gen._storage[self] return getattr(d['m'], attr) def __setattr__(self, attr, val): d = slave_gen._storage[self] return setattr(d['m'], attr, val) class Master(object): @slave_gen class Slave(slave_mixin): def __init__(self): slave_mixin.__init__(self) print 'Slave.__init__: self.master: ', self.master if __name__ == '__main__': m = Master() s = m.Slave() print 's.master: ', s.master It works, by looking little weird... and I can't find way to escape from using lock at object creation phase. It can be done by adding mandatory attribute to slave class constructor, but this is even worse(for me) than using lock. Please show me more clear way to make this slave to master link. PS Sorry for my English. -- ????? ??????? aka vugluskr From rosuav at gmail.com Sun Nov 13 21:15:05 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Nov 2011 13:15:05 +1100 Subject: Slave to master auto linking. In-Reply-To: <4EC067C4.7040009@vugluskr.org.ua> References: <4EC067C4.7040009@vugluskr.org.ua> Message-ID: 2011/11/14 ????? ??????? : > m = master() > s = m.slave() > s.master is m > Can you simply have m.slave() pass a parameter to the slave's constructor? class Master(object): class Slave(object): def __init__(self,master): self.master=master print 'Slave.__init__: self.master: ', self.master def slave(self): return self.Slave(self) Alternatively, you don't have to nest the classes at all: class Slave(object): def __init__(self,master): self.master=master print 'Slave.__init__: self.master: ', self.master class Master(object): def slave(self): return Slave(self) By passing 'self' to the Slave() constructor, I give the slave a chance to keep a reference to its own master. Chris Angelico From wuwei23 at gmail.com Sun Nov 13 21:50:33 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 13 Nov 2011 18:50:33 -0800 (PST) Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2b46d46c-f66d-4a13-8c0b-af9b6c638863@h30g2000pro.googlegroups.com> On Nov 13, 4:28?pm, Devin Jeanpierre wrote: > > which implies that getattr(x, 'a!b') should be equivalent to x.a!b > > No, it does not. The documentation states equivalence for two > particular values It states equivalence for two values _based on the name_. "If the string is the name of one of the object?s attributes, the result is the value of that attribute. For example, getattr(x, 'foobar') is equivalent to x.foobar." The string 'a!b' is the name of the attribute, ergo getattr(x, 'a!b') _is_ x.a!b. If x.a!b isn't valid CPython, then etc. > CPython breaks that equivalence So you're outright ignoring the comments that this behaviour is to make CPython more performant? From jeanpierreda at gmail.com Sun Nov 13 23:48:45 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 13 Nov 2011 23:48:45 -0500 Subject: all() is slow? In-Reply-To: <2b46d46c-f66d-4a13-8c0b-af9b6c638863@h30g2000pro.googlegroups.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> <2b46d46c-f66d-4a13-8c0b-af9b6c638863@h30g2000pro.googlegroups.com> Message-ID: > It states equivalence for two values _based on the name_. I don't know what you mean. "Based on the name" doesn't mean anything in particular to me in this context. > So you're outright ignoring the comments that this behaviour is to > make CPython more performant? I don't see how I'm ignoring the comment. Yes, breaking the spec improves performance. Is that a reason to not fix the spec, or something? Devin On Sun, Nov 13, 2011 at 9:50 PM, alex23 wrote: > On Nov 13, 4:28?pm, Devin Jeanpierre wrote: >> > which implies that getattr(x, 'a!b') should be equivalent to x.a!b >> >> No, it does not. The documentation states equivalence for two >> particular values > > It states equivalence for two values _based on the name_. > > "If the string is the name of one of the object?s attributes, the > result is the value of that attribute. For example, getattr(x, > 'foobar') is equivalent to x.foobar." > > The string 'a!b' is the name of the attribute, ergo getattr(x, 'a!b') > _is_ x.a!b. If x.a!b isn't valid CPython, then etc. > >> CPython breaks that equivalence > > So you're outright ignoring the comments that this behaviour is to > make CPython more performant? > -- > http://mail.python.org/mailman/listinfo/python-list > From wolftracks at invalid.com Mon Nov 14 00:19:22 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sun, 13 Nov 2011 21:19:22 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) In-Reply-To: References: Message-ID: I just pushed aside the python25 folder by renaming it, and installed py 2.5.2. However, when I try to open the simplest of py programs with IDLE, I get an error from Win7. c:\Users\blah\...\junk.py is not a valid Win 32 app. Here's one: def abc(one): print "abc: ", one, " is one" def duh(two): print "duh: ",abc(2) abc(1) duh(2) duh("so what") abc(36.333) From wuwei23 at gmail.com Mon Nov 14 00:42:59 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 13 Nov 2011 21:42:59 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: On Nov 11, 11:31 pm, macm wrote: > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > print k1 > print k2 > > There is a fast way (trick) to get k1 and k2 as string. It might be possible to do something using a reverse dictionary and getting rid of the nested dictionary. This is a quick and simple 'two-way' dictionary class that works by maintaining two dictionaries: the original key/value, and the reversed value/key. It returns a list of keys, allowing for a value to be assigned against more than from collections import defaultdict class TwoWayDict(dict): def __init__(self, *args, **kwargs): self._reversed = defaultdict(list) for key, val in kwargs.iteritems(): self[key] = val def __setitem__(self, key, value): super(TwoWayDict, self).__setitem__(key, value) self._reversed[value].append(key) def getkeys(self, match): return self._reversed[match] >>> original = TwoWayDict(a=100,b='foo',c=int,d='foo') >>> original.getkeys(100) ['a'] >>> original.getkeys('foo') ['b', 'd'] As for the nested dictionary, you could replace it with a _single_ dictionary that uses a composite key: >>> original = TwoWayDict(a=100,b=100) >>> original.getkeys(100) ['a', 'b'] >>> original = TwoWayDict() >>> original['record1','user1'] = 'martin' >>> original['record1','user2'] = 'robert' >>> original['record2','user1'] = 'robert' >>> original.getkeys('robert') [('record1', 'user2'), ('record2', 'user1')] > Whithout loop all dict. Just it! The TwoWayDict class removes the need to loop across the dict looking for keys that match a value by replacing it with another dict lookup. Reducing the nested dict to a single dict with composite keys removes the need to traverse the outer dict to compare against its children. From wuwei23 at gmail.com Mon Nov 14 00:44:25 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 13 Nov 2011 21:44:25 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: On Nov 11, 11:31 pm, macm wrote: > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > print k1 > print k2 > > There is a fast way (trick) to get k1 and k2 as string. It might be possible to do something using a reverse dictionary and getting rid of the nested dictionary. This is a quick and simple 'two-way' dictionary class that works by maintaining two dictionaries: the original key/value, and the reversed value/key. It returns a list of keys, allowing for a value to be assigned against more than from collections import defaultdict class TwoWayDict(dict): def __init__(self, *args, **kwargs): self._reversed = defaultdict(list) for key, val in kwargs.iteritems(): self[key] = val def __setitem__(self, key, value): super(TwoWayDict, self).__setitem__(key, value) self._reversed[value].append(key) def getkeys(self, match): return self._reversed[match] >>> original = TwoWayDict(a=100,b='foo',c=int,d='foo') >>> original.getkeys(100) ['a'] >>> original.getkeys('foo') ['b', 'd'] As for the nested dictionary, you could replace it with a _single_ dictionary that uses a composite key: >>> original = TwoWayDict(a=100,b=100) >>> original.getkeys(100) ['a', 'b'] >>> original = TwoWayDict() >>> original['record1','user1'] = 'martin' >>> original['record1','user2'] = 'robert' >>> original['record2','user1'] = 'robert' >>> original.getkeys('robert') [('record1', 'user2'), ('record2', 'user1')] > Whithout loop all dict. Just it! The TwoWayDict class removes the need to loop across the dict looking for keys that match a value by replacing it with another dict lookup. Reducing the nested dict to a single dict with composite keys removes the need to traverse the outer dict to compare against its children. From jason.swails at gmail.com Mon Nov 14 02:11:45 2011 From: jason.swails at gmail.com (Jason Swails) Date: Mon, 14 Nov 2011 02:11:45 -0500 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Sun, Nov 13, 2011 at 1:27 PM, Jason Swails wrote: > Hello, > > I'm trying my hand at creating a Tkinter application, but not having much > luck. I'm trying to have my top level window be a series of buttons with > different options on them. Every time a button is pressed, it opens up a > new window with options. While that new window is open, all of the buttons > on the original window are disabled. However, I want all of those buttons > to become active again once I quit my new window. I can't seem to > reactivate those buttons no matter what I do. > > This is the approach I'm trying: > > #!/usr/bin/env python > > from Tkinter import * > > class ActionButton(Button): > def __init__(self, frame, text): > self.frame = frame > Button.__init__(self, master=self.frame, text=text, > command=self.execute) > def execute(self): > window = Toplevel() > new_button = ActionButton(window, '2nd level button') > quit_button = Button(window, text='Quit!', command=window.destroy) > window.buttons = [new_button, quit_button] > for button in window.buttons: button.pack() > # Deactivate buttons from containing shell > for button in self.frame.buttons: button.config(state=DISABLED) > window.mainloop() > for button in self.frame.buttons: button.config(state=ACTIVE) > > > top = Tk() > top_button = ActionButton(top, 'Button on top!') > top_button.pack() > quit_button = Button(top, text='Quit', command=top.destroy) > quit_button.pack() > > top.buttons = [top_button, quit_button] > > top.mainloop() > > I'm really kind of running around in the dark here, so any advice or > explanation is appreciated. > Another approach I think will work, and that I'm going to try, is to subclass Toplevel and simply assign the higher-level frame/window as an instance attribute. Then, I can reactivate all of the buttons in the destroy() method before calling the destroy() method of Toplevel on self. Something like this: [untested] class MyToplevel(Toplevel): def __init__(self, root, **options): self.root = root Toplevel.__init__(self, options) for button in self.root.buttons: button.config(state=DISABLED) def destroy(self): for button in self.root.buttons: button.config(state=ACTIVE) Toplevel.destroy(self) This allows me to avoid running "mainloop()" on a non-root Toplevel instance, but links the re-activation of the buttons with the destruction of the child window (which was the effect I was going for). I must not understand what mainloop() does, fully (does it only make sense to run it on Tkinter.Tk()?) Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Nov 14 03:49:03 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Nov 2011 19:49:03 +1100 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Mon, Nov 14, 2011 at 6:11 PM, Jason Swails wrote: > Then, I can reactivate all of the buttons in the destroy() method before > calling the destroy() method of Toplevel on self. Small side point that might save you some work: Instead of disabling and enabling all the buttons, disable the whole window. I don't know Tkinter well enough to know if there's an easy way to create a modal window, but the thing to do is to disable the entire window rather than just its command buttons - that's the least astonishing[1] user interface technique. ChrisA [1] http://en.wikipedia.org/wiki/Principle_of_least_astonishment From mcepl at redhat.com Mon Nov 14 05:05:40 2011 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 14 Nov 2011 11:05:40 +0100 Subject: Multilevel dicts/arrays v. tuples as keys? [Was: Re: Get keys from a dicionary] In-Reply-To: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: Dne 11.11.2011 14:31, macm napsal(a): > def Dicty( dict[k1][k2] ): When looking at this I returned to the question which currently rolls in my mind: What's difference/advantage-disadvantage betweeng doing multi-level dicts/arrays like this and using tuple as a key? I.e., is it more Pythonic to have dict[k1,k2] instead? Best, Mat?j From affdfsdfdsfsd at b.com Mon Nov 14 05:41:52 2011 From: affdfsdfdsfsd at b.com (Tracubik) Date: 14 Nov 2011 10:41:52 GMT Subject: my new project, is this the right way? Message-ID: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Hi all, i'm developing a new program. Mission: learn a bit of database management Idea: create a simple, 1 window program that show me a db of movies i've seen with few (<10) fields (actors, name, year etc) technologies i'll use: python + gtk db: that's the question since i'm mostly a new-bye for as regard databases, my idea is to use sqlite at the beginning. Is that ok? any other db to start with? (pls don't say mysql or similar, they are too complex and i'll use this in a second step) is there any general tutorial of how to start developing a database? i mean a general guide to databases you can suggest to me? Thank you all MedeoTL P.s. since i have a ods sheet files (libreoffice calc), is there a way to easily convert it in a sqlite db? (maybe via csv) From mail at timgolden.me.uk Mon Nov 14 05:42:50 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 14 Nov 2011 10:42:50 +0000 Subject: Multilevel dicts/arrays v. tuples as keys? [Was: Re: Get keys from a dicionary] In-Reply-To: References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: <4EC0F0AA.4060003@timgolden.me.uk> On 14/11/2011 10:05, Matej Cepl wrote: > Dne 11.11.2011 14:31, macm napsal(a): >> def Dicty( dict[k1][k2] ): > > When looking at this I returned to the question which currently rolls in > my mind: > > What's difference/advantage-disadvantage betweeng doing multi-level > dicts/arrays like this and using tuple as a key? I.e., is it more > Pythonic to have > > dict[k1,k2] > > instead? For me, it would depend on what the data meant. To give an obvious example: if you were storing things which were based on coords, then clearly map[x, y] is more meaningful than map[x][y]. Conversely, if your dictionary structure was, say, a set of preferences for users, then prefs[username][prefname] is probably a more useful model. Sometimes it's not so clear, in which case one person might opt for one approach while another opted for another while modelling the same data concepts. If, for example, you were modelling a set of book reviews where each review might have one or more genres (which you could display as a tag-cloud, say) then you could consider the model to be a sort of book-genre tag cloud: book_genres[title, genre] or a list of books in each genre: genres[genre][title] or a list of genres for each book: books[title][genre] or even multiple ways if that made it easier to use in one situation or another. Stating-the-obvious-ly yours, TJG From __peter__ at web.de Mon Nov 14 05:47:58 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 14 Nov 2011 11:47:58 +0100 Subject: Multilevel dicts/arrays v. tuples as keys? References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: Matej Cepl wrote: > Dne 11.11.2011 14:31, macm napsal(a): >> def Dicty( dict[k1][k2] ): > > When looking at this I returned to the question which currently rolls in > my mind: > > What's difference/advantage-disadvantage betweeng doing multi-level > dicts/arrays like this and using tuple as a key? I.e., is it more > Pythonic to have > > dict[k1,k2] > > instead? If you need lookup only I'd prefer tuples, but sometimes you may want to retrieve all values with a certain k1 and d[k1] is certainly more efficient than [(k2, v) for (k1, k2), v in d.items() if k1 == wanted] From rosuav at gmail.com Mon Nov 14 05:55:43 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Nov 2011 21:55:43 +1100 Subject: my new project, is this the right way? In-Reply-To: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: On Mon, Nov 14, 2011 at 9:41 PM, Tracubik wrote: > Hi all, > i'm developing a new program. > Mission: learn a bit of database management If your goal is to learn about databasing, then I strongly recommend a real database engine. > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) The complexity, in most cases, is a direct consequence of the job at hand. I recommend PostgreSQL generally, although I've never used it with Python and can't speak for the quality of the APIs. The most important thing to consider is a separation of the back end (the "guts") from the front end (the "interface"). Since your goal is to explore databases, the guts of your code will basically just be working with the database (no heavy computation or anything). Make sure you can work with that, separately from your GUI. You may find it easier to dispense with GTK and just work through the console; you can always change later to make a pretty window. If you've never worked with databases before, it may be best to skip Python altogether and explore the fundamentals of relational database engines. There's plenty of excellent tutorials on the web. Get to know how things are done generally, and you'll be able to figure out how things are done in Python. All the best! ChrisA From andreas.perstinger at gmx.net Mon Nov 14 07:06:00 2011 From: andreas.perstinger at gmx.net (Andreas Perstinger) Date: Mon, 14 Nov 2011 13:06:00 +0100 Subject: Trying to write beautifulsoup result to a file and get error message In-Reply-To: References: Message-ID: <4EC10428.10603@gmx.net> On 2011-11-13 23:37, goldtech wrote: > If I try: > ... > soup = BeautifulSoup(ft3) > f = open(r'c:\NewFolder\clean4.html', "w") > f.write(soup) > f.close() > > I get error message: > > Traceback (most recent call last): > File "C:\Documents and Settings\user01\Desktop\py\tb1a.py", line > 203, in > f.write(soup) > TypeError: expected a character buffer object > > I want to write beautiful soup's result to a file, I am doing > something wrong. Help appreciated. BeautifulSoup takes a html document in the form of a string or file-like oject and creates an internal data-structure after parsing it: Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from BeautifulSoup import BeautifulSoup >>> html = "Demo" >>> soup = BeautifulSoup(html) >>> type(soup) To write the modified document into a file, you have to convert this structur back into a string: >>> new_html = str(soup) >>> type(new_html) >>> new_html '\n \n Demo\n \n' HTH, Andreas From love_ram2040 at yahoo.com Mon Nov 14 08:48:18 2011 From: love_ram2040 at yahoo.com (porxy) Date: Mon, 14 Nov 2011 05:48:18 -0800 (PST) Subject: new cars2011,2012,2013 Message-ID: <3976750c-d558-4c41-a492-4e4d70a6af64@p2g2000vbj.googlegroups.com> Honda Insight (2012) http://newscarsblogspotcom.blogspot.com/#!/2011/11/honda-insight-2012... Audi A2 concept (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/audi-a2-concept-20... Infiniti FX designed by Sebastian Vettel (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/infiniti-fx-design... Smart Forvision concept (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/smart-forvision-co... Honda Civic (2012) http://newscarsblogspotcom.blogspot.com/#!/2011/11/honda-civic-2012.html Ford Evos concept car (2011) news and pictures http://newscarsblogspotcom.blogspot.com/#!/2011/11/ford-evos-concept-... Fiat Panda (2012) http://newscarsblogspotcom.blogspot.com/#!/2011/11/fiat-panda-2012.html Peugeot HX1 concept car (2011) first news more picsere http://newscarsblogspotcom.blogspot.com/#!/2011/11/peugeot-hx1-concep... Citroen Tubik concept car (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/citroen-tubik-conc... Skoda MissionL concept car (2011) unveiled http://newscarsblogspotcom.blogspot.com/#!/2011/11/skoda-missionl-con... Audi A5 DTM (2012) http://newscarsblogspotcom.blogspot.com/#!/2011/11/audi-a5-dtm-2012.html Lambo Super Trofeo Stradale (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/lambo-super-trofeo... Mercedes SLK55 AMG (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/mercedes-slk55-amg... Lotus Exige S (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/lotus-exige-s-2011... Ford Fiesta ST concept (2011) at the Frankfurt motor show http://newscarsblogspotcom.blogspot.com/#!/2011/11/ford-fiesta-st-con... From gordon at panix.com Mon Nov 14 10:24:04 2011 From: gordon at panix.com (John Gordon) Date: Mon, 14 Nov 2011 15:24:04 +0000 (UTC) Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) References: Message-ID: In "W. eWatson" writes: > I just pushed aside the python25 folder by renaming it, and installed py > 2.5.2. However, when I try to open the simplest of py programs with > IDLE, I get an error from Win7. > c:\Users\blah\...\junk.py is not a valid Win 32 app. Are you double-clicking on the .py file? What application is associated with .py files? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From wolftracks at invalid.com Mon Nov 14 10:42:27 2011 From: wolftracks at invalid.com (W. eWatson) Date: Mon, 14 Nov 2011 07:42:27 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) In-Reply-To: References: Message-ID: On 11/14/2011 7:24 AM, John Gordon wrote: > In "W. eWatson" writes: > >> I just pushed aside the python25 folder by renaming it, and installed py >> 2.5.2. However, when I try to open the simplest of py programs with >> IDLE, I get an error from Win7. > >> c:\Users\blah\...\junk.py is not a valid Win 32 app. > > Are you double-clicking on the .py file? Yes. > > What application is associated with .py files? Application? Simple ones, including the one i put here that you removed to answer my question. From redcat at catfolks.net Mon Nov 14 10:47:17 2011 From: redcat at catfolks.net (Redcat) Date: 14 Nov 2011 15:47:17 GMT Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: <9icrg5F5lhU1@mid.individual.net> > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) I know it's a lot of work to learn initially, but I would recommend taking the time to install and become familiar with a database engine such as MySQL or PostgresQL. While SQLite is easy to install and easy to use, it also cuts a lot of corners and allows you to do things that would die in a real database. For example, in SQLite column types are merely suggestions; there is nothing in SQLite to keep you from storing a string in an integer field or vice versa. For example: dan at dan:~/work$ sqlite3 SQLite version 3.7.3 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table test ( ...> id int, ...> name varchar(64), ...> comment varchar(256) ...> ); sqlite> .schema test CREATE TABLE test ( id int, name varchar(64), comment varchar(256) ); sqlite> insert into test values (1, 'Dan', 'Normal insert with valid types'); sqlite> insert into test values ('Bogosity', 2, 'Record with invalid types'); sqlite> insert into test values ('This field should be an int but is really a long string instead', 12.45, 'A really screwy record'); sqlite> select * from test; 1|Dan|Normal insert with valid types Bogosity|2|Record with invalid types This field should be an int but is really a long string instead|12.45|A really screwy record sqlite> This is not to say that SQLite is useless. Far from it - I use it frequently myself. But I've been working with SQL databases for a bunch of years, and I am familiar with the tradeoffs involved in working with SQLite. A decent tutorial on working with SQL in general can be found at http:// www.w3schools.com/sql/sql_intro.asp Installing MySQL or Postgres can be fairly simple, if you use the tools provided with your Linux distro (assuming you're running on Linux). "sudo apt-get install mysql mysql-server" or "yum install mysql mysql-server" should get you what you need to start using MySQL, "sudo apt-get install postgresql" or "yum install postgresql" should get you started with PostgresQL. From tobias.oberstein at tavendo.de Mon Nov 14 10:57:28 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 07:57:28 -0800 Subject: Py2.7/FreeBSD: maximum number of open files Message-ID: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> I am trying to convince Python to open more than 32k files .. this is on FreeBSD. Now I know I have to set appropriate limits .. I did: $ sysctl kern.maxfiles kern.maxfiles: 204800 $ sysctl kern.maxfilesperproc kern.maxfilesperproc: 200000 $ sysctl kern.maxvnodes kern.maxvnodes: 200000 $ ulimit unlimited Here is what happens with a Python freshly built from sources .. it'll tell me I can open 200k files .. but will bail out at 32k: $ ./local/bin/python -V Python 2.7.2 $ ./local/bin/python Python 2.7.2 (default, Nov 14 2011, 16:41:56) [GCC 4.2.1 20070719 [FreeBSD]] on freebsd8 Type "help", "copyright", "credits" or "license" for more information. >>> import resource >>> resource.getrlimit(resource.RLIMIT_NOFILE) (200000L, 200000L) >>> resource.getrlimit(resource.RLIMIT_OFILE) Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'RLIMIT_OFILE' >>> import resource >>> >>> max = resource.getrlimit(resource.RLIMIT_NOFILE) >>> cnt = 0 >>> print "maximum FDs", max maximum FDs (200000L, 200000L) fds = [] while cnt < max: f = open("/tmp/test1/test_%d" % cnt, "w") f.write("test") fds.append(f) cnt += 1 if cnt % 1000 == 0: print "opened %d files" % cnt print "ok, created %d files" % cnt >>> >>> fds = [] >>> >>> while cnt < max: ... f = open("/tmp/test1/test_%d" % cnt, "w") ... f.write("test") ... fds.append(f) ... cnt += 1 ... if cnt % 1000 == 0: ... print "opened %d files" % cnt ... opened 1000 files opened 2000 files opened 3000 files opened 4000 files opened 5000 files opened 6000 files opened 7000 files opened 8000 files opened 9000 files opened 10000 files opened 11000 files opened 12000 files opened 13000 files opened 14000 files opened 15000 files opened 16000 files opened 17000 files opened 18000 files opened 19000 files opened 20000 files opened 21000 files opened 22000 files opened 23000 files opened 24000 files opened 25000 files opened 26000 files opened 27000 files opened 28000 files opened 29000 files opened 30000 files opened 31000 files opened 32000 files Traceback (most recent call last): File "", line 2, in IOError: [Errno 24] Too many open files: '/tmp/test1/test_32765' >>> print "ok, created %d files" % cnt ok, created 32765 files >>> From gordon at panix.com Mon Nov 14 11:15:45 2011 From: gordon at panix.com (John Gordon) Date: Mon, 14 Nov 2011 16:15:45 +0000 (UTC) Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) References: Message-ID: In "W. eWatson" writes: > > What application is associated with .py files? > Application? Simple ones, including the one i put here that you > removed to answer my question. Eh? I can't see anywhere that you mentioned your Windows settings as to what application is associated with .py files. (You mentioned running IDLE, but I don't see that it was given as the default application for opening .py files.) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From lists at cheimes.de Mon Nov 14 11:25:13 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 17:25:13 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> Message-ID: Am 14.11.2011 16:57, schrieb Tobias Oberstein: > I am trying to convince Python to open more than 32k files .. this is on FreeBSD. > > Now I know I have to set appropriate limits .. I did: > > $ sysctl kern.maxfiles > kern.maxfiles: 204800 > $ sysctl kern.maxfilesperproc > kern.maxfilesperproc: 200000 > $ sysctl kern.maxvnodes > kern.maxvnodes: 200000 > $ ulimit > unlimited > > Here is what happens with a Python freshly built from sources .. it'll tell me I can open 200k files .. but will bail out at 32k: I'm not familiar with BSD but Linux has similar Kernel options. The kernel options might be *global* flags to set the total upper limit of open file descriptors for the entire system, not for a single process. Also on Linux "ulimit" doesn't display the fd limit. You have to use "ulimit -n". Why do you need more than 32k file descriptors anyway? It's an insanely high amount of FDs. Most programs need less than 100 and the default value of 1024 on my Linux servers is usually high enough. I've never increased the fd limit over 8192 and our biggest installation servers more than 80 TB data in about 20 to 25 million files. Christian From tobias.oberstein at tavendo.de Mon Nov 14 11:36:37 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 08:36:37 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files In-Reply-To: References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> Message-ID: <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> > I'm not familiar with BSD but Linux has similar Kernel options. The kernel > options might be *global* flags to set the total upper limit of open file > descriptors for the entire system, not for a single process. > Also on Linux "ulimit" doesn't display the fd limit. You have to use "ulimit -n". This is a dedicated machine doing nothing else .. I'm monitoring global FD usage sysctl kern.openfiles and it's way beyond the configured limit $ ulimit -n 200000 > > Why do you need more than 32k file descriptors anyway? It's an insanely high It's not for files: This is a network service .. I tested it with up to 50k TCP connections .. however at this point, when the service tries to open a file, it'll bail out. Sockets+Files both contribute to open FDs. I need 50k sockets + 100 files. Thus, this is even more strange: the Python (a Twisted service) will happily accept 50k sockets, but as soon as you do open() a file, it'll bail out. From joncle at googlemail.com Mon Nov 14 11:37:01 2011 From: joncle at googlemail.com (Jon Clements) Date: Mon, 14 Nov 2011 08:37:01 -0800 (PST) Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: <7ce7af27-0f4d-4b17-ab44-36a192028f41@e15g2000vba.googlegroups.com> On Nov 14, 10:41?am, Tracubik wrote: > Hi all, > i'm developing a new program. > Mission: learn a bit of database management > Idea: create a simple, 1 window program that show me a db of movies i've > seen with few (<10) fields (actors, name, year etc) > technologies i'll use: python + gtk > db: that's the question > > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) > > is there any general tutorial of how to start developing a database? i > mean a general guide to databases you can suggest to me? > Thank you all > > MedeoTL > > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > easily convert it in a sqlite db? (maybe via csv) I would recommend working through the book "SQL for Dummies". I found it very clear, and slowly leads you into how to think about design, not just how to manipulate databases. Instead of using Python to start with consider using OOo Base or MS Access (retching noise), so you can use RAD to play with structure and manipulation of your data and create data-entry forms -- this'll allow you to enter data, and play with queries and the structure -- as you won't get it right the first time! You will be able to get either of these programs to give you the SQL that constructs tables, or makes queries etc... That'd be enough to keep you going for a couple of weeks I guess. Also, some things make more sense in a NoSQL database, so have a look at something like MongoDB or CouchDB and how their design works differently. That's probably another couple of weeks. Also worth checking out would be http://dabodev.com hth Jon. From lists at cheimes.de Mon Nov 14 11:51:23 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 17:51:23 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> Message-ID: <4EC1470B.90403@cheimes.de> Am 14.11.2011 17:36, schrieb Tobias Oberstein: > This is a dedicated machine doing nothing else .. I'm monitoring global FD usage > > sysctl kern.openfiles > > and it's way beyond the configured limit > > $ ulimit -n > 200000 Apparently you did everything right here. Well, it was worth the try. ;) > It's not for files: > > This is a network service .. I tested it with up to 50k TCP connections .. however > at this point, when the service tries to open a file, it'll bail out. > > Sockets+Files both contribute to open FDs. > > I need 50k sockets + 100 files. > > Thus, this is even more strange: the Python (a Twisted service) will happily > accept 50k sockets, but as soon as you do open() a file, it'll bail out. A limit of 32k smells like a overflow in a signed int. Perhaps your system is able and configured to handle more than 32k FDs but you hit an artificial limit because some C code or API has a overflow. This seems to be a known bug in FreeBSD http://lists.freebsd.org/pipermail/freebsd-bugs/2010-July/040689.html Christian From tobias.oberstein at tavendo.de Mon Nov 14 12:03:46 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 09:03:46 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <4EC1470B.90403@cheimes.de> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> Message-ID: <634914A010D0B943A035D226786325D42D0C2647EB@EXVMBX020-12.exch020.serverdata.net> > > I need 50k sockets + 100 files. > > > > Thus, this is even more strange: the Python (a Twisted service) will > > happily accept 50k sockets, but as soon as you do open() a file, it'll bail out. > > A limit of 32k smells like a overflow in a signed int. Perhaps your system is > able and configured to handle more than 32k FDs but you hit an artificial limit > because some C code or API has a overflow. This seems to be a known bug in > FreeBSD http://lists.freebsd.org/pipermail/freebsd-bugs/2010- > July/040689.html This is unbelievable. I've just tested: the bug (in libc) is still there on FreeBSD 8.2 p3 ... both on i386 _and_ amd64. Now I'm f***d;( A last chance: is it possible to compile Python for not using libc fopen(), but the Posix open()? Thanks anyway for this hint! From lists at cheimes.de Mon Nov 14 12:13:12 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 18:13:12 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C2647EB@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C2647EB@EXVMBX020-12.exch020.serverdata.net> Message-ID: <4EC14C28.2020106@cheimes.de> Am 14.11.2011 18:03, schrieb Tobias Oberstein: > This is unbelievable. > > I've just tested: the bug (in libc) is still there on FreeBSD 8.2 p3 ... both on i386 > _and_ amd64. > > Now I'm f***d;( > > A last chance: is it possible to compile Python for not using libc fopen(), > but the Posix open()? > > Thanks anyway for this hint! A fix would break the ABI compatibility. I guess that you won't see a fix for the issue until FreeBSD 9.0 is released. And no, you can't re-compile Python to use the open() API instead of fopen(). The built-in file type is developed around the file pointer API, not the file descriptor API. Luckily Python 2.7 has a backport of Python 3.x new IO library. The new IO API doesn't use file pointers at all and implements its own layer around file descriptors. Good luck! Christian From wolftracks at invalid.com Mon Nov 14 12:31:47 2011 From: wolftracks at invalid.com (W. eWatson) Date: Mon, 14 Nov 2011 09:31:47 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) In-Reply-To: References: Message-ID: On 11/14/2011 8:15 AM, John Gordon wrote: > In "W. eWatson" writes: > >>> What application is associated with .py files? > >> Application? Simple ones, including the one i put here that you >> removed to answer my question. > > Eh? I can't see anywhere that you mentioned your Windows settings as > to what application is associated with .py files. > > (You mentioned running IDLE, but I don't see that it was given as the > default application for opening .py files.) > I would think the install would make the association of py to Python, either IDLE or the interpreter. If I right-click on a py file, it asks me for "Open with". If I select idle.pyw, it gives me the message I posted earlier. From joncle at googlemail.com Mon Nov 14 12:33:48 2011 From: joncle at googlemail.com (Jon Clements) Date: Mon, 14 Nov 2011 09:33:48 -0800 (PST) Subject: Py2.7/FreeBSD: maximum number of open files References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> Message-ID: On Nov 14, 5:03?pm, Tobias Oberstein wrote: > > > I need 50k sockets + 100 files. > > > > Thus, this is even more strange: the Python (a Twisted service) will > > > happily accept 50k sockets, but as soon as you do open() a file, it'll bail out. > > > A limit of 32k smells like a overflow in a signed int. Perhaps your system is > > able and configured to handle more than 32k FDs but you hit an artificial limit > > because some C code or API has a overflow. This seems to be a known bug in > > FreeBSDhttp://lists.freebsd.org/pipermail/freebsd-bugs/2010- > > July/040689.html > > This is unbelievable. > > I've just tested: the bug (in libc) is still there on FreeBSD 8.2 p3 ... both on i386 > _and_ amd64. > > Now I'm f***d;( > > A last chance: is it possible to compile Python for not using libc fopen(), > but the Posix open()? > > Thanks anyway for this hint! Have you tried/or is it possible to get your 100 or whatever files first, before your sockets? hth Jon From tobias.oberstein at tavendo.de Mon Nov 14 12:46:00 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 09:46:00 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files In-Reply-To: References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> Message-ID: <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> > > > > I need 50k sockets + 100 files. > > > > > > Thus, this is even more strange: the Python (a Twisted service) > > > > will happily accept 50k sockets, but as soon as you do open() a file, it'll > bail out. > > > > > A limit of 32k smells like a overflow in a signed int. Perhaps your > > > system is able and configured to handle more than 32k FDs but you > > > hit an artificial limit because some C code or API has a overflow. > > > This seems to be a known bug in > > > FreeBSDhttp://lists.freebsd.org/pipermail/freebsd-bugs/2010- > > > July/040689.html > > > > This is unbelievable. > > > > I've just tested: the bug (in libc) is still there on FreeBSD 8.2 p3 > > ... both on i386 _and_ amd64. > > > > Now I'm f***d;( > > > > A last chance: is it possible to compile Python for not using libc > > fopen(), but the Posix open()? > > > > Thanks anyway for this hint! > > Have you tried/or is it possible to get your 100 or whatever files first, before > your sockets? If I only needed to open a fixed set of files, that might be a workaround. However, this is not the case. I.e. Twisted will do log switching and create/open a new file when the 50k sockets are already there. I just confirmed that the bug is even there for FreeBSD 9 RC1 ! This is most unfortunate. Seriously. I am running out of options, since I am willing to make my stuff Python 3 compatible, but Twisted is not yet there. Using the backported new IO on Python 2.7 will not make open() automatically use the new IO, will it? From miki.tebeka at gmail.com Mon Nov 14 12:48:27 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 14 Nov 2011 09:48:27 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: <28344033.1206.1321292907659.JavaMail.geo-discussion-forums@prms22> > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? I think sqlite3 makes sense since it's already there and has SQL interface. > is there any general tutorial of how to start developing a database? i > mean a general guide to databases you can suggest to me? The docs (http://docs.python.org/library/sqlite3.html) have some basic instructions. > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > easily convert it in a sqlite db? (maybe via csv) This can be your first exercise :) But it should be easy to import with the csv module. From gordon at panix.com Mon Nov 14 13:00:44 2011 From: gordon at panix.com (John Gordon) Date: Mon, 14 Nov 2011 18:00:44 +0000 (UTC) Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) References: Message-ID: In "W. eWatson" writes: > I would think the install would make the association of py to Python, > either IDLE or the interpreter. I would hope so too, however you did mention that you moved the python executable to a different directory and installed a newer version, so verifying that the .py file association points to the correct application might be worthwhile. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From lists at cheimes.de Mon Nov 14 13:03:31 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 19:03:31 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> Message-ID: Am 14.11.2011 18:46, schrieb Tobias Oberstein: > I just confirmed that the bug is even there for FreeBSD 9 RC1 ! > > This is most unfortunate. Seriously. W00t, that sucks! You could migrate to another BSD (NetBSD) or Linux ... :) > I am running out of options, since I am willing to make my stuff Python 3 compatible, > but Twisted is not yet there. > > Using the backported new IO on Python 2.7 will not make open() automatically use the new IO, will it? No, the open() function of Python 2.7 will still use the file class which in return uses fopen(). You could try to monkey patch the built-in open() function. It's mostly API compatible with the current open() function: >>> import io, __builtin__ >>> __builtin__.open = io.open It works as long as no codes checks for isinstance(obj, file). If your app only has to worry about log files, you might want to overwrite the _open() method of logging.FileHandler and its subclasses. Christian From wolftracks at invalid.com Mon Nov 14 13:08:17 2011 From: wolftracks at invalid.com (W. eWatson) Date: Mon, 14 Nov 2011 10:08:17 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) In-Reply-To: References: Message-ID: On 11/14/2011 10:00 AM, John Gordon wrote: > In "W. eWatson" writes: > >> I would think the install would make the association of py to Python, >> either IDLE or the interpreter. > > I would hope so too, however you did mention that you moved the python > executable to a different directory and installed a newer version, so > verifying that the .py file association points to the correct application > might be worthwhile. > Note though I had uninstalled Python. The folder remained, so I renamed it, then installed. I see no way that under that arrangement that py would be associated with the renamed contents. The renamed folder has no exe file for the interpreter. There is, of course, a new Python25 that shows python.exe and pythonw.exe. python.exe will bring up a command window. From tobias.oberstein at tavendo.de Mon Nov 14 13:28:21 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 10:28:21 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files In-Reply-To: References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> Message-ID: <634914A010D0B943A035D226786325D42D0C26485F@EXVMBX020-12.exch020.serverdata.net> > > I just confirmed that the bug is even there for FreeBSD 9 RC1 ! > > > > This is most unfortunate. Seriously. > > W00t, that sucks! You could migrate to another BSD (NetBSD) or Linux ... :) No, thanks;) > > I am running out of options, since I am willing to make my stuff > > Python 3 compatible, but Twisted is not yet there. > > > > Using the backported new IO on Python 2.7 will not make open() > automatically use the new IO, will it? > > No, the open() function of Python 2.7 will still use the file class which in > return uses fopen(). You could try to monkey patch the built-in > open() function. It's mostly API compatible with the current open() > function: > > >>> import io, __builtin__ > >>> __builtin__.open = io.open > > It works as long as no codes checks for isinstance(obj, file). If your app only > has to worry about log files, you might want to overwrite the > _open() method of logging.FileHandler and its subclasses. > Thanks! This is probably the most practical option I can go. I've just tested: the backported new IO on Python 2.7 will indeed open >32k files on FreeBSD. It also creates the files much faster. The old, non-monkey-patched version was getting slower and slower as more files were opened/created .. There seem to be slight differences though: Non-monkey patched: I can write to the file a non-Unicode string, even when the file was opened non-Binary. With monkey patch: either open the file Binary-mode, or write Unicode strings .. I need to see if / what breaks in Twisted. I can handle my own code .. no problem. Thanks alot!! import io, __builtin__ __builtin__.open = io.open import resource max = resource.getrlimit(resource.RLIMIT_NOFILE) cnt = 0 print "maximum FDs", max max = 33000 fds = [] while cnt < max: f = open("/tmp/test1/test_%d" % cnt, "wb") f.write("test") fds.append(f) cnt += 1 if cnt % 1000 == 0: print "opened %d files" % cnt print "ok, created %d files" % cnt From steve at sprangle.com Mon Nov 14 14:30:15 2011 From: steve at sprangle.com (Steve Edlefsen) Date: Mon, 14 Nov 2011 12:30:15 -0700 Subject: can't decompress data; zlib not available In-Reply-To: <1321221305.12661.6.camel@tim-laptop> References: <4EC009D7.90100@sprangle.com> <1321221305.12661.6.camel@tim-laptop> Message-ID: <4EC16C47.9000604@sprangle.com> Sorry about that. Ubuntu 11.10. I used Plone-4.1.2-UnifiedInstaller.tar which installed o.k. I'm serving a webpage on my LAN. I did a search on files named "python" on my machine. There are 23 not including the ones in the Plone buildout-cache in my account. Seems like a lot of applications install their own copy of python. There are also ./usr/lib/x86_64-linux-gnu/libz.so ./usr/lib/libz.so which, I believe, are the zlib libraries. I've read that you can reinstall python with configure using the "--with-zlib" option, but configure isn't in /usr/local/Plone/Python-2.6/lib/python2.6/config I think the python interpreter for the command line is the one in /usr/bin/python. Would this be the one I reconfigure for zlib? Should I simply install python from Python-3.2.2.tgz? On 11/13/2011 02:55 PM, Tim Wintle wrote: > On Sun, 2011-11-13 at 11:17 -0700, Steve Edlefsen wrote: >> which appears to install zlib when python is reinstalled. Except I >> can't run make without errors and there is no configuration file. >> >> How do I reinstall python to include zlib? > Which OS are you on? Linux? BSD? > > How did you install Plone? > > First I'd check if there's a module shadowing the builtin zlib module - > i.e. if you've got a local file called "zlib.py" which is getting > imported by mistake. > > > Fairly much all *nix systems will have a python installation out of the > box - it looks like you need python2.6 > > I've never had a missing zlib module - but it's possible that it might > be missing if you don't have the zlib/deflate headers installed - if > they're not available then I'd try installing them and then reinstalling > the package you started with. > > Tim Wintle > From lists at cheimes.de Mon Nov 14 14:34:31 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 20:34:31 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C26485F@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C26485F@EXVMBX020-12.exch020.serverdata.net> Message-ID: <4EC16D47.3000607@cheimes.de> Am 14.11.2011 19:28, schrieb Tobias Oberstein: > Thanks! This is probably the most practical option I can go. > > I've just tested: the backported new IO on Python 2.7 will indeed > open >32k files on FreeBSD. It also creates the files much faster. > The old, non-monkey-patched version was getting slower and > slower as more files were opened/created .. I wonder what's causing the O(n^2) behavior. Is it the old file type or BSD's fopen() fault? > There seem to be slight differences though: > > Non-monkey patched: I can write to the file a non-Unicode string, > even when the file was opened non-Binary. > > With monkey patch: either open the file Binary-mode, or > write Unicode strings .. Python 3.x doesn't collate data and text but distinguishes between bytes (str type in Python 2.x) and unicode. You can't write unicode to a binary file and str to a text file. See it as an opportunity! You are taking the first step towards Python 3 compatibility. :) Christian From lists at cheimes.de Mon Nov 14 14:50:39 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 20:50:39 +0100 Subject: can't decompress data; zlib not available In-Reply-To: <4EC16C47.9000604@sprangle.com> References: <4EC009D7.90100@sprangle.com> <1321221305.12661.6.camel@tim-laptop> <4EC16C47.9000604@sprangle.com> Message-ID: Am 14.11.2011 20:30, schrieb Steve Edlefsen: > Sorry about that. Ubuntu 11.10. > > I used > > Plone-4.1.2-UnifiedInstaller.tar > > which installed o.k. I'm serving a webpage on my LAN. > > I did a search on files named "python" on my machine. > There are 23 not including the ones in the Plone > buildout-cache in my account. Seems like a lot of > applications install their own copy of python. > > There are also > > ../usr/lib/x86_64-linux-gnu/libz.so > ../usr/lib/libz.so > > which, I believe, are the zlib libraries. > > I've read that you can reinstall python with configure > using the "--with-zlib" option, but configure isn't in > > /usr/local/Plone/Python-2.6/lib/python2.6/config > > I think the python interpreter for the command line is > the one in /usr/bin/python. Would this be the one I > reconfigure for zlib? You might have run into this [1] issue with Ubuntu 11.04+ and Python before 2.7.2. Christian [1] http://lipyrary.blogspot.com/2011/05/how-to-compile-python-on-ubuntu-1104.html From chris.martel at gmail.com Mon Nov 14 15:57:37 2011 From: chris.martel at gmail.com (Chris Martel) Date: Mon, 14 Nov 2011 12:57:37 -0800 (PST) Subject: Python Developer needed for Catalina Marketing - St. Petersburg Message-ID: <7430fa93-e8a0-41e5-8fd5-3a4b5fe40cc4@l19g2000yqc.googlegroups.com> We, at Catalina Marketing, are in need of a Python Developer for 3 - 6 months. You'd be writing highly sophisticated scripting in OO classes (cron) for our coupon campaigns. Also using SQLite, Oracle, and Netezza. Prefer someone who has at least 3-5 years of Python and database experience. The other skills are secondary. You would be a direct Catalina temporary employee, or we can do a C2C arrangement. Also if you know of someone who might be interested, I would muchly appreciate the referral. Please contact Chris Martel if interested: chris.martel at catalinamarketing.com, 727-579-5434. Catalina Marketing Corp. provides behavior-based marketing solutions for brand manufacturers, retailers, and healthcare providers. It offers campaign management services; Catalina Category Marketing, a behavior-based merchandising event; Catalina Interactive, which allows the user to communicate with consumers online; Catalina Product Alert, which tracks down actual recalled product buyers; Checkout Coupon, which targets consumers at the transaction level; Checkout Direct, which allows brands and retailers to target households based on past purchase behavior; Checkout Prizes, which builds product volume and generates in-store/brand excitement by pre-announcing sweepstakes events; and Checkout Rx, a household and transactional database. The company also provides competitive benchmarks; Connection Builder, a Web-based business intelligence application designed to support analytical needs; data mining services; Loyalty Quotient, a strategic application; new product launch programs; PatientLink, which delivers healthcare messages; PatientLinkMC, which delivers PatientLink messages in the patient's language of choice; Pay for Performance, which allows brand manufacturers to influence consumers before they reach the point of sale; PharmAware, which delivers educational messages about pharmaceutical products for pharmacists and their staff; Rebate Max, a program that simplifies customer participation in various manufacturer-funded rebate offers; and RxConx, an integrated wellness marketing solution. In addition, it offers retail consulting services. The company serves various brands, retailers, and healthcare markets. Catalina Marketing Corp. was founded in 1983 and is based in St. Petersburg, Florida with locations in the United States, the United Kingdom, the Netherlands, Japan, Italy, Germany, France, and Belgium. From tim.wintle at teamrubber.com Mon Nov 14 16:01:06 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Mon, 14 Nov 2011 21:01:06 +0000 Subject: can't decompress data; zlib not available In-Reply-To: <4EC16C47.9000604@sprangle.com> References: <4EC009D7.90100@sprangle.com> <1321221305.12661.6.camel@tim-laptop> <4EC16C47.9000604@sprangle.com> Message-ID: <1321304466.32356.14.camel@tim-laptop> On Mon, 2011-11-14 at 12:30 -0700, Steve Edlefsen wrote: > I did a search on files named "python" on my machine. > There are 23 not including the ones in the Plone > buildout-cache in my account. Seems like a lot of > applications install their own copy of python. > > There are also > > ./usr/lib/x86_64-linux-gnu/libz.so > ./usr/lib/libz.so > > which, I believe, are the zlib libraries. but do you have the headers? On my ubuntu it's /usr/include/zlib.h As Christian pointed out, Ubuntu 11.04 introduced some changes which may have broken the installation - there is a patch on the python bug tracker which will provide a work-around, but it is not going to be applied to 2.6 or lower as they are not actively maintained branches any more. You'll need to run through the steps that the plone installer makes and patch the extracted python directory before it makes it's local python. > I've read that you can reinstall python with configure > using the "--with-zlib" option, but configure isn't in > > /usr/local/Plone/Python-2.6/lib/python2.6/config > > I think the python interpreter for the command line is > the one in /usr/bin/python. Would this be the one I > reconfigure for zlib? Should I simply install python from > > Python-3.2.2.tgz? no - you need to use python2.6 - python3 is effectively a different language. python is a core part of *nix these days, so playing around recompiling the system python can cause a lot of pain. Tim From ethan at stoneleaf.us Mon Nov 14 16:53:29 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 14 Nov 2011 13:53:29 -0800 Subject: else in try/except Message-ID: <4EC18DD9.1070301@stoneleaf.us> The code in 'else' in a 'try/except/else[/finally]' block seems pointless to me, as I am not seeing any difference between having the code in the 'else' suite vs having the code in the 'try' suite. Can anybody shed some light on this for me? ~Ethan~ From python at mrabarnett.plus.com Mon Nov 14 17:59:35 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 14 Nov 2011 22:59:35 +0000 Subject: else in try/except In-Reply-To: <4EC18DD9.1070301@stoneleaf.us> References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: <4EC19D57.8000907@mrabarnett.plus.com> On 14/11/2011 21:53, Ethan Furman wrote: > The code in 'else' in a 'try/except/else[/finally]' block seems > pointless to me, as I am not seeing any difference between having the > code in the 'else' suite vs having the code in the 'try' suite. > > Can anybody shed some light on this for me? > The difference is that if an exception occurs in the else block it won't be caught by the exception handlers of the try statement. From arnodel at gmail.com Mon Nov 14 18:03:55 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Mon, 14 Nov 2011 23:03:55 +0000 Subject: else in try/except In-Reply-To: <4EC18DD9.1070301@stoneleaf.us> References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: On 14 November 2011 21:53, Ethan Furman wrote: > The code in 'else' in a 'try/except/else[/finally]' block seems pointless to > me, as I am not seeing any difference between having the code in the 'else' > suite vs having the code in the 'try' suite. > > Can anybody shed some light on this for me? Exceptions in the else clause will not be caught. Look at the difference between the two try clauses below: >>> def f(): raise TypeError ... >>> try: ... print("try") ... f() ... except TypeError: ... print("except") ... try except >>> try: ... print("try") ... except TypeError: ... print("except") ... else: ... f() ... try Traceback (most recent call last): File "", line 6, in File "", line 1, in f TypeError >>> HTH -- Arnaud From ckaynor at zindagigames.com Mon Nov 14 18:12:13 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Mon, 14 Nov 2011 15:12:13 -0800 Subject: else in try/except In-Reply-To: <4EC19D57.8000907@mrabarnett.plus.com> References: <4EC18DD9.1070301@stoneleaf.us> <4EC19D57.8000907@mrabarnett.plus.com> Message-ID: On Mon, Nov 14, 2011 at 2:59 PM, MRAB wrote: > On 14/11/2011 21:53, Ethan Furman wrote: >> >> The code in 'else' in a 'try/except/else[/finally]' block seems >> pointless to me, as I am not seeing any difference between having the >> code in the 'else' suite vs having the code in the 'try' suite. >> >> Can anybody shed some light on this for me? >> > The difference is that if an exception occurs in the else block it > won't be caught by the exception handlers of the try statement. Consider the examples: try: a raise RuntimeError() except RuntimeError: pass vs try: a except RuntimeError: pass else: raise RuntimeError() The first example will not raise an exception, while the second will result in a RuntimeError. Effectively, the first block will either: 1) If the "a" block raises a RuntimeError, continue, 2) If the "a" block raised any other error, propergate it, 3) If the "a" block does not raise an exception, continue. while the second block will either: 1) If the "a" block raises a RuntimeError, continue, 2) If the "a" block raised any other error, propergate it, 3) If the "a" block does not raise an exception, raise a RuntimeError. Note the difference in the 3rd case. > -- > http://mail.python.org/mailman/listinfo/python-list > From devplayer at gmail.com Mon Nov 14 18:59:39 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 14 Nov 2011 15:59:39 -0800 (PST) Subject: Opportunity missed by Python ? References: <4e96b324$0$1007$426a34cc@news.free.fr> <1dd5aa8c-7a41-4108-8940-ef666cd2ddb9@t38g2000prg.googlegroups.com> Message-ID: What I don't get is, having seen Python's syntax with indentation instead of open and closing puncuation and other -readability- structures in Python's syntax, is if someone is going to invent any new language, how could they NOT take Python's visual structures (read as readability) and copy it, whether it be a compiled language, explicidly typed checked or whatever underlying mechanism they want to make that code executable. From ethan at stoneleaf.us Mon Nov 14 19:15:16 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 14 Nov 2011 16:15:16 -0800 Subject: else in try/except In-Reply-To: <4EC18DD9.1070301@stoneleaf.us> References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: <4EC1AF14.3010401@stoneleaf.us> Thanks, all! ~Ethan~ From rosuav at gmail.com Mon Nov 14 19:28:10 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Nov 2011 11:28:10 +1100 Subject: Opportunity missed by Python ? In-Reply-To: References: <4e96b324$0$1007$426a34cc@news.free.fr> <1dd5aa8c-7a41-4108-8940-ef666cd2ddb9@t38g2000prg.googlegroups.com> Message-ID: On Tue, Nov 15, 2011 at 10:59 AM, DevPlayer wrote: > What I don't get is, having seen Python's syntax with indentation > instead of open and closing puncuation and other -readability- > structures in Python's syntax, is if someone is going to invent any > new language, how could they NOT take Python's visual structures (read > as readability) and copy it, whether it be a compiled language, > explicidly typed checked or whatever underlying mechanism they want to > make that code executable. What I would say is: How could they NOT be aware of Python's visual structures. There are tradeoffs, and just because something works for one language doesn't mean it's right for every other. I doubt the Dart developers were unaware of Python's structural style, so the choice to not use such was most likely conscious. (It may have been as simple as "let's keep the syntax mostly JS-like, to make it easier for JS developers to grok" though, rather than a major language-design choice.) ChrisA From rowen at uw.edu Mon Nov 14 20:00:38 2011 From: rowen at uw.edu (Russell E. Owen) Date: Mon, 14 Nov 2011 17:00:38 -0800 Subject: Decorator question: prefer class, but only function works References: Message-ID: In article , Ian Kelly wrote: > On Thu, Nov 10, 2011 at 2:52 PM, Russell E. Owen wrote: > > I am trying to write a decorator that times an instance method and > > writes the results to a class member variable. For example: > > > > def timeMethod(func): > > ? ?def wrapper(self, *args, **keyArgs): > > ? ? ? ?t1 = time.time() > > ? ? ? ?res = func(self, *args, **keyArgs) > > ? ? ? ?duration = time.time() - t1 > > ? ? ? ?self.timings[func.__name__] = duration > > ? ? ? ?return res > > ? ?return wrapper > > > > This works, but I'm not very happy with the way self.timings is obtained. > > What do you feel is wrong with it? Oops, I stripped so much out of my example that I stripped the ugly bit. This is closer to the original and demonstrated the issue: def timeMethod(func): name = func.__name__ + "Duration" def wrapper(self, *args, **keyArgs): ? ? t1 = time.time() ? ? ? ?res = func(self, *args, **keyArgs) ? ? ? ?duration = time.time() - t1 ? ? ? ?self.timings[name] = duration ? ? ? ?return res ? ?return wrapper I don't like the way name is passed into wrapper. It works, but it looks like magic. A class offers an obvious place to save the information. Or I could just generate the name each time. I realize I'm showing the limits of my understanding of python binding of variable names, but I also think that if I find it confusing then others will, as well. > sum(os.times()[:2]) instead, which (assuming your script is > single-threaded) will more accurately count the actual CPU time spent > in the function rather than real time, which could be quite different > if the CPU is busy. Thanks for the suggestion. I decided to use time.clock(), which I understand gives basically the same information (at a resolution that is sufficient for my needs). > Also, why do you need this? If you're just trying to evaluate the > speed of your code, you should consider using a proper profiler or the > timeit module. The former will tell you how much time is spent in > each function, while the latter runs the code a large number of times > in a loop, which gives you better precision for quick methods. It is for timing stages of a data processing pipeline. Only long-running tasks will be timed. Repeatedly running to get better times is neither practical nor necessary to get a good feeling of where the time is being spent. > > I first tried to write this as a class (for readability), and this did > > NOT work: > > > > class timeMethod(object): > > ? ?def __init__(self, func): > > ? ? ? ?self.func = func > > ? ?def __call__(self, *args, **keyArgs): > > ? ? ? ?t1 = time.time() > > ? ? ? ?res = self.func(*args, **keyArgs) > > ? ? ? ?duration = time.time() - t1 > > ? ? ? ?args[0].timings.set(self.func.__name__, duration) > > ? ? ? ?return res > > > > In the first case the wrapper is called as an unbound function, so it > > works. But in the second case the wrapper is called as a bound method -- > > thus args[0] is not func's class instance, and I can't get to the > > timings attribute. > > I prefer the function version myself, but to make this work you could > add something like this (untested) to make your wrapper class a > descriptor that tacks on the self argument: > > def __get__(self, instance, owner): > from functools import partial > if instance is None: > return self > return partial(self, instance) Thank you very much. I'll stick to the function, since it works, but it's nice to know how to work around the problem. From dbinks at codeaurora.org Mon Nov 14 20:09:39 2011 From: dbinks at codeaurora.org (Dominic Binks) Date: Mon, 14 Nov 2011 17:09:39 -0800 Subject: Opportunity missed by Python ? In-Reply-To: References: <4e96b324$0$1007$426a34cc@news.free.fr> <1dd5aa8c-7a41-4108-8940-ef666cd2ddb9@t38g2000prg.googlegroups.com> Message-ID: <4EC1BBD3.2020006@codeaurora.org> I believe Occam had a visual structure and was compiled. In fact it was even more picky than Python in this respect IIRC. On 11/14/2011 4:28 PM, Chris Angelico wrote: > On Tue, Nov 15, 2011 at 10:59 AM, DevPlayer wrote: >> What I don't get is, having seen Python's syntax with indentation >> instead of open and closing puncuation and other -readability- >> structures in Python's syntax, is if someone is going to invent any >> new language, how could they NOT take Python's visual structures (read >> as readability) and copy it, whether it be a compiled language, >> explicidly typed checked or whatever underlying mechanism they want to >> make that code executable. > > What I would say is: How could they NOT be aware of Python's visual > structures. There are tradeoffs, and just because something works for > one language doesn't mean it's right for every other. I doubt the Dart > developers were unaware of Python's structural style, so the choice to > not use such was most likely conscious. (It may have been as simple as > "let's keep the syntax mostly JS-like, to make it easier for JS > developers to grok" though, rather than a major language-design > choice.) > > ChrisA -- Dominic Binks: dbinks at codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum From wuwei23 at gmail.com Mon Nov 14 22:07:34 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 14 Nov 2011 19:07:34 -0800 (PST) Subject: Multilevel dicts/arrays v. tuples as keys? References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: <74d33315-beb0-4b4e-90bb-0cac8c91c5e6@j19g2000pro.googlegroups.com> Peter Otten <__pete... at web.de> wrote: > If you need lookup only I'd prefer tuples, but sometimes you may want to > retrieve all values with a certain k1 and > > d[k1] > > is certainly more efficient than > > [(k2, v) for (k1, k2), v in d.items() if k1 == wanted] This was the hidden cost of the tuple/reverse-dictionary solution I offered. The solution will of course depend on what the OP requires to be more efficient: looking up keys from values, or working with subsets of the data. From steve+comp.lang.python at pearwood.info Mon Nov 14 22:10:34 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 03:10:34 GMT Subject: Opportunity missed by Python ? References: <4e96b324$0$1007$426a34cc@news.free.fr> <1dd5aa8c-7a41-4108-8940-ef666cd2ddb9@t38g2000prg.googlegroups.com> Message-ID: <4ec1d829$0$29989$c3e8da3$5496439d@news.astraweb.com> On Mon, 14 Nov 2011 15:59:39 -0800, DevPlayer wrote: > What I don't get is, having seen Python's syntax with indentation > instead of open and closing puncuation and other -readability- > structures in Python's syntax, is if someone is going to invent any new > language, how could they NOT take Python's visual structures (read as > readability) and copy it, whether it be a compiled language, explicidly > typed checked or whatever underlying mechanism they want to make that > code executable. Because sometimes people have priorities other than readability. Or they actually *like* braces. (I know, crazy!) In fairness, the significant indentation is not all peaches and cream, it has a dark side too. For example, the difference between visually indistinguishable spaces and tabs can be meaningful (in Python 2, your code may be broken if you mix spaces and tabs; in Python 3, the compiler will give you an error). If you work in a noisy environment that eats whitespace, such as crappy web forums, people using HTML email, editors with unfriendly word-wrapping rules, and the like, you might miss having braces. I occasionally see emails with code looking something like this: print(something) while x < 100: print(something_else) x -= 1 if x % 2 == 1: some_function() else: another_function() third_function() print(x) So the "off-side rule", as it is called, is not uncontroversial. Languages developed by old-school language developers or academics, like Google's Go language, tend to be very conservative and hence require braces or even semicolons. http://en.wikipedia.org/wiki/Off-side_rule So many people keep asking for braces in Python that one of the developers (Guido?) gave in and added it to the language. Just run from __future__ import braces at the top of your file, or at the interactive interpreter, and you're done. My own opinion is that the time I save with significant indentation is a hundred times greater than the time I lose due to mangled code without braces. So I consider Python's design a big win, but other people may make other value judgments. -- Steven From steve+comp.lang.python at pearwood.info Mon Nov 14 22:22:03 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 03:22:03 GMT Subject: Decorator question: prefer class, but only function works References: Message-ID: <4ec1dada$0$29989$c3e8da3$5496439d@news.astraweb.com> On Mon, 14 Nov 2011 17:00:38 -0800, Russell E. Owen wrote: > Oops, I stripped so much out of my example that I stripped the ugly bit. > This is closer to the original and demonstrated the issue: > > def timeMethod(func): > name = func.__name__ + "Duration" > def wrapper(self, *args, **keyArgs): > ? ? t1 = time.time() > ? ? ? ?res = func(self, *args, **keyArgs) > ? ? ? ?duration = time.time() - t1 > ? ? ? ?self.timings[name] = duration > ? ? ? ?return res > ? ?return wrapper > > I don't like the way name is passed into wrapper. It works, but it looks > like magic. A class offers an obvious place to save the information. Or > I could just generate the name each time. The pattern you are seeing is called a closure, and it is a very important, if advanced, part of Python programming. Of course, you don't *have* to use closures, but it isn't scarily-advanced (like metaclass programming) but only moderately advanced, and there will be a lot of code out there using closures. http://en.wikipedia.org/wiki/Closure_(computer_science) Basically a closure is a function which remembers just enough of its current environment (the value of non-local variables) so that it can continue to work in the future, even if those non-locals change or disappear. I take it you are aware that timing code as shown is only suitable for long-running code, and not small snippets? For small snippets, you should use the timeit module. You might also find this recipe useful: http://code.activestate.com/recipes/577896/ -- Steven From brownbar at gmail.com Mon Nov 14 23:53:06 2011 From: brownbar at gmail.com (Barry W Brown) Date: Mon, 14 Nov 2011 20:53:06 -0800 (PST) Subject: else in try/except In-Reply-To: References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: <33343034.1390.1321332786394.JavaMail.geo-discussion-forums@yqbl36> I thought that the point of the else clause is that it is reached only if there is no exception in the try clause. From brownbar at gmail.com Mon Nov 14 23:53:06 2011 From: brownbar at gmail.com (Barry W Brown) Date: Mon, 14 Nov 2011 20:53:06 -0800 (PST) Subject: else in try/except In-Reply-To: References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: <33343034.1390.1321332786394.JavaMail.geo-discussion-forums@yqbl36> I thought that the point of the else clause is that it is reached only if there is no exception in the try clause. From jason.swails at gmail.com Tue Nov 15 00:18:28 2011 From: jason.swails at gmail.com (Jason Swails) Date: Tue, 15 Nov 2011 00:18:28 -0500 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Mon, Nov 14, 2011 at 3:49 AM, Chris Angelico wrote: > On Mon, Nov 14, 2011 at 6:11 PM, Jason Swails > wrote: > > Then, I can reactivate all of the buttons in the destroy() method before > > calling the destroy() method of Toplevel on self. > > Small side point that might save you some work: Instead of disabling > and enabling all the buttons, disable the whole window. I don't know > Tkinter well enough to know if there's an easy way to create a modal > window, but the thing to do is to disable the entire window rather > than just its command buttons - that's the least astonishing[1] user > interface technique. > Of course! Windows are widgets just like everything else is, and so can be configured to be in the DISABLED state just like a button can. I'm not used to this hierarchy in which the root window presides over all, yet is still a widget just like everything else. But there's a lot of GUI programming that I haven't wrapped my head around yet (which is why I'm running with this pet project -- but it's bound to be ugly :)). Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Nov 15 00:32:06 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Nov 2011 16:32:06 +1100 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 4:18 PM, Jason Swails wrote: > Of course!? Windows are widgets just like everything else is, and so can be > configured to be in the DISABLED state just like a button can.? I'm not used > to this hierarchy in which the root window presides over all, yet is still a > widget just like everything else. > > But there's a lot of GUI programming that I haven't wrapped my head around > yet (which is why I'm running with this pet project -- but it's bound to be > ugly :)). Heh, I grew up on OS/2 and everything was an object. (With a few exceptions; the minimize/maximize/close buttons are all a single object, rather than being three.) It's not normal to disable the title bar while leaving the window enabled, but if you want to, you can! As a general rule, if any parent is invisible, you won't see the child, and if any parent is disabled, you can't access the child. You may find that there's even a one-line command that will disable the window, open a new window, wait for the new window to close, and automatically reenable the window - an "open modal dialog" function or something. ChrisA From devplayer at gmail.com Tue Nov 15 02:39:51 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 14 Nov 2011 23:39:51 -0800 (PST) Subject: simple import hook References: <4EBBF15D.9090401@gmail.com> Message-ID: <09619112-407e-49ba-87df-ceed03e7789e@v5g2000yqn.googlegroups.com> An alternative approach: http://pastebin.com/z6pNqFYE or: # devplayer at gmail.com # 2011-Nov-15 # recordimports.py # my Import Hook Hack in response to: # http://groups.google.com/group/comp.lang.python/browse_thread/thread/5a5d5c724f142eb5?hl=en # as an initial learning exercise # This code needs to come before any imports you want recorded # usually just once in the initial (main) module # Of course you can excluding the if __name__ == '__main__': demo code # barely tested: # only tested with modules that had no errors on import # did not need/use/expect/try reload() # ran with Python 2.7 on Win32 # create two fake modules moda.py and modb.py and stick some imports in them ''' Exerpt from PEP 302 -- New Import Hooks ... Motivation: - __import__ gets called even for modules that are already in sys.modules, which is almost never what you want, unless you're writing some sort of monitoring tool. Note the last two words.''' # ======================================================================= # place to save Collected imports imported = [] # save old __builtins__.__import__() __builtins__.__dict__['__old_import__'] = __builtins__.__dict__['__import__'] # match __builtins__.__import__() function signature def __myimport(name, globals={}, locals={}, fromlist=[], level=-1): global imported # I don't know why this works. __name__ = locals['__name__'] __file__ = locals['__file__'] __package__ = locals['__package__'] __doc__ = locals['__doc__'] # call original __import__ module = __builtins__.__old_import__(name, globals, locals, fromlist, level) # save import module name into namespace __builtins__.__dict__[name] = module tag = (name, __name__, __file__, __package__, module) # do not append duplicates if tag not in imported: imported.append( tag ) return module # store the new __import__ into __builtins__ __builtins__.__dict__['__import__'] = __myimport # erase unneed func name del __myimport # ======================================================================= # demo if __name__ == '__main__': # import some random packages/modules import sys import moda # a test module that does some other imports import modb # a test module that does some imports from pprint import pprint # imported has name, __name__, __file__, __package__ # show each import for n, __n, __f, __p, m in imported: print n print ' ', __n print ' ', __f print ' ', __p print del n, __n, __f, __p, m print 'recordimports.py' pprint(dir(), None, 4, 1) print print 'moda.py' pprint(dir(moda), None, 4, 1) print print 'modb.py' pprint(dir(modb), None, 4, 1) # print imported print From whatsjacksemail at gmail.com Tue Nov 15 06:14:17 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Tue, 15 Nov 2011 11:14:17 +0000 Subject: Opportunity missed by Python ? In-Reply-To: References: <4e96b324$0$1007$426a34cc@news.free.fr> Message-ID: On Thu, Oct 13, 2011 at 11:07 AM, Chris Angelico wrote: > On Thu, Oct 13, 2011 at 8:45 PM, candide wrote: > > Dart is the very new language created by Google to replace Javascript. > > So Python was not able to do the job? Or may be they don't know about > Python > > at Google ;) ? > > > > Also, Dart is looking to support (optional) strict typing, which > Python doesn't do. That's a fairly major performance enhancement. > > Traits from Enthought has defined types. I'm no expert mind so might not be suitable. Cheers, Jack -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From suhasrm at gmail.com Tue Nov 15 07:04:51 2011 From: suhasrm at gmail.com (Roark) Date: Tue, 15 Nov 2011 04:04:51 -0800 (PST) Subject: Execute a command on remote machine in python Message-ID: Hi, I am first time trying my hands on python scripting and would need some guidance from the experts on my problem. I want to execute a windows command within python script from a client machine on a remote target server, and would want the output of the command written in a file on client machine. What is the way it could be achieved. Thanks in advance, Roark. From martin.hellwig at gmail.com Tue Nov 15 08:29:23 2011 From: martin.hellwig at gmail.com (Martin P. Hellwig) Date: Tue, 15 Nov 2011 13:29:23 +0000 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: On 11/15/11 12:04, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. > If your doing windows to windows then you could wrap PsExec (sysinternals) or the open source but more or less abandoned RemCom (http://sourceforge.net/projects/rce). Disadvantage is that both of them are a royal PITA to wrap nicely. There are multiple problems with re-redirected STDOUT/STDERR Advantage is that you don't need to configure anything on the target machine. hth -- mph From kwa at kuwata-lab.com Tue Nov 15 08:34:30 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Tue, 15 Nov 2011 22:34:30 +0900 Subject: PREFIX directory for pip command Message-ID: Is it possible to specify PREFIX directory for pip command by environment variable? I found that 'pip install --install-option=--prefix=PREFIX' works well, but I don't want to specify '--install-option=--prefix=PREFIX' every time. I prefer to specify it by environment variable such as:: export PIP_INSTALL_DIR=$PWD/local Is it possible? Or any idea? -- regards, makoto From nawijn at gmail.com Tue Nov 15 08:54:14 2011 From: nawijn at gmail.com (Marco Nawijn) Date: Tue, 15 Nov 2011 05:54:14 -0800 (PST) Subject: Execute a command on remote machine in python References: Message-ID: On Nov 15, 1:04?pm, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. > > Thanks in advance, > Roark. Hello Roark, If the command does not change over time, an option could be to encapsulate the command and the output behind an XML-RPC interface. I used it several times now and for me this works perfectly. XML-RPC is part of the Python standard library, so it should work out of the box on windows and linux. It also supports mixed programming languages (maybe C# on windows to get the info you want and python on linux on the client). Kind regards, Marco From jeanmichel at sequans.com Tue Nov 15 09:03:49 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 15 Nov 2011 15:03:49 +0100 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: <4EC27145.6070203@sequans.com> Martin P. Hellwig wrote: > On 11/15/11 12:04, Roark wrote: >> Hi, >> >> I am first time trying my hands on python scripting and would need >> some guidance from the experts on my problem. >> >> I want to execute a windows command within python script from a client >> machine on a remote target server, and would want the output of the >> command written in a file on client machine. What is the way it could >> be achieved. >> > > If your doing windows to windows then you could wrap PsExec > (sysinternals) or the open source but more or less abandoned RemCom > (http://sourceforge.net/projects/rce). > > Disadvantage is that both of them are a royal PITA to wrap nicely. > There are multiple problems with re-redirected STDOUT/STDERR > > Advantage is that you don't need to configure anything on the target > machine. > > hth have a look at execnet http://codespeak.net/execnet/ It allows you to execute python code on a remote machine, assuming the distant machine has python installed. Work fine with either nix or windows systems. Regarding the file transfert, it sounds like pywin32 provides the netcopy service, but I'm not sure, I'm not working with windows. JM From rosuav at gmail.com Tue Nov 15 09:10:51 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 01:10:51 +1100 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 11:04 PM, Roark wrote: > Hi, > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. This looks like a job for SSH. ChrisA From contact at xavierho.com Tue Nov 15 09:16:23 2011 From: contact at xavierho.com (Xavier Ho) Date: Wed, 16 Nov 2011 00:16:23 +1000 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: It sounds like Fabric is what you're after. We use it at work and it's the best thing since ssh. ;] http://docs.fabfile.org/en/1.3.2/index.html (Actually, it uses ssh internally and allows you to do remote shell-like programming in a pythonic fashion.) Cheers, Xav On 15 November 2011 22:04, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. > > > Thanks in advance, > Roark. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roy at panix.com Tue Nov 15 09:20:50 2011 From: roy at panix.com (Roy Smith) Date: Tue, 15 Nov 2011 09:20:50 -0500 Subject: Execute a command on remote machine in python References: Message-ID: In article , Chris Angelico wrote: > On Tue, Nov 15, 2011 at 11:04 PM, Roark wrote: > > Hi, > > > > I want to execute a windows command within python script from a client > > machine on a remote target server, and would want the output of the > > command written in a file on client machine. What is the way it could > > be achieved. > > This looks like a job for SSH. You might also want to look at fabric (http://fabfile.org). It's a nice python library for remote command execution built on top of SSH. A more general answer is that, yes, SSH is the right thing to be looking at for your basic connectivity, data transport and remote command execution. But trying to deal with raw SSH will drive you batty. Something like fabric, layered on top of SSH, will make things a lot easier. From invalid at invalid.invalid Tue Nov 15 09:31:56 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 15 Nov 2011 14:31:56 +0000 (UTC) Subject: else in try/except References: <4EC18DD9.1070301@stoneleaf.us> <33343034.1390.1321332786394.JavaMail.geo-discussion-forums@yqbl36> Message-ID: On 2011-11-15, Barry W Brown wrote: > I thought that the point of the else clause is that it is reached > only if there is no exception in the try clause. Not really. If that's all you wanted, then you just put the code at the end of the try block. -- Grant Edwards grant.b.edwards Yow! ... I see TOILET at SEATS ... gmail.com From usenet at solar-empire.de Tue Nov 15 09:33:42 2011 From: usenet at solar-empire.de (Marc Christiansen) Date: Tue, 15 Nov 2011 15:33:42 +0100 Subject: PREFIX directory for pip command References: Message-ID: <6r9ap8-2to.ln1@pluto.solar-empire.de> Makoto Kuwata wrote: > Is it possible to specify PREFIX directory for pip command by > environment variable? > > I found that 'pip install --install-option=--prefix=PREFIX' works well, > but I don't want to specify '--install-option=--prefix=PREFIX' every time. > I prefer to specify it by environment variable such as:: > > export PIP_INSTALL_DIR=$PWD/local > > Is it possible? Or any idea? I'd try export PIP_INSTALL_OPTION=--prefix=$PWD/local using a config file is also possible. See http://www.pip-installer.org/en/latest/configuration.html Ciao Marc From robert.kern at gmail.com Tue Nov 15 10:06:15 2011 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 15 Nov 2011 15:06:15 +0000 Subject: else in try/except In-Reply-To: References: <4EC18DD9.1070301@stoneleaf.us> <33343034.1390.1321332786394.JavaMail.geo-discussion-forums@yqbl36> Message-ID: On 11/15/11 2:31 PM, Grant Edwards wrote: > On 2011-11-15, Barry W Brown wrote: > >> I thought that the point of the else clause is that it is reached >> only if there is no exception in the try clause. > > Not really. If that's all you wanted, then you just put the code at > the end of the try block. No, he's right. You should only put code in the try: block where you want exceptions to be caught. Everything else should be outside of the block. You really do want to minimize the amount of code inside the try: block. try: # minimal code that might raise exceptions that you want to catch except ThisError: # handle ThisError exceptions, and probably continue execution except ThatError: # handle ThatError exceptions, and probably continue execution else: # Code that only runs if ThisError or ThatError were not # raised in the try: block. This code may raise ThisError or ThatError # exceptions that should not be caught by the above except: blocks. # Other code that runs regardless if a caught-and-continued exception # was raised or not -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From kwa at kuwata-lab.com Tue Nov 15 10:40:34 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Wed, 16 Nov 2011 00:40:34 +0900 Subject: PREFIX directory for pip command In-Reply-To: <6r9ap8-2to.ln1@pluto.solar-empire.de> References: <6r9ap8-2to.ln1@pluto.solar-empire.de> Message-ID: On Tue, Nov 15, 2011 at 11:33 PM, Marc Christiansen wrote: > > I'd try > ?export PIP_INSTALL_OPTION=--prefix=$PWD/local It works very well. Thank you. -- regards, makoto > > using a config file is also possible. See > http://www.pip-installer.org/en/latest/configuration.html > > Ciao > Marc > -- > http://mail.python.org/mailman/listinfo/python-list > From rodrick.brown at gmail.com Tue Nov 15 10:57:16 2011 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Tue, 15 Nov 2011 10:57:16 -0500 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: You could easily script this with popen calling secure shell to execute a command and capture the output. Sent from my iPhone On Nov 15, 2011, at 7:04 AM, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. > > > Thanks in advance, > Roark. > -- > http://mail.python.org/mailman/listinfo/python-list From amalguseynov at gmail.com Tue Nov 15 11:02:13 2011 From: amalguseynov at gmail.com (BOOK-AZ) Date: Tue, 15 Nov 2011 08:02:13 -0800 (PST) Subject: all() is slow? References: Message-ID: <98bccd44-92b0-4a98-92c0-fb56a2ce847d@hh9g2000vbb.googlegroups.com> On Nov 7, 1:00?pm, "OKB (not okblacke)" wrote: > ? ? ? ? I noticed this (Python 2.6.5 on Windows XP): > http://book-az.com > >>> import random, timeit > >>> def myAll(x): > > ... ? ? for a in x: > ... ? ? ? ? if a not in (True, False): > ... ? ? ? ? ? ? return False > ... ? ? return True>>> x = [random.choice([True, False]) for a in xrange(0, 5000000)] > >>> timeit.timeit('myAll(x)', 'from __main__ import myAll, x', > > number=10) > 0: 9.7685158309226452>>> timeit.timeit('all(a in (True, False) for a in x)', 'from __main__ > > import x', number=10) > 1: 12.348196768024984>>> x = [random.randint(0,100) for a in xrange(0, 5000000)] > >>> def myAll(x): > > ... ? ? for a in x: > ... ? ? ? ? if not a <= 100: > ... ? ? ? ? ? ? return False > ... ? ? return True>>> timeit.timeit('myAll(x)', 'from __main__ import myAll, x', > > number=10) > 4: 2.8248207523582209>>> timeit.timeit('all(a <= 100 for a in x)', 'gc.enable(); from > > __main__ import x', number=10) > 5: 4.6433557896324942 > > ? ? ? ? What is the point of the all() function being a builtin if it's > slower than writing a function to do the check myself? > > -- > --OKB (not okblacke) > Brendan Barnwell > "Do not follow where the path may lead. ?Go, instead, where there is > no path, and leave a trail." > ? ? ? ? --author unknown From ramit.prasad at jpmorgan.com Tue Nov 15 12:01:23 2011 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 15 Nov 2011 17:01:23 +0000 Subject: Extracting elements over multiple lists? In-Reply-To: <4EB828B3.1020509@sequans.com> References: <4EB828B3.1020509@sequans.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> >>for x in a, b, c: >> del x[0] >for arr in [a,b,c]: > arr.pop(0) >(Peter's "del" solution is quite close, but I find the 'del' statement >tricky in python and will mislead many python newcomers) Can you expand on why 'del' is "tricky"/misleading? Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From babiucandreea at gmail.com Tue Nov 15 12:11:10 2011 From: babiucandreea at gmail.com (Andreea Babiuc) Date: Tue, 15 Nov 2011 17:11:10 +0000 Subject: suppressing import errors Message-ID: Hi, Is there a way to suppress all the errors when importing a module in python? By that I mean.. If I have other imports in the module I'm trying to import that fail, I still want my module to be imported that way.. Many thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckaynor at zindagigames.com Tue Nov 15 12:24:03 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 15 Nov 2011 09:24:03 -0800 Subject: suppressing import errors In-Reply-To: References: Message-ID: As with any Python code, you can wrap the import into a try: except block. try: import badModule except: pass # Or otherwise handle the exception - possibly importing an alternative module. As with any except statement, specific exceptions may be caught (rather than the blank, catch everything). Chris On Tue, Nov 15, 2011 at 9:11 AM, Andreea Babiuc wrote: > Hi, > > Is there a way to suppress all the errors when importing a module in python? > > By that I mean.. If I have other imports in the module I'm trying to import > that fail, I still want my module to be imported that way.. > > Many thanks. > > -- > http://mail.python.org/mailman/listinfo/python-list > > From ramit.prasad at jpmorgan.com Tue Nov 15 12:26:51 2011 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 15 Nov 2011 17:26:51 +0000 Subject: overview on dao In-Reply-To: <96a0fc78-aa96-4830-bc26-b3efbb75e65b@f3g2000pri.googlegroups.com> References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> <96a0fc78-aa96-4830-bc26-b3efbb75e65b@f3g2000pri.googlegroups.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474018427@SCACMX008.exchad.jpmchase.net> >> Perhaps you should call it "LaoZiDao". >I just prefer shorter name. DAO as Data Access Objects is a common acronym in several languages (i.e. Java), so you will continually have this naming conflict. Just be aware that this conflict will happen frequently in the minds of many programmers. Ramit P.S. I vote for PyLaoziDao :P Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From babiucandreea at gmail.com Tue Nov 15 12:35:09 2011 From: babiucandreea at gmail.com (Andreea Babiuc) Date: Tue, 15 Nov 2011 17:35:09 +0000 Subject: suppressing import errors In-Reply-To: References: Message-ID: On 15 November 2011 17:24, Chris Kaynor wrote: > As with any Python code, you can wrap the import into a try: except block. > > try: > import badModule > except: > > pass # Or otherwise handle the exception - possibly importing an > alternative module. > > Hmm, I know this might sound silly, but if it fails I still want to import the module and disable those lines of code that are related to the reason while the module failed to be imported in the first place. Even if that makes the code not 100% correct. Does that make sense ? > As with any except statement, specific exceptions may be caught > (rather than the blank, catch everything). > > Chris > > On Tue, Nov 15, 2011 at 9:11 AM, Andreea Babiuc > wrote: > > Hi, > > > > Is there a way to suppress all the errors when importing a module in > python? > > > > By that I mean.. If I have other imports in the module I'm trying to > import > > that fail, I still want my module to be imported that way.. > > > > Many thanks. > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Blog: Http://andreeababiuc.ro Photo Portfolio: http://royaa.daportfolio.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From devplayer at gmail.com Tue Nov 15 12:56:03 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 15 Nov 2011 09:56:03 -0800 (PST) Subject: simple import hook References: <4EBBF15D.9090401@gmail.com> <09619112-407e-49ba-87df-ceed03e7789e@v5g2000yqn.googlegroups.com> Message-ID: And for an insane amount of what REALLY gets imported: python.exe -B -s -S -v -v -v -v your_module_here.py %1 %2 %3 %4 %5 %6 %7 %8 %9 or more appropiately: python -v -v -v -v your_module_here.py And for completeness, if you feel those options aren't telling the whole truth, you can turn on your operating system's file auditing for opens and reads; I forget if there are other places that can be imported from besides *.py, *.pyo, *.pyc, *.pyd files too (maybe zips?) From fraveydank at gmail.com Tue Nov 15 12:57:11 2011 From: fraveydank at gmail.com (David Riley) Date: Tue, 15 Nov 2011 12:57:11 -0500 Subject: suppressing import errors In-Reply-To: References: Message-ID: On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote: > > > On 15 November 2011 17:24, Chris Kaynor wrote: > As with any Python code, you can wrap the import into a try: except block. > > try: > import badModule > except: > > > pass # Or otherwise handle the exception - possibly importing an > alternative module. > > > Hmm, I know this might sound silly, but if it fails I still want to import the module and disable those lines of code that are related to the reason while the module failed to be imported in the first place. Even if that makes the code not 100% correct. > > Does that make sense ? It makes sense. It probably also makes sense to only do an "except ImportError", since if there are other errors (say, syntax errors in a module you're trying to import, rather than its absence, you probably want to know about it. To disable code that won't work without the module you're trying to import, you can always set flags in your module. For example, I've got a project at work that can use a variety of communications interfaces, including using PySerial for serial port comms. But if someone doesn't have PySerial installed, I want it to fail gracefully and just not support serial. So I can do the following: try: import serial _serial_enabled = True except ImportError: print("PySerial not installed - serial ports not supported!") _serial_enabled = False And then elsewhere in my module, I can check the value of _serial_enabled to see if I should e.g. list the serial ports in available communications interfaces. Of course, if there's some other error in PySerial (maybe I installed a broken version with a syntax error?), that error will get propagated up, which is a good thing, because I'd rather know that PySerial is broken than just have it tell me it's not installed (which is what would happen if I simply caught all exceptions). Your mileage may vary. - Dave From d at davea.name Tue Nov 15 13:17:48 2011 From: d at davea.name (Dave Angel) Date: Tue, 15 Nov 2011 13:17:48 -0500 Subject: Extracting elements over multiple lists? In-Reply-To: <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> References: <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> Message-ID: <4EC2ACCC.2000100@davea.name> On 11/15/2011 12:01 PM, Prasad, Ramit wrote: > >> (Peter's "del" solution is quite close, but I find the 'del' statement >> tricky in python and will mislead many python newcomers) > Can you expand on why 'del' is "tricky"/misleading? > > Ramit > a = someexpression... b = a .... del a Does not (necessarily) delete the object that a refers to. It merely deletes the symbol a. -- DaveA From python at mrabarnett.plus.com Tue Nov 15 13:44:44 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 15 Nov 2011 18:44:44 +0000 Subject: overview on dao In-Reply-To: <5B80DD153D7D744689F57F4FB69AF474018427@SCACMX008.exchad.jpmchase.net> References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> <96a0fc78-aa96-4830-bc26-b3efbb75e65b@f3g2000pri.googlegroups.com> <5B80DD153D7D744689F57F4FB69AF474018427@SCACMX008.exchad.jpmchase.net> Message-ID: <4EC2B31C.4060502@mrabarnett.plus.com> On 15/11/2011 17:26, Prasad, Ramit wrote: >>> Perhaps you should call it "LaoZiDao". >> I just prefer shorter name. > > DAO as Data Access Objects is a common acronym in several languages (i.e. Java), > so you will continually have this naming conflict. Just be aware that this > conflict will happen frequently in the minds of many programmers. > > Ramit > > P.S. I vote for PyLaoziDao :P > Just don't confuse it with PyDao, which is already taken. :-) From jeanmichel at sequans.com Tue Nov 15 13:58:30 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 15 Nov 2011 19:58:30 +0100 Subject: suppressing import errors In-Reply-To: References: Message-ID: <4EC2B656.7050902@sequans.com> David Riley wrote: > On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote: > > >> On 15 November 2011 17:24, Chris Kaynor wrote: >> As with any Python code, you can wrap the import into a try: except block. >> >> try: >> import badModule >> except: >> >> >> pass # Or otherwise handle the exception - possibly importing an >> alternative module. >> >> >> Hmm, I know this might sound silly, but if it fails I still want to import the module and disable those lines of code that are related to the reason while the module failed to be imported in the first place. Even if that makes the code not 100% correct. >> >> Does that make sense ? >> > > It makes sense. It probably also makes sense to only do an "except ImportError", since if there are other errors (say, syntax errors in a module you're trying to import, rather than its absence, you probably want to know about it. > > To disable code that won't work without the module you're trying to import, you can always set flags in your module. For example, I've got a project at work that can use a variety of communications interfaces, including using PySerial for serial port comms. But if someone doesn't have PySerial installed, I want it to fail gracefully and just not support serial. So I can do the following: > > > try: > import serial > _serial_enabled = True > except ImportError: > print("PySerial not installed - serial ports not supported!") > _serial_enabled = False > > > And then elsewhere in my module, I can check the value of _serial_enabled to see if I should e.g. list the serial ports in available communications interfaces. > > Of course, if there's some other error in PySerial (maybe I installed a broken version with a syntax error?), that error will get propagated up, which is a good thing, because I'd rather know that PySerial is broken than just have it tell me it's not installed (which is what would happen if I simply caught all exceptions). Your mileage may vary. > > - Dave > > If I'm not wrong the OP wants to disable the line *in the module being imported*, which is kindof silly and doesn't make sense to answer his question. Anreea, tell us why the module you are importing is failing and if this module is yours, we may provide you a proper way to handle this situation (though I'm pretty sure everything is in Dave's proposal). JM PS : @Dave there is a way to avoiding adding symbols to your global namespace, assign None to the module's name on import errors. Then before using it, just test the module bool value : if serial: serial.whateverMethod() From alisha1551 at gmail.com Tue Nov 15 14:06:45 2011 From: alisha1551 at gmail.com (alisha alisha) Date: Tue, 15 Nov 2011 11:06:45 -0800 (PST) Subject: Gossip Protocol in Python Message-ID: Hi All, I am new to Python. I have to implement a overlay network of around 500 nodes which are arranged as a random graph. To generate theoverlay network I will be using networkx. My query is, is there a way to implement Gossip protocol in my overlay network using Python. Like one node initiated the Gossip of a message, then in how many epoch time it reaches all the nodes in the network. Thanks. Regards, Alisha From info at wingware.com Tue Nov 15 14:18:51 2011 From: info at wingware.com (Wingware) Date: Tue, 15 Nov 2011 14:18:51 -0500 Subject: Wing IDE 4.1.1 released Message-ID: <4EC2BB1B.8080506@wingware.com> Hi, Wingware has released version 4.1.1 of Wing IDE, an integrated development environment designed specifically for the Python programming language. Wing IDE is a cross-platform Python IDE that provides a professional code editor with vi, emacs, and other key bindings, auto-completion, call tips, refactoring, context-aware auto-editing, a powerful graphical debugger, version control, unit testing, search, and many other features. **Changes in Version 4.1.1** Highlights of this release include: * Goto-definition on symbols in the shells * Expanded and improved auto-editing support (enable this in the Edit > Keyboard Personality menu): * Auto-closing * Auto-enter invocation args * Apply quote/comment/paren/etc to selection * Auto-enter spaces * Insert EOL and indent for new block * Continue comment on new line * Auto-indent when pasting multi-line text in Python code (undo once restores original indentation) * Improved Smart Tab key option for Python * Indent to Match menu and tool bar items toggle indentation to one indent position lower if already at matching indent level * Improved auto-indent of else, elif, except, and finally * Experimental Turbo auto-completer mode for Python that treats any non-word key as a completion key and Ctrl, Alt, and Command as a cancel keys * Link to docs.python.org in Source Assistant * Include argument names in auto-completer during invocation * About 30 other bug fixes and minor improvements Complete change log: http://wingware.com/pub/wingide/4.1.1/CHANGELOG.txt **New Features in Version 4** Version 4 adds the following new major features: * Refactoring -- Rename/move symbols, extract to function/method, and introduce variable * Find Uses -- Find all points of use of a symbol * Auto-Editing -- Reduce typing burden by auto-entering expected code * Diff/Merge -- Graphical file and repository comparison and merge * Django Support -- Debug Django templates, run Django unit tests, and more * matplotlib Support -- Maintains live-updating plots in shell and debugger * Simplified Licensing -- Includes all OSes and adds Support+Upgrades subscriptions Details on licensing changes: http://wingware.com/news/2011-02-16 **About Wing IDE** Wing IDE is an integrated development environment designed specifically for the Python programming language. It provides powerful editing, testing, and debugging features that help reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. Wing IDE can be used to develop Python code for web, GUI, and embedded scripting applications. Wing IDE is available in three product levels: Wing IDE Professional is the full-featured Python IDE, Wing IDE Personal offers a reduced feature set at a low price, and Wing IDE 101 is a free simplified version designed for teaching beginning programming courses with Python. Version 4.0 of Wing IDE Professional includes the following major features: * Professional quality code editor with vi, emacs, and other keyboard personalities * Code intelligence for Python: Auto-completion, call tips, find uses, goto-definition, error indicators, refactoring, context-aware auto-editing, smart indent and rewrapping, and source navigation * Advanced multi-threaded debugger with graphical UI, command line interaction, conditional breakpoints, data value tooltips over code, watch tool, and externally launched and remote debugging * Powerful search and replace options including keyboard driven and graphical UIs, multi-file, wild card, and regular expression search and replace * Version control integration for Subversion, CVS, Bazaar, git, Mercurial, and Perforce * Integrated unit testing with unittest, nose, and doctest frameworks * Django support: Debugs Django templates, provides project setup tools, and runs Django unit tests * Many other features including project manager, bookmarks, code snippets, diff/merge tool, OS command integration, indentation manager, PyLint integration, and perspectives * Extremely configurable and may be extended with Python scripts * Extensive product documentation and How-Tos for Django, matplotlib, Plone, wxPython, PyQt, mod_wsgi, Autodesk Maya, and many other frameworks Please refer to http://wingware.com/wingide/features for a detailed listing of features by product level. System requirements are Windows 2000 or later, OS X 10.3.9 or later (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Wing IDE supports Python versions 2.0.x through 3.2.x and Stackless Python. For more information, see the http://wingware.com/ **Downloads** Wing IDE Professional and Wing IDE Personal are commercial software and require a license to run. A free trial can be obtained directly from the product when launched. Wing IDE Pro -- Full-featured product: http://wingware.com/downloads/wingide/4.1 Wing IDE Personal -- A simplified IDE: http://wingware.com/downloads/wingide-personal/4.1 Wing IDE 101 -- For teaching with Python: http://wingware.com/downloads/wingide-101/4.1 **Purchasing and Upgrading** Wing 4.x requires an upgrade for Wing IDE 2.x and 3.x users at a cost of 1/2 the full product pricing. Upgrade a license: https://wingware.com/store/upgrade Purchase a new license: https://wingware.com/store/purchase Optional Support+Upgrades subscriptions are available for expanded support coverage and free upgrades to new major releases: http://wingware.com/support/agreement Thanks! -- The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com From fraveydank at gmail.com Tue Nov 15 14:39:01 2011 From: fraveydank at gmail.com (David Riley) Date: Tue, 15 Nov 2011 14:39:01 -0500 Subject: suppressing import errors In-Reply-To: <4EC2B656.7050902@sequans.com> References: <4EC2B656.7050902@sequans.com> Message-ID: <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> On Nov 15, 2011, at 1:58 PM, Jean-Michel Pichavant wrote: > PS : @Dave there is a way to avoiding adding symbols to your global namespace, assign None to the module's name on import errors. Then before using it, just test the module bool value : if serial: serial.whateverMethod() True, and that does avoid polluting namespace. However, you shouldn't be testing for None as a bool; you should instead do an "if is None:" (or, of course, "is not None"). - Dave From rosuav at gmail.com Tue Nov 15 14:53:26 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 06:53:26 +1100 Subject: Extracting elements over multiple lists? In-Reply-To: <4EC2ACCC.2000100@davea.name> References: <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> <4EC2ACCC.2000100@davea.name> Message-ID: On Wed, Nov 16, 2011 at 5:17 AM, Dave Angel wrote: > a = someexpression... > b = a > .... > del a > > Does not (necessarily) delete the object that a refers to. ?It merely > deletes the symbol a. I'd have to classify that as part of the change of thinking necessary for a refcounted language, and not specific to del at all. The del statement is identical to "a = None" in terms of deleting objects; someone who's come from C++ might want to explicitly del every variable before returning, but that's the only way that it's tied to 'del'. ChrisA From rosuav at gmail.com Tue Nov 15 15:01:40 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 07:01:40 +1100 Subject: suppressing import errors In-Reply-To: <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Wed, Nov 16, 2011 at 6:39 AM, David Riley wrote: > True, and that does avoid polluting namespace. ?However, you shouldn't be testing for None as a bool; you should instead do an "if is None:" (or, of course, "is not None"). Why not? Is there some other way for the module object to evaluate as false? ChrisA From passiday at gmail.com Tue Nov 15 15:37:03 2011 From: passiday at gmail.com (Passiday) Date: Tue, 15 Nov 2011 12:37:03 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript Message-ID: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Hello, I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? From rosuav at gmail.com Tue Nov 15 15:45:52 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 07:45:52 +1100 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: On Wed, Nov 16, 2011 at 7:37 AM, Passiday wrote: > The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. Hmm. If it's to be an educational platform, I would recommend doing something like the W3Schools "tryit" page [1] and just go back to the server each time. You have potential security issues to watch out for (so it may be worth chrooting your interpreter), but it's sure to be easier than rewriting the entire interpreter in another language. You would have to maintain your implementation as the language evolves, keep it bug-free, etc, etc. ChrisA [1] eg http://www.w3schools.com/html/tryit.asp?filename=tryhtml_basic From ian.g.kelly at gmail.com Tue Nov 15 15:52:49 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 15 Nov 2011 13:52:49 -0700 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: On Tue, Nov 15, 2011 at 1:37 PM, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. You could take a look at pyjamas, but it's precompiled. I don't know whether they have support for runtime compilation at all. From stef.mientki at gmail.com Tue Nov 15 16:08:28 2011 From: stef.mientki at gmail.com (Stef Mientki) Date: Tue, 15 Nov 2011 22:08:28 +0100 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: <4EC2D4CC.2090601@gmail.com> On 15-11-2011 21:37, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? skulpt ? cheers, Stef From fraveydank at gmail.com Tue Nov 15 16:20:33 2011 From: fraveydank at gmail.com (David Riley) Date: Tue, 15 Nov 2011 16:20:33 -0500 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Nov 15, 2011, at 3:01 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 6:39 AM, David Riley wrote: >> True, and that does avoid polluting namespace. However, you shouldn't be testing for None as a bool; you should instead do an "if is None:" (or, of course, "is not None"). > > Why not? Is there some other way for the module object to evaluate as false? Well, probably not. It was my understanding that "None" evaluating to a Boolean false was not necessarily guaranteed; I've even gotten some warnings from Python to that effect, though I can't recall the context in which that happened. In any case, PEP 8 states: Comparisons to singletons like None should always be done with 'is' or 'is not', never the equality operators. Also, beware of writing "if x" when you really mean "if x is not None" -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context! Obviously, that last bit doesn't apply to modules; they're not going to evaluate as False in general. I just bristle when I see people writing "if x" when they really mean "if x is not None", perhaps because it's not The Right Way(tm)? It mostly comes down to aesthetics, I guess. Write what you really mean. - Dave From rosuav at gmail.com Tue Nov 15 16:34:02 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 08:34:02 +1100 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Wed, Nov 16, 2011 at 8:20 AM, David Riley wrote: > ? ?Comparisons to singletons like None should always be done with > ? ? ?'is' or 'is not', never the equality operators. > > ? ? ?Also, beware of writing "if x" when you really mean "if x is not None" > ? ? ?-- e.g. when testing whether a variable or argument that defaults to > ? ? ?None was set to some other value. ?The other value might have a type > ? ? ?(such as a container) that could be false in a boolean context! It's probably quicker to execute "if x is None" than "if x" (presumably the former just compares the two pointers). On the other hand, it's more compact to leave off the "is None". And on the gripping hand, neither "quicker to execute" nor "more compact" equates to "more Pythonic". ChrisA From arnodel at gmail.com Tue Nov 15 16:42:22 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 15 Nov 2011 21:42:22 +0000 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On 15 November 2011 21:34, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 8:20 AM, David Riley wrote: >> ? ? ?Comparisons to singletons like None should always be done with >> ? ? ?'is' or 'is not', never the equality operators. >> >> ? ? ?Also, beware of writing "if x" when you really mean "if x is not None" >> ? ? ?-- e.g. when testing whether a variable or argument that defaults to >> ? ? ?None was set to some other value. ?The other value might have a type >> ? ? ?(such as a container) that could be false in a boolean context! > > It's probably quicker to execute "if x is None" than "if x" > (presumably the former just compares the two pointers). On the other > hand, it's more compact to leave off the "is None". And on the > gripping hand, neither "quicker to execute" nor "more compact" equates > to "more Pythonic". It's idiomatic to write "x is None" when you want to know whether x is None. -- Arnaud From ian.g.kelly at gmail.com Tue Nov 15 17:09:31 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 15 Nov 2011 15:09:31 -0700 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Tue, Nov 15, 2011 at 2:42 PM, Arnaud Delobelle wrote: > It's idiomatic to write "x is None" when you want to know whether x is None. It's also idiomatic to just write "if x:" when you want to know whether x is something or nothing, and that's what I would probably do here. Either is correct. From tjreedy at udel.edu Tue Nov 15 17:15:18 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 15 Nov 2011 17:15:18 -0500 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: On 11/15/2011 3:52 PM, Ian Kelly wrote: > On Tue, Nov 15, 2011 at 1:37 PM, Passiday wrote: >> Hello, >> >> I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. >> >> I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > You could take a look at pyjamas, but it's precompiled. I don't know > whether they have support for runtime compilation at all. Perhaps one could use pyjamas to compile pypy to javascript ;-). -- Terry Jan Reedy From steve+comp.lang.python at pearwood.info Tue Nov 15 17:21:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 22:21:41 GMT Subject: Extracting elements over multiple lists? References: <4EB828B3.1020509@sequans.com> Message-ID: <4ec2e5f4$0$29970$c3e8da3$5496439d@news.astraweb.com> On Tue, 15 Nov 2011 17:01:23 +0000, Prasad, Ramit wrote: > Can you expand on why 'del' is "tricky"/misleading? People often imagine that the del statement sends a message to the object "please delete yourself", which then calls the __del__ method. That is incorrect. "del x" is an unbinding operation, it removes the *name* "x" from the current namespace. As a side-effect, if the object which was bound to x no longer has any other references to it, then the garbage collector will delete it and __del__ may be called. (I say "may be called" rather than "will" because there are circumstances where __del__ methods won't get called, such as during interpreter shutdown.) On the other hand, "del x[i]" does work like the way people expect. It deletes items from collections (lists, dicts, etc.) and does so by calling the method x.__delitem__(i). This also may cause the garbage collector to delete the object which was at x[i] if that was the last reference to that object. CPython's implementation keeps a count of references for each object, and the garbage collector deletes the object immediately that reference count reaches zero. This is fast, simple, deterministic (objects will be predictably deleted as soon as they can be), but simple-minded, and so it is aided by a second garbage collector which runs periodically, looking for reference cycles. You can set how often this second garbage collector runs using the gc module. Jython uses the Java garbage collector, and IronPython the .Net garbage collector. Neither are reference counters, and (as far as I know) neither guarantees that objects will be deleted as soon as they are free to be deleted. They will be deleted whenever the garbage collector gets around to it. -- Steven From ckaynor at zindagigames.com Tue Nov 15 17:22:21 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 15 Nov 2011 14:22:21 -0800 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Tue, Nov 15, 2011 at 1:34 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 8:20 AM, David Riley wrote: >> ? ? ?Comparisons to singletons like None should always be done with >> ? ? ?'is' or 'is not', never the equality operators. >> >> ? ? ?Also, beware of writing "if x" when you really mean "if x is not None" >> ? ? ?-- e.g. when testing whether a variable or argument that defaults to >> ? ? ?None was set to some other value. ?The other value might have a type >> ? ? ?(such as a container) that could be false in a boolean context! > > It's probably quicker to execute "if x is None" than "if x" > (presumably the former just compares the two pointers). On the other > hand, it's more compact to leave off the "is None". And on the > gripping hand, neither "quicker to execute" nor "more compact" equates > to "more Pythonic". I decided to run some tests to see which is faster. As is turns out, in simple cases (eg, True), "if x: pass" is faster than "if x is None: pass" if x is True, and otherwise its the same. If x is a custom type (I only tested a simple custom class written in Python), "if x is None: pass" is significantly faster. Overall, performance-wise, it is irrelevant - use the code that is the most clear in the situation. Only if there is a custom type involved, and then only if that type defines Python code to be executed, does it matter. The tests (the code is shown later - its about 53 lines, with lots of copy+paste...): 1a: 0.04 usec/pass -- if None: pass 1b: 0.03 usec/pass -- if True: pass 1c: 0.27 usec/pass -- if customObjectWithNonZero: pass 1d: 0.04 usec/pass -- if customObjectNoNonZero: pass 2a: 0.04 usec/pass -- if None is None: pass 2b: 0.04 usec/pass -- if True is None: pass 2c: 0.04 usec/pass -- if customObjectWithNonZero is None: pass 2d: 0.04 usec/pass -- if customObjectNoNonZero is None: pass The tests were run on Python 2.6x64 on Windows: 2.6.4 (r264:75706, Aug 4 2010, 17:00:56) [MSC v.1500 64 bit (AMD64)] The code: import timeit def test(): numRuns = 10000000 statement1 = 'if x: pass' statement2 = 'if x is None: pass' setup1 = 'x = None' setup2 = 'x = True' setup3 = ''' class Test(object): def __nonzero__(self): return True x = Test()''' setup4 = ''' class Test(object): pass x = Test()''' t1a = timeit.Timer(stmt=statement1, setup=setup1) t1b = timeit.Timer(stmt=statement1, setup=setup2) t1c = timeit.Timer(stmt=statement1, setup=setup3) t1d = timeit.Timer(stmt=statement1, setup=setup4) t2a = timeit.Timer(stmt=statement2, setup=setup1) t2b = timeit.Timer(stmt=statement2, setup=setup2) t2c = timeit.Timer(stmt=statement2, setup=setup3) t2d = timeit.Timer(stmt=statement2, setup=setup4) a1 = [] b1 = [] c1 = [] d1 = [] a2 = [] b2 = [] c2 = [] d2 = [] for i in xrange(10): a1.append(1000000 * t1a.timeit(number=numRuns)/numRuns) b1.append(1000000 * t1b.timeit(number=numRuns)/numRuns) c1.append(1000000 * t1c.timeit(number=numRuns)/numRuns) d1.append(1000000 * t1d.timeit(number=numRuns)/numRuns) a2.append(1000000 * t2a.timeit(number=numRuns)/numRuns) b2.append(1000000 * t2b.timeit(number=numRuns)/numRuns) c2.append(1000000 * t2c.timeit(number=numRuns)/numRuns) d2.append(1000000 * t2d.timeit(number=numRuns)/numRuns) print "1a: %.2f usec/pass" % (sum(a1) / len(a1),) print "1b: %.2f usec/pass" % (sum(b1) / len(b1),) print "1c: %.2f usec/pass" % (sum(c1) / len(c1),) print "1d: %.2f usec/pass" % (sum(d1) / len(d1),) print "2a: %.2f usec/pass" % (sum(a2) / len(a2),) print "2b: %.2f usec/pass" % (sum(b2) / len(b2),) print "2c: %.2f usec/pass" % (sum(c2) / len(c2),) print "2d: %.2f usec/pass" % (sum(d2) / len(d2),) > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > From steve+comp.lang.python at pearwood.info Tue Nov 15 17:25:16 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 22:25:16 GMT Subject: Extracting elements over multiple lists? References: <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> <4EC2ACCC.2000100@davea.name> Message-ID: <4ec2e6cb$0$29970$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Nov 2011 06:53:26 +1100, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 5:17 AM, Dave Angel wrote: >> a = someexpression... >> b = a >> .... >> del a >> >> Does not (necessarily) delete the object that a refers to. ?It merely >> deletes the symbol a. > > I'd have to classify that as part of the change of thinking necessary > for a refcounted language, and not specific to del at all. Languages aren't refcounted. Or at least, *Python* isn't a refcounted language. CPython is a refcounted implementation. IronPython and Jython are not. del behaves exactly the same in IronPython and Jython as it does in CPython: it removes the name, which may have a side-effect of deleting the object. > The del > statement is identical to "a = None" in terms of deleting objects; I'm not entirely sure what you arr trying to say here. I *think* you are trying to say is this: Given that `a` is bound to my_object initially, `del a` from the point of view of my_object is no different from re-binding a to some other object such as None (or any other object). which is true as far as it goes, but it fails to note that the name "a" no longer exists after `del a` while it does exist after `a = None`. -- Steven From steve+comp.lang.python at pearwood.info Tue Nov 15 17:34:34 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 22:34:34 GMT Subject: suppressing import errors References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: <4ec2e8fa$0$29970$c3e8da3$5496439d@news.astraweb.com> On Tue, 15 Nov 2011 14:22:21 -0800, Chris Kaynor wrote: > The tests (the code is shown later - its about 53 lines, with lots of > copy+paste...): Holy unnecessarily complicated code Batman! This is much simpler: [steve at ando ~]$ python -m timeit -s "x = None" "if x is None: pass" 10000000 loops, best of 3: 0.0738 usec per loop [steve at ando ~]$ python -m timeit -s "x = True" "if x is None: pass" 10000000 loops, best of 3: 0.0799 usec per loop The difference is too small to be significant. If I run the same tests multiple times, the winner could easily change. -- Steven From rosuav at gmail.com Tue Nov 15 17:54:15 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 09:54:15 +1100 Subject: Extracting elements over multiple lists? In-Reply-To: <4ec2e6cb$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> <4EC2ACCC.2000100@davea.name> <4ec2e6cb$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Nov 16, 2011 at 9:25 AM, Steven D'Aprano wrote: > Languages aren't refcounted. Or at least, *Python* isn't a refcounted > language. CPython is a refcounted implementation. IronPython and Jython > are not. del behaves exactly the same in IronPython and Jython as it does > in CPython: it removes the name, which may have a side-effect of deleting > the object. Yes, I was sloppy there. A non-manually-memory-managed language, if you will; it's part of Python's spec that you do NOT have to explicitly release objects you're no longer using. >> The del >> statement is identical to "a = None" in terms of deleting objects; > > I'm not entirely sure what you arr trying to say here. I *think* you are > trying to say is this: > > ? ?Given that `a` is bound to my_object initially, `del a` > ? ?from the point of view of my_object is no different > ? ?from re-binding a to some other object such as None > ? ?(or any other object). > > which is true as far as it goes, but it fails to note that the name "a" > no longer exists after `del a` while it does exist after `a = None`. Right. Both actions have the same effect wrt deleting my_object; the only connection between Python's "del" and C++'s "delete" is that, which del shares with "a = None". The fact is that, regardless of the Python implementation, deleting *objects* is not the programmer's responsibility. The only thing he can or must do is delete *names*. del a del globals()['a'] globals().__delitem__('a') are all roughly equivalent (assuming that a is global). Maybe this is the best way to explain it - that you're deleting from a "dictionary" (which may or may not actually be implemented as a dict) of local names. ChrisA From ameyer2 at yahoo.com Tue Nov 15 17:59:12 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 15 Nov 2011 17:59:12 -0500 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: <4EC2EEC0.2090806@yahoo.com> On 11/15/2011 4:20 PM, David Riley wrote: ... > None was set to some other value. The other value might have a type > (such as a container) that could be false in a boolean context! > > Obviously, that last bit doesn't apply to modules; they're not going to evaluate as False in general. I just bristle when I see people writing "if x" when they really mean "if x is not None", perhaps because it's not The Right Way(tm)? It mostly comes down to aesthetics, I guess. Write what you really mean. Actually Dave, as your quote from PEP 8 says, the difference is real. It's not just aesthetics. Consider this: x = None if x: print('if x == true') else: print('if x == false') if x is None: print('x is None == true') else: print('x is none == false') y = '' if y: print('if y == true') else: print('if y == false') if y is None: print('y is None == true') else: print('y is none == false') The result is: if x == false x is None == true if y == false y is none == false Alan From ameyer2 at yahoo.com Tue Nov 15 18:05:49 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 15 Nov 2011 18:05:49 -0500 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: <4EC2F04D.5030801@yahoo.com> On 11/15/2011 3:37 PM, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? I don't have any good ideas for how to do this, but I do have a warning. The JavaScript security model prohibits a lot of things that Python does not prohibit. So if you need to do anything like access a file on the user's machine or talk to some computer other than the one you came from, it won't work. Alan From fraveydank at gmail.com Tue Nov 15 18:15:45 2011 From: fraveydank at gmail.com (David Riley) Date: Tue, 15 Nov 2011 18:15:45 -0500 Subject: suppressing import errors In-Reply-To: <4EC2EEC0.2090806@yahoo.com> References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> <4EC2EEC0.2090806@yahoo.com> Message-ID: <0D538417-B0EC-4C2E-B810-53038AB86D3C@gmail.com> On Nov 15, 2011, at 5:59 PM, Alan Meyer wrote: > On 11/15/2011 4:20 PM, David Riley wrote: > ... >> None was set to some other value. The other value might have a type >> (such as a container) that could be false in a boolean context! >> >> Obviously, that last bit doesn't apply to modules; they're not going to evaluate as False in general. I just bristle when I see people writing "if x" when they really mean "if x is not None", perhaps because it's not The Right Way(tm)? It mostly comes down to aesthetics, I guess. Write what you really mean. > > Actually Dave, as your quote from PEP 8 says, the difference is real. It's not just aesthetics. I guess I meant it's aesthetics when it comes down to determining whether a module is None or not; a module is never going to evaluate to False under any feasible circumstances. It's not an aesthetic difference when you consider that the global (or local) namespace may be polluted with other variables that have the same name as your module, but then your evaluation would be entirely invalid anyway. But yes, in the general case, it's much more than an aesthetic difference, which is why I always write "if x is None" when I want to know if it's None (rather than False, 0, [], "", etc). I have been bitten way too many times by doing the lazy thing to keep doing it. - Dave From jabba.laci at gmail.com Tue Nov 15 21:22:11 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Wed, 16 Nov 2011 03:22:11 +0100 Subject: redis beginner question Message-ID: Hi, I'm reading the redis documentation and there is one thing that bothers me. For redis, you need to start a server on localhost. Is there an easy way that my Python script starts this server automatically? Before using my script, I don't want to start redis-server each time. When my program terminates, the server could be shut down automatically. Thanks, Laszlo From pavlovevidence at gmail.com Tue Nov 15 21:51:19 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 15 Nov 2011 18:51:19 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> On Tuesday, November 15, 2011 12:37:03 PM UTC-8, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? Some people have already made an LLVM-to-Javascript compiler, and have managed to build Python 2.7 with it. The LLVM-to-Javascript project is called emscripten. https://github.com/kripken/emscripten/wiki Demo of Python (and a bunch of other languages) here: http://repl.it/ Carl Banks From jason.swails at gmail.com Tue Nov 15 22:02:25 2011 From: jason.swails at gmail.com (Jason Swails) Date: Tue, 15 Nov 2011 22:02:25 -0500 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 12:32 AM, Chris Angelico wrote: > > As a general rule, if any parent is invisible, you won't see the > child, and if any parent is disabled, you can't access the child. Yea, I'm becoming more familiar and comfortable with the GUI hierarchy as I play around. I do like how simple it is to test a concept in Tkinter (just a couple lines builds you a window with any kind of widget you want). > You > may find that there's even a one-line command that will disable the > window, open a new window, wait for the new window to close, and > automatically reenable the window - an "open modal dialog" function or > something. > Apparently I could not do what I was wanting to (state=DISABLED is not a valid option to Toplevel). What I wanted to do was something similar to what the dialogs were doing from tkMessageBox. The window didn't appear changed, but no buttons could be clicked. After looking through the tkMessageBox.py source code, I found the method I was looking for: grab_set. Essentially, I just have to have my new window call its grab_set() method to hog all events. Not really "disabling" the root window (which is why I had a hard time finding it on Google), but it's the exact behavior I was looking for. http://www.python-forum.org/pythonforum/viewtopic.php?f=15&t=4930 was helpful here. The only other approach I (successfully) tried was to use the .withdraw() method on the window during the constructor of the *new* window and execute .deiconify() on it during the new window's destroy() method (before calling Toplevel's destroy on self). I still like the first way better. Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From roy at panix.com Tue Nov 15 22:11:48 2011 From: roy at panix.com (Roy Smith) Date: Tue, 15 Nov 2011 22:11:48 -0500 Subject: redis beginner question References: Message-ID: In article , Jabba Laci wrote: > Hi, > > I'm reading the redis documentation and there is one thing that > bothers me. For redis, you need to start a server on localhost. Is > there an easy way that my Python script starts this server > automatically? Before using my script, I don't want to start > redis-server each time. When my program terminates, the server could > be shut down automatically. > > Thanks, > > Laszlo Why do you want to stop redis after your program terminates? Generally, you just start redis up when the system boots and leave it running. From john.37 at gmail.com Tue Nov 15 22:28:46 2011 From: john.37 at gmail.com (sword) Date: Tue, 15 Nov 2011 19:28:46 -0800 (PST) Subject: Stucked with python logging module Message-ID: <3ce63c21-1880-4cb2-979a-1c806ace4d8f@u37g2000prh.googlegroups.com> I just scaned through the beginer's guide of logging module, but I can't get anything from console. The demo just like this: import logging logging.debug("This is a demo") Maybe I should do sth to put the log to stdout in basicConfig first? Thanks in advance From goldtech at worldpost.com Tue Nov 15 22:38:48 2011 From: goldtech at worldpost.com (goldtech) Date: Tue, 15 Nov 2011 19:38:48 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots Message-ID: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Hi, Using Windows. Is there a python shell that has a history of typed in commands? I don't need output of commands just what I typed it. I need it to save between sessions - something that no shell seems to do. If I reboot there will still be a command history somewhere. Like bash history in Linux. Thanks From john.37 at gmail.com Tue Nov 15 22:45:06 2011 From: john.37 at gmail.com (sword) Date: Tue, 15 Nov 2011 19:45:06 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: <905c6590-84e0-4eab-80bd-3daf12d0a326@y15g2000prl.googlegroups.com> Maybe you're looking for ipython? History, tab-complete, sort of things in it. goldtech wrote: > Hi, > > Using Windows. Is there a python shell that has a history of typed in > commands? > > I don't need output of commands just what I typed it. I need it to > save between sessions - something that no shell seems to do. If I > reboot there will still be a command history somewhere. > > Like bash history in Linux. > > Thanks From rosuav at gmail.com Tue Nov 15 22:49:37 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 14:49:37 +1100 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Wed, Nov 16, 2011 at 2:02 PM, Jason Swails wrote: > Apparently I could not do what I was wanting to (state=DISABLED is not a > valid option to Toplevel).? What I wanted to do was something similar to > what the dialogs were doing from tkMessageBox. Yes, that would be what you'd want. I wonder, though: Is Toplevel the right window class? There may be a better class for a subwindow. Again, I'm not familiar with Tkinter, but a quick google suggests that Frame or Window might be worth looking into. Ideally, you want the window to disable its parent and claim all events. ChrisA From kushal.kumaran+python at gmail.com Wed Nov 16 00:13:10 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Wed, 16 Nov 2011 10:43:10 +0530 Subject: Stucked with python logging module In-Reply-To: <3ce63c21-1880-4cb2-979a-1c806ace4d8f@u37g2000prh.googlegroups.com> References: <3ce63c21-1880-4cb2-979a-1c806ace4d8f@u37g2000prh.googlegroups.com> Message-ID: On Wed, Nov 16, 2011 at 8:58 AM, sword wrote: > I just scaned through the beginer's guide of logging module, but I > can't get anything from console. The demo just like this: > > import logging > logging.debug("This is a demo") > > Maybe I should do sth to put the log to stdout in basicConfig first? Actually, the problem is not of the output location, but of the logging level. In the default configuration, logs at DEBUG level are suppressed. logging.basicConfig will be a simple way to change this. Are you following the logging documentation at http://docs.python.org/py3k/howto/logging.html#logging-basic-tutorial? This page is part of the documentation of the logging module, and is suitable for first-time logging module users. In your case, you can do this: import logging logging.basicConfig(level=logging.DEBUG) logging.debug("This is a demo") -- regards, kushal From john.37 at gmail.com Wed Nov 16 01:09:53 2011 From: john.37 at gmail.com (sword) Date: Tue, 15 Nov 2011 22:09:53 -0800 (PST) Subject: Got some problems when using logging Filter Message-ID: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> The logging cookbook gives an Filter example, explainning how to add contextural info to log. I can't figure out how to filter log from it. Suppose I have 3 file, a.py, b.py and main.py #file: a.py import logging logger=logging.getLogger(__name__) def print_log(): logger.debug("I'm module a") #file: b.py just like a.py import logging logger=logging.getLogger(__name__) def print_log(): logger.debug("I'm module b") #file: main.py import logging from logging import Filter logging.basicConfig(level=logging.DEBUG) logger=logging.getLogger("main") logger.debug("This is main process") logger.addFilter(Filter("a")) And I expected that the console output would contain main and b module log only. But it turned out that all logs there. Is it the problem of root logger? From passiday at gmail.com Wed Nov 16 02:05:21 2011 From: passiday at gmail.com (Passiday) Date: Tue, 15 Nov 2011 23:05:21 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <27707069.794.1321427121532.JavaMail.geo-discussion-forums@yqff21> Thanks Carl, this looks like a good base to start from. From passiday at gmail.com Wed Nov 16 02:07:15 2011 From: passiday at gmail.com (Passiday) Date: Tue, 15 Nov 2011 23:07:15 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <4EC2F04D.5030801@yahoo.com> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <4EC2F04D.5030801@yahoo.com> Message-ID: <11268744.795.1321427235257.JavaMail.geo-discussion-forums@yqff21> Of course, I am aware of this. But the file system can be emulated, and certain networking can be mediated via the server, too. But for starts, I don't plan to go beyond the basic file operations, if at all. From mail at timgolden.me.uk Wed Nov 16 03:37:47 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 16 Nov 2011 08:37:47 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: <4EC3765B.2020204@timgolden.me.uk> On 16/11/2011 03:38, goldtech wrote: > Hi, > > Using Windows. Is there a python shell that has a history of typed in > commands? Have a look at DreamPie: http://dreampie.sourceforge.net/ TJG From ulrich.eckhardt at dominolaser.com Wed Nov 16 04:08:24 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Wed, 16 Nov 2011 10:08:24 +0100 Subject: unit-profiling, similar to unit-testing Message-ID: <95bcp8-bft.ln1@satorlaser.homedns.org> Hi! I'm currently trying to establish a few tests here that evaluate certain performance characteristics of our systems. As part of this, I found that these tests are rather similar to unit-tests, only that they are much more fuzzy and obviously dependent on the systems involved, CPU load, network load, day of the week (Tuesday is virus scan day) etc. What I'd just like to ask is how you do such things. Are there tools available that help? I was considering using the unit testing framework, but the problem with that is that the results are too hard to interpret programmatically and too easy to misinterpret manually. Any suggestions? Cheers! Uli From amirouche.boubekki at gmail.com Wed Nov 16 05:39:09 2011 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Wed, 16 Nov 2011 11:39:09 +0100 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: H?llo I am looking for a way how to bring Python interpreter to JavaScript, in > order to provide a web-based application with python scripting > capabilities. The app would have basic IDE for writing and debugging the > python code, but the interpretation, of course, would be done in > JavaScript. I'd like to avoid any client-server transactions, so all the > interpretation should take place on the client side. The purpose of all > this would be to create educational platform for learning the programming > in python. > You might be looking for http://www.skulpt.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From babiucandreea at gmail.com Wed Nov 16 06:05:10 2011 From: babiucandreea at gmail.com (Andreea Babiuc) Date: Wed, 16 Nov 2011 11:05:10 +0000 Subject: suppressing import errors In-Reply-To: <4EC2B656.7050902@sequans.com> References: <4EC2B656.7050902@sequans.com> Message-ID: Loving the offtopic guys, sorry I have to go back to my problem now.. In the module I want to import I have a few import statements for Maya commands that don't work outside Maya unless I use the Maya standalone interpreter. So before I import this module I need to make sure I import maya and maya.standalone. I make sure I place the correct paths in sys.path, but I get the following error: import maya.standalone ImportError: /apps/Linux64/aw/maya2012/lib/python2.6/site-packages/maya/../../../../lib/libOGSDeviceOGL-2_7.so: undefined symbol: cgGetParameterBufferIndex Now, I've googled this error and couldn't find anything on it and I'd have no idea why it wouldn't work. It's not a python related error so I understand if you couldn't help me with this, but since you've asked :D I am thinking of using eval for each line in the module i want to import (instead of importing it ) and just ignoring the maya related commands. I can't and shouldn't edit any of these modules, I instead have to parse them and interpret the parameters types without actually executing the functions.. Thanks a lot, Andreea On 15 November 2011 18:58, Jean-Michel Pichavant wrote: > David Riley wrote: > >> On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote: >> >> >> >>> On 15 November 2011 17:24, Chris Kaynor >>> wrote: >>> As with any Python code, you can wrap the import into a try: except >>> block. >>> >>> try: >>> import badModule >>> except: >>> >>> pass # Or otherwise handle the exception - possibly importing an >>> alternative module. >>> >>> >>> Hmm, I know this might sound silly, but if it fails I still want to >>> import the module and disable those lines of code that are related to the >>> reason while the module failed to be imported in the first place. Even if >>> that makes the code not 100% correct. >>> >>> Does that make sense ? >>> >>> >> >> It makes sense. It probably also makes sense to only do an "except >> ImportError", since if there are other errors (say, syntax errors in a >> module you're trying to import, rather than its absence, you probably want >> to know about it. >> >> To disable code that won't work without the module you're trying to >> import, you can always set flags in your module. For example, I've got a >> project at work that can use a variety of communications interfaces, >> including using PySerial for serial port comms. But if someone doesn't >> have PySerial installed, I want it to fail gracefully and just not support >> serial. So I can do the following: >> >> >> try: >> import serial >> _serial_enabled = True >> except ImportError: >> print("PySerial not installed - serial ports not supported!") >> _serial_enabled = False >> >> >> And then elsewhere in my module, I can check the value of _serial_enabled >> to see if I should e.g. list the serial ports in available communications >> interfaces. >> >> Of course, if there's some other error in PySerial (maybe I installed a >> broken version with a syntax error?), that error will get propagated up, >> which is a good thing, because I'd rather know that PySerial is broken than >> just have it tell me it's not installed (which is what would happen if I >> simply caught all exceptions). Your mileage may vary. >> >> - Dave >> >> >> > If I'm not wrong the OP wants to disable the line *in the module being > imported*, which is kindof silly and doesn't make sense to answer his > question. > > Anreea, tell us why the module you are importing is failing and if this > module is yours, we may provide you a proper way to handle this situation > (though I'm pretty sure everything is in Dave's proposal). > > JM > PS : @Dave there is a way to avoiding adding symbols to your global > namespace, assign None to the module's name on import errors. Then before > using it, just test the module bool value : if serial: > serial.whateverMethod() > -- Blog: Http://andreeababiuc.ro Photo Portfolio: http://royaa.daportfolio.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanmichel at sequans.com Wed Nov 16 06:40:02 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 16 Nov 2011 12:40:02 +0100 Subject: Got some problems when using logging Filter In-Reply-To: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: <4EC3A112.70400@sequans.com> sword wrote: > The logging cookbook gives an Filter example, explainning how to add > contextural info to log. I can't figure out how to filter log from it. > > Suppose I have 3 file, a.py, b.py and main.py > #file: a.py > import logging > > logger=logging.getLogger(__name__) > def print_log(): > logger.debug("I'm module a") > > #file: b.py just like a.py > import logging > logger=logging.getLogger(__name__) > def print_log(): > logger.debug("I'm module b") > > #file: main.py > import logging > from logging import Filter > logging.basicConfig(level=logging.DEBUG) > logger=logging.getLogger("main") > logger.debug("This is main process") > logger.addFilter(Filter("a")) > > And I expected that the console output would contain main and b module > log only. But it turned out that all logs there. Is it the problem of > root logger? > > > Hi, First of all, in the code you provided we can't see where you import a & b, and when you call their respective print_log method. Secondly,Filter("a") would allow only the "a" log events, not forbid them. quoting the docs: "if name is specified, it names a logger which, together with its children, will have its events allowed through the filter." As for your problem it may come from the fact that you applied the filter to the 'main' logger, while you probably want to add the filter to the *root* logger. Your current hierarchy is root - main - a - b events fired from 'a' will be handled by the root logger, not the main. root = logging.getLogger() root.addFilter('main') root.addFilter('a') root.addFilter('b') JM From john.37 at gmail.com Wed Nov 16 07:31:08 2011 From: john.37 at gmail.com (sword) Date: Wed, 16 Nov 2011 04:31:08 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: On Nov 16, 7:40?pm, Jean-Michel Pichavant wrote: > sword wrote: > > The logging cookbook gives an Filter example, explainning how to add > > contextural info to log. I can't figure out how to filter log from it. > > > Suppose I have 3 file, a.py, b.py and main.py > > #file: a.py > > import logging > > > logger=logging.getLogger(__name__) > > def print_log(): > > ? ? logger.debug("I'm module a") > > > #file: b.py just like a.py > > import logging > > logger=logging.getLogger(__name__) > > def print_log(): > > ? ? logger.debug("I'm module b") > > > #file: main.py > > import logging > > from logging import Filter > > logging.basicConfig(level=logging.DEBUG) > > logger=logging.getLogger("main") > > logger.debug("This is main process") > > logger.addFilter(Filter("a")) > > > And I expected that the console output would contain main and b module > > log only. But it turned out that all logs there. ?Is it the problem of > > root logger? > > Hi, > > First of all, in the code you provided we can't see where you import a & > b, and when you call their respective print_log method. > Secondly,Filter("a") would allow only the "a" log events, not forbid > them. quoting the docs: "if name is specified, it names a logger which, > together with its children, will have its events allowed through the > filter." > > As for your problem it may come from the fact that you applied the > filter to the 'main' logger, while you probably want to add the filter > to the *root* logger. Your current hierarchy is > > root > ? - main > ? - a > ? - b > > events fired from 'a' will be handled by the root logger, not the main. > root = logging.getLogger() > root.addFilter('main') > root.addFilter('a') > root.addFilter('b') > > JM Thanks for your reply. I tried to edit the source a bit, now the main.py looks like this: #main.py import logging from logging import Filter import a import b logging.basicConfig(level=logging.DEBUG) root = logging.getLogger() root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg would pass this filter logger = logging.getLogger("main") logger.debug("main process") a.print_log() b.print_log() #### And It still prints out all the log msg. :( From jabba.laci at gmail.com Wed Nov 16 08:09:43 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Wed, 16 Nov 2011 14:09:43 +0100 Subject: redis beginner question In-Reply-To: References: Message-ID: > Why do you want to stop redis after your program terminates? ?Generally, > you just start redis up when the system boots and leave it running. Hi, OK, so it's more like MySQL or PostgeSQL, i.e. leave the server running in the background. I wanted to use it like SQLite, i.e. let it run only when I need it. Laszlo From dutche at gmail.com Wed Nov 16 08:48:16 2011 From: dutche at gmail.com (Eduardo Oliva) Date: Wed, 16 Nov 2011 05:48:16 -0800 (PST) Subject: Multiple threads Message-ID: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. What I want to do is: I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. I know that Semaphores would help with that. But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. Any help would be great. Thank you in advance From rosuav at gmail.com Wed Nov 16 08:55:40 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Nov 2011 00:55:40 +1100 Subject: Multiple threads In-Reply-To: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: On Thu, Nov 17, 2011 at 12:48 AM, Eduardo Oliva wrote: > Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. > > What I want to do is: > > ?I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. > ?I know that Semaphores would help with that. > ?But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. First off, it's better in CPython (the most popular Python) to use multiple processes than multiple threads. That aside, what you're looking at is a pretty common model - a large number of tasks being served by a pool of workers. Have a look at the multiprocessing module, specifically Pool: Version 2: http://docs.python.org/library/multiprocessing.html Version 3: http://docs.python.org/py3k/library/multiprocessing.html Should be fairly straightforward. ChrisA From hfaber at invalid.net Wed Nov 16 09:07:48 2011 From: hfaber at invalid.net (Henrik Faber) Date: Wed, 16 Nov 2011 15:07:48 +0100 Subject: Multiple threads References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: On 16.11.2011 14:48, Eduardo Oliva wrote: > I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. > I know that Semaphores would help with that. > But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. Absolute standard request, has nothing to do with Python. The way to go (in Cish pseudocode) is: thread() { /* do work */ [...] /* finished! */ semaphore++; } semaphore = 2 while (jobs) { semaphore--; // will block if pool exhausted thread(); } // in the end, collect remaining two workers semaphore -= 2 // will block until all are finished Best regards, Henrik From roy at panix.com Wed Nov 16 09:36:40 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 09:36:40 -0500 Subject: unit-profiling, similar to unit-testing References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: In article <95bcp8-bft.ln1 at satorlaser.homedns.org>, Ulrich Eckhardt wrote: > Hi! > > I'm currently trying to establish a few tests here that evaluate certain > performance characteristics of our systems. As part of this, I found > that these tests are rather similar to unit-tests, only that they are > much more fuzzy and obviously dependent on the systems involved, CPU > load, network load, day of the week (Tuesday is virus scan day) etc. > > What I'd just like to ask is how you do such things. Are there tools > available that help? I was considering using the unit testing framework, > but the problem with that is that the results are too hard to interpret > programmatically and too easy to misinterpret manually. Any suggestions? It's really, really, really hard to either control for, or accurately measure, things like CPU or network load. There's so much stuff you can't even begin to see. The state of your main memory cache. Disk fragmentation. What I/O is happening directly out of kernel buffers vs having to do a physical disk read. How slow your DNS server is today. What I suggest is instrumenting your unit test suite to record not just the pas/fail status of every test, but also the test duration. Stick these into a database as the tests run. Over time, you will accumulate a whole lot of performance data, which you can then start to mine. While you're running the tests, gather as much system performance data as you can (output of top, vmstat, etc) and stick that into your database too. You never know when you'll want to refer to the data, so just collect it all and save it forever. From roy at panix.com Wed Nov 16 09:37:09 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 09:37:09 -0500 Subject: redis beginner question References: Message-ID: In article , Jabba Laci wrote: > > Why do you want to stop redis after your program terminates? ?Generally, > > you just start redis up when the system boots and leave it running. > > Hi, > > OK, so it's more like MySQL or PostgeSQL, i.e. leave the server > running in the background. That's how I would treat it. From __peter__ at web.de Wed Nov 16 09:50:51 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 16 Nov 2011 15:50:51 +0100 Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: sword wrote: > Thanks for your reply. I tried to edit the source a bit, now the > main.py looks like this: > #main.py > import logging > from logging import Filter > import a > import b > > logging.basicConfig(level=logging.DEBUG) > root = logging.getLogger() > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > would pass this filter > > logger = logging.getLogger("main") > logger.debug("main process") > a.print_log() > b.print_log() > > #### > And It still prints out all the log msg. :( Here's a little demo to explore how filtering works: $ cat demo.py import logging class Filter(logging.Filter): def filter(self, record): print "applying filter", self.name return True logging.basicConfig() loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]] for logger in loggers: logger.addFilter(Filter("filter@" + logger.name)) [handler] = logging.getLogger().handlers handler.addFilter(Filter("filter at handler")) for logger in loggers: logger.critical("whatever") $ python demo.py applying filter filter at root applying filter filter at handler CRITICAL:root:whatever applying filter filter at a applying filter filter at handler CRITICAL:a:whatever applying filter filter at a.b applying filter filter at handler CRITICAL:a.b:whatever $ As you can infer from the output only the filter(s) of the original logger and of the handler(s) are applied. From lists at cheimes.de Wed Nov 16 10:01:15 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 16 Nov 2011 16:01:15 +0100 Subject: Multiple threads In-Reply-To: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: Am 16.11.2011 14:48, schrieb Eduardo Oliva: > Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. > > What I want to do is: > > I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. > I know that Semaphores would help with that. > But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. I suggest a slight different approach: use a queue [1] and create two worker threads that consume the queue. You don't need multiprocessing because you are already using multiple processes here (one Python and two ffmpeg processes). Christian [1] http://docs.python.org/library/queue.html From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Wed Nov 16 11:45:29 2011 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Wed, 16 Nov 2011 17:45:29 +0100 Subject: Multiple threads In-Reply-To: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: Am 16.11.2011 14:48 schrieb Eduardo Oliva: > Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. > > What I want to do is: > > I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. > I know that Semaphores would help with that. > But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. > > Any help would be great. I'm not sure if you need threads at all: if you launch a process with subprocess, it runs and you only would have to wait() for it. The same can be done with two processes. Pseudocode: LIMIT = 2 processes = [] def do_waiting(limit): while len(processes) >= limit: % take the first one... sp = processes.pop(0) % wait for it... st = sp.wait(100) if is None: % timeout, not finished yet, push back. processes.append(sp) else: % finished - don't push back, let outer for loop continue. print sp, "has finished with", st for fname in list: % launch process ... sp = subprocess.Popen(...) % ... and register it. processes.append(sp) % If we are on the limit, wait for process to finish. do_waiting(LIMIT) do_waiting(1) Thomas From anthra.norell at bluewin.ch Wed Nov 16 11:57:27 2011 From: anthra.norell at bluewin.ch (Frederic Rentsch) Date: Wed, 16 Nov 2011 17:57:27 +0100 Subject: try - except. How to identify errors unknown in advance? Message-ID: <1321462647.2315.31.camel@hatchbox-one> Hi all, I'd like to log MySQL errors. If I do: try: (command) except MySQLdb.OperationalError, e: print e I may get something like: (1136, "Column count doesn't match value count at row 1") If I don't know in advance which error to expect, but on the contrary want to find out which error occurred, I can catch any error by omitting the name: except: (handle) But now I don't have access to the error message 'e'. I'm sure there's a way and it's probably ridiculously simple. Frederic From whatsjacksemail at gmail.com Wed Nov 16 12:00:57 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Wed, 16 Nov 2011 17:00:57 +0000 Subject: Multiple threads In-Reply-To: References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: Hi Chris, On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelico wrote: > First off, it's better in CPython (the most popular Python) to use > multiple processes than multiple threads. I had been looking into treads and process/subprocess myself a while ago and couldn't decide which would suit what I needed to do best. I'm still very confused about the whole thing. Can you elaborate on the above a bit please? Cheers, Jack -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckaynor at zindagigames.com Wed Nov 16 12:09:39 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 16 Nov 2011 09:09:39 -0800 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: <1321462647.2315.31.camel@hatchbox-one> References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch wrote: > Hi all, > > > I'd like to log MySQL errors. If I do: > > ? ? ? ?try: (command) > ? ? ? ?except MySQLdb.OperationalError, e: print e > > I may get something like: > > ? ? ? ?(1136, "Column count doesn't match value count at row 1") > > If I don't know in advance which error to expect, but on the contrary > want to find out which error occurred, I can catch any error by omitting > the name: > > ? ? ? ?except: (handle) > > But now I don't have access to the error message 'e'. I'm sure there's a > way and it's probably ridiculously simple. except Exception, e: (or, in Py3, except Exception as e is prefereed). Note that you should generally avoid bare except statements "except:" as that will catch everything, including KeyboardInterrupt and SystemExit which may not be desirable. Even without saving the exception in the except statement, you can get the type, value, and traceback with the sys.exc_info command. See http://docs.python.org/library/sys.html#sys.exc_info For example: py>import sys py>try: py> raise RuntimeError py> except: py> print sys.exc_info() py> (, RuntimeError(), ) > > Frederic > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From d at davea.name Wed Nov 16 12:27:52 2011 From: d at davea.name (Dave Angel) Date: Wed, 16 Nov 2011 12:27:52 -0500 Subject: Multiple threads In-Reply-To: References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <4EC3F298.1030604@davea.name> On 11/16/2011 12:00 PM, Jack Keegan wrote: > Hi Chris, > > On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelico wrote: > >> First off, it's better in CPython (the most popular Python) to use >> multiple processes than multiple threads. > > I had been looking into treads and process/subprocess myself a while ago > and couldn't decide which would suit what I needed to do best. I'm still > very confused about the whole thing. Can you elaborate on the above a bit > please? > > Cheers, > > Jack Threads and processes are a concept that exists in your operating system, and Python can use either of them to advantage, depending on the problem. Note that different OS also handle them differently, so code that's optimal on one system might not be as optimal on another. Still, some generalities can be made. Each process is a separate program, with its own address space and its own file handles, etc. You can examine them separately with task manager, for example. If you launch multiple processes, they might not even all have to be python, so if one problem can be handled by an existing program, just run it as a separate process. Processes are generally very protected from each other, and the OS is generally better at scheduling them than it is at scheduling threads within a single process. If you have multiple cores, the processes can really run simultaneously, frequently with very small overhead. The downside is that you cannot share variables between processes without extra work, so if the two tasks are very interdependent, it's more of a pain to use separate processes. Within one process, you can have multiple threads. On some OS, and in some languages, this can be extremely efficient. Some programs launch hundreds of threads, and use them to advantage. By default, it's easy to share data between threads, since they're in the same address space. But the downsides are 1) it's very easy to trash another thread by walking on its variables. 2) Python does a lousy job of letting threads work independently. For CPU-bound tasks, using separate threads is likely to be slower than just doing it all in one thread. -- DaveA From tahoemph at gmail.com Wed Nov 16 12:55:24 2011 From: tahoemph at gmail.com (Michael Hunter) Date: Wed, 16 Nov 2011 09:55:24 -0800 Subject: Multiple threads In-Reply-To: <4EC3F298.1030604@davea.name> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <4EC3F298.1030604@davea.name> Message-ID: On Wed, Nov 16, 2011 at 9:27 AM, Dave Angel wrote: > On 11/16/2011 12:00 PM, Jack Keegan wrote: >[...] Processes [...] and the OS is generally better at scheduling them than it is at > scheduling threads within a single process. ?If you have multiple cores, the > processes can really run simultaneously, frequently with very small > overhead. ?[...] Maybe you are trying to simplify things but in a lot of cases this is just false. In at least some operating systems these days a thread is the basic unit that is scheduled. Processes are thread containers that provide other things (fds, separate address space, etc.). The comment about multiple cores can be extended to multiple threads on a core (CMT) but applies to threads as well as processes. Switching between processes tends to be heavier weight then switching between threads in a process because of the needs to change the address space. Just because Python sucks at threads doesn't make them heavier for the OS. That doesn't mean you shouldn't use multiprocessing. The problem asked about seems a good fit to me to a single python process starting and managing a set of external converter processes. Michael From furoscame at 7fun.de Wed Nov 16 13:00:38 2011 From: furoscame at 7fun.de (furoscame) Date: Wed, 16 Nov 2011 19:00:38 +0100 Subject: How to use pySerial under Windows 7 without administrator rights Message-ID: Hello together, currently I try to use pySerial under Windows 7. But it is not possible to open a serial port without running the script under adminstrator rights. Other programs like Terraterm are able to so without adminstrator rights. What is the reason for that and is it possible open a port without administrator rights in Python? regards furoscame From d at davea.name Wed Nov 16 13:06:40 2011 From: d at davea.name (Dave Angel) Date: Wed, 16 Nov 2011 13:06:40 -0500 Subject: Multiple threads In-Reply-To: References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <4EC3F298.1030604@davea.name> Message-ID: <4EC3FBB0.80601@davea.name> On 11/16/2011 12:55 PM, Michael Hunter wrote: > On Wed, Nov 16, 2011 at 9:27 AM, Dave Angel wrote: >> On 11/16/2011 12:00 PM, Jack Keegan wrote: >> [...] Processes [...] and the OS is generally better at scheduling them than it is at >> scheduling threads within a single process. If you have multiple cores, the >> processes can really run simultaneously, frequently with very small >> overhead. [...] > > Maybe you are trying to simplify things but in a lot of cases this is > just false. In at least some operating systems these days a thread is > the basic unit that is scheduled. Processes are thread containers > that provide other things (fds, separate address space, etc.). The > comment about multiple cores can be extended to multiple threads on a > core (CMT) but applies to threads as well as processes. Switching > between processes tends to be heavier weight then switching between > threads in a process because of the needs to change the address space. > > Just because Python sucks at threads doesn't make them heavier for the OS. > > That doesn't mean you shouldn't use multiprocessing. The problem > asked about seems a good fit to me to a single python process starting > and managing a set of external converter processes. > > Michael > No response is deserved. -- DaveA From d at davea.name Wed Nov 16 13:30:39 2011 From: d at davea.name (Dave Angel) Date: Wed, 16 Nov 2011 13:30:39 -0500 Subject: Multiple threads In-Reply-To: <4EC3FF56.7030101@davea.name> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <4EC3F298.1030604@davea.name> <4EC3FF56.7030101@davea.name> Message-ID: <4EC4014F.8080105@davea.name> On 11/16/2011 01:22 PM, Dave Angel wrote: > (You're top-posting. Put your remarks AFTER what you're quoting) > > On 11/16/2011 12:52 PM, Jack Keegan wrote: >> Ok, I thought that processes would do the same job as threads. So >> would the >> general rule be some thing like so: >> >> If I want another piece of work to run (theoretically) along side my >> main >> script, and I want to share data between them, I should use a thread and >> share data with the thread-safe queue. >> If the work I want done can function and complete on its own, go for a >> process. >> >> Would that be about right? >> > > Yes, with all the caveats I mentioned before. With some language > implementations, and with some operating systems, and on some > CPU-systems, the guidelines could be different. They all trade off in > ways too complex to describe here. > > For example, if a thread is mostly doing I/O, it may be just as > efficient as a separate process, even if sharing data isn't an issue. > > And in some languages, sharing data between processes isn't all that > tough, either. > > Well, you sent me a mail without including the list (just use Reply-All), and I tried to add the list in. Unfortunately, I picked the wrong one, so i sent this to Tutor by mistake. I'll try to fix that now, sorry. -- DaveA From anthra.norell at bluewin.ch Wed Nov 16 13:39:32 2011 From: anthra.norell at bluewin.ch (Frederic Rentsch) Date: Wed, 16 Nov 2011 19:39:32 +0100 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: <1321468772.2315.35.camel@hatchbox-one> On Wed, 2011-11-16 at 09:09 -0800, Chris Kaynor wrote: > On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch > wrote: > > Hi all, > > > > > > I'd like to log MySQL errors. If I do: > > > > try: (command) > > except MySQLdb.OperationalError, e: print e > > > > I may get something like: > > > > (1136, "Column count doesn't match value count at row 1") > > > > If I don't know in advance which error to expect, but on the contrary > > want to find out which error occurred, I can catch any error by omitting > > the name: > > > > except: (handle) > > > > But now I don't have access to the error message 'e'. I'm sure there's a > > way and it's probably ridiculously simple. > > except Exception, e: (or, in Py3, except Exception as e is prefereed). > > Note that you should generally avoid bare except statements "except:" > as that will catch everything, including KeyboardInterrupt and > SystemExit which may not be desirable. > > Even without saving the exception in the except statement, you can get > the type, value, and traceback with the sys.exc_info command. See > http://docs.python.org/library/sys.html#sys.exc_info > > For example: > > py>import sys > py>try: > py> raise RuntimeError > py> except: > py> print sys.exc_info() > py> > (, RuntimeError(), at 0x0000000002371588>) Chris, Thanks very much! Great help! Frederic From lists at cheimes.de Wed Nov 16 13:47:45 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 16 Nov 2011 19:47:45 +0100 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: <1321468772.2315.35.camel@hatchbox-one> References: <1321462647.2315.31.camel@hatchbox-one> <1321468772.2315.35.camel@hatchbox-one> Message-ID: Am 16.11.2011 19:39, schrieb Frederic Rentsch: >> py>import sys >> py>try: >> py> raise RuntimeError >> py> except: >> py> print sys.exc_info() >> py> >> (, RuntimeError(), > at 0x0000000002371588>) > > Chris, Thanks very much! Great help! How about using the excellent logging framework instead of rolling your own stuff? It can print the traceback, too. >>> import logging >>> logging.basicConfig() >>> log = logging.getLogger("mymodule") >>> try: ... raise ValueError("test") ... except Exception: ... log.exception("some message") ... ERROR:mymodule:some message Traceback (most recent call last): File "", line 2, in ValueError: test Christian From python at mrabarnett.plus.com Wed Nov 16 15:21:16 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 16 Nov 2011 20:21:16 +0000 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: <4EC41B3C.6040606@mrabarnett.plus.com> On 16/11/2011 17:09, Chris Kaynor wrote: > On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch > wrote: >> Hi all, >> >> >> I'd like to log MySQL errors. If I do: >> >> try: (command) >> except MySQLdb.OperationalError, e: print e >> >> I may get something like: >> >> (1136, "Column count doesn't match value count at row 1") >> >> If I don't know in advance which error to expect, but on the contrary >> want to find out which error occurred, I can catch any error by omitting >> the name: >> >> except: (handle) >> >> But now I don't have access to the error message 'e'. I'm sure there's a >> way and it's probably ridiculously simple. > > except Exception, e: (or, in Py3, except Exception as e is prefereed). > In Python 3, "except Exception as e" is not just preferred: it's the only form. > Note that you should generally avoid bare except statements "except:" > as that will catch everything, including KeyboardInterrupt and > SystemExit which may not be desirable. > [snip] Very true. From jason.swails at gmail.com Wed Nov 16 15:42:52 2011 From: jason.swails at gmail.com (Jason Swails) Date: Wed, 16 Nov 2011 15:42:52 -0500 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 10:49 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 2:02 PM, Jason Swails > wrote: > > Apparently I could not do what I was wanting to (state=DISABLED is not a > > valid option to Toplevel). What I wanted to do was something similar to > > what the dialogs were doing from tkMessageBox. > > Yes, that would be what you'd want. I wonder, though: Is Toplevel the > right window class? There may be a better class for a subwindow. > Again, I'm not familiar with Tkinter, but a quick google suggests that > Frame or Window might be worth looking into. Ideally, you want the > window to disable its parent and claim all events. > I think Toplevel is right. Frame isn't actually a window (a window has to be its parent), and I've never seen any documentation regarding a Window class (perhaps it's just meant to be a base class that Toplevel inherits from?). I think a separate window needs to be a Toplevel instance (or instance of a Toplevel-derived class). Pulling on the tkMessageBox example again, their base Dialog class inherits from Toplevel. In any case, I've actually found that Tkinter is relatively straightforward to learn, despite some of the bashing it's received here (admittedly I've never tried PyGTK or wxpython or any of the other toolkits because I want to keep dependencies within the stdlib as much as possible). Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From rafadurancastaneda at gmail.com Wed Nov 16 15:48:37 2011 From: rafadurancastaneda at gmail.com (=?ISO-8859-1?Q?Rafael_Dur=E1n_Casta=F1eda?=) Date: Wed, 16 Nov 2011 21:48:37 +0100 Subject: redis beginner question In-Reply-To: References: Message-ID: <4EC421A5.4010601@gmail.com> El 16/11/11 03:22, Jabba Laci escribi?: > Hi, > > I'm reading the redis documentation and there is one thing that > bothers me. For redis, you need to start a server on localhost. Is > there an easy way that my Python script starts this server > automatically? Before using my script, I don't want to start > redis-server each time. When my program terminates, the server could > be shut down automatically. > > Thanks, > > Laszlo I think you are misunderstanding the docs, on ubuntu (or whatever you use) you can do apt-get install redis-server and you'll get what you want. HTH From miki.tebeka at gmail.com Wed Nov 16 15:50:25 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 16 Nov 2011 12:50:25 -0800 (PST) Subject: Multiple threads In-Reply-To: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <17096391.271.1321476625430.JavaMail.geo-discussion-forums@yqhd1> You can see an example on how to use multiprocessing.Pool at http://pythonwise.blogspot.com/2011/03/convert-oggs-to-mp3-fast-way.html This is ogg -> mp3 but the same idea. From ben+python at benfinney.id.au Wed Nov 16 16:09:18 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 17 Nov 2011 08:09:18 +1100 Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: <8762ijlqpt.fsf@benfinney.id.au> goldtech writes: > Using Windows. Is there a python shell that has a history of typed in > commands? I don't know about MS Windows, but the Python interactive shell can be linked with the GNU Readline library for managing its command line including editing features, tab completion, history management, and a persistent history file. You can then use that functionality in your Python interactive startup file. Here's mine: ===== # $HOME/.pythonrc # User configuration for interactive Python shell. import sys import os import os.path import atexit # Tab completion with readline. # Cribbed from . try: import readline except ImportError: sys.stderr.write("Module readline not available.\n") else: import rlcompleter # Enable tab completion. readline.parse_and_bind("tab: complete") # Persistent command history. histfile = os.path.join(os.environ["HOME"], ".python_history") try: readline.read_history_file(histfile) except IOError: # Existing history file can't be read. pass atexit.register(readline.write_history_file, histfile) del histfile del sys, os, atexit ===== Reading the documentation, I see that the ?readline? library is only linked with Python on Unix-alike operating systems. Yet another reason why MS Windows is not a good choice for developing software I guess. -- \ ?The difference between religions and cults is determined by | `\ how much real estate is owned.? ?Frank Zappa | _o__) | Ben Finney From tjreedy at udel.edu Wed Nov 16 16:18:14 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Nov 2011 16:18:14 -0500 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: <1321462647.2315.31.camel@hatchbox-one> References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: On 11/16/2011 11:57 AM, Frederic Rentsch wrote: > If I don't know in advance which error to expect, but on the contrary > want to find out which error occurred, I can catch any error by omitting > the name: > > except: (handle) > > But now I don't have access to the error message 'e'. I'm sure there's a > way and it's probably ridiculously simple. Bare except is a holdover from when exceptions could be strings rather than an instance of a subclass of BaseException. A Python 3 interpreter in effect runs code within a try-except block something like this: try: except BaseException as __exception__: However, use Exception instead of BaseException in your code unless you REALLY know what you are doing and why. -- Terry Jan Reedy From andrea.crotti.0 at gmail.com Wed Nov 16 18:42:02 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 16 Nov 2011 23:42:02 +0000 Subject: pymacs? Message-ID: <4EC44A4A.70201@gmail.com> After a long time, and since it was included iin python-mode, I wanted to try if I can get ropemacs working finally. I have tried many possible things, also in Emacs -Q, and I actually got it working only once, apparently by pure luck with Emacs -Q: (setq py-load-python-mode-pymacs-p nil) (setq ca-pymacs-path (expand-file-name "~/Emacs-configuration/python-mode/pymacs")) (add-to-list 'load-path ca-pymacs-path) (setenv "PYMACS_PYTHON" "python2.7") (require 'pymacs) (pymacs-load "ropemacs" "rope-") (setq ropemacs-confirm-saving 'nil) The problem is that this configuration doesn't use python-mode.el but the standard python.el, all my attempts to make this work on my normal configuration failed. Did anyone got both correctly working? Thanks.. From drobinow at gmail.com Wed Nov 16 18:46:30 2011 From: drobinow at gmail.com (David Robinow) Date: Wed, 16 Nov 2011 18:46:30 -0500 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <8762ijlqpt.fsf@benfinney.id.au> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> Message-ID: On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney wrote: > goldtech writes: > >> Using Windows. Is there a python shell that has a history of typed in >> commands? > > I don't know about MS Windows, but the Python interactive shell can be > linked with the GNU Readline library for managing its command line > including editing > features, tab completion, history management, and a persistent history > file. > > You can then use that functionality in your Python interactive startup > file. Here's mine: > > ===== > # $HOME/.pythonrc > # User configuration for interactive Python shell. > > import sys > import os > import os.path > import atexit > > # Tab completion with readline. > # Cribbed from . > try: > ? ?import readline > except ImportError: > ? ?sys.stderr.write("Module readline not available.\n") > else: > ? ?import rlcompleter > > ? ?# Enable tab completion. > ? ?readline.parse_and_bind("tab: complete") > > ? ?# Persistent command history. > ? ?histfile = os.path.join(os.environ["HOME"], ".python_history") > ? ?try: > ? ? ? ?readline.read_history_file(histfile) > ? ?except IOError: > ? ? ? ?# Existing history file can't be read. > ? ? ? ?pass > ? ?atexit.register(readline.write_history_file, histfile) > > ? ?del histfile > > del sys, os, atexit > > ===== > > Reading the documentation, I see that the ?readline? library is only > linked with Python on Unix-alike operating systems. Yet another reason > why MS Windows is not a good choice for developing software I guess. I'm not sure what documentation you're reading, but your code works fine on Windows. Thanks. [It is necessary to properly set PYTHONSTARTUP] From ben+python at benfinney.id.au Wed Nov 16 18:59:27 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 17 Nov 2011 10:59:27 +1100 Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> Message-ID: <87hb23ei00.fsf@benfinney.id.au> David Robinow writes: > On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney wrote: > > I don't know about MS Windows, but the Python interactive shell can be > > linked with the GNU Readline library for managing its command line > > [?] > > Reading the documentation, I see that the ?readline? library is only > > linked with Python on Unix-alike operating systems. > I'm not sure what documentation you're reading The same documentation I linked to above. Immediately below the title, it specifies a limited set of platforms: ?Platforms: Unix? limiting the availability of the described module. > but your code works fine on Windows. Thanks. I'm glad to know that. Perhaps you could investigate why, and suggest an update to the above documentation if it's wrong? The bug tracker at would be the appropriate place for such a suggestion. -- \ ?Intellectual property is to the 21st century what the slave | `\ trade was to the 16th.? ?David Mertz | _o__) | Ben Finney From drobinow at gmail.com Wed Nov 16 19:49:31 2011 From: drobinow at gmail.com (David Robinow) Date: Wed, 16 Nov 2011 19:49:31 -0500 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <87hb23ei00.fsf@benfinney.id.au> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> <87hb23ei00.fsf@benfinney.id.au> Message-ID: On Wed, Nov 16, 2011 at 6:59 PM, Ben Finney wrote: > David Robinow writes: > >> On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney wrote: >> > I don't know about MS Windows, but the Python interactive shell can be >> > linked with the GNU Readline library for managing its command line >> > > [?] > >> > Reading the documentation, I see that the ?readline? library is only >> > linked with Python on Unix-alike operating systems. > >> ?I'm not sure what documentation you're reading > > The same documentation I linked to above. Immediately below the title, > it specifies a limited set of platforms: ?Platforms: Unix? limiting the > availability of the described module. > >> but your code works fine on Windows. Thanks. > > I'm glad to know that. Perhaps you could investigate why, and suggest an > update to the above documentation if it's wrong? The bug tracker at > would be the appropriate place for such a > suggestion. Upon further investigation, it turns out that I'm using pyreadline from http://pypi.python.org/pypi/pyreadline. I'd forgotten I'd installed it. No documentation fixes appear to be necessary. "The pyreadline package is a python implementation of GNU readline functionality it is based on the ctypes based UNC readline package by Gary Bishop. It is not complete. It has been tested for use with windows 2000 and windows xp." It appears to work in Vista also, at least for the purposes discussed in this thread. From dan at tombstonezero.net Wed Nov 16 20:07:37 2011 From: dan at tombstonezero.net (Dan Sommers) Date: Thu, 17 Nov 2011 01:07:37 +0000 (UTC) Subject: try - except. How to identify errors unknown in advance? References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: On Wed, 16 Nov 2011 17:57:27 +0100, Frederic Rentsch wrote: > I'd like to log MySQL errors. If I do: > > try: (command) > except MySQLdb.OperationalError, e: print e > > I may get something like: > > (1136, "Column count doesn't match value count at row 1") > > If I don't know in advance which error to expect, but on the contrary > want to find out which error occurred, I can catch any error by omitting > the name: > > except: (handle) > > But now I don't have access to the error message 'e'. I'm sure there's a > way and it's probably ridiculously simple. "except" catches any exception that inherits from its argument, and all MySQL exceptions inherit from MySQLError, so something like this will catch only MySQL exceptions and nothing else: try: (command) except MySQLdb.MySQLError as e: print(e) Dan From roy at panix.com Wed Nov 16 20:57:42 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 20:57:42 -0500 Subject: How to insert my own module in front of site eggs? Message-ID: I'm trying to use a custom version of mongoengine. I cloned the git repo and put the directory on my PYTHONPATH, but python is still importing the system's installed version. Looking at sys.path, it's obvious why: $ echo $PYTHONPATH /home/roy/songza:/home/roy/lib/mongoengine >>> pprint.pprint(sys.path) ['', '/usr/local/lib/python2.6/dist-packages/selenium-2.0a5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/unittest2-0.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.eg g', '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/mongoengine-0.5.2-py2.6.egg', '/home/roy/songza', '/home/roy/lib/mongoengine', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages'] The system eggs come before my path. I found http://mail.python.org/pipermail/distutils-sig/2006-July/006520.html in the archives; it explains that eggs come before PYTHONPATH, but doesn't explain how to get around this problem. I emphatically agree with Michael Bayer who said: > I cant think of a possible scenario where a path would explicitly > exist in PYTHONPATH, non-egg or egg, where the user would still like the > system-wide installation to take precedence So, is there any way to get my local copy of mongoengine loaded instead of the system egg? I could probably import sys, and do an egg-ectomy on sys.path before importing mongoengine, but that's too gross to contemplate. From roy at panix.com Wed Nov 16 21:30:57 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 21:30:57 -0500 Subject: staticmethod makes my brain hurt Message-ID: When I run this (python 2.6.1): class C: @staticmethod def foo(): pass print "inside", foo, callable(foo) print "outside", C.foo, callable(C.foo) I get: inside False outside True I don't understand. Why is foo not callable inside of the class definition? Where this comes up is that I'm trying to use a callable default in mongoengine: class User(Document): @staticmethod def _get_next_id(): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) The way mongoengine works is if callable(default) is true, it calls default() to get the real value to use. At the point where the IntField() call is made, _get_next_id is not callable, and eventually I end up with: ValidationError: could not be converted to int From wuwei23 at gmail.com Wed Nov 16 21:44:00 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 16 Nov 2011 18:44:00 -0800 (PST) Subject: staticmethod makes my brain hurt References: Message-ID: On Nov 17, 12:30?pm, Roy Smith wrote: > class C: > ? ? @staticmethod > ? ? def foo(): > ? ? ? ? pass > > ? ? print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I don't understand. ?Why is foo not callable inside of the class > definition? Consider this: >>> def foo(): pass ... >>> foo = staticmethod(foo) >>> callable(foo) False A staticmethod by itself does not appear to be callable. Your internal 'foo' is referring to the staticmethod wrapper. Your external 'C.foo' refers to the result returned by the class mechanism's __getattr__, which I'm guessing is munged into a callable at that point. Where this comes up is that I'm trying to use a callable > default in mongoengine: > > class User(Document): > ? ? @staticmethod > ? ? def _get_next_id(): > ? ? ? [blah, blah, blah] > ? ? ? return id > > ? ? user_id = IntField(required=True, default=_get_next_id) What you're effectively trying to do is use a class before it has been constructed to help construct itself. Just define it as a helper function before the class declaration. From roy at panix.com Wed Nov 16 21:52:57 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 21:52:57 -0500 Subject: staticmethod makes my brain hurt References: Message-ID: In article , alex23 wrote: > What you're effectively trying to do is use a class before it has been > constructed to help construct itself. > > Just define it as a helper function before the class declaration. Yes, this is the workaround I ended up with. From wuwei23 at gmail.com Wed Nov 16 22:04:23 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 16 Nov 2011 19:04:23 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> Message-ID: <3ed98382-5d03-4491-a24a-032f47f5ed5c@u24g2000pru.googlegroups.com> On Nov 17, 7:09?am, Ben Finney wrote: > You can then use that functionality in your Python interactive startup > file. Here's mine: Awesome, thank you for this. I use iPython where ever possible but there are times where I just can't avoid the default shell and this will help immensely. Cheers! From ethan at stoneleaf.us Wed Nov 16 22:24:02 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 16 Nov 2011 19:24:02 -0800 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: <4EC47E52.9080708@stoneleaf.us> Roy Smith wrote: > class User(Document): > @staticmethod > def _get_next_id(): > [blah, blah, blah] > return id > > user_id = IntField(required=True, default=_get_next_id) If you don't call '_get_next_id()' from any class methods (in other words, if you don't need to ever say 'self._gen_next_id()') then you can remove the '@staticmethod': def _get_next_id(): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) If you do need to sometimes call it from a method then still leave off the '@staticmethod', and give 'self' a default of 'None': def _get_next_id(self=None): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) ~Ethan~ From snorble at hotmail.com Wed Nov 16 23:17:21 2011 From: snorble at hotmail.com (snorble) Date: Wed, 16 Nov 2011 20:17:21 -0800 (PST) Subject: Monitoring/inventory client-server app Message-ID: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> I'm writing a tool for monitoring the workstations and servers in our office. I plan to have a server and a client service that runs on each workstation and reports back to the server (heartbeat, disk free space, etc). So far I am considering XMLRPC, or a client service that just downloads a Python file and runs it. With XMLRPC I don't know how to easily add features without having to update every client. Also while playing with XMLRPC I learned that when you run a registered function, it runs it on the server. I was hoping it would run on the client, so that when I get the machine's computer name (or disk space, etc) it will return the client's info. It seems with XMLRPC I would have to hard code the functionality into the client (i.e. client gets it's computer name, then calls the XMLRPC function to pass it to the server)? I was hoping it would work more like, "pass some code to the client to be run on the client, and report it to the server". Almost XMLRPC in the reverse direction. With the download-and-run approach, it seems trivially easy to add new functionality to the clients. Just save the updated Python file to the server, and clients download it and run it. Are there any standard approaches to problems like this that can be recommended? Thank you. From steve+comp.lang.python at pearwood.info Wed Nov 16 23:43:24 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Nov 2011 04:43:24 GMT Subject: staticmethod makes my brain hurt References: Message-ID: <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote: > When I run this (python 2.6.1): > > class C: > @staticmethod > def foo(): > pass > print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I get: > > inside False > outside True > > I don't understand. Why is foo not callable inside of the class > definition? This has come up before. http://bytes.com/topic/python/answers/34396-static-method-object-not-callable http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callable However, the fix is not as simple as merely making staticmethod objects callable. This was discussed at the 2011 language summit: http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html See also this thread: http://mail.python.org/pipermail/python-dev/2011-March/109090.html -- Steven From roy at panix.com Thu Nov 17 00:26:20 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 00:26:20 -0500 Subject: staticmethod makes my brain hurt References: <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4ec490ec$0$30003$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > This has come up before. > > http://bytes.com/topic/python/answers/34396-static-method-object-not-callable > > http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callabl > e > > > However, the fix is not as simple as merely making staticmethod objects > callable. This was discussed at the 2011 language summit: > > http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.h > tml > > See also this thread: > > http://mail.python.org/pipermail/python-dev/2011-March/109090.html Thanks for the links. It always makes me feel good when I get tripped up by something complex and subtle. It almost makes up for all the times when I feel like a dolt because I got tripped up by something obvious and elementary... From jeanpierreda at gmail.com Thu Nov 17 01:20:43 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 17 Nov 2011 01:20:43 -0500 Subject: staticmethod makes my brain hurt In-Reply-To: <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: > However, the fix is not as simple as merely making staticmethod objects > callable. This was discussed at the 2011 language summit: > > http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html > > See also this thread: > > http://mail.python.org/pipermail/python-dev/2011-March/109090.html The notes didn't actually mention what was discussed, but re the second thread, the issue was not changing staticmethod to be callable. Making staticmethod callable is fine, but __get__ still has to return the original function, not self. The context of the second thread was that staticmethod was imagined as one way to eliminate the difference between C and Python functions, when added to a class. But this doesn't quite work, unless staticmethod.__get__ returned self (which broke for related reasons). If it returns the original function (as it does now) then the issue is unresolved: C functions still behave differently from Python functions, so you can't quite just hide them behind a staticmethod and let everything remain the same. It doesn't eliminate the difference in behavior in certain circumstances, e.g.: class MyClass: foo = staticmethod(foo) class MyOtherClass: foo = MyClass.foo MyOtherClass().foo() # what happens if foo is builtin vs pure-Python? In the context of this thread, though, just making it callable without modifying __get__ is fine. Or at least, I don't see the issue. Devin On Wed, Nov 16, 2011 at 11:43 PM, Steven D'Aprano wrote: > On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote: > >> When I run this (python 2.6.1): >> >> class C: >> ? ? @staticmethod >> ? ? def foo(): >> ? ? ? ? pass >> ? ? print "inside", foo, callable(foo) >> >> print "outside", C.foo, callable(C.foo) >> >> I get: >> >> inside False >> outside True >> >> I don't understand. ?Why is foo not callable inside of the class >> definition? > > > This has come up before. > > http://bytes.com/topic/python/answers/34396-static-method-object-not-callable > > http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callable > > > However, the fix is not as simple as merely making staticmethod objects > callable. This was discussed at the 2011 language summit: > > http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html > > See also this thread: > > http://mail.python.org/pipermail/python-dev/2011-March/109090.html > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From dotancohen at gmail.com Thu Nov 17 01:44:23 2011 From: dotancohen at gmail.com (Dotan Cohen) Date: Thu, 17 Nov 2011 08:44:23 +0200 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 04:30, Roy Smith wrote: > When I run this (python 2.6.1): > > class C: > ? ?@staticmethod > ? ?def foo(): > ? ? ? ?pass > > ? ?print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I get: > > inside False > outside True > > I don't understand. ?Why is foo not callable inside of the class > definition? ?Where this comes up is that I'm trying to use a callable > default in mongoengine: > > class User(Document): > ? ?@staticmethod > ? ?def _get_next_id(): > ? ? ?[blah, blah, blah] > ? ? ?return id > > ? ?user_id = IntField(required=True, default=_get_next_id) > > The way mongoengine works is if callable(default) is true, it calls > default() to get the real value to use. ?At the point where the > IntField() call is made, _get_next_id is not callable, and eventually I > end up with: > > ValidationError: could not be > converted to int Try this (untested): class C: @staticmethod def foo(): pass print "inside", C.foo, callable(C.foo) -- Dotan Cohen http://gibberish.co.il http://what-is-what.com From anushritripathi at gmail.com Thu Nov 17 02:05:30 2011 From: anushritripathi at gmail.com (Anushree Tripathi) Date: Thu, 17 Nov 2011 12:35:30 +0530 Subject: problem in running script file of modeller Message-ID: When I run mod9.10 model-default.py command on command window.It is showing that 'import site' failed;use -v for traceback and also error in opening alignment.ali file.Now what do i have to change.Please reply me as soon as possible. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Nov 17 02:37:57 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 17 Nov 2011 00:37:57 -0700 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen wrote: > Try this (untested): > > class C: > ? @staticmethod > ? def foo(): > ? ? ? pass > > ? print "inside", C.foo, callable(C.foo) If you had tested this, you would have found that you get a NameError, since C is not yet bound inside the class block where you define it. From whatsjacksemail at gmail.com Thu Nov 17 02:38:04 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Thu, 17 Nov 2011 07:38:04 +0000 Subject: Multiple threads In-Reply-To: <4EC4014F.8080105@davea.name> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <4EC3F298.1030604@davea.name> <4EC3FF56.7030101@davea.name> <4EC4014F.8080105@davea.name> Message-ID: On Wed, Nov 16, 2011 at 6:30 PM, Dave Angel wrote: > On 11/16/2011 01:22 PM, Dave Angel wrote: > >> (You're top-posting. Put your remarks AFTER what you're quoting) >> >> On 11/16/2011 12:52 PM, Jack Keegan wrote: >> >>> Ok, I thought that processes would do the same job as threads. So would >>> the >>> general rule be some thing like so: >>> >>> If I want another piece of work to run (theoretically) along side my main >>> script, and I want to share data between them, I should use a thread and >>> share data with the thread-safe queue. >>> If the work I want done can function and complete on its own, go for a >>> process. >>> >>> Would that be about right? >>> >>> >> Yes, with all the caveats I mentioned before. With some language >> implementations, and with some operating systems, and on some CPU-systems, >> the guidelines could be different. They all trade off in ways too complex >> to describe here. >> >> For example, if a thread is mostly doing I/O, it may be just as efficient >> as a separate process, even if sharing data isn't an issue. >> >> And in some languages, sharing data between processes isn't all that >> tough, either. >> >> >> Well, you sent me a mail without including the list (just use > Reply-All), and I tried to add the list in. Unfortunately, I picked the > wrong one, so i sent this to Tutor by mistake. I'll try to fix that now, > sorry. Apologies, I usually reply-all and don't usually top-post. Was just rushing out the door when I responded last time. Cheers, Jack -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From bastian.ballmann at notch-interactive.com Thu Nov 17 03:36:59 2011 From: bastian.ballmann at notch-interactive.com (Bastian Ballmann) Date: Thu, 17 Nov 2011 09:36:59 +0100 Subject: pymacs? In-Reply-To: <4EC44A4A.70201@gmail.com> References: <4EC44A4A.70201@gmail.com> Message-ID: <4EC4C7AB.9050807@notch-interactive.com> Hi, why not try out emacs-for-python https://github.com/gabrielelanaro/emacs-for-python It's has everything included one needs as a python programmer on emacs and even if it's not your choice you can lookup pymacs configuration there. HTH && have a nice day Basti Am 17.11.2011 00:42, schrieb Andrea Crotti: > After a long time, and since it was included iin python-mode, I wanted > to try if I can > get ropemacs working finally. > I have tried many possible things, also in Emacs -Q, and I actually > got it working > only once, apparently by pure luck with Emacs -Q: > > (setq py-load-python-mode-pymacs-p nil) > > (setq ca-pymacs-path (expand-file-name > "~/Emacs-configuration/python-mode/pymacs")) > (add-to-list 'load-path ca-pymacs-path) > (setenv "PYMACS_PYTHON" "python2.7") > (require 'pymacs) > > (pymacs-load "ropemacs" "rope-") > (setq ropemacs-confirm-saving 'nil) > > The problem is that this configuration doesn't use python-mode.el but > the standard python.el, > all my attempts to make this work on my normal configuration failed. > Did anyone got both correctly working? > > Thanks.. -- Bastian Ballmann / Web Developer Notch Interactive GmbH / Badenerstrasse 571 / 8048 Z?rich Phone +41 43 818 20 91 / www.notch-interactive.com From ulrich.eckhardt at dominolaser.com Thu Nov 17 03:53:07 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 17 Nov 2011 09:53:07 +0100 Subject: unit-profiling, similar to unit-testing In-Reply-To: References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: Am 16.11.2011 15:36, schrieb Roy Smith: > It's really, really, really hard to either control for, or accurately > measure, things like CPU or network load. There's so much stuff you > can't even begin to see. The state of your main memory cache. Disk > fragmentation. What I/O is happening directly out of kernel buffers vs > having to do a physical disk read. How slow your DNS server is today. Fortunately, I am in a position where I'm running tests on one system (generic desktop PC) while the system to test is another one, and there both hardware and software is under my control. Since this is rather smallish and embedded, the power and load of the desktop don't play a significant role, the other side is usually the bottleneck. ;) > What I suggest is instrumenting your unit test suite to record not just > the pas/fail status of every test, but also the test duration. Stick > these into a database as the tests run. Over time, you will accumulate > a whole lot of performance data, which you can then start to mine. I'm not sure. I see unit tests as something that makes sure things run correctly. For performance testing, I have functions to set up and tear down the environment. Then, I found it useful to have separate code to prime a cache, which is something done before each test run, but which is not part of the test run itself. I'm repeating each test run N times, recording the times and calculating maximum, minimum, average and standard deviation. Some of this is similar to unit testing (code to set up/tear down), but other things are too different. Also, sometimes I can vary tests with a factor F, then I would also want to capture the influence of this factor. I would even wonder if you can't verify the behaviour agains an expected Big-O complexity somehow. All of this is rather general, not specific to my use case, hence my question if there are existing frameworks to facilitate this task. Maybe it's time to create one... > While you're running the tests, gather as much system performance data > as you can (output of top, vmstat, etc) and stick that into your > database too. You never know when you'll want to refer to the data, so > just collect it all and save it forever. Yes, this is surely something that is necessary, in particular since there are no clear success/failure outputs like for unit tests and they require a human to interpret them. Cheers! Uli From john.37 at gmail.com Thu Nov 17 04:06:03 2011 From: john.37 at gmail.com (sword) Date: Thu, 17 Nov 2011 01:06:03 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: <4f5fd473-4717-4f41-8017-d7407adc4571@u10g2000prl.googlegroups.com> On Nov 16, 10:50?pm, Peter Otten <__pete... at web.de> wrote: > sword wrote: > > Thanks for your reply. I tried to edit the source a bit, now the > > main.py looks like this: > > #main.py > > import logging > > from logging import Filter > > import a > > import b > > > logging.basicConfig(level=logging.DEBUG) > > root = logging.getLogger() > > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > > would pass this filter > > > logger = logging.getLogger("main") > > logger.debug("main process") > > a.print_log() > > b.print_log() > > > #### > > And It still prints out all the log msg. :( > > Here's a little demo to explore how filtering works: > > $ cat demo.py > import logging > class Filter(logging.Filter): > ? ? def filter(self, record): > ? ? ? ? print "applying filter", self.name > ? ? ? ? return True > > logging.basicConfig() > > loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]] > for logger in loggers: > ? ? logger.addFilter(Filter("filter@" + logger.name)) > > [handler] = logging.getLogger().handlers > handler.addFilter(Filter("filter at handler")) > > for logger in loggers: > ? ? logger.critical("whatever") > $ python demo.py > applying filter filter at root > applying filter filter at handler > CRITICAL:root:whatever > applying filter filter at a > applying filter filter at handler > CRITICAL:a:whatever > applying filter fil... at a.b > applying filter filter at handler > CRITICAL:a.b:whatever > $ > > As you can infer from the output only the filter(s) of the original logger > and of the handler(s) are applied. Thanks, so if I want to see my own log out of all logs produced by different module in the project, I should addFilter to each corresponding logger. I thought I could add Filter in root and filter out only the interested info from it before. From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Thu Nov 17 04:17:21 2011 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Thu, 17 Nov 2011 10:17:21 +0100 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: Am 17.11.2011 03:30 schrieb Roy Smith: > When I run this (python 2.6.1): > > class C: > @staticmethod > def foo(): > pass > > print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I get: > > inside False > outside True Right. The reason is that on an attribute access, you get a __get__ call of the "real" attribute. That is, if your class has a "regular" method, it is stored there as a formal function. But if you access it (C.f), you get C.__dict__["f"].__get__(None, C) (not sure about the arguments, but you should get the idea). A functions __get__ returns a unbound or bound method, depending on its own arguments. With a static method, you don't want this to happen. So you wrap your "regular" function into a staticmethod object, which has a __get__() method itself just returning the wrapped function object. Look at this: >>> class C(object): pass ... >>> f=lambda *a:a >>> C.f=f >>> s=staticmethod(f) >>> C.s=s >>> # Now we test the access ... >>> f at 0x00B43E30> >>> s >>> C.f > >>> C().f of <__main__.C object at 0x00B48810>> >>> C.s at 0x00B43E30> >>> C().s at 0x00B43E30> >>> f.__get__(None, C) > >>> f.__get__(C(), C) of <__main__.C object at 0x00B48AD0>> >>> s.__get__(None, C) at 0x00B43E30> >>> s.__get__(C(), C) at 0x00B43E30> That's how things work. If you want to get back the "real" function from a staticmethod, you either call its __get__ with an arbitrary argument, or you do it the clean way and do a def deref(s): class C(object): s=s return s.s and so do a class User(Document): @staticmethod def _get_next_id(): [blah, blah, blah] return id user_id = IntField(required=True, default=deref(_get_next_id)) HTH, Thomas From usenet at solar-empire.de Thu Nov 17 04:48:17 2011 From: usenet at solar-empire.de (Marc Christiansen) Date: Thu, 17 Nov 2011 10:48:17 +0100 Subject: How to insert my own module in front of site eggs? References: Message-ID: <1s1fp8-6la.ln1@pluto.solar-empire.de> Roy Smith wrote: > I'm trying to use a custom version of mongoengine. I cloned the git > repo and put the directory on my PYTHONPATH, but python is still > importing the system's installed version. Looking at sys.path, it's > obvious why: > > $ echo $PYTHONPATH > /home/roy/songza:/home/roy/lib/mongoengine > >>>> pprint.pprint(sys.path) > ['', > '/usr/local/lib/python2.6/dist-packages/selenium-2.0a5-py2.6.egg', > '/usr/local/lib/python2.6/dist-packages/unittest2-0.5.1-py2.6.egg', > > '/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.eg > g', > '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.2-py2.6.egg', > '/usr/local/lib/python2.6/dist-packages/mongoengine-0.5.2-py2.6.egg', > '/home/roy/songza', > '/home/roy/lib/mongoengine', [...] > The system eggs come before my path. I found > http://mail.python.org/pipermail/distutils-sig/2006-July/006520.html in > the archives; it explains that eggs come before PYTHONPATH, but doesn't > explain how to get around this problem. I emphatically agree with > Michael Bayer who said: > >> I cant think of a possible scenario where a path would explicitly >> exist in PYTHONPATH, non-egg or egg, where the user would still like the >> system-wide installation to take precedence > > So, is there any way to get my local copy of mongoengine loaded instead > of the system egg? I could probably import sys, and do an egg-ectomy on > sys.path before importing mongoengine, but that's too gross to > contemplate. The only way I found is to edit the easy_install.pth file and comment the two lines starting with "import sys". You'll have to do that every time you install/upgrade an egg via easy_install (and maybe setuptools). In your case the right file should be /usr/local/lib/python2.6/dist-packages/easy_install.pth BTW: You could try pip (http://www.pip-installer.org/) instead of easy_install, it doesn't mess with sys.path. Ciao Marc From anushritripathi at gmail.com Thu Nov 17 04:51:33 2011 From: anushritripathi at gmail.com (Anushree Tripathi) Date: Thu, 17 Nov 2011 15:21:33 +0530 Subject: problem in running script file (model-default.py) Message-ID: When I run script file(i.e.,model-default.py) on IDLE interface,I m getting this error: read_al_373E> Protein specified in ALIGN_CODES(i) was not found in the alignment file; ALIGN_CODES( 1) = 2hyd -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Thu Nov 17 05:12:09 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 17 Nov 2011 02:12:09 -0800 Subject: problem in running script file (model-default.py) In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 1:51 AM, Anushree Tripathi wrote: > When I run script file(i.e.,model-default.py) on IDLE interface,I m > getting?this error: > read_al_373E> Protein specified in ALIGN_CODES(i) was not found in the > alignment file; ALIGN_CODES(?????? 1) =? 2hyd Such an error is entirely specific to the particular script you are running (and/or possibly due to a lack of command-line arguments since you're running it via IDLE). Either consult the script's documentation or author, or post the script here. We can't debug/troubleshoot code we don't have access to. Regards, Chris From Nikunj.Badjatya at emc.com Thu Nov 17 05:39:33 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Thu, 17 Nov 2011 05:39:33 -0500 Subject: ProgressBar - Python and Powershell Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> Hi All, I am using Python 2.7, windows Env. I have an Installer written in Python(45%) and Powershell(55%) which is used to install Virtual Machines at specific locations. It is single threaded. I am trying to implement a ProgressBar for this installer. So that the user will come to know the progress of the installation. I am using pypi progressbar module. The top script is in python which inturns calls powershell scripts using subprocess.call() and proceeds with the installation. I am taking a shared file between python and powershell, so that diff functions can update their %age completion level in to the file. Ex. Func1() updates it to 5%, func2() will add its own 5% to it.. and so on. At the start of the (main.py) script I am creating a thread whose sole purpose would be to keep "READ" a temp file for a new entry in it. Based on this entry I can have my thread update the progressbar on the console. My questions are: 1. Can I have a better shared mechanism between python and powershell.? As I am using a file here. Reading + writing in python and writing only in powershell. ! 2. Does this thread mechanism work.? I am yet to implement and test it.! :P What can be the possible shortfalls.? Thanks Nikunj Bangalore - India -------------- next part -------------- An HTML attachment was scrubbed... URL: From dotancohen at gmail.com Thu Nov 17 06:13:38 2011 From: dotancohen at gmail.com (Dotan Cohen) Date: Thu, 17 Nov 2011 13:13:38 +0200 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 09:37, Ian Kelly wrote: > On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen wrote: >> Try this (untested): >> >> class C: >> ? @staticmethod >> ? def foo(): >> ? ? ? pass >> >> ? print "inside", C.foo, callable(C.foo) > > If you had tested this, you would have found that you get a NameError, > since C is not yet bound inside the class block where you define it. > I hadn't tested, I'm at work far from Idle. Just shooting from the hip. For that matter, though, this does work in Java (I'm pretty sure but again, untested right now). -- Dotan Cohen http://gibberish.co.il http://what-is-what.com From rosuav at gmail.com Thu Nov 17 06:38:19 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Nov 2011 22:38:19 +1100 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 10:13 PM, Dotan Cohen wrote: > I'm at work far from Idle. Taken out of context, I'm sure your boss is pleased. :) ChrisA From roy at panix.com Thu Nov 17 09:03:15 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 09:03:15 -0500 Subject: unit-profiling, similar to unit-testing References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: In article , Ulrich Eckhardt wrote: > Yes, this is surely something that is necessary, in particular since > there are no clear success/failure outputs like for unit tests and they > require a human to interpret them. As much as possible, you want to automate things so no human intervention is required. For example, let's say you have a test which calls foo() and times how long it takes. You've already mentioned that you run it N times and compute some basic (min, max, avg, sd) stats. So far, so good. The next step is to do some kind of regression against past results. Once you've got a bunch of historical data, it should be possible to look at today's numbers and detect any significant change in performance. Much as I loathe the bureaucracy and religious fervor which has grown up around Six Sigma, it does have some good tools. You might want to look into control charts (http://en.wikipedia.org/wiki/Control_chart). You think you've got the test environment under control, do you? Try plotting a month's worth of run times for a particular test on a control chart and see what it shows. Assuming your process really is under control, I would write scripts that did the following kinds of analysis: 1) For a given test, do a linear regression of run time vs date. If the line has any significant positive slope, you want to investigate why. 2) You already mentioned, "I would even wonder if you can't verify the behaviour agains an expected Big-O complexity somehow". Of course you can. Run your test a bunch of times with different input sizes. I would try something like a 1-2-5 progression over several decades (i.e. input sizes of 10, 20, 50, 100, 200, 500, 1000, etc) You will have to figure out what an appropriate range is, and how to generate useful input sets. Now, curve fit your performance numbers to various shape curves and see what correlation coefficient you get. All that being said, in my experience, nothing beats plotting your data and looking at it. From roy at panix.com Thu Nov 17 09:09:34 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 09:09:34 -0500 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> Message-ID: In article <1s1fp8-6la.ln1 at pluto.solar-empire.de>, Marc Christiansen wrote: > > So, is there any way to get my local copy of mongoengine loaded instead > > of the system egg? I could probably import sys, and do an egg-ectomy on > > sys.path before importing mongoengine, but that's too gross to > > contemplate. > > The only way I found is to edit the easy_install.pth file and comment > the two lines starting with "import sys". You'll have to do that every > time you install/upgrade an egg via easy_install (and maybe setuptools). > In your case the right file should be > /usr/local/lib/python2.6/dist-packages/easy_install.pth > > BTW: You could try pip (http://www.pip-installer.org/) instead of > easy_install, it doesn't mess with sys.path. But, you're talking about installers. I'm talking about if I've already got something installed, how do I force one particular python process to pull in a local copy of a module in preference to the installed one? In some cases, I own the machine and can make changes to /usr/local/lib if I want to. But what about on a shared machine? I don't want to (or perhaps can't) play with what's in /usr/local/lib just to make my stuff load first. From duncan.booth at invalid.invalid Thu Nov 17 10:04:49 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 17 Nov 2011 15:04:49 GMT Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> Message-ID: Roy Smith wrote: > In some cases, I own the machine and can make changes to /usr/local/lib > if I want to. But what about on a shared machine? I don't want to (or > perhaps can't) play with what's in /usr/local/lib just to make my stuff > load first. > Have you considered running your code in a virtualenv? http://pypi.python.org/pypi/virtualenv -- Duncan Booth http://kupuguy.blogspot.com From candide at free.invalid Thu Nov 17 10:48:04 2011 From: candide at free.invalid (candide) Date: Thu, 17 Nov 2011 16:48:04 +0100 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: <4ec52cb7$0$16583$426a74cc@news.free.fr> Thanks to all Le 12/11/2011 13:27, Chris Angelico a ?crit : > On Sat, Nov 12, 2011 at 10:56 PM, candide wrote: >> import foo as f >> >> equivalent to >> >> import foo >> f = foo >> > > Not quite, it's closer to: > > import foo > f = foo > del foo > Le 12/11/2011 13:43, Tim Chase a ?crit : > On 11/12/11 05:56, candide wrote: >> First, could you confirm the following syntax >> >> import foo as f >> >> equivalent to >> >> import foo >> f = foo > > and the issuing "del foo" > Correct, I missed this point : I didn't realize that importing is also binding. From candide at free.invalid Thu Nov 17 10:48:32 2011 From: candide at free.invalid (candide) Date: Thu, 17 Nov 2011 16:48:32 +0100 Subject: Use and usefulness of the as syntax In-Reply-To: References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: <4ec52cd3$0$16583$426a74cc@news.free.fr> Le 12/11/2011 13:29, Arnaud Delobelle a ?crit : >> -- The second case seems to be rather widespread and causes math attribute >> to be private but I don't figure out why this matters. > > This way math doesn't get bound in the global namespace when doing > "from module import *" > To contextualize more, I guess you are referring to the following situation : # a.py import math as _math # b.py from a import * print _math.sin(0) # raise a NameError print math.sin(0) # raise a NameError so the as syntax is also seful for hiding name, isn'it ? From wolftracks at invalid.com Thu Nov 17 11:55:36 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 08:55:36 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 Message-ID: Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I uninstalled and installed. Same problem. If one right-clicks on a py file, IDLE is not shown in the menu as Edit with IDLE. After playing with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same results. If I look at a 2.4 install on my laptop, I get the desired reference to Edit with IDLE. My guess is that Win 7 is behind this. If so, it's good-bye Python. Comments? From paul.nospam at rudin.co.uk Thu Nov 17 12:05:17 2011 From: paul.nospam at rudin.co.uk (Paul Rudin) Date: Thu, 17 Nov 2011 17:05:17 +0000 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> Message-ID: <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Roy Smith writes: > But, you're talking about installers. I'm talking about if I've already > got something installed, how do I force one particular python process to > pull in a local copy of a module in preference to the installed one? > > In some cases, I own the machine and can make changes to /usr/local/lib > if I want to. But what about on a shared machine? I don't want to (or > perhaps can't) play with what's in /usr/local/lib just to make my stuff > load first. Maybe I'm missing something - but if I want to do this I just mess about with sys.path at the top of my python script/program. Always seems to work... is there a situation in which it doesn't? From spartan.the at gmail.com Thu Nov 17 12:37:30 2011 From: spartan.the at gmail.com (spartan.the) Date: Thu, 17 Nov 2011 09:37:30 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: On 17 Nov, 18:55, "W. eWatson" wrote: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > results. > > If I look at a 2.4 install on my laptop, I get the desired reference to > Edit with IDLE. > > My guess is that Win 7 is behind this. If so, it's good-bye Python. > > Comments? I prefer "fail fast" approach too. If right-click not working on Win7 is your reason to say good bye to Python then better you do so. From ray040123 at gmail.com Thu Nov 17 12:37:49 2011 From: ray040123 at gmail.com (ray) Date: Fri, 18 Nov 2011 01:37:49 +0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4EC5466D.8000000@gmail.com> On Friday, November 18, 2011 12:55 AM, W. eWatson wrote: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago > I uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. > Same results. > > If I look at a 2.4 install on my laptop, I get the desired reference > to Edit with IDLE. > > My guess is that Win 7 is behind this. If so, it's good-bye Python. > > Comments? Why not good-bye Windows ? Actually you may want to try Vim, or gVim in Windows. I think the people who use IDLE is with really good patient. From gordon at panix.com Thu Nov 17 12:39:56 2011 From: gordon at panix.com (John Gordon) Date: Thu, 17 Nov 2011 17:39:56 +0000 (UTC) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: In "W. eWatson" writes: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > results. I'm not sure I'd describe the lack of IDLE in a context menu as "python not functioning". > If I look at a 2.4 install on my laptop, I get the desired reference to > Edit with IDLE. > My guess is that Win 7 is behind this. If so, it's good-bye Python. It was working originally, right? So the problem can't really just be Win 7. Can you add IDLE manually to the associated applications list? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From therve at free.fr Thu Nov 17 13:02:17 2011 From: therve at free.fr (=?UTF-8?B?VGhvbWFzIEhlcnbDqQ==?=) Date: Thu, 17 Nov 2011 19:02:17 +0100 Subject: Twisted 11.1.0 Released Message-ID: <4EC54C29.80300@free.fr> On behalf of Twisted Matrix Laboratories, I am pleased to announce the release of Twisted 11.1. Highlights of the 185 tickets closed include: * The poll reactor as default where applicable, instead of select everywhere. * A new SSL implementation only relying on OpenSSL for cryptography, (not I/O) making it more robust. * Several improvements to the fresh HTTP/1.1 client implementation, including proxy and cookie support. * My personal favorite: a new howto has been published on test-driven development with Twisted. * A special mention to the new abortConnection support on TCP and SSL connections, heroically pushed by Itamar and Jean-Paul, and the oldest ticket closed by this release. This is the last release supporting Python 2.4 (the support on Windows stopped with 11.0). For more information, see the NEWS file here: http://twistedmatrix.com/Releases/Twisted/11.1/NEWS.txt Download it now from: http://pypi.python.org/packages/source/T/Twisted/Twisted-11.1.0.tar.bz2 or http://pypi.python.org/packages/2.5/T/Twisted/Twisted-11.1.0.win32-py2.5.msi or http://pypi.python.org/packages/2.6/T/Twisted/Twisted-11.1.0.win32-py2.6.msi or http://pypi.python.org/packages/2.7/T/Twisted/Twisted-11.1.0.win32-py2.7.msi Thanks to the supporters of the Twisted Software Foundation and to the many contributors for this release. -- Thomas From steve+comp.lang.python at pearwood.info Thu Nov 17 13:42:36 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Nov 2011 18:42:36 GMT Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <4ec5559c$0$29967$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Nov 2011 08:55:36 -0800, W. eWatson wrote: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > results. I find I get better results when I stop "playing with matters" and start treating them seriously :) If you need help fixing the file associations on your Windows 7 machine, you'll probably get better advice on a dedicated Windows forum. Or even by googling for instructions: https://duckduckgo.com/html/?q=how%20to%20fix%20windows%207%20file%20associations > If I look at a 2.4 install on my laptop, I get the desired reference to > Edit with IDLE. So you're saying that Python is working on one laptop, but not on another machine? Okay. Great. What's your point? You have a messed up installation on your Windows 7 box, and a working installation on your laptop. What would you like us to do? Commiserate? Laugh? Look into a crystal ball and tell you what you did wrong? Can you run Python from the command line? If so, that tells you that Python is installed and working correctly. If Python is installed, then it sounds like a matter of getting the file associates fixed in the registry. Good luck. > My guess is that Win 7 is behind this. If so, it's good-bye Python. > > Comments? Why not good-bye Windows 7? This being Windows, have you run a virus scan with up to date definitions? Then run a *second* scan, using a completely different scanner, because no scanner can catch all viruses? And then run a good anti-spyware program. All of which will be irrelevant 99 times out of 100, but you could be the 1% ... -- Steven From wolftracks at invalid.com Thu Nov 17 15:22:03 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 12:22:03 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 9:39 AM, John Gordon wrote: > In "W. eWatson" writes: > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. > > I'm not sure I'd describe the lack of IDLE in a context menu as > "python not functioning". > >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. > > It was working originally, right? So the problem can't really just be > Win 7. > > Can you add IDLE manually to the associated applications list? > Not successfully. I tried it and pointed to idle.pyw. It gave a Invalid Win32 app. From wolftracks at invalid.com Thu Nov 17 15:31:28 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 12:31:28 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 9:39 AM, John Gordon wrote: > In "W. eWatson" writes: > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. > > I'm not sure I'd describe the lack of IDLE in a context menu as > "python not functioning". Well, yes, and I can run it from the command line. > >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. This has been a nagging problem for far too long. I see no reason why a simple install should make such a difference with the way I get to IDLE. Maybe few people here like IDLE, but for my minimal needs, it's just fine. > > It was working originally, right? So the problem can't really just be > Win 7. I installed it about April 2010, and it worked for months. I then stopped using it until around July 2011. It no longer worked in the IDLE sense. Who really knows? > > Can you add IDLE manually to the associated applications list? > Tried that by sending it directly to idle.pyw, but then trying to get there through the Edit with menu caused a "invalid Win32 app." From rosuav at gmail.com Thu Nov 17 15:43:05 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Nov 2011 07:43:05 +1100 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On Fri, Nov 18, 2011 at 7:31 AM, W. eWatson wrote: > I installed it [Windows 7] about April 2010, and it worked for months. I then stopped > using it until around July 2011. It no longer worked in the IDLE sense. > Microsoft have broken things in many Windowses, and it's often hard to figure out whether the fault is with the Windows version or with the application. MS several times went to ridiculous effort to try to ensure that broken programs that ran under version X would still run under version Y, to the extent of being bug-for-bug compatible. If you're having issues, grab a spare computer, throw Linux on it (I recommend Ubuntu or Debian, others will have other preferred distros), and see if the issues remain. Or if you're having trouble with the GUI, try things from the command line (Windows's command interpreter is pretty weak compared to bash, but it's plenty powerful enough). ChrisA From tycho at tycho.ws Thu Nov 17 15:45:56 2011 From: tycho at tycho.ws (Tycho Andersen) Date: Thu, 17 Nov 2011 14:45:56 -0600 Subject: unit-profiling, similar to unit-testing In-Reply-To: References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: <20111117204556.GD16669@velveeta.cs.wisc.edu> On Wed, Nov 16, 2011 at 09:36:40AM -0500, Roy Smith wrote: > In article <95bcp8-bft.ln1 at satorlaser.homedns.org>, > Ulrich Eckhardt wrote: > > > Hi! > > > > I'm currently trying to establish a few tests here that evaluate certain > > performance characteristics of our systems. As part of this, I found > > that these tests are rather similar to unit-tests, only that they are > > much more fuzzy and obviously dependent on the systems involved, CPU > > load, network load, day of the week (Tuesday is virus scan day) etc. > > > > What I'd just like to ask is how you do such things. Are there tools > > available that help? I was considering using the unit testing framework, > > but the problem with that is that the results are too hard to interpret > > programmatically and too easy to misinterpret manually. Any suggestions? > > It's really, really, really hard to either control for, or accurately > measure, things like CPU or network load. There's so much stuff you > can't even begin to see. The state of your main memory cache. Disk > fragmentation. What I/O is happening directly out of kernel buffers vs > having to do a physical disk read. How slow your DNS server is today. While I agree there's a lot of things you can't control for, you can get a more accurate picture by using CPU time instead of wall time (e.g. the clock() system call). If what you care about is mostly CPU time, you can control for the "your disk is fragmented", "your DNS server died", or "my cow-orker was banging on the test machine" this way. \t From spartan.the at gmail.com Thu Nov 17 15:46:38 2011 From: spartan.the at gmail.com (spartan.the) Date: Thu, 17 Nov 2011 12:46:38 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <6b26958f-291e-4c0f-8dce-36343781a63e@t16g2000vba.googlegroups.com> On Nov 17, 10:31?pm, "W. eWatson" wrote: > On 11/17/2011 9:39 AM, John Gordon wrote:> In ?"W. eWatson" ?writes: > > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > >> uninstalled and installed. Same problem. If one right-clicks on a py > >> file, IDLE is not shown in the menu as Edit with IDLE. After playing > >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > >> results. > > > I'm not sure I'd describe the lack of IDLE in a context menu as > > "python not functioning". > > Well, yes, and I can run it from the command line. > > >> If I look at a 2.4 install on my laptop, I get the desired reference to > >> Edit with IDLE. > > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. > > This has been a nagging problem for far too long. I see no reason why a > simple install should make such a difference with the way I get to IDLE. > Maybe few people here like IDLE, but for my minimal needs, it's just fine. > > > > > It was working originally, right? ?So the problem can't really just be > > Win 7. > > I installed it about April 2010, and it worked for months. I then > stopped using it until around July 2011. It no longer worked in the IDLE > sense. > > Who really knows? > > > > > Can you add IDLE manually to the associated applications list? > > Tried that by sending it directly to idle.pyw, but then trying to get > there through the Edit with menu caused a "invalid Win32 app." idle.pyw is not executable in Windows, but you can right-click it, open, browse to pythonw.exe. Then it should work. From python at mrabarnett.plus.com Thu Nov 17 15:59:33 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 17 Nov 2011 20:59:33 +0000 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4EC575B5.2070504@mrabarnett.plus.com> On 17/11/2011 20:31, W. eWatson wrote: > On 11/17/2011 9:39 AM, John Gordon wrote: >> In "W. eWatson" >> writes: >> >>> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >>> uninstalled and installed. Same problem. If one right-clicks on a py >>> file, IDLE is not shown in the menu as Edit with IDLE. After playing >>> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >>> results. >> >> I'm not sure I'd describe the lack of IDLE in a context menu as >> "python not functioning". > Well, yes, and I can run it from the command line. >> >>> If I look at a 2.4 install on my laptop, I get the desired reference to >>> Edit with IDLE. >> >>> My guess is that Win 7 is behind this. If so, it's good-bye Python. > This has been a nagging problem for far too long. I see no reason why a > simple install should make such a difference with the way I get to IDLE. > Maybe few people here like IDLE, but for my minimal needs, it's just fine. > >> >> It was working originally, right? So the problem can't really just be >> Win 7. > I installed it about April 2010, and it worked for months. I then > stopped using it until around July 2011. It no longer worked in the IDLE > sense. > > Who really knows? > >> >> Can you add IDLE manually to the associated applications list? >> > Tried that by sending it directly to idle.pyw, but then trying to get > there through the Edit with menu caused a "invalid Win32 app." Are you trying to associate .pyw with idle.pyw instead of with pythonw.exe? From spartan.the at gmail.com Thu Nov 17 16:28:56 2011 From: spartan.the at gmail.com (spartan.the) Date: Thu, 17 Nov 2011 13:28:56 -0800 (PST) Subject: unit-profiling, similar to unit-testing References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: On Nov 17, 4:03?pm, Roy Smith wrote: > In article , > ?Ulrich Eckhardt wrote: > > > Yes, this is surely something that is necessary, in particular since > > there are no clear success/failure outputs like for unit tests and they > > require a human to interpret them. > > As much as possible, you want to automate things so no human > intervention is required. > > For example, let's say you have a test which calls foo() and times how > long it takes. ?You've already mentioned that you run it N times and > compute some basic (min, max, avg, sd) stats. ?So far, so good. > > The next step is to do some kind of regression against past results. > Once you've got a bunch of historical data, it should be possible to > look at today's numbers and detect any significant change in performance. > > Much as I loathe the bureaucracy and religious fervor which has grown up > around Six Sigma, it does have some good tools. ?You might want to look > into control charts (http://en.wikipedia.org/wiki/Control_chart). ?You > think you've got the test environment under control, do you? ?Try > plotting a month's worth of run times for a particular test on a control > chart and see what it shows. > > Assuming your process really is under control, I would write scripts > that did the following kinds of analysis: > > 1) For a given test, do a linear regression of run time vs date. ?If the > line has any significant positive slope, you want to investigate why. > > 2) You already mentioned, "I would even wonder if you can't verify the > behaviour agains an expected Big-O complexity somehow". ?Of course you > can. ?Run your test a bunch of times with different input sizes. ?I > would try something like a 1-2-5 progression over several decades (i.e. > input sizes of 10, 20, 50, 100, 200, 500, 1000, etc) ?You will have to > figure out what an appropriate range is, and how to generate useful > input sets. ?Now, curve fit your performance numbers to various shape > curves and see what correlation coefficient you get. > > All that being said, in my experience, nothing beats plotting your data > and looking at it. I strongly agree with Roy, here. Ulrich, I recommend you to explore how google measures appengine's health here: http://code.google.com/status/appengine. Unit tests are inappropriate here; any single unit test can answer PASS or FAIL, YES or NO. It can't answer the question "how much". Unless you just want to use unit tests. Then any arguments here just don't make sense. I suggest: 1. Decide what you want to measure. Measure result must be a number in range (0..100, -5..5), so you can plot them. 2. Write no-UI programs to get each number (measure) and write it to CSV. Run each of them several times take away 1 worst and 1 best result, and take and average number. 3. Collect the data for some period of time. 4. Plot those average number over time axis (it's easy with CSV format). 5. Make sure you automate this process (batch files or so) so the plot is generated automatically each hour or each day. And then after a month you can decide if you want to divide your number ranges into green-yellow-red zones. More often than not you may find that your measures are so inaccurate and random that you can't trust them. Then you'll either forget that or dive into math (statistics). You have about 5% chances to succeed ;) From tjreedy at udel.edu Thu Nov 17 17:12:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 17 Nov 2011 17:12:44 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 11:55 AM, W. eWatson wrote: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > results. > > If I look at a 2.4 install on my laptop, I get the desired reference to > Edit with IDLE. > > My guess is that Win 7 is behind this. If so, it's good-bye Python. I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine. However, I almost never use that with Explorer to open files. I have IDLE pinned to the task bar so it is one click to start. If I edit a file, I want to run it, so I want a shell window open anyway. I usually open files to edit with the first three entries under the File menu: New File, Open, or Recent Files. Once I open a file in a particular directory (usually with Recent Files), Open initially looks for files in the same directory, which is usually what I want. So say hello again to Python, especially Python 3. -- Terry Jan Reedy From irmen at -NOSPAM-razorvine.net Thu Nov 17 17:31:50 2011 From: irmen at -NOSPAM-razorvine.net (Irmen de Jong) Date: Thu, 17 Nov 2011 23:31:50 +0100 Subject: Monitoring/inventory client-server app In-Reply-To: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> References: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> Message-ID: <4ec58b51$0$6842$e4fe514c@news2.news.xs4all.nl> On 17-11-2011 5:17, snorble wrote: > I'm writing a tool for monitoring the workstations and servers in our > office. I plan to have a server and a client service that runs on each > workstation and reports back to the server (heartbeat, disk free > space, etc). > > So far I am considering XMLRPC, or a client service that just > downloads a Python file and runs it. > > With XMLRPC I don't know how to easily add features without having to > update every client. Also while playing with XMLRPC I learned that > when you run a registered function, it runs it on the server. I was > hoping it would run on the client, so that when I get the machine's > computer name (or disk space, etc) it will return the client's info. > It seems with XMLRPC I would have to hard code the functionality into > the client (i.e. client gets it's computer name, then calls the XMLRPC > function to pass it to the server)? I was hoping it would work more > like, "pass some code to the client to be run on the client, and > report it to the server". Almost XMLRPC in the reverse direction. > > With the download-and-run approach, it seems trivially easy to add new > functionality to the clients. Just save the updated Python file to the > server, and clients download it and run it. > > Are there any standard approaches to problems like this that can be > recommended? Thank you. The security implications are HUGE when you are thinking about transferring and executing arbitrary code over the network. Avoid this if at all possible. But if you can be 100% sure it's only trusted stuff, things are not so grim. Have a look at Pyro, or even Pyro Flame: http://packages.python.org/Pyro4/ http://packages.python.org/Pyro4/flame.html Flame allows for very easy remote module execution and a limited way of transferring code to the 'other side'. Also what is wrong with running an XMLrpc server, or Pyro daemon, on your client machines? This way your central computer can call registered methods (or remote objects in case of Pyro) on the client and execute code there (that reports all sorts of stuff you want to know). Or have each client call into a central server, where it reports that stuff itself. Many ways to skin a cat. Regards, Irmen de Jong From wolftracks at invalid.com Thu Nov 17 18:54:39 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 15:54:39 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: <6b26958f-291e-4c0f-8dce-36343781a63e@t16g2000vba.googlegroups.com> References: <6b26958f-291e-4c0f-8dce-36343781a63e@t16g2000vba.googlegroups.com> Message-ID: On 11/17/2011 12:46 PM, spartan.the wrote: > On Nov 17, 10:31 pm, "W. eWatson" wrote: >> On 11/17/2011 9:39 AM, John Gordon wrote:> In "W. eWatson" writes: >> >>>> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >>>> uninstalled and installed. Same problem. If one right-clicks on a py >>>> file, IDLE is not shown in the menu as Edit with IDLE. After playing >>>> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >>>> results. >> >>> I'm not sure I'd describe the lack of IDLE in a context menu as >>> "python not functioning". >> >> Well, yes, and I can run it from the command line. >> >>>> If I look at a 2.4 install on my laptop, I get the desired reference to >>>> Edit with IDLE. >> >>>> My guess is that Win 7 is behind this. If so, it's good-bye Python. >> >> This has been a nagging problem for far too long. I see no reason why a >> simple install should make such a difference with the way I get to IDLE. >> Maybe few people here like IDLE, but for my minimal needs, it's just fine. >> >> >> >>> It was working originally, right? So the problem can't really just be >>> Win 7. >> >> I installed it about April 2010, and it worked for months. I then >> stopped using it until around July 2011. It no longer worked in the IDLE >> sense. >> >> Who really knows? >> >> >> >>> Can you add IDLE manually to the associated applications list? >> >> Tried that by sending it directly to idle.pyw, but then trying to get >> there through the Edit with menu caused a "invalid Win32 app." > > idle.pyw is not executable in Windows, but you can right-click it, > open, browse to pythonw.exe. Then it should work. right-click on junk.py gives me a menu. I select Open with, and ... hmmm, whoops, in the latest install, 2.7.2, I did not give it access to idle.pyw. My mistake above. I was talking about the previous 2.5.2 of install in Win7. Where I'm at is 2.7.2 now. However, I still find in very odd there is no Edit with IDLE when I right-click on junk.py. That's the way it worked on 2.5.2 on my XP and earlier, 2010, on Win7. Downright frustrating. From wolftracks at invalid.com Thu Nov 17 19:00:31 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 16:00:31 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 12:59 PM, MRAB wrote: > On 17/11/2011 20:31, W. eWatson wrote: >> On 11/17/2011 9:39 AM, John Gordon wrote: >>> In "W. eWatson" >>> writes: >>> >>>> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >>>> uninstalled and installed. Same problem. If one right-clicks on a py >>>> file, IDLE is not shown in the menu as Edit with IDLE. After playing >>>> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >>>> results. >>> >>> I'm not sure I'd describe the lack of IDLE in a context menu as >>> "python not functioning". >> Well, yes, and I can run it from the command line. >>> >>>> If I look at a 2.4 install on my laptop, I get the desired reference to >>>> Edit with IDLE. >>> >>>> My guess is that Win 7 is behind this. If so, it's good-bye Python. >> This has been a nagging problem for far too long. I see no reason why a >> simple install should make such a difference with the way I get to IDLE. >> Maybe few people here like IDLE, but for my minimal needs, it's just >> fine. >> >>> >>> It was working originally, right? So the problem can't really just be >>> Win 7. >> I installed it about April 2010, and it worked for months. I then >> stopped using it until around July 2011. It no longer worked in the IDLE >> sense. >> >> Who really knows? >> >>> >>> Can you add IDLE manually to the associated applications list? >>> >> Tried that by sending it directly to idle.pyw, but then trying to get >> there through the Edit with menu caused a "invalid Win32 app." > > Are you trying to associate .pyw with idle.pyw instead of with > pythonw.exe? What does pythonw.exe do for me? I would think all associations would be correct after an install. The single thing I do not understand is why in my latest install of 2.5.2 and 2.7.2 (2.5.2 was uninstalled before going to 2.7.2) on Win7 that why a right-click on a py file does not show as a choice is "Edit with IDLE", as it does on my XP PC and my 2010 install of 2.5.2 on this Win 7 PC. To me that signals that something is wrong. From wolftracks at invalid.com Thu Nov 17 19:03:14 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 16:03:14 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 2:12 PM, Terry Reedy wrote: > On 11/17/2011 11:55 AM, W. eWatson wrote: >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. >> >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. >> >> My guess is that Win 7 is behind this. If so, it's good-bye Python. > > I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine. > However, I almost never use that with Explorer to open files. I have > IDLE pinned to the task bar so it is one click to start. If I edit a > file, I want to run it, so I want a shell window open anyway. I usually > open files to edit with the first three entries under the File menu: New > File, Open, or Recent Files. Once I open a file in a particular > directory (usually with Recent Files), Open initially looks for files in > the same directory, which is usually what I want. So say hello again to > Python, especially Python 3. > I have not found any successful way to get to IDLE. It's on on the right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails with a "invalid Win32 app" msg. From steve+comp.lang.python at pearwood.info Thu Nov 17 19:24:47 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Nov 2011 00:24:47 GMT Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: > I have not found any successful way to get to IDLE. It's on on the > right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails > with a "invalid Win32 app" msg. If you associate .pyw files with pythonw.exe, and then open idle.pyw, does it work? Failing that, go to your laptop where the associations are right, and see what they are, then duplicate the settings on your Windows 7 machine. -- Steven From roy at panix.com Thu Nov 17 20:36:38 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 20:36:38 -0500 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: In article <874ny2fzn6.fsf at no-fixed-abode.cable.virginmedia.net>, Paul Rudin wrote: > Roy Smith writes: > > > > But, you're talking about installers. I'm talking about if I've already > > got something installed, how do I force one particular python process to > > pull in a local copy of a module in preference to the installed one? > > > > In some cases, I own the machine and can make changes to /usr/local/lib > > if I want to. But what about on a shared machine? I don't want to (or > > perhaps can't) play with what's in /usr/local/lib just to make my stuff > > load first. > > Maybe I'm missing something - but if I want to do this I just mess about > with sys.path at the top of my python script/program. Always seems to > work... is there a situation in which it doesn't? What if the first import of a module is happening inside some code you don't have access to? It just seems mind-boggling to me that PYTHONPATH doesn't preempt everything else. From roy at panix.com Thu Nov 17 20:38:30 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 20:38:30 -0500 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> Message-ID: In article , Duncan Booth wrote: > Roy Smith wrote: > > > In some cases, I own the machine and can make changes to /usr/local/lib > > if I want to. But what about on a shared machine? I don't want to (or > > perhaps can't) play with what's in /usr/local/lib just to make my stuff > > load first. > > > > Have you considered running your code in a virtualenv? > http://pypi.python.org/pypi/virtualenv I do that for some projects. In fact, I suspect I will do that for all furture projects that I start from scratch. For this particular one, there's a lot of stuff already installed in the system that I need. From martin.hellwig at gmail.com Thu Nov 17 20:55:56 2011 From: martin.hellwig at gmail.com (Martin P. Hellwig) Date: Fri, 18 Nov 2011 01:55:56 +0000 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: <6b26958f-291e-4c0f-8dce-36343781a63e@t16g2000vba.googlegroups.com> Message-ID: On 17/11/2011 23:54, W. eWatson wrote: > My mistake above. I was talking about the previous 2.5.2 of install in > Win7. Where I'm at is 2.7.2 now. However, I still find in very odd there > is no Edit with IDLE when I right-click on junk.py. That's the way it > worked on 2.5.2 on my XP and earlier, 2010, on Win7. Downright frustrating. > Well if I was still a windows administrator and you would be one of my users, I would first make sure that your profile or windows installation is not pooped as it definitively smells like that. After being reassured that this is not the case I would then search the interwebs for something like "extending right click context menu". Probably hitting something like this: http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-can-i-customize-right-click-mouse-context-menu/5ea7104f-2213-41b9-9933-83f25da086d1 And after that searching where this 'idle' you speak of is actually located, probably finding something like this: http://stackoverflow.com/questions/118260/how-to-start-idle-python-editor-without-using-the-shortcut-on-windows-vista Then it rest me to combine them both, after promising myself not to install one version of a particular program 'for all users' and then 'updating' for 'only me' as this can screw up the default settings quite badly. But hey I haven't been a win admin since I switched over to FreeBSD years and years ago. I find it immensely reassuring that the problems I encounter on my systems are all my fault, well actually that is just the same as with windows, just less obvious there. Luckily I am no longer an administrator either as I couldn't stand it anymore when users spill their frustrations, although perfectly understandable, unto those who are actually willing to help. Something to do with attitude or so, speaking if which, I do apologize for my own attitude, but given the choice of just ignoring you or lacing my post with patronization I though that the latter one was the least bad of them two. -- mph From roy at panix.com Thu Nov 17 21:00:00 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 21:00:00 -0500 Subject: unit-profiling, similar to unit-testing References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: In article , Tycho Andersen wrote: > While I agree there's a lot of things you can't control for, you can > get a more accurate picture by using CPU time instead of wall time > (e.g. the clock() system call). If what you care about is mostly CPU > time [...] That's a big if. In some cases, CPU time is important, but more often, wall-clock time is more critical. Let's say I've got two versions of a program. Here's some results for my test run: Version CPU Time Wall-Clock Time 1 2 hours 2.5 hours 2 1.5 hours 5.0 hours Between versions, I reduced the CPU time to complete the given task, but increased the wall clock time. Perhaps I doubled the size of some hash table. Now I get a lot fewer hash collisions (so I spend less CPU time re-hashing), but my memory usage went up so I'm paging a lot and my locality of reference went down so my main memory cache hit rate is worse. Which is better? I think most people would say version 1 is better. CPU time is only important in a situation where the system is CPU bound. In many real-life cases, that's not at all true. Things can be memory bound. Or I/O bound (which, when you consider paging, is often the same thing as memory bound). Or lock-contention bound. Before you starting measuring things, it's usually a good idea to know what you want to measure, and why :-) From ladasky at my-deja.com Thu Nov 17 21:18:11 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 18:18:11 -0800 (PST) Subject: What exactly is "pass"? What should it be? Message-ID: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Hi folks, I'm trying to write tidy, modular code which includes a long-running process. From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. Other times, I'll just want to let it run. So I have a section of code which, generally, looks like this: def _pass(*args): pass def long_running_process(arg1, arg2, arg_etc, report = _pass): result1 = do_stuff() report(result1) result2 = do_some_different_stuff() report(result2) result3 = do_even_more_stuff() report(result3) return result3 This does what I want. When I do not specify a report function, the process simply runs. Typically, when I do supply a report function, it would print something to stdout, or draw an update through a GUI. But this approach seems a tad cumbersome and unPythonic to me, particularly the part where I define the function _pass() which accepts an arbitrary argument list, and does nothing but... pass. This has led me to ask the question, what exactly IS pass? I played with the interpreter a bit. IDLE 2.6.6 ==== No Subprocess ==== >>> pass >>> pass() SyntaxError: invalid syntax >>> type(pass) SyntaxError: invalid syntax So, pass does not appear to be a function, nor even an object. Is it nothing more than a key word? And would there be any merit to having some syntactic sugar which allows pass to behave like the _pass() function I wrote, if it were called? As you can see, I'm programming in Python 2.6. I don't know whether pass is handled differently in Python 3. From wuwei23 at gmail.com Thu Nov 17 21:31:04 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 18:31:04 -0800 (PST) Subject: staticmethod makes my brain hurt References: Message-ID: On Nov 17, 1:24?pm, Ethan Furman wrote: > If you do need to sometimes call it from a method then still leave off > the '@staticmethod', and give 'self' a default of 'None': > > ? ? ?def _get_next_id(self=None): > ? ? ? ?[blah, blah, blah] > ? ? ? ?return id > > ? ? ?user_id = IntField(required=True, default=_get_next_id) And if the OP needs it to be a staticmethod as well, he can just wrap the nested function: gen_next_id = staticmethod(_gen_next_id) I think I like this approach best. I'm annoyed that I forgot functions declared in a class scope were callable within the definition :) From wuwei23 at gmail.com Thu Nov 17 21:38:47 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 18:38:47 -0800 (PST) Subject: Use and usefulness of the as syntax References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> <4ec52cd3$0$16583$426a74cc@news.free.fr> Message-ID: <1772de52-5ce0-4cb0-ac3c-e43aa2d17cf6@a5g2000vbb.googlegroups.com> On Nov 18, 1:48?am, candide wrote: > # a.py > import math as _math > > # b.py > from a import * > > print _math.sin(0) ? ? ? # raise a NameError > print math.sin(0) ? ? ? ?# raise a NameError > > so the as syntax is also seful for hiding name, isn'it ? Not exactly. It's the * import mechanism here that's ignoring any bindings that begin with an underscore. If you had: _dummy = 1 ...inside of a.py, it wouldn't be pulled in either. As you state later, 'as' is purely a binding convenience. Incidentally, you can still allow * import to bring in underscore- prefixed bindings by adding them to an __all__: __all__ = ['_dummy'] From clp2 at rebertia.com Thu Nov 17 21:45:58 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 17 Nov 2011 18:45:58 -0800 Subject: What exactly is "pass"? What should it be? In-Reply-To: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: On Thu, Nov 17, 2011 at 6:18 PM, John Ladasky wrote: > Hi folks, > > I'm trying to write tidy, modular code which includes a long-running process. ?From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. ?Other times, I'll just want to let it run. ?So I have a section of code which, generally, looks like this: > > def _pass(*args): > ? ?pass > > def long_running_process(arg1, arg2, arg_etc, report = _pass): > ? ?result1 = do_stuff() > ? ?report(result1) > ? ?result2 = do_some_different_stuff() > ? ?report(result2) > ? ?result3 = do_even_more_stuff() > ? ?report(result3) > ? ?return result3 > > This does what I want. ?When I do not specify a report function, the process simply runs. ?Typically, when I do supply a report function, it would print something to stdout, or draw an update through a GUI. > > But this approach seems a tad cumbersome and unPythonic to me, particularly the part where I define the function _pass() which accepts an arbitrary argument list, and does nothing but... pass. Seems fine to me (good use of the null object pattern), although I might define _pass() to instead take exactly 1 argument, since that's all you ever call report() with in your example. > This has led me to ask the question, what exactly IS pass? ?I played with the interpreter a bit. > > IDLE 2.6.6 ? ? ?==== No Subprocess ==== >>>> pass >>>> pass() > SyntaxError: invalid syntax >>>> type(pass) > SyntaxError: invalid syntax > > So, pass does not appear to be a function, nor even an object. ?Is it nothing more than a key word? Correct: http://docs.python.org/reference/simple_stmts.html#pass http://docs.python.org/reference/lexical_analysis.html#keywords Cheers, Chris From wuwei23 at gmail.com Thu Nov 17 21:58:46 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 18:58:46 -0800 (PST) Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: On Nov 18, 11:36?am, Roy Smith wrote: > What if the first import of a module is happening inside some code you > don't have access to? No import will happen until you import something. As long as you change sys.path before you do, all subsequent imports will use that path. From rosuav at gmail.com Thu Nov 17 21:59:13 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Nov 2011 13:59:13 +1100 Subject: What exactly is "pass"? What should it be? In-Reply-To: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: On Fri, Nov 18, 2011 at 1:18 PM, John Ladasky wrote: > def _pass(*args): > ? ?pass > > def long_running_process(arg1, arg2, arg_etc, report = _pass): > For some compactness at the expense of brevity, you could use a lambda: def long_running_process(arg1, arg2, arg_etc, report = lambda msg: None): Other than that, I think it's fine. (Actually, the lambda has a slight advantage in self-documentation; in the main function's definition it specifies that the 'report' argument is a function that takes one argument, the message. (Or whatever that argument is. Name it appropriately.) If you call your dummy function something else, it may help readability/self-documentation too. On the other hand, it may not. YMMV. ChrisA From dbinks at codeaurora.org Thu Nov 17 22:01:01 2011 From: dbinks at codeaurora.org (Dominic Binks) Date: Thu, 17 Nov 2011 19:01:01 -0800 Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <4EC5CA6D.3060100@codeaurora.org> On 11/17/2011 6:45 PM, Chris Rebert wrote: > On Thu, Nov 17, 2011 at 6:18 PM, John Ladasky wrote: >> Hi folks, >> >> I'm trying to write tidy, modular code which includes a long-running process. From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. Other times, I'll just want to let it run. So I have a section of code which, generally, looks like this: >> >> def _pass(*args): >> pass >> >> def long_running_process(arg1, arg2, arg_etc, report = _pass): >> result1 = do_stuff() >> report(result1) >> result2 = do_some_different_stuff() >> report(result2) >> result3 = do_even_more_stuff() >> report(result3) >> return result3 >> >> This does what I want. When I do not specify a report function, the process simply runs. Typically, when I do supply a report function, it would print something to stdout, or draw an update through a GUI. >> >> But this approach seems a tad cumbersome and unPythonic to me, particularly the part where I define the function _pass() which accepts an arbitrary argument list, and does nothing but... pass. > > Seems fine to me (good use of the null object pattern), although I > might define _pass() to instead take exactly 1 argument, since that's > all you ever call report() with in your example. > >> This has led me to ask the question, what exactly IS pass? I played with the interpreter a bit. >> >> IDLE 2.6.6 ==== No Subprocess ==== >>>>> pass >>>>> pass() >> SyntaxError: invalid syntax >>>>> type(pass) >> SyntaxError: invalid syntax >> >> So, pass does not appear to be a function, nor even an object. Is it nothing more than a key word? > It is a keyword that can appear in a position where a statement is required by the grammar but there is nothing to do. For example if .. then .. else .. where nothing happens in the else condition is effectively: if : else: pass Bourne shell has a similar construct with the colon statement : Another python example is where you need to catch an exception (or all exceptions but don't actually care about what they are) try: except: pass > Correct: > http://docs.python.org/reference/simple_stmts.html#pass > http://docs.python.org/reference/lexical_analysis.html#keywords > > Cheers, > Chris -- Dominic Binks: dbinks at codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum From wuwei23 at gmail.com Thu Nov 17 22:04:18 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 19:04:18 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: On Nov 18, 2:55?am, "W. eWatson" wrote: > Comments? Are you using the vanilla installer or ActiveState's ActivePython? I find the latter integrates better with Windows. Also, out of curiousity, 32 or 64 bit Windows? From ben+python at benfinney.id.au Thu Nov 17 22:45:35 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 18 Nov 2011 14:45:35 +1100 Subject: What exactly is "pass"? What should it be? References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <87pqgq6qlc.fsf@benfinney.id.au> John Ladasky writes: > So, pass does not appear to be a function, nor even an object. Is it > nothing more than a key word? Yes. Unlike some languages where the program is a collection of expressions, a Python program is a series of statements which themselves may or may not be expressions. -- \ ?I tell you the truth: some standing here will not taste death | `\ before they see the Son of Man coming in his kingdom.? ?Jesus, | _o__) c. 30 CE, as quoted in Matthew 16:28 | Ben Finney From d at davea.name Thu Nov 17 22:59:17 2011 From: d at davea.name (Dave Angel) Date: Thu, 17 Nov 2011 22:59:17 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4EC5D815.3090800@davea.name> On 11/17/2011 03:31 PM, W. eWatson wrote: > On 11/17/2011 9:39 AM, John Gordon wrote: > >> >> Can you add IDLE manually to the associated applications list? >> > Tried that by sending it directly to idle.pyw, but then trying to get > there through the Edit with menu caused a "invalid Win32 app." You've been told repeatedly that building an association to idle.pyw is useless. It must be to something Windows understands, such as .exe, or .bat (or several other extensions, as I said in an earlier message) So why waste our time telling us yet again that it doesn't work? -- DaveA From wolftracks at invalid.com Thu Nov 17 23:21:18 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 20:21:18 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 7:59 PM, Dave Angel wrote: > On 11/17/2011 03:31 PM, W. eWatson wrote: >> On 11/17/2011 9:39 AM, John Gordon wrote: >> >>> >>> Can you add IDLE manually to the associated applications list? >>> >> Tried that by sending it directly to idle.pyw, but then trying to get >> there through the Edit with menu caused a "invalid Win32 app." > > You've been told repeatedly that building an association to idle.pyw is > useless. It must be to something Windows understands, such as .exe, or > .bat (or several other extensions, as I said in an earlier message) So > why waste our time telling us yet again that it doesn't work? > > > Because some people think that's a solution, and ask. It's not. It leads to an error message. From wolftracks at invalid.com Thu Nov 17 23:33:40 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 20:33:40 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/17/2011 4:24 PM, Steven D'Aprano wrote: > On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: > >> I have not found any successful way to get to IDLE. It's on on the >> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >> with a "invalid Win32 app" msg. > > If you associate .pyw files with pythonw.exe, and then open idle.pyw, > does it work? > > Failing that, go to your laptop where the associations are right, and see > what they are, then duplicate the settings on your Windows 7 machine. > Sounds like a good idea except I've not used associations in so long under XP, I have no idea where to start. Control Panel. My Computer Tools? From wolftracks at invalid.com Thu Nov 17 23:34:31 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 20:34:31 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 7:04 PM, alex23 wrote: > On Nov 18, 2:55 am, "W. eWatson" wrote: >> Comments? > > Are you using the vanilla installer or ActiveState's ActivePython? I > find the latter integrates better with Windows. > > Also, out of curiousity, 32 or 64 bit Windows? 64-bit and plain old python msi installer. From snorble at hotmail.com Thu Nov 17 23:49:16 2011 From: snorble at hotmail.com (snorble) Date: Thu, 17 Nov 2011 20:49:16 -0800 (PST) Subject: Monitoring/inventory client-server app References: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> <4ec58b51$0$6842$e4fe514c@news2.news.xs4all.nl> Message-ID: <1ba9dc95-9347-4a5a-a705-774d31166a08@o17g2000yqa.googlegroups.com> On Nov 17, 4:31?pm, Irmen de Jong wrote: > On 17-11-2011 5:17, snorble wrote: > > > > > > > > > > > I'm writing a tool for monitoring the workstations and servers in our > > office. I plan to have a server and a client service that runs on each > > workstation and reports back to the server (heartbeat, disk free > > space, etc). > > > So far I am considering XMLRPC, or a client service that just > > downloads a Python file and runs it. > > > With XMLRPC I don't know how to easily add features without having to > > update every client. Also while playing with XMLRPC I learned that > > when you run a registered function, it runs it on the server. I was > > hoping it would run on the client, so that when I get the machine's > > computer name (or disk space, etc) it will return the client's info. > > It seems with XMLRPC I would have to hard code the functionality into > > the client (i.e. client gets it's computer name, then calls the XMLRPC > > function to pass it to the server)? I was hoping it would work more > > like, "pass some code to the client to be run on the client, and > > report it to the server". Almost XMLRPC in the reverse direction. > > > With the download-and-run approach, it seems trivially easy to add new > > functionality to the clients. Just save the updated Python file to the > > server, and clients download it and run it. > > > Are there any standard approaches to problems like this that can be > > recommended? Thank you. > > The security implications are HUGE when you are thinking about > transferring and executing arbitrary code over the network. Avoid this > if at all possible. But if you can be 100% sure it's only trusted stuff, > things are not so grim. > > Have a look at Pyro, or even Pyro Flame: > > http://packages.python.org/Pyro4/http://packages.python.org/Pyro4/flame.html > > Flame allows for very easy remote module execution and a limited way of > transferring code to the 'other side'. > > Also what is wrong with running an XMLrpc server, or Pyro daemon, on > your client machines? This way your central computer can call registered > methods (or remote objects in case of Pyro) on the client and execute > code there (that reports all sorts of stuff you want to know). Or have > each client call into a central server, where it reports that stuff > itself. Many ways to skin a cat. > > Regards, > Irmen de Jong I'm thinking maybe the client service will have a small number of generic features, such as reading WMI and SNMP values. That way the server still dictates the work to be done (i.e. XMLRPC returns which WMI/SNMP values to query), and the client remains relatively focused and straightforward. From alec.taylor6 at gmail.com Thu Nov 17 23:53:07 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Fri, 18 Nov 2011 15:53:07 +1100 Subject: Monitoring/inventory client-server app In-Reply-To: <1ba9dc95-9347-4a5a-a705-774d31166a08@o17g2000yqa.googlegroups.com> References: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> <4ec58b51$0$6842$e4fe514c@news2.news.xs4all.nl> <1ba9dc95-9347-4a5a-a705-774d31166a08@o17g2000yqa.googlegroups.com> Message-ID: Maybe take a look outside python: - Puppet On Fri, Nov 18, 2011 at 3:49 PM, snorble wrote: > On Nov 17, 4:31?pm, Irmen de Jong wrote: >> On 17-11-2011 5:17, snorble wrote: >> >> >> >> >> >> >> >> >> >> > I'm writing a tool for monitoring the workstations and servers in our >> > office. I plan to have a server and a client service that runs on each >> > workstation and reports back to the server (heartbeat, disk free >> > space, etc). >> >> > So far I am considering XMLRPC, or a client service that just >> > downloads a Python file and runs it. >> >> > With XMLRPC I don't know how to easily add features without having to >> > update every client. Also while playing with XMLRPC I learned that >> > when you run a registered function, it runs it on the server. I was >> > hoping it would run on the client, so that when I get the machine's >> > computer name (or disk space, etc) it will return the client's info. >> > It seems with XMLRPC I would have to hard code the functionality into >> > the client (i.e. client gets it's computer name, then calls the XMLRPC >> > function to pass it to the server)? I was hoping it would work more >> > like, "pass some code to the client to be run on the client, and >> > report it to the server". Almost XMLRPC in the reverse direction. >> >> > With the download-and-run approach, it seems trivially easy to add new >> > functionality to the clients. Just save the updated Python file to the >> > server, and clients download it and run it. >> >> > Are there any standard approaches to problems like this that can be >> > recommended? Thank you. >> >> The security implications are HUGE when you are thinking about >> transferring and executing arbitrary code over the network. Avoid this >> if at all possible. But if you can be 100% sure it's only trusted stuff, >> things are not so grim. >> >> Have a look at Pyro, or even Pyro Flame: >> >> http://packages.python.org/Pyro4/http://packages.python.org/Pyro4/flame.html >> >> Flame allows for very easy remote module execution and a limited way of >> transferring code to the 'other side'. >> >> Also what is wrong with running an XMLrpc server, or Pyro daemon, on >> your client machines? This way your central computer can call registered >> methods (or remote objects in case of Pyro) on the client and execute >> code there (that reports all sorts of stuff you want to know). Or have >> each client call into a central server, where it reports that stuff >> itself. Many ways to skin a cat. >> >> Regards, >> Irmen de Jong > > I'm thinking maybe the client service will have a small number of > generic features, such as reading WMI and SNMP values. That way the > server still dictates the work to be done (i.e. XMLRPC returns which > WMI/SNMP values to query), and the client remains relatively focused > and straightforward. > -- > http://mail.python.org/mailman/listinfo/python-list > From ladasky at my-deja.com Fri Nov 18 00:03:23 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 21:03:23 -0800 (PST) Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <19287522.9.1321592603810.JavaMail.geo-discussion-forums@prfb5> On Thursday, November 17, 2011 6:45:58 PM UTC-8, Chris Rebert wrote: > Seems fine to me (good use of the null object pattern), although I > might define _pass() to instead take exactly 1 argument, since that's > all you ever call report() with in your example. Oops, I over-simplified the calls to my report() function. The truth is that report() can accept a variable argument list too. From ladasky at my-deja.com Fri Nov 18 00:03:23 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 21:03:23 -0800 (PST) Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <19287522.9.1321592603810.JavaMail.geo-discussion-forums@prfb5> On Thursday, November 17, 2011 6:45:58 PM UTC-8, Chris Rebert wrote: > Seems fine to me (good use of the null object pattern), although I > might define _pass() to instead take exactly 1 argument, since that's > all you ever call report() with in your example. Oops, I over-simplified the calls to my report() function. The truth is that report() can accept a variable argument list too. From ladasky at my-deja.com Fri Nov 18 00:07:23 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 21:07:23 -0800 (PST) Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> On Thursday, November 17, 2011 8:34:22 PM UTC-8, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky > declaimed the following in > gmane.comp.python.general: > > def _pass(*args): > > pass > > > This is the equivalent of > > def _pass(*args): > return None > > (functions with no explicit return statement implicitly return None) OK, that works for me, and now I understand. One of my questions was: would there be any merit to having the Python "pass" token itself defined exactly as _pass() is defined above? From ladasky at my-deja.com Fri Nov 18 00:07:23 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 21:07:23 -0800 (PST) Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> On Thursday, November 17, 2011 8:34:22 PM UTC-8, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky > declaimed the following in > gmane.comp.python.general: > > def _pass(*args): > > pass > > > This is the equivalent of > > def _pass(*args): > return None > > (functions with no explicit return statement implicitly return None) OK, that works for me, and now I understand. One of my questions was: would there be any merit to having the Python "pass" token itself defined exactly as _pass() is defined above? From benjamin.kaplan at case.edu Fri Nov 18 00:25:29 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 18 Nov 2011 00:25:29 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 11:21 PM, W. eWatson wrote: > > On 11/17/2011 7:59 PM, Dave Angel wrote: >> >> On 11/17/2011 03:31 PM, W. eWatson wrote: >>> >>> On 11/17/2011 9:39 AM, John Gordon wrote: >>> >>>> >>>> Can you add IDLE manually to the associated applications list? >>>> >>> Tried that by sending it directly to idle.pyw, but then trying to get >>> there through the Edit with menu caused a "invalid Win32 app." >> >> You've been told repeatedly that building an association to idle.pyw is >> useless. It must be to something Windows understands, such as .exe, or >> .bat (or several other extensions, as I said in an earlier message) So >> why waste our time telling us yet again that it doesn't work? >> >> >> > Because some ?people think that's a solution, and ask. It's not. It leads to an error message. Checking my Python install, there should be an idle.bat file in there too. Have you tried that? From rosuav at gmail.com Fri Nov 18 00:34:10 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Nov 2011 16:34:10 +1100 Subject: What exactly is "pass"? What should it be? In-Reply-To: <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> Message-ID: On Fri, Nov 18, 2011 at 4:07 PM, John Ladasky wrote: > One of my questions was: would there be any merit to having the Python "pass" token itself defined exactly as _pass() is defined above? No, there wouldn't. The Python 'pass' statement is a special statement that indicates a lack of anything to execute; a dummy function call isn't this. What I would kinda like to see, though, is function versions of many things. Your basic operators exist in the 'operator' module, but the syntax is rather clunky; for comparison, Pike has beautifully simple (if a little cryptic) syntax: back-tick followed by the operator itself, very similar to the way C++ does operator overloading. In Python 2, back-tick has a special meaning. In Python 3, that meaning is removed. Is the character now available for this "function-version" syntax? ChrisA From clp2 at rebertia.com Fri Nov 18 00:49:47 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 17 Nov 2011 21:49:47 -0800 Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> Message-ID: On Thu, Nov 17, 2011 at 9:34 PM, Chris Angelico wrote: > On Fri, Nov 18, 2011 at 4:07 PM, John Ladasky wrote: >> One of my questions was: would there be any merit to having the Python "pass" token itself defined exactly as _pass() is defined above? > > No, there wouldn't. The Python 'pass' statement is a special statement > that indicates a lack of anything to execute; a dummy function call > isn't this. What I would kinda like to see, though, is function > versions of many things. Your basic operators exist in the 'operator' > module, but the syntax is rather clunky; for comparison, Pike has > beautifully simple (if a little cryptic) syntax: back-tick followed by > the operator itself, very similar to the way C++ does operator > overloading. > > In Python 2, back-tick has a special meaning. In Python 3, that > meaning is removed. Is the character now available for this > "function-version" syntax? Negative. I know this from personal experience. Things that will Not Change in Python 3000 (http://www.python.org/dev/peps/pep-3099/ ): "No more backticks." Cheers, Chris R. From paul.nospam at rudin.co.uk Fri Nov 18 00:54:15 2011 From: paul.nospam at rudin.co.uk (Paul Rudin) Date: Fri, 18 Nov 2011 05:54:15 +0000 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: <87wraydlh4.fsf@no-fixed-abode.cable.virginmedia.net> Roy Smith writes: > In article <874ny2fzn6.fsf at no-fixed-abode.cable.virginmedia.net>, > Paul Rudin wrote: > >> >> Maybe I'm missing something - but if I want to do this I just mess about >> with sys.path at the top of my python script/program. Always seems to >> work... is there a situation in which it doesn't? > > What if the first import of a module is happening inside some code you > don't have access to? If you change sys.path first - before you do any imports - then any other imports will surely come from the first thing on sys.path (unless something else you import also changes sys.path)? From wuwei23 at gmail.com Fri Nov 18 01:04:12 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 22:04:12 -0800 (PST) Subject: What exactly is "pass"? What should it be? References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: On Nov 18, 12:59?pm, Chris Angelico wrote: > If you call your dummy function something else, it may help > readability/self-documentation too. Or replace the pass with a docstring for the same effect: def silent(*args): """Null Object to repress reporting""" From wuwei23 at gmail.com Fri Nov 18 01:06:51 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 22:06:51 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: On Nov 18, 2:21?pm, "W. eWatson" wrote: > Because some ?people think that's a solution, and ask. It's not. It > leads to an error message. No, people are saying "manually add IDLE _the correct way that Windows can recognise_", not recommending you stuff random .pyw files into the context menu and hope they work. From steve+comp.lang.python at pearwood.info Fri Nov 18 01:07:21 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Nov 2011 06:07:21 GMT Subject: What exactly is "pass"? What should it be? References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> Message-ID: <4ec5f619$0$29967$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Nov 2011 21:07:23 -0800, John Ladasky wrote: > One of my questions was: would there be any merit to having the Python > "pass" token itself defined exactly as _pass() is defined above? No. The pass statement compiles to nothing at all. Your _pass() function compiles to a function object, which needs to be looked up at run time, then called, all of which takes time and memory. To satisfy the compiler, but do nothing, the pass statement should stay a statement. When you need a "do nothing" function, either define one (two lines) in your application, or use a lambda in place (lambda *args: None). Either way, it is too trivial to be a built-in. By the way, to answer your earlier question "what is pass?", you could do this in the interactive interpreter: help("pass") -- Steven From namenobodywants at gmail.com Fri Nov 18 02:27:47 2011 From: namenobodywants at gmail.com (Sean McIlroy) Date: Thu, 17 Nov 2011 23:27:47 -0800 (PST) Subject: useless python - term rewriter Message-ID: <429ffce6-8912-4851-bb4f-bb894241038f@v31g2000prg.googlegroups.com> ## term rewriter (python 3.1.1) def gettokens(string): spaced = string.replace('(',' ( ').replace(')',' ) ') return spaced.split() def getterm(tokens): if tokens[0] in '()': term = [] assert tokens[0] == '(' tokens.pop(0) while not tokens[0] == ')': term.append(getterm(tokens)) tokens.pop(0) return term return tokens.pop(0) def parse(strg): tokens = gettokens(strg) term = getterm(tokens) assert not tokens return term def unparse(term): if type(term) == str: return term subterms = [unparse(subterm) for subterm in term] return '({})'.format(' '.join(subterms)) def atom(term): return type(term) == str def compound(term): return type(term) == list def variable(term): return atom(term) and term[0].isupper() def constant(term): return atom(term) and not term[0].isupper() def conformable(term1,term2): return compound(term1) and compound(term2) and len(term1) == len(term2) def getrule(string): left, right = string.split('=') return [parse(left), parse(right)] def getrules(string): nonblank = lambda substring: substring and not substring.isspace() return [getrule(substring) for substring in string.splitlines() if nonblank(substring)] def substitute(bindings,term): if constant(term): return term if variable(term): return bindings.get(term,term) return [substitute(bindings,subterm) for subterm in term] def match(term,pattern): from operator import concat from functools import reduce if variable(pattern): return [[pattern, term]] if constant(pattern) and pattern == term: return [] if conformable(pattern,term): matches = [match(subterm,subpattern) for subterm, subpattern in zip(term,pattern)] return reduce(concat,matches) raise Exception def rewrite(term,rule): if type(rule) == dict: function = rule[term[0]] arguments = [int(subterm) for subterm in term[1:]] return str(function(*arguments)) left, right = rule bindings = dict(match(term,left)) return substitute(bindings,right) def apply(rule,term): try: return [rewrite(term,rule), True] except: if atom(term): return [term, False] applications = [apply(rule,subterm) for subterm in term] subterms = [subterm for subterm, change in applications] changes = [change for subterm, change in applications] return [subterms, any(changes)] def normalize(term,rules): while True: changes = [] for rule in rules: term, change = apply(rule,term) changes.append(change) if not any(changes): break return term def translate(rules): string = input('>>> ') if string and not string.isspace(): try: term = parse(string) normal = normalize(term,rules) string = unparse(normal) print(string) except: print('parse error') def interpret(equations): import operator rules = [vars(operator)] + getrules(equations) while True: try: translate(rules) except KeyboardInterrupt: print('end session') break example = """ (factorial 0) = 1 (factorial N) = (mul N (factorial (sub N 1))) (fibonacci 0) = 0 (fibonacci 1) = 1 (fibonacci N) = (add (fibonacci (sub N 1)) (fibonacci (sub N 2))) """ interpret(example) From tjreedy at udel.edu Fri Nov 18 02:35:51 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 18 Nov 2011 02:35:51 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 7:03 PM, W. eWatson wrote: > I have not found any successful way to get to IDLE. Use the start menu to start IDLE once. Then pin it to your taskbar. If you do not have STart/ all programs / Python / IDLE, then your installation is bad. As for the right click problem, you probably have something screwy in the registry. The python installer (or uninstaller) will not fix it (my experience on my old xp machine). You will have to do so manually. -- Terry Jan Reedy From abecedarian314159 at yahoo.com Fri Nov 18 02:38:06 2011 From: abecedarian314159 at yahoo.com (William) Date: Thu, 17 Nov 2011 23:38:06 -0800 (PST) Subject: python chat Message-ID: <1321601886.45737.YahooMailNeo@web161806.mail.bf1.yahoo.com> Hi, I've started a new site called StudyBrunch, where we offer a chance for online studygroups with video conferencing, screen sharing etc. ? I'd like to keep the groups small to be maneageble. ? I will offer a basic session on python for people who are interested, on Saturday or Sunday evening. ? If you are interested, you can look at: http://www.studybrunch.com/studysession/intro-to-python/ For this month, general membership is free and I hope to move on to more advanced topics later. ? If you have questions, or suggestion for topics (for example, classes, wxpython, urllib2, etc.), then contact us through?http://www.studybrunch.com/contact/ so we don't spam the list. I have listed some preliminary times on the site in EST, but let me know on the site if you can't make those and I can try to schedule another session later in the week. ?? Best, William -------------- next part -------------- An HTML attachment was scrubbed... URL: From peksikytola at gmail.com Fri Nov 18 02:51:12 2011 From: peksikytola at gmail.com (=?ISO-8859-1?B?UGVra2EgS3l09mzk?=) Date: Thu, 17 Nov 2011 23:51:12 -0800 (PST) Subject: Passing DLL handle as an argument (in Windows) Message-ID: Is it possible to pass my own dll's (already loaded) handle as an argument to load/attach to the very same instance of dll? Thing is that I've done plugin (dll) to a host app and the SDK's function pointers are assigned once the dll is loaded in the host process. I'd like to fire up python code with ShellExecuteEx from my plugin dll and expose (wrap) these SDK funcs to that script. If I just load the dll in python it will be different instance and the SDK function pointers are all NULL. I tried passing the dll handle as lpParameter but in vain. Is this ShellExecute + dll handle passing even possible or do I need to take a totally different route? What route that would be? Doesn't have to be portable, just so it works in Windows environment. From ulrich.eckhardt at dominolaser.com Fri Nov 18 03:27:39 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 18 Nov 2011 09:27:39 +0100 Subject: Passing DLL handle as an argument (in Windows) In-Reply-To: References: Message-ID: Am 18.11.2011 08:51, schrieb Pekka Kyt?l?: > Is it possible to pass my own dll's (already loaded) handle as an > argument to load/attach to the very same instance of dll? Thing is > that I've done plugin (dll) to a host app and the SDK's function > pointers are assigned once the dll is loaded in the host process. DLL handles are valid anywhere in a process, but... > I'd like to fire up python code with ShellExecuteEx from my plugin > dll and expose (wrap) these SDK funcs to that script. If I just load > the dll in python it will be different instance and the SDK function > pointers are all NULL. I tried passing the dll handle as lpParameter > but in vain. ...ShellExecuteEx will create a new process, where the DLL handle is not valid. A new process has a separate memory space, so the function pointers are different etc. This is so by design, it shouldn't matter to one process when a DLL it uses is loaded into another process, too. > Is this ShellExecute + dll handle passing even possible or do I need > to take a totally different route? What route that would be? Doesn't > have to be portable, just so it works in Windows environment. If all you want is to run Python code inside your application, you can link in a Python interpreter and run it from there. This is called embedding Python (docs.python.org/extending/embedding.html), as opposed to writing Python modules, don't confuse those two Python C APIs. Another way to get both into the same process is to convert your host application into a Python module, which you then import into Python. This would use the other Python C API (docs.python.org/extending/extending.html). It depends a bit on what you want to achieve, so you might want to elaborate on that. This is often better than asking for a way to achieve a solution that is impossible. Good luck! Uli From peksikytola at gmail.com Fri Nov 18 04:31:42 2011 From: peksikytola at gmail.com (=?ISO-8859-1?B?UGVra2EgS3l09mzk?=) Date: Fri, 18 Nov 2011 01:31:42 -0800 (PST) Subject: Passing DLL handle as an argument (in Windows) References: Message-ID: <59ccd4dd-3e39-44f5-8234-4afc64c32701@p16g2000yqd.googlegroups.com> On Nov 18, 10:27?am, Ulrich Eckhardt wrote: > Am 18.11.2011 08:51, schrieb Pekka Kyt?l?: > > > Is it possible to pass my own dll's (already loaded) handle as an > > argument to load/attach to the very same instance of dll? Thing is > > that I've done plugin (dll) to a host app and the SDK's function > > pointers are assigned once the dll is loaded in the host process. > > DLL handles are valid anywhere in a process, but... > > > I'd like to fire up python code with ShellExecuteEx from my plugin > > dll and expose (wrap) these SDK funcs to that script. If I just load > > the dll in python it will be different instance and the SDK function > > pointers are all NULL. I tried passing the dll handle as lpParameter > > but in vain. > > ...ShellExecuteEx will create a new process, where the DLL handle is not > valid. A new process has a separate memory space, so the function > pointers are different etc. This is so by design, it shouldn't matter to > one process when a DLL it uses is loaded into another process, too. > > > Is this ShellExecute + dll handle passing even possible or do I need > > to take a totally different route? What route that would be? Doesn't > > have to be portable, just so it works in Windows environment. > > If all you want is to run Python code inside your application, you can > link in a Python interpreter and run it from there. This is called > embedding Python (docs.python.org/extending/embedding.html), as opposed > to writing Python modules, don't confuse those two Python C APIs. > > Another way to get both into the same process is to convert your host > application into a Python module, which you then import into Python. > This would use the other Python C API > (docs.python.org/extending/extending.html). > > It depends a bit on what you want to achieve, so you might want to > elaborate on that. This is often better than asking for a way to achieve > a solution that is impossible. > > Good luck! > > Uli Thanks for reply, I'll try to elaborate a bit :) I should have included this bit from: http://docs.python.org/library/ctypes.html#loading-shared-libraries "All these classes can be instantiated by calling them with at least one argument, the pathname of the shared library. If you have an existing handle to an already loaded shared library, it can be passed as the handle named parameter, otherwise the underlying platforms dlopen or LoadLibrary function is used to load the library into the process, and to get a handle to it." So, I've got this handle to my .dll and would want to get that passed as an argument when firing up .py via ShellExecute and use one of the dll load functions that take in handle. What I don't know if these windows/python dll handles are interchangable at all. Think it would be quite nice if they were. But if they aren't I need to forget about it and just #include From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Fri Nov 18 04:57:42 2011 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Fri, 18 Nov 2011 10:57:42 +0100 Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: Am 18.11.2011 05:34 schrieb Dennis Lee Bieber: >> def _pass(*args): >> pass >> >> def long_running_process(arg1, arg2, arg_etc, report = _pass): >> result1 = do_stuff() >> report(result1) > > So this is a call to a function that just returns a None, which is > dropped by the interpreter... I'm not sure about this. I think, the call will be executed, but the callee will return immediately. It is different from call being dropped. Another optimized alternative could be to do def long_running_process(arg1, arg2, arg_etc, report=None): result1 = do_stuff() if report: report(result1) but I think that is too low benefit at the cost of too much readability. Such a function call is 2 0 LOAD_FAST 0 (a) 3 POP_JUMP_IF_FALSE 16 6 LOAD_FAST 0 (a) 9 CALL_FUNCTION 0 12 POP_TOP 13 JUMP_FORWARD 0 (to 16) 3 >> 16 ... as opposed to just 2 0 LOAD_FAST 0 (a) 3 CALL_FUNCTION 0 6 POP_TOP with a call target of 1 0 LOAD_CONST 0 (None) 3 RETURN_VALUE I don't think that a call is sooo expensive that it would make any noticeable difference. Thomas BTW: Sorry, Dennis, for the private mail - I am incapable to use Thunderbird correctly :-( From hujunfeng at gmail.com Fri Nov 18 05:23:29 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 02:23:29 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing Message-ID: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Hi All, I'm trying to leverage my core i5 to send more UDP packets with multiprocssing, but I found a interesting thing is that the socket.bind is always reporting 10048 error even the process didn't do anything about the socket. Here is the script import threading,socket,random,pp,os import time from multiprocessing import Process import multiprocessing.reduction localIP='10.80.2.24' localPort=2924 remoteIP='10.80.5.143' remotePort=2924 sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) #sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((localIP,localPort)) sock.connect((remoteIP,remotePort)) addRequest="MEGACO/1 ["+localIP+"]:"+str(localPort)+"\r\nTRANSACTION = 100 {\r\n" \ "\tCONTEXT = $ {\r\n" \ "\t\tADD = TDMs15c1f1/11{ \r\n" \ " Media { LocalControl { Mode=SendReceive,tdmc/ec=on }} " \ "\t}\r\n}}\r\n" def sendAddRequest(sock,addRequst): #for i in range(2500): #sock.send(addRequest) print "hello" if __name__ == '__main__': reader = Process(target=sendAddRequest,args=(sock,addRequest)) reader.start() Here is the output D:\Python test>mythread2.py Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\multiprocessing\forking.py", line 346, in main prepare(preparation_data) File "C:\Python27\lib\multiprocessing\forking.py", line 461, in prepare '__parents_main__', file, path_name, etc File "D:\Python test\mythread2.py", line 12, in sock.bind((localIP,localPort)) File "C:\Python27\lib\socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 10048] Only one usage of each socket address (protocol/netw ork address/port) is normally permitted From hansmu at xs4all.nl Fri Nov 18 05:52:54 2011 From: hansmu at xs4all.nl (Hans Mulder) Date: Fri, 18 Nov 2011 11:52:54 +0100 Subject: How to insert my own module in front of site eggs? In-Reply-To: References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: <4ec63907$0$6850$e4fe514c@news2.news.xs4all.nl> On 18/11/11 03:58:46, alex23 wrote: > On Nov 18, 11:36 am, Roy Smith wrote: >> What if the first import of a module is happening inside some code you >> don't have access to? > No import will happen until you import something. That would be the case if you use the '-S' command line option. Otherwise, site.py is imported before you get a chance to alter sys.path, and by default site.py imports other modules. -- HansM From michels at mps.mpg.de Fri Nov 18 05:56:36 2011 From: michels at mps.mpg.de (Helmut Michels) Date: Fri, 18 Nov 2011 11:56:36 +0100 Subject: [ANN] Data Plotting Library Dislin 10.2 Message-ID: Dear Python programmers, I am pleased to announce version 10.2 of the data plotting software Dislin. Dislin is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, OpenGL, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG, BMP and SVG. The software is available for the most C, Fortran 77 and Fortran 90/95 compilers. Plotting extensions for the interpreting languages Perl, Python and Java are also supported. Dislin is available from the site http://www.dislin.de and via FTP from the server ftp://ftp.gwdg.de/pub/grafik/dislin All Dislin distributions are free for non-commercial use. Licenses for commercial use are available from http://www.dislin.de. ------------------- Helmut Michels Max Planck Institute for Solar System Research Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : michels at mps.mpg.de From peksikytola at gmail.com Fri Nov 18 06:49:14 2011 From: peksikytola at gmail.com (=?ISO-8859-1?B?UGVra2EgS3l09mzk?=) Date: Fri, 18 Nov 2011 03:49:14 -0800 (PST) Subject: Passing DLL handle as an argument (in Windows) References: <59ccd4dd-3e39-44f5-8234-4afc64c32701@p16g2000yqd.googlegroups.com> Message-ID: <6bc18373-3213-4153-ad87-ba998ca2e597@p16g2000yqd.googlegroups.com> Hmm. Let me describe what is going a bit more carefully: What I build is a dll file that has exported function that gets called when the host application/dll loads my dll. In this function the function pointers to the actual SDK functions are fetched. After this my dll's registers some plugins that have callbacks. After that it's all about reacting to an event/callback. What I'd like to do is that after fetching those SDK function pointers I'd like to fire up .py/.pyc that snoops for possible plugins written in python and registers those plugins and callbacks and let them react to events. Obviously this python code needs access to those SDK functions. Essentially it would show for the host app as one .dll but registers multiple plugins from different python files. I don't mind if it's not ShellExecute route, but I'd prefer approaching this so that I don't need to compile different dll's to different versions of python but let the python code take care of that stuff. From python at mrabarnett.plus.com Fri Nov 18 08:03:28 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 18 Nov 2011 13:03:28 +0000 Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <4EC657A0.7000103@mrabarnett.plus.com> On 18/11/2011 04:34, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky > declaimed the following in > gmane.comp.python.general: > >> I'm trying to write tidy, modular code which includes a long-running process. From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. Other times, I'll just want to let it run. So I have a section of code which, generally, looks like this: >> >> def _pass(*args): >> pass >> > This is the equivalent of > > def _pass(*args): > return None > Wouldn't "pass_" be a more Pythonic name? > (functions with no explicit return statement implicitly return None) > >> def long_running_process(arg1, arg2, arg_etc, report = _pass): >> result1 = do_stuff() >> report(result1) > > So this is a call to a function that just returns a None, which is > dropped by the interpreter... > From neilc at norwich.edu Fri Nov 18 08:11:05 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 18 Nov 2011 13:11:05 GMT Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9in3r9F5j3U2@mid.individual.net> On 2011-11-18, W. eWatson wrote: > On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >> >>> I have not found any successful way to get to IDLE. It's on on the >>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>> with a "invalid Win32 app" msg. >> >> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >> does it work? >> >> Failing that, go to your laptop where the associations are right, and see >> what they are, then duplicate the settings on your Windows 7 machine. > > Sounds like a good idea except I've not used associations in so > long under XP, I have no idea where to start. Control Panel. My > Computer Tools? Open Windows Explorer. With the menu, to to Tools->Folder Options Click the File Types tab in the Folder Options menu. There will be an upper view with registered filed types, and some buttons below far making changes to them. -- Neil Cerutti From ulrich.eckhardt at dominolaser.com Fri Nov 18 09:14:56 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 18 Nov 2011 15:14:56 +0100 Subject: Passing DLL handle as an argument (in Windows) In-Reply-To: <6bc18373-3213-4153-ad87-ba998ca2e597@p16g2000yqd.googlegroups.com> References: <59ccd4dd-3e39-44f5-8234-4afc64c32701@p16g2000yqd.googlegroups.com> <6bc18373-3213-4153-ad87-ba998ca2e597@p16g2000yqd.googlegroups.com> Message-ID: <0s5ip8-oq1.ln1@satorlaser.homedns.org> Am 18.11.2011 12:49, schrieb Pekka Kyt?l?: > What I'd like to do is that after fetching those SDK function > pointers I'd like to fire up .py/.pyc that snoops for possible > plugins written in python and registers those plugins and callbacks > and let them react to events. Obviously this python code needs access > to those SDK functions. Essentially it would show for the host app as > one .dll but registers multiple plugins from different python files. Okay, so you want to export functions from your host application (it doesn't matter if that is inside a DLL or not) to a bunch of Python plugins. This is actually the embedding that I hinted at and documented, but here's some example code (stripped of any error handling and reference counting, so beware!): // append line to debug log static PyObject* log_string(PyObject *self, PyObject *args) { char const* arg = 0; if(!PyArg_ParseTuple(args, "s", &arg)) return NULL; fprintf(debug_output, "%s", arg); Py_RETURN_NONE; } // exported API static PyMethodDef host_api[] = { {"log_string", log_string, METH_VARARGS, "log_string(string) -> None\n" "Write text to debug output."}, {NULL, NULL, 0, NULL} }; Py_Initialize(); PyObject* host_api_module = Py_InitModule("host", host_api); PyObject* test_module = PyImport_ImportModule("./test.py"); PyObject* main_function = PyObject_GetAttrString(test_module, "main"); PyObject* res = PyObject_CallObject(main_function, NULL); Py_Finalize(); This has the disadvantage that it blocks, for multiple Python threads, you need to program a dispatcher. Also, you can only have a single interpreter loaded, so other parts of your program may not call Py_Initialize(). It does the job for my uses, so I hope it helps! Uli From zyzhu2000 at gmail.com Fri Nov 18 09:51:12 2011 From: zyzhu2000 at gmail.com (GZ) Date: Fri, 18 Nov 2011 06:51:12 -0800 (PST) Subject: Dynamically Generate Methods Message-ID: Hi, I have a class Record and a list key_attrs that specifies the names of all attributes that correspond to a primary key. I can write a function like this to get the primary key: def get_key(instance_of_record): return tuple(instance_of_record.__dict__[k] for k in key_attrs) However, since key_attrs are determined at the beginning of the program while get_key() will be called over and over again, I am wondering if there is a way to dynamically generate a get_ley method with the key attributes expanded to avoid the list comprehension/ generator. For example, if key_attrs=['A','B'], I want the generated function to be equivalent to the following: def get_key(instance_of_record): return (instance_of_record['A'],instance_of_record['B'] ) I realize I can use eval or exec to do this. But is there any other way to do this? Thanks, gz From hujunfeng at gmail.com Fri Nov 18 10:20:20 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:20:20 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <15167697.1495.1321629620458.JavaMail.geo-discussion-forums@yqoo7> I did a test on linux, it works well, so the issue is related to os. From wolftracks at invalid.com Fri Nov 18 10:29:56 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 07:29:56 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: <9in3r9F5j3U2@mid.individual.net> References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> Message-ID: On 11/18/2011 5:11 AM, Neil Cerutti wrote: > On 2011-11-18, W. eWatson wrote: >> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >>> >>>> I have not found any successful way to get to IDLE. It's on on the >>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>>> with a "invalid Win32 app" msg. >>> >>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >>> does it work? >>> >>> Failing that, go to your laptop where the associations are right, and see >>> what they are, then duplicate the settings on your Windows 7 machine. >> >> Sounds like a good idea except I've not used associations in so >> long under XP, I have no idea where to start. Control Panel. My >> Computer Tools? > > Open Windows Explorer. > With the menu, to to Tools->Folder Options > Click the File Types tab in the Folder Options menu. > > There will be an upper view with registered filed types, and some > buttons below far making changes to them. > OK, I've found that. I see Py Pyc Pyo Pyw If I click on each, it basically it gives a short description of each. If I click advanced, there's more info. For example for py, Actions are IDLE and Open. What does this tell me that's relevant to Win7? If on Win7, I go to Default Programs I see under associations various python items. Py shows Unknown application. Since installing 2.7.2 I have not messed with these associations. If I right-click on Unknown, I see Notepad and python.exe for choices to open the file. I want neither. Why isn't IDLE listed there? If I right-click on junk.py, I see "Open with". Notepad and python.exe are choices. However, that menu allows me to choose something else. For example, Adobe Reader, or Internet Explorer. I suppose the next question is should I use the browse there and try to connect to IDLE in ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid Win32 app", when I try to use it. From rosuav at gmail.com Fri Nov 18 10:33:11 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Nov 2011 02:33:11 +1100 Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Message-ID: On Fri, Nov 18, 2011 at 9:23 PM, Junfeng Hu wrote: > Hi All, I'm trying to leverage my core i5 to send more UDP packets with multiprocssing, but I found a interesting thing is that the socket.bind is always reporting 10048 error even the process didn't do anything about the socket. > sock.bind((localIP,localPort)) > socket.error: [Errno 10048] Only one usage of each socket address (protocol/netw > ork address/port) is normally permitted Try setting the socket to SO_REUSEADDR. ChrisA From hujunfeng at gmail.com Fri Nov 18 10:48:36 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:48:36 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Thanks Yes, I had tried this before, so you could find that I comment the line sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) Here is the results. D:\Python test>mythread2.py Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main self = load(from_parent) File "C:\Python27\lib\pickle.py", line 1378, in load return Unpickler(file).load() File "C:\Python27\lib\pickle.py", line 858, in load dispatch[key](self) File "C:\Python27\lib\pickle.py", line 1133, in load_reduce value = func(*args) File "C:\Python27\lib\multiprocessing\reduction.py", line 167, in rebuild_sock et _sock = fromfd(fd, family, type_, proto) File "C:\Python27\lib\multiprocessing\reduction.py", line 156, in fromfd s = socket.fromfd(fd, family, type_, proto) AttributeError: 'module' object has no attribute 'fromfd' From hujunfeng at gmail.com Fri Nov 18 10:48:36 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:48:36 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Thanks Yes, I had tried this before, so you could find that I comment the line sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) Here is the results. D:\Python test>mythread2.py Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main self = load(from_parent) File "C:\Python27\lib\pickle.py", line 1378, in load return Unpickler(file).load() File "C:\Python27\lib\pickle.py", line 858, in load dispatch[key](self) File "C:\Python27\lib\pickle.py", line 1133, in load_reduce value = func(*args) File "C:\Python27\lib\multiprocessing\reduction.py", line 167, in rebuild_sock et _sock = fromfd(fd, family, type_, proto) File "C:\Python27\lib\multiprocessing\reduction.py", line 156, in fromfd s = socket.fromfd(fd, family, type_, proto) AttributeError: 'module' object has no attribute 'fromfd' From hujunfeng at gmail.com Fri Nov 18 10:51:49 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:51:49 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> And actually ,the socket hadn't been used in this script. From hujunfeng at gmail.com Fri Nov 18 10:51:49 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:51:49 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> And actually ,the socket hadn't been used in this script. From wolftracks at invalid.com Fri Nov 18 10:54:56 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 07:54:56 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 8:34 PM, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 08:55:36 -0800, "W. eWatson" > declaimed the following in > gmane.comp.python.general: > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. >> >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. >> > Fine... so open a directory window, follow > > Tools/Folder Options/File Types > > Scroll down to PYW, click [Advanced] > > You should get an "Edit File Type" dialog. Mine shows just one > action "open", yours probably has "open" and "edit". Select "edit" and > then click [Edit] button. See what it says for the application to be > used. > > Do the same on the Win7 machine -- it probably doesn't have "edit" > as an action, so you'll be picking the [New] button. Define the new > action to look like the action on the laptop (use the correct path to > the python executable, and maybe to IDLE). > > Heck, check what those actions show for PY files too... The only > difference between PY and PYW should be the application used in the > "open" action. > PY => .../python.exe > PYW => .../pythonw.exe > > Also make sure that the "open" action is the defined default (select > the action, and click the default button); when there are more than one > action, the default will be in bold. > > > > > > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. >> >> Comments? See my response to Neil Cerutii a few msgs above this one. From wolftracks at invalid.com Fri Nov 18 10:57:02 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 07:57:02 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 8:34 PM, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 08:55:36 -0800, "W. eWatson" > declaimed the following in > gmane.comp.python.general: > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. >> >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. >> > Fine... so open a directory window, follow > > Tools/Folder Options/File Types > > Scroll down to PYW, click [Advanced] > > You should get an "Edit File Type" dialog. Mine shows just one > action "open", yours probably has "open" and "edit". Select "edit" and > then click [Edit] button. See what it says for the application to be > used. > > Do the same on the Win7 machine -- it probably doesn't have "edit" > as an action, so you'll be picking the [New] button. Define the new > action to look like the action on the laptop (use the correct path to > the python executable, and maybe to IDLE). > > Heck, check what those actions show for PY files too... The only > difference between PY and PYW should be the application used in the > "open" action. > PY => .../python.exe > PYW => .../pythonw.exe > > Also make sure that the "open" action is the defined default (select > the action, and click the default button); when there are more than one > action, the default will be in bold. > > > > > > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. >> >> Comments? See my response to Neil Cerutti a few msgs above this one. From rosuav at gmail.com Fri Nov 18 11:04:11 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Nov 2011 03:04:11 +1100 Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On Sat, Nov 19, 2011 at 2:51 AM, Junfeng Hu wrote: > And actually ,the socket hadn't been used in this script. Doesn't matter that you haven't used it; you're binding to the port, that's what causes the 10048. I think the main problem is that you're trying to share sockets across processes, but I haven't used the Python multiprocessing module with sockets before. I would recommend, if you can, creating separate sockets in each subprocess; that might make things a bit easier. ChrisA From hujunfeng at gmail.com Fri Nov 18 11:11:40 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 08:11:40 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <15809319.188.1321632700957.JavaMail.geo-discussion-forums@yqdr22> Hi Chris. The socket only binded once. That's the problem I'm puzzleing, I think it may a bug of multiprocessing in windows, or something I missed. From hujunfeng at gmail.com Fri Nov 18 11:11:40 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 08:11:40 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <15809319.188.1321632700957.JavaMail.geo-discussion-forums@yqdr22> Hi Chris. The socket only binded once. That's the problem I'm puzzleing, I think it may a bug of multiprocessing in windows, or something I missed. From rosuav at gmail.com Fri Nov 18 11:16:47 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Nov 2011 03:16:47 +1100 Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <15809319.188.1321632700957.JavaMail.geo-discussion-forums@yqdr22> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> <15809319.188.1321632700957.JavaMail.geo-discussion-forums@yqdr22> Message-ID: On Sat, Nov 19, 2011 at 3:11 AM, Junfeng Hu wrote: > Hi Chris. > The socket only binded once. That's the problem I'm puzzleing, I think it may a bug of multiprocessing in windows, or something I missed. I don't know how multiprocessing goes about initializing those subprocesses; I suspect that's where it creates the additional sockets. ChrisA From ramapraba2653 at gmail.com Fri Nov 18 11:20:05 2011 From: ramapraba2653 at gmail.com (SUPREME) Date: Fri, 18 Nov 2011 08:20:05 -0800 (PST) Subject: FOR FAST UPDATES IN FILM INDUSTRY Message-ID: FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From python at mrabarnett.plus.com Fri Nov 18 11:55:33 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 18 Nov 2011 16:55:33 +0000 Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <4EC68E05.6030209@mrabarnett.plus.com> On 18/11/2011 15:48, Junfeng Hu wrote: > Thanks > Yes, I had tried this before, so you could find that I comment the line > sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > Here is the results. > D:\Python test>mythread2.py > Traceback (most recent call last): > File "", line 1, in > File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main > self = load(from_parent) > File "C:\Python27\lib\pickle.py", line 1378, in load > return Unpickler(file).load() > File "C:\Python27\lib\pickle.py", line 858, in load > dispatch[key](self) > File "C:\Python27\lib\pickle.py", line 1133, in load_reduce > value = func(*args) > File "C:\Python27\lib\multiprocessing\reduction.py", line 167, in rebuild_sock > et > _sock = fromfd(fd, family, type_, proto) > File "C:\Python27\lib\multiprocessing\reduction.py", line 156, in fromfd > s = socket.fromfd(fd, family, type_, proto) > AttributeError: 'module' object has no attribute 'fromfd' The documentation for socket.fromfd says: Availability: Unix. You're using Microsoft Windows. From jeanmichel at sequans.com Fri Nov 18 11:56:29 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 18 Nov 2011 17:56:29 +0100 Subject: Dynamically Generate Methods In-Reply-To: References: Message-ID: <4EC68E3D.4050402@sequans.com> GZ wrote: > Hi, > > I have a class Record and a list key_attrs that specifies the names of > all attributes that correspond to a primary key. > > I can write a function like this to get the primary key: > > def get_key(instance_of_record): > return tuple(instance_of_record.__dict__[k] for k in key_attrs) > > However, since key_attrs are determined at the beginning of the > program while get_key() will be called over and over again, I am > wondering if there is a way to dynamically generate a get_ley method > with the key attributes expanded to avoid the list comprehension/ > generator. > > For example, if key_attrs=['A','B'], I want the generated function to > be equivalent to the following: > > def get_key(instance_of_record): > return (instance_of_record['A'],instance_of_record['B'] ) > > I realize I can use eval or exec to do this. But is there any other > way to do this? > > Thanks, > gz > > > > Hi, you may want to do something like class Record(object): PRIMARY_KEY = [] def __init__(self): for key in self.PRIMARY_KEY: setattr(self, key, None) def getPrimaryKeyValues(self): return [ getattr(self, key) for key in self.PRIMARY_KEY] class FruitRecord(Record): PRIMARY_KEY = ['fruit_id', 'fruit_name'] JM PS : there's a high chance that a python module already exists to access your database with python objects. From python at mrabarnett.plus.com Fri Nov 18 12:12:40 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 18 Nov 2011 17:12:40 +0000 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> Message-ID: <4EC69208.6040104@mrabarnett.plus.com> On 18/11/2011 15:29, W. eWatson wrote: > On 11/18/2011 5:11 AM, Neil Cerutti wrote: >> On 2011-11-18, W. eWatson wrote: >>> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >>>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >>>> >>>>> I have not found any successful way to get to IDLE. It's on on the >>>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>>>> with a "invalid Win32 app" msg. >>>> >>>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >>>> does it work? >>>> >>>> Failing that, go to your laptop where the associations are right, >>>> and see >>>> what they are, then duplicate the settings on your Windows 7 machine. >>> >>> Sounds like a good idea except I've not used associations in so >>> long under XP, I have no idea where to start. Control Panel. My >>> Computer Tools? >> >> Open Windows Explorer. >> With the menu, to to Tools->Folder Options >> Click the File Types tab in the Folder Options menu. >> >> There will be an upper view with registered filed types, and some >> buttons below far making changes to them. >> > OK, I've found that. I see > Py > Pyc > Pyo > Pyw > If I click on each, it basically it gives a short description of each. > If I click advanced, there's more info. For example for py, Actions are > IDLE and Open. > > What does this tell me that's relevant to Win7? > > If on Win7, I go to Default Programs I see under associations various > python items. Py shows Unknown application. Since installing 2.7.2 I > have not messed with these associations. If I right-click on Unknown, I > see Notepad and python.exe for choices to open the file. I want neither. > Why isn't IDLE listed there? > > If I right-click on junk.py, I see "Open with". Notepad and python.exe > are choices. However, that menu allows me to choose something else. For > example, Adobe Reader, or Internet Explorer. I suppose the next question > is should I use the browse there and try to connect to IDLE in > ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid > Win32 app", when I try to use it. > You can't associate .py with Idle because Idle is a Python script, not an executable (an .exe). Have a look here: http://superuser.com/questions/68852/change-windows-7-explorer-edit-context-menu-action-for-jpg-and-other-image-fil In my PC's registry (Windows XP, but Windows 7 should be similar or the same) it has the entry: Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command Value: "C:\Python31\pythonw.exe" "C:\Python31\Lib\idlelib\idle.pyw" -n -e "%1" Note how it actually associates the Edit action of Python files with an .exe file. From rustompmody at gmail.com Fri Nov 18 12:19:53 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 18 Nov 2011 09:19:53 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> Message-ID: <18f7cac6-1c38-4506-b8b9-f30d2b9ae5a9@x10g2000prk.googlegroups.com> On Nov 18, 10:12?pm, MRAB wrote: > On 18/11/2011 15:29, W. eWatson wrote: > > > > > > > > > On 11/18/2011 5:11 AM, Neil Cerutti wrote: > >> On 2011-11-18, W. eWatson wrote: > >>> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: > >>>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: > > >>>>> I have not found any successful way to get to IDLE. It's on on the > >>>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails > >>>>> with a "invalid Win32 app" msg. > > >>>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, > >>>> does it work? > > >>>> Failing that, go to your laptop where the associations are right, > >>>> and see > >>>> what they are, then duplicate the settings on your Windows 7 machine. > > >>> Sounds like a good idea except I've not used associations in so > >>> long under XP, I have no idea where to start. Control Panel. My > >>> Computer Tools? > > >> Open Windows Explorer. > >> With the menu, to to Tools->Folder Options > >> Click the File Types tab in the Folder Options menu. > > >> There will be an upper view with registered filed types, and some > >> buttons below far making changes to them. > > > OK, I've found that. I see > > Py > > Pyc > > Pyo > > Pyw > > If I click on each, it basically it gives a short description of each. > > If I click advanced, there's more info. For example for py, Actions are > > IDLE and Open. > > > What does this tell me that's relevant to Win7? > > > If on Win7, I go to Default Programs I see under associations various > > python items. Py shows Unknown application. Since installing 2.7.2 I > > have not messed with these associations. If I right-click on Unknown, I > > see Notepad and python.exe for choices to open the file. I want neither. > > Why isn't IDLE listed there? > > > If I right-click on junk.py, I see "Open with". Notepad and python.exe > > are choices. However, that menu allows me to choose something else. For > > example, Adobe Reader, or Internet Explorer. I suppose the next question > > is should I use the browse there and try to connect to IDLE in > > ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid > > Win32 app", when I try to use it. > > You can't associate .py with Idle because Idle is a Python script, not > an executable (an .exe). > > Have a look here:http://superuser.com/questions/68852/change-windows-7-explorer-edit-c... > > In my PC's registry (Windows XP, but Windows 7 should be similar or the > same) it has the entry: > > Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command > Value: "C:\Python31\pythonw.exe" "C:\Python31\Lib\idlelib\idle.pyw" -n > -e "%1" > > Note how it actually associates the Edit action of Python files with an > .exe file. The tools -> folder options approach is the user-friendly approach -- when it works. The 'Correct the registry' is the muscular approach -- it will set right everything iff you are a wizard. In between the two is assoc and ftype see http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ftype.mspx?mfr=true http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/assoc.mspx?mfr=true From wolftracks at invalid.com Fri Nov 18 12:45:26 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 09:45:26 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> Message-ID: On 11/18/2011 9:12 AM, MRAB wrote: > On 18/11/2011 15:29, W. eWatson wrote: >> On 11/18/2011 5:11 AM, Neil Cerutti wrote: >>> On 2011-11-18, W. eWatson wrote: >>>> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >>>>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >>>>> >>>>>> I have not found any successful way to get to IDLE. It's on on the >>>>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>>>>> with a "invalid Win32 app" msg. >>>>> >>>>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >>>>> does it work? >>>>> >>>>> Failing that, go to your laptop where the associations are right, >>>>> and see >>>>> what they are, then duplicate the settings on your Windows 7 machine. >>>> >>>> Sounds like a good idea except I've not used associations in so >>>> long under XP, I have no idea where to start. Control Panel. My >>>> Computer Tools? >>> >>> Open Windows Explorer. >>> With the menu, to to Tools->Folder Options >>> Click the File Types tab in the Folder Options menu. >>> >>> There will be an upper view with registered filed types, and some >>> buttons below far making changes to them. >>> >> OK, I've found that. I see >> Py >> Pyc >> Pyo >> Pyw >> If I click on each, it basically it gives a short description of each. >> If I click advanced, there's more info. For example for py, Actions are >> IDLE and Open. >> >> What does this tell me that's relevant to Win7? >> >> If on Win7, I go to Default Programs I see under associations various >> python items. Py shows Unknown application. Since installing 2.7.2 I >> have not messed with these associations. If I right-click on Unknown, I >> see Notepad and python.exe for choices to open the file. I want neither. >> Why isn't IDLE listed there? >> >> If I right-click on junk.py, I see "Open with". Notepad and python.exe >> are choices. However, that menu allows me to choose something else. For >> example, Adobe Reader, or Internet Explorer. I suppose the next question >> is should I use the browse there and try to connect to IDLE in >> ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid >> Win32 app", when I try to use it. >> > You can't associate .py with Idle because Idle is a Python script, not > an executable (an .exe). Odd, but OK. > > Have a look here: > http://superuser.com/questions/68852/change-windows-7-explorer-edit-context-menu-action-for-jpg-and-other-image-fil Are you suggesting that I use the "default" program mentioned there? > > > In my PC's registry (Windows XP, but Windows 7 should be similar or the > same) it has the entry: > > Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command > Value: "C:\Python31\pythonw.exe" "C:\Python31\Lib\idlelib\idle.pyw" -n > -e "%1" > > Note how it actually associates the Edit action of Python files with an > .exe file. So pythonw.exe and idle.pyw are not scripts but somehow can fire up idle? Are you suggesting I modify my registry? I still find it bizarre the install did not put it IDLE choice on the menu for py. It's there on XP. From wolftracks at invalid.com Fri Nov 18 12:48:54 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 09:48:54 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: <18f7cac6-1c38-4506-b8b9-f30d2b9ae5a9@x10g2000prk.googlegroups.com> References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> <18f7cac6-1c38-4506-b8b9-f30d2b9ae5a9@x10g2000prk.googlegroups.com> Message-ID: On 11/18/2011 9:19 AM, rusi wrote: > On Nov 18, 10:12 pm, MRAB wrote: >> On 18/11/2011 15:29, W. eWatson wrote: >> >> >> >> >> >> >> >>> On 11/18/2011 5:11 AM, Neil Cerutti wrote: >>>> On 2011-11-18, W. eWatson wrote: >>>>> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >>>>>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >> >>>>>>> I have not found any successful way to get to IDLE. It's on on the >>>>>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>>>>>> with a "invalid Win32 app" msg. >> >>>>>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >>>>>> does it work? >> >>>>>> Failing that, go to your laptop where the associations are right, >>>>>> and see >>>>>> what they are, then duplicate the settings on your Windows 7 machine. >> >>>>> Sounds like a good idea except I've not used associations in so >>>>> long under XP, I have no idea where to start. Control Panel. My >>>>> Computer Tools? >> >>>> Open Windows Explorer. >>>> With the menu, to to Tools->Folder Options >>>> Click the File Types tab in the Folder Options menu. >> >>>> There will be an upper view with registered filed types, and some >>>> buttons below far making changes to them. >> >>> OK, I've found that. I see >>> Py >>> Pyc >>> Pyo >>> Pyw >>> If I click on each, it basically it gives a short description of each. >>> If I click advanced, there's more info. For example for py, Actions are >>> IDLE and Open. >> >>> What does this tell me that's relevant to Win7? >> >>> If on Win7, I go to Default Programs I see under associations various >>> python items. Py shows Unknown application. Since installing 2.7.2 I >>> have not messed with these associations. If I right-click on Unknown, I >>> see Notepad and python.exe for choices to open the file. I want neither. >>> Why isn't IDLE listed there? >> >>> If I right-click on junk.py, I see "Open with". Notepad and python.exe >>> are choices. However, that menu allows me to choose something else. For >>> example, Adobe Reader, or Internet Explorer. I suppose the next question >>> is should I use the browse there and try to connect to IDLE in >>> ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid >>> Win32 app", when I try to use it. >> >> You can't associate .py with Idle because Idle is a Python script, not >> an executable (an .exe). >> >> Have a look here:http://superuser.com/questions/68852/change-windows-7-explorer-edit-c... >> >> In my PC's registry (Windows XP, but Windows 7 should be similar or the >> same) it has the entry: >> >> Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command >> Value: "C:\Python31\pythonw.exe" "C:\Python31\Lib\idlelib\idle.pyw" -n >> -e "%1" >> >> Note how it actually associates the Edit action of Python files with an >> .exe file. > > The tools -> folder options approach is the user-friendly approach -- > when it works. > The 'Correct the registry' is the muscular approach -- it will set > right everything iff you are a wizard. > > In between the two is assoc and ftype see > http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ftype.mspx?mfr=true > http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/assoc.mspx?mfr=true These two seem equally muscular. I shudder to think where these choices might lead me. From duncan.booth at invalid.invalid Fri Nov 18 12:52:49 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 18 Nov 2011 17:52:49 GMT Subject: Dynamically Generate Methods References: Message-ID: GZ wrote: > For example, if key_attrs=['A','B'], I want the generated function to > be equivalent to the following: > > def get_key(instance_of_record): > return (instance_of_record['A'],instance_of_record['B'] ) > > I realize I can use eval or exec to do this. But is there any other > way to do this? > Use operator.itemgetter: >>> key_attrs = ['A', 'B'] >>> import operator >>> get_key = operator.itemgetter(*key_attrs) >>> d = {'A': 42, 'B': 63, 'C': 99} >>> get_key(d) (42, 63) -- Duncan Booth http://kupuguy.blogspot.com From wolftracks at invalid.com Fri Nov 18 12:57:53 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 09:57:53 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 11:35 PM, Terry Reedy wrote: > On 11/17/2011 7:03 PM, W. eWatson wrote: > >> I have not found any successful way to get to IDLE. > > Use the start menu to start IDLE once. Then pin it to your taskbar. > If you do not have STart/ all programs / Python / IDLE, then your > installation is bad. > > As for the right click problem, you probably have something screwy in > the registry. The python installer (or uninstaller) will not fix it (my > experience on my old xp machine). You will have to do so manually. > IDLE is a choice on the Start menu (All Programs). Pressing it does nothing. I see nothing that suggests it's open. The IDLE entry is pointing at c:\Python27\ (shortcut) A post above yours suggests IDLE is a script, and somehow needs a "boost" to use it. An exe file, apparently. Beats the heck out of me. From wolftracks at invalid.com Fri Nov 18 12:59:00 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 09:59:00 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 9:25 PM, Benjamin Kaplan wrote: > On Thu, Nov 17, 2011 at 11:21 PM, W. eWatson wrote: >> >> On 11/17/2011 7:59 PM, Dave Angel wrote: >>> >>> On 11/17/2011 03:31 PM, W. eWatson wrote: >>>> >>>> On 11/17/2011 9:39 AM, John Gordon wrote: >>>> >>>>> >>>>> Can you add IDLE manually to the associated applications list? >>>>> >>>> Tried that by sending it directly to idle.pyw, but then trying to get >>>> there through the Edit with menu caused a "invalid Win32 app." >>> >>> You've been told repeatedly that building an association to idle.pyw is >>> useless. It must be to something Windows understands, such as .exe, or >>> .bat (or several other extensions, as I said in an earlier message) So >>> why waste our time telling us yet again that it doesn't work? >>> >>> >>> >> Because some people think that's a solution, and ask. It's not. It leads to an error message. > > > Checking my Python install, there should be an idle.bat file in there > too. Have you tried that? Yes. I tried running it. Got nowhere. From ian.g.kelly at gmail.com Fri Nov 18 13:04:19 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 18 Nov 2011 11:04:19 -0700 Subject: Dynamically Generate Methods In-Reply-To: References: Message-ID: On Fri, Nov 18, 2011 at 7:51 AM, GZ wrote: > Hi, > > I have a class Record and a list key_attrs that specifies the names of > all attributes that correspond to a primary key. > > I can write a function like this to get the primary key: > > def get_key(instance_of_record): > return tuple(instance_of_record.__dict__[k] for k in key_attrs) > > However, since key_attrs are determined at the beginning of the > program while get_key() will be called over and over again, I am > wondering if there is a way to dynamically generate a get_ley method > with the key attributes expanded to avoid the list comprehension/ > generator. (Accidentally sent this to the OP only) This is exactly what the attrgetter factory function produces. from operator import attrgetter get_key = attrgetter(*key_attrs) But if your attribute names are variable and arbitrary, I strongly recommend you store them in a dict instead. Setting them as instance attributes risks that they might conflict with the regular attributes and methods on your objects. Cheers, Ian From wolftracks at invalid.com Fri Nov 18 13:06:47 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 10:06:47 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) Message-ID: Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 flop the same way under Win 7. One thing I think no one has offered is whether their installation of 2.7.2 has the same IDLE oddity that I've described. That is, if you right-click on a py file, do you see a choice for the IDLE editor? From wolftracks at invalid.com Fri Nov 18 13:10:32 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 10:10:32 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: Message-ID: On 11/18/2011 10:06 AM, W. eWatson wrote: > Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 > flop the same way under Win 7. > > One thing I think no one has offered is whether their installation of > 2.7.2 has the same IDLE oddity that I've described. That is, if you > right-click on a py file, do you see a choice for the IDLE editor? Try it on Win 7. From mbadoiu at gmail.com Fri Nov 18 16:10:24 2011 From: mbadoiu at gmail.com (Mihai Badoiu) Date: Fri, 18 Nov 2011 16:10:24 -0500 Subject: Resources consumed by parent Message-ID: How do I get the resources consumed by the parent process? getrusage() in the resource module seems to work only for self or the children processes. thanks, --mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From me+list/python at ixokai.io Fri Nov 18 17:31:54 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Fri, 18 Nov 2011 14:31:54 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4EC6DCDA.8040802@ixokai.io> On 11/17/11 8:34 PM, W. eWatson wrote: > On 11/17/2011 7:04 PM, alex23 wrote: >> On Nov 18, 2:55 am, "W. eWatson" wrote: >>> Comments? >> >> Are you using the vanilla installer or ActiveState's ActivePython? I >> find the latter integrates better with Windows. >> >> Also, out of curiousity, 32 or 64 bit Windows? > 64-bit and plain old python msi installer. That'd be it, I expect. Windows has two parallel registry trees; if you launch a 32-bit program, it sees one.. if you launch a 64-bit program, it sees the other. What looks like the exact same keys can be different as a result. The MSI is probably writing the keys into the 32-bit registry, and Explorer is now a 64-bit application. You can add the associations for Edit manually. Though not to "idle.pyw", which you keep -- repeatedly -- saying you try and errors. Of course it errors. That's a python script, not an executable. Associate to pythonw.exe, and pass it the path to idle.pyw, and then -n -e "%1" -- which will be replaced with the actual filename. But you were told that already and seem to have just dismissed it out of hand. Like: PATH\pythonw.exe PATH\idle.pyw -n -e "%1" ... where PATH is whatever the location of those files are in your environment. Yes, its moderately annoying that you have to do this yourself; maybe you wouldn't if you installed 64-bit python, but I can't be sure. Maybe it has nothing to do with 32 or 64-bitness at all and my guess is wrong. Maybe your profile has gone wonky. But it doesn't matter. You can add the Edit association yourself. Its a one-time fix. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From steve+comp.lang.python at pearwood.info Fri Nov 18 18:44:08 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Nov 2011 23:44:08 GMT Subject: Python 2.7.2 on Win7 and IDLE (Try it) References: Message-ID: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: > Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 > flop the same way under Win 7. > > One thing I think no one has offered is whether their installation of > 2.7.2 has the same IDLE oddity that I've described. That is, if you > right-click on a py file, do you see a choice for the IDLE editor? Terry Reedy has already said that his installation works fine. "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." If you have installed the regular, 32-bit version of Python on a 64-bit version of Windows, chances are good that there will be registry problems stopping things from working correctly. See Stephen Hansen's post. -- Steven From wolftracks at invalid.com Fri Nov 18 19:31:03 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 16:31:03 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/18/2011 3:44 PM, Steven D'Aprano wrote: > On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: > >> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >> flop the same way under Win 7. >> >> One thing I think no one has offered is whether their installation of >> 2.7.2 has the same IDLE oddity that I've described. That is, if you >> right-click on a py file, do you see a choice for the IDLE editor? > > Terry Reedy has already said that his installation works fine. > > "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." > > > If you have installed the regular, 32-bit version of Python on a 64-bit > version of Windows, chances are good that there will be registry problems > stopping things from working correctly. See Stephen Hansen's post. > > > Somehow 3.3.2 doesn't look like 2.7.2. Ah, I installed a 32-bit. Missed his post. So what should I do? Try 3.3.2 64-bit? I'm game. By the time you read this, I will either have done it or gotten into it. From wolftracks at invalid.com Fri Nov 18 19:50:24 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 16:50:24 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/18/2011 4:31 PM, W. eWatson wrote: > On 11/18/2011 3:44 PM, Steven D'Aprano wrote: >> On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: >> >>> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >>> flop the same way under Win 7. >>> >>> One thing I think no one has offered is whether their installation of >>> 2.7.2 has the same IDLE oddity that I've described. That is, if you >>> right-click on a py file, do you see a choice for the IDLE editor? >> >> Terry Reedy has already said that his installation works fine. >> >> "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." >> >> >> If you have installed the regular, 32-bit version of Python on a 64-bit >> version of Windows, chances are good that there will be registry problems >> stopping things from working correctly. See Stephen Hansen's post. >> >> >> > Somehow 3.3.2 doesn't look like 2.7.2. > > Ah, I installed a 32-bit. Missed his post. So what should I do? Try > 3.3.2 64-bit? I'm game. By the time you read this, I will either have > done it or gotten into it. 3.3.2? I do not see that in his single message I found. I see a 3.2.2 release on . Google shows me nothing for 3.3.2. I see: * Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug information files (sig) * Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug information files (sig) Visual Studio???? I hope I don't need VS! From python at mrabarnett.plus.com Fri Nov 18 20:22:04 2011 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 19 Nov 2011 01:22:04 +0000 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4EC704BC.6050703@mrabarnett.plus.com> On 19/11/2011 00:50, W. eWatson wrote: > On 11/18/2011 4:31 PM, W. eWatson wrote: >> On 11/18/2011 3:44 PM, Steven D'Aprano wrote: >>> On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: >>> >>>> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >>>> flop the same way under Win 7. >>>> >>>> One thing I think no one has offered is whether their installation of >>>> 2.7.2 has the same IDLE oddity that I've described. That is, if you >>>> right-click on a py file, do you see a choice for the IDLE editor? >>> >>> Terry Reedy has already said that his installation works fine. >>> >>> "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works >>> fine." >>> >>> >>> If you have installed the regular, 32-bit version of Python on a 64-bit >>> version of Windows, chances are good that there will be registry >>> problems >>> stopping things from working correctly. See Stephen Hansen's post. >>> >>> >>> >> Somehow 3.3.2 doesn't look like 2.7.2. >> >> Ah, I installed a 32-bit. Missed his post. So what should I do? Try >> 3.3.2 64-bit? I'm game. By the time you read this, I will either have >> done it or gotten into it. > > 3.3.2? I do not see that in his single message I found. I see a 3.2.2 > release on . Google > shows me nothing for 3.3.2. > > I see: > * Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug > information files (sig) > * Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug > information files (sig) > > Visual Studio???? I hope I don't need VS! If you look more closely you'll see that there are 5 links on each line: Windows X86-64 MSI Installer (3.2.2) [1] (sig) Visual Studio debug information files (sig) Unless you intending to work on the sources, you need just the first one: Windows X86-64 MSI Installer (3.2.2) for a 64-bit build of Python 3.2.2. From hujunfeng at gmail.com Fri Nov 18 21:45:42 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 18:45:42 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <5e4635df-936f-4f5d-b3c9-ad4370a3be64@j10g2000vbe.googlegroups.com> On Nov 18, 10:55?am, MRAB wrote: > On 18/11/2011 15:48, Junfeng Hu wrote: > > > > > > > Thanks > > Yes, I had tried this before, so you could find that I comment the line > > sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > > Here is the results. > > D:\Python test>mythread2.py > > Traceback (most recent call last): > > ? ?File "", line 1, in > > ? ?File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main > > ? ? ?self = load(from_parent) > > ? ?File "C:\Python27\lib\pickle.py", line 1378, in load > > ? ? ?return Unpickler(file).load() > > ? ?File "C:\Python27\lib\pickle.py", line 858, in load > > ? ? ?dispatch[key](self) > > ? ?File "C:\Python27\lib\pickle.py", line 1133, in load_reduce > > ? ? ?value = func(*args) > > ? ?File "C:\Python27\lib\multiprocessing\reduction.py", line 167, in rebuild_sock > > et > > ? ? ?_sock = fromfd(fd, family, type_, proto) > > ? ?File "C:\Python27\lib\multiprocessing\reduction.py", line 156, in fromfd > > ? ? ?s = socket.fromfd(fd, family, type_, proto) > > AttributeError: 'module' object has no attribute 'fromfd' > > The documentation for socket.fromfd says: > > ? ? ?Availability: Unix. > > You're using Microsoft Windows.- Hide quoted text - > > - Show quoted text - Yes, but my question is , how to make such script work in windows. From sturlamolden at yahoo.no Fri Nov 18 23:26:17 2011 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 18 Nov 2011 20:26:17 -0800 (PST) Subject: Data Plotting Library Dislin 10.2 References: Message-ID: <9599229d-28aa-4730-b29a-b7c32e1e3d2e@e15g2000vba.googlegroups.com> On 18 Nov, 22:16, Tony the Tiger wrote: > Ya, but apparently no source unless you dig deep into your pockets. > Really, why would we need this when we already have gnuplot? > Just wondering... Dislin is a very nice plotting library for scientific data, particularly for scientists and engineers using Fortran (which, incidentally, is quite a few). For Python, we have Matplotlib as well (at least for 2D plots). Sturla From steve+comp.lang.python at pearwood.info Fri Nov 18 23:36:08 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Nov 2011 04:36:08 GMT Subject: Python 2.7.2 on Win7 and IDLE (Try it) References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ec73237$0$29967$c3e8da3$5496439d@news.astraweb.com> On Fri, 18 Nov 2011 16:31:03 -0800, W. eWatson wrote: > Somehow 3.3.2 doesn't look like 2.7.2. Oops, so you're right. Sorry for the noise. -- Steven From wolftracks at invalid.com Sat Nov 19 00:03:58 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 21:03:58 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: ... >> >> 3.3.2? I do not see that in his single message I found. I see a 3.2.2 >> release on . Google >> shows me nothing for 3.3.2. >> >> I see: >> * Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug >> information files (sig) >> * Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug >> information files (sig) >> >> Visual Studio???? I hope I don't need VS! > > If you look more closely you'll see that there are 5 links on each line: > > Windows X86-64 MSI Installer (3.2.2) > [1] > (sig) > Visual Studio debug information files > (sig) > > Unless you intending to work on the sources, you need just the first > one: > > Windows X86-64 MSI Installer (3.2.2) > > for a 64-bit build of Python 3.2.2. An oddity occurs here. Yes, x86-64 is the right installer, maybe. While noting your msg, my PC got very slow, and I ended up going to a related site for the downloads of 3.2.2 while trying for the one above. . It shows: Also look at the detailed Python 3.2.2 page: * Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not include source) * Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 / X86-64 binary [1] -- does not include source) The first of the two choices does not say x-bit anything. The second looks off course for my HP 64-bit PC. I'm going to just use Windows X86-64 MSI Installer (3.2.2). Wait a minute Windows X86-64 MSI Installer (3.2.2). Windows X86-64 MSI Installer (3.2.2) shows it's associated with Visual Studio. Why would I want that? Ah, I get it The single first line has Windows X86-64 MSI Installer (3.2.2) and Visual Studio. That's a really weird way to arrange them. OK, now off to Windows X86-64 MSI Installer (3.2.2) I'll be back shortly after I've made the install. From wolftracks at invalid.com Sat Nov 19 00:28:39 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 21:28:39 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/18/2011 9:03 PM, W. eWatson wrote: > ... >>> >>> 3.3.2? I do not see that in his single message I found. I see a 3.2.2 >>> release on . Google >>> shows me nothing for 3.3.2. >>> >>> I see: >>> * Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug >>> information files (sig) >>> * Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug >>> information files (sig) >>> >>> Visual Studio???? I hope I don't need VS! >> >> If you look more closely you'll see that there are 5 links on each line: >> >> Windows X86-64 MSI Installer (3.2.2) >> [1] >> (sig) >> Visual Studio debug information files >> (sig) >> >> Unless you intending to work on the sources, you need just the first >> one: >> >> Windows X86-64 MSI Installer (3.2.2) >> >> for a 64-bit build of Python 3.2.2. > > An oddity occurs here. Yes, x86-64 is the right installer, maybe. While > noting your msg, my PC got very slow, and I ended up going to a related > site for the downloads of 3.2.2 while trying for the one above. > . > > It shows: > Also look at the detailed Python 3.2.2 page: > > * Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not > include source) > * Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 / > X86-64 binary [1] -- does not include source) > > The first of the two choices does not say x-bit anything. The second > looks off course for my HP 64-bit PC. > > I'm going to just use Windows X86-64 MSI Installer (3.2.2). > > Wait a minute Windows X86-64 MSI Installer (3.2.2). Windows X86-64 MSI > Installer (3.2.2) shows it's associated with Visual Studio. Why would I > want that? Ah, I get it The single first line has Windows X86-64 MSI > Installer (3.2.2) and Visual Studio. That's a really weird way to > arrange them. OK, now off to Windows X86-64 MSI Installer (3.2.2) > > I'll be back shortly after I've made the install. I surrender. IDLE does not appear as a choice when I right-click on a py file. IDLE is on the All Programs list, and if I click on it, something more or less seems to happen, but it does not reveal anything. There is a comparability choice there that asks what OS did it last run on. Unfortunately the choices were VISTA (service packs) and Win7. I selected Win7 but it didn't help. Off to bed soon. From tjreedy at udel.edu Sat Nov 19 05:34:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 19 Nov 2011 05:34:25 -0500 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/18/2011 6:44 PM, Steven D'Aprano wrote: > On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: > >> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >> flop the same way under Win 7. >> >> One thing I think no one has offered is whether their installation of >> 2.7.2 has the same IDLE oddity that I've described. That is, if you >> right-click on a py file, do you see a choice for the IDLE editor? > > Terry Reedy has already said that his installation works fine. > > "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." 64 bit python and 64 bit win 7 > > If you have installed the regular, 32-bit version of Python on a 64-bit > version of Windows, chances are good that there will be registry problems > stopping things from working correctly. See Stephen Hansen's post. > > > -- Terry Jan Reedy From tjreedy at udel.edu Sat Nov 19 05:39:19 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 19 Nov 2011 05:39:19 -0500 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/19/2011 12:03 AM, W. eWatson wrote: I meant 3.2.2, not 3.3.2, sorry for typo. > * Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not > include source) this is 32 bit. Note that your c: has /program files for 64 bit programs and /program files(x86) for 32 bit programs. I know, a bit confusing. > * Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 / > X86-64 binary [1] -- does not include source) this is 64 bit. -- Terry Jan Reedy From alec.taylor6 at gmail.com Sat Nov 19 08:51:57 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sun, 20 Nov 2011 00:51:57 +1100 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: Message-ID: Works fine for me from msi install on Windows 8 x64 Dev Preview On Sat, Nov 19, 2011 at 5:06 AM, W. eWatson wrote: > Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 flop > the same way under Win 7. > > One thing I think no one has offered is whether their installation of 2.7.2 > has the same IDLE oddity that I've described. ?That is, if you right-click > on a py file, do you see a choice for the IDLE editor? > -- > http://mail.python.org/mailman/listinfo/python-list From safeerheart at gmail.com Sat Nov 19 09:54:47 2011 From: safeerheart at gmail.com (safeer) Date: Sat, 19 Nov 2011 06:54:47 -0800 (PST) Subject: dj Message-ID: <275a84ea-7a85-42fe-82ce-eab8e63326f0@q39g2000prg.googlegroups.com> http://123maza.com/48/gold028/ From wolftracks at invalid.com Sat Nov 19 10:35:52 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sat, 19 Nov 2011 07:35:52 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/19/2011 2:39 AM, Terry Reedy wrote: > On 11/19/2011 12:03 AM, W. eWatson wrote: > > I meant 3.2.2, not 3.3.2, sorry for typo. > >> * Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not >> include source) > > this is 32 bit. Note that your c: has /program files for 64 bit programs > and /program files(x86) for 32 bit programs. I know, a bit confusing. > >> * Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 / >> X86-64 binary [1] -- does not include source) > > this is 64 bit. > Yes. Did I miss something? From wolftracks at invalid.com Sat Nov 19 10:39:34 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sat, 19 Nov 2011 07:39:34 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/19/2011 2:34 AM, Terry Reedy wrote: > On 11/18/2011 6:44 PM, Steven D'Aprano wrote: >> On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: >> >>> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >>> flop the same way under Win 7. >>> >>> One thing I think no one has offered is whether their installation of >>> 2.7.2 has the same IDLE oddity that I've described. That is, if you >>> right-click on a py file, do you see a choice for the IDLE editor? >> >> Terry Reedy has already said that his installation works fine. >> >> "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." > > 64 bit python and 64 bit win 7 >> >> If you have installed the regular, 32-bit version of Python on a 64-bit >> version of Windows, chances are good that there will be registry problems >> stopping things from working correctly. See Stephen Hansen's post. >> >> >> > > Yes, see the other fork started by MRAB I tried it. Same old problem. From wolftracks at invalid.com Sat Nov 19 11:14:57 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sat, 19 Nov 2011 08:14:57 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: Message-ID: On 11/19/2011 5:51 AM, Alec Taylor wrote: > Works fine for me from msi install on Windows 8 x64 Dev Preview > > On Sat, Nov 19, 2011 at 5:06 AM, W. eWatson wrote: >> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 flop >> the same way under Win 7. >> >> One thing I think no one has offered is whether their installation of 2.7.2 >> has the same IDLE oddity that I've described. That is, if you right-click >> on a py file, do you see a choice for the IDLE editor? >> -- >> http://mail.python.org/mailman/listinfo/python-list 3.2.2, and not 2.7.2. The course of the thread was changed at the MRAB post. What do you mean by it works fine? My criterion is that it puts IDLE as a choice for editor on the menu produced with a right-click on a py file. From wolftracks at invalid.com Sat Nov 19 11:18:54 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sat, 19 Nov 2011 08:18:54 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: Message-ID: On 11/19/2011 5:51 AM, Alec Taylor wrote: > Works fine for me from msi install on Windows 8 x64 Dev Preview > > On Sat, Nov 19, 2011 at 5:06 AM, W. eWatson wrote: >> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 flop >> the same way under Win 7. >> >> One thing I think no one has offered is whether their installation of 2.7.2 >> has the same IDLE oddity that I've described. That is, if you right-click >> on a py file, do you see a choice for the IDLE editor? >> -- >> http://mail.python.org/mailman/listinfo/python-list Are you suggesting the mail list might be a better place to pursue this? Or is it from some one else? From no.email at nospam.invalid Sat Nov 19 18:21:52 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Sat, 19 Nov 2011 15:21:52 -0800 Subject: xml.dom.minidom question References: Message-ID: <7xwravu29b.fsf@ruckus.brouhaha.com> nivashno writes: > I always thought that xml was very precisely split up into nodes, > childnodes, etc, no matter what the whitespace between them was. But > apparently not, or am I missing something? The whitespace in your example becomes part of a data element. From vinay_sajip at yahoo.co.uk Sat Nov 19 19:42:19 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sat, 19 Nov 2011 16:42:19 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> <4f5fd473-4717-4f41-8017-d7407adc4571@u10g2000prl.googlegroups.com> Message-ID: <5dfa9add-582f-4219-8d78-01239f80525e@p5g2000vbm.googlegroups.com> On Nov 17, 9:06?am, sword wrote: > On Nov 16, 10:50?pm, Peter Otten <__pete... at web.de> wrote: > > > > > > > > > > > sword wrote: > > > Thanks for your reply. I tried to edit the source a bit, now the > > > main.py looks like this: > > > #main.py > > > importlogging > > > fromloggingimport Filter > > > import a > > > import b > > > >logging.basicConfig(level=logging.DEBUG) > > > root =logging.getLogger() > > > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > > > would pass this filter > > > > logger =logging.getLogger("main") > > > logger.debug("main process") > > > a.print_log() > > > b.print_log() > > > > #### > > > And It still prints out all the log msg. :( > > > Here's a little demo to explore how filtering works: > > > $ cat demo.py > > importlogging > > class Filter(logging.Filter): > > ? ? def filter(self, record): > > ? ? ? ? print "applying filter", self.name > > ? ? ? ? return True > > >logging.basicConfig() > > > loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]] > > for logger in loggers: > > ? ? logger.addFilter(Filter("filter@" + logger.name)) > > > [handler] =logging.getLogger().handlers > > handler.addFilter(Filter("filter at handler")) > > > for logger in loggers: > > ? ? logger.critical("whatever") > > $ python demo.py > > applying filter filter at root > > applying filter filter at handler > > CRITICAL:root:whatever > > applying filter filter at a > > applying filter filter at handler > > CRITICAL:a:whatever > > applying filter fil... at a.b > > applying filter filter at handler > > CRITICAL:a.b:whatever > > $ > > > As you can infer from the output only the filter(s) of the original logger > > and of the handler(s) are applied. > > Thanks, so if I want to see my own log out of all logs produced by > different module in the project, I should addFilter to each > corresponding logger. I thought I could add Filter in root and filter > out only the interested info from it before. Or you can add a filter to the handler (but then you can't use basicConfig() to configure it - you need to do it explicitly). Regards, Vinay Sajip From kwa at kuwata-lab.com Sat Nov 19 23:30:22 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Sun, 20 Nov 2011 13:30:22 +0900 Subject: [ANN] Oktest.py 0.11.0 released - a new-style testing library Message-ID: I released Oktest.py 0.11.0. http://pypi.python.org/pypi/Oktest/ http://packages.python.org/Oktest/ Oktest.py is a new-style testing library for Python. :: from oktest import ok, NG ok (x) > 0 # same as assertTrue(x > 0) ok (s) == 'foo' # same as assertEqual(s, 'foo') ok (s) != 'foo' # same as assertNotEqual(s, 'foo') ok (f).raises(ValueError) # same as assertRaises(ValueError, f) ok (u'foo').is_a(unicode) # same as assertTrue(isinstance(u'foo', unicode)) NG (u'foo').is_a(int) # same as assertTrue(not isinstance(u'foo', int)) ok ('A.txt').is_file() # same as assertTrue(os.path.isfile('A.txt')) NG ('A.txt').is_dir() # same as assertTrue(not os.path.isdir('A.txt')) See http://packages.python.org/Oktest/ for details. Changes and Enhancements ------------------------ * [change] 'spec()' is now NOT obsoleted. * [change] 'spec()' is now available as function decorator. ex:: class FooTest(unittest.TestCase): def test_method1(self) @spec("1+1 should be 2") def _(): ok (1+1) == 2 @spec("1-1 should be 0") def _(): ok (1-1) == 0 * [enhance] New assertions: not_file(), not_dir() and not_exist(). ex:: ok (".").not_file() # same as NG (".").is_file() ok (__file__).not_dir() # same as NG (__file__).is_dir() ok ("foobar").not_exist() # same as NG ("foobar").exists() * [enhance] New assertion: not_match(). ex:: ok ("SOS").not_match(r"\d+") # same as NG ("SOS").matches(r"\d+") * [enhance] Global provider/releaser functions can take 'self' argument. ex:: def provide_logname(self): self._LOGNAME = os.getenv('LOGNAME') os.environ['LOGNAME'] = "Haruhi" return os.environ['LOGNAME'] def release_logname(self, value): os.environ['LOGNAME'] = self._LOGNAME * [change] Change not to ignore test classes which name starts with '_'. * [change] (internal) Move some utility functions to 'util' module. * [change] (internal) Move '_Context' and '_RunnableContext' classes into 'util' module. * [change] (internal) Move 'Color' class into 'util' module * [change] (internal) Remove 'OUT' variable in 'Reporter' class * [change] (internal) Move 'TARGET_PATTERN' variable to 'config' * [bugfix] Fix to clear ImportError after trying to import unittest2 -- regards, makoto From andrew.rustytub at gmail.com Sun Nov 20 00:04:11 2011 From: andrew.rustytub at gmail.com (Andrew Evans) Date: Sat, 19 Nov 2011 21:04:11 -0800 Subject: Announcing Mii (My) Chat Message-ID: Hello I wish to inform the list of a Python Application I am writing entitled Mii Chat. What is Mii Chat you ask? It is an IP to IP or IP to Multiple IP text/voice/video chat client written in Python Currently the GUI is written in PyQT and could use a complete overhaul (in progress) There are a few bugs: Like I couldn't figure out the Threading for the Video so I am using QTimer. and the Audio could be improved. But overall it works as expected! I am happy about it cause I am not the best programmer. I have never been to school for Comp Science Programming or any university/college for that matter. I am self taught and consider myself a hobbyist programmer. It would be great if some one could suggest a library for TCP Nat Traversal. As well I am open to any and all suggestions! I appreciate any feedback *cheers Andrew Evans Here is the link http://code.google.com/p/mii-chat/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From nobody at nowhere.com Sun Nov 20 02:22:02 2011 From: nobody at nowhere.com (Nobody) Date: Sun, 20 Nov 2011 07:22:02 +0000 Subject: xml.dom.minidom question References: Message-ID: On Sat, 19 Nov 2011 15:32:18 -0600, nivashno wrote: > I always thought that xml was very precisely split up into nodes, > childnodes, etc, no matter what the whitespace between them was. But > apparently not, or am I missing something? XML allows mixed content (an element's children can be a mixture of text and elements). Formats such as XHTML wouldn't be possible otherwise. A validating parser will know from the schema whether an element can contain mixed content, and can use this knowledge to elide whitespace-only text nodes within elements which don't have mixed content (however, that doesn't meant that it will, or even that it should; some applications may prefer to retain the whitespace in order to preserve formatting). A non-validating parser (which doesn't use a schema) doesn't know whether an element contains mixed content, so it has to retain all text nodes in case they're significant. The Python standard library doesn't include a validating XML parser. xmlproc seems to be the preferred validating parser. That has a separate handle_ignorable_data() method for reporting whitespace-only text nodes within non-mixed-content elements; the handle_data() method is only called for "significant" text. From zyzhu2000 at gmail.com Sun Nov 20 06:23:18 2011 From: zyzhu2000 at gmail.com (GZ) Date: Sun, 20 Nov 2011 03:23:18 -0800 (PST) Subject: Dynamically Generate Methods References: Message-ID: <6c05cd6f-9adb-4f65-9da7-cd938616da41@j10g2000vbe.googlegroups.com> Hi All, I see. It works. Thanks, GZ On Nov 18, 12:04?pm, Ian Kelly wrote: > On Fri, Nov 18, 2011 at 7:51 AM, GZ wrote: > > Hi, > > > I have a class Record and a list key_attrs that specifies the names of > > all attributes that correspond to a primary key. > > > I can write a function like this to get the primary key: > > > def get_key(instance_of_record): > > ? return tuple(instance_of_record.__dict__[k] for k in key_attrs) > > > However, since key_attrs are determined at the beginning of the > > program while get_key() will be called over and over again, I am > > wondering if there is a way to dynamically generate a get_ley method > > with the key attributes expanded to avoid the list comprehension/ > > generator. > > (Accidentally sent this to the OP only) > > This is exactly what the attrgetter factory function produces. > > from operator import attrgetter > get_key = attrgetter(*key_attrs) > > But if your attribute names are variable and arbitrary, I strongly > recommend you store them in a dict instead. ?Setting them as instance > attributes risks that they might conflict with the regular attributes > and methods on your objects. > > Cheers, > Ian > > From phd at phdru.name Sun Nov 20 07:19:40 2011 From: phd at phdru.name (Oleg Broytman) Date: Sun, 20 Nov 2011 16:19:40 +0400 Subject: SQLObject 1.2.0 Message-ID: <20111120121940.GC24874@iskra.aviel.ru> Hello! I'm pleased to announce version 1.2.0, the first stable release of branch 1.2 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://pypi.python.org/pypi/SQLObject/1.2.0 News and changes: http://sqlobject.org/News.html What's New ========== Features & Interface -------------------- * Strings are treated specially in Select to allow Select(['id, 'name'], where='value = 42'). Update allows a string in WHERE. * ForeignKey('Table', refColumn='refcol_id') to allow ForeignKey to point to a non-id column; the referred column must be a unique integer column. * delColumn now accepts a ForeignKey's name without 'ID'. * Support for PostgreSQL 7.* is dropped. The minimal supported version of PostgreSQL is 8.1 now. * Quoting rules changed for PostgreSQL: SQLObject uses E'' escape string if the string contains characters escaped with backslash. * A bug caused by psycopg2 recently added a new boolean not callable autocommit attribute was fixed. * sqlobject.__doc__ and main.__doc__ no longer contain version number. Use sqlobject.version or version_info. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ phd at phdru.name Programmers don't die, they just GOSUB without RETURN. From Nikunj.Badjatya at emc.com Sun Nov 20 08:01:15 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Sun, 20 Nov 2011 08:01:15 -0500 Subject: ProgressBar - Python and Powershell In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> Can anyone throw some light on this please ! ? From: python-list-bounces+nikunj.badjatya=emc.com at python.org [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of Nikunj.Badjatya at emc.com Sent: Thursday, November 17, 2011 4:10 PM To: python-list at python.org Subject: ProgressBar - Python and Powershell Hi All, I am using Python 2.7, windows Env. I have an Installer written in Python(45%) and Powershell(55%) which is used to install Virtual Machines at specific locations. It is single threaded. I am trying to implement a ProgressBar for this installer. So that the user will come to know the progress of the installation. I am using pypi progressbar module. The top script is in python which inturns calls powershell scripts using subprocess.call() and proceeds with the installation. I am taking a shared file between python and powershell, so that diff functions can update their %age completion level in to the file. Ex. Func1() updates it to 5%, func2() will add its own 5% to it.. and so on. At the start of the (main.py) script I am creating a thread whose sole purpose would be to keep "READ" a temp file for a new entry in it. Based on this entry I can have my thread update the progressbar on the console. My questions are: 1. Can I have a better shared mechanism between python and powershell.? As I am using a file here. Reading + writing in python and writing only in powershell. ! 2. Does this thread mechanism work.? I am yet to implement and test it.! :P What can be the possible shortfalls.? Thanks Nikunj Bangalore - India -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Sun Nov 20 08:52:03 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 21 Nov 2011 00:52:03 +1100 Subject: ProgressBar - Python and Powershell In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> Message-ID: Why are you writing an installer in Python and Powershell? Just write an installer in WiX, NSIS or Inno like the rest of the sane world. Alternatively take a look at MakeMSI or the script python uses to generate there .MSI. Anything else is WAY too non-standard to consider. On Mon, Nov 21, 2011 at 12:01 AM, wrote: > Can anyone throw some light on this please ! ? > > > > > > From: python-list-bounces+nikunj.badjatya=emc.com at python.org > [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of > Nikunj.Badjatya at emc.com > Sent: Thursday, November 17, 2011 4:10 PM > To: python-list at python.org > Subject: ProgressBar - Python and Powershell > > > > Hi All, > > > > I am using Python 2.7, windows Env. > > I have an Installer written in Python(45%) and Powershell(55%) which is used > to install Virtual Machines at specific locations. It is single threaded. > > I am trying to implement a ProgressBar ?for this installer. So that the user > will come to know the progress of the installation. > > I am using pypi progressbar module. > > The top script is in python which inturns calls powershell scripts using > subprocess.call() and proceeds with the installation. > > > > I am taking a shared file between python and powershell, so that diff > functions can update their %age completion level in to the file. Ex. Func1() > updates it to 5%,? func2() will add its own 5% to it.. and so on. > > At the start of the (main.py) script I am creating a thread whose sole > purpose would be to keep ?READ? a temp file for a new entry in it. > > Based on this entry I can have my thread update the progressbar on the > console. > > > > My questions are: > > 1.?????? Can I have a better shared mechanism between python and > powershell.? ?As I am using a file here. Reading + writing in python and > writing only in powershell. ?! > > 2.?????? Does this thread mechanism work.? I am yet to implement and test > it.! :P What can be the possible shortfalls.? > > > > > Thanks > > > > Nikunj > > Bangalore - India > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From lists at cheimes.de Sun Nov 20 09:17:34 2011 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Nov 2011 15:17:34 +0100 Subject: Announcing Mii (My) Chat In-Reply-To: References: Message-ID: Am 20.11.2011 06:04, schrieb Andrew Evans: > Hello I wish to inform the list of a Python Application I am writing > entitled Mii Chat. Your choice of name is most likely to cause trouble. Nintendo has a trademark on "Mii" as part of the Wii console trademark. In Nintendo's glossary a Mii is a player's avatar. Christian From milleja46 at gmail.com Sun Nov 20 09:32:22 2011 From: milleja46 at gmail.com (Joshua Miller) Date: Sun, 20 Nov 2011 09:32:22 -0500 Subject: Announcing Mii (My) Chat In-Reply-To: References: Message-ID: I have to agree with christian.... Mii is those avatars in the nintendo wii system....I highly recommend you change the name it might be a good idea for software but the name will most likely get you in trouble On Sun, Nov 20, 2011 at 9:17 AM, Christian Heimes wrote: > Am 20.11.2011 06:04, schrieb Andrew Evans: >> Hello I wish to inform the list of a Python Application I am writing >> entitled Mii Chat. > > Your choice of name is most likely to cause trouble. Nintendo has a > trademark on "Mii" as part of the Wii console trademark. In Nintendo's > glossary a Mii is a player's avatar. > > Christian > > -- > http://mail.python.org/mailman/listinfo/python-list > From stefan_ml at behnel.de Sun Nov 20 10:03:24 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 20 Nov 2011 16:03:24 +0100 Subject: xml.dom.minidom question In-Reply-To: References: Message-ID: nivashno, 19.11.2011 22:32: > I've got this code: > > >>> dom = xml.dom.minidom.parse('myfile.xml') > >>> for testnode in dom.getElementsByTagName('tests')[0].childNodes: > ... print testnode > > When it's working on this xml: > > > something > > > I get the following: > > > > > > But when it's working on this xml: > > something > > I get this: > > > > > I always thought that xml was very precisely split up into nodes, > childnodes, etc, no matter what the whitespace between them was. But > apparently not, or am I missing something? You already got some answers to this question. I'd just like to point you to the xml.etree.(c)ElementTree packages, which are substantially faster and easier to use than minidom. Stefan From gelonida at gmail.com Sun Nov 20 10:15:05 2011 From: gelonida at gmail.com (Gelonida N) Date: Sun, 20 Nov 2011 16:15:05 +0100 Subject: Is there any way to unimport a library Message-ID: I wondered whether there is any way to un-import a library, such, that it's occupied memory and the related shared libraries are released. My usecase is following: success = False try: import lib1_version1 as lib1 import lib2_version1 as lib2 success = True except ImportError: pass if not success: try: import lib1_version2 as lib1 import lib2_version2 as lib2 success = True except importError: pass if not success: . . . Basically if I am not amble to import lib1_version1 AND lib2_version1, then I wanted to make sure, that lib1_version1 does not waste any memory At this moment this is more a thought excercise than a real issue, but I thought that perhaps somebody encountered this kind of issue and had an idea how to deal with such situations. One solution, that I could imagine is running the program a first time, detect all existing libraries and write out a config file being use the next time it is run, such, that immediately the right libs are imported. From renesd at gmail.com Sun Nov 20 10:25:07 2011 From: renesd at gmail.com (illume) Date: Sun, 20 Nov 2011 07:25:07 -0800 (PST) Subject: PyGameZine launched. See http://pygame.org for details. Message-ID: <16451527.473.1321802707273.JavaMail.geo-discussion-forums@yqan20> Hey ya, today we launched the first issue of PyGameZine. For more info, please see the pygame website: http://www.pygame.org/ cheers! From miki.tebeka at gmail.com Sun Nov 20 10:39:36 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Sun, 20 Nov 2011 07:39:36 -0800 (PST) Subject: Is there any way to unimport a library In-Reply-To: References: Message-ID: <31034729.395.1321803576950.JavaMail.geo-discussion-forums@prlm15> del sys.modules['my-module'] However if your module imported other modules, they'll still be there. If there are references to objects your module created, they'll still be there. A better option IMO is to use imp.find_module and then import. From miki.tebeka at gmail.com Sun Nov 20 10:39:36 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Sun, 20 Nov 2011 07:39:36 -0800 (PST) Subject: Is there any way to unimport a library In-Reply-To: References: Message-ID: <31034729.395.1321803576950.JavaMail.geo-discussion-forums@prlm15> del sys.modules['my-module'] However if your module imported other modules, they'll still be there. If there are references to objects your module created, they'll still be there. A better option IMO is to use imp.find_module and then import. From steve+comp.lang.python at pearwood.info Sun Nov 20 10:46:44 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 20 Nov 2011 15:46:44 GMT Subject: Is there any way to unimport a library References: Message-ID: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> On Sun, 20 Nov 2011 16:15:05 +0100, Gelonida N wrote: > I wondered whether there is any way to un-import a library, such, that > it's occupied memory and the related shared libraries are released. Not really. Python modules are objects, like everything else in Python, and can only be deleted when the garbage collector is certain that nothing else is keeping a reference to it. So long as any object, anywhere, no matter how deep in your code or in third-party code, has a reference to the module, you can't force it to be deleted. You can remove it from your application's namespace: import math result = math.sin(1.2345) del math This, however, is not sufficient to free the module, as it is cached. You can (but shouldn't!) do this as well: import sys del sys.modules['math'] But please don't delete modules from the cache unless (1) you really need to, and (2) you are prepared for the consequences. "Just in case the library uses too much memory" is not a good reason for deleting the module. The problem is, if you delete the module from the cache, but some other part of your application still holds onto a reference to the module (directly, or indirectly), the next time you import the library, Python will not use the cached version but will create a second, independent copy of the module in memory. Instead of saving memory, you have just DOUBLED the amount of memory used by the library. You may also run into bizarre, hard to debug problems due to breaking the "modules are singletons" promise. Trust me, this opens the door to a world of pain. > success = False > try: > import lib1_version1 as lib1 > import lib2_version1 as lib2 > success = True > except ImportError: > pass > if not success: > try: > import lib1_version2 as lib1 > import lib2_version2 as lib2 > success = True > except importError: > pass Can you mix lib1_version1 and lib2_version2? If so, the best way of doing this would be: try: import lib1_version1 as lib1 except ImportError: try: import lib1_version2 as lib1 except ImportError: # Last chance. If this fails, it is a fatal error. import lib1_version3 as lib1 And then do the same for lib2. > One solution, that I could imagine is running the program a first time, > detect all existing libraries and write out a config file being use the > next time it is run, such, that immediately the right libs are imported. What if the libs change between one run of your program and the next? -- Steven From gelonida at gmail.com Sun Nov 20 11:39:28 2011 From: gelonida at gmail.com (Gelonida N) Date: Sun, 20 Nov 2011 17:39:28 +0100 Subject: Is there any way to unimport a library In-Reply-To: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven, Mika, Thanks for your answers. It's always good to know which options exist. It makes it easier to choose the right one depending on the situation. On 11/20/2011 04:46 PM, Steven D'Aprano wrote: > On Sun, 20 Nov 2011 16:15:05 +0100, Gelonida N wrote: > >> I wondered whether there is any way to un-import a library, such, that >> it's occupied memory and the related shared libraries are released. > > > You can remove it from your application's namespace: > > import math > result = math.sin(1.2345) > del math > > > This, however, is not sufficient to free the module, as it is cached. You > can (but shouldn't!) do this as well: > > import sys > del sys.modules['math'] > > > The problem is, if you delete the module from the cache, but some other > part of your application still holds onto a reference to the module > (directly, or indirectly), the next time you import the library, Python > will not use the cached version but will create a second, independent > copy of the module in memory. Instead of saving memory, you have just > DOUBLED the amount of memory used by the library. You may also run into > bizarre, hard to debug problems due to breaking the "modules are > singletons" promise. > in my case only one module (the one with the try import statements) would import these libraries. >> success = False >> try: >> import lib1_version1 as lib1 >> import lib2_version1 as lib2 >> success = True >> except ImportError: >> pass >> if not success: >> try: >> import lib1_version2 as lib1 >> import lib2_version2 as lib2 >> success = True >> except importError: >> pass > > > Can you mix lib1_version1 and lib2_version2? If so, the best way of doing > this would be: > > try: > import lib1_version1 as lib1 > except ImportError: > try: > import lib1_version2 as lib1 > except ImportError: > # Last chance. If this fails, it is a fatal error. > import lib1_version3 as lib1 > No mixing would not be possible. So either I need the first two libs or the second two. > >> One solution, that I could imagine is running the program a first time, >> detect all existing libraries and write out a config file being use the >> next time it is run, such, that immediately the right libs are imported. > > What if the libs change between one run of your program and the next? > Well that's why wondered whether there is a dynamic solution. However if I'd like to force a rescan I could always just delete the config file. I think I'll look at imp.find_module as Miki suggested. In my case it should probably be enough to know whether a group of modules exist. Theoretically a module could exist, but fail to import but if in this rare situations one of the libraries stays in memory it wouldn't be the biggest issue. I'd just like to avoid that (this is not my use case, but just a (crazy) example) TKInter, wxWidgets, and pyQt were all loaded even if due I'd use only one of them due to the lack of other packages From shilparani9030 at gmail.com Sun Nov 20 11:40:47 2011 From: shilparani9030 at gmail.com (SHILPA) Date: Sun, 20 Nov 2011 08:40:47 -0800 (PST) Subject: XXX HOT PHOTOS&VIDEOS Message-ID: <53016838-1333-45fd-a347-a37220fba937@s35g2000pra.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From shilparani9030 at gmail.com Sun Nov 20 11:40:50 2011 From: shilparani9030 at gmail.com (SHILPA) Date: Sun, 20 Nov 2011 08:40:50 -0800 (PST) Subject: XXX HOT PHOTOS&VIDEOS Message-ID: <6449927a-d143-463d-b34e-5796b419879e@c16g2000pre.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From Nikunj.Badjatya at emc.com Sun Nov 20 11:40:58 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Sun, 20 Nov 2011 11:40:58 -0500 Subject: ProgressBar - Python and Powershell In-Reply-To: References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> Thanks for reply. Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am using Python. I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? The current look of the installer is completely command line based. -----Original Message----- From: Alec Taylor [mailto:alec.taylor6 at gmail.com] Sent: Sunday, November 20, 2011 7:22 PM To: Badjatya, Nikunj Cc: python-list at python.org Subject: Re: ProgressBar - Python and Powershell Why are you writing an installer in Python and Powershell? Just write an installer in WiX, NSIS or Inno like the rest of the sane world. Alternatively take a look at MakeMSI or the script python uses to generate there .MSI. Anything else is WAY too non-standard to consider. On Mon, Nov 21, 2011 at 12:01 AM, wrote: > Can anyone throw some light on this please ! ? > > > > > > From: python-list-bounces+nikunj.badjatya=emc.com at python.org > [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of > Nikunj.Badjatya at emc.com > Sent: Thursday, November 17, 2011 4:10 PM > To: python-list at python.org > Subject: ProgressBar - Python and Powershell > > > > Hi All, > > > > I am using Python 2.7, windows Env. > > I have an Installer written in Python(45%) and Powershell(55%) which is used > to install Virtual Machines at specific locations. It is single threaded. > > I am trying to implement a ProgressBar ?for this installer. So that the user > will come to know the progress of the installation. > > I am using pypi progressbar module. > > The top script is in python which inturns calls powershell scripts using > subprocess.call() and proceeds with the installation. > > > > I am taking a shared file between python and powershell, so that diff > functions can update their %age completion level in to the file. Ex. Func1() > updates it to 5%,? func2() will add its own 5% to it.. and so on. > > At the start of the (main.py) script I am creating a thread whose sole > purpose would be to keep "READ" a temp file for a new entry in it. > > Based on this entry I can have my thread update the progressbar on the > console. > > > > My questions are: > > 1.?????? Can I have a better shared mechanism between python and > powershell.? ?As I am using a file here. Reading + writing in python and > writing only in powershell. ?! > > 2.?????? Does this thread mechanism work.? I am yet to implement and test > it.! :P What can be the possible shortfalls.? > > > > > Thanks > > > > Nikunj > > Bangalore - India > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Sun Nov 20 11:53:06 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Nov 2011 03:53:06 +1100 Subject: Is there any way to unimport a library In-Reply-To: References: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Nov 21, 2011 at 3:39 AM, Gelonida N wrote: > No mixing would not be possible. > > So either I need the first two libs or the second two. > I wonder, can you make the first one import the second one? That automatically defines your dependency right there, and may make things clearer - you import lib1_version1, and if that fails, you import lib1_version2; if either succeeds, you know the matching lib2 is available. ChrisA From gelonida at gmail.com Sun Nov 20 12:21:00 2011 From: gelonida at gmail.com (Gelonida N) Date: Sun, 20 Nov 2011 18:21:00 +0100 Subject: Is there any way to unimport a library In-Reply-To: References: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: I forgot to mention, that this is at the moment more a thought experiment, than a real need. On 11/20/2011 05:53 PM, Chris Angelico wrote: > On Mon, Nov 21, 2011 at 3:39 AM, Gelonida N wrote: >> No mixing would not be possible. >> >> So either I need the first two libs or the second two. >> > > I wonder, can you make the first one import the second one? That > automatically defines your dependency right there, and may make things > clearer - you import lib1_version1, and if that fails, you import > lib1_version2; if either succeeds, you know the matching lib2 is > available. > At the moment I will do exactly what you suggested. I will make sure, that always the first import fails. But I wanted to learn more what is possible and which potential can of worms I would open if I wanted to unimport a library of which I'm sure that nobody is currently referencing (or refering? Not sure about my English here) to. From jabba.laci at gmail.com Sun Nov 20 13:06:44 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Sun, 20 Nov 2011 19:06:44 +0100 Subject: scraping a tumblr.com archive page Message-ID: Hi, I want to extract the URLs of all the posts on a tumblr blog. Let's take for instance this blog: http://loveyourchaos.tumblr.com/archive . If I download this page with a script, there are only 50 posts in the HTML. If you scroll down in your browser to the end of the archive, the browser will dynamically load newer and newer posts. How to scrape such a dynamic page? Thanks, Laszlo From benjamin.kaplan at case.edu Sun Nov 20 13:18:21 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Sun, 20 Nov 2011 13:18:21 -0500 Subject: scraping a tumblr.com archive page In-Reply-To: References: Message-ID: On Sun, Nov 20, 2011 at 1:06 PM, Jabba Laci wrote: > Hi, > > I want to extract the URLs of all the posts on a tumblr blog. Let's > take for instance this blog: http://loveyourchaos.tumblr.com/archive . > If I download this page with a script, there are only 50 posts in the > HTML. If you scroll down in your browser to the end of the archive, > the browser will dynamically load newer and newer posts. > > How to scrape such a dynamic page? > > Thanks, > > Laszlo > -- The page isn't really that dynamic- HTTP doesn't allow for that. Scrolling down the page triggers some Javascript. That Javascript sends some HTTP requests to the server, which returns more HTML, which gets stuck into the middle of the page. If you take the time to monitor your network traffic using a tool like Firebug, you should be able to figure out the pattern in the requests for more content. Just send those same requests yourself and parse the results. From andrew.chapkowski at gmail.com Sun Nov 20 15:02:11 2011 From: andrew.chapkowski at gmail.com (Andrew) Date: Sun, 20 Nov 2011 12:02:11 -0800 (PST) Subject: Server Questions (2 of them) Message-ID: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Hello List, How to do you create a server that accepts a set of user code? For example, I would like to send this function: def addition(x,y): return x+y and have the socket server perform the operation and send is back to the end user. Question 2: On that same server, I want a user to be able to pass a file to the server along with code. What is the best way to pass file to the server? Thank you for any suggestions or resources you can provide. Andrew From spartan.the at gmail.com Sun Nov 20 15:44:26 2011 From: spartan.the at gmail.com (spartan.the) Date: Sun, 20 Nov 2011 12:44:26 -0800 (PST) Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: On Nov 18, 3:36?am, Roy Smith wrote: ... > It just seems mind-boggling to me that PYTHONPATH doesn't preempt > everything else. I was surprised too, but this issue is widespread. Best explained here: https://bugs.launchpad.net/tahoe-lafs/+bug/821000/comments/0 Quote: " The crux of the problem is that the Python documentation says: "The PYTHONPATH variable can be set to a list of paths that will be added to the beginning of sys.path." http://docs.python.org/install/index.html#modifying-python-s-search-path This is true with standard distutils, false with setuptools, false with distribute... " Phillip J. Eby (setuptools guy) was religious about "easy installed" packages over anything else to comment on this issue 3 years ago: " This behavior change is unacceptable, as it makes it impossible to ensure that an easy_install-ed package takes precedence over an existing, distutils-installed version of the same package in the same PYTHONPATH directory. Please note that that is the intended default behavior of easy_install: if you wish to override it, you should use --multi-version, and explicitly select the egg(s) to be added to sys.path instead. " (http://bugs.python.org/setuptools/issue53) From sorsorday at gmail.com Sun Nov 20 16:16:26 2011 From: sorsorday at gmail.com (Herman) Date: Sun, 20 Nov 2011 13:16:26 -0800 Subject: What is the difference between "new Class()" and "Class()"? Message-ID: What is so special about the "new" operator? From rosuav at gmail.com Sun Nov 20 16:34:28 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Nov 2011 08:34:28 +1100 Subject: Server Questions (2 of them) In-Reply-To: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Message-ID: On Mon, Nov 21, 2011 at 7:02 AM, Andrew wrote: > Hello List, > > How to do you create a server that accepts a set of user code? > > For example, > > I would like to send this function: > def addition(x,y): > ? return x+y > and have the socket server perform the operation and send is back to > the end user. > > Question 2: > On that same server, I want a user to be able to pass a file to the > server along with code. ?What is the best way to pass file to the > server? The easiest way is to write an HTTP server (Python has some tools that will make this easy) and use an HTML form, which can do file uploads as well as accept keyed-in code. However, you will run into some fairly major security issues. You're accepting code across the internet and running it. Python does not protect you against malicious users reading files from your hard disk or, worse, modifying those files. This sort of thing can ONLY be used in a trusted environment - a local network on which you know everything that's happening. ChrisA From tjreedy at udel.edu Sun Nov 20 16:41:02 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Nov 2011 16:41:02 -0500 Subject: What is the difference between "new Class()" and "Class()"? In-Reply-To: References: Message-ID: On 11/20/2011 4:16 PM, Herman wrote: > What is so special about the "new" operator? There is no 'new' operator in Python. Perhaps you are thinking of javascript or maybe jave or ...? -- Terry Jan Reedy From hniksic at xemacs.org Sun Nov 20 16:44:25 2011 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Sun, 20 Nov 2011 22:44:25 +0100 Subject: Server Questions (2 of them) References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Message-ID: <8762iesc3q.fsf@xemacs.org> Andrew writes: > How to do you create a server that accepts a set of user code? [...] Look up the "exec" statement, the server can use it to execute any code received from the client as a string. Note "any code", though; exec runs in no sandbox and if a malicious client defines addition(1, 2) to execute os.system('sudo rm -rf /'), the server will happily do just that. From ben+python at benfinney.id.au Sun Nov 20 18:40:33 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 21 Nov 2011 10:40:33 +1100 Subject: What is the difference between "new Class()" and "Class()"? References: Message-ID: <87lira747i.fsf@benfinney.id.au> Herman writes: > What is so special about the "new" operator? It's special because Python doesn't have it. Can you refer us with a URL to the place where you've seen Python code containing a ?new? operator? -- \ ?Fear him, which after he hath killed hath power to cast into | `\ hell; yea, I say unto you, Fear him.? ?Jesus, as quoted in Luke | _o__) 12:5 | Ben Finney From ralf at systemexit.de Sun Nov 20 19:16:05 2011 From: ralf at systemexit.de (Ralf Schmitt) Date: Mon, 21 Nov 2011 01:16:05 +0100 Subject: [ANNOUNCE] pypiserver 0.4.0 - minimal pypi server Message-ID: <87ehx2ba9m.fsf@myhost.localnet> Hi, I've just uploaded pypiserver 0.4.0 to the python package index. pypiserver is a minimal PyPI compatible server. It can be used to serve a set of packages and eggs to easy_install or pip. pypiserver is easy to install (i.e. just easy_install pypiserver). It doesn't have any external dependencies. http://pypi.python.org/pypi/pypiserver/ should contain enough information to easily get you started running your own PyPI server in a few minutes. The code is available on github: https://github.com/schmir/pypiserver Changes in version 0.4.0 ------------------------- - add functionality to manage package updates - updated documentation - python 3 support has been added -- Cheers, Ralf From lists at cheimes.de Sun Nov 20 19:27:59 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 21 Nov 2011 01:27:59 +0100 Subject: Server Questions (2 of them) In-Reply-To: <8762iesc3q.fsf@xemacs.org> References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> <8762iesc3q.fsf@xemacs.org> Message-ID: Am 20.11.2011 22:44, schrieb Hrvoje Niksic: > Andrew writes: > >> How to do you create a server that accepts a set of user code? > [...] > > Look up the "exec" statement, the server can use it to execute any code > received from the client as a string. > > Note "any code", though; exec runs in no sandbox and if a malicious > client defines addition(1, 2) to execute os.system('sudo rm -rf /'), the > server will happily do just that. It's possible to sandbox Python code, see http://docs.python.org/library/rexec.html, http://code.activestate.com/recipes/496746-restricted-safe-eval/ or TTW code (through the web) in Zope. However the sandboxing is limited and you really need to know what you are doing. From jehugaleahsa at gmail.com Sun Nov 20 19:46:14 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sun, 20 Nov 2011 16:46:14 -0800 (PST) Subject: Using the Python Interpreter as a Reference Message-ID: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Hello: I am currently working on designing a new programming language. It is a compiled language, but I still want to use Python as a reference. Python has a lot of similarities to my language, such as indentation for code blocks, lambdas, non-locals and my language will partially support dynamic programming. Can anyone list a good introduction to the files found in the source code? I have been poking around the source code for a little bit and there is a lot there. So, I was hoping someone could point me to the "good parts". I am also wondering whether some of the code was generated because I see state transition tables, which I doubt someone built by hand. Any help would be greatly appreciated. It will be cool to see how the interpreter works internally. I am still wonder whether designing the language (going on 4 months now) will be harder than implementing it. Thanks, Travis Parks From alan.gauld at btinternet.com Sun Nov 20 20:28:14 2011 From: alan.gauld at btinternet.com (Alan Gauld) Date: Mon, 21 Nov 2011 01:28:14 +0000 Subject: What is the difference between "new Class()" and "Class()"? In-Reply-To: References: Message-ID: On 20/11/11 21:16, Herman wrote: > What is so special about the "new" operator? Assuming you mean the __new__() method? __new__() gets called when the class is being constructed, it returns the new instance. It is the real Pyhon constructor. As opposed to __init__() which is called after the instance has been created. It is not really a constructor but an initializer. (Even though most of us treat it as a constructor!) But you should never see code like meat = new Spam(). it should be meat = Spam() Which calls __new__() followed by __init__(). HTH -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ From jabba.laci at gmail.com Sun Nov 20 21:09:46 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Mon, 21 Nov 2011 03:09:46 +0100 Subject: scraping a tumblr.com archive page In-Reply-To: References: Message-ID: Hi, Thanks for the answer. Finally I found an API for this task: http://www.tumblr.com/docs/en/api/v2#posts . It returns the required data in JSON format. Laszlo > The page isn't really that dynamic- HTTP doesn't allow for that. > Scrolling down the page triggers some Javascript. That Javascript > sends some HTTP requests to the server, which returns more HTML, which > gets stuck into the middle of the page. If you take the time to > monitor your network traffic using a tool like Firebug, you should be > able to figure out the pattern in the requests for more content. Just > send those same requests yourself and parse the results. From loluengo at gmail.com Sun Nov 20 21:16:58 2011 From: loluengo at gmail.com (Lorenzo) Date: Sun, 20 Nov 2011 18:16:58 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <90f6dc69-1b8a-49d7-aa00-662c6baefda5@n14g2000vbn.googlegroups.com> On Nov 15, 11:51?pm, Carl Banks wrote: > Some people have already made an LLVM-to-Javascript compiler, and have managed to build Python 2.7 with it. > > The LLVM-to-Javascript project is called emscripten. > > https://github.com/kripken/emscripten/wiki > > Demo of Python (and a bunch of other languages) here: > > http://repl.it/ > > Carl Banks It definitely looks great!! From rosuav at gmail.com Sun Nov 20 21:33:21 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Nov 2011 13:33:21 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: On Mon, Nov 21, 2011 at 11:46 AM, Travis Parks wrote: > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. If you want to use Python as a reference for designing your language, look at the documentation. It's pretty decent on the subject of language specs (you may find yourself reading a lot of PEPs as well as the "normal" docs). But for actual code - you may want to look at Cython. I've never used it, but it compiles Python code to C (IIRC); that's more likely to be what you're after. What's your language's "special feature"? I like to keep track of languages using a "slug" - a simple one-sentence (or less) statement of when it's right to use this language above others. For example, Python is optimized for 'rapid deployment'. ChrisA From drsalists at gmail.com Sun Nov 20 21:55:21 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 20 Nov 2011 18:55:21 -0800 Subject: Using the Python Interpreter as a Reference In-Reply-To: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: On Sun, Nov 20, 2011 at 4:46 PM, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. > FWIW, comprehensions are often nicer than lambdas. You might want to check out PyPy. It's written in a more flexible implementation language than CPython, and facilitates writing languages - IOW, PyPy is more than just Python written in Python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wuwei23 at gmail.com Sun Nov 20 23:26:30 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 20 Nov 2011 20:26:30 -0800 (PST) Subject: Server Questions (2 of them) References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> <8762iesc3q.fsf@xemacs.org> Message-ID: <4e7f81b4-f394-40fa-91ff-fcc6a27d9a1c@k5g2000pre.googlegroups.com> On Nov 21, 10:27?am, Christian Heimes wrote: > It's possible to sandbox Python code, see > http://docs.python.org/library/rexec.html Although this has been deprecated since 2.6 & removed from 3.x (and cautioned against for as long as I've used Python). PyPy provides some sandboxing functionality that might be useful here: http://codespeak.net/pypy/dist/pypy/doc/sandbox.html From wuwei23 at gmail.com Sun Nov 20 23:58:33 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 20 Nov 2011 20:58:33 -0800 (PST) Subject: Is there any way to unimport a library References: Message-ID: <81b06056-9928-4871-8452-feb681bbc0d0@a3g2000prd.googlegroups.com> On Nov 21, 1:15?am, Gelonida N wrote: > I wondered whether there is any way to un-import a library, such, that > it's occupied ?memory and the related shared libraries are released. > > My usecase is following: > > success = False > try: > ? ? import lib1_version1 as lib1 > ? ? import lib2_version1 as lib2 > ? ? success = True > except ImportError: > ? ? pass > if not success: > ? ? try: > ? ? ? ? import lib1_version2 as lib1 > ? ? ? ? import lib2_version2 as lib2 > ? ? ? ? success = True > ? ? except importError: > ? ? ? ? pass > if not success: > ? ? . . . > > Basically if I am not amble to import lib1_version1 AND lib2_version1, > then I wanted to make sure, that lib1_version1 does not waste any memory A simple way would be to create packages for each version that import the two dependencies: /version1/__init__.py: import lib1_version1 as lib1 import lib2_version2 as lib2 /version2/__init__.py: import lib1_version2 as lib1 import lib2_version2 as lib2 Then create a single module to handle the importing: /libraries.py: __all__ = ['lib1', 'lib2', 'version'] version = None _import_errs = [] try: from version1 import lib1, lib2 version = 1 except ImportError as (err,): _import_errs.append(err) if version is None: try: from version2 import lib1, lib2 version = 2 except ImportError as (err,): _import_errs.append(err) if version is None: _format_errs = (('v%d: %s' % (ver, err)) for ver, err in enumerate(_import_errs, 1)) raise ImportError('Unable to import libraries: %s' % list(_format_errs)) From wuwei23 at gmail.com Mon Nov 21 00:04:50 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 20 Nov 2011 21:04:50 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <0296a730-c952-4f14-99ca-a63a9fe96096@k5g2000pre.googlegroups.com> On Nov 19, 3:59?am, "W. eWatson" wrote: > Yes. I tried running it. Got nowhere. Did you run it from the shell? Did it spit out any errors? From wuwei23 at gmail.com Mon Nov 21 00:09:24 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 20 Nov 2011 21:09:24 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <70f026ae-9a6d-42de-880d-c1e430275e7c@13g2000prw.googlegroups.com> On Nov 19, 8:31?am, Stephen Hansen wrote: > Yes, its moderately annoying that you have to do this yourself; maybe > you wouldn't if you installed 64-bit python, but I can't be sure. Maybe > it has nothing to do with 32 or 64-bitness at all and my guess is wrong. I've got the 32 bit version of 2.7 & the 64 bit of 3.2 installed under Windows 7. I'm not seeing 'Edit with IDLE' options, instead I get 'Edit with Pythonwin' from the 32bit installation. I'm also using ActivePython, though. I can honestly say I've never had an issue under Windows with it. From steve+comp.lang.python at pearwood.info Mon Nov 21 00:44:56 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Nov 2011 05:44:56 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <4ec9e558$0$29997$c3e8da3$5496439d@news.astraweb.com> On Mon, 21 Nov 2011 13:33:21 +1100, Chris Angelico wrote: > What's your language's "special feature"? I like to keep track of > languages using a "slug" - a simple one-sentence (or less) statement of > when it's right to use this language above others. For example, Python > is optimized for 'rapid deployment'. "Python will save the world" http://proyectojuanchacon.blogspot.com/2010/07/saving-world-with-python.html -- Steven From zyzhu2000 at gmail.com Mon Nov 21 00:46:35 2011 From: zyzhu2000 at gmail.com (GZ) Date: Sun, 20 Nov 2011 21:46:35 -0800 (PST) Subject: Close as Many Files/External resourcs as possible in the face of exceptions Message-ID: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> Hi, Here is my situation. A parent object owns a list of files (or other objects with a close() method). The close() method can sometimes fail and raise an exception. When the parent object's close() method is called, it needs to close down as many files it owns as possible, even if the close() function of some files fail. I also want to re-raise at least one of the original exceptions so that the outer program can handle it. What I come up is something like this, suppose L is a list that holds all the file objects. is_closed = set() try: for f in L: f.close() is_closed.add(f) except: try: raise #re-raise immediately, keeping context intact finally: for f in L: # close the rest of the file objects if f not in is_closed: try: f.close() except: pass It will re-raise the first exception and preserve the context and close as many other files as possible while ignoring any further exceptions. But this looks really awkward. And in the case that two files fail to close, I am not sure the best strategy is to ignore the second failure. What is a better way of handling such situation? Thanks, gz From nizamov.shawkat at gmail.com Mon Nov 21 01:28:03 2011 From: nizamov.shawkat at gmail.com (Nizamov Shawkat) Date: Mon, 21 Nov 2011 07:28:03 +0100 Subject: Server Questions (2 of them) In-Reply-To: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Message-ID: 2011/11/20 Andrew : > Hello List, > > How to do you create a server that accepts a set of user code? > > For example, > > I would like to send this function: > def addition(x,y): > ? return x+y > and have the socket server perform the operation and send is back to > the end user. > > Question 2: > On that same server, I want a user to be able to pass a file to the > server along with code. ?What is the best way to pass file to the > server? > > > Thank you for any suggestions or resources you can provide. > > Andrew > -- > http://mail.python.org/mailman/listinfo/python-list > Check for Pyro - it allows creation of objects on client side while running them on server side. Pyro makes this process almost transparent using proxy objects. Hope it helps, S.Nizamov From alec.taylor6 at gmail.com Mon Nov 21 01:28:55 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 21 Nov 2011 17:28:55 +1100 Subject: ProgressBar - Python and Powershell In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> Message-ID: So you're executing Powershell commands into Virtual Machines? Add this into the installer (probably WiX is your best bet) On Mon, Nov 21, 2011 at 3:40 AM, wrote: > Thanks for reply. > Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). > Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am ?using Python. > > I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? > > The current look of the installer is completely command line based. > > > -----Original Message----- > From: Alec Taylor [mailto:alec.taylor6 at gmail.com] > Sent: Sunday, November 20, 2011 7:22 PM > To: Badjatya, Nikunj > Cc: python-list at python.org > Subject: Re: ProgressBar - Python and Powershell > > Why are you writing an installer in Python and Powershell? > > Just write an installer in WiX, NSIS or Inno like the rest of the sane world. > > Alternatively take a look at MakeMSI or the script python uses to > generate there .MSI. > > Anything else is WAY too non-standard to consider. > > On Mon, Nov 21, 2011 at 12:01 AM, ? wrote: >> Can anyone throw some light on this please ! ? >> >> >> >> >> >> From: python-list-bounces+nikunj.badjatya=emc.com at python.org >> [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of >> Nikunj.Badjatya at emc.com >> Sent: Thursday, November 17, 2011 4:10 PM >> To: python-list at python.org >> Subject: ProgressBar - Python and Powershell >> >> >> >> Hi All, >> >> >> >> I am using Python 2.7, windows Env. >> >> I have an Installer written in Python(45%) and Powershell(55%) which is used >> to install Virtual Machines at specific locations. It is single threaded. >> >> I am trying to implement a ProgressBar ?for this installer. So that the user >> will come to know the progress of the installation. >> >> I am using pypi progressbar module. >> >> The top script is in python which inturns calls powershell scripts using >> subprocess.call() and proceeds with the installation. >> >> >> >> I am taking a shared file between python and powershell, so that diff >> functions can update their %age completion level in to the file. Ex. Func1() >> updates it to 5%,? func2() will add its own 5% to it.. and so on. >> >> At the start of the (main.py) script I am creating a thread whose sole >> purpose would be to keep "READ" a temp file for a new entry in it. >> >> Based on this entry I can have my thread update the progressbar on the >> console. >> >> >> >> My questions are: >> >> 1.?????? Can I have a better shared mechanism between python and >> powershell.? ?As I am using a file here. Reading + writing in python and >> writing only in powershell. ?! >> >> 2.?????? Does this thread mechanism work.? I am yet to implement and test >> it.! :P What can be the possible shortfalls.? >> >> >> >> >> Thanks >> >> >> >> Nikunj >> >> Bangalore - India >> >> >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > From rosuav at gmail.com Mon Nov 21 01:48:45 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Nov 2011 17:48:45 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ec9e558$0$29997$c3e8da3$5496439d@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4ec9e558$0$29997$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Nov 21, 2011 at 4:44 PM, Steven D'Aprano wrote: > On Mon, 21 Nov 2011 13:33:21 +1100, Chris Angelico wrote: > >> What's your language's "special feature"? I like to keep track of >> languages using a "slug" - a simple one-sentence (or less) statement of >> when it's right to use this language above others. For example, Python >> is optimized for 'rapid deployment'. > > "Python will save the world" > > http://proyectojuanchacon.blogspot.com/2010/07/saving-world-with-python.html I don't think Python has a hard disk big enough to save all of it... ChrisA From john.37 at gmail.com Mon Nov 21 02:15:21 2011 From: john.37 at gmail.com (sword) Date: Sun, 20 Nov 2011 23:15:21 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> <4f5fd473-4717-4f41-8017-d7407adc4571@u10g2000prl.googlegroups.com> <5dfa9add-582f-4219-8d78-01239f80525e@p5g2000vbm.googlegroups.com> Message-ID: <066c8586-dd11-4982-ab3a-5ff77db46b90@a3g2000prd.googlegroups.com> On Nov 20, 8:42?am, Vinay Sajip wrote: > On Nov 17, 9:06?am, sword wrote: > > > > > > > > > > > On Nov 16, 10:50?pm, Peter Otten <__pete... at web.de> wrote: > > > > sword wrote: > > > > Thanks for your reply. I tried to edit the source a bit, now the > > > > main.py looks like this: > > > > #main.py > > > > importlogging > > > > fromloggingimport Filter > > > > import a > > > > import b > > > > >logging.basicConfig(level=logging.DEBUG) > > > > root =logging.getLogger() > > > > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > > > > would pass this filter > > > > > logger =logging.getLogger("main") > > > > logger.debug("main process") > > > > a.print_log() > > > > b.print_log() > > > > > #### > > > > And It still prints out all the log msg. :( > > > > Here's a little demo to explore how filtering works: > > > > $ cat demo.py > > > importlogging > > > class Filter(logging.Filter): > > > ? ? def filter(self, record): > > > ? ? ? ? print "applying filter", self.name > > > ? ? ? ? return True > > > >logging.basicConfig() > > > > loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]] > > > for logger in loggers: > > > ? ? logger.addFilter(Filter("filter@" + logger.name)) > > > > [handler] =logging.getLogger().handlers > > > handler.addFilter(Filter("filter at handler")) > > > > for logger in loggers: > > > ? ? logger.critical("whatever") > > > $ python demo.py > > > applying filter filter at root > > > applying filter filter at handler > > > CRITICAL:root:whatever > > > applying filter filter at a > > > applying filter filter at handler > > > CRITICAL:a:whatever > > > applying filter fil... at a.b > > > applying filter filter at handler > > > CRITICAL:a.b:whatever > > > $ > > > > As you can infer from the output only the filter(s) of the original logger > > > and of the handler(s) are applied. > > > Thanks, so if I want to see my own log out of all logs produced by > > different module in the project, I should addFilter to each > > corresponding logger. I thought I could add Filter in root and filter > > out only the interested info from it before. > > Or you can add a filter to the handler (but then you can't use > basicConfig() to configure it - you need to do it explicitly). > > Regards, > > Vinay Sajip Thank you! Maybe I should find out another way to manipulate the log, like wrap the getLogger function and add the filter at the first time :) From ysh1989 at gmail.com Mon Nov 21 02:32:29 2011 From: ysh1989 at gmail.com (=?UTF-8?B?6aG66IiqIOa4uA==?=) Date: Sun, 20 Nov 2011 23:32:29 -0800 (PST) Subject: request of "real timeout" in socket.read Message-ID: Hi, few days ago I was confused with the behavior of socket.read when timeout is used -- that the lifespan of the operation often is longer than the time I've specified. So I go to python.org and get the source code of python. Yet I had read some lines of code from the Python-2.7.2/Modules/ socketmodule.c, and I found that the function was implemented in internal_select by poll or select, this function will block at most a span of timeout, so whenever it is called, another timeout time has to be wasted if there's nothing coming. So what if to change the code like this: now = time(NULL); //may be other function if( s->sock_timeout >= now + .5 ) return 1; timeout = s->sock_timeout + .5 - now; /* ... poll or select */ here s->sock_timeout is a particular moment rather than a time span, or: s->sock_timeout = time(NULL) + timeout; when init. From john.37 at gmail.com Mon Nov 21 02:33:47 2011 From: john.37 at gmail.com (sword) Date: Sun, 20 Nov 2011 23:33:47 -0800 (PST) Subject: Interesting problem about uuid1 Message-ID: My colleague asks me an interesting problem about uuid library in python. In multicore system with multiprocessing, is it possible to get the duplicated uuid with uuid1? I just check the RFC 4122, and I can't find anything about multicore environment. Python's uuid1 method generates the uuid with time stamp, mac address, and algorithm to gen random numbers. So, I think it's possible to get the duplicate uuid1 at the same time. What about you? Hope for your reply From brenNOSPAMbarn at NObrenSPAMbarn.net Mon Nov 21 02:41:02 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Mon, 21 Nov 2011 07:41:02 +0000 (UTC) Subject: (don't bash me too hard) Python interpreter in JavaScript References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: Carl Banks wrote: > Some people have already made an LLVM-to-Javascript compiler, and > have managed to build Python 2.7 with it. > > The LLVM-to-Javascript project is called emscripten. > > https://github.com/kripken/emscripten/wiki > > Demo of Python (and a bunch of other languages) here: > > http://repl.it/ Very interesting. Is there a simple way to add third-party libraries to these? I assume that for pure-Python modules you could just put a python file in the appropriate place and import it, but what about if you wanted a web app that used numpy or something? Is that feasible? -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From kai.diefenbach at iqpp.de Mon Nov 21 03:11:35 2011 From: kai.diefenbach at iqpp.de (Kai) Date: Mon, 21 Nov 2011 09:11:35 +0100 Subject: LFS 0.6 beta 1 released Message-ID: Hi, I'm happy to announce the release of LFS 0.6 beta 1. LFS is an online shop based on Django and jQuery. If you want to read more information please refer to: http://www.getlfs.com/released-06-beta-1 Thanks Kai From vincent.vandevyvre at swing.be Mon Nov 21 03:56:39 2011 From: vincent.vandevyvre at swing.be (Vincent Vande Vyvre) Date: Mon, 21 Nov 2011 09:56:39 +0100 Subject: Close as Many Files/External resourcs as possible in the face of exceptions In-Reply-To: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> References: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> Message-ID: <4ECA1247.8060500@swing.be> An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Mon Nov 21 04:07:53 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 21 Nov 2011 20:07:53 +1100 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: Just compile your python to C :] On Mon, Nov 21, 2011 at 6:41 PM, OKB (not okblacke) wrote: > Carl Banks wrote: > >> Some people have already made an LLVM-to-Javascript compiler, and >> have managed to build Python 2.7 with it. >> >> The LLVM-to-Javascript project is called emscripten. >> >> https://github.com/kripken/emscripten/wiki >> >> Demo of Python (and a bunch of other languages) here: >> >> http://repl.it/ > > ? ? ? ?Very interesting. ?Is there a simple way to add third-party > libraries to these? ?I assume that for pure-Python modules you could > just put a python file in the appropriate place and import it, but what > about if you wanted a web app that used numpy or something? ?Is that > feasible? > > -- > --OKB (not okblacke) > Brendan Barnwell > "Do not follow where the path may lead. ?Go, instead, where there is > no path, and leave a trail." > ? ? ? ?--author unknown > -- > http://mail.python.org/mailman/listinfo/python-list From vinay_sajip at yahoo.co.uk Mon Nov 21 05:11:17 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 21 Nov 2011 02:11:17 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> <4f5fd473-4717-4f41-8017-d7407adc4571@u10g2000prl.googlegroups.com> <5dfa9add-582f-4219-8d78-01239f80525e@p5g2000vbm.googlegroups.com> <066c8586-dd11-4982-ab3a-5ff77db46b90@a3g2000prd.googlegroups.com> Message-ID: <2169ee84-a59a-4d52-977b-00200deffc1a@m19g2000yqh.googlegroups.com> On Nov 21, 7:15?am, sword wrote: > > Thank you! Maybe I should find out another way to manipulate the log, > like wrap the getLogger function and add the filter at the first > time :) If you are using Python 2.7, 3.2 or later, you can use dictionary- based configuration - it's fairly painless. http://docs.python.org/library/logging.config.html#logging.config.dictConfig If you are using an earlier version of Python, the logutils project includes the same dictionary-based configuration logic. http://code.google.com/p/logutils/ Regards, Vinay Sajip From Nikunj.Badjatya at emc.com Mon Nov 21 05:44:17 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Mon, 21 Nov 2011 05:44:17 -0500 Subject: ProgressBar - Python and Powershell In-Reply-To: References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D3E9@MX34A.corp.emc.com> Yes I am executing powershell commands into virtual machines. Will have a look at WiX. But please, Answer my questions: >> My questions are: >> >> 1. Can I have a better shared mechanism between python and >> powershell.? As I am using a file here. Reading + writing in python and >> writing only in powershell. ! >> >> 2. Does this thread mechanism work.? I am yet to implement and test >> it.! :P What can be the possible shortfalls.? Thanks Nikunj -----Original Message----- From: Alec Taylor [mailto:alec.taylor6 at gmail.com] Sent: Monday, November 21, 2011 11:59 AM To: Badjatya, Nikunj Cc: python-list at python.org Subject: Re: ProgressBar - Python and Powershell So you're executing Powershell commands into Virtual Machines? Add this into the installer (probably WiX is your best bet) On Mon, Nov 21, 2011 at 3:40 AM, wrote: > Thanks for reply. > Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). > Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am ?using Python. > > I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? > > The current look of the installer is completely command line based. > > > -----Original Message----- > From: Alec Taylor [mailto:alec.taylor6 at gmail.com] > Sent: Sunday, November 20, 2011 7:22 PM > To: Badjatya, Nikunj > Cc: python-list at python.org > Subject: Re: ProgressBar - Python and Powershell > > Why are you writing an installer in Python and Powershell? > > Just write an installer in WiX, NSIS or Inno like the rest of the sane world. > > Alternatively take a look at MakeMSI or the script python uses to > generate there .MSI. > > Anything else is WAY too non-standard to consider. > > On Mon, Nov 21, 2011 at 12:01 AM, ? wrote: >> Can anyone throw some light on this please ! ? >> >> >> >> >> >> From: python-list-bounces+nikunj.badjatya=emc.com at python.org >> [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of >> Nikunj.Badjatya at emc.com >> Sent: Thursday, November 17, 2011 4:10 PM >> To: python-list at python.org >> Subject: ProgressBar - Python and Powershell >> >> >> >> Hi All, >> >> >> >> I am using Python 2.7, windows Env. >> >> I have an Installer written in Python(45%) and Powershell(55%) which is used >> to install Virtual Machines at specific locations. It is single threaded. >> >> I am trying to implement a ProgressBar ?for this installer. So that the user >> will come to know the progress of the installation. >> >> I am using pypi progressbar module. >> >> The top script is in python which inturns calls powershell scripts using >> subprocess.call() and proceeds with the installation. >> >> >> >> I am taking a shared file between python and powershell, so that diff >> functions can update their %age completion level in to the file. Ex. Func1() >> updates it to 5%,? func2() will add its own 5% to it.. and so on. >> >> At the start of the (main.py) script I am creating a thread whose sole >> purpose would be to keep "READ" a temp file for a new entry in it. >> >> Based on this entry I can have my thread update the progressbar on the >> console. >> >> >> >> My questions are: >> >> 1.?????? Can I have a better shared mechanism between python and >> powershell.? ?As I am using a file here. Reading + writing in python and >> writing only in powershell. ?! >> >> 2.?????? Does this thread mechanism work.? I am yet to implement and test >> it.! :P What can be the possible shortfalls.? >> >> >> >> >> Thanks >> >> >> >> Nikunj >> >> Bangalore - India >> >> >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > From jeanmichel at sequans.com Mon Nov 21 06:39:20 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 21 Nov 2011 12:39:20 +0100 Subject: Got some problems when using logging Filter In-Reply-To: References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: <4ECA3868.8010905@sequans.com> sword wrote: > On Nov 16, 7:40 pm, Jean-Michel Pichavant > wrote: > >> sword wrote: >> >>> The logging cookbook gives an Filter example, explainning how to add >>> contextural info to log. I can't figure out how to filter log from it. >>> >>> Suppose I have 3 file, a.py, b.py and main.py >>> #file: a.py >>> import logging >>> >>> logger=logging.getLogger(__name__) >>> def print_log(): >>> logger.debug("I'm module a") >>> >>> #file: b.py just like a.py >>> import logging >>> logger=logging.getLogger(__name__) >>> def print_log(): >>> logger.debug("I'm module b") >>> >>> #file: main.py >>> import logging >>> from logging import Filter >>> logging.basicConfig(level=logging.DEBUG) >>> logger=logging.getLogger("main") >>> logger.debug("This is main process") >>> logger.addFilter(Filter("a")) >>> >>> And I expected that the console output would contain main and b module >>> log only. But it turned out that all logs there. Is it the problem of >>> root logger? >>> >> Hi, >> >> First of all, in the code you provided we can't see where you import a & >> b, and when you call their respective print_log method. >> Secondly,Filter("a") would allow only the "a" log events, not forbid >> them. quoting the docs: "if name is specified, it names a logger which, >> together with its children, will have its events allowed through the >> filter." >> >> As for your problem it may come from the fact that you applied the >> filter to the 'main' logger, while you probably want to add the filter >> to the *root* logger. Your current hierarchy is >> >> root >> - main >> - a >> - b >> >> events fired from 'a' will be handled by the root logger, not the main. >> root = logging.getLogger() >> root.addFilter('main') >> root.addFilter('a') >> root.addFilter('b') >> >> JM >> > > Thanks for your reply. I tried to edit the source a bit, now the > main.py looks like this: > #main.py > import logging > from logging import Filter > import a > import b > > logging.basicConfig(level=logging.DEBUG) > root = logging.getLogger() > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > would pass this filter > > logger = logging.getLogger("main") > logger.debug("main process") > a.print_log() > b.print_log() > > #### > And It still prints out all the log msg. :( > You need to add you filter to the handler(s) of the root logger, not the root logger itself. Filters to loggger object are applied only when the log event is raised, i.e. when one of the logging method error, info, warning, debug is called. In your case, log events are raised by other loggers than the root logger, so its filter will not apply. However any filter applied to the root *handlers* will be applied to any log processed by the handler, including log event raised by sub-logger. root.handlers[-1].addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg JM Quoting http://docs.python.org/library/logging.html#filter-objects "Note that filters attached to handlers are consulted whenever an event is emitted by the handler, whereas filters attached to loggers are consulted whenever an event is logged to the handler (using debug(), info(), etc.) This means that events which have been generated by descendant loggers will not be filtered by a logger?s filter setting, unless the filter has also been applied to those descendant loggers." From mwilson at the-wire.com Mon Nov 21 07:09:11 2011 From: mwilson at the-wire.com (Mel Wilson) Date: Mon, 21 Nov 2011 07:09:11 -0500 Subject: Close as Many Files/External resourcs as possible in the face of exceptions References: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> Message-ID: GZ wrote: > Here is my situation. A parent object owns a list of files (or other > objects with a close() method). The close() method can sometimes fail > and raise an exception. When the parent object's close() method is > called, it needs to close down as many files it owns as possible, even > if the close() function of some files fail. I also want to re-raise at > least one of the original exceptions so that the outer program can > handle it. [ ... ] > > It will re-raise the first exception and preserve the context and > close as many other files as possible while ignoring any further > exceptions. > > But this looks really awkward. And in the case that two files fail to > close, I am not sure the best strategy is to ignore the second > failure. I imagine you could save any caught exception instances in a list and study them later. Mel. From ahsanbagwan at gmail.com Mon Nov 21 07:13:29 2011 From: ahsanbagwan at gmail.com (sl33k) Date: Mon, 21 Nov 2011 04:13:29 -0800 (PST) Subject: Format the ouput in my python code Message-ID: <3f23c6ac-0554-4cb7-bf7c-b98c29721796@z22g2000prd.googlegroups.com> I am printing the numbers from 1 to 100. In that, I want to display multiples of 3,5 and of both as mulof3, mul0f5 and mulof3and5 respectively. I am getting the output I want but I would like to format the output to print only 10 number per line. How do I go about doing this? for i in range(1, 101): if i % 3 == 0: if i % 5 == 0: print 'mulof3and5', else: print 'mulof3', elif i % 5 == 0: print 'mulof5', else: print i From Nikunj.Badjatya at emc.com Mon Nov 21 07:27:47 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Mon, 21 Nov 2011 07:27:47 -0500 Subject: ProgressBar - Python and Powershell In-Reply-To: References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D3E9@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D401@MX34A.corp.emc.com> Hey Thanks. Will do that. Just a question in general. Is it possible that we have opened one file in r+ mode ( file1.txt ). We have 2 threads, thread1 will continuously only read the file in a loop. Thread2 will only update the data in the file. Now thread2 has called other script ( written in say Perl/Powershell ) and those scripts are inturn updating ( only writing ) into that file by their own file i/o mechanism. Is it possible by any chance? One file being shared between different processes one is updating and other is reading ..? Will this work in practical and what can be the complications ? -----Original Message----- From: Alec Taylor [mailto:alec.taylor6 at gmail.com] Sent: Monday, November 21, 2011 5:23 PM To: Badjatya, Nikunj Subject: Re: ProgressBar - Python and Powershell WiX will manage all the progress bar stuff for you. Just wrap it all in On Mon, Nov 21, 2011 at 9:44 PM, wrote: > Yes I am executing powershell commands into virtual machines. > > Will have a look at WiX. > > But please, Answer my questions: > >>> My questions are: >>> >>> 1. ? ? ? Can I have a better shared mechanism between python and >>> powershell.? ?As I am using a file here. Reading + writing in python and >>> writing only in powershell. ?! >>> >>> 2. ? ? ? Does this thread mechanism work.? I am yet to implement and test >>> it.! :P What can be the possible shortfalls.? > > Thanks > Nikunj > > -----Original Message----- > From: Alec Taylor [mailto:alec.taylor6 at gmail.com] > Sent: Monday, November 21, 2011 11:59 AM > To: Badjatya, Nikunj > Cc: python-list at python.org > Subject: Re: ProgressBar - Python and Powershell > > So you're executing Powershell commands into Virtual Machines? > > Add this into the installer (probably WiX is your best bet) > > On Mon, Nov 21, 2011 at 3:40 AM, ? wrote: >> Thanks for reply. >> Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). >> Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am ?using Python. >> >> I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? >> >> The current look of the installer is completely command line based. >> >> >> -----Original Message----- >> From: Alec Taylor [mailto:alec.taylor6 at gmail.com] >> Sent: Sunday, November 20, 2011 7:22 PM >> To: Badjatya, Nikunj >> Cc: python-list at python.org >> Subject: Re: ProgressBar - Python and Powershell >> >> Why are you writing an installer in Python and Powershell? >> >> Just write an installer in WiX, NSIS or Inno like the rest of the sane world. >> >> Alternatively take a look at MakeMSI or the script python uses to >> generate there .MSI. >> >> Anything else is WAY too non-standard to consider. >> >> On Mon, Nov 21, 2011 at 12:01 AM, ? wrote: >>> Can anyone throw some light on this please ! ? >>> >>> >>> >>> >>> >>> From: python-list-bounces+nikunj.badjatya=emc.com at python.org >>> [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of >>> Nikunj.Badjatya at emc.com >>> Sent: Thursday, November 17, 2011 4:10 PM >>> To: python-list at python.org >>> Subject: ProgressBar - Python and Powershell >>> >>> >>> >>> Hi All, >>> >>> >>> >>> I am using Python 2.7, windows Env. >>> >>> I have an Installer written in Python(45%) and Powershell(55%) which is used >>> to install Virtual Machines at specific locations. It is single threaded. >>> >>> I am trying to implement a ProgressBar ?for this installer. So that the user >>> will come to know the progress of the installation. >>> >>> I am using pypi progressbar module. >>> >>> The top script is in python which inturns calls powershell scripts using >>> subprocess.call() and proceeds with the installation. >>> >>> >>> >>> I am taking a shared file between python and powershell, so that diff >>> functions can update their %age completion level in to the file. Ex. Func1() >>> updates it to 5%,? func2() will add its own 5% to it.. and so on. >>> >>> At the start of the (main.py) script I am creating a thread whose sole >>> purpose would be to keep "READ" a temp file for a new entry in it. >>> >>> Based on this entry I can have my thread update the progressbar on the >>> console. >>> >>> >>> >>> My questions are: >>> >>> 1.?????? Can I have a better shared mechanism between python and >>> powershell.? ?As I am using a file here. Reading + writing in python and >>> writing only in powershell. ?! >>> >>> 2.?????? Does this thread mechanism work.? I am yet to implement and test >>> it.! :P What can be the possible shortfalls.? >>> >>> >>> >>> >>> Thanks >>> >>> >>> >>> Nikunj >>> >>> Bangalore - India >>> >>> >>> >>> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >>> >> > From santosdosreis at gmail.com Mon Nov 21 08:05:30 2011 From: santosdosreis at gmail.com (Jayson Santos) Date: Mon, 21 Nov 2011 05:05:30 -0800 (PST) Subject: New memcached module Message-ID: <9f3e0c68-3057-4a65-90f8-5e05f82c5aae@y7g2000vbe.googlegroups.com> Hi guys, I have created a pure python module [1] to work with memcached in binary protocol with SASL authentication. I need some contributors or people to discuss some idead about it, anyone is free to contact me, any help will be appreciated. Thank You Jayson Reis [1] https://github.com/jaysonsantos/python-binary-memcached From jeanmichel at sequans.com Mon Nov 21 08:06:18 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 21 Nov 2011 14:06:18 +0100 Subject: Is there any way to unimport a library In-Reply-To: References: Message-ID: <4ECA4CCA.5050308@sequans.com> Gelonida N wrote: > I wondered whether there is any way to un-import a library, such, that > it's occupied memory and the related shared libraries are released. > > > My usecase is following: > > > success = False > try: > import lib1_version1 as lib1 > import lib2_version1 as lib2 > success = True > except ImportError: > pass > if not success: > try: > import lib1_version2 as lib1 > import lib2_version2 as lib2 > success = True > except importError: > pass > if not success: > . . . > > > > Basically if I am not amble to import lib1_version1 AND lib2_version1, > then I wanted to make sure, that lib1_version1 does not waste any memory > > > At this moment this is more a thought excercise than a real issue, but I > thought that perhaps somebody encountered this kind of issue and had an > idea how to deal with such situations. > > One solution, that I could imagine is running the program a first time, > detect all existing libraries and write out a config file being use > the next time it is run, such, that immediately the right libs are imported. > > Short answer for unimporting modules : Not possible (yes there is a long one :o) ). One approach to your problem is to test for module existence before importing any module. import imp def impVersion(version) try: imp.find_module('lib1_version%s' % version) imp.find_module('lib2_version%s' % version) except ImportError: raise else: lib1 = __import__('lib1_version%s' % version) lib2 = __import__('lib2_version%s' % version) # using a for loop to avoid to many nested try statement for version in [1,2,3,4]: try: impVersion(version) except ImportError: continue break if not lib1 or not lib2: # no lib imported pass Using this code allows you to import your library only if all conditions are met, preventing you from rolling back in case of error. Jean-Michel From alec.taylor6 at gmail.com Mon Nov 21 08:08:29 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Tue, 22 Nov 2011 00:08:29 +1100 Subject: ProgressBar - Python and Powershell In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D401@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D3E9@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D401@MX34A.corp.emc.com> Message-ID: New thread! On Mon, Nov 21, 2011 at 11:27 PM, wrote: > Hey Thanks. Will do that. > > Just a question in general. ?Is it possible that we have opened one file in r+ mode ( file1.txt ). We have 2 threads, thread1 will continuously only read the file in a loop. Thread2 will only update the data in the file. Now thread2 has called other script ( written in say Perl/Powershell ) and those scripts are inturn updating ( only writing ) into that file by their own file i/o mechanism. > Is it possible by any chance? One file being shared between different processes one is updating and other is reading ..? Will this work in practical and what can be the complications ? > > > > -----Original Message----- > From: Alec Taylor [mailto:alec.taylor6 at gmail.com] > Sent: Monday, November 21, 2011 5:23 PM > To: Badjatya, Nikunj > Subject: Re: ProgressBar - Python and Powershell > > WiX will manage all the progress bar stuff for you. > > Just wrap it all in > > On Mon, Nov 21, 2011 at 9:44 PM, ? wrote: >> Yes I am executing powershell commands into virtual machines. >> >> Will have a look at WiX. >> >> But please, Answer my questions: >> >>>> My questions are: >>>> >>>> 1. ? ? ? Can I have a better shared mechanism between python and >>>> powershell.? ?As I am using a file here. Reading + writing in python and >>>> writing only in powershell. ?! >>>> >>>> 2. ? ? ? Does this thread mechanism work.? I am yet to implement and test >>>> it.! :P What can be the possible shortfalls.? >> >> Thanks >> Nikunj >> >> -----Original Message----- >> From: Alec Taylor [mailto:alec.taylor6 at gmail.com] >> Sent: Monday, November 21, 2011 11:59 AM >> To: Badjatya, Nikunj >> Cc: python-list at python.org >> Subject: Re: ProgressBar - Python and Powershell >> >> So you're executing Powershell commands into Virtual Machines? >> >> Add this into the installer (probably WiX is your best bet) >> >> On Mon, Nov 21, 2011 at 3:40 AM, ? wrote: >>> Thanks for reply. >>> Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). >>> Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am ?using Python. >>> >>> I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? >>> >>> The current look of the installer is completely command line based. >>> >>> >>> -----Original Message----- >>> From: Alec Taylor [mailto:alec.taylor6 at gmail.com] >>> Sent: Sunday, November 20, 2011 7:22 PM >>> To: Badjatya, Nikunj >>> Cc: python-list at python.org >>> Subject: Re: ProgressBar - Python and Powershell >>> >>> Why are you writing an installer in Python and Powershell? >>> >>> Just write an installer in WiX, NSIS or Inno like the rest of the sane world. >>> >>> Alternatively take a look at MakeMSI or the script python uses to >>> generate there .MSI. >>> >>> Anything else is WAY too non-standard to consider. >>> >>> On Mon, Nov 21, 2011 at 12:01 AM, ? wrote: >>>> Can anyone throw some light on this please ! ? >>>> >>>> >>>> >>>> >>>> >>>> From: python-list-bounces+nikunj.badjatya=emc.com at python.org >>>> [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of >>>> Nikunj.Badjatya at emc.com >>>> Sent: Thursday, November 17, 2011 4:10 PM >>>> To: python-list at python.org >>>> Subject: ProgressBar - Python and Powershell >>>> >>>> >>>> >>>> Hi All, >>>> >>>> >>>> >>>> I am using Python 2.7, windows Env. >>>> >>>> I have an Installer written in Python(45%) and Powershell(55%) which is used >>>> to install Virtual Machines at specific locations. It is single threaded. >>>> >>>> I am trying to implement a ProgressBar ?for this installer. So that the user >>>> will come to know the progress of the installation. >>>> >>>> I am using pypi progressbar module. >>>> >>>> The top script is in python which inturns calls powershell scripts using >>>> subprocess.call() and proceeds with the installation. >>>> >>>> >>>> >>>> I am taking a shared file between python and powershell, so that diff >>>> functions can update their %age completion level in to the file. Ex. Func1() >>>> updates it to 5%,? func2() will add its own 5% to it.. and so on. >>>> >>>> At the start of the (main.py) script I am creating a thread whose sole >>>> purpose would be to keep "READ" a temp file for a new entry in it. >>>> >>>> Based on this entry I can have my thread update the progressbar on the >>>> console. >>>> >>>> >>>> >>>> My questions are: >>>> >>>> 1.?????? Can I have a better shared mechanism between python and >>>> powershell.? ?As I am using a file here. Reading + writing in python and >>>> writing only in powershell. ?! >>>> >>>> 2.?????? Does this thread mechanism work.? I am yet to implement and test >>>> it.! :P What can be the possible shortfalls.? >>>> >>>> >>>> >>>> >>>> Thanks >>>> >>>> >>>> >>>> Nikunj >>>> >>>> Bangalore - India >>>> >>>> >>>> >>>> >>>> -- >>>> http://mail.python.org/mailman/listinfo/python-list >>>> >>> >> > From jeanmichel at sequans.com Mon Nov 21 08:08:34 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 21 Nov 2011 14:08:34 +0100 Subject: Is there any way to unimport a library In-Reply-To: <4ECA4CCA.5050308@sequans.com> References: <4ECA4CCA.5050308@sequans.com> Message-ID: <4ECA4D52.5090504@sequans.com> Jean-Michel Pichavant wrote: > Gelonida N wrote: >> I wondered whether there is any way to un-import a library, such, that >> it's occupied memory and the related shared libraries are released. >> >> >> My usecase is following: >> >> >> success = False >> try: >> import lib1_version1 as lib1 >> import lib2_version1 as lib2 >> success = True >> except ImportError: >> pass >> if not success: >> try: >> import lib1_version2 as lib1 >> import lib2_version2 as lib2 >> success = True >> except importError: >> pass >> if not success: >> . . . >> >> >> >> Basically if I am not amble to import lib1_version1 AND lib2_version1, >> then I wanted to make sure, that lib1_version1 does not waste any memory >> >> >> At this moment this is more a thought excercise than a real issue, but I >> thought that perhaps somebody encountered this kind of issue and had an >> idea how to deal with such situations. >> >> One solution, that I could imagine is running the program a first time, >> detect all existing libraries and write out a config file being use >> the next time it is run, such, that immediately the right libs are >> imported. >> >> > Short answer for unimporting modules : Not possible (yes there is a > long one :o) ). > > One approach to your problem is to test for module existence before > importing any module. > > import imp > > def impVersion(version) > try: > imp.find_module('lib1_version%s' % version) > imp.find_module('lib2_version%s' % version) > except ImportError: > raise > else: > lib1 = __import__('lib1_version%s' % version) > lib2 = __import__('lib2_version%s' % version) > > # using a for loop to avoid to many nested try statement > for version in [1,2,3,4]: > try: > impVersion(version) > except ImportError: > continue > break > > if not lib1 or not lib2: > # no lib imported > pass > > Using this code allows you to import your library only if all > conditions are met, preventing you from rolling back in case of error. > > Jean-Michel there are missing global lib1 global lib2 statements right before assigning lib1 and lib2. JM From Nikunj.Badjatya at emc.com Mon Nov 21 08:15:28 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Mon, 21 Nov 2011 08:15:28 -0500 Subject: Multiple Threads - I/O in Same File Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D407@MX34A.corp.emc.com> Hi All, Just a question in general. Is it possible that we have opened one file in r+ mode ( file1.txt ). We have 2 threads, * Thread1 will continuously 'only read' the file in a loop. * Thread2 will only update the data in the file ( say a number < 100 ). Now thread2 has called other script ( written in say Perl/Powershell using subprocess.call() ) and those scripts are inturn updating ( only writing ) into that file by their own file i/o mechanism. Is it possible by any chance? One file being shared between different processes one is only updating and other is only reading ..? Will this work in practical and what can be the complications ? Thanks Nikunj -------------- next part -------------- An HTML attachment was scrubbed... URL: From ray at aarden.us Mon Nov 21 08:18:00 2011 From: ray at aarden.us (ray) Date: Mon, 21 Nov 2011 05:18:00 -0800 (PST) Subject: How to: Coordinate DictReader and Reader for CSV Message-ID: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> I am trying to get the data from a CSV file into variables. I have used DictReader to get the field names and I can report them. When I attempt to look at the data, every row shows the combination of fieldname:data. How do I get the data out? linelist=open( "C:/Users/rjoseph/Documents/Projects/Bootstrap Plan Design Tool/Sandbox/line_list_r0a.csv", "rb" ) csvDictReader=csv.DictReader( linelist, dialect='excel' ) for data in csvReader: print data[0] print data[1] print data[2] print data[3] linelist.close() Thanks, ray From alec.taylor6 at gmail.com Mon Nov 21 08:39:18 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Tue, 22 Nov 2011 00:39:18 +1100 Subject: JSON passing protocol Message-ID: Good morning, I'm planning on assembling my django templates onto mobile apps using a JSON passing protocol, probably tunnels through HTTP. What's available? Thanks for all information, Alec Taylor From ray at aarden.us Mon Nov 21 08:42:59 2011 From: ray at aarden.us (ray) Date: Mon, 21 Nov 2011 05:42:59 -0800 (PST) Subject: How to Get Data from DictReader for CSV Files Message-ID: I don't see how to get my data from the output. I can see the data in the rows but it is mixed in with the field names. That is, the data I get comes out as: fieldname1 : data1 , fieldname2 : data2 , etc. import csv linelist=open( "C:/Users/me/line_list_r0.csv", "rb" ) csvReader= csv.DictReader( linelist, dialect='excel' ) for data in csvReader: print data linelist.close() I want to pass this data as arrays or lists to another module such as: myfunction(data1, data2, data3) How do I get the data I want out of the pair fieldname1 : data1? Thanks, ray From neilc at norwich.edu Mon Nov 21 08:59:35 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 21 Nov 2011 13:59:35 GMT Subject: How to: Coordinate DictReader and Reader for CSV References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> Message-ID: <9iv3q7F1t5U1@mid.individual.net> On 2011-11-21, ray wrote: > I am trying to get the data from a CSV file into variables. I have > used DictReader to get the field names and I can report them. When I > attempt to look at the data, every row shows the combination of > fieldname:data. How do I get the data out? > linelist=open( "C:/Users/rjoseph/Documents/Projects/Bootstrap Plan > Design Tool/Sandbox/line_list_r0a.csv", "rb" ) > csvDictReader=csv.DictReader( linelist, dialect='excel' ) > for data in csvReader: > print data[0] > print data[1] > print data[2] > print data[3] > linelist.close() The elements yielded by a DictReader iterator are dictionaries, and the keys are the headings of the csv file. So replace those integers with strings representing the headings of your file. If the headings are actually those numbers, you want: [...] print data['0'] print data['1'] print data['2'] print data['3'] print data['4'] [...] -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins From mlenz at nocturnal.org Mon Nov 21 09:00:55 2011 From: mlenz at nocturnal.org (mlenz at nocturnal.org) Date: Mon, 21 Nov 2011 06:00:55 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. Message-ID: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> I'm working on a project where I need to communicate with some devices via modem which have the possibility of using MARK and SPACE parity. These are not defined by POSIX and therefore are not directly supported under Linux. I've found the following discussion on the topic: http://www.lothosoft.ch/thomas/libmip/markspaceparity.php and I have been trying to use this information (since the TERMIOS module is available) to proceed with the communication. I was able to use minicom to determine that the first device I started testing with uses 7M1 but cannot figure out how to implement the solution described by the author above. Any pointers would be greatly appreciated. From matthew at nocturnal.org Mon Nov 21 09:16:44 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 06:16:44 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> Message-ID: <16480720.736.1321885004083.JavaMail.geo-discussion-forums@yqni5> I should also note that I am aware of the following discussion on the newsgroup: https://groups.google.com/d/msg/comp.lang.python/1HyCqPSOf50/eQINFrrFKwoJ However, I believe this refers to implementing the solution for 8M1 and 8S1. From nizamov.shawkat at gmail.com Mon Nov 21 09:26:48 2011 From: nizamov.shawkat at gmail.com (Nizamov Shawkat) Date: Mon, 21 Nov 2011 15:26:48 +0100 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> Message-ID: 2011/11/21 : > I'm working on a project where I need to communicate with some devices via modem which have the possibility of using MARK and SPACE parity. ?These are not defined by POSIX and therefore are not directly supported under Linux. > > I've found the following discussion on the topic: > > http://www.lothosoft.ch/thomas/libmip/markspaceparity.php > > and I have been trying to use this information (since the TERMIOS module is available) to proceed with the communication. > > I was able to use minicom to determine that the first device I started testing with uses 7M1 but cannot figure out how to implement the solution described by the author above. > "The modes 7M1 (7 data bits, MARK parity, 1 stop bit) and 7S1 (7 data bits, SPACE parity, 1 stop bit) can easily be emulated using 8N1 (0 data bits, NO parity, 1 stop bit) and setting the 8th data bit to 1 resp. 0. This is relatively simple to implement and cannot be distinguished by the receiver." It means that 7M1 === 8N1. Set 8N1 mode on your side and 7M1 on the other side. I really do not understand what is the reason to have dedicated 7M1 or 7S1 mode - it is no different from regular 8 bit mode from the hardware point of view. From the software point of view it is just the matter of the definition of the highest bit. In other words, 7M1/7S1 are two complementary subsets of a single 8N1 set. HTH From d at davea.name Mon Nov 21 09:27:29 2011 From: d at davea.name (Dave Angel) Date: Mon, 21 Nov 2011 09:27:29 -0500 Subject: Format the ouput in my python code In-Reply-To: <3f23c6ac-0554-4cb7-bf7c-b98c29721796@z22g2000prd.googlegroups.com> References: <3f23c6ac-0554-4cb7-bf7c-b98c29721796@z22g2000prd.googlegroups.com> Message-ID: <4ECA5FD1.5090308@davea.name> On 11/21/2011 07:13 AM, sl33k wrote: > I am printing the numbers from 1 to 100. In that, I want to display > multiples of 3,5 and of both as mulof3, mul0f5 and mulof3and5 > respectively. > > I am getting the output I want but I would like to format the output > to print only 10 number per line. How do I go about doing this? > > for i in range(1, 101): > if i % 3 == 0: > if i % 5 == 0: > print 'mulof3and5', > else: > print 'mulof3', > elif i % 5 == 0: > print 'mulof5', > else: > print i > Change that loop into a generator, having it return values rather than printing them. Then call that generator in a for-loop, something like: for index, val in enumerate(mygen): print val, if not index%10: print -- DaveA From d at davea.name Mon Nov 21 09:34:14 2011 From: d at davea.name (Dave Angel) Date: Mon, 21 Nov 2011 09:34:14 -0500 Subject: Format the ouput in my python code In-Reply-To: <4ECA5FD1.5090308@davea.name> References: <3f23c6ac-0554-4cb7-bf7c-b98c29721796@z22g2000prd.googlegroups.com> <4ECA5FD1.5090308@davea.name> Message-ID: <4ECA6166.3050401@davea.name> On 11/21/2011 09:27 AM, Dave Angel wrote: > On 11/21/2011 07:13 AM, sl33k wrote: >> I am printing the numbers from 1 to 100. In that, I want to display >> multiples of 3,5 and of both as mulof3, mul0f5 and mulof3and5 >> respectively. >> >> I am getting the output I want but I would like to format the output >> to print only 10 number per line. How do I go about doing this? >> >> for i in range(1, 101): >> if i % 3 == 0: >> if i % 5 == 0: >> print 'mulof3and5', >> else: >> print 'mulof3', >> elif i % 5 == 0: >> print 'mulof5', >> else: >> print i >> > Change that loop into a generator, having it return values rather than > printing them. Then call that generator in a for-loop, something like: > > for index, val in enumerate(mygen): > print val, > if not index%10: print > > Oops. That was untested, and it probably wasn't quite what you wanted. More likely something like (untested): for index, val in enumerate(mygen): print val, if not ((index+1)%10): print -- DaveA From andrea.crotti.0 at gmail.com Mon Nov 21 09:44:34 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 21 Nov 2011 14:44:34 +0000 Subject: decorators and closures Message-ID: <4ECA63D2.7080603@gmail.com> With one colleague I discovered that the decorator code is always executed, every time I call a nested function: def dec(fn): print("In decorator") def _dec(): fn() return _dec def nested(): @dec def fun(): print("here") nested() nested() Will give: In decorator In decorator So we were wondering, would the interpreter be able to optimize this somehow? I was betting it's not possible, but I'm I would like to be wrong :) From d at davea.name Mon Nov 21 10:06:00 2011 From: d at davea.name (Dave Angel) Date: Mon, 21 Nov 2011 10:06:00 -0500 Subject: decorators and closures In-Reply-To: <4ECA63D2.7080603@gmail.com> References: <4ECA63D2.7080603@gmail.com> Message-ID: <4ECA68D8.2060608@davea.name> On 11/21/2011 09:44 AM, Andrea Crotti wrote: > With one colleague I discovered that the decorator code is always > executed, every time I call > a nested function: > > def dec(fn): > print("In decorator") > def _dec(): > fn() > > return _dec > > def nested(): > @dec > def fun(): > print("here") > > nested() > nested() > > Will give: > In decorator > In decorator > > So we were wondering, would the interpreter be able to optimize this > somehow? > I was betting it's not possible, but I'm I would like to be wrong :) Your function 'nested' isn't nested, 'fun' is. What you discovered is that a decorator is always executed, every time a nested decorated function is defined. You've also ust proved that it would be an incompatible change. Doesn't that answer the question? An optimizer that changes the behavior isn't usually desirable. -- DaveA From ray at aarden.us Mon Nov 21 10:16:15 2011 From: ray at aarden.us (ray) Date: Mon, 21 Nov 2011 07:16:15 -0800 (PST) Subject: How to: Coordinate DictReader and Reader for CSV References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> <9iv3q7F1t5U1@mid.individual.net> Message-ID: <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> On Nov 21, 7:59?am, Neil Cerutti wrote: > On 2011-11-21, ray wrote: > > > I am trying to get the data from a CSV file into variables. ?I have > > used DictReader to get the field names and I can report them. ?When I > > attempt to look at the data, every row shows the combination of > > fieldname:data. ?How do I get the data out? > > linelist=open( "C:/Users/thisuser/Documents/Projects/Bootstrap Plan > > Design Tool/Sandbox/line_list_r0a.csv", "rb" ) > > csvDictReader=csv.DictReader( linelist, dialect='excel' ) > > for data in csvReader: > > ? ? ? ? print data[0] > > ? ? ? ? print data[1] > > ? ? ? ? print data[2] > > ? ? ? ? print data[3] > > linelist.close() > > The elements yielded by a DictReader iterator are dictionaries, > and the keys are the headings of the csv file. So replace those > integers with strings representing the headings of your file. > > If the headings are actually those numbers, you want: > > [...] > ? ? print data['0'] > ? ? print data['1'] > ? ? print data['2'] > ? ? print data['3'] > ? ? print data['4'] > [...] > > -- > Neil Cerutti > ? "This room is an illusion and is a trap devisut by Satan. ?Go > ahead and dauntlessly! ?Make rapid progres!" > ? --Ghosts 'n Goblins Neil, Thank you for your efforts. When I use the 0, 1, etc. in the data[x] slot, I get some data. When I put a string in, I get an error stating: TypeError: list indices must be integers, not str But your suggestion has helped my better understand my problem. The output is first a list of the keys and then the associated data. The difficulty is that I want to pass the data to another function will I am in the 'for' loop. But the first data out is keys and that is not the data I want to send to the other function. Is there a way to capture the keys outside of the for loop so when the for loop is entered, only data is extracted? Thanks, ray From andrea.crotti.0 at gmail.com Mon Nov 21 10:35:13 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 21 Nov 2011 15:35:13 +0000 Subject: decorators and closures In-Reply-To: <4ECA68D8.2060608@davea.name> References: <4ECA63D2.7080603@gmail.com> <4ECA68D8.2060608@davea.name> Message-ID: <4ECA6FB1.6000701@gmail.com> On 11/21/2011 03:06 PM, Dave Angel wrote: > Your function 'nested' isn't nested, 'fun' is. What you discovered is > that a decorator is always executed, every time a nested decorated > function is defined. > > You've also ust proved that it would be an incompatible change. > Doesn't that answer the question? An optimizer that changes the > behavior isn't usually desirable. > Yes sure I think it makes perfectly sense, because you actually redefine a local variable every time.. Another thing (which was also the reason of the subject), I tried to disassemble the following: def dec(fn): def _dec(): fn() return _dec @dec def fun(): print("here") fun() And I get this: In [29]: dis.dis(test_decorate) Disassembly of dec: 2 0 LOAD_CLOSURE 0 (fn) 3 BUILD_TUPLE 1 6 LOAD_CONST 1 () 9 MAKE_CLOSURE 0 12 STORE_FAST 1 (_dec) 5 15 LOAD_FAST 1 (_dec) 18 RETURN_VALUE Disassembly of fun: 3 0 LOAD_DEREF 0 (fn) 3 CALL_FUNCTION 0 6 POP_TOP 7 LOAD_CONST 0 (None) 10 RETURN_VALUE Looking up the definition of the single calls didn't help much, so why do we need for example MAKE_CLOSURE? Is MAKE_CLOSURE just more generic maybe? From neilc at norwich.edu Mon Nov 21 10:41:31 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 21 Nov 2011 15:41:31 GMT Subject: How to: Coordinate DictReader and Reader for CSV References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> <9iv3q7F1t5U1@mid.individual.net> <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> Message-ID: <9iv9pbFdboU1@mid.individual.net> On 2011-11-21, ray wrote: > Is there a way to capture the keys outside of the for loop so > when the for loop is entered, only data is extracted? I have sometimes done the following type of thing, since DictReader doesn't offer an attribute providing the field names. This is Python 3.3.2 code, so revise boilerplate if necessary. # Open once as a csv.reader instance to get the field names, in # order. with open(in_file_name, newline='') as in_file: reader = csv.reader(in_file) fields = next(reader) # Open it again as a csv.DictReader instance to do actual work, # writing revised lines to the output file as I go. with open(in_file_name, newline=') as in_file: with open(out_file_name, "w", newline='') as out_file: reader = csv.DictReader(in_file) writer = csv.DictWriter(out_file, fieldnames=fields) # Write header line writer.writerow({f: f for n in fields}) for record in reader: # Change a few fields # [...] writer.writerow(record) -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins From neilc at norwich.edu Mon Nov 21 10:43:25 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 21 Nov 2011 15:43:25 GMT Subject: How to: Coordinate DictReader and Reader for CSV References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> <9iv3q7F1t5U1@mid.individual.net> <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> <9iv9pbFdboU1@mid.individual.net> Message-ID: <9iv9stFdboU2@mid.individual.net> On 2011-11-21, Neil Cerutti wrote: > On 2011-11-21, ray wrote: >> Is there a way to capture the keys outside of the for loop so >> when the for loop is entered, only data is extracted? > > I have sometimes done the following type of thing, since > DictReader doesn't offer an attribute providing the field names. > This is Python 3.3.2 code, so revise boilerplate if necessary. > > # Open once as a csv.reader instance to get the field names, in > # order. > with open(in_file_name, newline='') as in_file: > reader = csv.reader(in_file) > fields = next(reader) Equal to reader.next() in 2.x Python, I believe. > # Open it again as a csv.DictReader instance to do actual work, > # writing revised lines to the output file as I go. > with open(in_file_name, newline=') as in_file: > with open(out_file_name, "w", newline='') as out_file: > reader = csv.DictReader(in_file) > writer = csv.DictWriter(out_file, fieldnames=fields) > # Write header line > writer.writerow({f: f for n in fields}) Oops! {f: f for f in fields}. Sorry about that. > for record in reader: > # Change a few fields > # [...] > writer.writerow(record) -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins From jabba.laci at gmail.com Mon Nov 21 10:56:59 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Mon, 21 Nov 2011 16:56:59 +0100 Subject: sqlalchemy beginner Message-ID: Hi, I'm reading the Essential SQLAlchemy book from O'Reilly. It explains SqlAlch 0.4 but my current version is 0.7 and there are some differences. Here is an example from the book: user_table = Table('tf_user', metadata, Column('id', Integer, primary_key=True), Column('user_name', Unicode(16), unique=True, nullable=False), Column('password', Unicode(40), nullable=False), Column('display_name', Unicode(255), default=''), Column('created', DateTime, default=datetime.now) ) Here I get the following warning: SAWarning: Unicode column received non-unicode default value. Column('display_name', Unicode(255), default=''), Changing Unicode(255) to String(255) makes the warning disappear but I'm not sure if it's the correct solution. For table names, the book uses the prefix convention 'tf_' but what does it mean? 't' is table, but what is 'f'? Thanks, Laszlo From matthew at nocturnal.org Mon Nov 21 11:28:19 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 08:28:19 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> Message-ID: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Using 8N1 under minicom with this device resulted in garbled text when once connected. Connection using 7M1 resulted in the correct text. So there must be something else that needs to be done in my python program correct? From matthew at nocturnal.org Mon Nov 21 11:28:19 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 08:28:19 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> Message-ID: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Using 8N1 under minicom with this device resulted in garbled text when once connected. Connection using 7M1 resulted in the correct text. So there must be something else that needs to be done in my python program correct? From zyzhu2000 at gmail.com Mon Nov 21 11:29:53 2011 From: zyzhu2000 at gmail.com (GZ) Date: Mon, 21 Nov 2011 08:29:53 -0800 (PST) Subject: How to Get Data from DictReader for CSV Files References: Message-ID: <7c77f2c4-09a5-4b5d-b162-b282688c0409@n35g2000yqf.googlegroups.com> Hi, On Nov 21, 7:42?am, ray wrote: > I don't see how to get my data from the output. ?I can see the data in > the rows but it is mixed in with the field names. ?That is, the data I > get comes out as: > fieldname1 : data1 , fieldname2 : data2 , etc. > > import csv > linelist=open( "C:/Users/me/line_list_r0.csv", "rb" ) > csvReader= csv.DictReader( linelist, dialect='excel' ) > for data in csvReader: > ? ? ? ? print data > linelist.close() > > I want to pass this data as arrays or lists to another module such as: > myfunction(data1, data2, data3) > > How do I get the data I want out of the pair fieldname1 : data1? > > Thanks, > ray > > It returns a dict(). You can reference the fields with data['fieldname1'], etc. From wolftracks at invalid.com Mon Nov 21 11:39:37 2011 From: wolftracks at invalid.com (W. eWatson) Date: Mon, 21 Nov 2011 08:39:37 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. Message-ID: My criterion for success is that it puts IDLE as a choice for editor on the menu produced with a right-click on a py file. So far no response on this has solved the problem. I know it sets up that way on a 2.5 and 2.4 on other PCs I have. I know at one time it worked on my 64-bit Win 7 PC, which likely had a 32-bit version installed on it. After something like six months of modest use it stopped working as above. No IDLE choice. I know by installing a 64-bit version, 3.2.2 failed the IDLE criterions as described. No IDLE. I do know that IDLE appears on the Win 7 Start menu, but, when used, nothing happens. Well, OK, for about 3 seconds the Win 7 "working" icon spins around then zip, nothing. Further, right-clicking on Properties of IDLE (GUI) produces a tabbed dialog. It shows Start in: c:\Python32\, and None for shortcut. There is a compatibility tab, which I've set to Win7. I think there's a troubleshooter there too, but I haven't used it. Under the Details tab, it shows Name: IDLE(Python Gui).lnk. Folder Path as: c:\ProgramData\Microsoft\Windows\Start... Nothing after the "...". Attributes: A Going directly to ...\Lib\idlelib\idle.pyw produces the spinning icon. At least, that's what happens in 3.2.2, but in the 32-bit versions I tried, I would get "invalid Win 32 app". When I rebooted my system a few hours after installing 3.2.2, because the PC was running really slowly--not because of Python, I was greeted by a couple of interesting messages as the desktop was populated. I can execute Python from the command line. 1. Specified module could not be found: Load Lib, python.dll. 2. \ProgramFiles(x86)\uniblueDrivers\Scanner (x86) Python26.dll. I'm sure this is related to Winamp, which I had installed a month ago. It had some "crazy" choice to scan for new drivers. Of course, if it found one-connected with Python, and if you wanted it, $$$. I think this message is a red herring. I may re-install Winamp to get rid of that uniblue tool that seems like nothing more than an ad. Some have suggested a registry problem, but I don't have a clue how to play with that, or somehow clean it up, if there is a problem. My PC behaves normally I'm using Win 7 Premium. So unless some brilliant idea appears, that leaves me with the choice of not using Python or this suggestion... (Let's not get off into other variations of other "Pythons" like Active..."): Someone suggested using the mail list at . What's different about that list than this NG? Does the "org" suggest that the inhabitants of that list are more likely associated with the people who are responsible for constructing Python? Comments? From rosuav at gmail.com Mon Nov 21 11:41:01 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Nov 2011 03:41:01 +1100 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Message-ID: On Tue, Nov 22, 2011 at 3:28 AM, Matthew Lenz wrote: > Using 8N1 under minicom with this device resulted in garbled text when once connected. ?Connection using 7M1 resulted in the correct text. ?So there must be something else that needs to be done in my python program correct? Using 8N1 when it's really 7M1 means you have the high bit set on every byte. I don't know if there's an easy way to do this fast in Python, but what you need to do is mask them all off... I'm not sure if there's a better way, but this ought to work: string = "".join(chr(ord(x)&0x7f) for x in string) In Python 3, iterating over a 'bytes' string produces integers, so omit the ord() call. Other than that, code is not tested. ChrisA From fraveydank at gmail.com Mon Nov 21 11:47:53 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 11:47:53 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Message-ID: <5074B814-C5A1-4B42-8F89-3B7406C91F49@gmail.com> On Nov 21, 2011, at 11:28 AM, Matthew Lenz wrote: > Using 8N1 under minicom with this device resulted in garbled text when once connected. Connection using 7M1 resulted in the correct text. So there must be something else that needs to be done in my python program correct? Under minicom in 8N1, it's going to look garbled because the high bit will always be set. Minicom will try to spit out those characters anyway, which will print out whatever extended ASCII garbage your terminal supports in the 0x80-0xFF range. Programmatically, though, you can strip off the high bit when you're receiving it in Python. "Space" parity, on the other hand, should look normal under Minicom because the high bit will always be low, giving you standard 7-bit ASCII. - Dave From matthew at nocturnal.org Mon Nov 21 11:52:17 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 08:52:17 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Message-ID: <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Ahh. Ok. So how would I go about doing that with python? I think in perl (sorry for the naughty word) I could use the tr// (translate) but is there a quick way to do so with python? Is it going to be necessary to convert commands I SEND to the device or only convert what I receive? From matthew at nocturnal.org Mon Nov 21 11:52:17 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 08:52:17 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Message-ID: <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Ahh. Ok. So how would I go about doing that with python? I think in perl (sorry for the naughty word) I could use the tr// (translate) but is there a quick way to do so with python? Is it going to be necessary to convert commands I SEND to the device or only convert what I receive? From gordon at panix.com Mon Nov 21 12:08:06 2011 From: gordon at panix.com (John Gordon) Date: Mon, 21 Nov 2011 17:08:06 +0000 (UTC) Subject: sqlalchemy beginner References: Message-ID: In Jabba Laci writes: > SAWarning: Unicode column received non-unicode default value. > Column('display_name', Unicode(255), default=''), Perhaps it would help to supply the default value as a Unicode string instead of a plain string? Column('display_name', Unicode(255), default=u''), -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From d at davea.name Mon Nov 21 12:11:30 2011 From: d at davea.name (Dave Angel) Date: Mon, 21 Nov 2011 12:11:30 -0500 Subject: decorators and closures In-Reply-To: <4ECA6FB1.6000701@gmail.com> References: <4ECA63D2.7080603@gmail.com> <4ECA68D8.2060608@davea.name> <4ECA6FB1.6000701@gmail.com> Message-ID: <4ECA8642.7060908@davea.name> On 11/21/2011 10:35 AM, Andrea Crotti wrote: > On 11/21/2011 03:06 PM, Dave Angel wrote: >> Your function 'nested' isn't nested, 'fun' is. What you discovered is >> that a decorator is always executed, every time a nested decorated >> function is defined. >> >> You've also ust proved that it would be an incompatible change. >> Doesn't that answer the question? An optimizer that changes the >> behavior isn't usually desirable. >> > Yes sure I think it makes perfectly sense, because you actually redefine > a local variable every time.. > > Another thing (which was also the reason of the subject), I tried to > disassemble the following: > def dec(fn): > def _dec(): > fn() > > return _dec > > @dec > def fun(): > print("here") > > fun() > > And I get this: > In [29]: dis.dis(test_decorate) > Disassembly of dec: > 2 0 LOAD_CLOSURE 0 (fn) > 3 BUILD_TUPLE 1 > 6 LOAD_CONST 1 ( line 2>) > 9 MAKE_CLOSURE 0 > 12 STORE_FAST 1 (_dec) > > 5 15 LOAD_FAST 1 (_dec) > 18 RETURN_VALUE > > Disassembly of fun: > 3 0 LOAD_DEREF 0 (fn) > 3 CALL_FUNCTION 0 > 6 POP_TOP > 7 LOAD_CONST 0 (None) > 10 RETURN_VALUE > > > Looking up the definition of the single calls didn't help much, so why > do we need > for example MAKE_CLOSURE? > Is MAKE_CLOSURE just more generic maybe? > You didn't mention what version of Python you're running. With Python 2, I got very different results. So I switched to Python 3.2, and I still don't get exactly what you have. A closure is needed if there's some non-global data outside the function definition (code object) that's needed by the function object. As you supply the code I don't need a closure. But if I add a local variable in test_decorate(), and refer to it in dec(), then I get one. Not the same as yours. You left out the import and the definition line for test_decorate. Did you leave anything else? And what version of Python are you using? Are you perhaps running in a shell, as opposed to running code directly from a source file? -- DaveA From andrea.crotti.0 at gmail.com Mon Nov 21 12:12:03 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 21 Nov 2011 17:12:03 +0000 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: <4ECA8663.2070706@gmail.com> On 11/21/2011 04:39 PM, W. eWatson wrote: > ... > I'm using Win 7 Premium. > > So unless some brilliant idea appears, that leaves me with the choice > of not using Python or this suggestion... (Let's not get off into > other variations of other "Pythons" like Active..."): > > Someone suggested using the mail list at > . What's > different about that list than this NG? Does the "org" suggest that > the inhabitants of that list are more likely associated with the > people who are responsible for constructing Python? > > Comments? I only see windows and users-related problems, not much having to do with Python actually. Moreover, nothing forces you to use it, and with this attitude is not bad that you stay way from it, no offense of course. From andrea.crotti.0 at gmail.com Mon Nov 21 12:17:12 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 21 Nov 2011 17:17:12 +0000 Subject: decorators and closures In-Reply-To: <4ECA8642.7060908@davea.name> References: <4ECA63D2.7080603@gmail.com> <4ECA68D8.2060608@davea.name> <4ECA6FB1.6000701@gmail.com> <4ECA8642.7060908@davea.name> Message-ID: <4ECA8798.6060906@gmail.com> On 11/21/2011 05:11 PM, Dave Angel wrote: > > You didn't mention what version of Python you're running. With Python > 2, I got very different results. So I switched to Python 3.2, and I > still don't get exactly what you have. > > A closure is needed if there's some non-global data outside the > function definition (code object) that's needed by the function > object. As you supply the code I don't need a closure. But if I add > a local variable in test_decorate(), and refer to it in dec(), then I > get one. Not the same as yours. > > You left out the import and the definition line for test_decorate. > Did you leave anything else? And what version of Python are you > using? Are you perhaps running in a shell, as opposed to running code > directly from a source file? I use python 2.7, and actually the whole source is this (test_decorate.py): def dec(fn): def _dec(): fn() return _dec @dec def fun(): print("here") fun() Using ipython: import test_decorate dis.dis(test_decorate) From fraveydank at gmail.com Mon Nov 21 12:22:28 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 12:22:28 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Message-ID: <0BC69704-0205-4D1E-B2BA-06DB2783F31D@gmail.com> On Nov 21, 2011, at 11:52 AM, Matthew Lenz wrote: > Ahh. Ok. So how would I go about doing that with python? I think in perl (sorry for the naughty word) I could use the tr// (translate) but is there a quick way to do so with python? Is it going to be necessary to convert commands I SEND to the device or only convert what I receive? The high-level overview is that you'll want to OR in 0x80 on transmit, and AND 0x7F on receive (thus inserting the high bit when you send it out and removing it when you receive). If you wanted to be extra-sure you're receiving things correctly, you should also check to see if your value ANDed with 0x80 is not zero. In Python 2.x, as mentioned, when you iterate over a string, you get a bunch of tiny one-character strings, which you then need to convert into numbers with ord() and back into strings with chr() when you re-concatenate it. ord() and chr() may be familiar to you from Perl. For example, you could do this on reception: ---- # However you get your data out of serial received_str = receive_my_string() ord_str = [ord(x) for x in received_str] # An exception may be extreme in this case, but hey. Note that # the filter() function actually returns a list of all the # characters that don't have the high bit set, so you could # actually use that if you wanted to. if filter((lambda x: x < 0x80), ord_str): raise IOError("Received character without mark parity") return "".join([chr(x & 0x7F) for x in received_str]) ---- In Python 3.x, iterating over a bytes array (which is, hopefully, what your serial interface returns) will give you a bunch of ints, so you shouldn't need to do the conversions: ---- # However you get your data out of serial received_bytes = receive_my_string() # In Python 3.x, filter() returns an iterator, which is generally a # better thing to return, but doesn't test as nicely for a bool. for b in received_bytes: if b < 0x80: raise IOError("Received character without mark parity") # None of this "".join() nonsense with byte arrays! return bytes([(x & 0x7F) for x in received_bytes]) ---- There are surely more efficient ways to do what I've typed up there, but those should work pretty well for whatever you're looking to do. For sending, you pretty much want to swap (x & 0x7F) with (x | 0x80) to insert that high bit. - Dave From gheskett at wdtv.com Mon Nov 21 12:25:54 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 21 Nov 2011 12:25:54 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <5074B814-C5A1-4B42-8F89-3B7406C91F49@gmail.com> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <5074B814-C5A1-4B42-8F89-3B7406C91F49@gmail.com> Message-ID: <201111211225.54775.gheskett@wdtv.com> On Monday, November 21, 2011 11:58:53 AM David Riley did opine: > On Nov 21, 2011, at 11:28 AM, Matthew Lenz wrote: > > Using 8N1 under minicom with this device resulted in garbled text when > > once connected. Connection using 7M1 resulted in the correct text. > > So there must be something else that needs to be done in my python > > program correct? > > Under minicom in 8N1, it's going to look garbled because the high bit > will always be set. Minicom will try to spit out those characters > anyway, which will print out whatever extended ASCII garbage your > terminal supports in the 0x80-0xFF range. Programmatically, though, you > can strip off the high bit when you're receiving it in Python. I have been using 8n1 in minicom for years, never ever had such a problem. In fact, I don't even know if I can set the path to mark parity as it is so rarely used. E or O as error detectors are much more commonly used. Example copy/paste from minicom, talking to a trs-80 Color Computer 3 running a shell under nitros9, which is a bit like unix. I am asking it for the settings of its own output path, .1=stdout: {t2|07}/DD/NITROS9/dw3install/6309L2/SCRIPTS:tmode .1 /t2 upc=00 bso=01 dlo=00 eko=01 alf=01 nul=00 pau=01 pag=18 bsp=08 del=18 eor=0D eof=1B rpr=09 dup=01 psc=17 int=03 qut=05 bse=08 ovf=07 par=01 bau=06 xon=00 xof=00 {t2|07}/DD/NITROS9/dw3install/6309L2/SCRIPTS: And that is 9600 baud 8n1 on both ends. Ascii is normally 7 bit and will have a low 8th bit if fed normal ascii data, so how is the 8th bit getting set other than purposely setting 7M1 on the other end of the cable? > "Space" parity, on the other hand, should look normal under Minicom > because the high bit will always be low, giving you standard 7-bit > ASCII. > Yes. > - Dave Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Everything is controlled by a small evil group to which, unfortunately, no one we know belongs. From fraveydank at gmail.com Mon Nov 21 12:50:17 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 12:50:17 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <201111211225.54775.gheskett@wdtv.com> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <5074B814-C5A1-4B42-8F89-3B7406C91F49@gmail.com> <201111211225.54775.gheskett@wdtv.com> Message-ID: <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> On Nov 21, 2011, at 12:25 PM, gene heskett wrote: > And that is 9600 baud 8n1 on both ends. Ascii is normally 7 bit and will > have a low 8th bit if fed normal ascii data, so how is the 8th bit getting > set other than purposely setting 7M1 on the other end of the cable? That's what I thought the OP was doing; it sounds like he's trying to receive 7M1 in Minicom using 8N1 on the terminal and getting garbled data because the high bit is set (because the other end is sending 7M1). I never meant to imply that 8N1 would give garbled data if both ends were set to it; indeed, that's pretty much standard communications settings for short cables in low to moderate noise environments. If anyone else read it that way, that's not what I meant. :-) - Dave From cousinstanley at gmail.com Mon Nov 21 12:52:52 2011 From: cousinstanley at gmail.com (Cousin Stanley) Date: Mon, 21 Nov 2011 17:52:52 +0000 (UTC) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: Message-ID: W. eWatson wrote: > My criterion for success is that it puts IDLE as a choice for editor > on the menu produced with a right-click on a py file. > > So far no response on this has solved the problem. > .... As an alternative you might consider adding a short-cut to IDLE to the Send To directory if that option is still available under windows 7 .... That would seem almost as handy only moving the mouse one more time to roll out the Send To target menu before the final click to launch .... -- Stanley C. Kitching Human Being Phoenix, Arizona From mcepl at redhat.com Mon Nov 21 12:55:30 2011 From: mcepl at redhat.com (=?UTF-8?B?TWF0xJtqIENlcGw=?=) Date: Mon, 21 Nov 2011 18:55:30 +0100 Subject: [ANN] json_diff 0.9.2 released - JSON files comparator In-Reply-To: References: Message-ID: <4ECA9092.90906@redhat.com> I released json_diff 0.9.2. http://pypi.python.org/pypi/json_diff json_diff is an utility comparing two JSON files and generating diff in form of another JSON file with differences for each level of the object in a dict { "_append": {}, "_remove": {}, "_update": {} } This is the first public release, working my way towards 1.0 release. Development repository is at https://gitorious.org/json_diff, patches and pull requests welcome! -- http://www.ceplovi.cz/matej/, Jabber: mceplceplovi.cz GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC Basically, the only ?intuitive? interface is the nipple. After that, it's all learned. -- Bruce Ediger when discussing intuivity of Mac OS http://groups.google.com/group/comp.sys.next.advocacy\ /msg/7fa8c580900353d0 From ian.g.kelly at gmail.com Mon Nov 21 12:58:58 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 21 Nov 2011 10:58:58 -0700 Subject: How to Get Data from DictReader for CSV Files In-Reply-To: References: Message-ID: The point of DictReader is that it produces dicts. If you actually want a sequence, then use an ordinary csv.reader instead. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew at nocturnal.org Mon Nov 21 12:59:47 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 09:59:47 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Message-ID: <5536811.2361.1321898387975.JavaMail.geo-discussion-forums@yqcm23> Thanks, this will be a great help. Just wanted to confirm that you meant to use [ .. for x in ord_str] in the example conversion? Got a TypeError using the received_str. From matthew at nocturnal.org Mon Nov 21 12:59:47 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 09:59:47 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Message-ID: <5536811.2361.1321898387975.JavaMail.geo-discussion-forums@yqcm23> Thanks, this will be a great help. Just wanted to confirm that you meant to use [ .. for x in ord_str] in the example conversion? Got a TypeError using the received_str. From fraveydank at gmail.com Mon Nov 21 13:12:50 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 13:12:50 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <5536811.2361.1321898387975.JavaMail.geo-discussion-forums@yqcm23> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> <5536811.2361.1321898387975.JavaMail.geo-discussion-forums@yqcm23> Message-ID: On Nov 21, 2011, at 12:59 PM, Matthew Lenz wrote: > Thanks, this will be a great help. > > Just wanted to confirm that you meant to use [ .. for x in ord_str] in the example conversion? Got a TypeError using the received_str. Yes, I probably should have double-checked that. ord_str is indeed what I meant. :-) - Dave From python at mrabarnett.plus.com Mon Nov 21 13:20:01 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 21 Nov 2011 18:20:01 +0000 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Message-ID: <4ECA9651.8020809@mrabarnett.plus.com> On 21/11/2011 16:52, Matthew Lenz wrote: > Ahh. Ok. So how would I go about doing that with python? I think in > perl (sorry for the naughty word) I could use the tr// (translate) > but is there a quick way to do so with python? Is it going to be > necessary to convert commands I SEND to the device or only convert > what I receive? Python strings have a .translate method: # Example in Python 2 import string # From top bit set... from_chars = "".join(chr(c | 0x80) for c in range(0x7F)) # ...to top bit clear. to_chars = "".join(chr(c) for c in range(0x7F)) # Build the translation table. force_clear = string.maketrans(from_chars, to_chars) s = "\x41\xC1" print s print s.translate(force_clear) From gheskett at wdtv.com Mon Nov 21 13:33:17 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 21 Nov 2011 13:33:17 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> Message-ID: <201111211333.17806.gheskett@wdtv.com> On Monday, November 21, 2011 01:28:16 PM David Riley did opine: > On Nov 21, 2011, at 12:25 PM, gene heskett wrote: > > And that is 9600 baud 8n1 on both ends. Ascii is normally 7 bit and > > will have a low 8th bit if fed normal ascii data, so how is the 8th > > bit getting set other than purposely setting 7M1 on the other end of > > the cable? > > That's what I thought the OP was doing; it sounds like he's trying to > receive 7M1 in Minicom using 8N1 on the terminal and getting garbled > data because the high bit is set (because the other end is sending > 7M1). I never meant to imply that 8N1 would give garbled data if both > ends were set to it; indeed, that's pretty much standard communications > settings for short cables in low to moderate noise environments. If > anyone else read it that way, that's not what I meant. :-) > > - Dave I think that getting the other end off 7M1 was what I was saying. Trying to attack the bad data after capture by writing code always seems extremely masochistic to me. The amount of miss-understanding that seems to pervade rs-232 communications is mind boggling at times. The tech itself is so old it is being forgotten! Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Whatever occurs from love is always beyond good and evil. -- Friedrich Nietzsche From fetchinson at googlemail.com Mon Nov 21 13:33:44 2011 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 21 Nov 2011 19:33:44 +0100 Subject: SQLObject 1.2.0 In-Reply-To: <20111120121940.GC24874@iskra.aviel.ru> References: <20111120121940.GC24874@iskra.aviel.ru> Message-ID: Thanks a million Oleg! Cheers, Daniel On 11/20/11, Oleg Broytman wrote: > Hello! > > I'm pleased to announce version 1.2.0, the first stable release of branch > 1.2 of SQLObject. > > > What is SQLObject > ================= > > SQLObject is an object-relational mapper. Your database tables are > described > as classes, and rows are instances of those classes. SQLObject is meant to > be > easy to use and quick to get started with. > > SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, > Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). > > > Where is SQLObject > ================== > > Site: > http://sqlobject.org > > Development: > http://sqlobject.org/devel/ > > Mailing list: > https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss > > Archives: > http://news.gmane.org/gmane.comp.python.sqlobject > > Download: > http://pypi.python.org/pypi/SQLObject/1.2.0 > > News and changes: > http://sqlobject.org/News.html > > > What's New > ========== > > Features & Interface > -------------------- > > * Strings are treated specially in Select to allow > Select(['id, 'name'], where='value = 42'). Update allows a string in > WHERE. > > * ForeignKey('Table', refColumn='refcol_id') to allow ForeignKey to > point to a non-id column; the referred column must be a unique integer > column. > > * delColumn now accepts a ForeignKey's name without 'ID'. > > * Support for PostgreSQL 7.* is dropped. The minimal supported version of > PostgreSQL is 8.1 now. > > * Quoting rules changed for PostgreSQL: SQLObject uses E'' escape string > if the string contains characters escaped with backslash. > > * A bug caused by psycopg2 recently added a new boolean not callable > autocommit attribute was fixed. > > * sqlobject.__doc__ and main.__doc__ no longer contain version number. > Use sqlobject.version or version_info. > > For a more complete list, please see the news: > http://sqlobject.org/News.html > > Oleg. > -- > Oleg Broytman http://phdru.name/ phd at phdru.name > Programmers don't die, they just GOSUB without RETURN. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From python.list at tim.thechases.com Mon Nov 21 13:36:14 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 21 Nov 2011 12:36:14 -0600 Subject: How to: Coordinate DictReader and Reader for CSV In-Reply-To: <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> <9iv3q7F1t5U1@mid.individual.net> <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> Message-ID: <4ECA9A1E.1060100@tim.thechases.com> On 11/21/11 09:16, ray wrote: > Is there a way to capture the keys outside of the for loop so > when the for loop is entered, only data is extracted? I frequently do this for things like tweaking headers (stripping space, normalizing case, etc because clients love to send us messy data): def norm_header(h): return h.strip().upper() def norm_item(i): return i.strip() f = file("example.csv", "rb") try: r = csv.reader(f) headers = r.next() header_map = dict( (norm_header(h), i) for i, h in enumerate(headers) ) for row in r: item = lambda h: norm_item(row[header_map[norm_header(h)]]) value1 = item("Item1") value2 = item("ITEM3") ... finally: f.close() Should work in 2.x, possibly in 3.x (though you might need to change from "headers = r.next()" to "headers = next(r)") -tkc From illy at otekno.biz Mon Nov 21 14:21:16 2011 From: illy at otekno.biz (Illy) Date: Tue, 22 Nov 2011 02:21:16 +0700 Subject: SetStatusText of MDIParentFrame from MDIChildFrame Message-ID: <4ECAA4AC.6040803@otekno.biz> Dear my friends.... I am stucked on a problem: I can't call a function of MDIParentFrame from MDIChildFrame: myturnonmenu and mystatusbar.SetStatusText() Anybody would be so nice for telling me my mistakes? Please do me a favor. Thank you very much in advance. I created 3 files contain this sourcecode: ceo at mefi:~/sementara/tes$ ls jendelapos.py jendelapos.pyc myMDIChildFrameforLogin.py myMDIChildFrameforLogin.pyc myMDIFrame.py ceo at mefi:~/sementara/tes$ =========================================== ceo at mefi:~/sementara/tes$ cat myMDIFrame.py #!/usr/bin/env python import wx import os import jendelapos import myMDIChildFrameforLogin class myMDIParentFrame (wx.MDIParentFrame): def __init__(self): global mystatusbar, menuakuntan wx.MDIParentFrame.__init__(self, None, -1, "This is myMDIParentFrame", size=(1020,800)) mystatusbar = self.CreateStatusBar() mystatusbar.SetStatusText("This is the StatusBar I want to put my message for the users in it") menuakuntan = wx.Menu() menuakuntan.Append(1000, "Accounting - POS (&Point of Sale)") menuaplikasi = wx.Menu() menuaplikasi.Append(20000, "&Login") menuaplikasi.Append(20001, "E&xit") menubar = wx.MenuBar() menubar.Append(menuakuntan, "&Accounting") menubar.Append(menuaplikasi, "A&pplication") myturnoffmenu(self) self.SetMenuBar(menubar) self.Bind (wx.EVT_MENU, self.jendelapos, id=1000) self.Bind (wx.EVT_MENU, self.myMDIChildFrameforLogin, id=20000) self.Bind (wx.EVT_MENU, self.OnExit, id=20001) def OnExit(self, evt): self.Close(True) jendelapos = jendelapos.Show myMDIChildFrameforLogin = myMDIChildFrameforLogin.Show def myturnoffmenu(self): menuakuntan.Enable(1000, False) def myturnonmenu(self): menuakuntan.Enable(1000, True) if __name__ == '__main__': app = wx.PySimpleApp() myMDIFrame = myMDIParentFrame() myMDIFrame.Show() app.MainLoop() ceo at mefi:~/sementara/tes$ ================================================= ceo at mefi:~/sementara/tes$ cat ./myMDIChildFrameforLogin.py import wx def Show(self, evt): global pengguna, katakunci, jendela jendela = wx.MDIChildFrame(self, -1, "Login Form", style= wx.DEFAULT_FRAME_STYLE | wx.HSCROLL | wx.VSCROLL) mystatusbar.SetStatusText("Login succeeded") myturnonmenu() jendela.Show(True) ceo at mefi:~/sementara/tes$ ================================================= ceo at mefi:~/sementara/tes$ cat jendelapos.py import wx def Show (self, evt): win = wx.MDIChildFrame(self, -1, "Accounting - POS") win.Show(True) ceo at mefi:~/sementara/tes$ ================================================= From matthew at nocturnal.org Mon Nov 21 14:29:24 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 11:29:24 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> Message-ID: <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Another thing I noticed is that the & and | appear to give the same result as adding or subtracting 128 from the ordinal value. I'm assuming that isn't coincidence. :) From matthew at nocturnal.org Mon Nov 21 14:29:24 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 11:29:24 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> Message-ID: <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Another thing I noticed is that the & and | appear to give the same result as adding or subtracting 128 from the ordinal value. I'm assuming that isn't coincidence. :) From invalid at invalid.invalid Mon Nov 21 14:42:35 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Nov 2011 19:42:35 +0000 (UTC) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> Message-ID: On 2011-11-21, Matthew Lenz wrote: > Another thing I noticed is that the & and | appear to give the same > result as adding or subtracting 128 from the ordinal value. Nope, that's only true for some values. If we're limiting ourselves to byte values, then we're talking modulo-256 arithmetic, so: 128 + 128 = 0 128 | 128 = 128 0 - 128 = 128 0 & 0x7f = 0 What's is true is that adding 128 is actullay the same as subtracting 128, and both are the same as exclusive-or 128 (v ^ 128): >>> x = 128 >>> (x + 128) & 0xff 0 >>> (x - 128) & 0xff 0 >>> (x ^ 128) & 0xff 0 >>> x = 0 >>> (x + 128) & 0xff 128 >>> (x - 128) & 0xff 128 >>> (x ^ 128) & 0xff 128 > I'm assuming that isn't coincidence. :) Well, the weighting of the high-order bit in an 8-bit wide binary number is 128, if that's what you're getting at... -- Grant Edwards grant.b.edwards Yow! How's it going in at those MODULAR LOVE UNITS?? gmail.com From fraveydank at gmail.com Mon Nov 21 15:42:23 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 15:42:23 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <38BF659E-38D4-4516-9F22-3C0F7F992828@gmail.com> On Nov 21, 2011, at 2:29 PM, Matthew Lenz wrote: > Another thing I noticed is that the & and | appear to give the same result as adding or subtracting 128 from the ordinal value. I'm assuming that isn't coincidence. :) It's not, though the difference is important. They're binary ANDs (&) and ORs (|), so (0x0F | 0x80) = 0x8F, but (0x8F | 0x80) = 0x8F as well, whereas (0x8F + 0x80) = 0x10F. For manipulating bit values (which is what you're doing, you should almost never be adding or subtracting, but rather ANDing and ORing (or XORing, but not nearly as often). Just in case you're not familiar, 0x is the prefix for a hexadecimal number. 0x80 = 128, which is binary 10000000 (i.e. the high bit in a byte). - Dave From phihag at phihag.de Mon Nov 21 16:14:17 2011 From: phihag at phihag.de (Philipp Hagemeister) Date: Mon, 21 Nov 2011 22:14:17 +0100 Subject: youtube-dl: way to deal with the size cap issue + new errors + issues ... In-Reply-To: <1321124792.454176@nntp.aceinnovative.com> References: <1321124792.454176@nntp.aceinnovative.com> Message-ID: <4ECABF29.1030805@phihag.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 As a general rule, feel free to contact youtube-dl developers and users at https://github.com/rg3/youtube-dl/issues/ . youtube-dl is just one application, which happens to be written in Python. lbrt at mail.python.org wrote: > I did find my way (through a silly hack) to get all files within a size range without waiting for youtube-dl to be "enhanced". You may be able to send a HEAD request to the URL, but there's no guarantee the response will contain a Content-Length header. In fact, there will never be a Content-Lenght header for infinite HTTP streams. Also, RTMP URLs are way more complicated. > I have also been getting errors reporting: > RTMP download detected but "rtmpdump" could not be run You need rtmpdump. See http://rtmpdump.mplayerhq.hu/ for instructions on how to install it. > It would be very helpful if you could redirect youtube-dl errors to a separate file you would indicate via a flag If you think so, please open an issue. Do not forget to consider the usefulness not only for your specific application, but also of other applications. I think the command-line API (https://github.com/rg3/youtube-dl/issues/152) will be your best shot. Note that you can already redirect youtube-dl's output to a file, just like any other shell program: $ youtube-dl uHlDtZ6Oc3s > log will write a file log that contains all of youtube-dl's output. If the return code is not 0, an error has occured. Cheers, Philipp youtube-dl developer -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEAREKAAYFAk7KvygACgkQ9eq1gvr7CFw6GwCfeaF0TPNonTCaXVBDnmDBPio2 qVQAn2/JQzTbBYs+pe50t4qVCjxY+BLy =o6uC -----END PGP SIGNATURE----- From questions.anon at gmail.com Mon Nov 21 16:42:25 2011 From: questions.anon at gmail.com (questions anon) Date: Tue, 22 Nov 2011 08:42:25 +1100 Subject: mask one array using another array Message-ID: I am trying to mask one array using another array. I have created a masked array using mask=MA.masked_equal(myarray,0), that looks something like: [1 - - 1, 1 1 - 1, 1 1 1 1, - 1 - 1] I have an array of values that I want to mask whereever my mask has a a '-'. how do I do this? I have looked at http://www.cawcr.gov.au/bmrc/climdyn/staff/lih/pubs/docs/masks.pdf but the command: d = array(a, mask=c.mask() results in this error: TypeError: 'numpy.ndarray' object is not callable I basically want to do exactly what that article does in that equation. Any feedback will be greatly appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Mon Nov 21 16:48:37 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Nov 2011 16:48:37 -0500 Subject: Close as Many Files/External resourcs as possible in the face of exceptions In-Reply-To: References: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> Message-ID: On 11/21/2011 7:09 AM, Mel Wilson wrote: > GZ wrote: >> Here is my situation. A parent object owns a list of files (or other >> objects with a close() method). The close() method can sometimes fail >> and raise an exception. When the parent object's close() method is >> called, it needs to close down as many files it owns as possible, even >> if the close() function of some files fail. I also want to re-raise at >> least one of the original exceptions so that the outer program can >> handle it. > [ ... ] >> >> It will re-raise the first exception and preserve the context and >> close as many other files as possible while ignoring any further >> exceptions. >> >> But this looks really awkward. And in the case that two files fail to >> close, I am not sure the best strategy is to ignore the second failure. > > I imagine you could save any caught exception instances in a list and > study them later. Yes, I would raise a custom exception instance that takes such a list of failures in its constructor. Give it a custom __str__ method to display them all. -- Terry Jan Reedy From ameyer2 at yahoo.com Mon Nov 21 17:43:38 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 21 Nov 2011 17:43:38 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4ECAD41A.9070405@yahoo.com> On 11/17/2011 3:43 PM, Chris Angelico wrote: > ... > If you're having issues, grab a spare computer, throw Linux on it (I > recommend Ubuntu or Debian, others will have other preferred distros), > and see if the issues remain. Or if you're having trouble with the > GUI, try things from the command line (Windows's command interpreter > is pretty weak compared to bash, but it's plenty powerful enough). > > ChrisA If the OP is having trouble with this issue, and if he can't make Windows work here, I suspect that he'll get into trouble trying to install and test with Linux. However if he did want to try it, and assuming he's got 8GB or so of extra space, one easy way to test with Linux is to install VirtualBox, then install Linux under that. I've done that a half dozen times without hiccups. That way he doesn't need a second machine and doesn't need to repartition or toss his old OS. Alan From tjreedy at udel.edu Mon Nov 21 18:07:47 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Nov 2011 18:07:47 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: On 11/21/2011 11:39 AM, W. eWatson wrote: > > My criterion for success is that it puts IDLE as a choice for editor on > the menu produced with a right-click on a py file. Your first criterion for success should be that IDLE runs at all, which is apparently does not. How you run it is secondary. Right-click responses are controlled by Windows using data in the registry. Windows modifies the registry in response to installers *and users*. The ActiveState installers request 'Edit with PythonWin'. They do not request 'Edit with IDLE' and it is foolish to complain to us when you use ActiveState and get their choice of context choices. The PSF .msi installers (.msi = MicroSoftInstall format) from python.org request 'Edit with IDLE' but cannot make Windows put it in. If your registry is messed up enough, it does not happen. But no error message. I have explained to you another way to work with IDLE once it runs. It you refuse to use it, that is your problem, not ours. > I know it sets up that way on a 2.5 and 2.4 on other PCs I have. You installed with the PSF installer with an ok registry. > I know at one time it worked on my 64-bit Win 7 PC, which likely had a > 32-bit version installed on it. After something like six months of > modest use it stopped working as above. No IDLE choice. So some *other* program messed things up. Stop blaming us. Heavy or modest use in the meantime is irrelevant. > I know by installing a 64-bit version, 3.2.2 failed the IDLE criterions > as described. No IDLE. Did you uninstall the 32 bit version, and best, all Python versions? > I do know that IDLE appears on the Win 7 Start menu, but, when used, > nothing happens. Well, OK, for about 3 seconds the Win 7 "working" icon > spins around then zip, nothing. This is your real problem. Stop worrying about the context menu. > Further, right-clicking on Properties of > IDLE (GUI) produces a tabbed dialog. It shows Start in: c:\Python32\, This is the Shortcut tab. A shortcut is like a bound method. The function is the target: 'python 3.2.2 (64 bit)' on my machine. The starting directory is like a bound argument, although it is passed to the launcher that launches the function. What the Properties dialog does not show are the actual 'bound arguments' that are passed to the target as options. So one cannot know what the shortcut is actually trying to do. This is one of the Really Stupid things about Windows that should have been fixed long ago but has not. > and None for shortcut. None for Shortcut key, such as alt-I to invoke the shortcut. > There is a compatibility tab, which I've set to > Win7. I think there's a troubleshooter there too, but I haven't used it. > Under the Details tab, it shows Name: IDLE(Python Gui).lnk. Folder Path > as: c:\ProgramData\Microsoft\Windows\Start... Nothing after the "...". Details: Folder Path is the same as General: Location. Mouse over the latter the the full path appears. That Properties windows are still fixed at 480 pixel wide, regardless of screen size, is another Really Stupid thing. > Going directly to ...\Lib\idlelib\idle.pyw produces the spinning icon. > At least, that's what happens in 3.2.2, but in the 32-bit versions I > tried, I would get "invalid Win 32 app". If the registry entry for .pyw is messed up, trying to run the file by clicking on it is not likely to work. Try running from Command Prompt, as I believe others suggested. > When I rebooted my system a few hours after installing 3.2.2, because > the PC was running really slowly--not because of Python, I was greeted > by a couple of interesting messages as the desktop was populated. > > I can execute Python from the command line. > > 1. Specified module could not be found: Load Lib, python.dll. > > 2. \ProgramFiles(x86)\uniblueDrivers\Scanner (x86) Python26.dll. The uniblue drivers program will match your drivers against a database of up-to-date drivers and offer to upgrade them. I have used uniblue's registry scanner program. Treating pythonxy.dll as a driver, if they are, is an error. These are paid programs. The free demos only scan to tell you what they would do if you bought them. > I'm sure this is related to Winamp, which I had installed a month ago. I do not believe they are the same companies, but they may have a cross-promotion deal. > had some "crazy" choice to scan for new drivers. Of course, if it found > one-connected with Python, and if you wanted it, $$$. I think this > message is a red herring. I may re-install Winamp to get rid of that > uniblue tool that seems like nothing more than an ad. > > Some have suggested a registry problem, but I don't have a clue how to > play with that, or somehow clean it up, if there is a problem. My PC > behaves normally If you ran the psf 3.2.2 installer and idle does not run when you click the start menu shortcut, something is wrong. > Someone suggested using the mail list at > . What's different > about that list than this NG? Does the "org" suggest that the > inhabitants of that list are more likely associated with the people who > are responsible for constructing Python? Python list is mirror to comp.lang.python which is mirrored to a google group. It is also mirrored to gmane.comp.python, which is how I read and post. There is some spam filtering if you use the python.org list or gmane group. -- Terry Jan Reedy From invalid at invalid.invalid Mon Nov 21 18:08:12 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Nov 2011 23:08:12 +0000 (UTC) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On 2011-11-21, David Riley wrote: > On Nov 21, 2011, at 2:29 PM, Matthew Lenz wrote: > >> Another thing I noticed is that the & and | appear to give the same result as adding or subtracting 128 from the ordinal value. I'm assuming that isn't coincidence. :) > > It's not, though the difference is important. They're binary ANDs (&) and ORs (|), so (0x0F | 0x80) = 0x8F, but (0x8F | 0x80) = 0x8F as well, whereas (0x8F + 0x80) = 0x10F. For manipulating bit values (which is what you're doing, you should almost never be adding or subtracting, but rather ANDing and ORing (or XORing, but not nearly as often). > > Just in case you're not familiar, 0x is the prefix for a hexadecimal number. 0x80 = 128, which is binary 10000000 (i.e. the high bit in a byte). Like the old joke: There are 10 kinds of people in the world: those who understand binary numbers, and those who don't. -- Grant Edwards grant.b.edwards Yow! ... I don't like FRANK at SINATRA or his CHILDREN. gmail.com From invalid at invalid.invalid Mon Nov 21 18:09:44 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Nov 2011 23:09:44 +0000 (UTC) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On 2011-11-21, Grant Edwards wrote: > Like the old joke: > > There are 10 kinds of people in the world: those who understand > binary numbers, and those who don't. OK, it's not _much_ of a joke, but I don't get to use it very often, so I couldn't let it go (for one thing, it only works in "print"). -- Grant Edwards grant.b.edwards Yow! I feel like I am at sharing a ``CORN-DOG'' gmail.com with NIKITA KHRUSCHEV ... From chasrmartin at gmail.com Mon Nov 21 18:17:05 2011 From: chasrmartin at gmail.com (Charlie Martin) Date: Mon, 21 Nov 2011 15:17:05 -0800 (PST) Subject: Peculiarity of '@' in logging.Formatter Message-ID: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> This is what seems like an odd bug, but in code I'd thing often-enough used it must be the expected behavior and I just don't understand. Please, sirs/mesdames, is this a bug? Example code: ---------------- begin code ------------------- #!/usr/bin/env python """ @-character WTF? """ import sys import os import logging, logging.handlers import socket log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) fmtColon = logging.Formatter('[%(module)s:%(lineno)03d]:%(message)s') strC = logging.handlers.SysLogHandler(address='/dev/log') strC.setFormatter(fmtColon) strC.setLevel(logging.DEBUG) log.addHandler(strC) fmtAt = logging.Formatter('[%(module)s@%(lineno)03d]:%(message)s') strA = logging.handlers.SysLogHandler(address='/dev/log') strA.setFormatter(fmtAt) strA.setLevel(logging.DEBUG) log.addHandler(strA) log.info("My log message:isn't it special?") ---------------- end code ---------------- produces these entries in the syslog messages: ---------------- begin results ---------------------- Nov 21 16:09:56 crmartin [atSign: 026]:My log message:isn't it special? Nov 21 16:09:56 crmartin [atSign at 026]: My log message:isn't it special? ---------------- end results ------------------------ Observe: * in the first entry, "[atSign: 026]:My" with space after the first ":"; that space isn't in the format string. * in the second entry "[atSign at 026]: My" again has an additional space after the first ":" the colons following are unchanged. This **seems** like it must be some obscure bug, but perhaps it's some undocumented feature? From chasrmartin at gmail.com Mon Nov 21 18:19:28 2011 From: chasrmartin at gmail.com (Charlie Martin) Date: Mon, 21 Nov 2011 15:19:28 -0800 (PST) Subject: Peculiarity of '@' in logging.Formatter In-Reply-To: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> References: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <10658976.1704.1321917568761.JavaMail.geo-discussion-forums@yqni5> Oops, forgot the python version etc: bash $ /usr/bin/env python -V Python 2.7 On SuSE 11.4 bash $ uname -a Linux crmartin 2.6.37.6-0.9-desktop #1 SMP PREEMPT 2011-10-19 22:33:27 +0200 x86_64 x86_64 x86_64 GNU/Linux From jehugaleahsa at gmail.com Mon Nov 21 19:07:45 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 21 Nov 2011 16:07:45 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4ec9e558$0$29997$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3c8fa8-c792-4afc-8e69-ef65538e5121@w1g2000vba.googlegroups.com> On Nov 21, 12:44?am, Steven D'Aprano wrote: > On Mon, 21 Nov 2011 13:33:21 +1100, Chris Angelico wrote: > > What's your language's "special feature"? I like to keep track of > > languages using a "slug" - a simple one-sentence (or less) statement of > > when it's right to use this language above others. For example, Python > > is optimized for 'rapid deployment'. > > "Python will save the world" > > http://proyectojuanchacon.blogspot.com/2010/07/saving-world-with-pyth... > > -- > Steven The language, psuedo name Unit, will be a low-level language capable of replacing C in most contexts. However, it will have integrated functional programming features (tail-end recursion optimization, tuples, currying, closures, function objects, etc.) and dynamic features (prototypical inheritance and late binding). It is a hybrid between C#, C++, F#, Python and JavaScript. The hope is that you won't pay for features you don't use, so it will run well on embedded devices as well as on desktops - that's to be seen. I'm no master compiler builder, here. The functional code is pretty basic: let multiply = function x y: return x * y # automatic generic arguments (integer here) let double = multiply _ 2 # short-hand currying - inlined if possible let doubled = [|0..10|].Apply(double) # double zero through 10 The dynamic code is pretty simple too: dynamic Prototype = function value: self.Value = value # simulated ctor Prototype.Double = function: self.Value * 2 # self refers to instance new Prototype(5).Double() # 10 new Prototype(6).Double() # 12 dynamic x = 5 # five wrapped with a bag x.Double = function: self * 2 x.Double() # 10 dynamic y = 6 y.Double = x.Double # member sharing y.Double() #12 The language also sports OOP features like are found in Java or C#: single inheritance; multiple interface inheritance; sealed, virtual and abstract types and members; explicit inheritance; extension methods and namespaces. The coolest feature will be its generics-oriented function signatures. By default everything is generic. You apply constraints to parameters, rather than specific types. For instance: let Average = function values: where values is ICountable IIterable assert values.Count > 0 "The values list cannot be empty." throws ArgumentException returns Float64 let sum = 0 for value in values: sum += value return sum / values.Count # floating point division As you can see, the function headers can be larger than the bodies themselves. They support type constraints, assertions (argument checking), exceptions enumeration, default parameters and return type information. All of them can be left out if the type of arguments can be inferred. This will not be an overnight project. :-) From roy at panix.com Mon Nov 21 19:25:03 2011 From: roy at panix.com (Roy Smith) Date: Mon, 21 Nov 2011 19:25:03 -0500 Subject: sqlalchemy beginner References: Message-ID: In article , Jabba Laci wrote: > Hi, > > I'm reading the Essential SQLAlchemy book from O'Reilly. Everytime I've worked with SQLAlchemy, I've run away screaming in the other direction. Sure, portability is a good thing, but at what cost? From rosuav at gmail.com Mon Nov 21 19:32:30 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Nov 2011 11:32:30 +1100 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On Tue, Nov 22, 2011 at 10:09 AM, Grant Edwards wrote: > On 2011-11-21, Grant Edwards wrote: > >> Like the old joke: >> >> ? There are 10 kinds of people in the world: those who understand >> ? binary numbers, and those who don't. > > OK, it's not _much_ of a joke, but I don't get to use it very often, > so I couldn't let it go (for one thing, it only works in "print"). On a scale of 1 to 10, what is the probability that this is in binary? There's plenty of great binary jokes going around. ChrisA From python at mrabarnett.plus.com Mon Nov 21 19:48:42 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 22 Nov 2011 00:48:42 +0000 Subject: mask one array using another array In-Reply-To: References: Message-ID: <4ECAF16A.7080707@mrabarnett.plus.com> On 21/11/2011 21:42, questions anon wrote: > I am trying to mask one array using another array. > > I have created a masked array using > mask=MA.masked_equal(myarray,0), > that looks something like: > [1 - - 1, > 1 1 - 1, > 1 1 1 1, > - 1 - 1] > > I have an array of values that I want to mask whereever my mask has a a '-'. > how do I do this? > I have looked at > http://www.cawcr.gov.au/bmrc/climdyn/staff/lih/pubs/docs/masks.pdf but > the command: > > d = array(a, mask=c.mask() > > results in this error: > TypeError: 'numpy.ndarray' object is not callable > > I basically want to do exactly what that article does in that equation. > > Any feedback will be greatly appreciated. > The article is using the Numeric module, but your error says that you're using the numpy module. They're not the same. From questions.anon at gmail.com Mon Nov 21 20:37:57 2011 From: questions.anon at gmail.com (questions anon) Date: Tue, 22 Nov 2011 12:37:57 +1100 Subject: mask one array using another array In-Reply-To: <4ECAF16A.7080707@mrabarnett.plus.com> References: <4ECAF16A.7080707@mrabarnett.plus.com> Message-ID: thank you, that makes sense. I should have posted this on another list (which I have now). and the change required is: If your new array is x, you can use: numpy.ma.masked_array(x, mask=mask.mask) On Tue, Nov 22, 2011 at 11:48 AM, MRAB wrote: > On 21/11/2011 21:42, questions anon wrote: > >> I am trying to mask one array using another array. >> >> I have created a masked array using >> mask=MA.masked_equal(myarray,**0), >> that looks something like: >> [1 - - 1, >> 1 1 - 1, >> 1 1 1 1, >> - 1 - 1] >> >> I have an array of values that I want to mask whereever my mask has a a >> '-'. >> how do I do this? >> I have looked at >> http://www.cawcr.gov.au/bmrc/**climdyn/staff/lih/pubs/docs/**masks.pdfbut >> the command: >> >> d = array(a, mask=c.mask() >> >> results in this error: >> TypeError: 'numpy.ndarray' object is not callable >> >> I basically want to do exactly what that article does in that equation. >> >> Any feedback will be greatly appreciated. >> >> The article is using the Numeric module, but your error says that you're > using > the numpy module. They're not the same. > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bthate at gmail.com Mon Nov 21 21:49:28 2011 From: bthate at gmail.com (Bart Thate) Date: Mon, 21 Nov 2011 18:49:28 -0800 (PST) Subject: JSONBOT 0.80.3 RELEASED Message-ID: <29575735.33.1321930168912.JavaMail.geo-discussion-forums@yqni5> Hello world !! I released JSONBOT 0.80.3 .. the first in the 0.80 series ;] about ~~~~~ JSONBOT is a chatbot that can take commands and react to events on the network it is connected to (IRC, XMPP, WEB mostely). Push functionality is also provided (think RSS feeds to your IRC channel or XMPP conference). It is possible to program your own plugins to create custom functionality. source/docs ~~~~~~~~~~~ see http://jsonbot.org and http://jsonbot.googlecode.com make backup first ~~~~~~~~~~~~~~~~~ I added the jsb-backup program, please run this before starting the 0.80 bot. It will make a backup of your datadir into ~/jsb-backups changes ~~~~~~~ * GAE is no longer part of the standard distribution, as that is aimed at shell users as of 0.80 - use the mercurial repo if you want to use the GAE part of the bot * web console is now supported on shell - use the jsb-tornado program to launch a tornado web server bot on port 10102 * jsb-xmpp now supports OpenFire - use --openfire option to enable this * todo now uses per user databases instead of per channel - use the -c option to the todo command to show the channel todo * learn items are not global per default - use !learn-toglobal to copy local learn data to the global learndb * relay plugins has been rewritten to use bot.cfg.name as well - means that relays need to be created again * jsb-udpstripped program has been added that can be used to send udp data to the bot without the need of making config files (copy and edit it) * add fulljids = 1 to your xmpp bot config (most of the times in ~/.jsb/config/fleet/default-sxmpp/config) to enable full JID discovery in xmpp conference rooms (non anonymous) and: * lots of new plugins .. see !list ;] * lots of bug fixes - thnx everybody for reporting them * still lots of things to fix at 03:35 < jsonbot> tracker is http://code.google.com/p/jsonbot/issues/list If you find any problems or have feature request please post that on the tracker url above. Or try @botfather on #dunkbots on irc.freenode.net ;] From wuwei23 at gmail.com Mon Nov 21 21:51:00 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 21 Nov 2011 18:51:00 -0800 (PST) Subject: sqlalchemy beginner References: Message-ID: <8832ab6d-8def-45d1-92df-baac40e1c498@t36g2000prt.googlegroups.com> On Nov 22, 10:25?am, Roy Smith wrote: > Everytime I've worked with SQLAlchemy, I've run away screaming in the > other direction. ?Sure, portability is a good thing, but at what cost? I've never found SQLAlchemy to be anything but sane and approachable. It's really worth understanding _how_ it works so you can see there's no magic happening there. What cost do you see inherit in the use of SQLAlchemy? From ray at aarden.us Mon Nov 21 21:58:53 2011 From: ray at aarden.us (ray) Date: Mon, 21 Nov 2011 18:58:53 -0800 (PST) Subject: How to Get Data from DictReader for CSV Files References: <7c77f2c4-09a5-4b5d-b162-b282688c0409@n35g2000yqf.googlegroups.com> Message-ID: On Nov 21, 10:29?am, GZ wrote: > Hi, > > On Nov 21, 7:42?am, ray wrote: > > > > > > > I don't see how to get my data from the output. ?I can see the data in > > the rows but it is mixed in with the field names. ?That is, the data I > > get comes out as: > > fieldname1 : data1 , fieldname2 : data2 , etc. > > > import csv > > linelist=open( "C:/Users/me/line_list_r0.csv", "rb" ) > > csvReader= csv.DictReader( linelist, dialect='excel' ) > > for data in csvReader: > > ? ? ? ? print data > > linelist.close() > > > I want to pass this data as arrays or lists to another module such as: > > myfunction(data1, data2, data3) > > > How do I get the data I want out of the pair fieldname1 : data1? > > > Thanks, > > ray > > It returns a dict(). You can reference the fields with > data['fieldname1'], etc.- Hide quoted text - > > - Show quoted text - GZ, That works great. Thanks, ray From wuwei23 at gmail.com Mon Nov 21 22:00:46 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 21 Nov 2011 19:00:46 -0800 (PST) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: Message-ID: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> "W. eWatson" wrote: > Comments? Please don't start multiple threads on the same issue. From nytrokiss at gmail.com Mon Nov 21 22:03:06 2011 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 21 Nov 2011 22:03:06 -0500 Subject: JSONBOT 0.80.3 RELEASED In-Reply-To: <29575735.33.1321930168912.JavaMail.geo-discussion-forums@yqni5> References: <29575735.33.1321930168912.JavaMail.geo-discussion-forums@yqni5> Message-ID: Looks good I am going to plug twisted into this. On Mon, Nov 21, 2011 at 9:49 PM, Bart Thate wrote: > Hello world !! I released JSONBOT 0.80.3 .. the first in the 0.80 series ;] > > about > ~~~~~ > > JSONBOT is a chatbot that can take commands and react to events on the > network it is connected to (IRC, XMPP, WEB > mostely). Push functionality is also provided (think RSS feeds to your IRC > channel or XMPP conference). It is possible to program your own plugins to > create custom > functionality. > > source/docs > ~~~~~~~~~~~ > > see http://jsonbot.org and http://jsonbot.googlecode.com > > > make backup first > ~~~~~~~~~~~~~~~~~ > > I added the jsb-backup program, please run this before starting the 0.80 > bot. It will make a backup of your datadir into ~/jsb-backups > > changes > ~~~~~~~ > > * GAE is no longer part of the standard distribution, as that is aimed at > shell users as of 0.80 - use the mercurial repo if you want to use the GAE > part of the bot > * web console is now supported on shell - use the jsb-tornado program to > launch a tornado web server bot on port 10102 > * jsb-xmpp now supports OpenFire - use --openfire option to enable this > * todo now uses per user databases instead of per channel - use the -c > option to the todo command to show the channel todo > * learn items are not global per default - use !learn-toglobal to copy > local learn data to the global learndb > * relay plugins has been rewritten to use bot.cfg.name as well - means > that relays need to be created again > * jsb-udpstripped program has been added that can be used to send udp data > to the bot without the need of making config files (copy and edit it) > * add fulljids = 1 to your xmpp bot config (most of the times in > ~/.jsb/config/fleet/default-sxmpp/config) to enable full JID discovery in > xmpp conference rooms > (non anonymous) > > and: > > * lots of new plugins .. see !list ;] > * lots of bug fixes - thnx everybody for reporting them > * still lots of things to fix at > > 03:35 < jsonbot> tracker is http://code.google.com/p/jsonbot/issues/list > > If you find any problems or have feature request please post that on the > tracker url above. > > Or try @botfather on #dunkbots on irc.freenode.net ;] > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://www.goldwatches.com -- -------------- next part -------------- An HTML attachment was scrubbed... URL: From nytrokiss at gmail.com Mon Nov 21 22:13:57 2011 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 21 Nov 2011 22:13:57 -0500 Subject: Multiple Threads - I/O in Same File In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D407@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D407@MX34A.corp.emc.com> Message-ID: You may have some issues with disk reading as the drive heads move in different ways On Mon, Nov 21, 2011 at 8:15 AM, wrote: > Hi All,**** > > ** ** > > Just a question in general. Is it possible that we have opened one file > in r+ mode ( file1.txt ). **** > > We have 2 threads, **** > > **? **Thread1 will continuously ?only read? the file in a loop. ** > ** > > **? **Thread2 will only update the data in the file ( say a > number < 100 ). **** > > Now thread2 has called other script ( written in say Perl/Powershell using > subprocess.call() ) and those scripts are inturn updating ( only writing ) > into that file by their own file i/o mechanism.**** > > ** ** > > Is it possible by any chance? One file being shared between different > processes one is only updating and other is only reading ..? Will this work > in practical and what can be the complications ?**** > > ** ** > > ** ** > > Thanks**** > > Nikunj**** > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://www.goldwatches.com -- -------------- next part -------------- An HTML attachment was scrubbed... URL: From devplayer at gmail.com Mon Nov 21 22:16:14 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 21 Nov 2011 19:16:14 -0800 (PST) Subject: Is there any way to unimport a library References: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 20, 12:21?pm, Gelonida N wrote: > I forgot to mention, that this is at the moment more a thought > experiment, than a real need. > > At the moment I will do exactly what you suggested. I will make sure, > that always the first import fails. > > But I wanted to learn more what is possible and which potential can of > worms I would open if I wanted to unimport a library of which I'm sure > that nobody is currently referencing (or refering? Not sure about my > English here) to. Get how many references to an object: sys.getrefcount(sys) From roy at panix.com Mon Nov 21 22:18:05 2011 From: roy at panix.com (Roy Smith) Date: Mon, 21 Nov 2011 22:18:05 -0500 Subject: sqlalchemy beginner References: <8832ab6d-8def-45d1-92df-baac40e1c498@t36g2000prt.googlegroups.com> Message-ID: In article <8832ab6d-8def-45d1-92df-baac40e1c498 at t36g2000prt.googlegroups.com>, alex23 wrote: > On Nov 22, 10:25?am, Roy Smith wrote: > > Everytime I've worked with SQLAlchemy, I've run away screaming in the > > other direction. ?Sure, portability is a good thing, but at what cost? > > I've never found SQLAlchemy to be anything but sane and approachable. > It's really worth understanding _how_ it works so you can see there's > no magic happening there. > > What cost do you see inherit in the use of SQLAlchemy? The cost of understanding how it works :-) Seriously. I understand SQL. Well, I'm not a SQL wizard, but I understand enough to do what I need to do. Whenever I have to use SQLAlchemy, I always find myself knowing exactly what SQL I want to write and scratching my head to figure out how to translate that into SQLAlchemy calls. From wuwei23 at gmail.com Mon Nov 21 22:22:43 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 21 Nov 2011 19:22:43 -0800 (PST) Subject: Interesting problem about uuid1 References: Message-ID: <43572d62-7afc-4554-a212-4271ee5355e5@o37g2000prn.googlegroups.com> On Nov 21, 5:33?pm, sword wrote: > My colleague asks me an interesting problem about uuid library in > python. In multicore system with multiprocessing, is it possible to > get the duplicated uuid with uuid1? > > I just check the RFC 4122, and I can't find anything about multicore > environment. Python's uuid1 method generates the uuid with time stamp, > mac address, and algorithm to gen random numbers. So, I think it's > possible to get the duplicate uuid1 at the same time. > > What about you? Hope for your reply Check the library documentation: http://docs.python.org/library/uuid.html uuid.uuid1([node[, clock_seq]]) Generate a UUID from a host ID, sequence number, and the current time. If node is not given, getnode() is used to obtain the hardware address. If clock_seq is given, it is used as the sequence number; otherwise a random 14-bit sequence number is chosen. Each process would have to not only execute at the exact same time, it would have to generate the same 14-bit random sequence. And if you're really concerned, try specifying a different clock_seq for each core. From steve+comp.lang.python at pearwood.info Mon Nov 21 22:54:43 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Nov 2011 03:54:43 GMT Subject: decorators and closures References: Message-ID: <4ecb1d03$0$30003$c3e8da3$5496439d@news.astraweb.com> On Mon, 21 Nov 2011 14:44:34 +0000, Andrea Crotti wrote: > With one colleague I discovered that the decorator code is always > executed, every time I call a nested function: "def" is a statement which is executed at runtime. Often people will talk about "definition time" instead of "compile time". Python compiles your source into byte code (compile time), then executes the byte code. The function doesn't actually get created until the byte code is executed, i.e. at run time. This is not as slow as it sounds, because the function is created from pre-compiled parts. In effect, if you have a module: x = 23 def spam(a): print x print x+1 return x**3 then the body of the function is compiled into a "code object" at compile time, and at runtime the function object itself is assembled from the code object, name, and whatever other bits and pieces are needed. In pseudo-code, the byte code looks like this: bind name "x" to object 23 build a function object "spam" from code object bind name "spam" to function object The hard part is creating the code object, as that requires parsing the source code of the body and generating byte code. That's done once, ahead of time, so the actual "build a function" part is fast. Now, if you have an ordinary nested function: def spam(a): def ham(b): return a+b return ham(a+42) # returns a numeric value or a closure: def spam(a): def ham(b): return a+b return ham # returns a closure (function object) the process is no different: the inner function doesn't get created until runtime, that is, when spam gets *called*. But it gets created from parts that were prepared earlier at compile time, and so is fast. Add a decorator, and the basic process remains. Remember that decorator syntax is just syntactic sugar. This: @decorator def spam(): pass is exactly the same as this: def spam(): pass spam = decorator(spam) which clearly has to be done at runtime, not compile time. That applies regardless of whether the function is nested or top-level. -- Steven From cs at zip.com.au Tue Nov 22 01:06:16 2011 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 22 Nov 2011 17:06:16 +1100 Subject: sqlalchemy beginner In-Reply-To: References: Message-ID: <20111122060616.GA17562@cskk.homeip.net> On 21Nov2011 22:18, Roy Smith wrote: | In article | <8832ab6d-8def-45d1-92df-baac40e1c498 at t36g2000prt.googlegroups.com>, | alex23 wrote: | > On Nov 22, 10:25?am, Roy Smith wrote: | > > Everytime I've worked with SQLAlchemy, I've run away screaming in the | > > other direction. ?Sure, portability is a good thing, but at what cost? | > | > I've never found SQLAlchemy to be anything but sane and approachable. | > It's really worth understanding _how_ it works so you can see there's | > no magic happening there. | > | > What cost do you see inherit in the use of SQLAlchemy? | | The cost of understanding how it works :-) | | Seriously. I understand SQL. Well, I'm not a SQL wizard, but I | understand enough to do what I need to do. Whenever I have to use | SQLAlchemy, I always find myself knowing exactly what SQL I want to | write and scratching my head to figure out how to translate that into | SQLAlchemy calls. Are you trying to go the ORM route (make classes etc mapping to SQL entities etc)? I ask because I avoid ORM and mostly use the SQL syntax notation, eg: for node_id, attr, value in select( [ attrs.c.NODE_ID, attrs.c.ATTR, attrs.c.VALUE, ] ) \ .order_by(asc(attrs.c.NODE_ID)) \ .execute(): or: self.attrs.delete(self.attrs.c.NODE_ID == node_id).execute() which I find very easy to read (self.attrs is an SQLAchemy table). ORMs seem very cool and all, but I personally prefer to work with simple SQL level schemae and python-level objects and classes i.e. not ORM classes but ordinary classes that cll SQLAlchemy select/update/delete/etc methods to manipulate the db. For me the great strengths of SQLA are that it (1) talks to many different backend DBs and (2) removes the need to write tediously quotes SQL because I can write python expressions like the above that map directly to SQL statements, and SQLA does all the quoting, conversion etc. Reliably! Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ I sometimes wish that people would put a little more emphasis upon the observance of the law than they do upon its enforcement. - Calvin Coolidge From davidlujun at gmail.com Tue Nov 22 05:18:25 2011 From: davidlujun at gmail.com (David Lu) Date: Tue, 22 Nov 2011 18:18:25 +0800 Subject: a qustion about import that really confuses me Message-ID: Hi, there. I have two files: a.py: > # -*- coding: utf-8 -*- > print('in a') > import b > > print('var') > VAR = 1 > > def p(): > print('{}, {}'.format(VAR, id(VAR))) > > if __name__ == '__main__': > VAR = -1 > p() > b.p() # Where does this VAR come from? > b.py: > # -*- coding: utf-8 -*- > print('in b') > import a > > def p(): > a.p() > I don't understand why there're two different VARs, which is supposed to the same. Is it a bug? If I move the 'main' block to another file, everything works well. c.py: > # coding=UTF-8 > import a > import b > > if __name__ == '__main__': > a.VAR = -1 > a.p() > b.p() > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Tue Nov 22 08:16:26 2011 From: d at davea.name (Dave Angel) Date: Tue, 22 Nov 2011 08:16:26 -0500 Subject: a qustion about import that really confuses me In-Reply-To: References: Message-ID: <4ECBA0AA.9000800@davea.name> On 11/22/2011 05:18 AM, David Lu wrote: > Hi, there. > > I have two files: > > a.py: > >> # -*- coding: utf-8 -*- >> print('in a') >> import b >> >> print('var') >> VAR = 1 >> >> def p(): >> print('{}, {}'.format(VAR, id(VAR))) >> >> if __name__ == '__main__': >> VAR = -1 >> p() >> b.p() # Where does this VAR come from? >> > b.py: > >> # -*- coding: utf-8 -*- >> print('in b') >> import a >> Right there is your problem. You try to import a module that you've earlier used as the top-level script. The top-level script gets a module name of "__main__" and this import is defining a module of "a". So you have two distinct modules from the same source file, as you've discovered. >> def p(): >> a.p() >> > I don't understand why there're two different VARs, which is supposed to > the same. > Is it a bug? > If I move the 'main' block to another file, everything works well. > > c.py: > >> # coding=UTF-8 >> import a >> import b >> >> if __name__ == '__main__': >> a.VAR = -1 >> a.p() >> b.p() >> More generally, you should avoid circular imports. Other problems can occur, this is just the most blatant. When you discover that two modules are using (importing) each other's resources. you should move as much code as necessary from one of them to a 3rd module, and both should import that one. Similar problems appear in other languages, and the cure is generally the same. Avoid circular dependencies. Incidentally, using all uppercase for a name is a convention for constants. Further, you explicitly request that VAR have different values when it's the top-level script than when it's an imported module, so the language is doing exactly what you request, even if not what you wanted. You're lucky that the problem was so obvious. Many mutual import problems are much more subtle. -- DaveA From loluengo at gmail.com Tue Nov 22 09:15:37 2011 From: loluengo at gmail.com (Lorenzo) Date: Tue, 22 Nov 2011 06:15:37 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <70a4b790-b51b-4eb9-b487-07771895056c@w7g2000yqc.googlegroups.com> > ? ? ? ? Very interesting. ?Is there a simple way to add third-party > libraries to these? ?I assume that for pure-Python modules you could > just put a python file in the appropriate place and import it, but what > about if you wanted a web app that used numpy or something? ?Is that > feasible? > I cannot imagine how slow can be a python interpreter in javascript crunching numbers using numpy, and converting those numeric libraries (ATLAS, LAPACK,MKL,ACML) to javascript. From aleksandrs.zdancuks at gmail.com Tue Nov 22 09:54:05 2011 From: aleksandrs.zdancuks at gmail.com (Tiaburn Stedd) Date: Tue, 22 Nov 2011 06:54:05 -0800 (PST) Subject: Peculiarity of '@' in logging.Formatter References: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> <10658976.1704.1321917568761.JavaMail.geo-discussion-forums@yqni5> Message-ID: <4d86a69d-e737-41ea-8e23-a67351a67994@cu3g2000vbb.googlegroups.com> Upvote this. Looks like a bug for me. ---------------- begin results ---------------------- Nov 22 16:47:45 lvaltp0521 [minitest: 021]:My log message:isn't it special? Nov 22 16:47:45 lvaltp0521 [minitest at 021]: My log message:isn't it special? ---------------- end results ------------------------ ~$ python --version Python 2.6.6 From aleksandrs.zdancuks at gmail.com Tue Nov 22 10:19:59 2011 From: aleksandrs.zdancuks at gmail.com (Tiaburn Stedd) Date: Tue, 22 Nov 2011 07:19:59 -0800 (PST) Subject: Strange logging.Formatter behaviour Message-ID: Hello, all! I'm working on specific project and have a curious task where I need to use specific formatter and custom handlers, which are switchable to default handlers. Problem is that default handlers behaviour is to consume errors, so errors raised from code have printed tracebacks, but not passed outside logger, because of it silent behaviour. Unit test for this is below: import logging import unittest class SpecificFormatException(Exception): pass class MyClass(object): def __init__(self, record): raise TypeError class MyFormatter(logging.Formatter, object): def format(self, record): try: specific_format_record = MyClass(record) except TypeError: raise SpecificFormatException("Error raised") class TestLogger(unittest.TestCase): def test_my_logger(self): self.logger = logging.getLogger(self.__class__.__name__) handler = logging.FileHandler('test_logger.log') handler.setFormatter(fmt=MyFormatter()) self.logger.addHandler(handler) self.assertRaises(SpecificFormatException, self.logger.warn,"Log something") if __name__ == '__main__': unittest.main() I don't believe this behavior is normal. I expect error raised in a Formatter.format function, should be passed all the way up, but not consumed. I found a workaround: class CustomFileHandler(logging.FileHandler, object): def handleError(self, record): super(CustomFileHandler, self).handleError(record) raise But it looks ugly to add Custom*Handler for any default Handler (like, StreamHandler, etc) to make them possible to fall out on any error. There are raiseException switch in source of logging/__init__.py 92 #raiseExceptions is used to see if exceptions during handling should be 93 #propagated 94 # 95 raiseExceptions = 1 But all it switch is only is traceback printed or not. I think this behaviour is against Zen of Python: "Errors should never pass silently." May be logging library should be updated to contain 2 flags: printTracebacks and raiseExceptions ? From bex.lewis at gmail.com Tue Nov 22 10:46:43 2011 From: bex.lewis at gmail.com (becky_lewis) Date: Tue, 22 Nov 2011 07:46:43 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: <39d7d689-6953-4ae5-84f5-83d44eb9fd39@w7g2000yqc.googlegroups.com> On Nov 15, 8:37?pm, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? I think you may find it a little time consuming to reimpliment python in javascript. I'm inclined to say "go for it" though since you may create something awesome in the process ;) If you want to take an easier route, may I point out pythonanywhere.com? It doesn't run in the browser but does give safe access to multiple python interpreters and from my own use I can say that it works pretty well. You can even set up web apps using it. For educational purposes it might be helpful to you. From wolftracks at invalid.com Tue Nov 22 10:57:30 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 07:57:30 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: On 11/21/2011 11:21 AM, Dennis Lee Bieber wrote: > On Mon, 21 Nov 2011 08:39:37 -0800, "W. eWatson" > declaimed the following in > gmane.comp.python.general: > >> >> My criterion for success is that it puts IDLE as a choice for editor on >> the menu produced with a right-click on a py file. So far no response on >> this has solved the problem. >> >> I know it sets up that way on a 2.5 and 2.4 on other PCs I have. >> > I have three computers here: > > -=-=-=-=-=- Desktop > WinXP Pro 32-bit, 3.4GHz hyper-threaded P4 > ActiveState ActivePython 2.5.2.2 (Python 2.5.2) All of the above use ActiveState. I use whatever the Python organization provides on their download site. I would not expect the two to compare. > > -=-=-=-=-=- > > So, out of two generations of 32-bit Python 2.5, and 64 and 32 bit > versions of Python 2.7, on three computers, NONE of mine have a > right-click option for IDLE. > >> I do know that IDLE appears on the Win 7 Start menu, but, when used, >> nothing happens. Well, OK, for about 3 seconds the Win 7 "working" icon >> spins around then zip, nothing. Further, right-clicking on Properties >> of IDLE (GUI) produces a tabbed dialog. It shows Start in: >> c:\Python32\, and None for shortcut. There is a compatibility tab, > > But what does it show for TARGET! c:\Python32 Start in, and for Target: Python 3.2.2 (64-bit) For the shortcut C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python3.2 > >> Going directly to ...\Lib\idlelib\idle.pyw produces the spinning icon. >> At least, that's what happens in 3.2.2, but in the 32-bit versions I >> tried, I would get "invalid Win 32 app". >> > Possibly because you are trying to start a 32-bit version with a > default "open" for .pyw files that runs the 64-bit Python.exe; so the > DLLs are mixed architecture. 3.2.2 is 64-bit. > > >> Some have suggested a registry problem, but I don't have a clue how to >> play with that, or somehow clean it up, if there is a problem. My PC >> behaves normally >> > Since none of your problems appear to be related to Python itself, > but rather to the Windows configuration of the Python system, I'd have > to disagree. > >> I'm using Win 7 Premium. > > Home, Pro, Ultimate (or whatever the top level is? From wolftracks at invalid.com Tue Nov 22 11:12:13 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 08:12:13 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: On 11/21/2011 3:07 PM, Terry Reedy wrote: > On 11/21/2011 11:39 AM, W. eWatson wrote: >> >> My criterion for success is that it puts IDLE as a choice for editor on >> the menu produced with a right-click on a py file. > > Your first criterion for success should be that IDLE runs at all, which > is apparently does not. How you run it is secondary. > > Right-click responses are controlled by Windows using data in the > registry. Windows modifies the registry in response to installers *and > users*. The ActiveState installers request 'Edit with PythonWin'. They > do not request 'Edit with IDLE' and it is foolish to complain to us when > you use ActiveState and get their choice of context choices. ActiveState. Am I missing something? I'm running 64-bit Python downloaded from the Python organization's web site.l > > The PSF .msi installers (.msi = MicroSoftInstall format) from python.org > request 'Edit with IDLE' but cannot make Windows put it in. If your > registry is messed up enough, it does not happen. But no error message. > > I have explained to you another way to work with IDLE once it runs. It > you refuse to use it, that is your problem, not ours. > >> I know it sets up that way on a 2.5 and 2.4 on other PCs I have. > > You installed with the PSF installer with an ok registry. PSF? What does "ok registry" mean? > >> I know at one time it worked on my 64-bit Win 7 PC, which likely had a >> 32-bit version installed on it. After something like six months of >> modest use it stopped working as above. No IDLE choice. > > So some *other* program messed things up. Stop blaming us. > Heavy or modest use in the meantime is irrelevant. I'm blaming you??? I was just providing data for whatever it might be worth. I'm also suggesting that I do not have years of experience with Python. > >> I know by installing a 64-bit version, 3.2.2 failed the IDLE criterions >> as described. No IDLE. > > Did you uninstall the 32 bit version, and best, all Python versions? > >> I do know that IDLE appears on the Win 7 Start menu, but, when used, >> nothing happens. Well, OK, for about 3 seconds the Win 7 "working" icon >> spins around then zip, nothing. > > This is your real problem. Stop worrying about the context menu. I would expect consistency through all Python org releases. Should I put consistency in really bold letters with a 30 point font? :-) > > > Further, right-clicking on Properties of >> IDLE (GUI) produces a tabbed dialog. It shows Start in: c:\Python32\, > > This is the Shortcut tab. A shortcut is like a bound method. The > function is the target: 'python 3.2.2 (64 bit)' on my machine. The > starting directory is like a bound argument, although it is passed to > the launcher that launches the function. What the Properties dialog does > not show are the actual 'bound arguments' that are passed to the target > as options. So one cannot know what the shortcut is actually trying to > do. This is one of the Really Stupid things about Windows that should > have been fixed long ago but has not. I never use the shortcut on the Start menu. I mentioned the Start menu, since it might have some relevance. > >> and None for shortcut. > > None for Shortcut key, such as alt-I to invoke the shortcut. > >> There is a compatibility tab, which I've set to >> Win7. I think there's a troubleshooter there too, but I haven't used it. >> Under the Details tab, it shows Name: IDLE(Python Gui).lnk. Folder Path >> as: c:\ProgramData\Microsoft\Windows\Start... Nothing after the "...". > > Details: Folder Path is the same as General: Location. Mouse over the > latter the the full path appears. That Properties windows are still > fixed at 480 pixel wide, regardless of screen size, is another Really > Stupid thing. Yes, I finally realized I could mouse over it. > >> Going directly to ...\Lib\idlelib\idle.pyw produces the spinning icon. >> At least, that's what happens in 3.2.2, but in the 32-bit versions I >> tried, I would get "invalid Win 32 app". > > If the registry entry for .pyw is messed up, trying to run the file by > clicking on it is not likely to work. Try running from Command Prompt, > as I believe others suggested. I'm not trying to run the program, I'm trying to edit. Several times in these threads I've mentioned I can execute python from the command line. > >> When I rebooted my system a few hours after installing 3.2.2, because >> the PC was running really slowly--not because of Python, I was greeted >> by a couple of interesting messages as the desktop was populated. >> >> I can execute Python from the command line. >> >> 1. Specified module could not be found: Load Lib, python.dll. >> >> 2. \ProgramFiles(x86)\uniblueDrivers\Scanner (x86) Python26.dll. > > The uniblue drivers program will match your drivers against a database > of up-to-date drivers and offer to upgrade them. I have used uniblue's > registry scanner program. Treating pythonxy.dll as a driver, if they > are, is an error. These are paid programs. The free demos only scan to > tell you what they would do if you bought them. Yes. Just Winamp looking for $$$. > > > I'm sure this is related to Winamp, which I had installed a month ago. > > I do not believe they are the same companies, but they may have a > cross-promotion deal. Evidently. > >> had some "crazy" choice to scan for new drivers. Of course, if it found >> one-connected with Python, and if you wanted it, $$$. I think this >> message is a red herring. I may re-install Winamp to get rid of that >> uniblue tool that seems like nothing more than an ad. >> >> Some have suggested a registry problem, but I don't have a clue how to >> play with that, or somehow clean it up, if there is a problem. My PC >> behaves normally > > If you ran the psf 3.2.2 installer and idle does not run when you click > the start menu shortcut, something is wrong. Of course. Assuming psf means something like python software foundation. > >> Someone suggested using the mail list at >> . What's different >> about that list than this NG? Does the "org" suggest that the >> inhabitants of that list are more likely associated with the people who >> are responsible for constructing Python? > > Python list is mirror to comp.lang.python which is mirrored to a google > group. It is also mirrored to gmane.comp.python, which is how I read and > post. There is some spam filtering if you use the python.org list or > gmane group. > Good. Then I don't need it. From wolftracks at invalid.com Tue Nov 22 11:14:16 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 08:14:16 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> References: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> Message-ID: On 11/21/2011 7:00 PM, alex23 wrote: > "W. eWatson" wrote: >> Comments? > > Please don't start multiple threads on the same issue. Your joking, right, or do you just prefer 500 line threads wandering all over the place? From vinay_sajip at yahoo.co.uk Tue Nov 22 11:21:10 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 22 Nov 2011 08:21:10 -0800 (PST) Subject: Strange logging.Formatter behaviour References: Message-ID: On Nov 22, 3:19?pm, Tiaburn Stedd wrote: > I don't believe this behavior is normal. I expect error raised in a > Formatter.format function, should be passed all the way up, but not > consumed. > > I found a workaround: > > class CustomFileHandler(logging.FileHandler, object): > ? ? def handleError(self, record): > ? ? ? ? ?super(CustomFileHandler, self).handleError(record) > ? ? ? ? ?raise > > But it looks ugly to add Custom*Handler for any default Handler (like, > StreamHandler, etc) to make them possible to fall out on any error. > > There are raiseException switch in source of logging/__init__.py > > ? 92 #raiseExceptions is used to see if exceptions during handling > should be > ? 93 #propagated > ? 94 # > ? 95 raiseExceptions = 1 > > But all it switch is only is traceback printed or not. I think this > behaviour is against Zen of Python: "Errors should never pass > silently." They don't pass silently - raiseExceptions defaults to 1, so tracebacks are printed by default. In production, it's not a good idea for a potentially long-running process like a server to be brought down because someone put a typo in a logging format string, so the recommendation is to set raiseExceptions to 0/False in such scenarios. Since you are developing a custom formatter, you can certainly catch any formatting exceptions in your format method and decide what you want to do with them. The default handleError behaviour of printing a traceback is reasonable, in my view. If you want something else, you can subclass the relevant handler class; just setting a printTracebacks flag to false isn't going to get useful behaviour specific to individual requirements. There's no real point in throwing a very specific exception from a formatter, as a handler isn't going to automatically know how to handle a SpecificFormatException in any meaningful way. Remember that in the general case, application developers don't always have control of what handlers are configured for an application (for example, this could be set by end-user or per-deployment configuration). Regards, Vinay Sajip From dihedral88888 at googlemail.com Tue Nov 22 12:03:42 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 22 Nov 2011 09:03:42 -0800 (PST) Subject: decorators and closures In-Reply-To: References: Message-ID: <24059779.511.1321981422154.JavaMail.geo-discussion-forums@prou19> On Monday, November 21, 2011 10:44:34 PM UTC+8, Andrea Crotti wrote: > With one colleague I discovered that the decorator code is always > executed, every time I call > a nested function: > > def dec(fn): > print("In decorator") > def _dec(): > fn() > > return _dec > > def nested(): > @dec > def fun(): > print("here") > > nested() > nested() > > Will give: > In decorator > In decorator > > So we were wondering, would the interpreter be able to optimize this > somehow? > I was betting it's not possible, but I'm I would like to be wrong :) I love to use decorators. I did the same things to functions and structures in c long time ago. I think that might be the dark night era in programming in the early 90's long long ago. Cheers. From dihedral88888 at googlemail.com Tue Nov 22 12:03:42 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 22 Nov 2011 09:03:42 -0800 (PST) Subject: decorators and closures In-Reply-To: References: Message-ID: <24059779.511.1321981422154.JavaMail.geo-discussion-forums@prou19> On Monday, November 21, 2011 10:44:34 PM UTC+8, Andrea Crotti wrote: > With one colleague I discovered that the decorator code is always > executed, every time I call > a nested function: > > def dec(fn): > print("In decorator") > def _dec(): > fn() > > return _dec > > def nested(): > @dec > def fun(): > print("here") > > nested() > nested() > > Will give: > In decorator > In decorator > > So we were wondering, would the interpreter be able to optimize this > somehow? > I was betting it's not possible, but I'm I would like to be wrong :) I love to use decorators. I did the same things to functions and structures in c long time ago. I think that might be the dark night era in programming in the early 90's long long ago. Cheers. From RDRichardson at rad-con.com Tue Nov 22 13:32:53 2011 From: RDRichardson at rad-con.com (Rob Richardson) Date: Tue, 22 Nov 2011 18:32:53 +0000 Subject: What replaces log4py under Python 3.2? Message-ID: <67D108EDFAD3C148A593E6ED7DCB4BBDEDD0A5@RADCONWIN2K8PDC.radcon.local> Greetings! My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? Thank you. RobR From ameyer2 at yahoo.com Tue Nov 22 13:37:32 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 22 Nov 2011 13:37:32 -0500 Subject: Using the Python Interpreter as a Reference In-Reply-To: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <4ECBEBEC.2010300@yahoo.com> On 11/20/2011 7:46 PM, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. ... I have great respect for people who take on projects like this. Your chances of popularizing the language are small. There must be thousands of projects like this for every one that gets adopted by other people. However your chances of learning a great deal are large, including many things that you'll be able to apply to programs and projects that, at first glance, wouldn't appear to benefit from this kind of experience. If you get it working you'll have an impressive item to add to your resume. I suspect that you'll also have a lot of fun. Good luck with it. Alan From ameyer2 at yahoo.com Tue Nov 22 13:55:22 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 22 Nov 2011 13:55:22 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: <4ECBF01A.7060507@yahoo.com> On 11/21/2011 11:39 AM, W. eWatson wrote: > My criterion for success is that it puts IDLE as a choice for editor on > the menu produced with a right-click on a py file. So far no response on > this has solved the problem. ... I don't know what responses you're referring to since this is the first posting in the thread. It's possible what I'm about to say was already told to you - in which case I'm wasting my and everyone's time. However, leaving that aside, I think that this is trivially easy to solve. It has nothing whatever to do with Python or Idle - though it's possible that the Python installer could have done something for that it didn't - and it's also possible that the Python installer did what you told it to do but you told it the wrong thing, or you told Windows to change it without realizing that you did. (I do that all the time. A mouse slip and inadvertent click on the wrong object, a misunderstanding of a prompt, or lots of other missteps can change things without your having any idea what happened.) Anyway, if I understand what you're looking for, here's what you need to do to fix your problem: 1. Open Windows Explorer. 2. Navigate to a Python file. 3. Right click on the Python file with the mouse. 4. Select "Open With" 5. Select "Choose Default Program" 6. Select, or navigate to and select, the python IDLE interpreter. 7. Check the box that says "Always use the selected program to open this kind of file." 8. Click "OK". The prompts I described above are the ones I saw on my Windows Server 2008 machine. Yours may vary slightly, but I think the procedures should be the same. Please let us know if that solves your problem. Alan From andrea.crotti.0 at gmail.com Tue Nov 22 14:15:47 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 22 Nov 2011 19:15:47 +0000 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> Message-ID: <4ECBF4E3.9000007@gmail.com> On 11/22/2011 04:14 PM, W. eWatson wrote: > Your joking, right, or do you just prefer 500 line threads wandering > all over the place? I would personally prefer to just not see useless discussions about Windows set up in a python mailing list, but I guess it's a price to pay for the popularity of Python.. From ameyer2 at yahoo.com Tue Nov 22 14:29:18 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 22 Nov 2011 14:29:18 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ECBF01A.7060507@yahoo.com> References: <4ECBF01A.7060507@yahoo.com> Message-ID: <4ECBF80E.9090003@yahoo.com> On 11/22/2011 1:55 PM, Alan Meyer wrote: ... > 6. Select, or navigate to and select, the python IDLE interpreter. ... On my system that's C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe Alan From irmen at -NOSPAM-xs4all.nl Tue Nov 22 14:41:00 2011 From: irmen at -NOSPAM-xs4all.nl (Irmen de Jong) Date: Tue, 22 Nov 2011 20:41:00 +0100 Subject: What replaces log4py under Python 3.2? In-Reply-To: References: Message-ID: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> On 22-11-11 19:32, Rob Richardson wrote: > Greetings! > > My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? The logging module from Python's stdlib? http://docs.python.org/py3k/library/logging.html Irmen From tjreedy at udel.edu Tue Nov 22 17:50:35 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 22 Nov 2011 17:50:35 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: On 11/22/2011 1:01 PM, Dennis Lee Bieber wrote: >> c:\Python32 Start in, and for Target: Python 3.2.2 (64-bit) > > Which tells me that the TARGET field is garbaged, The above is exactly what my IDLE shortcut target field says, and it works fine. > since THAT is what specifies the program (and arguments) > that has to be run when the shortcut is double-clicked. It would be nice if it DID show all that info. > Try editing the target field to read (presuming the 3.x branch of > Python keeps the same library structure): > > c:\python32\lib\idlelib\idle.bat > > save the change, and then select the short-cut to see if it runs. Target for the .msi created shortcut cannot be edited, even as admin. -- Terry Jan Reedy From wolftracks at invalid.com Tue Nov 22 22:29:57 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 19:29:57 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ECBF80E.9090003@yahoo.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/22/2011 11:29 AM, Alan Meyer wrote: > On 11/22/2011 1:55 PM, Alan Meyer wrote: > ... >> 6. Select, or navigate to and select, the python IDLE interpreter. > ... > On my system that's > C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe > > Alan OK, I'm going to try it soon. Keeping my fingers crossed. From ameyer2 at yahoo.com Tue Nov 22 22:45:41 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 22 Nov 2011 22:45:41 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <4ECC6C65.2090902@yahoo.com> On 11/22/2011 3:05 PM, Dennis Lee Bieber wrote: > On Tue, 22 Nov 2011 14:29:18 -0500, Alan Meyer > declaimed the following in gmane.comp.python.general: > >> On 11/22/2011 1:55 PM, Alan Meyer wrote: >> ... >>> 6. Select, or navigate to and select, the python IDLE interpreter. >> ... >> On my system that's >> C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe >> > Note that this is not the Tk based IDLE (which is implemented, > itself, as a .pyw file and is not natively executable -- which seems to > be one of the problems; Win7 has removed the detailed file type > association windows so you can't specify that the "application" is > pythonw.exe running idle.pyw using one's selected file as the argument > to the mess). Bummer! Sorry W.eWatson, my instructions may not work. I've got the ActiveState Python on my Windows machine. It runs a .exe file as the IDLE executable. If your implementation doesn't have an exe then you're going to have to do some more complex work. Since I don't have the version of Python from python.org under Windows, I can't really advise on what to do with that. If you haven't got an exe, my instructions will only work if you install the ActiveState version, which does have one. Alan From wolftracks at invalid.com Tue Nov 22 22:46:01 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 19:46:01 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/22/2011 7:29 PM, W. eWatson wrote: > On 11/22/2011 11:29 AM, Alan Meyer wrote: >> On 11/22/2011 1:55 PM, Alan Meyer wrote: >> ... >>> 6. Select, or navigate to and select, the python IDLE interpreter. >> ... >> On my system that's >> C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe >> >> Alan > OK, I'm going to try it soon. Keeping my fingers crossed. Well, all there was there was a README.txt file that told me the purpose of the folder. "This directory exists so that 3rd party packages can be installed here. Read the source for site.py for more details." Of course, Dennis' C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe wouldn't work either. I did a Win 7 search Pythonwin.exe, and found nothing. However, sometimes that search fails even when though there is something on the PC that matches the search. There is a pythonw.exe under C:\Python32. From snorble at hotmail.com Wed Nov 23 00:19:21 2011 From: snorble at hotmail.com (snorble) Date: Tue, 22 Nov 2011 21:19:21 -0800 (PST) Subject: Writing code to be optimizable Message-ID: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> Sometimes I want to prototype a program in Python, with the idea of optimizing it later by rewriting parts of it in C or Cython. But I usually find that in order to rewrite the slow parts, I end up writing those parts very much like C or C++ anyway, and I end up wondering what is the point of using Python in such a project. I liked the idea of Cython, mainly the idea of being able to write in pure Python, then create a file that modifies the pure Python file (with type declarations and such), but I ran into the same problems. In order to be able to modify the code, I can't make a lot of use of the really helpful things in Python like dicts and such. I have to dumb down Python to where I'm basically writing C code in Python, so again I ask myself what is the point? Is it reasonable to prototype an application in Python that will require performance? Are there any recommendations on how to write code in such a way that it can later be optimized or replaced with a module written in C or Cython? Or any good examples of this being done that I could learn from? From Nikunj.Badjatya at emc.com Wed Nov 23 00:44:50 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Wed, 23 Nov 2011 00:44:50 -0500 Subject: Thread problem Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D616@MX34A.corp.emc.com> Howdy All, Please see http://pastebin.com/GuwH8B5C . Its a sample program implementing progressbar in multithreaded program. Here I am creating a thread and passing update2() function to it. Now wheneever I press CTRL-C, the program isnt returning to prompt. ! Can someone help me out with this please. ! Thanks Nikunj -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Wed Nov 23 01:45:07 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 23 Nov 2011 17:45:07 +1100 Subject: Writing code to be optimizable In-Reply-To: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> References: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> Message-ID: On Wed, Nov 23, 2011 at 4:19 PM, snorble wrote: > Sometimes I want to prototype a program in Python, with the idea of > optimizing it later by rewriting parts of it in C or Cython. But I > usually find that in order to rewrite the slow parts, I end up writing > those parts very much like C or C++ anyway, and I end up wondering > what is the point of using Python in such a project. There's a few ways to prototype. If you use Python as the language of your specs documents (or pseudo-Python, perhaps) - consider the entire Python implementation as ephemeral, and use it to verify that your specifications are correct, but not for any sort of performance - then it doesn't matter that you've rewritten it completely, nor that you've written C code in Python. You would have been writing C code in English otherwise, anyway. If you're not sure which parts you're prototyping (ie will rewrite in C/C++) and which parts you're writing properly (ie will keep the Python version as the production code), I'd still recommend using all of Python's best features... but keep your function docstrings comprehensive. When you rewrite it in C, you're able to take advantage of what you learned first time around, but otherwise it's just strictly reimplementing the docstring in a different environment. Chris Angelico From atadesse at sunedison.com Wed Nov 23 01:48:19 2011 From: atadesse at sunedison.com (Alemu Tadesse) Date: Wed, 23 Nov 2011 00:48:19 -0600 Subject: What I do and do not know about installing Python on Win 7 withregard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com><4ECBF80E.9090003@yahoo.com> Message-ID: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019677F1@mail.sunedison.com> I just subscribed for python and I am VERY NEW. I would like to have a an IDLE. My texts are just the same whether it is comment or def or statement or ...... how am I going to make it highlighted ..my scientific package is not working and complaining about not able to find/load DLL ... frustrating for the first day in the python world. ANY tip ? Thanks Alemu -----Original Message----- From: python-list-bounces+atadesse=sunedison.com at python.org [mailto:python-list-bounces+atadesse=sunedison.com at python.org] On Behalf Of Dennis Lee Bieber Sent: Tuesday, November 22, 2011 11:43 PM To: python-list at python.org Subject: Re: What I do and do not know about installing Python on Win 7 withregard to IDLE. On Tue, 22 Nov 2011 19:46:01 -0800, "W. eWatson" declaimed the following in gmane.comp.python.general: > > Of course, Dennis' > C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe > wouldn't work either. > If you didn't install an ActiveState packaged version, nor hand installed the win32 extension package into a Python.org installed system, you won't have PythonWin. > I did a Win 7 search Pythonwin.exe, and found nothing. However, > sometimes that search fails even when though there is something on the > PC that matches the search. > > There is a pythonw.exe under C:\Python32. And has been mentioned at least three times in the last week -- pythonw.exe is the version of the Python interpreter that is supposed to be the default application for .pyw files. It is the version that does NOT open a console window for stdin/stdout (IOWs, it is meant for use by Python scripts that use a graphical library for all I/O -- Tk, wxPython, etc.). If you ran a graphical script using the plain python.exe it would open a console window that would just sit there until the script exited. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- http://mail.python.org/mailman/listinfo/python-list From stefan_ml at behnel.de Wed Nov 23 02:37:53 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 23 Nov 2011 08:37:53 +0100 Subject: Writing code to be optimizable In-Reply-To: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> References: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> Message-ID: snorble, 23.11.2011 06:19: > Sometimes I want to prototype a program in Python, with the idea of > optimizing it later by rewriting parts of it in C or Cython. But I > usually find that in order to rewrite the slow parts, I end up writing > those parts very much like C or C++ anyway, and I end up wondering > what is the point of using Python in such a project. > > I liked the idea of Cython, mainly the idea of being able to write in > pure Python, then create a file that modifies the pure Python file > (with type declarations and such), but I ran into the same problems. > In order to be able to modify the code, I can't make a lot of use of > the really helpful things in Python like dicts and such. I have to > dumb down Python to where I'm basically writing C code in Python, so > again I ask myself what is the point? > > Is it reasonable to prototype an application in Python that will > require performance? Are there any recommendations on how to write > code in such a way that it can later be optimized or replaced with a > module written in C or Cython? I think the usual approach is to write it in Python and make sure it works by writing "enough" tests, then benchmark it, then decide if a non-Python level optimisation is required. If it's required, Cython compile the entire module and add static types to your hot spots, either in Python notation ("pure mode") or in an external .pxd file. If that doesn't yield enough performance, copy code into a separate Cython module and optimise it there using C paradigms instead of Python paradigms, i.e. apply algorithmic optimisations by dropping data structures into C. Then use an import to use the code from your so-called accelerator module in your original module. Try to provide both a pure Python implementation and a Cython implementation, as that will allow you to run your code in other Python implementations directly and to compare your two implementations for equivalence and performance. The advantage of stepping down into C-ish Cython code incrementally is that you will have a working implementation at each step and can decide to stop optimising because it is "good enough". If you started 'optimising' your code while still writing it, it will take longer to write it and you can never be sure that the complexity you add to the long-term maintenance by writing C-ish code is truly worth the performance gain (or if there even is any gain). Stefan From as at sci.fi Wed Nov 23 04:19:14 2011 From: as at sci.fi (Anssi Saari) Date: Wed, 23 Nov 2011 11:19:14 +0200 Subject: Python 2.7.2 on Win7 and IDLE (Try it) References: Message-ID: "W. eWatson" writes: > One thing I think no one has offered is whether their installation of > 2.7.2 has the same IDLE oddity that I've described. That is, if you > right-click on a py file, do you see a choice for the IDLE editor? I don't have 2.7.2, but my Windows (7, 32 bit) machine has 3.2 installed and also 2.6.6 included in Python(x,y) distribution. Right clicking on a .py has, under Open with, the choices GNU Emacsclient (my choice for editing), python.exe and pythonw.exe. No Idle. I was able to add idle to the menu it by clicking "Choose default program" in the menu and pointing that to idle.bat. From as at sci.fi Wed Nov 23 04:23:19 2011 From: as at sci.fi (Anssi Saari) Date: Wed, 23 Nov 2011 11:23:19 +0200 Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: goldtech writes: > Using Windows. Is there a python shell that has a history of typed in > commands? Is there a shell that doesn't have history then? At least both the vanilla shell and Idle both have basic history in Windows. IPython for more fun. From r32813 at freescale.com Wed Nov 23 04:54:22 2011 From: r32813 at freescale.com (Wong Wah Meng-R32813) Date: Wed, 23 Nov 2011 09:54:22 +0000 Subject: import _tclinter error in python 2.7.1 Itanium build Message-ID: <02EA6D704E30CE499C5071776509A925F9DC74@039-SN1MPN1-002.039d.mgd.msft.net> Hello there, I am in the midst of converting my application code from python 1.5.2 to python 2.7.1. In the build of my python 2.7.1 on Itanium 64-bit HP11.3 platform, I noticed my Tkinter module was built and linked successfully, that I am able to import the module and use it. However, I just found out that my application that utilizes Tcl/Tk code, somehow wants to use _tclinter, instead of using _tkinter (In fact I have a Tkinter.py file) . The only comment I can see from the author is "Have Pic use Tclinter instead of Tkinter to allow Pic to start with a valid X Display". That comment was left at the time python 1.5.2 and tcl/tk 8.1 (maybe) was used and I am not sure if the same issue is applicable to the current version of python and tcl/tk. However, the question I want to ask is, I build python when tcl/tk files are both available, why only tk is detected and built-in with python, not tcl? $ python Python 2.7.1 (r271:86832, Oct 6 2011, 11:10:10) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkinter >>> import Tclinter Traceback (most recent call last): File "", line 1, in File "Tclinter.py", line 5, in import _tclinter # If this fails your Python is not configured for Tcl ImportError: No module named _tclinter >>> import _tclinter Traceback (most recent call last): File "", line 1, in ImportError: No module named _tclinter >>> import _tkinter >>> Regards, Wah Meng -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Wed Nov 23 05:29:28 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Nov 2011 10:29:28 GMT Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> On Wed, 23 Nov 2011 11:23:19 +0200, Anssi Saari wrote: > goldtech writes: > >> Using Windows. Is there a python shell that has a history of typed in >> commands? > > Is there a shell that doesn't have history then? At least both the > vanilla shell and Idle both have basic history in Windows. IPython for > more fun. The default interactive interpreter for Python doesn't have persistent history, so if you exit the interpreter and restart it, your commands are gone. -- Steven From mail at timgolden.me.uk Wed Nov 23 05:37:56 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Nov 2011 10:37:56 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ECCCD04.1060408@timgolden.me.uk> On 23/11/2011 10:29, Steven D'Aprano wrote: > On Wed, 23 Nov 2011 11:23:19 +0200, Anssi Saari wrote: > >> goldtech writes: >> >>> Using Windows. Is there a python shell that has a history of typed in >>> commands? >> >> Is there a shell that doesn't have history then? At least both the >> vanilla shell and Idle both have basic history in Windows. IPython for >> more fun. > > The default interactive interpreter for Python doesn't have persistent > history, so if you exit the interpreter and restart it, your commands are > gone. Not quite The interpreter inherits the command shell's history function: Open a cmd window and then a Python session. Do some stuff. Ctrl-Z to exit to the surrounding cmd window. Do some random cmd stuff: dir, cd, etc. Start a second Python session. up-arrow etc. will bring back the previous Python session's commands (and not the ones you entered in the surrounding shell) Obviously this only applies when an underlying cmd session persists -- if you simply start Python from Start > Run twice the command history will not persist between sessions. TJG From k.sahithi2862 at gmail.com Wed Nov 23 07:09:32 2011 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Wed, 23 Nov 2011 04:09:32 -0800 (PST) Subject: WORLD BEST PICS Message-ID: <29b6c18c-a72a-46d2-94a1-5bfc9c0f8dff@e34g2000prh.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ SIMHAPUTHRUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/simhaputhrudu-movie-stills.html SOLO MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/solo-movie-stills.html BEZAWADA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/bezawada-movie-stills.html RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS SARAH JANE DIAS HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/sarah-jane-dias-hot.html KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html POONAM KAUR HOT ROMANTIC STILLS http://hotactress-kalyani.blogspot.com/2011/11/poonam-kaur-hot.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From python at bdurham.com Wed Nov 23 07:11:16 2011 From: python at bdurham.com (python at bdurham.com) Date: Wed, 23 Nov 2011 07:11:16 -0500 Subject: Choosing a Windows C compiler for use with Cython and 32-bit Python 2.7 Message-ID: <1322050276.28050.140661002645593@webmail.messagingengine.com> Looking for some tips on getting started with Cython development under Windows. I am using Python 2.7.2. After reading the Cython documentation [1] it appears that one has a choice of using either the MinGW or MS Visual C compiler. 1. Are there any issues associated with using the MinGW compiler and mixing C runtimes? This seems the be the simplest and fastest way to get started with the tradeoff being the need to distribute another C runtime (in addition to the MS C runtime required for the Python interpreter itself) 2. Regarding the MS Visual C compiler - can one use the C compiler that ships with one of the free Express editions of Visual Studio or must one purchase a full version of MS Visual Studio to get the appropriate compiler? 3. Which version (2005, 2008, 2010, ...) of MS Visual Studio is required to compile Cython libraries compatible with the 32 bit version of Python 2.7.2? Thank you, Malcolm [1] http://docs.cython.org/src/quickstart/install.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From as at sci.fi Wed Nov 23 07:16:52 2011 From: as at sci.fi (Anssi Saari) Date: Wed, 23 Nov 2011 14:16:52 +0200 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: Message-ID: Dennis Lee Bieber writes: >> c:\Python32 Start in, and for Target: Python 3.2.2 (64-bit) > > Which tells me that the TARGET field is garbaged, since THAT is what > specifies the program (and arguments) that has to be run when the > shortcut is double-clicked. Actually, no, it's what I have too. 32-bit Windows 7 here and Python 3.2. The Target for the Idle shortcut is just Python 3.2. It's also greyed out and uneditable. So yes, weird. Mine works though and I rarely use Idle, so no complaints. From lists at cheimes.de Wed Nov 23 07:27:46 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 23 Nov 2011 13:27:46 +0100 Subject: Choosing a Windows C compiler for use with Cython and 32-bit Python 2.7 In-Reply-To: <1322050276.28050.140661002645593@webmail.messagingengine.com> References: <1322050276.28050.140661002645593@webmail.messagingengine.com> Message-ID: Am 23.11.2011 13:11, schrieb python at bdurham.com: > Looking for some tips on getting started with Cython development > under Windows. I am using Python 2.7.2. > > After reading the Cython documentation [1] it appears that one > has a choice of using either the MinGW or MS Visual C compiler. > > 1. Are there any issues associated with using the MinGW compiler > and mixing C runtimes? This seems the be the simplest and fastest > way to get started with the tradeoff being the need to distribute > another C runtime (in addition to the MS C runtime required for > the Python interpreter itself) No, don't worry. MinGW from msys can link against almost any C runtime library. > 2. Regarding the MS Visual C compiler - can one use the C > compiler that ships with one of the free Express editions of > Visual Studio or must one purchase a full version of MS Visual > Studio to get the appropriate compiler? > > 3. Which version (2005, 2008, 2010, ...) of MS Visual Studio is > required to compile Cython libraries compatible with the 32 bit > version of Python 2.7.2? I've explained everything in PCbuild/readme.txt in great detail. Summary: You can use the free VS 2088 Express Edition if you don't need PGO or AMD64 builds. Christian From vinay_sajip at yahoo.co.uk Wed Nov 23 07:54:16 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Wed, 23 Nov 2011 04:54:16 -0800 (PST) Subject: Peculiarity of '@' in logging.Formatter References: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <92b117a3-21b6-46ae-9063-00d85a8d3ff8@s4g2000yqk.googlegroups.com> On Nov 21, 11:17?pm, Charlie Martin wrote: > This is what seems like an odd bug, but in code I'd > thing often-enough used it must be the expected behavior > and I just don't understand. ?Please, sirs/mesdames, is > this a bug? It may be a bug, but if so, it's in the syslog daemon rather than logging. Please try again with FileHandlers in place of SysLogHandlers, and confirm whether the anomaly still occurs. I could reproduce the problem on a Suse 11.3 machine running Python 2.6, but it doesn't occur on Ubuntu for example: Nov 23 12:33:09 eta-jaunty [slhtest3:026]:My log message:isn't it special? Nov 23 12:33:09 eta-jaunty [slhtest3 at 026]:My log message:isn't it special? I get the same (expected) result on Ubuntu for both Python 2.6 and 2.7. I noticed that on Suse the syslog daemon is rsyslogd, whereas on Ubuntu it's plain syslogd. Daemons do differ on how they parse messages :-( I ran the script with strace, and logging is writing correctly to the socket: socket(PF_FILE, SOCK_DGRAM, 0) = 3 connect(3, {sa_family=AF_FILE, path="/dev/log"}, 10) = 0 socket(PF_FILE, SOCK_DGRAM, 0) = 4 connect(4, {sa_family=AF_FILE, path="/dev/log"}, 10) = 0 gettimeofday({1322052499, 78501}, NULL) = 0 send(3, "<14>[slhtest:026]:My log message"..., 51, 0) = 51 send(4, "<14>[slhtest at 026]:My log message"..., 51, 0) = 51 close(4) = 0 close(3) = 0 This is on Suse 11.3, where the formatting anomaly does occur - so it appears to be down to how rsyslogd does things. Regards, Vinay Sajip From roy at panix.com Wed Nov 23 08:31:57 2011 From: roy at panix.com (Roy Smith) Date: Wed, 23 Nov 2011 08:31:57 -0500 Subject: Writing code to be optimizable References: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> Message-ID: In article <63e78437-c76b-4a9e-9a62-bfea8d078208 at v5g2000yqn.googlegroups.com>, snorble wrote: > Is it reasonable to prototype an application in Python that will > require performance? Yes. Several observations: 1) The classic 80/20 rule. 80% of the time is spent running 20% of the code. Sometimes quoted as 90/10. Why waste time optimizing the 80%? 2) Surprisingly to many people, it's difficult to predict in advance which 20% will be the slow parts. Don't sweat it until the whole thing is up and running and you can begin to gather profiling data. 3) Often enough, when you're done writing your program, you'll discover that it's fast enough to get value from. Be happy and move onto the next task on your list. > Are there any recommendations on how to write code in such a way that > it can later be optimized or replaced with a module written in C or > Cython? Sure. Make your code modular and loosely coupled. Each module or class should do one thing, and have narrow, well-defined interfaces. Limit the number of other modules or classes it interacts with directly. If you've done that, it becomes easier to a) identify the slow parts and b) plug something better in its place. From RDRichardson at rad-con.com Wed Nov 23 09:07:34 2011 From: RDRichardson at rad-con.com (Rob Richardson) Date: Wed, 23 Nov 2011 14:07:34 +0000 Subject: What replaces log4py under Python 3.2? In-Reply-To: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> References: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> Message-ID: <67D108EDFAD3C148A593E6ED7DCB4BBDEDD182@RADCONWIN2K8PDC.radcon.local> Thank you for that link. Our customers are used to the rotating log file capability of the log4py package. I did not see anything in that link that talks about rotating log files (changing file name when the date changes, and saving a limited number of old log files). Is that possible using the stdlib logging package? Is there something else available that will do that, so we don't have to roll our own (or, more likely, stick to Python 2.7, for which log4py works)? Thanks again! RobR -----Original Message----- From: python-list-bounces+rob.richardson=rad-con.com at python.org [mailto:python-list-bounces+rob.richardson=rad-con.com at python.org] On Behalf Of Irmen de Jong Sent: Tuesday, November 22, 2011 2:41 PM To: python-list at python.org Subject: Re: What replaces log4py under Python 3.2? On 22-11-11 19:32, Rob Richardson wrote: > Greetings! > > My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? The logging module from Python's stdlib? http://docs.python.org/py3k/library/logging.html Irmen -----Original Message----- From: python-list-bounces+rob.richardson=rad-con.com at python.org [mailto:python-list-bounces+rob.richardson=rad-con.com at python.org] On Behalf Of Irmen de Jong Sent: Tuesday, November 22, 2011 2:41 PM To: python-list at python.org Subject: Re: What replaces log4py under Python 3.2? On 22-11-11 19:32, Rob Richardson wrote: > Greetings! > > My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? The logging module from Python's stdlib? http://docs.python.org/py3k/library/logging.html Irmen -- http://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Wed Nov 23 09:18:26 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 23 Nov 2011 15:18:26 +0100 Subject: What replaces log4py under Python 3.2? References: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> <67D108EDFAD3C148A593E6ED7DCB4BBDEDD182@RADCONWIN2K8PDC.radcon.local> Message-ID: Rob Richardson wrote: > Our customers are used to the rotating log file capability of the log4py > package. I did not see anything in that link that talks about rotating > log files (changing file name when the date changes, and saving a limited > number of old log files). Is that possible using the stdlib logging > package? How about http://docs.python.org/py3k/library/logging.handlers.html#timedrotatingfilehandler From alec.taylor6 at gmail.com Wed Nov 23 10:06:33 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 24 Nov 2011 02:06:33 +1100 Subject: What replaces log4py under Python 3.2? In-Reply-To: References: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> <67D108EDFAD3C148A593E6ED7DCB4BBDEDD182@RADCONWIN2K8PDC.radcon.local> Message-ID: zing! On Thu, Nov 24, 2011 at 1:18 AM, Peter Otten <__peter__ at web.de> wrote: > Rob Richardson wrote: > >> Our customers are used to the rotating log file capability of the log4py >> package. ?I did not see anything in that link that talks about rotating >> log files (changing file name when the date changes, and saving a limited >> number of old log files). ?Is that possible using the stdlib logging >> package? > > How about > > http://docs.python.org/py3k/library/logging.handlers.html#timedrotatingfilehandler > > > -- > http://mail.python.org/mailman/listinfo/python-list From atadesse at sunedison.com Wed Nov 23 10:40:46 2011 From: atadesse at sunedison.com (Alemu Tadesse) Date: Wed, 23 Nov 2011 09:40:46 -0600 Subject: Python 2.7.2 on XP In-Reply-To: References: Message-ID: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> Dear All, I am new to python. I do not know why my python editor (for 2.7.2) changes everything to just black and white after saving. No color for say the built in functions for loops defs .... they all look the same - it is annoying for someone coming from another editors that help you track/easily see your work. I just un installed it to install it again. I know it is pain to install all the scientific things again. I wish Python has something like R (R-studio) from which you can install packages very easily. I just started yesterday and already frustrated with it. I am sticking to python only because I hear good things about it and I think it is my problem. Thank you all Alemu From gordon at panix.com Wed Nov 23 11:08:12 2011 From: gordon at panix.com (John Gordon) Date: Wed, 23 Nov 2011 16:08:12 +0000 (UTC) Subject: What I do and do not know about installing Python on Win 7 withregard to IDLE. References: <4ECBF01A.7060507@yahoo.com><4ECBF80E.9090003@yahoo.com> Message-ID: In "Alemu Tadesse" writes: > scientific package is not working and complaining about not able to > find/load DLL ... frustrating for the first day in the python world. ANY > tip ? Post the exact error message you're getting. Also post your code, if it's not too long. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From gordon at panix.com Wed Nov 23 11:11:25 2011 From: gordon at panix.com (John Gordon) Date: Wed, 23 Nov 2011 16:11:25 +0000 (UTC) Subject: Python 2.7.2 on XP References: Message-ID: In "Alemu Tadesse" writes: > I am new to python. I do not know why my python editor (for 2.7.2) > changes everything to just black and white after saving. No color for What editor are you using? There are quite a lot of them. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From massi_srb at msn.com Wed Nov 23 12:10:09 2011 From: massi_srb at msn.com (Massi) Date: Wed, 23 Nov 2011 09:10:09 -0800 (PST) Subject: String splitting by spaces question Message-ID: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Hi everyone, I have to parse a string and splitting it by spaces. The problem is that the string can include substrings comprises by quotations which must mantain the spaces. What I need is to pass from a string like: This is an 'example string' to the following vector: ["This", "is", "an", "example string"] Which is the best way to achieve this? Thanks in advance! From atadesse at sunedison.com Wed Nov 23 12:31:21 2011 From: atadesse at sunedison.com (Alemu Tadesse) Date: Wed, 23 Nov 2011 11:31:21 -0600 Subject: String splitting by spaces question In-Reply-To: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: <6FA6EB75E3CA4744ADF9EF97D8DAC18B01967924@mail.sunedison.com> Hi Everyone, Can we use rsplit function on an array or vector of strings ? it works for one not for vector Alemu -----Original Message----- From: python-list-bounces+atadesse=sunedison.com at python.org [mailto:python-list-bounces+atadesse=sunedison.com at python.org] On Behalf Of Massi Sent: Wednesday, November 23, 2011 10:10 AM To: python-list at python.org Subject: String splitting by spaces question Hi everyone, I have to parse a string and splitting it by spaces. The problem is that the string can include substrings comprises by quotations which must mantain the spaces. What I need is to pass from a string like: This is an 'example string' to the following vector: ["This", "is", "an", "example string"] Which is the best way to achieve this? Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list From wolftracks at invalid.com Wed Nov 23 12:33:55 2011 From: wolftracks at invalid.com (W. eWatson) Date: Wed, 23 Nov 2011 09:33:55 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/22/2011 10:43 PM, Dennis Lee Bieber wrote: > On Tue, 22 Nov 2011 19:46:01 -0800, "W. eWatson" > declaimed the following in > gmane.comp.python.general: > >> >> Of course, Dennis' >> C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe >> wouldn't work either. >> > If you didn't install an ActiveState packaged version, nor hand > installed the win32 extension package into a Python.org installed > system, you won't have PythonWin. > >> I did a Win 7 search Pythonwin.exe, and found nothing. However, >> sometimes that search fails even when though there is something on the >> PC that matches the search. >> >> There is a pythonw.exe under C:\Python32. > > And has been mentioned at least three times in the last week -- > pythonw.exe is the version of the Python interpreter that is supposed to > be the default application for .pyw files. It is the version that does > NOT open a console window for stdin/stdout (IOWs, it is meant for use by > Python scripts that use a graphical library for all I/O -- Tk, wxPython, > etc.). If you ran a graphical script using the plain python.exe it would > open a console window that would just sit there until the script exited. Glad to hear you're keeping count. :-) I'll pin it on my wall. Don't use graphics. From wolftracks at invalid.com Wed Nov 23 12:35:04 2011 From: wolftracks at invalid.com (W. eWatson) Date: Wed, 23 Nov 2011 09:35:04 -0800 Subject: What I do and do not know about installing Python on Win 7 withregard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com><4ECBF80E.9090003@yahoo.com> Message-ID: On 11/23/2011 8:08 AM, John Gordon wrote: > In "Alemu Tadesse" writes: > >> scientific package is not working and complaining about not able to >> find/load DLL ... frustrating for the first day in the python world. ANY >> tip ? > > Post the exact error message you're getting. Also post your code, if it's > not too long. > And post it in a new thread. From wolftracks at invalid.com Wed Nov 23 12:38:36 2011 From: wolftracks at invalid.com (W. eWatson) Date: Wed, 23 Nov 2011 09:38:36 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: So unless Alan Meyer has further interest in this, it looks like it's at an end. It may be time to move on to c++. From arnodel at gmail.com Wed Nov 23 12:40:37 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 23 Nov 2011 17:40:37 +0000 Subject: String splitting by spaces question In-Reply-To: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: On 23 November 2011 17:10, Massi wrote: > Hi everyone, > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces. What I need is to pass from a string like: > > This is an 'example string' > > to the following vector: You mean "list" > ["This", "is", "an", "example string"] > Here's a way: >>> s = "This is an 'example string' with 'quotes again'" >>> [x for i, p in enumerate(s.split("'")) for x in ([p] if i%2 else p.split())] ['This', 'is', 'an', 'example string', 'with', 'quotes again'] -- Arnaud From nicholas.dokos at hp.com Wed Nov 23 12:51:12 2011 From: nicholas.dokos at hp.com (Nick Dokos) Date: Wed, 23 Nov 2011 12:51:12 -0500 Subject: String splitting by spaces question In-Reply-To: Message from "Alemu Tadesse" of "Wed, 23 Nov 2011 11:31:21 CST." <6FA6EB75E3CA4744ADF9EF97D8DAC18B01967924@mail.sunedison.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> <6FA6EB75E3CA4744ADF9EF97D8DAC18B01967924@mail.sunedison.com> Message-ID: <27191.1322070672@alphaville.dokosmarshall.org> Alemu Tadesse wrote: > Can we use rsplit function on an array or vector of strings ? it works > for one not for vector > ... > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces. What I need is to pass from a string like: > > This is an 'example string' > > to the following vector: > > ["This", "is", "an", "example string"] > > Which is the best way to achieve this? > Thanks in advance! You can use a list comprehension: l2 = [x.rsplit(...) for x in l] But for the original question, maybe the csv module would be more useful: you can change delimiters and quotechars to match your input: import csv reader = csv.reader(open("foo.txt", "rb"), delimiter=' ', quotechar="'") for row in reader: print row Nick From kliateni at gmail.com Wed Nov 23 13:04:54 2011 From: kliateni at gmail.com (Karim) Date: Wed, 23 Nov 2011 19:04:54 +0100 Subject: Template class and class design on concrete example xl2csv writer Message-ID: <4ECD35C6.4070306@gmail.com> Hello All, I have the following code and I am quite satisfied with its design BUT I have the feeling I can do better. Basically the, main() execute the program (I did not put the parsing of arguments function). I am opening an Excel document and writing content in a CSV one w/ different format. The design is an abstract template class XLWriter, and derived 'Xl2Csv', 'Xl2Scsv', 'Xl2text' classes to write the correct ASCII DOCUMENT to correct format. The property hook method file_format is implement in these classes and return an object of type 'XlCsvFileFormat' or 'XlTabFileFormat'. It allows to put the right file extension and delimiter. These class are derived from standard csv.excel and csv.excel_tab. At last a Factory class MakeXlWriter has the job to create the correct writer. For now I did not add a strategy pattern which usually goes with the Template pattern. Except from that all better design or others critics will be welcome. Regards karim _______________________________________________________________________________________________________________________________________ from __future__ import print_function import sys, os, argparse, csv, xlrd __all__ = ['main', 'Xl2CsvError', 'XLWriter', 'XlCsvFileFormat', 'XlTabFileFormat', 'Xl2Csv', 'Xl2Scsv', 'Xl2text', 'MakeXlWriter'] class Xl2CsvError(Exception): """The exception class to manage the internal program errors.""" pass class XlWriter(object): """Abstract template class.""" def __init__(self, xlfilename=None, sheets=None): """Initializer.""" if self.__class__.__name__ == 'XlWriter': raise TypeError('Abstract template Class XlWriter could not be instanciated directly!') if not xlfilename: raise Xl2CsvError('Please provide a non empty file name!') else: self._source_name = xlfilename self._book = xlrd.open_workbook(xlfilename) if sheets is not None: if isinstance(sheets[0], int): self._selected_sheets = [self._book.sheet_by_index(sheetnum-1) for sheetnum in sheets] elif isinstance(sheets[0], str): try: self._selected_sheets = [self._book.sheet_by_name(sheetname) for sheetname in sheets] except xlrd.biffh.XLRDError, e: print('{0} in file document {1}'.format(e, xlfilename)) sys.exit(1) else: raise Xl2CsvError('Sheets element type not recognized!') else: self._selected_sheets = self._book.sheets() def write(self): """The file extraction public method.""" for sheet in self._selected_sheets: xlfilename = '{sheet}{ext}'.format(sheet=sheet.name, ext='.'+self.file_format.extension.lower()) try: writer = csv.writer(open(xlfilename, 'wb'), delimiter=self.file_format.delimiter) print("Creating csv file '{file}' for sheet '{sheet}' contained in document {src} ...".format( sheet=sheet.name, file=xlfilename, src=self._source_name), end=' ') for row in xrange(sheet.nrows): writer.writerow(sheet.row_values(row)) print('Done.') except csv.Error, e: print(e) return 1 return 0 @property def file_format(self): """Hook method. Need to implement in derived classes. Should return an XLAsciiFileFormat object to get file extension and inner delimiter. """ pass class XlCsvFileFormat(csv.excel): """Add file extension to the usual properties of Excel-generated CSV files.""" extension = 'CSV' class XlTabFileFormat(csv.excel_tab): """Add file extension to the usual properties of Excel-generated delimited files.""" extension = 'TXT' class Xl2Csv(XlWriter): @property def file_format(self): """Hook factory method""" return XlCsvFileFormat() class Xl2Scsv(XlWriter): @property def file_format(self): """Hook factory method""" _format = XlCsvFileFormat() _format.extension = 'SCSV' _format.delimiter = ';' return _format class Xl2Text(XlWriter): @property def file_format(self): """Hook factory method""" return XlTabFileFormat() class MakeXlWriter(object): """Factory class for XLWriter objects. """ @staticmethod def make(xlfilename=None, sheets=None, extension='CSV'): if extension == "TXT": return Xl2Text(xlfilename=xlfilename, sheets=sheets) elif extension == "SCSV": return Xl2Scsv(xlfilename=xlfilename, sheets=sheets) elif extension == "CSV": return Xl2Csv(xlfilename=xlfilename, sheets=sheets) def main(): """Main of this application""" args = _process_command_line() args.xl.close() writer = MakeXlWriter.make(xlfilename=args.xl.name, sheets=args.sheets, extension=args.ext) return writer.write() ___________________________________________________________________________________________________________________________ From arnodel at gmail.com Wed Nov 23 13:29:05 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 23 Nov 2011 18:29:05 +0000 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 23 November 2011 17:38, W. eWatson wrote: [...] > It may be time to move on to c++. Good Luck. Bye! -- Arnaud From malaclypse2 at gmail.com Wed Nov 23 13:34:39 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 23 Nov 2011 13:34:39 -0500 Subject: String splitting by spaces question In-Reply-To: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: On Wed, Nov 23, 2011 at 12:10 PM, Massi wrote: > Hi everyone, > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces. What I need is to pass from a string like: > > This is an 'example string' > > to the following vector: > > ["This", "is", "an", "example string"] > > Which is the best way to achieve this? > This sounds a lot like the way a shell parses arguments on the command line. If that's your desire, python has a module in the standard library that will help, called shlex (http://docs.python.org/library/shlex.html). Particularly, shlex.split may do exactly what you want out of the box: Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32 >>> import shlex >>> s = "This is an 'example string'" >>> shlex.split(s) ['This', 'is', 'an', 'example string'] >>> -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Wed Nov 23 14:00:39 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 23 Nov 2011 19:00:39 +0000 Subject: Python 2.7.2 on XP In-Reply-To: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> References: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> Message-ID: <4ECD42D7.7010207@mrabarnett.plus.com> On 23/11/2011 15:40, Alemu Tadesse wrote: > I am new to python. I do not know why my python editor (for 2.7.2) > changes everything to just black and white after saving. If you're using IDLE, are you saving the file without the .py extension? That could be the problem. > No color for say the built in functions for loops defs .... they all > look the same - it is annoying for someone coming from another > editors that help you track/easily see your work. I just un installed > it to install it again. I know it is pain to install all the > scientific things again. I wish Python has something like R > (R-studio) from which you can install packages very easily. I just > started yesterday and already frustrated with it. I am sticking to > python only because I hear good things about it and I think it is my > problem. > From atadesse at sunedison.com Wed Nov 23 14:02:11 2011 From: atadesse at sunedison.com (Alemu Tadesse) Date: Wed, 23 Nov 2011 13:02:11 -0600 Subject: Python 2.7.2 on XP In-Reply-To: <4ECD42D7.7010207@mrabarnett.plus.com> References: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> <4ECD42D7.7010207@mrabarnett.plus.com> Message-ID: <6FA6EB75E3CA4744ADF9EF97D8DAC18B0196798B@mail.sunedison.com> I am saving it with .py extention -----Original Message----- From: python-list-bounces+atadesse=sunedison.com at python.org [mailto:python-list-bounces+atadesse=sunedison.com at python.org] On Behalf Of MRAB Sent: Wednesday, November 23, 2011 12:01 PM To: python-list at python.org Subject: Re: Python 2.7.2 on XP On 23/11/2011 15:40, Alemu Tadesse wrote: > I am new to python. I do not know why my python editor (for 2.7.2) > changes everything to just black and white after saving. If you're using IDLE, are you saving the file without the .py extension? That could be the problem. > No color for say the built in functions for loops defs .... they all > look the same - it is annoying for someone coming from another > editors that help you track/easily see your work. I just un installed > it to install it again. I know it is pain to install all the > scientific things again. I wish Python has something like R > (R-studio) from which you can install packages very easily. I just > started yesterday and already frustrated with it. I am sticking to > python only because I hear good things about it and I think it is my > problem. > -- http://mail.python.org/mailman/listinfo/python-list From gordon at panix.com Wed Nov 23 14:11:37 2011 From: gordon at panix.com (John Gordon) Date: Wed, 23 Nov 2011 19:11:37 +0000 (UTC) Subject: Python 2.7.2 on XP References: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> <4ECD42D7.7010207@mrabarnett.plus.com> Message-ID: In "Alemu Tadesse" writes: > I am saving it with .py extention It would really help us answer your question if you identified which editor you're using. IDLE? PyScripter? Eclipse? PyCharm? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From miki.tebeka at gmail.com Wed Nov 23 15:40:27 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 23 Nov 2011 12:40:27 -0800 (PST) Subject: String splitting by spaces question In-Reply-To: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: <29337570.208.1322080827452.JavaMail.geo-discussion-forums@yqiv14> http://docs.python.org/library/shlex.html From nulla.epistola at web.de Wed Nov 23 16:13:28 2011 From: nulla.epistola at web.de (Sibylle Koczian) Date: Wed, 23 Nov 2011 22:13:28 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ECC6C65.2090902@yahoo.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ECC6C65.2090902@yahoo.com> Message-ID: Am 23.11.2011 04:45, schrieb Alan Meyer: > On 11/22/2011 3:05 PM, Dennis Lee Bieber wrote: >> On Tue, 22 Nov 2011 14:29:18 -0500, Alan Meyer >> declaimed the following in gmane.comp.python.general: >> >>> On 11/22/2011 1:55 PM, Alan Meyer wrote: >>> ... >>>> 6. Select, or navigate to and select, the python IDLE interpreter. >>> ... >>> On my system that's >>> C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe >>> >> Note that this is not the Tk based IDLE (which is implemented, >> itself, as a .pyw file and is not natively executable -- which seems to >> be one of the problems; Win7 has removed the detailed file type >> association windows so you can't specify that the "application" is >> pythonw.exe running idle.pyw using one's selected file as the argument >> to the mess). > > Bummer! > > Sorry W.eWatson, my instructions may not work. I've got the ActiveState > Python on my Windows machine. It runs a .exe file as the IDLE > executable. If your implementation doesn't have an exe then you're going > to have to do some more complex work. > PythonWin hasn't got anything to do with IDLE, it's another IDE for Python. It is part of the Python for Windows extensions: http://sourceforge.net/projects/pywin32/. From ben+python at benfinney.id.au Wed Nov 23 16:49:48 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 24 Nov 2011 08:49:48 +1100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <878vn67blv.fsf@benfinney.id.au> Arnaud Delobelle writes: > On 23 November 2011 17:38, W. eWatson wrote: > [...] > > It may be time to move on to c++. > > Good Luck. Bye! Sadly, IME it's most often the case that the person who threatens to leave with just about every message will instead stick around a long time, repeating the same threats while expecting those threats to elicit support. -- \ ?It is far better to grasp the universe as it really is than to | `\ persist in delusion, however satisfying and reassuring.? ?Carl | _o__) Sagan | Ben Finney From ameyer2 at yahoo.com Wed Nov 23 17:29:29 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Wed, 23 Nov 2011 17:29:29 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/23/2011 12:38 PM, W. eWatson wrote: > So unless Alan Meyer has further interest in this, it looks like it's at > an end. > > It may be time to move on to c++. > C++ is a ton of fun. You haven't lived until you've made a syntax error in a template instantiation and seen a hundred cascading error messages from included files that you didn't know you included. Unlike Python, it really builds character. I say, go for it! Alan From anacrolix at gmail.com Wed Nov 23 17:58:59 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Thu, 24 Nov 2011 09:58:59 +1100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: Moving to C++ is _always_ a step backwards. On Thu, Nov 24, 2011 at 9:29 AM, Alan Meyer wrote: > On 11/23/2011 12:38 PM, W. eWatson wrote: >> >> So unless Alan Meyer has further interest in this, it looks like it's at >> an end. >> >> It may be time to move on to c++. >> > > C++ is a ton of fun. ?You haven't lived until you've made a syntax error in > a template instantiation and seen a hundred cascading error messages from > included files that you didn't know you included. > > Unlike Python, it really builds character. > > I say, go for it! > > ? ?Alan > -- > http://mail.python.org/mailman/listinfo/python-list > From Phil_member at newsguy.com Wed Nov 23 19:02:40 2011 From: Phil_member at newsguy.com (Phil Rist) Date: 23 Nov 2011 16:02:40 -0800 Subject: Running Idle on Windows 7 Message-ID: I have installed ActiveState Python 32bit on my computer. There are potentially five different ways that Idle can be run. Actually six if you include activating a command window and typing in the command. We will not do that here. The first way is to use the shortcut put into the start menu by the ActiveState installation program. Left click on the start menu icon followed by hovering over the 'All Programs' button will bring up the menu. At this point find and click the ActiveState ActivePython entry. This will bring up the Python sub-menu on which Idle can be found and clicked to start Idle. If this is not previously you could create a shortcut as described below and move it to the start button. I do not know how to do that on Windows 7. The other methods may require some effort on your part. Each extension has a file type. Each file type has a context menu which can be accessed by right clicking an appropriate Windows Explorer entry or desktop icon. The contents of the context menu is maintained in the registry. The Regedit utility can be used to modify the menu. The following text typed into a file with a .reg extension can be used to create part of a context menu for files with either a .py or .pyw extension. Once the file is created it can be run by double clicking the file's entry in Windows Explorer. The file type I selected is pyfile. If you select a file type that already exists it will be overwritten. If these extensions have already been given a file type that file type should be used. If there is already an Open command and you do not want to replace it change the Open names here to something that is not already used. Note the wrapping of the last line. REGEDIT4 [HKEY_CLASSES_ROOT\.py] @="pyfile" [HKEY_CLASSES_ROOT\.pyw] @="pyfile" [HKEY_CLASSES_ROOT\pyfile] @="Python source" [HKEY_CLASSES_ROOT\pyfile\Shell] @="Open" [HKEY_CLASSES_ROOT\pyfile\Shell\Open] @="Open" "EditFlags"=hex:01,00,00,00 [HKEY_CLASSES_ROOT\pyfile\Shell\Open\Command] @="c:\\sys\\Language\\python\\pythonw.exe C:\\Sys\\Language\\Python\\Lib\\idlelib\\idle.pyw \"%1\" " The first two group of lines simply assign the pyfile file type to the two extensions. The third group sets the file type description displayed by Windows Explorer to 'Python Source'. The fourth group makes Open the default command. The command that will be executed when a file is doubled clicked. The last group defines the text for the command. This is basically the same as any command entered in a command window except instead of a file name %1 is entered. This will be replaced by the name of the selected python file. Also any '\' or '"' which appear in the command must be preceeded by a '\'. The command given here will run Idle. The file paths will need to be changed to what is appropriate on your computer. I noticed that I had a file type Python.File. This file type had two commands one to run the program, 'Open' and one to Edit with Pythonwin, 'Edit with Pythonwin'. This was setup by the ActiveState installation program. These can be recovered with a .reg file with the following contents. REGEDIT4 [HKEY_CLASSES_ROOT\.py] @="Python.File" [HKEY_CLASSES_ROOT\.pyw] @="Python.File" There is also a context menu for directories. One menu for all directories. An entry for Idle can be created with the following code. This also is entered into a .reg file. The same rules apply. Here %1 will be replaced by the directory path. Like the Start Menu method you do not have access to a file path. Note the wrapping of the last line. REGEDIT4 [HKEY_CLASSES_ROOT\Directory\Shell\Idle] @="Idle" "EditFlags"=hex:01,00,00,00 [HKEY_CLASSES_ROOT\Directory\Shell\Idle\Command] @="c:\\sys\\Language\\python\\pythonw.exe C:\\Sys\\Language\\Python\\Lib\\idlelib\\idle.pyw " The fourth way is to create a shortcut to Idle. This is basically the same as the Start Menu method except the shortcut can be put on the desktop where it will appear as an icon or in any directory where it can be accessed from Windows Explorer. My technique here was to create a directory called 'Python'. Within that directory I created three directories 'New', 'Explore' and 'Projects' to contain my Python programs. The 'Python' directory contains infrastructure files such as the .reg files. I created a fourth sub-menu called 'Python Shortcuts'. I added several shortcuts which I thought would be useful, including a shortcut to Idle. Windows allows me to create a toolbar on the quick launch bar. This toolbar contains a list of the contents of a selected directory. In my case the 'Python Shortcuts' directory. I can run Idle by clicking on the toolbar and then the entry for Idle. To create the shortcut find the Python interpreter pythonw.exe. Right click it and select 'Create shortcut'. The shortcut will appear in the same directory as pythonw.exe. Drag it to the directory you want it in. Right click it and select 'Properties'. In the middle of the dialog is a text box labeled 'Target'. This field contains the command which will be executed. Add the path to Idle.pyw to the end of the command. Click the OK button. You can also create a shortcut to the supplied .bat file. This will work without any further editing. The last method is to use a program which accepts command lines from some source. I have a buttonbar program which uses an initialization file which defines each command for each button. As a word of warning, .reg files are not the easiest things to work with. From Phil_member at newsguy.com Wed Nov 23 19:20:43 2011 From: Phil_member at newsguy.com (Phil Rist) Date: 23 Nov 2011 16:20:43 -0800 Subject: String splitting by spaces question References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: In article <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f at r9g2000vbw.googlegroups.com>, Massi says... > >Hi everyone, > >I have to parse a string and splitting it by spaces. The problem is >that the string can include substrings comprises by quotations which >must mantain the spaces. What I need is to pass from a string like: > >This is an 'example string' > >to the following vector: > >["This", "is", "an", "example string"] > >Which is the best way to achieve this? >Thanks in advance! Is this what you want? import shlex lText = "This is a 'short string' for you to read." lWords = shlex.split(lText) print lWords produces, ['This', 'is', 'a', 'short string', 'for', 'you', 'to', 'read.'] Shlex can be found under 'Program Frameworks' under 'The Python Standard Library' of ActivePython 2.7 documentation. C:\Source\Python\New> From steve+comp.lang.python at pearwood.info Wed Nov 23 21:16:10 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 02:16:10 GMT Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> On Wed, 23 Nov 2011 10:37:56 +0000, Tim Golden wrote: > The interpreter inherits the command shell's history function: Open a > cmd window and then a Python session. Do some stuff. > > Ctrl-Z to exit to the surrounding cmd window. Do some random cmd stuff: > dir, cd, etc. > > Start a second Python session. up-arrow etc. will bring back the > previous Python session's commands (and not the ones you entered in the > surrounding shell) Doesn't work for me, at least not with Python 2.5 and 2.6 on Linux. I don't suppose you are running a site-specific command history script in your startup.py file? [steve at wow-wow ~]$ unset PYTHONSTARTUP [steve at wow-wow ~]$ python Python 2.5 (r25:51908, Nov 6 2007, 16:54:01) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print 42 42 >>> [1]+ Stopped python [steve at wow-wow ~]$ python Python 2.5 (r25:51908, Nov 6 2007, 16:54:01) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> You can't see it, but I'm hitting the up arrow on that last line, and nothing is happening except my console is flashing :) -- Steven From devplayer at gmail.com Wed Nov 23 22:09:49 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 23 Nov 2011 19:09:49 -0800 (PST) Subject: Is there any way to unimport a library References: Message-ID: Seems so far the common way to fully unload any import is to exit the Python session. Only if this is true do I offer this hackish idea: Therefore you might wish to run an os script instead of a python script right off. Here is my hack at it... Something like this: file myapp.bat -------------- python get_availble_imports.py available_imports.log python myapp.py available_imports.log file get_availble_imports.py ---------------------------- find_module_names = """ os sys time sqlite lib1_verA lib2_verA sqlite3 lib1_verB lib2_verB """ # other code i'm leaving out of this forum post def find_module_names_using_pydoc( block_string ): '''Searchs for module names, provided in a block string, against the resultant module names list returned from pydoc. \n Returns a list of strings, being the intersection of module names from both lists.''' all_wanted_modules = parse_block_for_module_names( block_string ) # use split and drop empties module_names_found = [] # walk_packages actually imports libraries; # so you know the import should work. # i call em modules; but they could be packages too # following line can take many seconds to run package_generator = pydoc.pkgutil.walk_packages(path=None, prefix='', onerror=error_handler) for package_name in package_generator: module_loader, module_name, ispkg = package_name if module_name in all_wanted_modules: module_names_found.append( module_name ) print repr( module_name ) return module_names_found found = find_module_names_using_pydoc( find_module_names ) #Then with a switch statement (if/elif) create a string with to be #saved to the log file with what module names are in usable_mods if 'sqlite' in found and 'lib1_verA' in found and 'lib2_verA' in found: save('import sqlite, lib1_verA, lib2_verA') elif 'sqlite' in found and 'lib1_verB' in found and 'lib2_verB' in found: save('import sqlite3, lib1_verB, lib2_verB') else: raise ImportError('Necessary packages not found') file myapp.py ------------- with open('available_imports.log','r') as f: text = f.read() exec(text) # DONE From devplayer at gmail.com Wed Nov 23 22:23:09 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 23 Nov 2011 19:23:09 -0800 (PST) Subject: Is there any way to unimport a library References: Message-ID: <0edae6b0-439c-4d0f-ba03-e5b62d04693c@s6g2000vbc.googlegroups.com> btw if you like processing text outside of python (say using grep or something) python -c "help('modules')" > all_imports.log which you might note on windows get's processed to: python -c "help('modules')" 1> all_imports.log on windows from within a batch file From steve+comp.lang.python at pearwood.info Wed Nov 23 22:29:16 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 03:29:16 GMT Subject: Capturing SIGSTOP Message-ID: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> I'd like to perform a task when the user interrupts my application with Ctrl-Z on Linux. I tried installing a signal handler: import signal def handler(signalnum, stackframe): print "Received signal %d" % signalnum signal.signal(signal.SIGSTOP, handler) But I got a RuntimeError: Traceback (most recent call last): File "", line 1, in RuntimeError: (22, 'Invalid argument') This isn't documented: http://docs.python.org/library/signal.html#signal.signal Is there a way to catch SIGSTOP? -- Steven From nirmanlongjam at gmail.com Wed Nov 23 22:50:16 2011 From: nirmanlongjam at gmail.com (nirman longjam) Date: Wed, 23 Nov 2011 19:50:16 -0800 (PST) Subject: Tree data structure with: single, double and triple children option along with AVM data at each node Message-ID: <7548c4b6-f3f1-4f96-9a77-fcb9e0edeed0@s4g2000yqk.googlegroups.com> Dear sir, I am very happy to find this group. Sir, i am new to Python. Currently i am working on text processing. Can you give me some suggestions about Tree data structure representation, where i require each node capable to handle: only one child, or up to 3 children plus hold feature information. Thanking you, L. Nirman Singh From devplayer at gmail.com Wed Nov 23 22:53:44 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 23 Nov 2011 19:53:44 -0800 (PST) Subject: String splitting by spaces question References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: <45795de6-01d4-4969-9a6e-872ceadaf645@da3g2000vbb.googlegroups.com> This is an 'example string' Don't for get to watch for things like: Don't, Can't, Won't, I'll, He'll, Hor'davors, Mc'Kinly From steve+comp.lang.python at pearwood.info Wed Nov 23 22:55:56 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 03:55:56 GMT Subject: Bind key press to call function Message-ID: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> I'm looking for a way to interrupt a long-running function on a key press, but without halting the function. E.g. if I have these two functions: def handler(*args): print "caught interrupt and continuing..." def exercise_cpu(): for i in range(8): print "working..." for j in range(1000000): pass print "done" and I call exercise_cpu(), then type some key combination (say, Ctrl-x-p for the sake of the argument), I'd like the result to look something like this: >>> exercise_cpu() working... working... working... working... working... working... caught interrupt and continuing... working... working... done I think I want to use the readline module to catch the key press Ctrl-x-p and generate a signal, say SIGUSR1, then use the signal module to install a signal handler to catch SIGUSR1. Is this the right approach, or is there a better one? Does anyone show me an example of working code that does this? Linux only solutions are acceptable. -- Steven From rosuav at gmail.com Wed Nov 23 23:20:09 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 15:20:09 +1100 Subject: Bind key press to call function In-Reply-To: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 2:55 PM, Steven D'Aprano wrote: > I'm looking for a way to interrupt a long-running function on a key > press, but without halting the function. I assume there's a reason for not using Ctrl-C and SIGINT with the signal module? This looks like the classic "sigint handler sets a flag that the main loop polls" structure. ChrisA From rosuav at gmail.com Wed Nov 23 23:22:23 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 15:22:23 +1100 Subject: Capturing SIGSTOP In-Reply-To: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 2:29 PM, Steven D'Aprano wrote: > Is there a way to catch SIGSTOP? In the strictest sense, no; SIGSTOP can't be caught. However, some systems have SIGTSTP which is sent when you hit Ctrl-Z, which would be what you're looking for. http://www.gnu.org/s/hello/manual/libc/Job-Control-Signals.html Tested on my Linux box only; this almost certainly won't work on Windows. ChrisA From rosuav at gmail.com Wed Nov 23 23:30:57 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 15:30:57 +1100 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 1:16 PM, Steven D'Aprano wrote: > On Wed, 23 Nov 2011 10:37:56 +0000, Tim Golden wrote: > >> The interpreter inherits the command shell's history function: Open a >> cmd window and then a Python session. Do some stuff. >> >> Ctrl-Z to exit to the surrounding cmd window. Do some random cmd stuff: >> dir, cd, etc. >>>> > [1]+ ?Stopped ? ? ? ? ? ? ? ? python Ctrl-Z is the Windows equivalent (well, mostly) of Linux's Ctrl-D. You want to cleanly exit the interpreter, not SIGSTOP it. ChrisA From Nikunj.Badjatya at emc.com Wed Nov 23 23:44:30 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Wed, 23 Nov 2011 23:44:30 -0500 Subject: Thread problem In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D616@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D616@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D735@MX34A.corp.emc.com> Can someone help me on this please? From: python-list-bounces+nikunj.badjatya=emc.com at python.org [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of Nikunj.Badjatya at emc.com Sent: Wednesday, November 23, 2011 11:15 AM To: python-list at python.org Subject: Thread problem Howdy All, Please see http://pastebin.com/GuwH8B5C . Its a sample program implementing progressbar in multithreaded program. Here I am creating a thread and passing update2() function to it. Now wheneever I press CTRL-C, the program isnt returning to prompt. ! Can someone help me out with this please. ! Thanks Nikunj -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Thu Nov 24 01:07:47 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 06:07:47 GMT Subject: Bind key press to call function References: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecddf33$0$30003$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 15:20:09 +1100, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 2:55 PM, Steven D'Aprano > wrote: >> I'm looking for a way to interrupt a long-running function on a key >> press, but without halting the function. > > I assume there's a reason for not using Ctrl-C and SIGINT with the > signal module? Yes, I want to leave Ctrl-C alone and have a similar, but separate, signal handler (or equivalent). > This looks like the classic "sigint handler sets a flag that the main > loop polls" structure. Exactly. I am open to alternative methods if they are lightweight. -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 24 01:11:19 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 06:11:19 GMT Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 15:30:57 +1100, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 1:16 PM, Steven D'Aprano > wrote: >> On Wed, 23 Nov 2011 10:37:56 +0000, Tim Golden wrote: >> >>> The interpreter inherits the command shell's history function: Open a >>> cmd window and then a Python session. Do some stuff. >>> >>> Ctrl-Z to exit to the surrounding cmd window. Do some random cmd >>> stuff: dir, cd, etc. >>>>> >> [1]+ ?Stopped ? ? ? ? ? ? ? ? python > > Ctrl-Z is the Windows equivalent (well, mostly) of Linux's Ctrl-D. You > want to cleanly exit the interpreter, not SIGSTOP it. One of us is confused, and I'm pretty sure it's you :) Tim went on to say "Obviously this only applies when an underlying cmd session persists", which I understood as implying that he too is using Linux where Ctrl-Z stops the process, but does not exit it. -- Steven From torriem at gmail.com Thu Nov 24 01:15:20 2011 From: torriem at gmail.com (Michael Torrie) Date: Wed, 23 Nov 2011 23:15:20 -0700 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> Message-ID: <4ECDE0F8.2030701@gmail.com> On 11/22/2011 09:14 AM, W. eWatson wrote: > On 11/21/2011 7:00 PM, alex23 wrote: >> "W. eWatson" wrote: >>> Comments? >> >> Please don't start multiple threads on the same issue. > Your joking, right, or do you just prefer 500 line threads wandering all > over the place? Most of us use threaded e-mail clients or nntp clients (Gmail's conversations are rubbish for this kind of thing) and so yes, having all 500 responses wandering all over the place in an orderly tree structure is infinitely preferred to many threads all talking about the same thing. Each message contains a referral id that refers the message that is being replied to. Thus the logical flow of the conversation is preserved very well despite many posters and meandering conversation branches. From rosuav at gmail.com Thu Nov 24 01:20:30 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 17:20:30 +1100 Subject: Bind key press to call function In-Reply-To: <4ecddf33$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecddf33$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 5:07 PM, Steven D'Aprano wrote: >> This looks like the classic "sigint handler sets a flag that the main >> loop polls" structure. > > Exactly. I am open to alternative methods if they are lightweight. Might be easiest to spin off a thread to do the work, and then have the main thread block on the keyboard. ChrisA From rosuav at gmail.com Thu Nov 24 01:22:35 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 17:22:35 +1100 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 5:11 PM, Steven D'Aprano wrote: > One of us is confused, and I'm pretty sure it's you :) > > Tim went on to say "Obviously this only applies when an underlying cmd > session persists", which I understood as implying that he too is using > Linux where Ctrl-Z stops the process, but does not exit it. Entirely possible :) I blithely assumed from the fact that he said "dir" that it was Windows, but it goes to show what happens when you assume. ChrisA From rick.mansilla at gmail.com Thu Nov 24 01:36:40 2011 From: rick.mansilla at gmail.com (Ricardo Mansilla) Date: Thu, 24 Nov 2011 00:36:40 -0600 Subject: Does py2app improves speed? Message-ID: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> Hi everyone.. My question is exactly as in the subject of This Mail. I have made a Python script which is to slow and i have heard (and common sense also suggest) that if you use some libraries to "frozen" the script the performance improves substantially. So I need to know; is This a myth or it is a fact? Thanks in advance for your time. From steve+comp.lang.python at pearwood.info Thu Nov 24 01:36:53 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 06:36:53 GMT Subject: Capturing SIGSTOP References: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 15:22:23 +1100, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 2:29 PM, Steven D'Aprano > wrote: >> Is there a way to catch SIGSTOP? > > In the strictest sense, no; SIGSTOP can't be caught. However, some > systems have SIGTSTP which is sent when you hit Ctrl-Z, which would be > what you're looking for. That's exactly what I'm looking for, thanks. After catching the interrupt and doing whatever I need to do, I want to allow the process to be stopped as normal. Is this the right way? import signal, os def handler(signalnum, stackframe): print "Received signal %d" % signalnum os.kill(os.getpid(), signal.SIGSTOP) # Hit myself with a brick. signal.signal(signal.SIGTSTP, handler) It seems to work for me (on Linux), but is it the right way? -- Steven From ian.g.kelly at gmail.com Thu Nov 24 03:04:02 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 24 Nov 2011 01:04:02 -0700 Subject: Does py2app improves speed? In-Reply-To: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> Message-ID: On Wed, Nov 23, 2011 at 11:36 PM, Ricardo Mansilla wrote: > Hi everyone.. > My question is exactly as in the subject of This Mail. > I have made a Python ?script which is to slow and i have heard (and common sense also suggest) that if you use some libraries to "frozen" the script the performance improves substantially. So I need to know; is This a myth or it is a fact? > Thanks in advance for your time. I would not expect any speedup. You might see some difference in loading times, but the actual program being run is still just the Python interpreter running your script, and that's not going to run any faster. I had a coworker who wrapped up one of his applications with py2exe / pyInstaller on the theory that since his program would be run from a network share, it would be faster to load a single exe over the network than a bunch of .pyc files plus the files needed to run the interpreter. I can't tell any difference, though. Cheers, Ian From rosuav at gmail.com Thu Nov 24 03:12:13 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 19:12:13 +1100 Subject: Capturing SIGSTOP In-Reply-To: <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 5:36 PM, Steven D'Aprano wrote: > ? ?os.kill(os.getpid(), signal.SIGSTOP) ?# Hit myself with a brick. > Sometimes there'll be a raise() function but it's going to do the same thing. Yep, that would be the way to do it. ChrisA From rosuav at gmail.com Thu Nov 24 03:15:02 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 19:15:02 +1100 Subject: Capturing SIGSTOP In-Reply-To: <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 5:36 PM, Steven D'Aprano wrote: > ? ?os.kill(os.getpid(), signal.SIGSTOP) ?# Hit myself with a brick. > > > It seems to work for me (on Linux), but is it the right way? And - if your system has SIGTSTP, it'll have SIGSTOP and this will be how it works. (Windows has neither.) This code will probably work fine on all modern Unix-like systems, but if it fails anywhere, it'll be for lack of SIGTSTP I would say. ChrisA From mail at timgolden.me.uk Thu Nov 24 03:51:35 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Nov 2011 08:51:35 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ECE0597.60802@timgolden.me.uk> On 24/11/2011 06:22, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 5:11 PM, Steven D'Aprano > wrote: >> One of us is confused, and I'm pretty sure it's you :) >> >> Tim went on to say "Obviously this only applies when an underlying cmd >> session persists", which I understood as implying that he too is using >> Linux where Ctrl-Z stops the process, but does not exit it. > > Entirely possible :) I blithely assumed from the fact that he said > "dir" that it was Windows, but it goes to show what happens when you > assume. Ahem. Sorry for any confusion caused. The OP was asking about the situation on Windows, and I was responding in that context. The Ctrl-Z thing is what *exits* the interpreter on Windows (a la Ctrl-D on Linux). In short - on Windows, within one cmd shell you can open and exit the interpreter as many times as you like and the Python command history will be retained via the cmd shell's history mechanism, and kept distinct from the history of other things you may type into the cmd shell. If you exit the cmd shell then that history is lost, and I'm not aware of any mechanism for retaining it. All this may or may not be of any use to the OP. I was responding to this comment by Steven: "The default interactive interpreter for Python doesn't have persistent history, so if you exit the interpreter and restart it, your commands are gone." TJG From ulrich.eckhardt at dominolaser.com Thu Nov 24 06:56:42 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 24 Nov 2011 12:56:42 +0100 Subject: reading optional configuration from a file Message-ID: Hi! I have a few tests that require a network connection. Typically, the target will be localhost on port 20000. However, sometimes these settings differ, so I want to be able to optionally set them. What I'm currently doing is this: try: from settings import REMOTE_HOST, REMOTE_PORT except ImportError: REMOTE_HOST = 'localhost' REMOTE_PORT = 20000 This works fine. However, there are actually a few more settings that can be overridden, so I changed the whole thing to this: try: from settings import * if not 'REMOTE_HOST' in locals(): REMOTE_HOST = 'localhost' if not 'REMOTE_PORT' in locals(): REMOTE_PORT = 20000 except ImportError: REMOTE_HOST = 'localhost' REMOTE_PORT = 20000 Yes, wildcard imports are dangerous, but that's something I don't mind actually, this is an internal tool for clueful users. Still, this is ugly, since the defaults are stored redundantly, so I went to this variant: REMOTE_HOST = 'localhost' REMOTE_PORT = 20000 try: from settings import * except ImportError: pass Now, in order to avoid ambiguities, I thought about using relative imports, but there I'm stomped because wildcard imports are not supported for relative imports, it seems. How would you do it? Any other suggestions? Cheers! Uli From bnrj.rudra at gmail.com Thu Nov 24 07:31:35 2011 From: bnrj.rudra at gmail.com (Rudra Banerjee) Date: Thu, 24 Nov 2011 18:01:35 +0530 Subject: suitability of python Message-ID: <1322137895.4211.3.camel@roddur> Dear friends, I am a newbie in python and basically i use python for postprocessing like plotting, data manipulation etc. Based on ease of programming on python I am wondering if I can consider it for the main development as well. My jobs (written on fortran) runs for weeks and quite CPU intensive. How python works on these type of heavy computation? Any comment or reference is welcome. From moky.math at gmail.com Thu Nov 24 07:46:13 2011 From: moky.math at gmail.com (Laurent Claessens) Date: Thu, 24 Nov 2011 13:46:13 +0100 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: Le 24/11/2011 13:31, Rudra Banerjee a ?crit : > Dear friends, > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? > Any comment or reference is welcome. If you need mathematical power (especially symbolic computations), you should also consider Sage[1] which is kind of a module of math over python. In some situations, Sage is the "correct" successor of Fortran instead of plain python. Well, it does not answers the question, but ... Laurent [1] http://sagemath.org From d at davea.name Thu Nov 24 08:08:39 2011 From: d at davea.name (Dave Angel) Date: Thu, 24 Nov 2011 08:08:39 -0500 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: <4ECE41D7.9090103@davea.name> On 11/24/2011 07:31 AM, Rudra Banerjee wrote: > Dear friends, > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? > Any comment or reference is welcome. > If I take your description at face value, then I'd say that stock CPython would be slower than Fortran. If the CPU-intensive parts had to be rewritten in CPython, they'd be slower than the Fortran they replace, by somewhere between 10:1 and 500:1. Further, if you've already got those Fortran algorithms written and debugged, why rewrite them? And finally, even for new code, you might be getting ideas for your algorithms from journals and other resources, where the examples may well be done in Fortran, so productivity might be best in Fortran as well. HOWEVER, you don't have to use stock CPython, alone. It could be that some of your Fortran algorithms are written in shared libraries, and that you could get your CPython code to call them to do the "heavy lifting." Or it could be that numpy, sage, or other 3rd party libraries might be usable for your particular problems, and that speed is then comparable to Fortran. Or it could be that one of the alternative Python implementations might be fast enough. Or it could even be that you're mistaken that the present code is even CPU intensive. Or it could be that by the time you recode the problem in Python, you discover a more efficient algorithm, and that way gain back all the speed you theoretically lost. There are tools to measure things, though I'm not the one to recommend specifics. And those probably depend on your platform as well. The last Fortran that I wrote was over 40 years ago. I'm afraid when I need speed, I usually use C++. But if I were starting a personal math-intensive project now, I'd try to prototype it in Python, and only move portions of it to Fortran or other compiled language. Only the portions that measurably took too long. And those portions might be rewritten in Cython, C++, or Fortran, depending on what kind of work they actually did. Another alternative that might make sense is to use Python as a "macro language" to Fortran, where you call out to Python to automate some tasks within the main program. I have no experience with doing that, but I assume it'd be something like how MSWord can call out to VBA routines. And it'd make the most sense when the main app is already written, and the macro stuff is an afterthought. I think the real point is that it doesn't have to be "all or nothing." I suspect that the pieces you're already doing in Python are calling out to pre-existing libraries as well. So your plotting code does some massaging, and then calls into some plotting library, or even execs a plotting executable. -- DaveA From rick.mansilla at gmail.com Thu Nov 24 08:26:27 2011 From: rick.mansilla at gmail.com (Ricardo Mansilla) Date: Thu, 24 Nov 2011 07:26:27 -0600 Subject: Does py2app improves speed? In-Reply-To: References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> Message-ID: <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... Bye. From d at davea.name Thu Nov 24 08:38:43 2011 From: d at davea.name (Dave Angel) Date: Thu, 24 Nov 2011 08:38:43 -0500 Subject: Does py2app improves speed? In-Reply-To: <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> Message-ID: <4ECE48E3.6070701@davea.name> On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: > Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... > Bye. Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Python language for all or most of the app. There have been lots of threads on the topic. -- DaveA From rick.mansilla at gmail.com Thu Nov 24 09:02:49 2011 From: rick.mansilla at gmail.com (Ricardo Mansilla) Date: Thu, 24 Nov 2011 08:02:49 -0600 Subject: Does py2app improves speed? In-Reply-To: <4ECE48E3.6070701@davea.name> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> Message-ID: <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> Most of m?thods for improving the speed are related to efficient memory management and using specific structures for a specific tasks... But i have already optimized my code (which is very short actually) following all these rules and it is very slow yet. Do you think there is another way to do This? Probably i'm missing something here... On 24/11/2011, at 07:38, Dave Angel wrote: > On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: >> Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... >> Bye. > Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Python language for all or most of the app. There have been lots of threads on the topic. > > -- > > DaveA > From ulrich.eckhardt at dominolaser.com Thu Nov 24 09:05:55 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 24 Nov 2011 15:05:55 +0100 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <87hb23ei00.fsf@benfinney.id.au> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> <87hb23ei00.fsf@benfinney.id.au> Message-ID: <4jv1q8-sv.ln1@satorlaser.homedns.org> Am 17.11.2011 00:59, schrieb Ben Finney: > David Robinow writes: >> but your code works fine on Windows. Thanks. > > I'm glad to know that. Perhaps you could investigate why, and suggest an > update to the above documentation if it's wrong? The bug tracker at > would be the appropriate place for such a > suggestion. Interestingly, on MS Windows (XP here), every commandline program inherits the history functionality (browsing with cursor up/down) from the shell it runs in. That means the program itself doesn't have to supply any of that, but also that it can't customize any of that... The history is not persistent though, it is restricted to that shell. Still, this might explain why it never bothered anyone enough to fix things properly. ;) Uli From anacrolix at gmail.com Thu Nov 24 09:15:20 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Fri, 25 Nov 2011 01:15:20 +1100 Subject: Does py2app improves speed? In-Reply-To: <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> Message-ID: Yes. Try posting your code. On Fri, Nov 25, 2011 at 1:02 AM, Ricardo Mansilla wrote: > Most of m?thods for improving the speed are related to efficient memory management and using specific structures for a specific tasks... But i have already optimized my code (which is very short actually) following all these rules and it is very slow yet. > Do you think there is another way to do This? Probably i'm missing something here... > > On 24/11/2011, at 07:38, Dave Angel wrote: > >> On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: >>> Well, that's sad... I think Im gonna end getting back to C++ for This. ?But anyway, thanks a lot for the quick answer... >>> Bye. >> Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Python language for all or most of the app. There have been lots of threads on the topic. >> >> -- >> >> DaveA >> > -- > http://mail.python.org/mailman/listinfo/python-list > From anacrolix at gmail.com Thu Nov 24 09:21:24 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Fri, 25 Nov 2011 01:21:24 +1100 Subject: reading optional configuration from a file In-Reply-To: References: Message-ID: ? ?REMOTE_HOST = 'localhost' ? ?REMOTE_PORT = 20000 ? ?try: from .settings import * ? ?except ImportError: ? ? ? ?pass This works? If you're using an old version of Python you may need to mess about with __future__. On Thu, Nov 24, 2011 at 10:56 PM, Ulrich Eckhardt wrote: > Hi! > > I have a few tests that require a network connection. Typically, the target > will be localhost on port 20000. However, sometimes these settings differ, > so I want to be able to optionally set them. > > What I'm currently doing is this: > > ? ?try: > ? ? ? ?from settings import REMOTE_HOST, REMOTE_PORT > ? ?except ImportError: > ? ? ? ?REMOTE_HOST = 'localhost' > ? ? ? ?REMOTE_PORT = 20000 > > This works fine. However, there are actually a few more settings that can be > overridden, so I changed the whole thing to this: > > ? ?try: > ? ? ? ?from settings import * > ? ? ? ?if not 'REMOTE_HOST' in locals(): > ? ? ? ? ? ?REMOTE_HOST = 'localhost' > ? ? ? ?if not 'REMOTE_PORT' in locals(): > ? ? ? ? ? ?REMOTE_PORT = 20000 > ? ?except ImportError: > ? ? ? ?REMOTE_HOST = 'localhost' > ? ? ? ?REMOTE_PORT = 20000 > > Yes, wildcard imports are dangerous, but that's something I don't mind > actually, this is an internal tool for clueful users. Still, this is ugly, > since the defaults are stored redundantly, so I went to this variant: > > ? ?REMOTE_HOST = 'localhost' > ? ?REMOTE_PORT = 20000 > ? ?try: > ? ? ? ?from settings import * > ? ?except ImportError: > ? ? ? ?pass > > Now, in order to avoid ambiguities, I thought about using relative imports, > but there I'm stomped because wildcard imports are not supported for > relative imports, it seems. > > > How would you do it? Any other suggestions? > > Cheers! > > Uli > -- > http://mail.python.org/mailman/listinfo/python-list > From d at davea.name Thu Nov 24 09:27:10 2011 From: d at davea.name (Dave Angel) Date: Thu, 24 Nov 2011 09:27:10 -0500 Subject: Does py2app improves speed? In-Reply-To: <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> Message-ID: <4ECE543E.9040807@davea.name> On 11/24/2011 09:02 AM, Ricardo Mansilla wrote: > Most of m?thods for improving the speed are related to efficient memory management and using specific structures for a specific tasks... But i have already optimized my code (which is very short actually) following all these rules and it is very slow yet. > Do you think there is another way to do This? Probably i'm missing something here... > > On 24/11/2011, at 07:38, Dave Angel wrote: > >> On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: >>> Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... >>> Bye. >> Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Python language for all or most of the app. There have been lots of threads on the topic. >> >> -- >> >> DaveA >> > (Please don't top-post. If you put your comments ahead of the part you're quoting, you confuse us) Several ways to speed up code. 1) use language features to best advantage 2) use 3rd party libraries that do certain things well 3) use best algorithms, subject to #1 and #2 4) have someone else review the code (perhaps on the list, perhaps within your own organization) 5) measure (eg. profile it) 6) use optimizing tools, such as pypy or Cython. 7) rewrite parts of it in another language 8) get a faster processor 9) rewrite it all in another language It takes experience to choose between these, and each project is different. But even the most experienced developers will frequently guess entirely wrong where the bottleneck is, which is why you measure if you care. -- DaveA From Nikunj.Badjatya at emc.com Thu Nov 24 10:35:36 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Thu, 24 Nov 2011 10:35:36 -0500 Subject: How to keep Console area fixed for a thread Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D7B8@MX34A.corp.emc.com> Hi All, Please look at the code below. I am using pypi progressbar. But in general, How can I keep the area of the console fixed for the thread to print its status on it. {{{ import sys import time import threading import os from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \ FileTransferSpeed, FormatLabel, Percentage, \ ProgressBar, ReverseBar, RotatingMarker, \ SimpleProgress, Timer def ProgBar(): widgets = [' ', Percentage(), ' ', Bar(marker='#',left='[',right=']'),' '] pbar = ProgressBar(widgets=widgets, maxval=100) pbar.start() return pbar def update2(i): os.environ["PBAR"] = i print("This will print for every call to update") return class MyThread(threading.Thread): def run(self): l = 0 while True: n = os.getenv("PBAR", "") if len(n) != 0: n = int(n) if n > l: pbar.update(n) l = n if n == 100: break else: continue pbar = ProgBar() mythread = MyThread() mythread.daemon = True mythread.start() for i in range(101): update2("{0}".format(i)) time.sleep(0.25) }}} {{{ Output: [cid:image002.jpg at 01CCAAEC.CFE44870] }}} But I require the output to be of type: {{{ 13% [########### ] This will print for every call to update This will print for every call to update This will print for every call to update This will print for every call to update This will print for every call to update }}} This is just a sample piece of code for narrowing down the problem. How can I fix the cursor position fix for the thread which is updating my progressbar .? Thanks Nikunj Bangalore-India -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 37098 bytes Desc: image002.jpg URL: From zdoor at xs4all.nl Thu Nov 24 11:28:01 2011 From: zdoor at xs4all.nl (Alex van der Spek) Date: Thu, 24 Nov 2011 17:28:01 +0100 Subject: WAVE file writing, confused about setsampwidth(n) Message-ID: <4ece7092$0$6902$e4fe514c@news2.news.xs4all.nl> I am confused about the Wave_write object setsampwidth(n). Is the sample width n the total sample width, i.e. for a stereo sample consisting of short (2 byte) integers; n=4 or is the sample width the number of bytes in either the left or the right channel? Regards, Alex van der Spek From jcea at jcea.es Thu Nov 24 11:46:48 2011 From: jcea at jcea.es (Jesus Cea) Date: Thu, 24 Nov 2011 17:46:48 +0100 Subject: DTrace probes in Python 2.7 (and next 3.3) Message-ID: <4ECE74F8.5050208@jcea.es> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all. I have spend some time trying to integrate DTrace probes in official Python: Currently I have a patch to python 2.7, and my plan in to integrate officially in 3.3. The initial probes were based on previous work from OpenSolaris, and similar, but currently I have quite a few more probes. Current details in The probes are tested under Solaris 10 x86 and x86-64. I would need somebody to try on Solaris 10 Sparc (32 and 64 bits), Solaris 11, OpenIndiana, FreeBSD (seems to need a kernel recompilation to enable user mode tracing, check Google), Mac (I doubt it works as is), etc., any other platform running DTrace. What about SystemTap compatibility? Details: How to check: . The easier way to get the patch is to clone my repository at (with mercurial) and move to the branch "dtrace-issue13405_2.7". Keep the clone around if you plan to try future versions of this patch, including the future 3.3 version. You can manually apply the patch in to python 2.7.2+ sourcecode. The patch is developed against version 3c3009f63700 (2011-11-14). It might not apply cleanly to 2.7.2 sourcecode (not checked). I will provide a direct patch to 2.7.3 when available. Maybe to 2.7.2 if there is demand. This is still work in progress. I will improve support with your feedback. I am considering probes to monitor GIL and thinking how to monitor C function calls from Python in an easy and fast way. Feedback very welcomed. Please, if you care about this, test it and provide some feedback :). PS: Better post feedback in the bug tracker that by personal email :-). - -- Jesus Cea Avion _/_/ _/_/_/ _/_/_/ jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/ . _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQCVAwUBTs50+Jlgi5GaxT1NAQKWUwQAnl99nFd6nM5yiPGl8yw4/YR81BTIS563 3wyPz74o5wAE3k9quexr+UPCndPogiH6nhnJ9DNXfUpVyaouGG/tGEbZn/x+h7Dv jc5616IRnHxGAxxuoTscCRRN88zsPVY6i71QMxK2BOS+zXMdcrsBajLrmx1UIzHY Elr7fq8L988= =uQM5 -----END PGP SIGNATURE----- From miki.tebeka at gmail.com Thu Nov 24 12:24:24 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Thu, 24 Nov 2011 09:24:24 -0800 (PST) Subject: Tree data structure with: single, double and triple children option along with AVM data at each node In-Reply-To: <7548c4b6-f3f1-4f96-9a77-fcb9e0edeed0@s4g2000yqk.googlegroups.com> References: <7548c4b6-f3f1-4f96-9a77-fcb9e0edeed0@s4g2000yqk.googlegroups.com> Message-ID: <29675595.296.1322155464662.JavaMail.geo-discussion-forums@vbjs5> There a many ways to do this, here's one: from collections import namedtuple Tree = namedtuple('Tree', ['feature', 'children']) t = Tree(1, [Tree('hello', []), Tree(3, [])]) From cv33cv33cv33 at gmail.com Thu Nov 24 13:27:09 2011 From: cv33cv33cv33 at gmail.com (BV) Date: Thu, 24 Nov 2011 10:27:09 -0800 (PST) Subject: YOU MUST KNOW THIS MAN !!!!!!!!!!!!!!! Message-ID: <4d6f12c2-f596-4c50-af96-c9ee51e66aaa@j10g2000vbe.googlegroups.com> In The Name Of Allah, Most Gracious, Most Merciful YOU MUST KNOW THIS MAN MUHAMMAD You may be an atheist or an agnostic; or you may belong to anyone of the religious denominations that exist in the world today. You may be a Communist or a believer in democracy and freedom. No matter what you are, and no matter what your religious and political beliefs, personal and social habits happen to be - YOU MUST STILL KNOW THIS MAN! He was by far the most remarkable man that ever set foot on this earth. He preached a religion, founded a state, built a nation, laid down a moral code, initiated numberless social and political reforms, established a dynamic and powerful society to practice and represent his teachings, and completely revolutionized the worlds of human thought and action for all times to come. HIS NAME IS MUHAMMAD, peace and blessings of Almighty God be upon him and he accomplished all these wonders in the unbelievably short span of twenty-three years. Muhammad, peace and blessings of God Almighty be upon him was born in Arabia on the 20th of August, in the year 570 of the Christian era, and when he died after 63 years, the whole of the Arabian Peninsula had changed from paganism and idol-worship to the worship of One God; from tribal quarrels and wars to national solidarity and cohesion; from drunkenness and debauchery to sobriety and piety; from lawlessness and anarchy to disciplined living; from utter moral bankruptcy to the highest standards of moral excellence. Human history has never known such a complete transformation of a people or a place before or since! The Encyclopedia Britannica calls him "the most successful of all religious personalities of the world". Bernard Shaw said about him that if Muhammad were alive today he would succeed in solving all those problems which threaten to destroy human civilization in our times. Thomas Carlysle was simply amazed as to how one man, single- handedly, could weld warring tribes and wandering Bedouins into a most powerful and civilized nation in less than two decades. Napoleon and Gandhi never tired of dreaming of a society along the lines established by this man in Arabia fourteen centuries ago. Indeed no other human being ever accomplished so much, in such diverse fields of human thought and behavior, in so limited a space of time, as did Muhammad, peace and blessings of God Almighty be upon him. He was a religious teacher, a social reformer, a moral guide, a political thinker, a military genius, an administrative colossus, a faithful friend, a wonderful companion, a devoted husband, a loving father - all in one. No other man in history ever excelled or equaled him in any of these difficult departments of life. The world has had its share of great personalities. But these were one sided figures who distinguished themselves in but one or two fields such as religious thought or military leadership. None of the other great leaders of the world ever combined in himself so many different qualities to such an amazing level of perfection as did Muhammad, peace and blessings of God Almighty be upon him. The lives and teachings of other great personalities of the world are shrouded in the mist of time. There is so much speculation about the time and the place of their birth, the mode and style of their life, the nature and detail of their teachings and the degree and measure of their success or failure that it is impossible for humanity today to reconstruct accurately and precisely the lives and teachings of those men. Not so this man Muhammad, peace and blessings of God Almighty be upon him. Not only was he born in the fullest blaze of recorded history, but every detail of his private and public life, of his actions and utterances, has been accurately documented and faithfully preserved to our day. The authenticity of the information so preserved is vouched for not only by faithful followers but also by unbiased critics and open-minded scholars. At the level of ideas there is no system of thought and belief-secular or religious, social or political-which could surpass or equal ISLAM- the system which Muhammad peace and blessings of God Almighty be upon him propounded. In a fast changing world, while other systems have undergone profound transformations, Islam alone has remained above all change and mutation, and retained its original form for the past 1400 years. What is more, the positive changes that are taking place in the world of human thought and behavior, truly and consistently reflect the healthy influence of Islam in these areas. Further, it is not given to the best of thinkers to put their ideas completely into practice, and to see the seeds of their labors grow and bear fruit, in their own lifetime. Except of course, Muhammad, peace and blessings of God Almighty be upon him, who not only preached the most wonderful ideas but also successfully translated each one of them into practice in his own lifetime. At the time of his death his teachings were not mere precepts and ideas straining for fulfillment, but had become the very core of the life of tens of thousands of perfectly trained individuals, each one of whom was a marvelous personification of everything that Muhammad peace and blessings of God Almighty be upon him taught and stood for. At what other time or place and in relation to what other political, social, religious system, philosophy or ideology-did the world ever witness such a perfectly amazing phenomenon? Indeed no other system or ideology secular or religious, social or political, ancient or modern - could ever claim the distinction of having been put into practice in its fullness and entirety EVEN ONCE in this world, either before or after the death of its founder. Except of course ISLAM, the ideology preached by Muhammad, peace and blessings of God Almighty be upon him which was established as a complete way of life by the teacher himself, before he departed from this world. History bears testimony to this fact and the greatest skeptics have no option but to concede this point. In spite of these amazing achievements and in spite of the countless absolutely convincing and authentic miracles performed by him and the phenomenal success which crowned his efforts, he did not for a moment claim to be God or God's incarnation or Son - but only a human being who was chosen and ordained by God to be a teacher of truth to man kind and a complete model and pattern for their actions. He was nothing more or less than a human being. But he was a man with a noble and exalted mission-and his unique mission was to unite humanity on the worship of ONE AND ONLY GOD and to teach them the way to honest and upright living in accordance with the laws and commands of God. He always described himself as A MESSENGER AND SERVANT OF GOD, and so indeed every single action and movement of his proclaimed him to be. A world which has not hesitated to raise to Divinity individuals whose very lives and missions have been lost in legend and who historically speaking did not accomplish half as much-or even one tenth-as was accomplished by Muhammad, peace and blessings of God Almighty be upon him should stop to take serious note of this remarkable man's claim to be God's messenger to mankind. Today after the lapse of some 1400 years the life and teachings of Prophet Muhammad, peace and blessings of God Almighty be upon him, have survived without the slightest loss, alteration or interpolation. Today they offer the same undying hope for treating mankind's many ills which they did when Prophet Muhammad, peace and blessings of God Almighty be upon him, was alive. This is our honest claim and this is the inescapable conclusion forced upon us by a critical and unbiased study of history. The least YOU should do as a thinking, sensitive, concerned human being is to stop for one brief moment and ask yourself: Could it be that these statements, extraordinary and revolutionary as they sound, are really true? Supposing they really are true, and you did not know this man Muhammad, peace and blessings of God Almighty be upon him or hear about his teachings? Or did not know him well and intimately enough to be able to benefit from his guidance and example? Isn't it time you responded to this tremendous challenge and made some effort to know him? It will not cost you anything but it may well prove to be the beginning of a completely new era in your life. Come, let us make a new discovery of the life of this wonderful man Muhammad, peace and blessings of God Almighty be upon him the like of whom never walked on this earth, and whose example and teachings can change YOUR LIFE and OUR WORLD for the better. May God shower His choicest blessings upon him! IF YOU WISH TO KNOW MORE ABOUT ISLAM, WE PREFER TO VISIT THE FOLLOWING WEBSITES: http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://imanway1.com/eng http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://www.chatislamonline.org/ar http://www.dar-us-salam.com http://youtubeislam.com From aszeszo at gmail.com Thu Nov 24 13:49:40 2011 From: aszeszo at gmail.com (Andrzej Szeszo) Date: Thu, 24 Nov 2011 18:49:40 +0000 Subject: [oi-dev] DTrace probes in Python 2.7 (and next 3.3) In-Reply-To: <4ECE74F8.5050208@jcea.es> References: <4ECE74F8.5050208@jcea.es> Message-ID: <4ECE91C4.2040208@gmail.com> Hi Jesus Just noticed that there is a python 2.7 package in Oracle's userland repo here: It includes DTrace patch. Did you see/use that? Andrzej On 24/11/2011 16:46, Jesus Cea wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi all. > > I have spend some time trying to integrate DTrace probes in official > Python: Currently I have a patch to python 2.7, and my plan in to > integrate officially in 3.3. > > The initial probes were based on previous work from OpenSolaris, and > similar, but currently I have quite a few more probes. Current details > in > > > The probes are tested under Solaris 10 x86 and x86-64. I would need > somebody to try on Solaris 10 Sparc (32 and 64 bits), Solaris 11, > OpenIndiana, FreeBSD (seems to need a kernel recompilation to enable > user mode tracing, check Google), Mac (I doubt it works as is), etc., > any other platform running DTrace. What about SystemTap compatibility? > > Details: > > How to check:. > > The easier way to get the patch is to clone my repository at > (with mercurial) and move to the > branch "dtrace-issue13405_2.7". Keep the clone around if you plan to > try future versions of this patch, including the future 3.3 version. > > You can manually apply the patch in > to python 2.7.2+ > sourcecode. The patch is developed against version 3c3009f63700 > (2011-11-14). It might not apply cleanly to 2.7.2 sourcecode (not > checked). I will provide a direct patch to 2.7.3 when available. Maybe > to 2.7.2 if there is demand. > > This is still work in progress. I will improve support with your > feedback. I am considering probes to monitor GIL and thinking how to > monitor C function calls from Python in an easy and fast way. Feedback > very welcomed. > > Please, if you care about this, test it and provide some feedback :). > > PS: Better post feedback in the bug tracker that by personal email :-). > > - -- > Jesus Cea Avion _/_/ _/_/_/ _/_/_/ > jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ > jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/ > . _/_/ _/_/ _/_/ _/_/ _/_/ > "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ > "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ > "El amor es poner tu felicidad en la felicidad de otro" - Leibniz > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iQCVAwUBTs50+Jlgi5GaxT1NAQKWUwQAnl99nFd6nM5yiPGl8yw4/YR81BTIS563 > 3wyPz74o5wAE3k9quexr+UPCndPogiH6nhnJ9DNXfUpVyaouGG/tGEbZn/x+h7Dv > jc5616IRnHxGAxxuoTscCRRN88zsPVY6i71QMxK2BOS+zXMdcrsBajLrmx1UIzHY > Elr7fq8L988= > =uQM5 > -----END PGP SIGNATURE----- > > _______________________________________________ > oi-dev mailing list > oi-dev at openindiana.org > http://openindiana.org/mailman/listinfo/oi-dev From wolftracks at invalid.com Thu Nov 24 16:18:59 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 24 Nov 2011 13:18:59 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/23/2011 2:29 PM, Alan Meyer wrote: > On 11/23/2011 12:38 PM, W. eWatson wrote: >> So unless Alan Meyer has further interest in this, it looks like it's at >> an end. >> >> It may be time to move on to c++. >> > > C++ is a ton of fun. You haven't lived until you've made a syntax error > in a template instantiation and seen a hundred cascading error messages > from included files that you didn't know you included. > > Unlike Python, it really builds character. > > I say, go for it! > > Alan So posting the results of the adventure you put me on has no further way to proceed? From wolftracks at invalid.com Thu Nov 24 16:22:51 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 24 Nov 2011 13:22:51 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: Whoops, I thought I was replying to Matt Meyers just above you. However, I think he chimed in above about ActiveState back on the 22nd. In any case, I think this thread has ceased to be productive. From wolftracks at invalid.com Thu Nov 24 16:24:06 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 24 Nov 2011 13:24:06 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/23/2011 10:29 AM, Arnaud Delobelle wrote: > On 23 November 2011 17:38, W. eWatson wrote: > [...] >> It may be time to move on to c++. > > Good Luck. Bye! > "Wellll, pardoooon meee." -- Steve Martin From dbinks at codeaurora.org Thu Nov 24 16:41:50 2011 From: dbinks at codeaurora.org (Dominic Binks) Date: Thu, 24 Nov 2011 13:41:50 -0800 Subject: Does py2app improves speed? In-Reply-To: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> Message-ID: <4ECEBA1E.4020405@codeaurora.org> On 11/23/2011 10:36 PM, Ricardo Mansilla wrote: > Hi everyone.. > My question is exactly as in the subject of This Mail. > I have made a Python script which is to slow and i have heard (and common sense also suggest) that if you use some libraries to "frozen" the script the performance improves substantially. So I need to know; is This a myth or it is a fact? > Thanks in advance for your time. Depending on the code you have pypy may be faster - I've seen it both significantly faster and about the same as CPython. -- Dominic Binks: dbinks at codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum From ben+python at benfinney.id.au Thu Nov 24 17:28:28 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 25 Nov 2011 09:28:28 +1100 Subject: reading optional configuration from a file References: Message-ID: <8739dd6tpv.fsf@benfinney.id.au> Ulrich Eckhardt writes: > I have a few tests that require a network connection. Typically, the > target will be localhost on port 20000. However, sometimes these > settings differ, so I want to be able to optionally set them. I subscribe to the view that an application's user-configurable settings should be data, not executable code. For this purpose, you will want to investigate the Python standard library modules ?json? and ?configparser? . -- \ ?I saw a sign: ?Rest Area 25 Miles?. That's pretty big. Some | `\ people must be really tired.? ?Steven Wright | _o__) | Ben Finney From alex.kapps at web.de Thu Nov 24 18:18:44 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Fri, 25 Nov 2011 00:18:44 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <4ECED0D4.6080501@web.de> On 24.11.2011 22:22, W. eWatson wrote: > Whoops, I thought I was replying to Matt Meyers just above you. Above who? As said by somebody already, most people use a mail-client (Thunderbird/Outlook) or a Usenet client to read this forum. Google Groups is (In My Opinion at least) just crap (and should be blocked/forbidden. It's *the* one spam sender already) Please always post enough context, Now, we are talking about Python 3.2.* on Win7, correct? I only have Win7 32bit in a VBox VM, but still. Please paste the following into a "python.reg", file, then right-click on that file and choose the fist option (the one wihch is in bold font, something like install/insert/insert or however it's called in your language. In my German versin it's called "Zusammenf?hren") Do you get an "Edit with IDLE" then? Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Python.File] @="Python File" [HKEY_CLASSES_ROOT\Python.File\DefaultIcon] @="C:\\Python32\\DLLs\\py.ico" [HKEY_CLASSES_ROOT\Python.File\shell] [HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE] [HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command] @="\"C:\\Python32\\pythonw.exe\" \"C:\\Python32\\Lib\\idlelib\\idle.pyw\" -e \"%1\"" [HKEY_CLASSES_ROOT\Python.File\shell\open] [HKEY_CLASSES_ROOT\Python.File\shell\open\command] @="\"C:\\Python32\\python.exe\" \"%1\" %*" From alex.kapps at web.de Thu Nov 24 18:37:03 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Fri, 25 Nov 2011 00:37:03 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ECED0D4.6080501@web.de> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ECED0D4.6080501@web.de> Message-ID: <4ECED51F.2000106@web.de> On 25.11.2011 00:18, Alexander Kapps wrote: > Do you get an "Edit with IDLE" then? And even if not. Why are you so obsessive about IDLE? I mean, seriously, IDLE is just a bare-level if-nothing-else-is-available editor/IDE. It's better than notepad, OK. I really don't buy it, that your are willing to move to C++ (or even just change the language) just because the default editor is not available in the context menu. From jcea at jcea.es Thu Nov 24 19:01:22 2011 From: jcea at jcea.es (Jesus Cea) Date: Fri, 25 Nov 2011 01:01:22 +0100 Subject: [oi-dev] DTrace probes in Python 2.7 (and next 3.3) In-Reply-To: <4ECE91C4.2040208@gmail.com> References: <4ECE74F8.5050208@jcea.es> <4ECE91C4.2040208@gmail.com> Message-ID: <4ECEDAD2.5060301@jcea.es> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 24/11/11 19:49, Andrzej Szeszo wrote: > Hi Jesus > > Just noticed that there is a python 2.7 package in Oracle's > userland repo here: > > > > > > It includes DTrace patch. Did you see/use that? That was my starting point. Talking about that... How is the license going?. Mailing the guy... - -- Jesus Cea Avion _/_/ _/_/_/ _/_/_/ jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/ . _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQCVAwUBTs7a0plgi5GaxT1NAQLNUAP/WUopUbet5NN5K1kgJ6/5KNJFX/HMXqIl JXWXHro72f3SFuWws1QL82nos/nhVn5JQkkc3sRDwi3EV0dFM2Zi9BS8paHfOrQi 2qNNbvnTMzGKjZ9ZQrhiC+aSfr5qG6ou53mtQch53W7v15t7flqrDWr/VqlKxRWO xn0P8WzSC8g= =G9Ie -----END PGP SIGNATURE----- From steve+comp.lang.python at pearwood.info Thu Nov 24 19:04:04 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Nov 2011 00:04:04 GMT Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 17:25:23 -0600, Tony the Tiger wrote: > On Wed, 23 Nov 2011 17:43:20 -0800, Dennis Lee Bieber wrote: > >> Windows PowerShell includes more than one hundred basic core cmdlets, >> and you can write your own cmdlets and share them with other users. > > Oh, goodie! They've found yet another way to infect a Windows system. :) My Linux system includes compilers or interpreters for C, Pascal, Haskell, Forth, Python, Ruby, PHP, Javascript, Java, bash, csh, zsh, sh, awk, sed, Perl, SQL, Tcl, Tk, OpenXion, and very likely others. Most of these were supplied by the vendor. I could write my own executable code, "cmdlets" if you will, in any of these languages, and share them with others. So by your reasoning, that's at least 20 ways to infect my Linux system. I never realised just how insecure Linux must be! If "sharing code" is considered to be synonymous with "infection", what does that say about the Free and Open Source Software movement? Linux-users-aren't-the-only-people-allowed-to-write-shell-scripts-ly y'rs, -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 24 19:16:06 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Nov 2011 00:16:06 GMT Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> On Fri, 25 Nov 2011 00:18:44 +0100, Alexander Kapps wrote: > Now, we are talking about Python 3.2.* on Win7, correct? I only have > Win7 32bit in a VBox VM, but still. I believe that W. eWatson's problems occurred when he installed a 32-bit version of Python 3.2 on a 64-bit version of Windows 7. Either the 32-bit installer doesn't set the default file associations correctly on 64-bit systems, or W. eWatson has mangled his registry by making arbitrary changes to file associations, and now even the correct 64-bit installer can't set the associations correctly. As far as I can tell, nobody running the 64-bit version of Windows 7 has chimed in to either confirm or refute W. eWatson's claim that IDLE doesn't show up, so we have no way of telling whether it doesn't show up due to a lack in the installer, or because eWatson has (slightly) broken his system and has inadvertently prevented it from showing up. Fixing the associations is a Windows issue, not a Python issue. Even if it turns out that the installer does neglect to set up menu commands for IDLE (which should be reported as a feature request on the bug tracker), this is not a problem best solved here, although we can do our best. It would be best solved on a Window forum, where experts on Windows can give advice. -- Steven From alex.kapps at web.de Thu Nov 24 19:32:08 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Fri, 25 Nov 2011 01:32:08 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ECEE208.9010602@web.de> On 25.11.2011 01:04, Steven D'Aprano wrote: > So by your reasoning, that's at least 20 ways to infect my Linux system. > I never realised just how insecure Linux must be! Yes, there are 20+ ways to "infect" your (and mine) Linux system. You cannot trust *any* kind of 3rd party code. Period. Have you ever added a 3rd party repo (PPA or such). Have you ever added some Firefox addon or installed some 3rd-party addition (of any kind) to some program) Where is the protection now? The main difference here is, that Linux makes it easy to seperate administrative accounts from end-user accounts, The custom addon/cmdlet/whatever I give you has the same dangers on Linux as on windows. If you blindly install it, you're owned! > If "sharing code" is considered to be synonymous with "infection", what > does that say about the Free and Open Source Software movement? Completely besides the topic. It's not about "sharing code", but about the seperation between normal and administrative user on the OS level (which Windows still doesn't have by default). > Linux-users-aren't-the-only-people-allowed-to-write-shell-scripts-ly y'rs, But-Linux-Users-aren't-root-by-default-ly y'rs. :) From tjreedy at udel.edu Thu Nov 24 19:51:10 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Nov 2011 19:51:10 -0500 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: On 11/24/2011 7:31 AM, Rudra Banerjee wrote: > Dear friends, > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? The first killer app for Python was running Fortran code from within Python. People use Python for both pre- and post-processing. For small jobs, this enabled running Fortran interactively. This lead to Numerical Python, now Numpy, SciPy, and later Sage and other scientific and Python packages. I believe SciPy has an f2py (fortran to py) module to help with running Fortran under Python (but it has been years since I read the details). Detailed questions might get better answers on, for instance, a scipy list. -- Terry Jan Reedy From tjreedy at udel.edu Thu Nov 24 20:06:24 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Nov 2011 20:06:24 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/24/2011 7:16 PM, Steven D'Aprano wrote: > As far as I can tell, nobody running the 64-bit version of Windows 7 has > chimed in to either confirm or refute W. eWatson's claim that IDLE > doesn't show up, On the contrary, back when he first posted, I stated that 64-bit Python 3.2.2 on my 64-bit Windows 7 works fine, just as he wants it to. > so we have no way of telling whether it doesn't show up > due to a lack in the installer, or because eWatson has (slightly) broken > his system and has inadvertently prevented it from showing up. I also noted that I had slightly screwed up my previous machine, and the installers never fixed up the deviation. So I gave him a better alternative that I use. He has ignored that and most everything else I posted. When he later revealed that IDLE does not run by any means, that he should fix *that* before worrying about right-clicks. > Fixing the associations is a Windows issue, not a Python issue. Even if > it turns out that the installer does neglect to set up menu commands for > IDLE (which should be reported as a feature request on the bug tracker), The installer for each version has been setting up commands for IDLE for perhaps a decade or more. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Thu Nov 24 21:19:56 2011 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 24 Nov 2011 18:19:56 -0800 (PST) Subject: Return of an old friend Message-ID: Hello Fellow Pythonistas, I am very glad to be back after an unfortunate incident caused my Google account to be deleted. Unfortunately for those of you that have been following along and supporting my crusade to bring fairness and humility to the python community, my old posts under "rantingrick" have all been deleted from Google Groups. However, you can always search the python-list archives if you need a jog down memory lane. Actually this accidental deletion may have been a good thing as i've had some extra time to muse on the innards of Python4000. In any event, this announcement is intended to be a new call to arms for my brothers and sisters who fight the good fight, and for those of you who despise me , well, this might be a good time to add my new moniker to your kill files. Thanks, and happy Thanksgiving everyone! From aljosa.mohorovic at gmail.com Thu Nov 24 22:00:52 2011 From: aljosa.mohorovic at gmail.com (Aljosa Mohorovic) Date: Thu, 24 Nov 2011 19:00:52 -0800 (PST) Subject: memory leaks - tools and docs Message-ID: i've been trying to find memory leaks in a wsgi application using gunicorn to run it and after a lot of time invested in research and testing tools i did find a lot of useful information (most really old) but i'm left with a feeling that this should be easier, better documented and with tools that generate better data. if anybody can share some tips, links, docs or better tools with better reports i would really appreciate it. i'm not against paying for a good tool so any recommendation is appreciated. i mostly used http://guppy-pe.sourceforge.net/#Heapy but found http://pysizer.8325.org/ and http://code.google.com/p/pympler/ also interesting. Aljosa From mcfletch at vrplumber.com Thu Nov 24 22:17:11 2011 From: mcfletch at vrplumber.com (Mike C. Fletcher) Date: Thu, 24 Nov 2011 22:17:11 -0500 Subject: memory leaks - tools and docs In-Reply-To: References: Message-ID: <4ECF08B7.9070201@vrplumber.com> On 11-11-24 10:00 PM, Aljosa Mohorovic wrote: > i've been trying to find memory leaks in a wsgi application using > gunicorn to run it and after a lot of time invested in research and > testing tools i did find a lot of useful information (most really old) > but i'm left with a feeling that this should be easier, better > documented and with tools that generate better data. > > if anybody can share some tips, links, docs or better tools with > better reports i would really appreciate it. > i'm not against paying for a good tool so any recommendation is > appreciated. > > i mostly used http://guppy-pe.sourceforge.net/#Heapy but found > http://pysizer.8325.org/ and http://code.google.com/p/pympler/ also > interesting. > > Aljosa Meliae is a similar tool wrt collecting memory-usage information. RunSnakeRun can process Meliae dumps to produce visualizations of the memory used in the process. HTH, Mike https://launchpad.net/meliae http://www.vrplumber.com/programming/runsnakerun/ -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dihedral88888 at googlemail.com Thu Nov 24 22:27:12 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 24 Nov 2011 19:27:12 -0800 (PST) Subject: suitability of python In-Reply-To: References: <1322137895.4211.3.camel@roddur> Message-ID: <1342091.65.1322191632498.JavaMail.geo-discussion-forums@prmu26> On Friday, November 25, 2011 8:51:10 AM UTC+8, Terry Reedy wrote: > On 11/24/2011 7:31 AM, Rudra Banerjee wrote: > > Dear friends, > > I am a newbie in python and basically i use python for postprocessing > > like plotting, data manipulation etc. > > Based on ease of programming on python I am wondering if I can consider > > it for the main development as well. My jobs (written on fortran) runs > > for weeks and quite CPU intensive. How python works on these type of > > heavy computation? > > The first killer app for Python was running Fortran code from within > Python. People use Python for both pre- and post-processing. For small > jobs, this enabled running Fortran interactively. > > This lead to Numerical Python, now Numpy, SciPy, and later Sage and > other scientific and Python packages. I believe SciPy has an f2py > (fortran to py) module to help with running Fortran under Python (but it > has been years since I read the details). > > Detailed questions might get better answers on, for instance, a scipy list. > > -- > Terry Jan Reedy If pyhthon just handles the user interface and glue logics of well written python modules that are most written c, the speed of running python pyc is OK. Of course the object reference updating required in OOP is completely supported by python. From dihedral88888 at googlemail.com Thu Nov 24 22:27:12 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 24 Nov 2011 19:27:12 -0800 (PST) Subject: suitability of python In-Reply-To: References: <1322137895.4211.3.camel@roddur> Message-ID: <1342091.65.1322191632498.JavaMail.geo-discussion-forums@prmu26> On Friday, November 25, 2011 8:51:10 AM UTC+8, Terry Reedy wrote: > On 11/24/2011 7:31 AM, Rudra Banerjee wrote: > > Dear friends, > > I am a newbie in python and basically i use python for postprocessing > > like plotting, data manipulation etc. > > Based on ease of programming on python I am wondering if I can consider > > it for the main development as well. My jobs (written on fortran) runs > > for weeks and quite CPU intensive. How python works on these type of > > heavy computation? > > The first killer app for Python was running Fortran code from within > Python. People use Python for both pre- and post-processing. For small > jobs, this enabled running Fortran interactively. > > This lead to Numerical Python, now Numpy, SciPy, and later Sage and > other scientific and Python packages. I believe SciPy has an f2py > (fortran to py) module to help with running Fortran under Python (but it > has been years since I read the details). > > Detailed questions might get better answers on, for instance, a scipy list. > > -- > Terry Jan Reedy If pyhthon just handles the user interface and glue logics of well written python modules that are most written c, the speed of running python pyc is OK. Of course the object reference updating required in OOP is completely supported by python. From wuwei23 at gmail.com Thu Nov 24 22:37:30 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 24 Nov 2011 19:37:30 -0800 (PST) Subject: suitability of python References: <1322137895.4211.3.camel@roddur> Message-ID: Terry Reedy wrote: > This lead to Numerical Python, now Numpy, SciPy, and later Sage and > other scientific and Python packages. I believe SciPy has an f2py > (fortran to py) module to help with running Fortran under Python (but it > has been years since I read the details). Andrew Dalke recently did some work on f2pypy, as a step toward running Fortran under PyPy: http://www.dalkescientific.com/writings/diary/archive/2011/11/09/f2pypy.html If PyPy's Numpy support was more advanced, I'd probably recommend the OP start there. From wuwei23 at gmail.com Thu Nov 24 22:47:29 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 24 Nov 2011 19:47:29 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> Message-ID: <944e0207-7083-4ae8-a59e-3e05b595708e@d37g2000prg.googlegroups.com> Tim Golden wrote: > The interpreter inherits the command shell's history function: > Open a cmd window and then a Python session. Do some stuff. > > Ctrl-Z to exit to the surrounding cmd window. > Do some random cmd stuff: dir, cd, etc. > > Start a second Python session. up-arrow etc. will bring back > the previous Python session's commands (and not the ones you > entered in the surrounding shell) This isn't true, at least not for ActivePython 2.7.2.5 under Windows 7-64. The second session has no history whatsoever. From wuwei23 at gmail.com Thu Nov 24 22:49:46 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 24 Nov 2011 19:49:46 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 24, 6:51?pm, Tim Golden wrote: > The > Ctrl-Z thing is what *exits* the interpreter on Windows (a la Ctrl-D > on Linux). With ActivePython, Ctrl-D works as well, which is a godsend as I'm constantly working across Windows & linux. > In short - on Windows, within one cmd shell you can open and exit > the interpreter as many times as you like and the Python command > history will be retained via the cmd shell's history mechanism, > and kept distinct from the history of other things you may type > into the cmd shell. And again, I'm definitely not seeing this. Inside the one cmd shell, each instance of Python has no recollection of the history of the last. From lists at cheimes.de Thu Nov 24 23:05:11 2011 From: lists at cheimes.de (Christian Heimes) Date: Fri, 25 Nov 2011 05:05:11 +0100 Subject: memory leaks - tools and docs In-Reply-To: References: Message-ID: Am 25.11.2011 04:00, schrieb Aljosa Mohorovic: > i mostly used http://guppy-pe.sourceforge.net/#Heapy but found > http://pysizer.8325.org/ and http://code.google.com/p/pympler/ also > interesting. Guppy is a extremely powerful tool because it can also track non GC objects without a debug build of Python. I only wished it would have a user friendly and easy to script interface. The _.more thing is killing me. :( I'm using a very simple and almost for free approach to keep track of memory usage with psutil. After every unit test case I store RSS and VM size with psutil.Process(os.getpid()).get_memory_info(), threading.active_count(), len(gc.garbage) and len(gc.get_objects()). It doesn't show what's going wrong, but it helps me to isolate the code paths, that may introduce memory leaks and reference cycles. Since we use continuous integration (Jenkins) I can track down regressions more easily, too. Christian From ameyer2 at yahoo.com Thu Nov 24 23:06:26 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Thu, 24 Nov 2011 23:06:26 -0500 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: On 11/24/2011 07:31 AM, Rudra Banerjee wrote: > Dear friends, > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? > Any comment or reference is welcome. > I would expect that a language that compiles intensive math programming to machine language will be much more than an order of magnitude faster than a program that does the same thing by interpreting byte code. If you study all of the Python math libraries I'm guessing you'll find modules that do a lot, conceivably all, of what you want in compiled machine language, but when held together with Python it may or may not be as efficient as fortran. I'm guessing there's not much out there that is as efficient as fortran for purely numerical work. I think your division of labor using fortran for the CPU intensive math parts and python for post-processing is a pretty good one. It takes advantage of the strength of each language. In addition, it completely separates the two parts so that they aren't really dependent on each other. You can change the fortran any way you want without breaking the python code as long as you output the same format, and of course you can change the python any way you want. Programs in each language don't even have to know that any other language is involved. My only suggestion is to see if you can get a profiler to see what's happening inside that weeks long running fortran program. You might find some surprises. I once wrote a 5,000 line program that was slower than I had hoped. I ran it through a profiler and it showed me that I was spending more than 50 percent of my time on one single line of my code that called a simple library routine ("strcpy"). I wrote the simple library routine inline instead adding just a few lines of code. It cut the total execution time of the whole program in half. Alan From steve+comp.lang.python at pearwood.info Thu Nov 24 23:37:21 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Nov 2011 04:37:21 GMT Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecf1b80$0$29988$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 20:06:24 -0500, Terry Reedy wrote: > On 11/24/2011 7:16 PM, Steven D'Aprano wrote: > >> As far as I can tell, nobody running the 64-bit version of Windows 7 >> has chimed in to either confirm or refute W. eWatson's claim that IDLE >> doesn't show up, > > On the contrary, back when he first posted, I stated that 64-bit Python > 3.2.2 on my 64-bit Windows 7 works fine, just as he wants it to. Ah, sorry about that Terry! This thread, or multiple threads, is long and confusing and I obviously haven't been able to keep track of who said what. -- Steven From anacrolix at gmail.com Fri Nov 25 00:08:17 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Fri, 25 Nov 2011 16:08:17 +1100 Subject: Return of an old friend In-Reply-To: References: Message-ID: I haven't heard of you before, but feel like I've missed out on something. Do you (or someone else) care to link to some of your more contentious work? On Fri, Nov 25, 2011 at 1:19 PM, Rick Johnson wrote: > Hello Fellow Pythonistas, > > I am very glad to be back after an unfortunate incident caused my > Google account to be deleted. Unfortunately for those of you that have > been following along and supporting my crusade to bring fairness and > humility to the python community, my old posts under "rantingrick" > have all been deleted from Google Groups. However, you can always > search the python-list archives if you need a jog down memory lane. > > Actually this accidental deletion may have been a good thing as i've > had some extra time to muse on the innards of Python4000. > > In any event, this announcement is intended to be a new call to arms > for my brothers and sisters who fight the good fight, and for those of > you who despise me , well, this might be a good time to add my new > moniker to your kill files. > > Thanks, and happy Thanksgiving everyone! > -- > http://mail.python.org/mailman/listinfo/python-list > From 6brisk at gmail.com Fri Nov 25 00:23:13 2011 From: 6brisk at gmail.com (brisk brisk) Date: Thu, 24 Nov 2011 21:23:13 -0800 (PST) Subject: online form filling jobs Message-ID: online form filling jobs http://onlinejobsprocess.weebly.com/ From zpengxen at gmail.com Fri Nov 25 01:52:25 2011 From: zpengxen at gmail.com (ZhouPeng) Date: Fri, 25 Nov 2011 14:52:25 +0800 Subject: Strange result ffor object to bool Message-ID: Hi all, In my program, I get a listen element by listen = graphics.find("listen") print listen is print type listen is I am sure listen is not None and can be accessed properly. But print bool(listen) is False if not listen is True -- Zhou Peng From rosuav at gmail.com Fri Nov 25 03:04:11 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Nov 2011 19:04:11 +1100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Nov 25, 2011 at 3:49 PM, Dennis Lee Bieber wrote: > On 25 Nov 2011 00:04:04 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > >> My Linux system includes compilers or interpreters for C, Pascal, >> Haskell, Forth, Python, Ruby, PHP, Javascript, Java, bash, csh, zsh, sh, >> awk, sed, Perl, SQL, Tcl, Tk, OpenXion, and very likely others. Most of > > ? ? ? ?What? No REXX? > > ? ? ? ?{Granted, other than IBM's mainframes, the only decent REXX > implementation [heck, maybe even better] was the Amiga version -- it was > integrated well into the Amiga message passing IPC system, such that > pretty much any application with an ARexx port could connect to and > control any other application with an ARexx port} IBM's non-mainframes too - their OS/2 implementation was - and still is - awesome. I use REXX for a variety of odds and ends, everything from simple scripts up to full-on GUI applications. Yes, we still use OS/2 (as well as Windows and Linux - mixed LANs are fun). ChrisA From chris at simplistix.co.uk Fri Nov 25 03:14:36 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Fri, 25 Nov 2011 08:14:36 +0000 Subject: MailingLogger 3.6.0 Released! Message-ID: <4ECF4E6C.3050308@simplistix.co.uk> I'm pleased to announce a new release of Mailinglogger. Mailinglogger provides two handlers for the standard python logging framework that enable log entries to be emailed either as the entries are logged or as a summary at the end of the running process. The handlers have the following features: - customisable and dynamic subject lines for emails sent - emails sent with a configurable headers for easy filtering - flood protection to ensure the number of emails sent is not excessive - support for SMTP servers that require authentication - fully documented and tested The only change for this release is to allow summaries sent by SummarisingLogger to contain messages logged at a lower level than those which triggered the summary to be emailed. Full docs can be found here: http://packages.python.org/mailinglogger/ For more information, please see: http://www.simplistix.co.uk/software/python/mailinglogger or http://pypi.python.org/pypi/mailinglogger cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk From rosuav at gmail.com Fri Nov 25 03:46:17 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Nov 2011 19:46:17 +1100 Subject: Strange result ffor object to bool In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 5:52 PM, ZhouPeng wrote: > I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False > if not listen ?is True Casting something to boolean follows strict rules derived from the notion that emptiness is false and nonemptiness is true. For instance: >>> bool(""),bool([]),bool({}),bool(0) (False, False, False, False) Details here: http://docs.python.org/library/stdtypes.html Chris Angelico From mail at timgolden.me.uk Fri Nov 25 03:58:30 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 25 Nov 2011 08:58:30 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <944e0207-7083-4ae8-a59e-3e05b595708e@d37g2000prg.googlegroups.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <944e0207-7083-4ae8-a59e-3e05b595708e@d37g2000prg.googlegroups.com> Message-ID: <4ECF58B6.1060906@timgolden.me.uk> On 25/11/2011 03:47, alex23 wrote: > Tim Golden wrote: >> The interpreter inherits the command shell's history function: >> Open a cmd window and then a Python session. Do some stuff. >> >> Ctrl-Z to exit to the surrounding cmd window. >> Do some random cmd stuff: dir, cd, etc. >> >> Start a second Python session. up-arrow etc. will bring back >> the previous Python session's commands (and not the ones you >> entered in the surrounding shell) > > This isn't true, at least not for ActivePython 2.7.2.5 under Windows > 7-64. The second session has no history whatsoever. Well I don't know what to say. It works for me with an almost identical setup. (ActivePython 2.7.1.4 Win7 x64). And has worked for me over countless setups on different machines / versions of Windows / versions of Python etc. Do you have the pyreadline module installed? ISTR that that takes over from the standard cmd processing... TJG From steve+comp.lang.python at pearwood.info Fri Nov 25 03:59:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Nov 2011 08:59:41 GMT Subject: Strange result ffor object to bool References: Message-ID: <4ecf58fd$0$29988$c3e8da3$5496439d@news.astraweb.com> On Fri, 25 Nov 2011 14:52:25 +0800, ZhouPeng wrote: > Hi all, > > In my program, I get a listen element by listen = > graphics.find("listen") What is a listen element? It is not a standard Python object. What library is it from? > print listen is print type listen is 'instance'> I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False What makes you think this is a strange result? Many things are false: py> for obj in (None, [], {}, 0, 0.0, "", 42): ... print bool(obj), ... False False False False False False True -- Steven From __peter__ at web.de Fri Nov 25 04:06:05 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 25 Nov 2011 10:06:05 +0100 Subject: Strange result ffor object to bool References: Message-ID: ZhouPeng wrote: > In my program, I get a listen element by > listen = graphics.find("listen") > > print listen is > print type listen is > I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False > if not listen is True bool(listen) is False here means that the Element has no children. Quoting http://effbot.org/zone/elementtree-13-intro.htm#truth-testing """ Truth testing # The Element type now issues a warning when used in a ?boolean context?. To get rid of the warning, make the test explicit: if len(elem): ... has at least one children ... elem = root.find("tag") if elem is not None: ... found ... Explicit tests work just fine in ET 1.2, of course. The boolean interpretation will most likely change in future versions, so that all elements evaluate to true, also if they have no children. """ From zpengxen at gmail.com Fri Nov 25 05:09:43 2011 From: zpengxen at gmail.com (ZhouPeng) Date: Fri, 25 Nov 2011 18:09:43 +0800 Subject: Strange result ffor object to bool In-Reply-To: References: Message-ID: Thanks all. I am a c/c++ programer before, So I directly think it is the same roughly between if not obj: (in python) and if (!obj) {(in c/c++) / if obj: (in python) and if (obj) {(in c/c++) That if obj is not None, 'if obj:' goes true branch, 'if not obj:' goes false branch, and I don't need to care where the obj is from (what type or what lib) But, Now it seem not be consistent, so I feel strange. And it seem be obj's library related in python. On Fri, Nov 25, 2011 at 4:59 PM, Peter Otten <__peter__ at web.de> wrote: >What is a listen element? It is not a standard Python object. What >library is it from? from xml.etree.ElementTree On Fri, Nov 25, 2011 at 5:06 PM, Peter Otten <__peter__ at web.de> wrote: > ZhouPeng wrote: > >> In my program, I get a listen element by >> listen = graphics.find("listen") >> >> print listen is >> print type listen is >> I am sure listen is not None and can be accessed properly. >> >> But print bool(listen) is False >> if not listen ?is True > > bool(listen) is False here means that the Element has no children. > Quoting > http://effbot.org/zone/elementtree-13-intro.htm#truth-testing Thanks, > """ > Truth testing # > The Element type now issues a warning when used in a ?boolean context?. To > get rid of the warning, make the test explicit: > if len(elem): > ? ?... has at least one children ... > > elem = root.find("tag") > if elem is not None: > ? ?... found ... > Explicit tests work just fine in ET 1.2, of course. > The boolean interpretation will most likely change in future versions, so > that all elements evaluate to true, also if they have no children. > """ Yea, you are right. And I got it later, when I run my program in python 2.7.2, It complains: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. if not graphics: > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Zhou Peng From enalicho at gmail.com Fri Nov 25 05:13:00 2011 From: enalicho at gmail.com (Noah Hall) Date: Fri, 25 Nov 2011 10:13:00 +0000 Subject: Return of an old friend In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 5:08 AM, Matt Joiner wrote: > I haven't heard of you before, but feel like I've missed out on something. > > Do you (or someone else) care to link to some of your more contentious work? Ignore him, he's a troll with an unjustly inflated ego. From onlinedollarsgroups at gmail.com Fri Nov 25 05:33:25 2011 From: onlinedollarsgroups at gmail.com (onlinedollars earning) Date: Fri, 25 Nov 2011 02:33:25 -0800 (PST) Subject: Amazing website!!! Message-ID: <93aa2e6b-60c8-4aef-8ef6-ed6407c008a2@x30g2000prh.googlegroups.com> Hai, I have a tips for earn money from home.Just go to http://onlinedollarsgroups.blogspot.com/2011/11/blog-post_25.html this weblink.Then click open new tab via that link.One new website will display,then sign up this,and earn money (or)and get any products in low price,offers etc. From ulrich.eckhardt at dominolaser.com Fri Nov 25 05:37:14 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 25 Nov 2011 11:37:14 +0100 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: Am 25.11.2011 04:49, schrieb alex23: > On Nov 24, 6:51 pm, Tim Golden wrote: >> The Ctrl-Z thing is what *exits* the interpreter on Windows >> (a la Ctrl-D on Linux). > > With ActivePython, Ctrl-D works as well, which is a godsend as I'm > constantly working across Windows& linux. > >> In short - on Windows, within one cmd shell you can open and exit >> the interpreter as many times as you like and the Python command >> history will be retained via the cmd shell's history mechanism, >> and kept distinct from the history of other things you may type >> into the cmd shell. > > And again, I'm definitely not seeing this. Inside the one cmd shell, > each instance of Python has no recollection of the history of the > last. I'm seeing history browsing in Python on MS Windows XP here and it also works for every other commandline-based program. Well, it seems with the exception of the ActivePython distribution of Python. That one intentionally changes the MS Windows defaults like Control-Z behaviour and at the same time, maybe even as a side effect, it breaks the shell's history browsing. You don't happen to have an installation of the vanilla Python distribution to test, do you? This is getting me curious... Uli From rosuav at gmail.com Fri Nov 25 05:42:50 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Nov 2011 21:42:50 +1100 Subject: Strange result ffor object to bool In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 9:09 PM, ZhouPeng wrote: > Thanks all. > if not obj: (in python) and if (!obj) {(in c/c++) > > / if obj: (in python) and if (obj) {(in c/c++) > > Yea, ?you are right. > And I got it later, when I run my program in python 2.7.2, > It complains: > FutureWarning: The behavior of this method will change in future versions. > Use specific 'len(elem)' or 'elem is not None' test instead. if not graphics: Yep, this is exactly what you need to do. Check if 'elem is None' to see if it's there or not. Chris Angelico From jehugaleahsa at gmail.com Fri Nov 25 05:55:53 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Fri, 25 Nov 2011 02:55:53 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4ECBEBEC.2010300@yahoo.com> Message-ID: On Nov 22, 1:37?pm, Alan Meyer wrote: > On 11/20/2011 7:46 PM, Travis Parks wrote: > > > Hello: > > > I am currently working on designing a new programming language. ... > > I have great respect for people who take on projects like this. > > Your chances of popularizing the language are small. ?There must be > thousands of projects like this for every one that gets adopted by other > people. ?However your chances of learning a great deal are large, > including many things that you'll be able to apply to programs and > projects that, at first glance, wouldn't appear to benefit from this > kind of experience. ?If you get it working you'll have an impressive > item to add to your resume. > > I suspect that you'll also have a lot of fun. > > Good luck with it. > > ? ? ?Alan I've been learning a lot and having tons of fun just designing the language. First, I get think about all of the language features that I find useful. Then I get to learn a little bit how they work internally. For instance, functions are first-class citizens in Unit, supporting closures. To make that happen meant wrapping such functions inside of types and silently elavating local variables to reference counted pointers. Or, I realized that in order to support default arguments, I would have to silently wrap parameters in types that were either set or not set. That way calls to the default command could simply be replaced by an if statement. It was a really subtle implementation detail. It is also fun thinking about what makes sense. For instance, Unit will support calling methods with named arguments. Originally, I thought about using the '=' operator: Foo(name="bob" age=64) but, then I realized that the equals sign could be confused with assignment. Those types of syntactic conflicts occur quite often and lead to a lot of rethinking. Ultimately, somewhat good ideas get replaced with much better ideas. I had been contemplating Unit for months before the final look and feel of the language came into view. It isn't what I started out imagining, but I think it turned out better than I had originally planned. Recently, I rethought how functions looked, since the headers were too long: alias Predicate = function (value: & readonly T) throws() returns(Boolean) let Any = public function (values: & readonly IIterable) (?predicate: Predicate) throws() # ArgumentNullException inherits from UncheckedException returns(Boolean): # this can be on one line default predicate = (function value: true) assert predicate != null "The predicate cannot be null." ArgumentNullException for value in values: if predicate(value): return true return false Most of the time, throws clauses, returns clauses and parameter type constraints can be left off. Plus, now they can all appear on one line. Assertions and default statements now appear in the body. Assertions now optionally take a message and the exception type to throw. So, yeah, this has been an awesome project so far. I have dozens of documents and I have been keeping up on a blog. I've even started implementing a simple recursive descent parser just to make sure the syntax doesn't conflict. Now it will be a matter of formally defining a grammer and implementing the backend of the compiler... which I've never done before. I have been thinking about compiling into a language like C++ or C instead of assembler for my first time through. From rosuav at gmail.com Fri Nov 25 06:10:00 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Nov 2011 22:10:00 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4ECBEBEC.2010300@yahoo.com> Message-ID: On Fri, Nov 25, 2011 at 9:55 PM, Travis Parks wrote: > I have been thinking about compiling into a > language like C++ or C instead of assembler for my first time through. Yep, or any other language you feel like using as an intermediate. Or alternatively, just start with an interpreter - whatever's easiest. Compiling to C gives you a massive leg-up on portability; so does writing an interpreter in C, as either way your language is easily made available on every platform that gcc's been ported to. As long as you're happy with the idea of building a massively language that'll never be used by anybody but yourself, you can have immense fun with this. And hey, Unit might turn out to be a beautiful niche language, or even go mainstream. But mainly, you'll have fun doing it. And if you're not having fun, what's the use of living forever? (Oh wait, you're not a vampire from Innistrad. Sorry about that.) ChrisA From andrea.crotti.0 at gmail.com Fri Nov 25 06:15:30 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 25 Nov 2011 11:15:30 +0000 Subject: getting svn tag in version Message-ID: <4ECF78D2.8000502@gmail.com> Given a project with many eggs, I would like to make it easy to have all the version numbers synchronized to the upper level SVN version. So for example I might have svn tags 0.1, 0.2 and a development version. The development version should get version -dev, and the others 0.1 and 0.2 I found few examples around that read and parse the .svn/entries file, is it really the best way to do it? From user at nospam.invalid Fri Nov 25 06:24:44 2011 From: user at nospam.invalid (user) Date: Fri, 25 Nov 2011 12:24:44 +0100 Subject: How to get path to Python standard library directory? Message-ID: In a Makefile (or sometimes inside python) I need the path to the root of the Python standard lib folder used by "env python". e.g. /usr/lib/python2.6/ or C:\Python27\Lib\ what is the best/canonical way to get that? From mail at timgolden.me.uk Fri Nov 25 06:29:51 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 25 Nov 2011 11:29:51 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ECF7C2F.8090905@timgolden.me.uk> On 25/11/2011 10:37, Ulrich Eckhardt wrote: > Am 25.11.2011 04:49, schrieb alex23: >> On Nov 24, 6:51 pm, Tim Golden wrote: >>> The Ctrl-Z thing is what *exits* the interpreter on Windows >>> (a la Ctrl-D on Linux). >> >> With ActivePython, Ctrl-D works as well, which is a godsend as I'm >> constantly working across Windows& linux. >> >>> In short - on Windows, within one cmd shell you can open and exit >>> the interpreter as many times as you like and the Python command >>> history will be retained via the cmd shell's history mechanism, >>> and kept distinct from the history of other things you may type >>> into the cmd shell. >> >> And again, I'm definitely not seeing this. Inside the one cmd shell, >> each instance of Python has no recollection of the history of the >> last. > > I'm seeing history browsing in Python on MS Windows XP here and it also > works for every other commandline-based program. Well, it seems with the > exception of the ActivePython distribution of Python. That one > intentionally changes the MS Windows defaults like Control-Z behaviour > and at the same time, maybe even as a side effect, it breaks the shell's > history browsing. Except that, intriguingly, I'm also using an ActiveState distro and it neither adds Ctrl-D nor prevents history. But I'm fairly sure that pyreadline does both of those things. TJG From michael at stroeder.com Fri Nov 25 07:31:10 2011 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Fri, 25 Nov 2011 13:31:10 +0100 Subject: ANN: python-ldap 2.4.5 Message-ID: Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.4 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stuff (e.g. processing LDIF, LDAPURLs and LDAPv3 schema). Project's web site: http://www.python-ldap.org/ Ciao, Michael. ---------------------------------------------------------------- Released 2.4.5 2011-11-25 Changes since 2.4.4: Installation: * defines for SASL and SSL in setup.cfg to be more friendly to Python setup tools (easy_install) Lib/ * Fixed typo in ldap.functions._ldap_function_call() which always released ldap._ldap_module_lock instead of local lock * ldap.controls.ppolicy: Fixed decoding the password policy response control Demo/ * Demo script for ldap.controls.ppolicy From 1989lzhh at gmail.com Fri Nov 25 07:47:11 2011 From: 1989lzhh at gmail.com (=?GB2312?B?wfXV8bqj?=) Date: Fri, 25 Nov 2011 20:47:11 +0800 Subject: How to change the file creation timestamp? Message-ID: Hi, I want to change the file creation timestamp using python, but I can not find a solution to do it. I know the way to change the file creation timestamp in C under Windows, but I want to change it using python. I really need help! Regards, Liu Zhenhai -------------- next part -------------- An HTML attachment was scrubbed... URL: From massi_srb at msn.com Fri Nov 25 08:00:04 2011 From: massi_srb at msn.com (Massi) Date: Fri, 25 Nov 2011 05:00:04 -0800 (PST) Subject: Automatic import of submodules Message-ID: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | -- __init__.py -- EtcPlug.py Every .py file contain a class definition whose name is identical to to the file name, so in my main script I have to import each submodule like that: from plugins.wav_plug.WavPlug import WavPlug from plugins.wav_plug.Mp3Plug import Mp3Plug and so on. This is uncomfortable, since when a new plugin is added I have to import it too. So my question is, is it possible to iterate through the 'plugins' directory tree in order to automatically import the submodules contained in each subdirectory? I googled and found that the pkgutil could help, but it is not clear how. Any hints? Thanks in advance. From d at davea.name Fri Nov 25 08:08:08 2011 From: d at davea.name (Dave Angel) Date: Fri, 25 Nov 2011 08:08:08 -0500 Subject: How to get path to Python standard library directory? In-Reply-To: References: Message-ID: <4ECF9338.1050007@davea.name> On 11/25/2011 06:24 AM, user wrote: > In a Makefile (or sometimes inside python) I need the path to the root > of the Python standard lib folder used by "env python". > > e.g. /usr/lib/python2.6/ or C:\Python27\Lib\ > > what is the best/canonical way to get that? You could look at sys.executable. However, on my Linux, it's a symlink, so you have to dereference that to get the directory involved. -- DaveA From d at davea.name Fri Nov 25 08:18:30 2011 From: d at davea.name (Dave Angel) Date: Fri, 25 Nov 2011 08:18:30 -0500 Subject: Automatic import of submodules In-Reply-To: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> References: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Message-ID: <4ECF95A6.20808@davea.name> On 11/25/2011 08:00 AM, Massi wrote: > Hi everyone, > > in my project I have the following directory structure: > > plugins > | > -- wav_plug > | > -- __init__.py > -- WavPlug.py > -- mp3_plug > | > -- __init__.py > -- Mp3Plug.py > ... > -- etc_plug > | > -- __init__.py > -- EtcPlug.py > > Every .py file contain a class definition whose name is identical to > to the file name, so in my main script I have to import each submodule > like that: > > from plugins.wav_plug.WavPlug import WavPlug > from plugins.wav_plug.Mp3Plug import Mp3Plug > > and so on. This is uncomfortable, since when a new plugin is added I > have to import it too. So my question is, is it possible to iterate > through the 'plugins' directory tree in order to automatically import > the submodules contained in each subdirectory? > I googled and found that the pkgutil could help, but it is not clear > how. Any hints? > Thanks in advance. > I think the key to the problem is the __import__() function, which takes a string and returns a module object. So you make a list of the fully qualified module names (filenames less the extension), and loop through that list, Then for each one, you can extract items from the module. It doesn't make sense to define the class names at your top-level, though, since you'd not have any code to reference any new plugin if it has a unique class name. So at some point, you're probably going to have a list or map of such class objects. -- DaveA From ironfroggy at gmail.com Fri Nov 25 08:23:33 2011 From: ironfroggy at gmail.com (Calvin Spealman) Date: Fri, 25 Nov 2011 08:23:33 -0500 Subject: How to get path to Python standard library directory? In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 6:24 AM, user wrote: > In a Makefile (or sometimes inside python) I need the path to the root of > the Python standard lib folder used by "env python". > > e.g. ?/usr/lib/python2.6/ ? or ? ?C:\Python27\Lib\ > > what is the best/canonical way to get that? This should get you what you're looking for. Just look relative to a known stdlib module. import os stdlib_dir = os.path.dirname(os.__file__) > -- > http://mail.python.org/mailman/listinfo/python-list > -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy From jeanmichel at sequans.com Fri Nov 25 08:43:58 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 25 Nov 2011 14:43:58 +0100 Subject: Automatic import of submodules In-Reply-To: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> References: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Message-ID: <4ECF9B9E.704@sequans.com> Massi wrote: > Hi everyone, > > in my project I have the following directory structure: > > plugins > | > -- wav_plug > | > -- __init__.py > -- WavPlug.py > -- mp3_plug > | > -- __init__.py > -- Mp3Plug.py > ... > -- etc_plug > | > -- __init__.py > -- EtcPlug.py > > Every .py file contain a class definition whose name is identical to > to the file name, so in my main script I have to import each submodule > like that: > > from plugins.wav_plug.WavPlug import WavPlug > from plugins.wav_plug.Mp3Plug import Mp3Plug > > and so on. This is uncomfortable, since when a new plugin is added I > have to import it too. So my question is, is it possible to iterate > through the 'plugins' directory tree in order to automatically import > the submodules contained in each subdirectory? > I googled and found that the pkgutil could help, but it is not clear > how. Any hints? > Thanks in advance. > > Hi, Try something like (*untested code*) plugins = {} classes = {} for plugin, className in [('wav_plug', 'WavPlug'), ('mp3_plug', 'Mp3Plug')]: plugins[plugin] = __import__(os.path.join('plugins', plugin, className)) classes[className] = getattr(plugins[plugin], className) # raise a keyError if the plugin has not been imported wav = classes['wav_plug']() Make sure all subdirs have the __init__.py file, including the plugins directory. JM From a24061 at ducksburg.com Fri Nov 25 08:50:01 2011 From: a24061 at ducksburg.com (Adam Funk) Date: Fri, 25 Nov 2011 13:50:01 +0000 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) Message-ID: <91j4q8xgv9.ln2@news.ducksburg.com> I'm converting JSON data to XML using the standard library's json and xml.dom.minidom modules. I get the input this way: input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') big_json = json.load(input_source) input_source.close() Then I recurse through the contents of big_json to build an instance of xml.dom.minidom.Document (the recursion includes some code to rewrite dict keys as valid element names if necessary), and I save the document: xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') doc.writexml(xml_file, encoding='UTF-8') xml_file.close() I thought this would force all the output to be valid, but xmlstarlet gives some errors like these on a few documents: PCDATA invalid Char value 7 PCDATA invalid Char value 31 I guess I need to process each piece of PCDATA to clean out the control characters before creating the text node: text = doc.createTextNode(j) root.appendChild(text) What's the best way to do that, bearing in mind that there can be multibyte characters in the strings? I found some suggestions on the WWW involving filter with string.printable, which AFAICT isn't unicode-friendly --- is there a unicode.printable or something like that? -- "Mrs CJ and I avoid clich?s like the plague." From alec.taylor6 at gmail.com Fri Nov 25 08:51:34 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sat, 26 Nov 2011 00:51:34 +1100 Subject: How to change the file creation timestamp? In-Reply-To: References: Message-ID: import os import time from stat import * #returns a list of all the files on the current directory files = os.listdir('.') for f in files: #my folder has some jpegs and raw images if f.lower().endswith('jpg') or f.lower().endswith('crw'): st = os.stat(f) atime = st[ST_ATIME] #access time mtime = st[ST_MTIME] #modification time new_mtime = mtime + (4*3600) #new modification time #modify the file timestamp os.utime(f,(atime,new_mtime)) On Fri, Nov 25, 2011 at 11:47 PM, ??? <1989lzhh at gmail.com> wrote: > Hi, > I want to change the file creation timestamp using python, but I can not > find a solution to do it. > I know the way to?change the file creation timestamp in C under Windows, but > I want to change it using python. > I really need help! > > Regards, > Liu Zhenhai > > -- > http://mail.python.org/mailman/listinfo/python-list > From irmen.NOSPAM at xs4all.nl Fri Nov 25 09:11:06 2011 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Fri, 25 Nov 2011 15:11:06 +0100 Subject: getting svn tag in version In-Reply-To: References: Message-ID: <4ecfa1fc$0$6909$e4fe514c@news2.news.xs4all.nl> On 25-11-2011 12:15, Andrea Crotti wrote: > Given a project with many eggs, I would like to make it easy to have all the version > numbers synchronized > to the upper level SVN version. > > So for example I might have svn tags > 0.1, > 0.2 > and a development version. > The development version should get version -dev, and the others 0.1 and 0.2 > > I found few examples around that read and parse the .svn/entries file, is it really > the best way to do it? I wouldn't do that, you'll be dependent on the svn implementation. For instance, in svn 1.7, they changed the .svn folder. Easiest is probably parsing the output of the command line svn: svn info --xml Irmen From someone at someplace.invalid Fri Nov 25 10:44:19 2011 From: someone at someplace.invalid (HoneyMonster) Date: Fri, 25 Nov 2011 15:44:19 +0000 (UTC) Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: On Mon, 14 Nov 2011 21:55:43 +1100, Chris Angelico wrote: > On Mon, Nov 14, 2011 at 9:41 PM, Tracubik wrote: >> Hi all, >> i'm developing a new program. >> Mission: learn a bit of database management > > If your goal is to learn about databasing, then I strongly recommend a > real database engine. > >> since i'm mostly a new-bye for as regard databases, my idea is to use >> sqlite at the beginning. >> >> Is that ok? any other db to start with? (pls don't say mysql or >> similar, >> they are too complex and i'll use this in a second step) > > The complexity, in most cases, is a direct consequence of the job at > hand. I recommend PostgreSQL generally, although I've never used it with > Python and can't speak for the quality of the APIs. > > The most important thing to consider is a separation of the back end > (the "guts") from the front end (the "interface"). Since your goal is to > explore databases, the guts of your code will basically just be working > with the database (no heavy computation or anything). Make sure you can > work with that, separately from your GUI. You may find it easier to > dispense with GTK and just work through the console; you can always > change later to make a pretty window. > > If you've never worked with databases before, it may be best to skip > Python altogether and explore the fundamentals of relational database > engines. There's plenty of excellent tutorials on the web. Get to know > how things are done generally, and you'll be able to figure out how > things are done in Python. I agree that given "Mission: learn a bit of database management", Python is not really relevant at this stage. I also entirely concur with your recommendation of PostgreSQL. Just for information, PostgreSQL works very well indeed with Psycopg (a PostgreSQL adapter for Python), but for learning purposes straightforward PSQL is best to start with. From miki.tebeka at gmail.com Fri Nov 25 10:48:35 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Fri, 25 Nov 2011 07:48:35 -0800 (PST) Subject: How to get path to Python standard library directory? In-Reply-To: References: Message-ID: <1236612.727.1322236115510.JavaMail.geo-discussion-forums@yqoo7> You can try PYLIB = $(shell python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()') (or pack the long command line in a script). From rosuav at gmail.com Fri Nov 25 10:49:43 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 26 Nov 2011 02:49:43 +1100 Subject: my new project, is this the right way? In-Reply-To: References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: On Sat, Nov 26, 2011 at 2:44 AM, HoneyMonster wrote: > Just for information, PostgreSQL works very well indeed with Psycopg (a > PostgreSQL adapter for Python), but for learning purposes straightforward > PSQL is best to start with. Thanks for that. I've used PgSQL from C++ (using libpqxx), PHP, Pike, and the command line, but not from Python. (Yeah, a lot of Ps in that.) Once you start looking to write actual code, Python will be an excellent choice. But master the basics of database/schema/table/column, primary keys, etc, etc, etc, first. ChrisA From maxthemouse at googlemail.com Fri Nov 25 11:31:56 2011 From: maxthemouse at googlemail.com (MaxTheMouse) Date: Fri, 25 Nov 2011 08:31:56 -0800 (PST) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <8ce7e33b-418b-478d-bada-0e128ddf7cb6@c18g2000yqj.googlegroups.com> On Nov 24, 10:49?pm, Dennis Lee Bieber wrote: > On 25 Nov 2011 00:16:06 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > > chimed in to either confirm or refute W. eWatson's claim that IDLE > > doesn't show up, so we have no way of telling whether it doesn't show up > > due to a lack in the installer, or because eWatson has (slightly) broken > > his system and has inadvertently prevented it from showing up. > I guess I will put in my 2 cents. I installed EPD from Enthought on 64 bit Win 7 Enterprise. Both 32 bit and 64 versions resulted in having "Edit with Idle" when I right-click on a file. I don't have system administration privileges on this machine so I have no idea how the installer did it. Cheers, Adam From rustompmody at gmail.com Fri Nov 25 12:01:34 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 25 Nov 2011 09:01:34 -0800 (PST) Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> On Nov 14, 3:41?pm, Tracubik wrote: > Hi all, > i'm developing a new program. > Mission: learn a bit of database management > Idea: create a simple, 1 window program that show me a db of movies i've > seen with few (<10) fields (actors, name, year etc) > technologies i'll use: python + gtk > db: that's the question > > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) > > is there any general tutorial of how to start developing a database? i > mean a general guide to databases you can suggest to me? > Thank you all > > MedeoTL > > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > easily convert it in a sqlite db? (maybe via csv) To learn DBMS you need to learn sql [Note sql is necessary but not sufficient for learning DBMS] I recommend lightweight approaches to start with -- others have mentioned access, libreoffice-base. One more lightweight playpen is firefox plugin sqlite-manager > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) Correct. First you must figure out how to structure data -- jargon is normalization. After that you can look at transactions, ACID, distribution and all the other good stuff. From rustompmody at gmail.com Fri Nov 25 12:11:01 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 25 Nov 2011 09:11:01 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <67882be2-e60e-44c0-851c-a981f882e2ed@c16g2000pre.googlegroups.com> On Nov 21, 5:46?am, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. > > Can anyone list a good introduction to the files found in the source > code? I have been poking around the source code for a little bit and > there is a lot there. So, I was hoping someone could point me to the > "good parts". I am also wondering whether some of the code was > generated because I see state transition tables, which I doubt someone > built by hand. > > Any help would be greatly appreciated. It will be cool to see how the > interpreter works internally. I am still wonder whether designing the > language (going on 4 months now) will be harder than implementing it. > > Thanks, > Travis Parks - compiled language - indentation based - functional programming features Looks like a description of Haskell. You may want to look there. Back end: LLVM is gaining a lot of traction these days. Seems to give best of both worlds -- compiling to C and to machine code From roy at panix.com Fri Nov 25 12:16:21 2011 From: roy at panix.com (Roy Smith) Date: Fri, 25 Nov 2011 12:16:21 -0500 Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> Message-ID: In article <581dab49-e6b0-4fea-915c-4a41fa887c3b at p7g2000pre.googlegroups.com>, rusi wrote: > First you must figure out how to structure data -- jargon is > normalization. After that you can look at transactions, ACID, > distribution and all the other good stuff. And when you're all done with that, you can start unlearning everything you've learned about normalization (not that you shouldn't learn about it in the first place, just that you should also learn when excessive normalization is a bad thing). And then start looking at BASE (Basic Availability, Soft-state, Eventually consistent) as an alternative to ACID. Don't get me wrong. SQL is a powerful tool, and truly revolutionized the database world. Anybody who is thinking about going into databases as a career needs to know SQL. But, it's not the end of the road. There is life after SQL, and that's worth exploring too. From python at mrabarnett.plus.com Fri Nov 25 12:56:07 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 25 Nov 2011 17:56:07 +0000 Subject: Return of an old friend In-Reply-To: References: Message-ID: <4ECFD6B7.30205@mrabarnett.plus.com> On 25/11/2011 10:13, Noah Hall wrote: > On Fri, Nov 25, 2011 at 5:08 AM, Matt Joiner wrote: >> I haven't heard of you before, but feel like I've missed out on something. >> >> Do you (or someone else) care to link to some of your more contentious work? > > Ignore him, he's a troll with an unjustly inflated ego. He has previously posted under the name "rantingrick". In brief, his posts have been about how Python is doomed unless it's rescued from the elite who are ignoring the needs of the silent majority by not fixing this or that, and he offers himself as the one who'll lead the Python community into the promised land, or something like that. From nikunjbadjatya at gmail.com Fri Nov 25 13:00:21 2011 From: nikunjbadjatya at gmail.com (Nikunj Badjatya) Date: Fri, 25 Nov 2011 23:30:21 +0530 Subject: How to keep Console area fixed for a thread In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D7B8@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D7B8@MX34A.corp.emc.com> Message-ID: Can anyone throw some light on this please ! ? On Thu, Nov 24, 2011 at 9:05 PM, wrote: > Hi All,**** > > ** ** > > Please look at the code below.**** > > I am using pypi progressbar. But in general, How can I keep the area of > the console fixed for the thread to print its status on it.**** > > ** ** > > {{{**** > > import sys**** > > import time**** > > import threading**** > > import os**** > > ** ** > > from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \* > *** > > FileTransferSpeed, FormatLabel, Percentage, \**** > > ProgressBar, ReverseBar, RotatingMarker, \**** > > SimpleProgress, Timer**** > > **** > > def ProgBar():**** > > widgets = [' ', Percentage(), ' ', > Bar(marker='#',left='[',right=']'),' ']**** > > pbar = ProgressBar(widgets=widgets, maxval=100)**** > > pbar.start()**** > > return pbar**** > > **** > > def update2(i):**** > > os.environ["PBAR"] = i**** > > print(?This will print for every call to update?)**** > > return **** > > **** > > ** ** > > ** ** > > class MyThread(threading.Thread):**** > > def run(self):**** > > l = 0**** > > while True:**** > > n = os.getenv("PBAR", "")**** > > if len(n) != 0:**** > > n = int(n)**** > > if n > l:**** > > pbar.update(n)**** > > l = n**** > > if n == 100:**** > > break **** > > else:**** > > continue **** > > ** ** > > pbar = ProgBar()**** > > mythread = MyThread()**** > > mythread.daemon = True **** > > mythread.start() **** > > ** ** > > **** > > for i in range(101):**** > > update2("{0}".format(i))**** > > time.sleep(0.25)**** > > ** ** > > }}} **** > > ** ** > > {{{**** > > Output:**** > > ** ** > > [image: output.jpeg]**** > > ** ** > > ** ** > > }}}**** > > ** ** > > But I require the output to be of type:**** > > {{{**** > > 13% [########### ]**** > > This will print for every call to update**** > > This will print for every call to update**** > > This will print for every call to update**** > > This will print for every call to update**** > > This will print for every call to update**** > > }}}**** > > ** ** > > This is just a sample piece of code for narrowing down the problem. **** > > How can I fix the cursor position fix for the thread which is updating my > progressbar .?**** > > ** ** > > Thanks**** > > Nikunj**** > > Bangalore-India**** > > ** ** > > ** ** > > ** ** > > ** ** > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 37098 bytes Desc: not available URL: From chris at simplistix.co.uk Fri Nov 25 13:54:13 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Fri, 25 Nov 2011 18:54:13 +0000 Subject: What replaces log4py under Python 3.2? In-Reply-To: <67D108EDFAD3C148A593E6ED7DCB4BBDEDD0A5@RADCONWIN2K8PDC.radcon.local> References: <67D108EDFAD3C148A593E6ED7DCB4BBDEDD0A5@RADCONWIN2K8PDC.radcon.local> Message-ID: <4ECFE455.30904@simplistix.co.uk> On 22/11/2011 18:32, Rob Richardson wrote: > My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? How about the core logging package included in Python itself? cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From nulla.epistola at web.de Fri Nov 25 14:52:56 2011 From: nulla.epistola at web.de (Sibylle Koczian) Date: Fri, 25 Nov 2011 20:52:56 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: Am 25.11.2011 01:16, schrieb Steven D'Aprano: > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > chimed in to either confirm or refute W. eWatson's claim that IDLE > doesn't show up, so we have no way of telling whether it doesn't show up > due to a lack in the installer, or because eWatson has (slightly) broken > his system and has inadvertently prevented it from showing up. > I'm using Python 3.2.2 on Windows 7, 64 bit, and I get "Edit with IDLE" and "Edit with PythonWin" in my context menu. I installed Python from the Python.org site, the Windows extensions from Sourceforge, both of them for all users and without any changes to the standard installation or to file associations. This isn't the first Python 3 version on this machine, I don't know if that might be relevant. But it's a fact that changing the applications shown in the context menu for a file association isn't obvious any more on Windows 7. HTH Sibylle From dihedral88888 at googlemail.com Fri Nov 25 18:19:25 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 25 Nov 2011 15:19:25 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <26406614.367.1322263165339.JavaMail.geo-discussion-forums@prnu18> > Except that, intriguingly, I'm also using an ActiveState distro > and it neither adds Ctrl-D nor prevents history. But I'm > fairly sure that pyreadline does both of those things. > > TJG In python I can spawn a process to run python byte code that will produce a file with results. Easy to avoid a lot import A,B,C,D...... on the top level. From dihedral88888 at googlemail.com Fri Nov 25 18:19:25 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 25 Nov 2011 15:19:25 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <26406614.367.1322263165339.JavaMail.geo-discussion-forums@prnu18> > Except that, intriguingly, I'm also using an ActiveState distro > and it neither adds Ctrl-D nor prevents history. But I'm > fairly sure that pyreadline does both of those things. > > TJG In python I can spawn a process to run python byte code that will produce a file with results. Easy to avoid a lot import A,B,C,D...... on the top level. From 1989lzhh at gmail.com Fri Nov 25 20:12:21 2011 From: 1989lzhh at gmail.com (=?GB2312?B?wfXV8bqj?=) Date: Sat, 26 Nov 2011 09:12:21 +0800 Subject: How to change the file creation timestamp? In-Reply-To: References: Message-ID: Hi Alec Thanks for your help. I want to change the creation timestamp. the code that you give is to change the modification and access time. I already find a solution using pywin32's win32file module import win32file filehandle = win32file.CreateFile(file_name, win32file.GENERIC_WRITE, 0, None, win32file.OPEN_EXISTING, 0, 0) win32file.SetFileTime(filehandle, ctime, atime, mtime) Regards, Liu Zhenhai 2011/11/25 Alec Taylor > import os > import time > from stat import * > > #returns a list of all the files on the current directory > files = os.listdir('.') > > for f in files: > #my folder has some jpegs and raw images > if f.lower().endswith('jpg') or f.lower().endswith('crw'): > st = os.stat(f) > atime = st[ST_ATIME] #access time > mtime = st[ST_MTIME] #modification time > > new_mtime = mtime + (4*3600) #new modification time > > #modify the file timestamp > os.utime(f,(atime,new_mtime)) > > On Fri, Nov 25, 2011 at 11:47 PM, ??? <1989lzhh at gmail.com> wrote: > > Hi, > > I want to change the file creation timestamp using python, but I can not > > find a solution to do it. > > I know the way to change the file creation timestamp in C under Windows, > but > > I want to change it using python. > > I really need help! > > > > Regards, > > Liu Zhenhai > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.kapps at web.de Fri Nov 25 20:34:19 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Sat, 26 Nov 2011 02:34:19 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ECEE208.9010602@web.de> Message-ID: <4ED0421B.3080801@web.de> On 25.11.2011 05:49, Dennis Lee Bieber wrote: > On Fri, 25 Nov 2011 01:32:08 +0100, Alexander Kapps > declaimed the following in gmane.comp.python.general: > > >> The main difference here is, that Linux makes it easy to seperate >> administrative accounts from end-user accounts, >> > So does Win7... Heck -- I have to answer prompts to OK an installer > even while logged into my admin account! For Windows, Left-Clicking an OK button to confirm potentionally dangerous admin tasks is like linking the acceleration pedal in your car to the brake pedal(If the traffic light shows Red/Stop, push the acceleration pedal to break) I mean, seriously, left-clicking an OK button is something *SO* unusual to Windows users that you could also just remove that "barrier" altogether. Now, OK, I don't really know any Windows version after XP, so things might have changed. But what I see from the casual Win users in my environment is that nothing has really changed. From wuwei23 at gmail.com Fri Nov 25 22:42:31 2011 From: wuwei23 at gmail.com (alex23) Date: Fri, 25 Nov 2011 19:42:31 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <944e0207-7083-4ae8-a59e-3e05b595708e@d37g2000prg.googlegroups.com> Message-ID: On Nov 25, 6:58?pm, Tim Golden wrote: > Do you have the pyreadline module installed? ISTR that that takes > over from the standard cmd processing... I'm pretty sure I do. It's really not an issue, though, as I tend to stick to linux & iPython where possible :) From illy at otekno.biz Fri Nov 25 22:45:05 2011 From: illy at otekno.biz (Illy) Date: Sat, 26 Nov 2011 10:45:05 +0700 Subject: myComboBox.SetValue() does not work in windows. Message-ID: <4ED060C1.3050609@otekno.biz> Dear friends.... Anybody know how can I change the text of a ComboBox? Because " myComboBox.SetValue("my text") " does not work on Windows. Anybody would be so nice for telling me complete reference/documentation about wxPython on windows? Because the wxPython between on Linux and on Windows are sometimes different. Thank you very much in advance. -- Let us cut your costs for your business: http://www.otekno.biz Skype: otekno.biz Yahoo-ID: ceo.opentek at ymail.com OpenTEKID: ceo at opentek.tv Mobile: 087 888 04 26 77 Office: +62-21-4587 90 75, 4587 68 08 Fax: +62-21-4587 64 65 BlackBerry Messanger: 274DF07F From wuwei23 at gmail.com Fri Nov 25 23:15:47 2011 From: wuwei23 at gmail.com (alex23) Date: Fri, 25 Nov 2011 20:15:47 -0800 (PST) Subject: Automatic import of submodules References: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Message-ID: <1603fc14-93b7-4e07-b891-631c083c60bc@20g2000prp.googlegroups.com> On Nov 25, 11:00?pm, Massi wrote: > plugins > ? ? | > ? ? -- wav_plug > ? ? ? ? ? | > ? ? ? ? ? -- __init__.py > ? ? ? ? ? -- WavPlug.py > ? ? -- mp3_plug > ? ? ? ? ? | > ? ? ? ? ? -- __init__.py > ? ? ? ? ? -- Mp3Plug.py > ... > ? ? -- etc_plug > ? ? ? ? ? | > ? ? ? ? ? -- __init__.py > ? ? ? ? ? -- EtcPlug.py What do you gain by having each plugin as a package? Unless you're storing other resources with each plugin, I'd move all your XXXPlug.py files into plugins/ I'd also probably call the modules 'wavplug' and the class 'WavPlug' to always make it clear to which you're referring. > Every .py file contain a class definition whose name is identical to > to the file name, so in my main script I have to import each submodule > like that: > > from plugins.wav_plug.WavPlug import WavPlug > from plugins.wav_plug.Mp3Plug import Mp3Plug > > and so on. This is uncomfortable, since when a new plugin is added I > have to import it too. So my question is, is it possible to iterate > through the 'plugins' directory tree in order to automatically import > the submodules contained in each subdirectory? It's not exactly automatic, but you could move all of those imports into plugins/__init__.py, then just do a single from plugins import * in your main module. From fred.sells at adventistcare.org Fri Nov 25 23:22:46 2011 From: fred.sells at adventistcare.org (Sells, Fred) Date: Fri, 25 Nov 2011 23:22:46 -0500 Subject: Using the Python Interpreter as a Reference In-Reply-To: <67882be2-e60e-44c0-851c-a981f882e2ed@c16g2000pre.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <67882be2-e60e-44c0-851c-a981f882e2ed@c16g2000pre.googlegroups.com> Message-ID: I'm looking at a variation on this theme. I currently use Flex/ActionScript for client side work, but there is pressure to move toward HTML5+Javascript and or iOS. Since I'm an old hand at Python, I was wondering if there is a way to use it to model client side logic, then generate the javascript and ActionScript. I don't see an issue using custom python objects to render either mxml, xaml or html5 but I'm not aware if anyone has already solved the problem of converting Python (byte code?) to these languages? Any suggestions. From metolone at gmail.com Fri Nov 25 23:26:31 2011 From: metolone at gmail.com (Mark Tolonen) Date: Fri, 25 Nov 2011 20:26:31 -0800 (PST) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 25, 11:52?am, Sibylle Koczian wrote: > Am 25.11.2011 01:16, schrieb Steven D'Aprano: > > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > > chimed in to either confirm or refute W. eWatson's claim that IDLE > > doesn't show up, so we have no way of telling whether it doesn't show up > > due to a lack in the installer, or because eWatson has (slightly) broken > > his system and has inadvertently prevented it from showing up. > > I'm using Python 3.2.2 on Windows 7, 64 bit, and I get "Edit with IDLE" > and "Edit with PythonWin" in my context menu. I installed Python from > the Python.org site, the Windows extensions from Sourceforge, both of > them for all users and without any changes to the standard installation > or to file associations. > > This isn't the first Python 3 version on this machine, I don't know if > that might be relevant. > > But it's a fact that changing the applications shown in the context menu > for a file association isn't obvious any more on Windows 7. > > HTH > Sibylle I'm also using Python 2.7 and Python 3.3 on Windows 7, 64-bit, and have both "Edit" menu items as well. Changing the application defaults is now in "Default Programs" right on the Start Menu. It's more "obvious" than the old location, but the old location is just known by more people and Microsoft loves to move things around. -Mark From rustompmody at gmail.com Fri Nov 25 23:48:06 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 25 Nov 2011 20:48:06 -0800 (PST) Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> Message-ID: <804444da-54f8-4325-b3b1-e37b9dc250f1@d37g2000prg.googlegroups.com> On Nov 25, 10:16?pm, Roy Smith wrote: > In article > <581dab49-e6b0-4fea-915c-4a41fa887... at p7g2000pre.googlegroups.com>, > > ?rusi wrote: > > First you must figure out how to structure data -- jargon is > > normalization. After that you can look at transactions, ACID, > > distribution and all the other good stuff. > > And when you're all done with that, you can start unlearning everything > you've learned about normalization (not that you shouldn't learn about > it in the first place, just that you should also learn when excessive > normalization is a bad thing). > > And then start looking at BASE (Basic Availability, Soft-state, > Eventually consistent) as an alternative to ACID. > > Don't get me wrong. ?SQL is a powerful tool, and truly revolutionized > the database world. ?Anybody who is thinking about going into databases > as a career needs to know SQL. ?But, it's not the end of the road. > There is life after SQL, and that's worth exploring too. Yes going all the way up to fifth normal form can be nonsensical. Putting it less jargony -- Given a real world scenario involving data can you organize it into tables with reasonable foreign-key relations, and integrity constraints? If so you can start looking beyond sql. From steve+comp.lang.python at pearwood.info Sat Nov 26 01:18:50 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Nov 2011 06:18:50 GMT Subject: How to change the file creation timestamp? References: Message-ID: <4ed084ca$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sat, 26 Nov 2011 00:51:34 +1100, Alec Taylor wrote: > import os > import time > from stat import * > > #returns a list of all the files on the current directory files = > os.listdir('.') > > for f in files: > #my folder has some jpegs and raw images if f.lower().endswith('jpg') > or f.lower().endswith('crw'): > st = os.stat(f) > atime = st[ST_ATIME] #access time > mtime = st[ST_MTIME] #modification time The original poster asks for how to change the file creation timestamp. (The poster assumes that there is a creation timestamp, which is not necessarily the case -- many file systems do not store the creation time.) > new_mtime = mtime + (4*3600) #new modification time > > #modify the file timestamp > os.utime(f,(atime,new_mtime)) Note that this is from the posix module, so it probably won't work under Windows. > > On Fri, Nov 25, 2011 at 11:47 PM, ??? <1989lzhh at gmail.com> wrote: >> Hi, >> I want to change the file creation timestamp using python, but I can >> not find a solution to do it. >> I know the way to?change the file creation timestamp in C under >> Windows, but I want to change it using python. >> I really need help! >> >> Regards, >> Liu Zhenhai >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> From anacrolix at gmail.com Sat Nov 26 07:19:43 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Sat, 26 Nov 2011 23:19:43 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <67882be2-e60e-44c0-851c-a981f882e2ed@c16g2000pre.googlegroups.com> Message-ID: http://pyjs.org/ On Sat, Nov 26, 2011 at 3:22 PM, Sells, Fred wrote: > I'm looking at a variation on this theme. ?I currently use > Flex/ActionScript for client side work, but there is pressure to move > toward HTML5+Javascript and or iOS. ?Since I'm an old hand at Python, I > was wondering if there is a way to use it to model client side logic, > then generate the javascript and ActionScript. ?I don't see an issue > using custom python objects to render either mxml, xaml or html5 but I'm > not aware if anyone has already solved the problem of converting Python > (byte code?) to these languages? ?Any suggestions. > > -- > http://mail.python.org/mailman/listinfo/python-list > From no.email at please.post Sat Nov 26 08:40:28 2011 From: no.email at please.post (kj) Date: Sat, 26 Nov 2011 13:40:28 +0000 (UTC) Subject: sick of distribute, setup, and all the rest... Message-ID: it's an all-out disgrace. when is python going to get a decent module distribution system??? and don't tell me to do it myself: it's clear that the sorry situation we have now is precisely that too many programmers without the requisite expertise or policy-making authority have decided to pitch in. This is something for GvR and his top Python core library team to do, because the problems are as much policy and institutional ones as they are technical (programming) ones. From steve+comp.lang.python at pearwood.info Sat Nov 26 09:22:11 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Nov 2011 14:22:11 GMT Subject: sick of distribute, setup, and all the rest... References: Message-ID: <4ed0f612$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sat, 26 Nov 2011 13:40:28 +0000, kj wrote: > it's an all-out disgrace. > > when is python going to get a decent module distribution system??? Python 4.3, scheduled for March 2038. It's been ready for a few years now, and a small secret coterie of privileged developers have been using it for their own in-house projects since version 2.1, but it was decided not to release it to the general public, because they'll just bitch and moan that it's a disgrace without actually explaining why they think so, or volunteering to help build a better system. -- Steven From marduk at letterboxes.org Sat Nov 26 09:51:22 2011 From: marduk at letterboxes.org (Albert W. Hopkins) Date: Sat, 26 Nov 2011 09:51:22 -0500 Subject: sick of distribute, setup, and all the rest... In-Reply-To: <4ed0f612$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ed0f612$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <1322319082.3652.3.camel@stretch> On Sat, 2011-11-26 at 14:22 +0000, Steven D'Aprano wrote: > > when is python going to get a decent module distribution system??? > > Python 4.3, scheduled for March 2038. It's been ready for a few years > now, and a small secret coterie of privileged developers have been > using > it for their own in-house projects since version 2.1, but it was > decided > not to release it to the general public, because they'll just bitch > and > moan that it's a disgrace without actually explaining why they think > so, > or volunteering to help build a better system. > > I suspected that all along! > > From maxthemouse at googlemail.com Sat Nov 26 11:22:18 2011 From: maxthemouse at googlemail.com (MaxTheMouse) Date: Sat, 26 Nov 2011 08:22:18 -0800 (PST) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3fe404cb-7a6d-45c4-88ea-830441d22878@p9g2000vbb.googlegroups.com> On Nov 26, 1:13?am, Dennis Lee Bieber wrote: > On Fri, 25 Nov 2011 20:26:31 -0800 (PST), Mark Tolonen > declaimed the following in > gmane.comp.python.general: > > > Changing the application defaults is now in "Default Programs" right > > on the Start Menu. ?It's more "obvious" than the old location, but the > > old location is just known by more people and Microsoft loves to move > > things around. > > ? ? ? ? Maybe I missed it, but when I looked at that on my Win7 laptop, I > only saw a way to define a default for "open" action -- which, for .py > and .pyw files, should be python.exe and pythonw.exe, respectively; > otherwise you can't run them via double-click. > > ? ? ? ? What I did NOT find was a way to define OTHER actions for the > menu... IE; no way to define an "edit with xxx", or a > "print" operation. > -- > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ I haven't gone back through this complicated thread so I apologize if this has already been mentioned. I only found a registry based way for vista and win7. http://www.techspot.com/guides/210-edit-windows-extended-context-menu/ http://www.winvistaclub.com/e11.html There is also the 'extended' menu by shift+right-click. Maybe the Edit option can show up there. Adam From rustompmody at gmail.com Sat Nov 26 12:11:38 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 26 Nov 2011 09:11:38 -0800 (PST) Subject: Return of an old friend References: Message-ID: On Nov 25, 7:19?am, Rick Johnson wrote: > Hello Fellow Pythonistas, > > I am very glad to be back after an unfortunate incident caused my > Google account to be deleted. Unfortunately for those of you that have > been following along and supporting my crusade to bring fairness and > humility to the python community, my old posts under "rantingrick" > have all been deleted from Google Groups. However, you can always > search the python-list archives if you need a jog down memory lane. > > Actually this accidental deletion may have been a good thing as i've > had some extra time to muse on the innards of Python4000. > > In any event, this announcement is intended to be a new call to arms > for my brothers and sisters who fight the good fight, and for those of > you who despise me , well, this might be a good time to add my new > moniker to your kill files. > > Thanks, and happy Thanksgiving everyone! Hi Rick! Glad to see you back! [Courts can be dull places without jesters ye-know!] From rustompmody at gmail.com Sat Nov 26 12:28:48 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 26 Nov 2011 09:28:48 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: Message-ID: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> On Nov 26, 6:40?pm, kj wrote: > it's an all-out disgrace. > > when is python going to get a decent module distribution system??? > > and don't tell me to do it myself: it's clear that the sorry > situation we have now is precisely that too many programmers without > the requisite expertise or policy-making authority have decided to > pitch in. ?This is something for GvR and his top Python core library > team to do, because the problems are as much policy and institutional > ones as they are technical (programming) ones. I second this. The only thing I disagree about is that GvR is 'top' enough to handle this. For example on my debian box my python system is a mishmash of debian- apt-packages, eggs, and hand-installed stuff. [I believe I tried something like pypi and did not succeed -- dont exactly remember] So for systems like mine python and apt need to talk courteously to each other -- not possible for the likes of u&me; hard even for the likes of GvR. Frankly, this is not great but could be much worse. Some years ago when I worked with Ruby on Rails the rails that came from debian was an travesty. After some suffering I gathered that the optimal diplomacy was: - ruby from apt - gem hand installed - rails from gem While Ive never seen anything as ridiculous as the debian-rails in the python world, its still always a hobson choice: use a deb package that will cleanly install, deinstall, upgrade etc but is out of date or use a fresh and shiny egg that messes up the system. Haskell's cabal/hackage system is just as much a mess http://www.reddit.com/r/haskell/comments/f3lh5/haskells_own_dll_hell/ In short the mess arises from this that each of these languages comes up with its own package management system, neglecting the fact that the language invariably exists in a larger ecosystem From rosuav at gmail.com Sat Nov 26 12:38:18 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 04:38:18 +1100 Subject: Return of an old friend In-Reply-To: References: Message-ID: On Sun, Nov 27, 2011 at 4:11 AM, rusi wrote: > Hi Rick! > Glad to see you back! > [Courts can be dull places without jesters ye-know!] So, what... you'd take someone to court for being funny? That sounds like the -other- Pythons. ChrisA From rantingrickjohnson at gmail.com Sat Nov 26 12:46:32 2011 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 26 Nov 2011 09:46:32 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> Message-ID: <4092a435-02fd-4705-80db-ec958a5fc968@r28g2000yqj.googlegroups.com> On Nov 26, 11:28?am, rusi wrote: > On Nov 26, 6:40?pm, kj wrote: > The only thing I disagree about is that GvR is 'top' enough to handle > this. For a concrete example of how uninterested Mr. Van Rossum has become, take a look at the gawd awful state of Tkinter and especially IDLE. Whist I applaud GvR's initial good will attempts when creating these modules, i am simultaneously ashamed of their current bit-rot states. From alec.taylor6 at gmail.com Sat Nov 26 13:46:52 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sun, 27 Nov 2011 05:46:52 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: Consider implementing OOP, reflection and implement in HLA or C =] On Mon, Nov 21, 2011 at 11:46 AM, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. > > Can anyone list a good introduction to the files found in the source > code? I have been poking around the source code for a little bit and > there is a lot there. So, I was hoping someone could point me to the > "good parts". I am also wondering whether some of the code was > generated because I see state transition tables, which I doubt someone > built by hand. > > Any help would be greatly appreciated. It will be cool to see how the > interpreter works internally. I am still wonder whether designing the > language (going on 4 months now) will be harder than implementing it. > > Thanks, > Travis Parks > -- > http://mail.python.org/mailman/listinfo/python-list From rantingrickjohnson at gmail.com Sat Nov 26 13:53:15 2011 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 26 Nov 2011 10:53:15 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: On Nov 20, 6:46?pm, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, I hope you meant to say "*forced* indention for code blocks"! "Forced" being the key word here. What about tabs over spaces, have you decided the worth of one over the other or are you going to repeat Guido's folly? And please, i love Python, but the language is a bit asymmetrical. Do try to bring some symmetry to this new language. You can learn a lot from GvR's triumphs, however, you can learn even more from his follys. From rosuav at gmail.com Sat Nov 26 14:34:25 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 06:34:25 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: On Sun, Nov 27, 2011 at 5:53 AM, Rick Johnson wrote: > I hope you meant to say "*forced* indention for code blocks"! "Forced" > being the key word here. What about tabs over spaces, have you decided > the worth of one over the other or are you going to repeat Guido's > folly? I recommend demanding that indentation strictly alternate tabs or spaces in successive non-blank lines. Comment-only lines must be identical to the immediately-preceding line. A tab is equivalent to seven spaces. End the ambiguity! ChrisA From rantingrickjohnson at gmail.com Sat Nov 26 16:15:57 2011 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 26 Nov 2011 13:15:57 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <34d119af-3aa9-4720-944c-3852c720552a@4g2000yqu.googlegroups.com> On Nov 26, 1:34?pm, Chris Angelico wrote: > On Sun, Nov 27, 2011 at 5:53 AM, Rick Johnson > > wrote: > > I hope you meant to say "*forced* indention for code blocks"! "Forced" > > being the key word here. What about tabs over spaces, have you decided > > the worth of one over the other or are you going to repeat Guido's > > folly? > > I recommend demanding that indentation strictly alternate tabs or > spaces in successive non-blank lines. Funny. > Comment-only lines must be > identical to the immediately-preceding line. ...as in "indentation" you mean, then yes. OR suffer the syntax error. > A tab is equivalent to > seven spaces. ...as for "the litmus test of stdlib code" you mean, then yes. OR suffer the syntax error. From candide at free.invalid Sat Nov 26 16:20:36 2011 From: candide at free.invalid (candide) Date: Sat, 26 Nov 2011 22:20:36 +0100 Subject: Pragmatics of the standard is() function Message-ID: <4ed15825$0$21841$426a34cc@news.free.fr> In which cases should we use the is() function ? The is() function compares identity of objects rather than values so I was wondering in which circumstances comparing identities of objects is really vital. Examining well reputated Python source code, I realize that is() function is mainly used in the following set form : spam is None But how much "spam is None" is different from "spam == None" ? is() function makes comparaison of (abstract representation of) adresses of objects in memory. Comparing addresses of objects is a low level feature performed by low level langages such as C but seldom needed in high level languages like Python, isn'it ? From roy at panix.com Sat Nov 26 16:32:17 2011 From: roy at panix.com (Roy Smith) Date: Sat, 26 Nov 2011 16:32:17 -0500 Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: In article <4ed15825$0$21841$426a34cc at news.free.fr>, candide wrote: > In which cases should we use the is() function ? The is() function > compares identity of objects rather than values so I was wondering in > which circumstances comparing identities of objects is really vital. > > Examining well reputated Python source code, I realize that is() > function is mainly used in the following set form : > > spam is None > > But how much "spam is None" is different from "spam == None" ? It's the difference between *being* None, and being equal to None. For example: class Spam: def __eq__(self, other): return not other spam = Spam() print spam is None print spam == None When I run that, it prints: False True In practice, when you compare something to None, you usually want the "is" form. In cases where either would work (i.e. 99% of the time), it's convention (and/or good practice) to use "is" because it more more clearly expresses what it is that you're trying to do. From b49P23TIvg at stny.rr.com Sat Nov 26 16:42:00 2011 From: b49P23TIvg at stny.rr.com (Dave) Date: Sat, 26 Nov 2011 13:42:00 -0800 (PST) Subject: tkinter Message-ID: http://forums.devshed.com/python-programming-11/setting-tkinter-checkbox-default-graphical-state-865148.html Please answer this question I failed to resolve. Thanks, Dave. From rosuav at gmail.com Sat Nov 26 17:22:40 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 09:22:40 +1100 Subject: Pragmatics of the standard is() function In-Reply-To: <4ed15825$0$21841$426a34cc@news.free.fr> References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: On Sun, Nov 27, 2011 at 8:20 AM, candide wrote: > is() function makes comparaison of (abstract representation of) adresses of > objects in memory. Comparing addresses of objects is a low level feature > performed by low level langages such as C but seldom needed in high level > languages like Python, isn'it ? You also want 'is' when you're testing for a singleton used as a default value: DEFAULT = object() def foo(arg1,arg2,arg3=DEFAULT): if arg3 is DEFAULT: print("You gave me two args") ChrisA From alex.kapps at web.de Sat Nov 26 17:38:26 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Sat, 26 Nov 2011 23:38:26 +0100 Subject: Pragmatics of the standard is() function In-Reply-To: <4ed15825$0$21841$426a34cc@news.free.fr> References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: <4ED16A62.4050009@web.de> On 26.11.2011 22:20, candide wrote: You already got answers for the "is" vs. "==" difference. I'd like to add the following. > In which cases should we use the is() function ? "is" is not a function, It's an operator, just like == or +. > is() function makes comparaison of (abstract representation of) > adresses of objects in memory. That's an implementation detail. CPython (and maybe others) implement "is" in terms of memory addresses. Other implementations might use an object ID number or whatever else. From steve+comp.lang.python at pearwood.info Sat Nov 26 18:01:13 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Nov 2011 23:01:13 GMT Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sat, 26 Nov 2011 22:20:36 +0100, candide wrote: > In which cases should we use the is() function ? The is() function > compares identity of objects rather than values so I was wondering in > which circumstances comparing identities of objects is really vital. `is` is not a function. It is a keyword and an operator. You should always use `is` when you intend to test for object identity, and never use `is` when you do not intend to test for object identity. For example: TASK: check whether a number is equal to 42. # WRONG don't do this if x is 42: ... # RIGHT use equality instead if x == 42: ... Object identity is the wrong solution here, because you cannot control whether Python will re-use the same object for every instance of 42, or different objects each time. TASK: check whether an object is a specific sentinel value, and no other value, even if it happens to compare equal to the sentinel. The most common sentinel is the singleton None. # WRONG don't do this if x == None: ... # RIGHT use is instead if x is None: ... Use of equality is inappropriate, because it tests whether the object compares equal to None. Although there are no built-ins that compare equal to None, there could be any number of custom objects that do, and so your code contains a bug: you intend to branch *only* on None, but might branch on some other object by mistake. > Examining well reputated Python source code, I realize that is() > function is mainly used in the following set form : > > spam is None > > But how much "spam is None" is different from "spam == None" ? Even if you can guarantee that your code base does not contain any object which compares equal to None except for None itself (and how would you do that? a full audit of every line of code in every library you use?), the use of `is` should be preferred because it signals your intention much better. If your intention is to accept arbitrary objects which compare equal to None, than by all means use == for your comparison. But normally the intention is to accept None, and nothing else. > is() function makes comparaison of (abstract representation of) adresses > of objects in memory. Comparing addresses of objects is a low level > feature performed by low level langages such as C but seldom needed in > high level languages like Python, isn'it ? That is correct. You probably should rarely use `is`. Apart from testing for None, use of `is` should be rare. -- Steven From jason.swails at gmail.com Sat Nov 26 18:10:40 2011 From: jason.swails at gmail.com (Jason Swails) Date: Sat, 26 Nov 2011 18:10:40 -0500 Subject: tkinter In-Reply-To: References: Message-ID: The problem is that the logMode1 reference is _only_ bound to the name logMode1. Assigning it to "variable" in the Checkbutton instance (logCheck1) does not actually generate a reference to that variable inside logCheck1. Therefore, once the initialize method terminates, all references to logMode1 are destroyed and the variable is garbage-collected. Therefore, that variable will be None by default, regardless of what you do to it inside "initialize", which is why the button appears unchecked. If you create a reference to it, then the Checkbutton behaves as you'd expect (that is, it appears checked). You can verify this easily by just making logMode1 an attribute of simpleapp_tk (replace logMode1 with self.logMode1 in every case). You can also see this behavior by artificially lengthening the initialize method. Import the time module and run "time.sleep(5)" at the end of initialize, and you will see the check button remain checked for 5 seconds (while the reference logMode1 survives), before the check vanishes as sleep ends and the reference leaves scope. I would suggest that this is a checking feature rather than a bug. The variable that you set is useless unless you plan to use the value (or if there's a case where you may use it). If such a case exists, then you'll need a reference to that variable in the relevant scope you're dealing with. Hope this helps, Jason On Nov 26, 2011, at 4:42 PM, Dave wrote: > http://forums.devshed.com/python-programming-11/setting-tkinter-checkbox-default-graphical-state-865148.html > Please answer this question I failed to resolve. > Thanks, > Dave. > -- > http://mail.python.org/mailman/listinfo/python-list From dihedral88888 at googlemail.com Sat Nov 26 18:41:38 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 26 Nov 2011 15:41:38 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> Message-ID: <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > On Nov 14, 3:41?pm, Tracubik wrote: > > Hi all, > > i'm developing a new program. > > Mission: learn a bit of database management > > Idea: create a simple, 1 window program that show me a db of movies i've > > seen with few (<10) fields (actors, name, year etc) > > technologies i'll use: python + gtk > > db: that's the question > > > > since i'm mostly a new-bye for as regard databases, my idea is to use > > sqlite at the beginning. > > > > Is that ok? any other db to start with? (pls don't say mysql or similar, > > they are too complex and i'll use this in a second step) > > > > is there any general tutorial of how to start developing a database? i > > mean a general guide to databases you can suggest to me? > > Thank you all > > > > MedeoTL > > > > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > easily convert it in a sqlite db? (maybe via csv) > > To learn DBMS you need to learn sql > [Note sql is necessary but not sufficient for learning DBMS] > I recommend lightweight approaches to start with -- others have > mentioned access, libreoffice-base. > One more lightweight playpen is firefox plugin sqlite-manager > > > Is that ok? any other db to start with? (pls don't say mysql or similar, > > they are too complex and i'll use this in a second step) > > Correct. First you must figure out how to structure data -- jargon is > normalization. > After that you can look at transactions, ACID, distribution and all > the other good stuff. If I have a fast hash library that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? From candide at free.invalid Sat Nov 26 20:42:52 2011 From: candide at free.invalid (candide) Date: Sun, 27 Nov 2011 02:42:52 +0100 Subject: Pragmatics of the is operator In-Reply-To: <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed1959d$0$690$426a74cc@news.free.fr> Thanks to all for your response. Le 27/11/2011 00:01, Steven D'Aprano a ?crit : > On Sat, 26 Nov 2011 22:20:36 +0100, candide wrote: > >> In which cases should we use the is() function ? The is() function >> compares identity of objects rather than values so I was wondering in >> which circumstances comparing identities of objects is really vital. > > `is` is not a function. It is a keyword and an operator. oops exponent 10 !! I have in mind the id() function, very close to the is operator. An operator named "is" makes search of code snippets very complicated because the verb "is" is always embedded in comments or documentation. >> But how much "spam is None" is different from "spam == None" ? > > Even if you can guarantee that your code base does not contain any object > which compares equal to None except for None itself (and how would you do > that? a full audit of every line of code in every library you use?), the > use of `is` should be preferred because it signals your intention much > better. OK but tons of good code use "spam == None" ; for instance, many tests files in Python official code. A random example (from openshot/openshot/windows/MainGTK.py): # --------------------------------------------------------------- parent_name = item.parent if parent_name == None: match_iter = None # Check for NO files if mode == None and self.project.project_folder.items.__len__() == 0: #switch to the detail view if drop_track == None: # keep old parent, if no track found if self.new_clip_object == None: self.item_detected = False # --------------------------------------------------------------- > > If your intention is to accept arbitrary objects which compare equal to > None, than by all means use == for your comparison. But normally the > intention is to accept None, and nothing else. So, for the same reason, wouldn't it be better to use "if spam is True" against to "if spam == True" (or better "if spam") ? > That is correct. You probably should rarely use `is`. Apart from testing > for None, use of `is` should be rare. OK, thanks From rosuav at gmail.com Sat Nov 26 20:50:52 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 12:50:52 +1100 Subject: Pragmatics of the is operator In-Reply-To: <4ed1959d$0$690$426a74cc@news.free.fr> References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed1959d$0$690$426a74cc@news.free.fr> Message-ID: On Sun, Nov 27, 2011 at 12:42 PM, candide wrote: > So, for the same reason, wouldn't it be better to use "if spam is True" > against to "if spam == True" ?(or better "if spam") ? > They're quite different. "if spam" will check the truthiness of spam - it's equivalent to "if bool(spam) is True"; "if spam is True" checks that it's actually a boolean. But I would recommend against the "== True" form, as it's unclear which form you meant to use. (Others may disagree.) ChrisA From d at davea.name Sat Nov 26 21:20:01 2011 From: d at davea.name (Dave Angel) Date: Sat, 26 Nov 2011 21:20:01 -0500 Subject: How to keep Console area fixed for a thread In-Reply-To: References: <599CEBACD49B4144A61212D837EE3C0F144604D7B8@MX34A.corp.emc.com> Message-ID: <4ED19E51.5000302@davea.name> On 11/25/2011 01:00 PM, Nikunj Badjatya wrote: > Can anyone throw some light on this please ! ? > > > ( when you top-post, you confuse things. comp.lang.python follows the usual convention of putting new material after the parts you're quoting. Further, trying to embed images inside html messages will mess up all of us who use text readers to read a text forum. ) > On Thu, Nov 24, 2011 at 9:05 PM, wrote: > >> Hi All,**** >> >> ** ** >> >> Please look at the code below.**** >> >> I am using pypi progressbar. But in general, How can I keep the area of >> the console fixed for the thread to print its status on it.**** >> No idea what you're really asking. But I'll take a wild guess. Perhaps you're trying to divvy up a console box, and have different parts of it updated by different threads. In the general case, it can't be done. But if you are going to make it work, you'll need to restrict the environment some. Perhaps if you reword the question, with more information, someone can help. What operating system and what Python version will this have to run on? On Unix/Linux, you have curses that can be used at least to print without scrolling. On Windows, you may have something similar, by using ANSI sequences, but it's been so long since I tried that I have no idea. But if you just use print from different threads, the characters may be intermingled. -- DaveA From d at davea.name Sat Nov 26 21:35:29 2011 From: d at davea.name (Dave Angel) Date: Sat, 26 Nov 2011 21:35:29 -0500 Subject: my new project, is this the right way? In-Reply-To: <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: <4ED1A1F1.1080404@davea.name> On 11/26/2011 06:41 PM, 88888 Dihedral wrote: > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: >> On Nov 14, 3:41 pm, Tracubik wrote: >>> Hi all, >>> i'm developing a new program. >>> Mission: learn a bit of database management >>> Idea: create a simple, 1 window program that show me a db of movies i've >>> seen with few (<10) fields (actors, name, year etc) >>> technologies i'll use: python + gtk >>> db: that's the question >>> >>> since i'm mostly a new-bye for as regard databases, my idea is to use >>> sqlite at the beginning. >>> >>> Is that ok? any other db to start with? (pls don't say mysql or similar, >>> they are too complex and i'll use this in a second step) >>> >>> is there any general tutorial of how to start developing a database? i >>> mean a general guide to databases you can suggest to me? >>> Thank you all >>> >>> MedeoTL >>> >>> P.s. since i have a ods sheet files (libreoffice calc), is there a way to >>> easily convert it in a sqlite db? (maybe via csv) >> To learn DBMS you need to learn sql >> [Note sql is necessary but not sufficient for learning DBMS] >> I recommend lightweight approaches to start with -- others have >> mentioned access, libreoffice-base. >> One more lightweight playpen is firefox plugin sqlite-manager >> >>> Is that ok? any other db to start with? (pls don't say mysql or similar, >>> they are too complex and i'll use this in a second step) >> Correct. First you must figure out how to structure data -- jargon is >> normalization. >> After that you can look at transactions, ACID, distribution and all >> the other good stuff. > If I have a fast hash library that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > If you're using Python, you already have a "fast hash" library, in the dictionary class. And yes, if a problem doesn't need the full generality of a database, you may be able to implement it with dictionaries, and it may even be practical to store those dictionaries to disk for later retrieval. However, there are quite a few reasons this may not be good enough. To start with just two: if there are multiple users of the database, and they have to be synched. Or if you have to be safe from a program or a system crashing. -- DaveA From roy at panix.com Sat Nov 26 21:49:20 2011 From: roy at panix.com (Roy Smith) Date: Sat, 26 Nov 2011 21:49:20 -0500 Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: In article , Dave Angel wrote: > If you're using Python, you already have a "fast hash" library, in the > dictionary class. And yes, if a problem doesn't need the full > generality of a database, you may be able to implement it with > dictionaries, and it may even be practical to store those dictionaries > to disk for later retrieval. However, there are quite a few reasons > this may not be good enough. To start with just two: if there are > multiple users of the database, and they have to be synched. Or if you > have to be safe from a program or a system crashing. This is a good point. In general, databases differ from in-memory data structures in that they provide: 1) Persistence 2) Data integrity 3) Shared access Different kinds of databases provide different amounts and flavors of these (especially #2). I think it's fair to say, however, that those three in some form are essential for something that calls itself a database. Where thing get fun is when you start looking at the various things out there that call themselves databases and need to evaluate which ones give you the combination of these that best match your needs. From steve+comp.lang.python at pearwood.info Sat Nov 26 22:13:00 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Nov 2011 03:13:00 GMT Subject: Pragmatics of the is operator References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed1959d$0$690$426a74cc@news.free.fr> Message-ID: <4ed1aabc$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sun, 27 Nov 2011 02:42:52 +0100, candide wrote: >> Even if you can guarantee that your code base does not contain any >> object which compares equal to None except for None itself (and how >> would you do that? a full audit of every line of code in every library >> you use?), the use of `is` should be preferred because it signals your >> intention much better. > > OK but tons of good code use "spam == None" ; for instance, many tests > files in Python official code. A random example (from > openshot/openshot/windows/MainGTK.py): I don't know what openshot is, but I don't think it is "official" in the sense of being in the Python standard library: >>> import openshot Traceback (most recent call last): File "", line 1, in ImportError: No module named openshot But even if it were, the standard library is not written by superhuman perfect gods, only by ordinary human beings who can make mistakes. Comparing against None with == is not idiomatic Python, and is usually a mistake. It rarely leads to obvious bugs, so it can survive in code without notice for a long time. >> If your intention is to accept arbitrary objects which compare equal to >> None, than by all means use == for your comparison. But normally the >> intention is to accept None, and nothing else. > > > So, for the same reason, wouldn't it be better to use "if spam is True" > against to "if spam == True" (or better "if spam") ? No. Normally should just say "if spam" and allow Python to test the truthiness of spam. "if spam == True" is worse, because there are many truthy objects which are not equal to True, e.g. 42, "norwegian blue", [1, 2, 3] are all truthy objects that (almost always) should be accepted but will wrongly be rejected. "if spam is True" is even worse, because there are many truthy objects that are not the True singleton. Old code, especially if it was written before the introduction of bools in (I think) 2.1 or 2.2, often uses 1 as the standard true-like value. To save typing, many people will still pass 1 or 0 as an argument when a bool is expected, which will then fail if you test for identity. The exception is if for some reason you actually care whether your flag is the True object and absolutely nothing else. This violates Python's preference for duck-typing and support for truthiness, but if you have a good reason, go right ahead. Suppose spam is already a bool. Then "if spam" is enough, since spam is a bool. "if spam is True" is no more necessary than if spam is True is True if spam is True is True is True if spam is True is True is True is True if spam is True is True is True is True is True if spam is True is True is True is True is True is True # I never know when to stop... The right place to stop is not to start. "if spam is True" is redundant. And lastly, testing for identity against None is guaranteed by the language: any implementation of Python must have None a singleton. But True and False are not such a strong promise. A future version of Python, or another implementation, might not bother to make True and False singletons. (Doubletons?) Unlikely, but why make assumptions that you don't need to? -- Steven From dihedral88888 at googlemail.com Sat Nov 26 22:14:36 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 26 Nov 2011 19:14:36 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> On Sunday, November 27, 2011 10:49:20 AM UTC+8, Roy Smith wrote: > In article , > Dave Angel wrote: > > > If you're using Python, you already have a "fast hash" library, in the > > dictionary class. And yes, if a problem doesn't need the full > > generality of a database, you may be able to implement it with > > dictionaries, and it may even be practical to store those dictionaries > > to disk for later retrieval. However, there are quite a few reasons > > this may not be good enough. To start with just two: if there are > > multiple users of the database, and they have to be synched. Or if you > > have to be safe from a program or a system crashing. > > This is a good point. In general, databases differ from in-memory data > structures in that they provide: > > 1) Persistence > > 2) Data integrity > > 3) Shared access Shared in access in a local lan or a wide wan? In python there are packages can solve these easily. From rosuav at gmail.com Sat Nov 26 22:24:09 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 14:24:09 +1100 Subject: my new project, is this the right way? In-Reply-To: <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> Message-ID: On Sun, Nov 27, 2011 at 2:14 PM, 88888 Dihedral wrote: > Shared in access in a local lan or a wide wan? > That question isn't inherent to databasiness; it might not even be network-shared at all - in fact, most database-driven web sites have a database that's accessible only from localhost (which is where the web server runs). It's still shared access, and has all the same concerns. ChrisA From d at davea.name Sat Nov 26 22:27:38 2011 From: d at davea.name (Dave Angel) Date: Sat, 26 Nov 2011 22:27:38 -0500 Subject: my new project, is this the right way? In-Reply-To: <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> Message-ID: <4ED1AE2A.50709@davea.name> On 11/26/2011 10:14 PM, 88888 Dihedral wrote: > On Sunday, November 27, 2011 10:49:20 AM UTC+8, Roy Smith wrote: >> >> This is a good point. In general, databases differ from in-memory data >> structures in that they provide: >> >> 1) Persistence >> >> 2) Data integrity >> >> 3) Shared access > Shared in access in a local lan or a wide wan? > > In python there are packages can solve these easily. Right, and they are not in-memory databases. or to go back to the OP in this fork of the thread, they are not "fast hashes." -- DaveA From roy at panix.com Sat Nov 26 22:41:39 2011 From: roy at panix.com (Roy Smith) Date: Sat, 26 Nov 2011 22:41:39 -0500 Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> Message-ID: In article <26232548.146.1322363676465.JavaMail.geo-discussion-forums at pruu5>, 88888 Dihedral wrote: > > In general, databases differ from in-memory data > > structures in that they provide: > > > > 1) Persistence > > > > 2) Data integrity > > > > 3) Shared access > > Shared in access in a local lan or a wide wan? Well, like I said in my original post, "Different kinds of databases provide different amounts and flavors of these". Sharing across a network is one type of shared access, but there are lots of things that don't do network access that I would still consider databases. From anacrolix at gmail.com Sat Nov 26 23:03:26 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Sun, 27 Nov 2011 15:03:26 +1100 Subject: my new project, is this the right way? In-Reply-To: <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: Sounds like you want a key-value store. If it's a lot of data, you may still want a "database", I think it's just relational databases that you're trying to avoid? On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral wrote: > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: >> On Nov 14, 3:41?pm, Tracubik wrote: >> > Hi all, >> > i'm developing a new program. >> > Mission: learn a bit of database management >> > Idea: create a simple, 1 window program that show me a db of movies i've >> > seen with few (<10) fields (actors, name, year etc) >> > technologies i'll use: python + gtk >> > db: that's the question >> > >> > since i'm mostly a new-bye for as regard databases, my idea is to use >> > sqlite at the beginning. >> > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, >> > they are too complex and i'll use this in a second step) >> > >> > is there any general tutorial of how to start developing a database? i >> > mean a general guide to databases you can suggest to me? >> > Thank you all >> > >> > MedeoTL >> > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to >> > easily convert it in a sqlite db? (maybe via csv) >> >> To learn DBMS you need to learn sql >> [Note sql is necessary but not sufficient for learning DBMS] >> I recommend lightweight approaches to start with -- others have >> mentioned access, libreoffice-base. >> One more lightweight playpen is firefox plugin sqlite-manager >> >> > Is that ok? any other db to start with? (pls don't say mysql or similar, >> > they are too complex and i'll use this in a second step) >> >> Correct. First you must figure out how to structure data -- jargon is >> normalization. >> After that you can look at transactions, ACID, distribution and all >> the other good stuff. > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > -- > http://mail.python.org/mailman/listinfo/python-list > From dihedral88888 at googlemail.com Sun Nov 27 03:29:52 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 27 Nov 2011 00:29:52 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > Sounds like you want a key-value store. If it's a lot of data, you may > still want a "database", I think it's just relational databases that > you're trying to avoid? > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > wrote: > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > >> On Nov 14, 3:41?pm, Tracubik wrote: > >> > Hi all, > >> > i'm developing a new program. > >> > Mission: learn a bit of database management > >> > Idea: create a simple, 1 window program that show me a db of movies i've > >> > seen with few (<10) fields (actors, name, year etc) > >> > technologies i'll use: python + gtk > >> > db: that's the question > >> > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > >> > sqlite at the beginning. > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > > >> > is there any general tutorial of how to start developing a database? i > >> > mean a general guide to databases you can suggest to me? > >> > Thank you all > >> > > >> > MedeoTL > >> > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > >> > easily convert it in a sqlite db? (maybe via csv) > >> > >> To learn DBMS you need to learn sql > >> [Note sql is necessary but not sufficient for learning DBMS] > >> I recommend lightweight approaches to start with -- others have > >> mentioned access, libreoffice-base. > >> One more lightweight playpen is firefox plugin sqlite-manager > >> > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > >> Correct. First you must figure out how to structure data -- jargon is > >> normalization. > >> After that you can look at transactions, ACID, distribution and all > >> the other good stuff. > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. Each entry is just a type and value stored in a row of my database. I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. Can I do this in 1024 hashes in python ? From dihedral88888 at googlemail.com Sun Nov 27 03:29:52 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 27 Nov 2011 00:29:52 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > Sounds like you want a key-value store. If it's a lot of data, you may > still want a "database", I think it's just relational databases that > you're trying to avoid? > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > wrote: > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > >> On Nov 14, 3:41?pm, Tracubik wrote: > >> > Hi all, > >> > i'm developing a new program. > >> > Mission: learn a bit of database management > >> > Idea: create a simple, 1 window program that show me a db of movies i've > >> > seen with few (<10) fields (actors, name, year etc) > >> > technologies i'll use: python + gtk > >> > db: that's the question > >> > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > >> > sqlite at the beginning. > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > > >> > is there any general tutorial of how to start developing a database? i > >> > mean a general guide to databases you can suggest to me? > >> > Thank you all > >> > > >> > MedeoTL > >> > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > >> > easily convert it in a sqlite db? (maybe via csv) > >> > >> To learn DBMS you need to learn sql > >> [Note sql is necessary but not sufficient for learning DBMS] > >> I recommend lightweight approaches to start with -- others have > >> mentioned access, libreoffice-base. > >> One more lightweight playpen is firefox plugin sqlite-manager > >> > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > >> Correct. First you must figure out how to structure data -- jargon is > >> normalization. > >> After that you can look at transactions, ACID, distribution and all > >> the other good stuff. > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. Each entry is just a type and value stored in a row of my database. I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. Can I do this in 1024 hashes in python ? From dihedral88888 at googlemail.com Sun Nov 27 03:49:14 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 27 Nov 2011 00:49:14 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> Message-ID: <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> On Sunday, November 27, 2011 4:29:52 PM UTC+8, 88888 Dihedral wrote: > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > Sounds like you want a key-value store. If it's a lot of data, you may > > still want a "database", I think it's just relational databases that > > you're trying to avoid? > > > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > > wrote: > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > >> On Nov 14, 3:41?pm, Tracubik wrote: > > >> > Hi all, > > >> > i'm developing a new program. > > >> > Mission: learn a bit of database management > > >> > Idea: create a simple, 1 window program that show me a db of movies i've > > >> > seen with few (<10) fields (actors, name, year etc) > > >> > technologies i'll use: python + gtk > > >> > db: that's the question > > >> > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > >> > sqlite at the beginning. > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > > >> > is there any general tutorial of how to start developing a database? i > > >> > mean a general guide to databases you can suggest to me? > > >> > Thank you all > > >> > > > >> > MedeoTL > > >> > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > >> > easily convert it in a sqlite db? (maybe via csv) > > >> > > >> To learn DBMS you need to learn sql > > >> [Note sql is necessary but not sufficient for learning DBMS] > > >> I recommend lightweight approaches to start with -- others have > > >> mentioned access, libreoffice-base. > > >> One more lightweight playpen is firefox plugin sqlite-manager > > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > >> Correct. First you must figure out how to structure data -- jargon is > > >> normalization. > > >> After that you can look at transactions, ACID, distribution and all > > >> the other good stuff. > > > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. > > Each entry is just a type and value stored in a row of my database. > I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. > > Can I do this in 1024 hashes in python ? Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. I'll reserve 24 entries per row for book keeping. Thus the record can have 1000 entries maximum first. The number of record can be very large. Each value will be a string with type 1 byte and the stored value 8 to 255 bytes represented as a string when fetching the value can be auto-transformed according to the type. The sort and search will be rewritten for the comparison operator. From dihedral88888 at googlemail.com Sun Nov 27 03:49:14 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 27 Nov 2011 00:49:14 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> Message-ID: <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> On Sunday, November 27, 2011 4:29:52 PM UTC+8, 88888 Dihedral wrote: > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > Sounds like you want a key-value store. If it's a lot of data, you may > > still want a "database", I think it's just relational databases that > > you're trying to avoid? > > > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > > wrote: > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > >> On Nov 14, 3:41?pm, Tracubik wrote: > > >> > Hi all, > > >> > i'm developing a new program. > > >> > Mission: learn a bit of database management > > >> > Idea: create a simple, 1 window program that show me a db of movies i've > > >> > seen with few (<10) fields (actors, name, year etc) > > >> > technologies i'll use: python + gtk > > >> > db: that's the question > > >> > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > >> > sqlite at the beginning. > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > > >> > is there any general tutorial of how to start developing a database? i > > >> > mean a general guide to databases you can suggest to me? > > >> > Thank you all > > >> > > > >> > MedeoTL > > >> > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > >> > easily convert it in a sqlite db? (maybe via csv) > > >> > > >> To learn DBMS you need to learn sql > > >> [Note sql is necessary but not sufficient for learning DBMS] > > >> I recommend lightweight approaches to start with -- others have > > >> mentioned access, libreoffice-base. > > >> One more lightweight playpen is firefox plugin sqlite-manager > > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > >> Correct. First you must figure out how to structure data -- jargon is > > >> normalization. > > >> After that you can look at transactions, ACID, distribution and all > > >> the other good stuff. > > > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. > > Each entry is just a type and value stored in a row of my database. > I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. > > Can I do this in 1024 hashes in python ? Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. I'll reserve 24 entries per row for book keeping. Thus the record can have 1000 entries maximum first. The number of record can be very large. Each value will be a string with type 1 byte and the stored value 8 to 255 bytes represented as a string when fetching the value can be auto-transformed according to the type. The sort and search will be rewritten for the comparison operator. From anacrolix at gmail.com Sun Nov 27 07:54:24 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Sun, 27 Nov 2011 23:54:24 +1100 Subject: sick of distribute, setup, and all the rest... In-Reply-To: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> Message-ID: Agreed. I recently gave Haskell a go, and it was remarkable how similar the package management is to Python's. How well does the new "packaging" (set for release in Python 3.3?) module deal with the problems? With a better package management system, the half of the standard library that nobody uses can be unceremoniously dumped, and their more recent upstream versions used correctly. Even distutils itself is "obsolete", the first recommendation people give is to replace it with distribute and/or pip. On Sun, Nov 27, 2011 at 4:28 AM, rusi wrote: > On Nov 26, 6:40?pm, kj wrote: >> it's an all-out disgrace. >> >> when is python going to get a decent module distribution system??? >> >> and don't tell me to do it myself: it's clear that the sorry >> situation we have now is precisely that too many programmers without >> the requisite expertise or policy-making authority have decided to >> pitch in. ?This is something for GvR and his top Python core library >> team to do, because the problems are as much policy and institutional >> ones as they are technical (programming) ones. > > I second this. > > The only thing I disagree about is that GvR is 'top' enough to handle > this. > For example on my debian box my python system is a mishmash of debian- > apt-packages, > eggs, and hand-installed stuff. ?[I believe I tried something like > pypi and did not succeed -- dont exactly remember] > So for systems like mine python and apt need to talk courteously to > each other -- not possible for the likes of u&me; hard even for the > likes of GvR. > > Frankly, this is not great but could be much worse. ?Some years ago > when I worked with Ruby on Rails the rails that came from debian was > an travesty. ?After some suffering I gathered that the optimal > diplomacy was: > - ruby from apt > - gem hand installed > - rails from gem > > While Ive never seen anything as ridiculous as the debian-rails in the > python world, its still always a hobson choice: ?use a deb package > that will cleanly install, deinstall, upgrade etc but is out of date > or use a fresh and shiny egg that messes up the system. > > Haskell's cabal/hackage system is just as much a mess > http://www.reddit.com/r/haskell/comments/f3lh5/haskells_own_dll_hell/ > > In short the mess arises from this that each of these languages comes > up with its own package management system, neglecting the fact that > the language invariably exists in a larger ecosystem > -- > http://mail.python.org/mailman/listinfo/python-list > From anacrolix at gmail.com Sun Nov 27 08:04:01 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Mon, 28 Nov 2011 00:04:01 +1100 Subject: Return of an old friend In-Reply-To: References: Message-ID: On Sun, Nov 27, 2011 at 4:38 AM, Chris Angelico wrote: > On Sun, Nov 27, 2011 at 4:11 AM, rusi wrote: >> Hi Rick! >> Glad to see you back! >> [Courts can be dull places without jesters ye-know!] > > So, what... you'd take someone to court for being funny? That sounds > like the -other- Pythons. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > Burn!! :D From irmen.NOSPAM at xs4all.nl Sun Nov 27 09:33:22 2011 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Sun, 27 Nov 2011 15:33:22 +0100 Subject: why is bytearray treated so inefficiently by pickle? Message-ID: <4ed24a33$0$6869$e4fe514c@news2.news.xs4all.nl> Hi, A bytearray is pickled (using max protocol) as follows: >>> pickletools.dis(pickle.dumps(bytearray([255]*10),2)) 0: \x80 PROTO 2 2: c GLOBAL '__builtin__ bytearray' 25: q BINPUT 0 27: X BINUNICODE u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' 52: q BINPUT 1 54: U SHORT_BINSTRING 'latin-1' 63: q BINPUT 2 65: \x86 TUPLE2 66: q BINPUT 3 68: R REDUCE 69: q BINPUT 4 71: . STOP >>> bytearray("\xff"*10).__reduce__() (, (u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff', 'latin-1'), None) Is there a particular reason it is encoded so inefficiently? Most notably, the actual *bytes* in the bytearray are represented by an UTF-8 string. This needs to be transformed into a unicode string and then encoded back into bytes, when unpickled. The thing being a bytearray, I would expect it to be pickled as such: a sequence of bytes. And then possibly converted back to bytearray using the constructor that takes the bytes directly (BINSTRING/BINBYTES pickle opcodes). The above occurs both on Python 2.x and 3.x. Any ideas? Candidate for a patch? Irmen. From delmarmcbride at gmail.com Sun Nov 27 09:57:10 2011 From: delmarmcbride at gmail.com (Horace Quinn) Date: Sun, 27 Nov 2011 06:57:10 -0800 (PST) Subject: Buy Google AdWords Vouchers & Coupons Message-ID: <8e9c5394-68c9-449e-bbf5-4fdcfd5b3d39@f30g2000pri.googlegroups.com> Hi Friends, Do You Need Google AdWords Vouchers. You Can Get All Coupons Of $100, $75, $50 Credit. Just Visit http://buyadwordsvoucher.tk/ To Get Them. You Will Receive Coupon With In 12 Hrs 100%. Thankyou & Good Luck In Google AdWords. adwords voucher, adwords coupon, buy adwords voucher, buy adwords coupon, adwords credit, adwords Gutschein, adwords buono, adwords kupon From delmarmcbride at gmail.com Sun Nov 27 09:59:02 2011 From: delmarmcbride at gmail.com (Horace Quinn) Date: Sun, 27 Nov 2011 06:59:02 -0800 (PST) Subject: Buy Google AdWords Vouchers & Coupons Message-ID: <158025fc-151e-456f-81e8-abcdcf8c8210@s17g2000pra.googlegroups.com> Hi Friends, Do You Need Google AdWords Vouchers. You Can Get All Coupons Of $100, $75, $50 Credit. Just Visit http://buyadwordsvoucher.tk/ To Get Them. You Will Receive Coupon With In 12 Hrs 100%. Thankyou & Good Luck In Google AdWords. adwords voucher, adwords coupon, buy adwords voucher, buy adwords coupon, adwords credit, adwords Gutschein, adwords buono, adwords kupon From delmarmcbride at gmail.com Sun Nov 27 09:59:29 2011 From: delmarmcbride at gmail.com (Horace Quinn) Date: Sun, 27 Nov 2011 06:59:29 -0800 (PST) Subject: hii Message-ID: <2d643f3a-ee29-4ced-9471-7d44b101ef35@n22g2000prh.googlegroups.com> okk From stef.mientki at gmail.com Sun Nov 27 11:46:26 2011 From: stef.mientki at gmail.com (Stef Mientki) Date: Sun, 27 Nov 2011 17:46:26 +0100 Subject: [ANN] Android Debug Bridge (ADB) Scripting Language For Android (SL4A) convenience library Message-ID: <4ED26962.8070901@gmail.com> hello, The information on ADB / SL4A is quiet overwhelming. Despite that, especially for people, not familiar with Linux, it's not an easy task to get their first program running. This library allows you to easy upload and run Python files on a Android device, without pressing any button on the Android device. After installing SL4A and Py4A on the Android device, and ADB on the hostmachine, it's just a matter of connecting the USB cable between Android device and host-PC, and run the program. One of the simplest program that will run out of the box (without touching any button on the Android device) : # ***************************************************** from adb_sl4a_support import ADB_Connection ADB = ADB_Connection () print ADB # Create a simple program Simple_Program = """ import android droid = android.Android (( '%s', %s )) droid.makeToast ( "Wasn't that easy?") """ % ( ADB.SL4A_Servers [-1][0], ADB.SL4A_Servers [-1][1] ) # execute the program (this will run the program from the host PC !!) exec ( Simple_Program ) # ***************************************************** you can find the library here: http://code.google.com/p/pylab-works/downloads/detail?name=adb_sl4a_support.py&can=2&q= cheers, Stef From invalid at invalid.invalid Sun Nov 27 12:19:27 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 27 Nov 2011 17:19:27 +0000 (UTC) Subject: suitability of python References: <1322137895.4211.3.camel@roddur> Message-ID: On 2011-11-24, Rudra Banerjee wrote: > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? You'll have to tell us what "these type of heavy computation" are before we can answer. There are a _lot_ of heavy-duty computational libraries (many of them written in FORTAN) that have been interfaced to Python (BLAS and so on). If the heavy lifting can be done by those libraries, Python might be very suitable. You might want to check out scipy, Scientific Python, and the Enthought python distro. http://www.scipy.org/ http://dirac.cnrs-orleans.fr/plone/software/scientificpython/overview/ http://www.enthought.com/products/epd.php From stefan_ml at behnel.de Sun Nov 27 12:54:47 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 27 Nov 2011 17:54:47 +0000 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: Rudra Banerjee, 24.11.2011 12:31: > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? You already got a lot of answers that pointed you to the scientific computing tools that are available for Python. The reason why they exist is because (and nowadays also "why") Python is so extremely popular in that field: it's an easy to learn and use language and the standard implementation (often referred to as CPython) makes it really easy to interface with external code (C/C++/Fortran/etc.) in a very efficient way. In addition to looking at NumPy/SciPy and/or Sage (depending on the kind of computations you are involved with), you should also look at fwrap and Cython. They will allow you to easily wrap your existing Fortran code for Python, and to quickly write very fast glue code for the two language environments. Thus, you can keep your existing code as it is, and use and control it from Python, using all the nice tools that Python provides for quickly writing anything from distributed code and test suites to graphical user interfaces for visualising your data. Since you specifically asked about plotting, don't miss out on matplotlib. Stefan From gelonida at gmail.com Sun Nov 27 13:57:29 2011 From: gelonida at gmail.com (Gelonida N) Date: Sun, 27 Nov 2011 19:57:29 +0100 Subject: lxml precaching DTD for document verification. Message-ID: Hi, I'd like to verify some (x)html / / html5 / xml documents from a server. These documents have a very limited number of different doc types / DTDs. So what I would like to do is to build a small DTD cache and some code, that would avoid searching the DTDs over and over from the net. What would be the best way to do this? I guess, that the fields od en ElementTre, that I have to look at are docinfo.public_id docinfo.system_uri There's also mentioning af a catalogue, but I don't know how to use a catalog and how to know what is inside my catalogue and what isn't. Below a non working skeleto (first shot): --------------------------------------------- Would this be the right way?? ### ufnctions with '???' are not implemented / are the ones ### where I don't know whether they exist alreday. import os import urllib from lxml import etree cache_dir = os.path.join(os.environ['HOME'], ''.my_dtd_cache') def get_from_cache(docinfo): """ the function which I'd like to implement most efficiently """ fpi = docinfo.public_id uri = docinfo.system_uri dtd = ???get_from_dtd_cache(fpi, uri) if dtd is not None: return dtd # how can I check what is in my 'catalogue' if ???dtd_in_catalogue(??): return ???get_dtd_from_catalogue??? dtd_rdr = urllib.urlopen(uri) dtd_filename = ???create_cache_filename(docinfo) (fname, _headers) = urllib.urlretrieve(uri, dtd_filename) return etree.DTD(fname) def check_doc_cached(filename): """ function, which should report errors if a doc doesn't validate. """ doc = etree.parse(filename) dtd = get_from_cache(doc.docinfo) rslt = dtd.validate(doc) if not rlst: print "validate error:" print(dtd.error_log.filter_from_errors()[0]) From roy at panix.com Sun Nov 27 15:29:13 2011 From: roy at panix.com (Roy Smith) Date: Sun, 27 Nov 2011 15:29:13 -0500 Subject: lxml precaching DTD for document verification. References: Message-ID: In article , Gelonida N wrote: > I'd like to verify some (x)html / / html5 / xml documents from a server. I'm sure you could roll your own validator with lxml and some DTDs, but you would probably save yourself a huge amount of effort by just using the validator the W3C provides (http://validator.w3.org/). From gordon at panix.com Sun Nov 27 16:33:44 2011 From: gordon at panix.com (John Gordon) Date: Sun, 27 Nov 2011 21:33:44 +0000 (UTC) Subject: lxml precaching DTD for document verification. References: Message-ID: In Roy Smith writes: > In article , > Gelonida N wrote: > > > I'd like to verify some (x)html / / html5 / xml documents from a server. > I'm sure you could roll your own validator with lxml and some DTDs, but > you would probably save yourself a huge amount of effort by just using > the validator the W3C provides (http://validator.w3.org/). With regards to XML, he may mean that he wants to validate that the document conforms to a specific format, not just that it is generally valid XML. I don't think the w3 validator will do that. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From cs at zip.com.au Sun Nov 27 16:46:13 2011 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 28 Nov 2011 08:46:13 +1100 Subject: sick of distribute, setup, and all the rest... In-Reply-To: References: Message-ID: <20111127214613.GA11514@cskk.homeip.net> On 27Nov2011 23:54, Matt Joiner wrote: | Agreed. I recently gave Haskell a go, and it was remarkable how | similar the package management is to Python's. | | How well does the new "packaging" (set for release in Python 3.3?) | module deal with the problems? | | With a better package management system, the half of the standard | library that nobody uses can be unceremoniously dumped, and their more | recent upstream versions used correctly. Even distutils itself is | "obsolete", the first recommendation people give is to replace it with | distribute and/or pip. Ah the cheery optimism of the end user. Package systems have a lot of fun complications. Install for the user only? For the whole system? Architecture specific? What if people want access to different versions of a package? What about vendor supplied (eg RPM) versus user obtained? They'll fight, one way or another. What if policy has user supplied installing to its own tree (sensible to avoid conflicts) - the fetch/install kit need to know this. What about stability? Your "half of the standard library that nobody uses can be unceremoniously dumped, and their more recent upstream versions used correctly" leads to bugs in the apps that use the packages if they depend on particular versions/APIs. The stdlib is generally quite careful about breaking APIs but other packagers often are less so. I can make this list bigger or more detailed if you want. All package systems have these issues. They're not as trivial as you might imagine. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The problem with elections is that the government always wins. - Chris Rudram From jehugaleahsa at gmail.com Sun Nov 27 17:21:01 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sun, 27 Nov 2011 14:21:01 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> On Nov 26, 1:53?pm, Rick Johnson wrote: > On Nov 20, 6:46?pm, Travis Parks wrote: > > > Hello: > > > I am currently working on designing a new programming language. It is > > a compiled language, but I still want to use Python as a reference. > > Python has a lot of similarities to my language, such as indentation > > for code blocks, > > I hope you meant to say "*forced* indention for code blocks"! "Forced" > being the key word here. What about tabs over spaces, have you decided > the worth of one over the other or are you going to repeat Guido's > folly? > > And please, i love Python, but the language is a bit asymmetrical. Do > try to bring some symmetry to this new language. You can learn a lot > from GvR's triumphs, however, you can learn even more from his follys. Personally, I find a lot of good things in Python. I thinking tabs are out-of-date. Even the MAKE community wishes that the need for tabs would go away and many implementations have done just that. I have been seriously debating about whether to force a specific number of spaces, such as the classic 4, but I am not sure yet. Some times, 2 or even 8 spaces is appropriate (although I'm not sure when). I have always found the standard library for Python to be disjoint. That can be really beneficial where it keeps the learning curve down and the size of the standard modules down. At the same time, it means re-learning whenever you use a new module. My language combines generators and collection initializers, instead of creating a whole new syntax for comprehensions. [| for i in 0..10: for j in 0.10: yield return i * j |] Lambdas and functions are the same thing in my language, so no need for a special keyword. I also distinguish between initialization and assignment via the let keyword. Also, non-locals do not need to be defined explicitly, since the scoping rules in Unit are far more "anal". In reality though, it takes a certain level of arrogance to assume that any language will turn out without bumps. It is like I was told in college long ago, "Only the smallest programs are bug free." I think the same thing could be said for a language. The only language without flaws would be so small that it would be useless. I love these types of discussions though, because it helps me to be aware. When designing a language, it is extremely helpful to hear what language features have led to problems. For instance, C#'s foreach loops internally reuse a variable, which translates to something like this: using (IEnumerator enumerator = enumerable.GetEnumerator()) { T current; while (enumerator.MoveNext()) { current = enumerator.Current; // inner loop code goes here } } Since the same variable is reused, threads referencing the loop variable work against whatever value is currently in the variable, rather than the value when the thread was created. Most of the time, this means every thread works against the same value, which isn't the expected outcome. Moving the variable inside the loop _may_ help, but it would probably be optimized back out of the loop by the compiler. With the growth of threaded applications, these types of stack-based optimizations may come to an end. That is why it is important for a next-gen language to have a smarter stack - one that is context sensitive. In Unit, the stack grows and shrinks like a dynamic array, at each scope, rather than at the beginning and end of each function. Sure, there's a slight cost in performance, but a boost in consistency. If a programmer really wants the performance, they can move the variable out of the loop themselves. In fact, there are a lot of features in Unit that will come with overhead, such as default arguments, non-locals, function-objects, etc. However, the game plan is to avoid the overhead if it isn't used. Some things, such as exception handling, will be hard to provide without overhead. My belief is that, provided a tool, most developers will use it and accept the slight runtime overhead. I think everyone has an idea about what would make for the perfect language. I am always willing to entertain ideas. I have pulled from many sources: C#, Java, Python, JavaScript, F#, Lisp and more. The hope is to provide as much expression with as much consistency as possible. Just the other day I spent 2 hours trying to determine how to create a null pointer (yeah, it took that long). let pi = null as shared * Integer32 # null is always a pointer Originally, I wanted 'as' to be a safe conversion. However, I decided to make use of the 'try' keyword to mean a safe conversion. let nd = try base as shared * Derived let d = if nd.Succeeded: nd.Value else: null # or, shorthand let i = try Integer32.Parse("123") else 0 Of course, the last line could cost performance wise. For that reason, Unit will allow for "try" versions of methods. let Parse = public static method (value: String) throws(FormatException UnderflowException OverflowException) returns(Integer32): ... and Parse = public static try method (value: String) returns(TryResult): ... Of course, such methods are required to never throw and must return a specific named tuple type. Type, type, type. In short, I can only hope my language is useful and that I dodge as many inconsistencies as possible. The good thing about an unknown language is that no one gets mad when things change. In that sense, Python's annoyances are probably an indication of its quality. :-) From colinh at somewhere.invalid Sun Nov 27 18:02:37 2011 From: colinh at somewhere.invalid (Colin Higwell) Date: Sun, 27 Nov 2011 23:02:37 +0000 (UTC) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> Message-ID: On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > On Nov 26, 1:53?pm, Rick Johnson wrote: >> On Nov 20, 6:46?pm, Travis Parks wrote: >> >> > Hello: >> >> > I am currently working on designing a new programming language. It is >> > a compiled language, but I still want to use Python as a reference. >> > Python has a lot of similarities to my language, such as indentation >> > for code blocks, >> >> I hope you meant to say "*forced* indention for code blocks"! "Forced" >> being the key word here. What about tabs over spaces, have you decided >> the worth of one over the other or are you going to repeat Guido's >> folly? >> >> And please, i love Python, but the language is a bit asymmetrical. Do >> try to bring some symmetry to this new language. You can learn a lot >> from GvR's triumphs, however, you can learn even more from his follys. > > Personally, I find a lot of good things in Python. I thinking tabs are > out-of-date. Even the MAKE community wishes that the need for tabs would > go away and many implementations have done just that. I have been > seriously debating about whether to force a specific number of spaces, > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > spaces is appropriate (although I'm not sure when). > > I have always found the standard library for Python to be disjoint. That > can be really beneficial where it keeps the learning curve down and the > size of the standard modules down. At the same time, it means > re-learning whenever you use a new module. > > My language combines generators and collection initializers, instead of > creating a whole new syntax for comprehensions. > > [| for i in 0..10: for j in 0.10: yield return i * j |] > > Lambdas and functions are the same thing in my language, so no need for > a special keyword. I also distinguish between initialization and > assignment via the let keyword. Also, non-locals do not need to be > defined explicitly, since the scoping rules in Unit are far more "anal". > > In reality though, it takes a certain level of arrogance to assume that > any language will turn out without bumps. It is like I was told in > college long ago, "Only the smallest programs are bug free." I think the > same thing could be said for a language. The only language without flaws > would be so small that it would be useless. > > I love these types of discussions though, because it helps me to be > aware. When designing a language, it is extremely helpful to hear what > language features have led to problems. For instance, C#'s foreach loops > internally reuse a variable, which translates to something like this: > > using (IEnumerator enumerator = enumerable.GetEnumerator()) > { > T current; > while (enumerator.MoveNext()) > { > current = enumerator.Current; > // inner loop code goes here > } > } > > Since the same variable is reused, threads referencing the loop variable > work against whatever value is currently in the variable, rather than > the value when the thread was created. Most of the time, this means > every thread works against the same value, which isn't the expected > outcome. Moving the variable inside the loop _may_ help, but it would > probably be optimized back out of the loop by the compiler. With the > growth of threaded applications, these types of stack-based > optimizations may come to an end. That is why it is important for a > next-gen language to have a smarter stack - one that is context > sensitive. In Unit, the stack grows and shrinks like a dynamic array, at > each scope, rather than at the beginning and end of each function. Sure, > there's a slight cost in performance, but a boost in consistency. If a > programmer really wants the performance, they can move the variable out > of the loop themselves. > > In fact, there are a lot of features in Unit that will come with > overhead, such as default arguments, non-locals, function-objects, etc. > However, the game plan is to avoid the overhead if it isn't used. Some > things, such as exception handling, will be hard to provide without > overhead. My belief is that, provided a tool, most developers will use > it and accept the slight runtime overhead. > > I think everyone has an idea about what would make for the perfect > language. I am always willing to entertain ideas. I have pulled from > many sources: C#, Java, Python, JavaScript, F#, Lisp and more. The hope > is to provide as much expression with as much consistency as possible. > Just the other day I spent 2 hours trying to determine how to create a > null pointer (yeah, it took that long). > > let pi = null as shared * Integer32 # null is always a pointer > > Originally, I wanted 'as' to be a safe conversion. However, I decided to > make use of the 'try' keyword to mean a safe conversion. > > let nd = try base as shared * Derived let d = if nd.Succeeded: nd.Value > else: null # or, shorthand let i = try Integer32.Parse("123") else 0 > > Of course, the last line could cost performance wise. For that reason, > Unit will allow for "try" versions of methods. > > let Parse = public static method (value: String) throws(FormatException > UnderflowException OverflowException) returns(Integer32): ... > and Parse = public static try method (value: String) > returns(TryResult): ... > > Of course, such methods are required to never throw and must return a > specific named tuple type. > > Type, type, type. In short, I can only hope my language is useful and > that I dodge as many inconsistencies as possible. The good thing about > an unknown language is that no one gets mad when things change. In that > sense, Python's annoyances are probably an indication of its quality. > :-) Most of this is way above my head but FWIW, I am very happy with four spaces for indentation. I forget now what I used in BASIC and COBOL, but I have always used four spaces in PL/SQL, PL/pgSQL, PL/Tcl, c, ksh, bash and Python. From steve+comp.lang.python at pearwood.info Sun Nov 27 18:55:09 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Nov 2011 23:55:09 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> Message-ID: <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > Personally, I find a lot of good things in Python. I thinking tabs are > out-of-date. Even the MAKE community wishes that the need for tabs would > go away and many implementations have done just that. Tabs have every theoretical advantage and only one practical disadvantage: the common toolsets used by Unix programmers are crap in their handling of tabs, and instead of fixing the toolsets, they blame the tabs. The use of spaces as indentation is a clear case of a technically worse solution winning over a better solution. > I have been > seriously debating about whether to force a specific number of spaces, > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > spaces is appropriate (although I'm not sure when). Why on earth should your language dictate the width of an indentation? I can understand that you might care that indents are consistent within a single source code unit (a file?), but anything more than that is just obnoxious. > I have always found the standard library for Python to be disjoint. That > can be really beneficial where it keeps the learning curve down and the > size of the standard modules down. At the same time, it means > re-learning whenever you use a new module. I know what disjoint means, but I don't understand what you think it means for a software library to be disjoint. I don't understand the rest of the paragraph. > My language combines generators and collection initializers, instead of > creating a whole new syntax for comprehensions. > > [| for i in 0..10: for j in 0.10: yield return i * j |] Are we supposed to intuit what that means? Is | a token, or are the delimiters [| and |] ? Is there a difference between iterating over 0..10 and iterating over what looks like a float 0.10? What is "yield return"? > Lambdas and functions are the same thing in my language, so no need for > a special keyword. That does not follow. Lambdas and def functions are the same thing in Python, but Python requires a special keyword. > I also distinguish between initialization and > assignment via the let keyword. What does this mean? I can guess, but I might guess wrong. > Also, non-locals do not need to be > defined explicitly, since the scoping rules in Unit are far more "anal". What does this mean? I can't even guess what you consider more anal scoping rules. > In reality though, it takes a certain level of arrogance to assume that > any language will turn out without bumps. It is like I was told in > college long ago, "Only the smallest programs are bug free." I think the > same thing could be said for a language. The only language without flaws > would be so small that it would be useless. I'm pretty sure that being so small that it is useless would count as a flaw. What does it mean to say that a language is "small"? A Turing Machine is a pretty small language, with only a few instructions: step forward, step backwards, erase a cell, write a cell, branch on the state of the cell. And yet anything that can be computed, anything at all, can be computed by a Turning Machine: a Turing Machine can do anything you can do in C, Lisp, Fortran, Python, Java... and very probably anything you can (mentally) do, full stop. So what does that mean about "small" languages? On the other hand, take Epigram, a functional programming language: http://en.wikipedia.org/wiki/Epigram_(programming_language) It is *less* powerful than a Turing Machine, despite being far more complex. Similarly languages like regular expressions, finite automata and context-free grammers are more complex, "bigger", possibly with dozens or hundreds of instructions, and yet less powerful. Likewise for spreadsheets without cycles. Forth is much smaller than Java, but I would say that Forth is much, much more powerful in some sense than Java. You could write a Java compiler in Forth more easily than you could write a Forth compiler in Java. -- Steven From rosuav at gmail.com Sun Nov 27 19:26:17 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 28 Nov 2011 11:26:17 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Nov 28, 2011 at 10:55 AM, Steven D'Aprano wrote: > What does it mean to say that a language is "small"? > > A Turing Machine is a pretty small language, with only a few > instructions: step forward, step backwards, erase a cell, write a cell, > branch on the state of the cell. And yet anything that can be computed, > anything at all, can be computed by a Turning Machine... Ook has only three tokens (okay, it's a derivative of BrainF** so it kinda has eight, but they're implemented on three). It's Turing-complete, but it is so small as to be useless for any practical purposes. The ONLY way to use Ook for any useful code would be to write an interpreter for another language in it, and use that other language. However, Ook can be proven to be flawless, as can an Ook interpreter, much more easily than a full-featured language like Python or C. ChrisA From gelonida at gmail.com Sun Nov 27 19:32:33 2011 From: gelonida at gmail.com (Gelonida N) Date: Mon, 28 Nov 2011 01:32:33 +0100 Subject: lxml precaching DTD for document verification. In-Reply-To: References: Message-ID: On 11/27/2011 10:33 PM, John Gordon wrote: > In Roy Smith writes: > >> In article , >> Gelonida N wrote: >> >>> I'd like to verify some (x)html / / html5 / xml documents from a server. > >> I'm sure you could roll your own validator with lxml and some DTDs, but >> you would probably save yourself a huge amount of effort by just using >> the validator the W3C provides (http://validator.w3.org/). This validator requires that I post the code to some host. The contents that I'd like to verify is intranet contents, which I am not allowed to post to an external site. > > With regards to XML, he may mean that he wants to validate that the > document conforms to a specific format, not just that it is generally > valid XML. I don't think the w3 validator will do that. > Basically I want to integrate this into a django unit test. I noticed, that some of of the templates generate documents with mismatching DTD headers / contents. All of the HTML code is parsable as xml (if it isn't it's a bug) There are also some custom XML files, which have their specific DTDs So I thought about validating some of the generated html with lxml. the django test environment allows to run test clients, which are supposedly much faster than a real http client. From devplayer at gmail.com Sun Nov 27 20:20:13 2011 From: devplayer at gmail.com (DevPlayer) Date: Sun, 27 Nov 2011 17:20:13 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: On Nov 15, 10:38?pm, goldtech wrote: > Hi, > > Using Windows. Is there a python shell that has a history of typed in > commands? > > I don't need output of commands just what I typed it. I need it to > save between sessions - something that no shell seems to do. If I > reboot there will still be a command history somewhere. > > Like bash history in Linux. > > Thanks Something that might be of interest is wxPython's pyslicesshell.py it's not commandline in console window but the interpreter in a window. And you can save it. I haven't used it lately by there's also PythonWin http://python.net/crew/skippy/win32/PythonwinPreview.html From tjreedy at udel.edu Sun Nov 27 21:09:47 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 27 Nov 2011 21:09:47 -0500 Subject: why is bytearray treated so inefficiently by pickle? In-Reply-To: <4ed24a33$0$6869$e4fe514c@news2.news.xs4all.nl> References: <4ed24a33$0$6869$e4fe514c@news2.news.xs4all.nl> Message-ID: On 11/27/2011 9:33 AM, Irmen de Jong wrote: > Hi, > > A bytearray is pickled (using max protocol) as follows: > >>>> pickletools.dis(pickle.dumps(bytearray([255]*10),2)) > 0: \x80 PROTO 2 > 2: c GLOBAL '__builtin__ bytearray' > 25: q BINPUT 0 > 27: X BINUNICODE u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' > 52: q BINPUT 1 > 54: U SHORT_BINSTRING 'latin-1' > 63: q BINPUT 2 > 65: \x86 TUPLE2 > 66: q BINPUT 3 > 68: R REDUCE > 69: q BINPUT 4 > 71: . STOP > >>>> bytearray("\xff"*10).__reduce__() > (, (u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff', 'latin-1'), None) > > > Is there a particular reason it is encoded so inefficiently? Most notably, the actual > *bytes* in the bytearray are represented by an UTF-8 string. This needs to be > transformed into a unicode string and then encoded back into bytes, when unpickled. The > thing being a bytearray, I would expect it to be pickled as such: a sequence of bytes. > And then possibly converted back to bytearray using the constructor that takes the bytes > directly (BINSTRING/BINBYTES pickle opcodes). > > The above occurs both on Python 2.x and 3.x. > > Any ideas? Candidate for a patch? Possibly. The two developers listed as particularly interested in pickle are 'alexandre.vassalotti,pitrou' (antoine), so if you do open a tracker issue, add them as nosy. Take a look at http://www.python.org/dev/peps/pep-3154/ by Antoine Pitrou or forwary your message to him. -- Terry Jan Reedy From fpm at u.washington.edu Sun Nov 27 23:16:43 2011 From: fpm at u.washington.edu (cassiope) Date: Sun, 27 Nov 2011 20:16:43 -0800 (PST) Subject: Proper way to delete/kill a logger? Message-ID: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> I've been trying to migrate some code to using the standard python logging classes/objects. And they seem quite capable of doing what I need them to do. Unfortunately there's a problem in my unit tests. It's fairly common to have to create quite a few entities in the course of a series of tests. What appears to be happening is that the loggers don't get entirely eliminated, so that new invocations end up spewing output messages from each of the loggers that were started with this invocation of the python interpreter. I haven't found a function within the logging module that completely kills a given instance. The removeHandler() function seems to leave a stdout/stderr output even if all the assigned handlers have been removed. I've tried a few workarounds, such as increasing the level to an absurdly large level, which mostly kinda works, and killing the old entity before creating the new test version. There is probably something simple that I'm missing. If you know what that is, please point me to that fine manual - I'd appreciate it. Thanks! -f From rustompmody at gmail.com Sun Nov 27 23:25:16 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 27 Nov 2011 20:25:16 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: Message-ID: <46c11371-411a-4ba0-89b9-967e2f83e942@k5g2000pre.googlegroups.com> On Nov 28, 2:46?am, Cameron Simpson wrote: > On 27Nov2011 23:54, Matt Joiner wrote: > | Agreed. I recently gave Haskell a go, and it was remarkable how > | similar the package management is to Python's. > | > | How well does the new "packaging" (set for release in Python 3.3?) > | module deal with the problems? > | > | With a better package management system, the half of the standard > | library that nobody uses can be unceremoniously dumped, and their more > | recent upstream versions used correctly. Even distutils itself is > | "obsolete", the first recommendation people give is to replace it with > | distribute and/or pip. > > Ah the cheery optimism of the end user. > Package systems have a lot of fun complications. > > Install for the user only? For the whole system? > Architecture specific? > What if people want access to different versions of a package? > What about vendor supplied (eg RPM) versus user obtained? They'll fight, > one way or another. What if policy has user supplied installing to its > own tree (sensible to avoid conflicts) - the fetch/install kit need to > know this. > What about stability? Your "half of the standard library that nobody uses can > be unceremoniously dumped, and their more recent upstream versions used > correctly" leads to bugs in the apps that use the packages if they depend on > particular versions/APIs. The stdlib is generally quite careful about > breaking APIs but other packagers often are less so. > > I can make this list bigger or more detailed if you want. ?All package > systems have these issues. They're not as trivial as you might imagine. Where is there any implication that there are not issues or that they are trivial? At the end of his life Dijkstra said: The single biggest problem in computer science is how not to make a mess of it; that problem remains unsolved. The OP simply expressed a wish for improvement and I seconded that [and pls ignore ranters with oedipal problems] >From my post from a few months http://mail.python.org/pipermail/python-list/2011-May/1271765.html If I may restate: Too much mindshare is devoted to all the linguistic features of python: garbage collection, identation, metaclasses and all that other good stuff from the 70s and too little to extra-linguistic ecosystem features below: If the linguistic features were all that mattered Lisp would be the king of languages today > > > | Area | Tool(s) | > > |------------------+------------------------| > > | packaging | distutils, setuptools, | > > | | distutils2, distribute | > > | | Native tools (eg apt) | > > | versioning | hg, git, bzr | > > | multiple pythons | virtualenv | > > | ?? | tox | > > | testing | unittest, nose, pytest | > > | build | scons, make... | > > | deployment | fabric | > From roy at panix.com Sun Nov 27 23:31:42 2011 From: roy at panix.com (Roy Smith) Date: Sun, 27 Nov 2011 23:31:42 -0500 Subject: sick of distribute, setup, and all the rest... References: <46c11371-411a-4ba0-89b9-967e2f83e942@k5g2000pre.googlegroups.com> Message-ID: In article <46c11371-411a-4ba0-89b9-967e2f83e942 at k5g2000pre.googlegroups.com>, rusi wrote: > If the linguistic features were all that mattered Lisp would be the > king of languages today (that (is (one (of (the (most (absurd (statements (I've (read (in (a (long (time)))))))))))))) From Shambhu.Rajak at kpitcummins.com Sun Nov 27 23:31:59 2011 From: Shambhu.Rajak at kpitcummins.com (Shambhu Rajak) Date: Mon, 28 Nov 2011 04:31:59 +0000 Subject: Automatic import of submodules In-Reply-To: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> References: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Message-ID: <408F64D89899604FB24015E64E10490C179CA4BA@KCHJEXMB02.kpit.com> -----Original Message----- From: Massi [mailto:massi_srb at msn.com] Sent: 25/11/2011 6:30 PM To: python-list at python.org Subject: Automatic import of submodules Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | -- __init__.py -- EtcPlug.py Every .py file contain a class definition whose name is identical to to the file name, so in my main script I have to import each submodule like that: from plugins.wav_plug.WavPlug import WavPlug from plugins.wav_plug.Mp3Plug import Mp3Plug and so on. This is uncomfortable, since when a new plugin is added I have to import it too. So my question is, is it possible to iterate through the 'plugins' directory tree in order to automatically import the submodules contained in each subdirectory? I googled and found that the pkgutil could help, but it is not clear how. Any hints? Thanks in advance. ===== What you could do is : Instead of importing method wise , import the module. from plugins.wav_plug import WavPlug you can then use like this then WavPlug.WavPlug This will avoid the-every time importing of each method Regards, Shambhu From wuwei23 at gmail.com Sun Nov 27 23:37:41 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 27 Nov 2011 20:37:41 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> Message-ID: <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> rusi wrote: > While Ive never seen anything as ridiculous as the debian-rails in the > python world, its still always a hobson choice: ?use a deb package > that will cleanly install, deinstall, upgrade etc but is out of date > or use a fresh and shiny egg that messes up the system. The only time I use the OS package manager to install a Python library is if some other application requires it as a dependency. If you're not making the distinction between your system install of Python and your development install, you're really inviting a whole world of pain and confusion on yourself. With that approach in mind, I've never had any real issues using pip, virtualenv etc for managing my development environment. From chris at simplistix.co.uk Mon Nov 28 02:13:15 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Mon, 28 Nov 2011 07:13:15 +0000 Subject: Proper way to delete/kill a logger? In-Reply-To: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> References: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> Message-ID: <4ED3348B.4020301@simplistix.co.uk> On 28/11/2011 04:16, cassiope wrote: > I've been trying to migrate some code to using the standard python > logging classes/objects. And they seem quite capable of doing what I > need them to do. Unfortunately there's a problem in my unit tests. > It's fairly common to have to create quite a few entities in the > course of a series of tests. What appears to be happening is that the > loggers don't get entirely eliminated, so that new invocations end up > spewing output messages from each of the loggers that were started > with this invocation of the python interpreter. Two suggestions: - unless you are specifically testing the logging set up of your application, your code under test shouldn't be setting up logging. - if you want to check that your code under test is emitting log messages correctly, use a LogCapture from testfixtures: http://packages.python.org/testfixtures. cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From rustompmody at gmail.com Mon Nov 28 02:18:15 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 27 Nov 2011 23:18:15 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> Message-ID: <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> On Nov 28, 9:37?am, alex23 wrote: > With that approach in mind, I've never had any real issues using pip, > virtualenv etc for managing my development environment. Yes that is in a way my point also: we discuss (things like) pip, virtualenv etc too little. Try working out the ratio of the number of helps/tutorials on functions/lists/types/classes to those on these extra-linguistic features needed for environment/build/deployment/versioning and you can see the skewness of focus From stefan_ml at behnel.de Mon Nov 28 02:38:12 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 28 Nov 2011 07:38:12 +0000 Subject: lxml precaching DTD for document verification. In-Reply-To: References: Message-ID: Gelonida N, 27.11.2011 18:57: > I'd like to verify some (x)html / / html5 / xml documents from a server. > > These documents have a very limited number of different doc types / DTDs. > > So what I would like to do is to build a small DTD cache and some code, > that would avoid searching the DTDs over and over from the net. > > What would be the best way to do this? Configure your XML catalogues. > I guess, that > the fields od en ElementTre, that I have to look at are > docinfo.public_id > docinfo.system_uri Yes, catalogue lookups generally happen through the public ID. > There's also mentioning af a catalogue, but I don't know how to > use a catalog and how to know what is inside my catalogue > and what isn't. Does this help? http://lxml.de/resolvers.html#xml-catalogs http://xmlsoft.org/catalog.html They should normally come pre-configured on Linux distributions, but you may have to install additional packages with the respective DTDs. Look for any packages with "dtd" and "html" in their name, for example. Stefan From dihedral88888 at googlemail.com Mon Nov 28 03:51:06 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 28 Nov 2011 00:51:06 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> Message-ID: <18928439.420.1322470266331.JavaMail.geo-discussion-forums@prnv8> On Sunday, November 27, 2011 4:49:14 PM UTC+8, 88888 Dihedral wrote: > On Sunday, November 27, 2011 4:29:52 PM UTC+8, 88888 Dihedral wrote: > > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > > Sounds like you want a key-value store. If it's a lot of data, you may > > > still want a "database", I think it's just relational databases that > > > you're trying to avoid? > > > > > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > > > wrote: > > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > > >> On Nov 14, 3:41?pm, Tracubik wrote: > > > >> > Hi all, > > > >> > i'm developing a new program. > > > >> > Mission: learn a bit of database management > > > >> > Idea: create a simple, 1 window program that show me a db of movies i've > > > >> > seen with few (<10) fields (actors, name, year etc) > > > >> > technologies i'll use: python + gtk > > > >> > db: that's the question > > > >> > > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > > >> > sqlite at the beginning. > > > >> > > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > > >> > they are too complex and i'll use this in a second step) > > > >> > > > > >> > is there any general tutorial of how to start developing a database? i > > > >> > mean a general guide to databases you can suggest to me? > > > >> > Thank you all > > > >> > > > > >> > MedeoTL > > > >> > > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > > >> > easily convert it in a sqlite db? (maybe via csv) > > > >> > > > >> To learn DBMS you need to learn sql > > > >> [Note sql is necessary but not sufficient for learning DBMS] > > > >> I recommend lightweight approaches to start with -- others have > > > >> mentioned access, libreoffice-base. > > > >> One more lightweight playpen is firefox plugin sqlite-manager > > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > > >> > they are too complex and i'll use this in a second step) > > > >> > > > >> Correct. First you must figure out how to structure data -- jargon is > > > >> normalization. > > > >> After that you can look at transactions, ACID, distribution and all > > > >> the other good stuff. > > > > > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. > > > > Each entry is just a type and value stored in a row of my database. > > I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. > > > > Can I do this in 1024 hashes in python ? > Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) > Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. For the same value stored , I need a column_no+next stored, a list. All relations can be derived. From dihedral88888 at googlemail.com Mon Nov 28 03:51:06 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 28 Nov 2011 00:51:06 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> Message-ID: <18928439.420.1322470266331.JavaMail.geo-discussion-forums@prnv8> On Sunday, November 27, 2011 4:49:14 PM UTC+8, 88888 Dihedral wrote: > On Sunday, November 27, 2011 4:29:52 PM UTC+8, 88888 Dihedral wrote: > > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > > Sounds like you want a key-value store. If it's a lot of data, you may > > > still want a "database", I think it's just relational databases that > > > you're trying to avoid? > > > > > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > > > wrote: > > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > > >> On Nov 14, 3:41?pm, Tracubik wrote: > > > >> > Hi all, > > > >> > i'm developing a new program. > > > >> > Mission: learn a bit of database management > > > >> > Idea: create a simple, 1 window program that show me a db of movies i've > > > >> > seen with few (<10) fields (actors, name, year etc) > > > >> > technologies i'll use: python + gtk > > > >> > db: that's the question > > > >> > > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > > >> > sqlite at the beginning. > > > >> > > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > > >> > they are too complex and i'll use this in a second step) > > > >> > > > > >> > is there any general tutorial of how to start developing a database? i > > > >> > mean a general guide to databases you can suggest to me? > > > >> > Thank you all > > > >> > > > > >> > MedeoTL > > > >> > > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > > >> > easily convert it in a sqlite db? (maybe via csv) > > > >> > > > >> To learn DBMS you need to learn sql > > > >> [Note sql is necessary but not sufficient for learning DBMS] > > > >> I recommend lightweight approaches to start with -- others have > > > >> mentioned access, libreoffice-base. > > > >> One more lightweight playpen is firefox plugin sqlite-manager > > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > > >> > they are too complex and i'll use this in a second step) > > > >> > > > >> Correct. First you must figure out how to structure data -- jargon is > > > >> normalization. > > > >> After that you can look at transactions, ACID, distribution and all > > > >> the other good stuff. > > > > > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. > > > > Each entry is just a type and value stored in a row of my database. > > I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. > > > > Can I do this in 1024 hashes in python ? > Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) > Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. For the same value stored , I need a column_no+next stored, a list. All relations can be derived. From ramapraba2653 at gmail.com Mon Nov 28 05:05:01 2011 From: ramapraba2653 at gmail.com (SUPREME) Date: Mon, 28 Nov 2011 02:05:01 -0800 (PST) Subject: XXX HOT PHOTOS&VIDEOS Message-ID: FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ URIMI LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/urimi-movie-stills.html NIPPU MOVIE WORKING STILLS http://actressgallery-kalyani.blogspot.com/2011/11/nippu-movie-stills.html SIMHAPUTHRUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/simhaputhrudu-movie-stills.html SOLO MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/solo-movie-stills.html BEZAWADA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/bezawada-movie-stills.html RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS SARAH JANE DIAS HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/sarah-jane-dias-hot.html KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html POONAM KAUR HOT ROMANTIC STILLS http://hotactress-kalyani.blogspot.com/2011/11/poonam-kaur-hot.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From gelonida at gmail.com Mon Nov 28 05:15:58 2011 From: gelonida at gmail.com (Gelonida N) Date: Mon, 28 Nov 2011 11:15:58 +0100 Subject: lxml precaching DTD for document verification. In-Reply-To: References: Message-ID: Thanks Stefan, On 11/28/2011 08:38 AM, Stefan Behnel wrote: > Gelonida N, 27.11.2011 18:57: >> I'd like to verify some (x)html / / html5 / xml documents from a server. >> >> These documents have a very limited number of different doc types / DTDs. >> >> So what I would like to do is to build a small DTD cache and some code, >> that would avoid searching the DTDs over and over from the net. >> >> What would be the best way to do this? > > Configure your XML catalogues. . . . > > Yes, catalogue lookups generally happen through the public ID. > > . . . > Does this help? > > http://lxml.de/resolvers.html#xml-catalogs > > http://xmlsoft.org/catalog.html These links look perfect. > > They should normally come pre-configured on Linux distributions, but you > may have to install additional packages with the respective DTDs. Look > for any packages with "dtd" and "html" in their name, for example. > Thanks once more. Indeed the package w3c-dtd-xhtml wasn't installed on my Ubuntu host. I'll check this lateron today. (Just have to remove my own hackish cashing solution, which downloads if not found in a cash dir) From steve+comp.lang.python at pearwood.info Mon Nov 28 06:42:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 11:42:30 GMT Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> Message-ID: <4ed373a5$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sun, 27 Nov 2011 23:18:15 -0800, rusi wrote: > On Nov 28, 9:37?am, alex23 wrote: > >> With that approach in mind, I've never had any real issues using pip, >> virtualenv etc for managing my development environment. > > Yes that is in a way my point also: we discuss (things like) pip, > virtualenv etc too little. I don't know about that. I think we discuss things like pip, etc. exactly the right amount. > Try working out the ratio of the number of helps/tutorials on > functions/lists/types/classes to those on these extra-linguistic > features needed for environment/build/deployment/versioning and you can > see the skewness of focus We don't chase people down on the street and lecture them about the problems we think they are having, we answer questions about ACTUAL problems that they have experienced and asking about. If there are 10 or 100 times more answers about (say) classes than about (say) pip, that is because there are 10 or 100 times as many questions about classes. Maybe that's because pip users are cleverer, more experienced and don't have problems; maybe it's because only 1 in 100 people go on to use pip. Maybe it's because pip is a heap of trash that nobody touches; or perhaps it is so fantastic that nobody has any problems with it. Whatever the reason, there's no great big queue of unanswered questions about pip that I can see. Hence, ever question gets an answer, and we're discussing things about as much as we ought to. (I don't mean to single out pip, it is just an example.) -- Steven From andrea.crotti.0 at gmail.com Mon Nov 28 06:45:57 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 28 Nov 2011 11:45:57 +0000 Subject: python 2.5 and ast Message-ID: <4ED37475.3050709@gmail.com> I'm happily using the ast module to analyze some code, but my scripts need also to run unfortunately on python 2.5 The _ast was there already, but the ast helpers not yet. Is it ok if I just copy over the source from the ast helpers in my code base or is there a smarter way? (I don't even need all of them, just "parse" and NodeVisitor at the moment) From jayronsoares at gmail.com Mon Nov 28 06:54:18 2011 From: jayronsoares at gmail.com (Jayron Soares) Date: Mon, 28 Nov 2011 09:54:18 -0200 Subject: Cursor.fetchall Message-ID: Hi guys! I'm stuck at a problem, when I run the follow code: http://pastebin.com/4Gd9V325 I get this error: Traceback (most recent call last): File "/home/jayron/Downloads/grafos.py", line 49, in g, e = ministro_lei() File "/home/jayron/Downloads/grafos.py", line 24, in ministro_lei resp = Q.fetchall() AttributeError: 'long' object has no attribute 'fetchall' Please any help ? cheers -- *" A Vida ? arte do Saber...Quem quiser saber tem que Estudar!"* http://bucolick.tumblr.com http://artecultural.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.vinturini at gmail.com Mon Nov 28 07:06:30 2011 From: felipe.vinturini at gmail.com (Felipe Vinturini) Date: Mon, 28 Nov 2011 10:06:30 -0200 Subject: Cursor.fetchall In-Reply-To: References: Message-ID: Hi Jayron, Instead of using "Q" to loop over the result, use: "dbcursor". resp = dbcursor.fetchall() I hope it helps. Regards, Felipe. On Mon, Nov 28, 2011 at 9:54 AM, Jayron Soares wrote: > Hi guys! > > I'm stuck at a problem, when I run the follow code: > > http://pastebin.com/4Gd9V325 > > I get this error: > > Traceback (most recent call last): > File "/home/jayron/Downloads/grafos.py", line 49, in > g, e = ministro_lei() > File "/home/jayron/Downloads/grafos.py", line 24, in ministro_lei > resp = Q.fetchall() > AttributeError: 'long' object has no attribute 'fetchall' > > Please any help ? > > cheers > > > -- > *" A Vida ? arte do Saber...Quem quiser saber tem que Estudar!"* > > http://bucolick.tumblr.com > http://artecultural.wordpress.com/ > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Mon Nov 28 07:11:15 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 12:11:15 GMT Subject: suppressing bad characters in output PCDATA (converting JSON to XML) References: <91j4q8xgv9.ln2@news.ducksburg.com> Message-ID: <4ed37a63$0$29988$c3e8da3$5496439d@news.astraweb.com> On Fri, 25 Nov 2011 13:50:01 +0000, Adam Funk wrote: > I'm converting JSON data to XML using the standard library's json and > xml.dom.minidom modules. I get the input this way: > > input_source = codecs.open(input_file, 'rb', encoding='UTF-8', > errors='replace') big_json = json.load(input_source) > input_source.close() > > Then I recurse through the contents of big_json to build an instance of > xml.dom.minidom.Document (the recursion includes some code to rewrite > dict keys as valid element names if necessary), How are you doing that? What do you consider valid? > and I save the document: > > xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', > errors='replace') doc.writexml(xml_file, encoding='UTF-8') > xml_file.close() > > > I thought this would force all the output to be valid, but xmlstarlet > gives some errors like these on a few documents: It will force the output to be valid UTF-8 encoded to bytes, not necessarily valid XML. > PCDATA invalid Char value 7 > PCDATA invalid Char value 31 What's xmlstarlet, and at what point does it give this error? It doesn't appear to be in the standard library. > I guess I need to process each piece of PCDATA to clean out the control > characters before creating the text node: > > text = doc.createTextNode(j) > root.appendChild(text) > > What's the best way to do that, bearing in mind that there can be > multibyte characters in the strings? Are you mixing unicode and byte strings? Are you sure that the input source is actually UTF-8? If not, then all bets are off: even if the decoding step works, and returns a string, it may contain the wrong characters. This might explain why you are getting unexpected control characters in the output: they've come from a badly decoded input. Another possibility is that your data actually does contain control characters where there shouldn't be any. -- Steven From python.list at tim.thechases.com Mon Nov 28 07:12:06 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 28 Nov 2011 06:12:06 -0600 Subject: cmd.Cmd asking questions? Message-ID: <4ED37A96.2090905@tim.thechases.com> Are there best-practices for creating wizards or asking various questions (whether yes/no or text/numeric entry) in a cmd.Cmd class? Something like the imaginary confirm() and get_string() methods here: class MyCmd(cmd.Cmd): def do_name(self,line): s = get_string(prompt=line, default="Whatever") ... def do_save(self,line): if os.path.isfile(line): if not confirm("%r exists. Continue?", True): return self.save(line) def save(self, filename): ... I can monkey with printing messages and using raw_input(), but I'd like to know if there's a better way (such as something interacting with readline for text-entry-with-history-and-completion, or raw-character input for Y/N answers rather than the need to hit , making it feel more uniform), Thanks, -tkc From robert.kern at gmail.com Mon Nov 28 07:27:50 2011 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 28 Nov 2011 12:27:50 +0000 Subject: cmd.Cmd asking questions? In-Reply-To: <4ED37A96.2090905@tim.thechases.com> References: <4ED37A96.2090905@tim.thechases.com> Message-ID: On 11/28/11 12:12 PM, Tim Chase wrote: > Are there best-practices for creating wizards or asking various questions > (whether yes/no or text/numeric entry) in a cmd.Cmd class? Something like the > imaginary confirm() and get_string() methods here: > > class MyCmd(cmd.Cmd): > def do_name(self,line): > s = get_string(prompt=line, default="Whatever") > ... > def do_save(self,line): > if os.path.isfile(line): > if not confirm("%r exists. Continue?", True): return > self.save(line) > def save(self, filename): > ... > > I can monkey with printing messages and using raw_input(), but I'd like to know > if there's a better way (such as something interacting with readline for > text-entry-with-history-and-completion, If you import readline, then any following uses of raw_input() will automatically use readline. You may want to swap out the history when you use get_string() or confirm() so they don't mess up the regular Cmd history, but the basic functionality should work out-of-box. > or raw-character input for Y/N answers > rather than the need to hit , making it feel more uniform), I actually have a preference for needing to press enter for Y/N answers, too. It's distinctly *less* uniform to have some questions requiring an enter and some not. It can be unpleasantly surprising to the user, too. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From jayronsoares at gmail.com Mon Nov 28 07:45:53 2011 From: jayronsoares at gmail.com (Jayron Soares) Date: Mon, 28 Nov 2011 10:45:53 -0200 Subject: Cursor.fetchall In-Reply-To: References: Message-ID: Hi Felipe, I did, however I got this error: Traceback (most recent call last): File "/home/jayron/Downloads/grafos.py", line 48, in g, e = ministro_lei() File "/home/jayron/Downloads/grafos.py", line 34, in ministro_lei for i in G.degree(): TypeError: 'int' object is not iterable I could not understood what's going on, I've tried so many different approaches to solve this problem, but unfortunately no success. Cheers 2011/11/28 Felipe Vinturini > Hi Jayron, > > Instead of using "Q" to loop over the result, use: "dbcursor". > > resp = dbcursor.fetchall() > > I hope it helps. > > Regards, > Felipe. > > On Mon, Nov 28, 2011 at 9:54 AM, Jayron Soares wrote: > >> Hi guys! >> >> I'm stuck at a problem, when I run the follow code: >> >> http://pastebin.com/4Gd9V325 >> >> I get this error: >> >> Traceback (most recent call last): >> File "/home/jayron/Downloads/grafos.py", line 49, in >> g, e = ministro_lei() >> File "/home/jayron/Downloads/grafos.py", line 24, in ministro_lei >> resp = Q.fetchall() >> AttributeError: 'long' object has no attribute 'fetchall' >> >> Please any help ? >> >> cheers >> >> >> -- >> *" A Vida ? arte do Saber...Quem quiser saber tem que Estudar!"* >> >> http://bucolick.tumblr.com >> http://artecultural.wordpress.com/ >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> >> > -- *" A Vida ? arte do Saber...Quem quiser saber tem que Estudar!"* http://bucolick.tumblr.com http://artecultural.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanmichel at sequans.com Mon Nov 28 07:57:16 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 28 Nov 2011 13:57:16 +0100 Subject: Pragmatics of the standard is() function In-Reply-To: <4ed15825$0$21841$426a34cc@news.free.fr> References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: <4ED3852C.6090102@sequans.com> candide wrote: > In which cases should we use the is() function ? The is() function > compares identity of objects rather than values so I was wondering in > which circumstances comparing identities of objects is really vital. > > Examining well reputated Python source code, I realize that is() > function is mainly used in the following set form : > > spam is None > > But how much "spam is None" is different from "spam == None" ? > > > > is() function makes comparaison of (abstract representation of) > adresses of objects in memory. Comparing addresses of objects is a low > level feature performed by low level langages such as C but seldom > needed in high level languages like Python, isn'it ? I remember meeting a use case where testing identity is required, when you are searching for an instance containing a specific object: class Someone: def __init__(self, name, car): self.name = name self.car = car class Car: def __init__(self, brand): self.brand = brand def __eq__(self, other): return self.brand == other.brand people = { 'bob':Someone('bob', Car('chrys')), 'cindy': Someone('cindy', Car('Volk')), 'carlos':Someone('carlos', Car('Volk'))} aCar = people['carlos'].car print "people owning a Volk car", [ people[ppl].name for ppl in people if people[ppl].car == Car('Volk')] print "people owning Carlos's car", [ people[ppl].name for ppl in people if people[ppl].car is aCar] people owning a Volk car ['carlos', 'cindy'] people owning Carlos's car ['carlos'] JM From rustompmody at gmail.com Mon Nov 28 08:14:27 2011 From: rustompmody at gmail.com (rusi) Date: Mon, 28 Nov 2011 05:14:27 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> <4ed373a5$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 28, 4:42 pm, Steven D'Aprano wrote: > We don't chase people down on the street and lecture them about the > problems we think they are having, we answer questions about ACTUAL > problems that they have experienced and asking about. > ... ever question gets an answer, and we're discussing > things about as much as we ought to. How about applying these claims to the OP? From jeanmichel at sequans.com Mon Nov 28 08:20:44 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 28 Nov 2011 14:20:44 +0100 Subject: Cursor.fetchall In-Reply-To: References: Message-ID: <4ED38AAC.3090103@sequans.com> Jayron Soares wrote: > Hi Felipe, > > I did, however I got this error: > > Traceback (most recent call last): > File "/home/jayron/Downloads/grafos.py", line 48, in > g, e = ministro_lei() > File "/home/jayron/Downloads/grafos.py", line 34, in ministro_lei > for i in G.degree(): > TypeError: 'int' object is not iterable > > I could not understood what's going on, I've tried so many different > approaches to solve this problem, but unfortunately no success. > > Cheers > > > > 2011/11/28 Felipe Vinturini > > > Hi Jayron, > > Instead of using "Q" to loop over the result, use: "dbcursor". > > resp = dbcursor.fetchall() > > I hope it helps. > > Regards, > Felipe. > > On Mon, Nov 28, 2011 at 9:54 AM, Jayron Soares > > wrote: > > Hi guys! > > I'm stuck at a problem, when I run the follow code: > > http://pastebin.com/4Gd9V325 > > I get this error: > > Traceback (most recent call last): > File "/home/jayron/Downloads/grafos.py", line 49, in > g, e = ministro_lei() > File "/home/jayron/Downloads/grafos.py", line 24, in > ministro_lei > resp = Q.fetchall() > AttributeError: 'long' object has no attribute 'fetchall' > > Please any help ? > > cheers > Hello, You are iterating on G.degree(), which is fine when it is a dictionary. However regarding DiGraph documentation: "Returns : nd : dictionary, or number A dictionary with nodes as keys and degree as values or a number if a single node is specified." So you may get an integer and thus cannot iterate on it. You could use if type(G.degree()) is int: lista.append(G.degree()) else: for i in G.degree().values(): lista.append(i) I'm quite surprised that a distributed graph API uses such inconsistent interface. I guess you'll have to live with it. JM PS : Try to code & document in English, it's much better especially when asking for help on this list, mixing spanish and english has few benefits since you may bother both spanish and english ppl :o) From jeanmichel at sequans.com Mon Nov 28 08:47:51 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 28 Nov 2011 14:47:51 +0100 Subject: Proper way to delete/kill a logger? In-Reply-To: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> References: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> Message-ID: <4ED39107.20109@sequans.com> cassiope wrote: > I've been trying to migrate some code to using the standard python > logging classes/objects. And they seem quite capable of doing what I > need them to do. Unfortunately there's a problem in my unit tests. > It's fairly common to have to create quite a few entities in the > course of a series of tests. What appears to be happening is that the > loggers don't get entirely eliminated, so that new invocations end up > spewing output messages from each of the loggers that were started > with this invocation of the python interpreter. > > I haven't found a function within the logging module that completely > kills a given instance. The removeHandler() function seems to leave a > stdout/stderr output even if all the assigned handlers have been > removed. I've tried a few workarounds, such as increasing the level > to an absurdly large level, which mostly kinda works, and killing the > old entity before creating the new test version. > > There is probably something simple that I'm missing. If you know what > that is, please point me to that fine manual - I'd appreciate it. > Thanks! > > -f > Loggers are static objects managed by the module itself. When you create one, it won't be removed until you leave the shell. Thas is way it is advise not to create thousands of loggers with different names. That's the module design, nothing you can do about it. It takes a little time to get used to it but the logging documentation has a lot of examples showing how to use to module. Your main problem is that some of your test instances are configuring the loggers, they should not. Configuration should be done in the 'main' function *only*. import logging, sys class Test1: def __init__(self): self.logger = logging.getLogger(self.__class__.__name__) # create a new logger or reuse one if a logger with that name already exists self.logger.info('I am created') # adding a handler to the logger here would be a mistake, configuration is let to the user, in this case the program main entry point # objects raising log events should not care about how they are formated/displayed class Test2: def __init__(self): self.logger = logging.getLogger(self.__class__.__name__) self.logger.info('I am created') def main(): # configure here the logger, usually the root logger root = logging.getLogger() root.handlers = [] # required if you don't want to exit the shell between 2 executions (not very wise) root.setLevel(logging.DEBUG) root.addHandler(logging.StreamHandler(sys.stdout)) root.handlers[-1].setFormatter(logging.Formatter('%(name)s - %(levelname)s - %(message)s')) t1 = Test1() t2 = Test2() t3 = Test2() if __name__ == '__main__': main() > run test.py Test1 - INFO - I am created Test2 - INFO - I am created Test2 - INFO - I am created JM PS : one way to cleanup a logger is to remove all its handlers, i.e. logger.handlers = [], but if you need to do this you may have done something wrong. From steve+comp.lang.python at pearwood.info Mon Nov 28 09:04:26 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 14:04:26 GMT Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> <4ed373a5$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed394e9$0$29988$c3e8da3$5496439d@news.astraweb.com> On Mon, 28 Nov 2011 05:14:27 -0800, rusi wrote: > On Nov 28, 4:42 pm, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> We don't chase people down on the street and lecture them about the >> problems we think they are having, we answer questions about ACTUAL >> problems that they have experienced and asking about. > >> ... ever question gets an answer, and we're discussing things about as >> much as we ought to. > > How about applying these claims to the OP? The OP ranted that the existing packaging systems are an "all-out disgrace" (his words), without giving even a single example of a concrete problem, and unilaterally declared that this needs the personal attention of Guido van Rossum. There's a word for posts like that one: starts with T, ends in ROLL. Presumably the OP believes that not only should he not have to solve his own problems with existing packaging systems, but he should not have to even describe those supposed problems. The OP's only question was "when is python going to get a decent module distribution system???", to which the right answer is presumably "about a decade ago". Decent does not necessarily mean perfect. If the OP decides to ask a sensible question about an actual problem, I'm sure he'll get a sensible answer. Perhaps not the answer he is hoping for, but an an answer. -- Steven From jeanmichel at sequans.com Mon Nov 28 09:18:54 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 28 Nov 2011 15:18:54 +0100 Subject: Cursor.fetchall In-Reply-To: <4ED38AAC.3090103@sequans.com> References: <4ED38AAC.3090103@sequans.com> Message-ID: <4ED3984E.700@sequans.com> Jean-Michel Pichavant wrote: > > PS : Try to code & document in English, it's much better especially > when asking for help on this list, mixing spanish and english has few > benefits since you may bother both spanish and english ppl :o) Actually it is english mixed with portuguese, sorry if I offended anyone :o( . JM From andreas.perstinger at gmx.net Mon Nov 28 09:23:23 2011 From: andreas.perstinger at gmx.net (Andreas Perstinger) Date: Mon, 28 Nov 2011 15:23:23 +0100 Subject: sick of distribute, setup, and all the rest... In-Reply-To: References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> <4ed373a5$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ED3995B.9040308@gmx.net> On 2011-11-28 14:14, rusi wrote: > On Nov 28, 4:42 pm, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> We don't chase people down on the street and lecture them about the >> problems we think they are having, we answer questions about ACTUAL >> problems that they have experienced and asking about. > >> ... ever question gets an answer, and we're discussing >> things about as much as we ought to. > > How about applying these claims to the OP? > OP asked only one question (the rest was just ranting) and Steven answered it (IMHO in the right manner). OP never mentioned specific problems or what's wrong with any of the distribution systems. So what answers are you expecting from such a post? Bye, Andreas From roy at panix.com Mon Nov 28 09:56:53 2011 From: roy at panix.com (Roy Smith) Date: Mon, 28 Nov 2011 09:56:53 -0500 Subject: Proper way to delete/kill a logger? References: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> Message-ID: In article , Jean-Michel Pichavant wrote: > Loggers are static objects managed by the module itself. For reasons I can't quite explain, that sentence makes me want to sing The Lumberjack Song. "I'm a logger(*) and I'm OK..." (*) Yes, I know that's not right. From jtim.arnold at gmail.com Mon Nov 28 10:36:17 2011 From: jtim.arnold at gmail.com (Tim) Date: Mon, 28 Nov 2011 07:36:17 -0800 (PST) Subject: correct usage of a generator? Message-ID: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Hi, I need to generate a list of file names that increment, like this: fname1 fname2 fname3 and so on. I don't know how many I'll need until runtime so I figure a generator is called for. def fname_gen(stem): i = 0 while True: i = i+1 yield '%s%d' % (stem,i) blarg = fname_gen('blarg') boo = fname_gen('boo') n = 3 for w in range(0,n): in_name = blarg.next() out_name = boo.next() This works, but is it the 'normal' way to accomplish the task when you don't know 'n' until run-time? thanks, --Tim From fpm at u.washington.edu Mon Nov 28 11:27:07 2011 From: fpm at u.washington.edu (cassiope) Date: Mon, 28 Nov 2011 08:27:07 -0800 (PST) Subject: Proper way to delete/kill a logger? References: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> Message-ID: <11b21871-0bf2-4957-a0a3-65d3c039632d@u1g2000prl.googlegroups.com> Thanks Chris and JM, I will explore how much work it's going to take to change the various scripts to _always_ starting the logger from main(). As further explanation - this code predates the logging module, and many of the functions/classes had an optional argument for the home- made logger - and where the caller didn't provide it, it was locally created. The unit tests were carefully enough put together to provide almost complete coverage, resulting in creating the logger possibly a dozen or more times in the course of the tests. So I appreciate what "doing it the right way" means, I was just hoping not to have to go there, as I have a lot of code that uses the old structures. It makes it harder to justify moving to the "newer" module. I'll have to try the logger.handlers=[] approach, thanks. From steve+comp.lang.python at pearwood.info Mon Nov 28 11:44:40 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 16:44:40 GMT Subject: correct usage of a generator? References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Message-ID: <4ed3ba77$0$29988$c3e8da3$5496439d@news.astraweb.com> On Mon, 28 Nov 2011 07:36:17 -0800, Tim wrote: > Hi, I need to generate a list of file names that increment, like this: > fname1 > fname2 > fname3 and so on. > > I don't know how many I'll need until runtime so I figure a generator is > called for. > > def fname_gen(stem): > i = 0 > while True: > i = i+1 > yield '%s%d' % (stem,i) > > blarg = fname_gen('blarg') > boo = fname_gen('boo') > > n = 3 > for w in range(0,n): > in_name = blarg.next() > out_name = boo.next() > > > This works, but is it the 'normal' way to accomplish the task when you > don't know 'n' until run-time? thanks, Looks perfectly fine to me. In Python 2.6 onwards, I'd write next(blarg) rather than blarg.next(), and similarly for boo. In Python 3.x, you have to use next(blarg). If I were to nit-pick, I'd write the last part as: for _ in range(3): in_name = blarg.next() out_name = boo.next() where _ is the traditional "don't care" name in Python. -- Steven From __peter__ at web.de Mon Nov 28 11:54:48 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 28 Nov 2011 17:54:48 +0100 Subject: correct usage of a generator? References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Message-ID: Tim wrote: > Hi, I need to generate a list of file names that increment, like this: > fname1 > fname2 > fname3 and so on. > > I don't know how many I'll need until runtime so I figure a generator is > called for. > > def fname_gen(stem): > i = 0 > while True: > i = i+1 > yield '%s%d' % (stem,i) > > blarg = fname_gen('blarg') > boo = fname_gen('boo') > > n = 3 > for w in range(0,n): > in_name = blarg.next() > out_name = boo.next() > > > This works, but is it the 'normal' way to accomplish the task when you > don't know 'n' until run-time? thanks, As a fan of the itertools module I would spell it (untested) from itertools import count, islice, izip def fname_gen(stem): return ("%s%d" % (stem, i) for i in count(1)) # ... for in_name, out_name in islice(izip(blarg, boo), n): #... but your way is perfectly OK. From neilc at norwich.edu Mon Nov 28 12:04:25 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 28 Nov 2011 17:04:25 GMT Subject: correct usage of a generator? References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> <4ed3ba77$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9jht8pFrs3U1@mid.individual.net> On 2011-11-28, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 07:36:17 -0800, Tim wrote: >> Hi, I need to generate a list of file names that increment, like this: >> fname1 >> fname2 >> fname3 and so on. >> >> I don't know how many I'll need until runtime so I figure a >> generator is called for. >> >> def fname_gen(stem): >> i = 0 >> while True: >> i = i+1 >> yield '%s%d' % (stem,i) >> >> blarg = fname_gen('blarg') >> boo = fname_gen('boo') I don't see anything wrong with that. I've written similar code in terms of itertools.count, myself. If I may make a suggestion, it would be nice to zero-pad the number to achieve lexicographical ordering of filenames. However, if you really have no idea of the magnitude you might need that won't work. The following assumes you'll need less than 1000. counter = itertools.count() ... with open("%03d" % counter.next(), "w") as the_next_file: ... My Python < 3.0 is rusty, so sorry if I messed that up. -- Neil Cerutti From !nospam!astrochelonian at gmail.com Mon Nov 28 12:21:37 2011 From: !nospam!astrochelonian at gmail.com (Eduardo Alvarez) Date: Mon, 28 Nov 2011 17:21:37 +0000 (UTC) Subject: mailbox module difficulties Message-ID: Hello, everyone, I'm in the process of learning how to use the mailbox module with python 3.2. I've noticed the following seemingly inconsistent behavior: if I call a Maildir object directly, the module works perfectly. I can, for example, call mailbox.Maildir("~/Maildir").items() and get the expected list of (key,Message) pairs. however, if I do the following: b = mailbox.Maildir("~/Maildir") b.items() I get an empty list. I don't understand why this is so, specially since the last example in the documentation shows a reference to a Maildir object being created. Why does this happen? yours, -- Eduardo Alvarez From rosuav at gmail.com Mon Nov 28 12:29:45 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 04:29:45 +1100 Subject: mailbox module difficulties In-Reply-To: References: Message-ID: On Tue, Nov 29, 2011 at 4:21 AM, Eduardo Alvarez wrote: > if I call a Maildir object directly, the module works perfectly. I can, > for example, call > > mailbox.Maildir("~/Maildir").items() > > and get the expected list of (key,Message) pairs. > > however, if I do the following: > > b = mailbox.Maildir("~/Maildir") > b.items() > > I get an empty list. They ought to be equivalent. Can you post your whole code? Maybe there's some other difference. ChrisA From __peter__ at web.de Mon Nov 28 12:50:17 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 28 Nov 2011 18:50:17 +0100 Subject: mailbox module difficulties References: Message-ID: Eduardo Alvarez wrote: > however, if I do the following: > > b = mailbox.Maildir("~/Maildir") > b.items() > > I get an empty list. > > I don't understand why this is so, specially since the last example in > the documentation shows a reference to a Maildir object being created. > Why does this happen? Could this be http://bugs.python.org/issue13254 ? From mwilson at the-wire.com Mon Nov 28 12:58:50 2011 From: mwilson at the-wire.com (Mel Wilson) Date: Mon, 28 Nov 2011 12:58:50 -0500 Subject: correct usage of a generator? References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Message-ID: Tim wrote: > Hi, I need to generate a list of file names that increment, like this: > fname1 > fname2 > fname3 and so on. > > I don't know how many I'll need until runtime so I figure a generator is > called for. > > def fname_gen(stem): > i = 0 > while True: > i = i+1 > yield '%s%d' % (stem,i) > > blarg = fname_gen('blarg') > boo = fname_gen('boo') > > n = 3 > for w in range(0,n): > in_name = blarg.next() > out_name = boo.next() > > > This works, but is it the 'normal' way to accomplish the task when you > don't know 'n' until run-time? thanks, It's kind of overkill in the toy demo example, but if the main loop is a little more abstract, e.g. for task in task_supplier(): in_name = blarg.next() out_name = boo.next() handle_task (task, in_name, out_name) then it's obviously a good thing. One quibble (that Peter Otten also suggested): if your business rules expect that files blarg25 and boo25 (for example) work together, then you'd be better off generating them together as a pair in a single generator call. As it is, there's a chance of the blarg and boo generators getting out of step and supplying mismatched names. Mel. From jehugaleahsa at gmail.com Mon Nov 28 13:03:38 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 10:03:38 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <61aacaf4-4953-4e6d-8f5e-2c999a9e2b63@k26g2000yqd.googlegroups.com> On Nov 27, 6:55?pm, Steven D'Aprano wrote: > On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > > Personally, I find a lot of good things in Python. I thinking tabs are > > out-of-date. Even the MAKE community wishes that the need for tabs would > > go away and many implementations have done just that. > > Tabs have every theoretical advantage and only one practical > disadvantage: the common toolsets used by Unix programmers are crap in > their handling of tabs, and instead of fixing the toolsets, they blame > the tabs. > > The use of spaces as indentation is a clear case of a technically worse > solution winning over a better solution. > > > I have been > > seriously debating about whether to force a specific number of spaces, > > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > > spaces is appropriate (although I'm not sure when). > > Why on earth should your language dictate the width of an indentation? I > can understand that you might care that indents are consistent within a > single source code unit (a file?), but anything more than that is just > obnoxious. > > > I have always found the standard library for Python to be disjoint. That > > can be really beneficial where it keeps the learning curve down and the > > size of the standard modules down. At the same time, it means > > re-learning whenever you use a new module. > > I know what disjoint means, but I don't understand what you think it > means for a software library to be disjoint. I don't understand the rest > of the paragraph. > > > My language combines generators and collection initializers, instead of > > creating a whole new syntax for comprehensions. > > > [| for i in 0..10: for j in 0.10: yield return i * j |] > > Are we supposed to intuit what that means? > > Is | a token, or are the delimiters [| and |] ? > > Is there a difference between iterating over 0..10 and iterating over > what looks like a float 0.10? > > What is "yield return"? > > > Lambdas and functions are the same thing in my language, so no need for > > a special keyword. > > That does not follow. Lambdas and def functions are the same thing in > Python, but Python requires a special keyword. > > > I also distinguish between initialization and > > assignment via the let keyword. > > What does this mean? I can guess, but I might guess wrong. > > > Also, non-locals do not need to be > > defined explicitly, since the scoping rules in Unit are far more "anal". > > What does this mean? I can't even guess what you consider more anal > scoping rules. > > > In reality though, it takes a certain level of arrogance to assume that > > any language will turn out without bumps. It is like I was told in > > college long ago, "Only the smallest programs are bug free." I think the > > same thing could be said for a language. The only language without flaws > > would be so small that it would be useless. > > I'm pretty sure that being so small that it is useless would count as a > flaw. > > What does it mean to say that a language is "small"? > > A Turing Machine is a pretty small language, with only a few > instructions: step forward, step backwards, erase a cell, write a cell, > branch on the state of the cell. And yet anything that can be computed, > anything at all, can be computed by a Turning Machine: a Turing Machine > can do anything you can do in C, Lisp, Fortran, Python, Java... and very > probably anything you can (mentally) do, full stop. So what does that > mean about "small" languages? > > On the other hand, take Epigram, a functional programming language: > > http://en.wikipedia.org/wiki/Epigram_(programming_language) > > It is *less* powerful than a Turing Machine, despite being far more > complex. Similarly languages like regular expressions, finite automata > and context-free grammers are more complex, "bigger", possibly with > dozens or hundreds of instructions, and yet less powerful. Likewise for > spreadsheets without cycles. > > Forth is much smaller than Java, but I would say that Forth is much, much > more powerful in some sense than Java. You could write a Java compiler in > Forth more easily than you could write a Forth compiler in Java. > > -- > Steven > > Yes. I was mostly rambling. More explanation would have meant more typing. Languages that use type inference heavily typically find unique ways of indicating literals, including numbers and collections. In Unit, [||] indicates fixed length arrays, [] is for dynamic arrays, {} is for sets and unordered dictionaries (at least one value is needed). A frozen set might be represented with a {||} in the future. I stole the syntax from F#. Numbers have a trailing letter indicating their types: signed byte (y), short (s), long (l), float (f), fixed (m), arbitrary precision (i), rational (r) and imaginary (j). Unsigned versions have a u before the letter (uy). Also, .. is the range operator in Unit. 0..10 means "0 through 10" and 0.1 means a floating point number (I missed a dot). 0..10..2 means 0, 2, 4, 6, 8, 10. Saves me from needing a range function, like Python. Quite a few functional languages support that syntax. From !nospam!astrochelonian at gmail.com Mon Nov 28 13:10:47 2011 From: !nospam!astrochelonian at gmail.com (Eduardo Alvarez) Date: Mon, 28 Nov 2011 18:10:47 +0000 (UTC) Subject: mailbox module difficulties References: Message-ID: On 2011-11-28, Peter Otten <__peter__ at web.de> wrote: > Eduardo Alvarez wrote: > >> however, if I do the following: >> >> b = mailbox.Maildir("~/Maildir") >> b.items() >> >> I get an empty list. >> >> I don't understand why this is so, specially since the last example in >> the documentation shows a reference to a Maildir object being created. >> Why does this happen? > > Could this be > > http://bugs.python.org/issue13254 > > ? Peter and Chris, This is exactly it. I guess the version in my linux distribution is not patched. I'll let the maintainer know, thank you! Yours, -- Eduardo Alvarez From stefan_ml at behnel.de Mon Nov 28 13:20:40 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 28 Nov 2011 19:20:40 +0100 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) In-Reply-To: <91j4q8xgv9.ln2@news.ducksburg.com> References: <91j4q8xgv9.ln2@news.ducksburg.com> Message-ID: Adam Funk, 25.11.2011 14:50: > I'm converting JSON data to XML using the standard library's json and > xml.dom.minidom modules. I get the input this way: > > input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') It doesn't make sense to use codecs.open() with a "b" mode. > big_json = json.load(input_source) You shouldn't decode the input before passing it into json.load(), just open the file in binary mode. Serialised JSON is defined as being UTF-8 encoded (or BOM-prefixed), not decoded Unicode. > input_source.close() In case of a failure, the file will not be closed safely. All in all, use this instead: with open(input_file, 'rb') as f: big_json = json.load(f) > Then I recurse through the contents of big_json to build an instance > of xml.dom.minidom.Document (the recursion includes some code to > rewrite dict keys as valid element names if necessary) If the name "big_json" is supposed to hint at a large set of data, you may want to use something other than minidom. Take a look at the xml.etree.cElementTree module instead, which is substantially more memory efficient. > and I save the document: > > xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') > doc.writexml(xml_file, encoding='UTF-8') > xml_file.close() Same mistakes as above. Especially the double encoding is both unnecessary and likely to fail. This is also most likely the source of your problems. > I thought this would force all the output to be valid, but xmlstarlet > gives some errors like these on a few documents: > > PCDATA invalid Char value 7 > PCDATA invalid Char value 31 This strongly hints at a broken encoding, which can easily be triggered by your erroneous encode-and-encode cycles above. Also, the kind of problem you present here makes it pretty clear that you are using Python 2.x. In Python 3, you'd get the appropriate exceptions when trying to write binary data to a Unicode file. Stefan From jtim.arnold at gmail.com Mon Nov 28 14:20:22 2011 From: jtim.arnold at gmail.com (Tim) Date: Mon, 28 Nov 2011 11:20:22 -0800 (PST) Subject: correct usage of a generator? In-Reply-To: References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Message-ID: <6572253.26.1322508022441.JavaMail.geo-discussion-forums@yqf20> thanks everyone. I thought blarg.next() looked a little strange--I'm just learning generators now and I'm glad too see that next(blarg) is the way to go. The example really was just a toy or I would use an iterator. I do need the two (well, the several) generators to not be coupled together so they increment independently. I'll keep the zero-padding advice in mind--I didn't think of that one. what a great group this is. thanks again! --Tim From patentsvnc at gmail.com Mon Nov 28 14:22:09 2011 From: patentsvnc at gmail.com (Den) Date: Mon, 28 Nov 2011 11:22:09 -0800 (PST) Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 26, 3:01?pm, Steven D'Aprano wrote: > On Sat, 26 Nov 2011 22:20:36 +0100, candide wrote: >>SNIP<< > > That is correct. You probably should rarely use `is`. Apart from testing > for None, use of `is` should be rare. > > -- > Steven With respect, I disagree with advice that the use of a language construct should be rare. All constructs should be used *appropriately*. While in general a particular use of a Python construct may be rare, if the programmer is involved deeply with that rare use, then it is NOT rare to him/her. Thus, for a particular programmer, use of 'is' may be quite frequent because the program they're working on requires knowledge of object identity. The same goes for global variables, by the way. While it's easy to shoot yourself in the foot with global variables, that doesn't lead to never-use-them. It leads to use-them-appropriately-and-carefully. Sorry, you plucked a string of mine. One does not throw a tool out of your tool box because it might be dangerous. Table saws are incredibly dangerous, but in the hands of a skilled operator can be competently and safely used to produce beautiful woodwork. To say *never* use a table saw because it's dangerous is silly. Language constructs are put there intentionally. Advice that they be used *rarely* or *never* should *never* be given ((chuckle)). Just learn what they are, learn how they work, learn what the consequences of misuse can be (loss of a hand, in the case of a table saw), and use them confidently when the circumstances make them the best choice of tool to solve your problem. To make a long comment short (too late!!) learn the differences between 'is' and ==, and use them appropriately. When I was learning Python, I found the two books by Mark Lutz to be filled with information of such things as these. D From patentsvnc at gmail.com Mon Nov 28 14:24:10 2011 From: patentsvnc at gmail.com (Den) Date: Mon, 28 Nov 2011 11:24:10 -0800 (PST) Subject: Return of an old friend References: Message-ID: On Nov 25, 2:13?am, Noah Hall wrote: > On Fri, Nov 25, 2011 at 5:08 AM, Matt Joiner wrote: > > I haven't heard of you before, but feel like I've missed out on something. > > > Do you (or someone else) care to link to some of your more contentious work? > > Ignore him, he's a troll with an unjustly inflated ego. ((laugh)) Well, that didn't take long. From ian.g.kelly at gmail.com Mon Nov 28 14:32:59 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 28 Nov 2011 12:32:59 -0700 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano wrote: >> My language combines generators and collection initializers, instead of >> creating a whole new syntax for comprehensions. >> >> [| for i in 0..10: for j in 0.10: yield return i * j |] > > Are we supposed to intuit what that means? > > Is | a token, or are the delimiters [| and |] ? > > Is there a difference between iterating over 0..10 and iterating over > what looks like a float 0.10? > > What is "yield return"? I would assume that "yield return" is borrowed from C#, where it is basically equivalent to Python's yield statement. The advantage of using two keywords like that is that you can compare the statements "yield return foo" and "yield break", which is a bit clearer than comparing the equivalent "yield foo" and "return". Having to type out "yield return" in every comprehension seems a bit painful to me, but I can understand the approach: what is shown above is a full generator, not a single "generator expression" like we use in Python, so the statement keywords can't be omitted. It's trading off convenience for expressiveness (a bad trade-off IMO -- complex generators should be named, not anonymous). >> Lambdas and functions are the same thing in my language, so no need for >> a special keyword. > > That does not follow. Lambdas and def functions are the same thing in > Python, but Python requires a special keyword. I think the implication is that Unit has only one syntax for creating functions, which is lambda-style. In any case, why does Python require a special keyword? def is only used in a statement context, and lambda is only used in an expression context. Why not use the same keyword for both? I think the answer is historical: def came first, and when anonymous functions were added it didn't make sense to use the keyword "def" for them, because "def" implies a name being defined. Cheers, Ian From ameyer2 at yahoo.com Mon Nov 28 15:03:13 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 28 Nov 2011 15:03:13 -0500 Subject: Does py2app improves speed? In-Reply-To: References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> Message-ID: <4ED3E901.30306@yahoo.com> On 11/24/2011 9:27 AM, Dave Angel wrote: ... > Several ways to speed up code. > > 1) use language features to best advantage > 2) use 3rd party libraries that do certain things well > 3) use best algorithms, subject to #1 and #2 > 4) have someone else review the code (perhaps on the list, perhaps > within your own organization) > 5) measure (eg. profile it) > 6) use optimizing tools, such as pypy or Cython. > 7) rewrite parts of it in another language > 8) get a faster processor > 9) rewrite it all in another language > > It takes experience to choose between these, and each project is > different. But even the most experienced developers will frequently > guess entirely wrong where the bottleneck is, which is why you measure > if you care. I agree that measuring (profiling) is the most critical. As you say, even the most experienced programmers can guess wrong. The first time I used a profiler a couple of decades ago I was egotistical enough to wonder how this thing could help me. After all, I wrote the code. I knew what it did. The profiler wasn't going to tell me anything I didn't know. I learned a little humility after reading the profiler output. The program was spending most of its time in a place that I never dreamed was a problem, and a 10 minute fix cut run times in half. In that particular case there wasn't even a design problem, it was just a procedure call inside a tight loop that executed far more often than I imagined and could be replaced with a few lines of inline code. I think the rest of your list is excellent too. Alan From ethan at stoneleaf.us Mon Nov 28 15:05:00 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 28 Nov 2011 12:05:00 -0800 Subject: Pragmatics of the standard is() function In-Reply-To: References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ED3E96C.9040701@stoneleaf.us> Den wrote: > With respect, I disagree with advice that the use of a language > construct should be rare. All constructs should be used > *appropriately*. +1 ~Ethan~ From tjreedy at udel.edu Mon Nov 28 15:08:23 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 28 Nov 2011 15:08:23 -0500 Subject: python 2.5 and ast In-Reply-To: <4ED37475.3050709@gmail.com> References: <4ED37475.3050709@gmail.com> Message-ID: On 11/28/2011 6:45 AM, Andrea Crotti wrote: > I'm happily using the ast module to analyze some code, > but my scripts need also to run unfortunately on python 2.5 > > The _ast was there already, but the ast helpers not yet. > Is it ok if I just copy over the source from the ast helpers in my code > base That is the standard way of backporting features of later versions. -- Terry Jan Reedy From neilc at norwich.edu Mon Nov 28 15:20:36 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 28 Nov 2011 20:20:36 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9ji8okFs94U2@mid.individual.net> On 2011-11-28, Ian Kelly wrote: > I think the implication is that Unit has only one syntax for > creating functions, which is lambda-style. In any case, why > does Python require a special keyword? def is only used in a > statement context, and lambda is only used in an expression > context. Why not use the same keyword for both? I think the > answer is historical: def came first, and when anonymous > functions were added it didn't make sense to use the keyword > "def" for them, because "def" implies a name being defined. I've always held with the "anti-functional style conspiracy" interpretation of Python's lambda expressions. They were added but grudgingingly, made weak on purpose to discourage their use. -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins From plsullivan1 at gmail.com Mon Nov 28 15:24:32 2011 From: plsullivan1 at gmail.com (plsullivan1 at gmail.com) Date: Mon, 28 Nov 2011 12:24:32 -0800 (PST) Subject: remove characters before last occurance of "." Message-ID: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> I need for GIS.GIS.Cadastral\GIS.GIS.Citylimit to be Citylimit. The "cadastral" and "citylimit" will be different as I readlines from a list. In other words, the above could be GIS.GIS.Restricted\GIS.GIS.Pipeline and I would need Pipeline. s = GIS.GIS.Cadastral\GIS.GIS.Citylimit NeededValue = Citylimit Thanks. From greg.ewing at canterbury.ac.nz Mon Nov 28 15:40:01 2011 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 29 Nov 2011 09:40:01 +1300 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> Message-ID: <9ji9t4FdphU1@mid.individual.net> Travis Parks wrote: > I thinking tabs are > out-of-date. Even the MAKE community wishes that the need for tabs > would go away The situation with make is a bit different, because it *requires* tabs in certain places -- spaces won't do. Python lets you choose which to use as long as you don't mix them up, and I like it that way. > let Parse = public static method (value: String) > throws(FormatException UnderflowException OverflowException) Checked exceptions? I fear you're repeating a huge mistake going down that route... -- Greg From ethan at stoneleaf.us Mon Nov 28 15:45:55 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 28 Nov 2011 12:45:55 -0800 Subject: remove characters before last occurance of "." In-Reply-To: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> References: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> Message-ID: <4ED3F303.8020307@stoneleaf.us> plsullivan1 at gmail.com wrote: > s = GIS.GIS.Cadastral\GIS.GIS.Citylimit > NeededValue = Citylimit NeededValue = s.rsplit('.', 1)[1] ~Ethan~ From greg.ewing at canterbury.ac.nz Mon Nov 28 15:48:34 2011 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 29 Nov 2011 09:48:34 +1300 Subject: Using the Python Interpreter as a Reference In-Reply-To: <9ji8okFs94U2@mid.individual.net> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <9ji8okFs94U2@mid.individual.net> Message-ID: <9jiad5Fhr9U1@mid.individual.net> Neil Cerutti wrote: > I've always held with the "anti-functional style conspiracy" > interpretation of Python's lambda expressions. They were added > but grudgingingly, made weak on purpose to discourage their use. Seems to me that Python's lambdas are about as powerful as they can be given the statement/expression distinction. No conspiracy is needed, just an understandable desire on Guido's part not to do violence to the overall syntactic style of the language. -- Greg From alemumihretu at gmail.com Mon Nov 28 15:52:13 2011 From: alemumihretu at gmail.com (Alemu mihretu) Date: Mon, 28 Nov 2011 13:52:13 -0700 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: Hello all, My python runs and crashes after another run. I am getting errors like Microsoft Visual C++ Runtime Library program c:\Python27\pythonw.exe This application has requested the Runtime to terminate it in an usuak way. Please contact the application's support team for more information. Any Idea ? my plot also does not work ? frustrating On Mon, Nov 28, 2011 at 12:32 PM, Ian Kelly wrote: > On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano > wrote: > >> My language combines generators and collection initializers, instead of > >> creating a whole new syntax for comprehensions. > >> > >> [| for i in 0..10: for j in 0.10: yield return i * j |] > > > > Are we supposed to intuit what that means? > > > > Is | a token, or are the delimiters [| and |] ? > > > > Is there a difference between iterating over 0..10 and iterating over > > what looks like a float 0.10? > > > > What is "yield return"? > > I would assume that "yield return" is borrowed from C#, where it is > basically equivalent to Python's yield statement. The advantage of > using two keywords like that is that you can compare the statements > "yield return foo" and "yield break", which is a bit clearer than > comparing the equivalent "yield foo" and "return". > > Having to type out "yield return" in every comprehension seems a bit > painful to me, but I can understand the approach: what is shown above > is a full generator, not a single "generator expression" like we use > in Python, so the statement keywords can't be omitted. It's trading > off convenience for expressiveness (a bad trade-off IMO -- complex > generators should be named, not anonymous). > > >> Lambdas and functions are the same thing in my language, so no need for > >> a special keyword. > > > > That does not follow. Lambdas and def functions are the same thing in > > Python, but Python requires a special keyword. > > I think the implication is that Unit has only one syntax for creating > functions, which is lambda-style. In any case, why does Python > require a special keyword? def is only used in a statement context, > and lambda is only used in an expression context. Why not use the > same keyword for both? I think the answer is historical: def came > first, and when anonymous functions were added it didn't make sense to > use the keyword "def" for them, because "def" implies a name being > defined. > > Cheers, > Ian > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at gmail.com Mon Nov 28 16:08:29 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Mon, 28 Nov 2011 21:08:29 +0000 Subject: remove characters before last occurance of "." In-Reply-To: <4ED3F303.8020307@stoneleaf.us> References: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> <4ED3F303.8020307@stoneleaf.us> Message-ID: On 28 November 2011 20:45, Ethan Furman wrote: > plsullivan1 at gmail.com wrote: >> >> s = GIS.GIS.Cadastral\GIS.GIS.Citylimit >> NeededValue = Citylimit > > NeededValue = s.rsplit('.', 1)[1] Also: >>> s[s.rfind(".") + 1:] 'Citylimit' >>> s.rpartition(".")[2] 'Citylimit' -- Arnaud From neilc at norwich.edu Mon Nov 28 16:11:06 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 28 Nov 2011 21:11:06 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <9ji8okFs94U2@mid.individual.net> <9jiad5Fhr9U1@mid.individual.net> Message-ID: <9jibnaFrjeU1@mid.individual.net> On 2011-11-28, Gregory Ewing wrote: > Neil Cerutti wrote: >> I've always held with the "anti-functional style conspiracy" >> interpretation of Python's lambda expressions. They were added >> but grudgingingly, made weak on purpose to discourage their >> use. > > Seems to me that Python's lambdas are about as powerful as they > can be given the statement/expression distinction. No > conspiracy is needed, just an understandable desire on Guido's > part not to do violence to the overall syntactic style of the > language. It's true. Most conspiracy theories do fall apart once facts and clear thinking are applied. But we love them anyway. ;) -- Neil Cerutti From plsullivan1 at gmail.com Mon Nov 28 16:13:44 2011 From: plsullivan1 at gmail.com (plsullivan1 at gmail.com) Date: Mon, 28 Nov 2011 13:13:44 -0800 (PST) Subject: remove characters before last occurance of "." In-Reply-To: References: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> <4ED3F303.8020307@stoneleaf.us> Message-ID: <28260178.222.1322514824753.JavaMail.geo-discussion-forums@yqi26> Thanks! From plsullivan1 at gmail.com Mon Nov 28 16:13:44 2011 From: plsullivan1 at gmail.com (plsullivan1 at gmail.com) Date: Mon, 28 Nov 2011 13:13:44 -0800 (PST) Subject: remove characters before last occurance of "." In-Reply-To: References: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> <4ED3F303.8020307@stoneleaf.us> Message-ID: <28260178.222.1322514824753.JavaMail.geo-discussion-forums@yqi26> Thanks! From jehugaleahsa at gmail.com Mon Nov 28 16:29:06 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 13:29:06 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <9ji9t4FdphU1@mid.individual.net> Message-ID: On Nov 28, 3:40?pm, Gregory Ewing wrote: > Travis Parks wrote: > > I thinking tabs are > > out-of-date. Even the MAKE community wishes that the need for tabs > > would go away > > The situation with make is a bit different, because it > *requires* tabs in certain places -- spaces won't do. > Python lets you choose which to use as long as you don't > mix them up, and I like it that way. > > > let Parse = public static method (value: String) > > throws(FormatException UnderflowException OverflowException) > > Checked exceptions? I fear you're repeating a huge mistake > going down that route... > > -- > Greg > > Exception handling is one of those subjects few understand and fewer can implement properly in modern code. Languages that don't support exceptions as part of their signature lead to capturing generic Exception all throughout code. It is one of those features I wish .NET had. At the same time, with my limited experience with Java, it has been a massive annoyance. Perhaps something to provide or just shut off via a command line parameter. What indications have there been that this has been a flaw? I can see it alienating a large group of up- and-coming developers. From jehugaleahsa at gmail.com Mon Nov 28 16:34:07 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 13:34:07 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <16c6a453-22de-4dc3-bc99-16a45200fca2@o13g2000vbo.googlegroups.com> On Nov 28, 2:32?pm, Ian Kelly wrote: > On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano > > wrote: > >> My language combines generators and collection initializers, instead of > >> creating a whole new syntax for comprehensions. > > >> [| for i in 0..10: for j in 0.10: yield return i * j |] > > > Are we supposed to intuit what that means? > > > Is | a token, or are the delimiters [| and |] ? > > > Is there a difference between iterating over 0..10 and iterating over > > what looks like a float 0.10? > > > What is "yield return"? > > I would assume that "yield return" is borrowed from C#, where it is > basically equivalent to Python's yield statement. ?The advantage of > using two keywords like that is that you can compare the statements > "yield return foo" and "yield break", which is a bit clearer than > comparing the equivalent "yield foo" and "return". > > Having to type out "yield return" in every comprehension seems a bit > painful to me, but I can understand the approach: what is shown above > is a full generator, not a single "generator expression" like we use > in Python, so the statement keywords can't be omitted. ?It's trading > off convenience for expressiveness (a bad trade-off IMO -- complex > generators should be named, not anonymous). > > >> Lambdas and functions are the same thing in my language, so no need for > >> a special keyword. > > > That does not follow. Lambdas and def functions are the same thing in > > Python, but Python requires a special keyword. > > I think the implication is that Unit has only one syntax for creating > functions, which is lambda-style. ?In any case, why does Python > require a special keyword? ?def is only used in a statement context, > and lambda is only used in an expression context. ?Why not use the > same keyword for both? ?I think the answer is historical: ?def came > first, and when anonymous functions were added it didn't make sense to > use the keyword "def" for them, because "def" implies a name being > defined. > > Cheers, > Ian > > Most languages I have worked with have a "lambda" syntax and a function syntax. It has always been a historical artifact. Languages start out avoiding functional features and then eventually adopt them. It seems that eventually, convenient high-order functions become a must-have (most standard algorithm packages). It is a conflict between old C-style programming and the need for functional code. As soon as functions can be assigned to variables, the code starts looking oddly like JavaScript. From rosuav at gmail.com Mon Nov 28 16:57:46 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 08:57:46 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <9ji9t4FdphU1@mid.individual.net> Message-ID: On Tue, Nov 29, 2011 at 8:29 AM, Travis Parks wrote: > Languages that don't support > exceptions as part of their signature lead to capturing generic > Exception all throughout code. It is one of those features I wish .NET > had. At the same time, with my limited experience with Java, it has > been a massive annoyance. In Java, it mainly feels like syntactic salt. There's still a class of RuntimeExceptions that aren't listed in the signature, so you still have to concern yourself with the possibility that unexpected exceptions will propagate; and you're forced to decorate every method with the list of what it might propagate up, other than that. It's like const-decorating a series of functions in C++, only far less consequential and requiring far more typing. ChrisA From steve+comp.lang.python at pearwood.info Mon Nov 28 17:24:46 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 22:24:46 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> On Mon, 28 Nov 2011 12:32:59 -0700, Ian Kelly wrote: > On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano > wrote: [...] >>> Lambdas and functions are the same thing in my language, so no need >>> for a special keyword. >> >> That does not follow. Lambdas and def functions are the same thing in >> Python, but Python requires a special keyword. > > I think the implication is that Unit has only one syntax for creating > functions, which is lambda-style. In any case, why does Python require > a special keyword? def is only used in a statement context, and lambda > is only used in an expression context. Why not use the same keyword for > both? Because the syntax is completely different. One is a statement, and stands alone, the other is an expression. Even putting aside the fact that lambda's body is an expression, and a def's body is a block, def also requires a name. Using the same keyword for both would require special case reasoning: sometimes def is followed by a name, sometimes without a name. That's ugly. def name(args): block # okay funcs = [def args: expr, # okay so far def name(args): expr, # not okay def: expr, # okay ] def: expr # also okay def: expr expr # but not okay x = def x: expr # okay x = def x(x): expr # not okay Using the same keyword for named and unnamed functions is, in my opinion, one of those foolish consistencies we are warned about. When deciding on syntax, the difference between anonymous and named functions are more significant than their similarities. > I think the answer is historical: def came first, and when > anonymous functions were added it didn't make sense to use the keyword > "def" for them, because "def" implies a name being defined. That reasoning still applies even if they were added simultaneously. Lambda is pretty old: it certainly exists in Python 1.5 and almost certainly in 1.4. While it doesn't exist as a keyword in Python 0.9.1, there is a module called "lambda" with a function "lambda" that uses more or less the same syntax. Instead of lambda x: x+1, you would instead write lambda("x", "x+1"). So the idea of including anonymous functions was around in Python circles before the syntax was locked in. -- Steven From rosuav at gmail.com Mon Nov 28 17:48:24 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 09:48:24 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Nov 29, 2011 at 9:24 AM, Steven D'Aprano wrote: > Because the syntax is completely different. One is a statement, and > stands alone, the other is an expression. Even putting aside the fact > that lambda's body is an expression, and a def's body is a block, def > also requires a name. Using the same keyword for both would require > special case reasoning: sometimes def is followed by a name, sometimes > without a name. That's ugly. > All you need to do is define that a block of code is an object (and thus suitable material for an expression), and you have easy commonality. fn = def(args): block of code Now def is an expression that takes an optional name (omitted in the above), an arg list, and a block of code... and there's minimal difference between named and anonymous functions. (If it's given a name, then it sets __name__ and also binds to that name, being convenient for the common case. The above code is a silly way to do almost the default.) ChrisA From steve+comp.lang.python at pearwood.info Mon Nov 28 17:57:47 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 22:57:47 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <9ji9t4FdphU1@mid.individual.net> Message-ID: <4ed411eb$0$29988$c3e8da3$5496439d@news.astraweb.com> On Mon, 28 Nov 2011 13:29:06 -0800, Travis Parks wrote: > Exception handling is one of those subjects few understand and fewer can > implement properly in modern code. Languages that don't support > exceptions as part of their signature lead to capturing generic > Exception all throughout code. It is one of those features I wish .NET > had. At the same time, with my limited experience with Java, it has been > a massive annoyance. Perhaps something to provide or just shut off via a > command line parameter. What indications have there been that this has > been a flaw? I can see it alienating a large group of up- and-coming > developers. http://www.ibm.com/developerworks/java/library/j-jtp05254/index.html Note also that Bruce Eckel repeats a rumour that checked exceptions were *literally* an experiment snuck into the Java language while James Gosling was away on holiday. http://www.mindview.net/Etc/Discussions/UnCheckedExceptionComments Even if that is not true, checked exceptions are a feature that *in practice* seems to lead to poor exception handling and cruft needed only to satisfy the compiler: http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-219143 and other annoyances. It's main appeal, it seems to me, is to give a false sense of security to Java developers who fail to realise that under certain circumstances Java will raise certain checked exceptions *even if they are not declared*. E.g. null pointer exceptions. See also: http://java.dzone.com/articles/checked-exceptions-i-love-you and note especially the comment from the coder who says that he simply declares his functions to throw Exception (the most generic checked exception), thus defeating the whole point of checked exceptions. -- Steven From devplayer at gmail.com Mon Nov 28 19:54:08 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 28 Nov 2011 16:54:08 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 27, 6:55?pm, Steven D'Aprano wrote: > On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > > Personally, I find a lot of good things in Python. I thinking tabs are > > out-of-date. Even the MAKE community wishes that the need for tabs would > > go away and many implementations have done just that. > > Tabs have every theoretical advantage and only one practical > disadvantage: the common toolsets used by Unix programmers are crap in > their handling of tabs, and instead of fixing the toolsets, they blame > the tabs. > > The use of spaces as indentation is a clear case of a technically worse > solution winning over a better solution. > > > I have been > > seriously debating about whether to force a specific number of spaces, > > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > > spaces is appropriate (although I'm not sure when). > > Why on earth should your language dictate the width of an indentation? I > can understand that you might care that indents are consistent within a > single source code unit (a file?), but anything more than that is just > obnoxious. > I do not understand why the interpreter preprocesses each logical line of source code using something as simple as this: def reindent( line, spaces_per_tab=os.spaces_per_tab): index = 0 # index into line of text indent = 0 # increase 1 when in next tab column spaces = 0 # index into current column for c in line: if c == ' ': spaces +=1 if spaces >= spaces_per_tab: indent += 1 spaces = 0 if c == '\t': # jump to next tab column indent += 1 spaces = 0 if c <> ' ' and c <> '\t': break index += 1 rest_of_line = line[index:] new_indent = ' ' * indent * spaces_per_tab + ' ' * spaces newline = new_indent + rest_of_line return newline or even some regex equivelent. That function would need to be run on each line of source code, after processing the line continuation character and single/double/triple quote pairs are processed but before the code block tokenizer (INDENT/ DEDENT) if possible. Unless some of you expert parser/compiler writers know fancier tricks. To me, I would think the interpreter finding the coder's intended indent wouldn't be that hard. And just make the need for consistant spaces or tabs irrevelent simply by reformatting the indent as expected. Pretty much all my text editors can. From devplayer at gmail.com Mon Nov 28 19:59:42 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 28 Nov 2011 16:59:42 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: > I do not understand why the interpreter preprocesses each logical line > of source code using something as simple as this: correction: I do not understand why the interpreter - does not- preprocess each logical line of source code using something as simple as this: From rosuav at gmail.com Mon Nov 28 20:49:49 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 12:49:49 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Nov 29, 2011 at 11:54 AM, DevPlayer wrote: > To me, I would think the interpreter finding the coder's intended > indent wouldn't be that hard. And just make the need for consistant > spaces or tabs irrevelent simply by reformatting the indent as > expected. Pretty much all my text editors can. The trouble with having a language declaration that "a tab is equivalent to X spaces" is that there's no consensus as to what X should be. Historically X has always been 8, and quite a few programs still assume this. I personally like 4. Some keep things narrow with 2. You can even go 1 - a strict substitution of \t with \x20. Once you declare it in your language, you immediately break everyone who uses anything different. ChrisA From jehugaleahsa at gmail.com Mon Nov 28 21:42:12 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 18:42:12 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> On Nov 28, 5:24?pm, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 12:32:59 -0700, Ian Kelly wrote: > > On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano > > wrote: > [...] > >>> Lambdas and functions are the same thing in my language, so no need > >>> for a special keyword. > > >> That does not follow. Lambdas and def functions are the same thing in > >> Python, but Python requires a special keyword. > > > I think the implication is that Unit has only one syntax for creating > > functions, which is lambda-style. ?In any case, why does Python require > > a special keyword? ?def is only used in a statement context, and lambda > > is only used in an expression context. ?Why not use the same keyword for > > both? > > Because the syntax is completely different. One is a statement, and > stands alone, the other is an expression. Even putting aside the fact > that lambda's body is an expression, and a def's body is a block, def > also requires a name. Using the same keyword for both would require > special case reasoning: sometimes def is followed by a name, sometimes > without a name. That's ugly. > > def name(args): block ?# okay > > funcs = [def args: expr, ?# okay so far > ? ? ? ? ?def name(args): expr, ?# not okay > ? ? ? ? ?def: expr, ?# okay > ? ? ? ? ?] > > def: expr ?# also okay > > def: expr > ? ? expr ?# but not okay > > x = def x: expr ?# okay > x = def x(x): expr ?# not okay > > Using the same keyword for named and unnamed functions is, in my opinion, > one of those foolish consistencies we are warned about. When deciding on > syntax, the difference between anonymous and named functions are more > significant than their similarities. A good example I have run into is recursion. When a local function calls itself, the name of the function may not be part of scope (non- local). Languages that support tail-end recursion optimization can't optimize. In order to support this, a function in Unit will have access to its own name and type. In other words, special scoping rules are in place in Unit to allow treating a function as an expression. > > > I think the answer is historical: ?def came first, and when > > anonymous functions were added it didn't make sense to use the keyword > > "def" for them, because "def" implies a name being defined. > > That reasoning still applies even if they were added simultaneously. > > Lambda is pretty old: it certainly exists in Python 1.5 and almost > certainly in 1.4. While it doesn't exist as a keyword in Python 0.9.1, > there is a module called "lambda" with a function "lambda" that uses more > or less the same syntax. Instead of lambda x: x+1, you would instead > write lambda("x", "x+1"). So the idea of including anonymous functions > was around in Python circles before the syntax was locked in. I find that interesting. I also find it interesting that the common functional methods (all, any, map, filter) are basically built into Python core language. That is unusual for most imperative programming languages early-on. From rosuav at gmail.com Mon Nov 28 21:57:32 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 13:57:32 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> Message-ID: On Tue, Nov 29, 2011 at 1:42 PM, Travis Parks wrote: > A good example I have run into is recursion. When a local function > calls itself, the name of the function may not be part of scope (non- > local). Languages that support tail-end recursion optimization can't > optimize. In order to support this, a function in Unit will have > access to its own name and type. In other words, special scoping rules > are in place in Unit to allow treating a function as an expression. I'm inclined toward an alternative: explicit recursion. Either a different syntax, or a special-case on the use of the function's own name, but whichever syntax you use, it compiles in a "recurse" opcode. That way, if name bindings change, it's still going to recurse - something few languages guarantee, and therefore few languages can optimize. ChrisA From jehugaleahsa at gmail.com Mon Nov 28 21:57:54 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 18:57:54 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <9ji9t4FdphU1@mid.individual.net> <4ed411eb$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 28, 5:57?pm, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 13:29:06 -0800, Travis Parks wrote: > > Exception handling is one of those subjects few understand and fewer can > > implement properly in modern code. Languages that don't support > > exceptions as part of their signature lead to capturing generic > > Exception all throughout code. It is one of those features I wish .NET > > had. At the same time, with my limited experience with Java, it has been > > a massive annoyance. Perhaps something to provide or just shut off via a > > command line parameter. What indications have there been that this has > > been a flaw? I can see it alienating a large group of up- and-coming > > developers. > > http://www.ibm.com/developerworks/java/library/j-jtp05254/index.html > > Note also that Bruce Eckel repeats a rumour that checked exceptions were > *literally* an experiment snuck into the Java language while James > Gosling was away on holiday. > > http://www.mindview.net/Etc/Discussions/UnCheckedExceptionComments > > Even if that is not true, checked exceptions are a feature that *in > practice* seems to lead to poor exception handling and cruft needed only > to satisfy the compiler: > > http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-ex... > > and other annoyances. It's main appeal, it seems to me, is to give a > false sense of security to Java developers who fail to realise that under > certain circumstances Java will raise certain checked exceptions *even if > they are not declared*. E.g. null pointer exceptions. > > See also: > > http://java.dzone.com/articles/checked-exceptions-i-love-you > > and note especially the comment from the coder who says that he simply > declares his functions to throw Exception (the most generic checked > exception), thus defeating the whole point of checked exceptions. > > -- > Steven I think all of the examples you listed referred specifically to most programmers finding ways around the annoyance. I have heard about throwing generic Exception or inheriting all custom exception types from RuntimeException. I did this quite often myself. In general, unchecked exceptions shouldn't be caught. They occur because of bad code and insufficient testing. Checked exceptions occur because of downed databases, missing files, network problems - things that may become available later without code changes. One day, I went through about 10,000 lines of code and moved argument checking code outside of try blocks because I realized I was handling some of them by accident. Here is the program: if me == idiot: exit(). People don't think about this, but the exceptions thrown by a module are part of that module's interface. Being able to make sure only what you expect to come out is important. Unlike Java, Unit requires you to opt in to using throws clauses. If you don't list one, one is generated for you automatically. The benefit: you can see what a function throws and protect yourself without all the babysitting. A lack of exception handling is big problem in .NET. I have had libraries from big names including Novell and Oracle throw NullReferenceExceptions because _they_ didn't know what would happen in cases where a DLL is missing or a dependency isn't installed. They could have done better testing, but if the biggest names in development can't manage to figure it, I say leave it up to the compiler. Returning nulls or special value in cases of failures takes us back to the days of C and Fortran. From jehugaleahsa at gmail.com Mon Nov 28 22:00:48 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 19:00:48 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2cb176e6-322f-4c2d-a9bd-c3c5b6729cb6@e2g2000vbb.googlegroups.com> On Nov 28, 8:49?pm, Chris Angelico wrote: > On Tue, Nov 29, 2011 at 11:54 AM, DevPlayer wrote: > > To me, I would think the interpreter finding the coder's intended > > indent wouldn't be that hard. And just make the need for consistant > > spaces or tabs irrevelent simply by reformatting the indent as > > expected. Pretty much all my text editors can. > > The trouble with having a language declaration that "a tab is > equivalent to X spaces" is that there's no consensus as to what X > should be. Historically X has always been 8, and quite a few programs > still assume this. I personally like 4. Some keep things narrow with > 2. You can even go 1 - a strict substitution of \t with \x20. Once you > declare it in your language, you immediately break everyone who uses > anything different. > > ChrisA Yeah. We must remember the Unix users, espcially those who don't know how to hack Vim or bash. I've decided not to require a specific number of spaces. I am still teetering on whether to allow tabs. From d at davea.name Mon Nov 28 22:53:14 2011 From: d at davea.name (Dave Angel) Date: Mon, 28 Nov 2011 22:53:14 -0500 Subject: Does py2app improves speed? In-Reply-To: <4ED3E901.30306@yahoo.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> <4ED3E901.30306@yahoo.com> Message-ID: <4ED4572A.5020508@davea.name> On 11/28/2011 03:03 PM, Alan Meyer wrote: > On 11/24/2011 9:27 AM, Dave Angel wrote: > ... >> Several ways to speed up code. >> >> 1) use language features to best advantage >> 2) use 3rd party libraries that do certain things well >> 3) use best algorithms, subject to #1 and #2 >> 4) have someone else review the code (perhaps on the list, perhaps >> within your own organization) >> 5) measure (eg. profile it) >> 6) use optimizing tools, such as pypy or Cython. >> 7) rewrite parts of it in another language >> 8) get a faster processor >> 9) rewrite it all in another language >> >> It takes experience to choose between these, and each project is >> different. But even the most experienced developers will frequently >> guess entirely wrong where the bottleneck is, which is why you measure >> if you care. > > I agree that measuring (profiling) is the most critical. > > As you say, even the most experienced programmers can guess wrong. > The first time I used a profiler a couple of decades ago I was > egotistical enough to wonder how this thing could help me. After all, > I wrote the code. I knew what it did. The profiler wasn't going to > tell me anything I didn't know. > > I learned a little humility after reading the profiler output. The > program was spending most of its time in a place that I never dreamed > was a problem, and a 10 minute fix cut run times in half. > > In that particular case there wasn't even a design problem, it was > just a procedure call inside a tight loop that executed far more often > than I imagined and could be replaced with a few lines of inline code. > > I think the rest of your list is excellent too. > > Alan Thanks. I once had an assignment to speed up a function implementation which was obviously slow (I had noted the same thing to the architect when I first saw the code; it would definitely be slow on large data sets). I knew faster algorithms. But I stopped instead to measure how many times it was being called in the particularly slow scenario that the customer complained about. Turns out it wasn't being called at all. I asked the appropriate developer why he had chosen to do it another way (expecting he'd say because he knew this function was slow), and he gave me an entirely different reason. I asked him whether he'd be willing to call this function if I fixed his complaint about its interface, and he agreed. Now, I rewrote the function, making a change to tighten its interface restrictions. And it cut the customer's wait time from 90 minutes to 2. Everyone was happy. Total time spent, a week. But I didn't start coding till the 4th day. -- DaveA From d at davea.name Mon Nov 28 22:55:49 2011 From: d at davea.name (Dave Angel) Date: Mon, 28 Nov 2011 22:55:49 -0500 Subject: python 2.5 and ast In-Reply-To: References: <4ED37475.3050709@gmail.com> Message-ID: <4ED457C5.2020407@davea.name> On 11/28/2011 03:08 PM, Terry Reedy wrote: > On 11/28/2011 6:45 AM, Andrea Crotti wrote: >> I'm happily using the ast module to analyze some code, >> but my scripts need also to run unfortunately on python 2.5 >> >> The _ast was there already, but the ast helpers not yet. >> Is it ok if I just copy over the source from the ast helpers in my code >> base > > That is the standard way of backporting features of later versions. > But don't forget to tag it as version specific, so it gets removed when the later version of the library is available. There are various ways of doing that, but the easiest is probably to put a test in the acceptance suite that fails if this code is used in 2.6 or later. -- DaveA From wuwei23 at gmail.com Mon Nov 28 22:58:17 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 28 Nov 2011 19:58:17 -0800 (PST) Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 29, 5:22?am, Den wrote: > On Nov 26, 3:01?pm, Steven D'Aprano > That is correct. You probably should rarely use `is`. Apart from testing > > for None, use of `is` should be rare. > > With respect, I disagree with advice that the use of a language > construct should be rare. ?All constructs should be used > *appropriately*. Steven didn't say it _shouldn't_ be used, only that it it should be _rarely_ used. General consensus would be that that is the most appropriate use of 'is'. Value comparisons are _far_ more common in Python than identity comparisons, the ubiquitous None notwithstanding. But for your general point, I totally agree. I feel the same way about the ternary syntax, boolean defaults for conditionals etc From ian.g.kelly at gmail.com Mon Nov 28 23:56:19 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 28 Nov 2011 21:56:19 -0700 Subject: Using the Python Interpreter as a Reference In-Reply-To: <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> Message-ID: On Mon, Nov 28, 2011 at 7:42 PM, Travis Parks wrote: > I find that interesting. I also find it interesting that the common > functional methods (all, any, map, filter) are basically built into > Python core language. That is unusual for most imperative programming > languages early-on. all and any are actually quite recent additions. Guido added them to placate users of "reduce(lambda x, y: x and y, foo)" back when the plan was to remove reduce in Python 3. Cheers, Ian From mrinalini at edss.co.in Tue Nov 29 02:34:01 2011 From: mrinalini at edss.co.in (Mrinalini Kulkarni) Date: Tue, 29 Nov 2011 13:04:01 +0530 Subject: Executing .pyc using python c api Message-ID: <98b3b679c77003a565bd306bc06c5709@edss.co.in> Hi I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. thanks, From steve+comp.lang.python at pearwood.info Tue Nov 29 03:04:14 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Nov 2011 08:04:14 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed491fe$0$14018$c3e8da3$76491128@news.astraweb.com> On Tue, 29 Nov 2011 12:49:49 +1100, Chris Angelico wrote: > On Tue, Nov 29, 2011 at 11:54 AM, DevPlayer wrote: >> To me, I would think the interpreter finding the coder's intended >> indent wouldn't be that hard. And just make the need for consistant >> spaces or tabs irrevelent simply by reformatting the indent as >> expected. Pretty much all my text editors can. > > The trouble with having a language declaration that "a tab is equivalent > to X spaces" is that there's no consensus as to what X should be. > Historically X has always been 8, and quite a few programs still assume > this. I personally like 4. Some keep things narrow with 2. You can even > go 1 - a strict substitution of \t with \x20. Once you declare it in > your language, you immediately break everyone who uses anything > different. Why should we enforce how many spaces a tab is set to? That is literally only visible to the editor, not the compiler. (Unless the parser is particularly stupid and merely substitutes X spaces for a tab every time it sees one.) Mixed spaces and tabs in an indent are ambiguous, and so raises SyntaxError (or at least it *should* raise SyntaxError). But separate code blocks can use different absolute indent levels without ambiguity, so long as the relative indentation is consistent: def ham(): # tab stops at 4 and 8 do(a) do(b) if c: do(c) else: do(d) def spam(): # tab stops at 8 and 12 do(a) do(b) if c: do(c) else: do(d) There is no meaningful difference in indentation between ham and spam above. In either case, I could replace spaces with tabs to get the same relative indents regardless of the absolute indentation. I can appreciate the aesthetic argument that *within a single file*, indentation should be consistent. But it's not logically necessary for the parser: it need only be consistent within a single code unit (function or class usually). In other words: syntax should only care about relative indentation, absolute indentation belongs as a coding standard. -- Steven From steve+comp.lang.python at pearwood.info Tue Nov 29 03:12:09 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Nov 2011 08:12:09 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> Message-ID: <4ed493d8$0$14018$c3e8da3$76491128@news.astraweb.com> On Tue, 29 Nov 2011 13:57:32 +1100, Chris Angelico wrote: > I'm inclined toward an alternative: explicit recursion. Either a > different syntax, or a special-case on the use of the function's own > name, but whichever syntax you use, it compiles in a "recurse" opcode. > That way, if name bindings change, it's still going to recurse - > something few languages guarantee, and therefore few languages can > optimize. As I recall, Forth uses (or used) a special RECURSE word which turned on the recursion bit while compiling, so that the compiled word could see itself. By memory, the (incomplete) definition: : fact dup 1- fact * ; would fail, unless you happened to already have another word called fact existing at compilation time. To make it recurse correctly, the compiler needs to make sure that the namespace fact sees includes itself: RECURSE : fact dup 1- fact * ; which should work, apart from the embarrassing fact that I don't recall the syntax for conditional jumps and so the recursion never terminates. :) -- Steven From stefan_ml at behnel.de Tue Nov 29 03:15:41 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 29 Nov 2011 09:15:41 +0100 Subject: Executing .pyc using python c api In-Reply-To: <98b3b679c77003a565bd306bc06c5709@edss.co.in> References: <98b3b679c77003a565bd306bc06c5709@edss.co.in> Message-ID: Mrinalini Kulkarni, 29.11.2011 08:34: > I need to run .pyc files using python c api. if i do PyImport_Import it > executes the script. However, i need to pass a set of variables and their > values which will be accessed from within the script. How can this be done. Assuming you have the source as well, you should change your script to be usable as an importable module as well as an executable script. Here is how: http://docs.python.org/tutorial/modules.html#executing-modules-as-scripts If you do not have the source, however, you are a bit out of luck. In that case, what so you mean by "pass a set of variables"? Do you mean command line arguments, or do you want to pass in global names that the module can use? In the first case, you may need to modify sys.argv. If the latter, you could change the globals() of the imported module. However, both are clumsy solutions, and if possible at all, you should change the module source code instead. Stefan From steve+comp.lang.python at pearwood.info Tue Nov 29 03:41:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Nov 2011 08:41:30 GMT Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed49aba$0$14018$c3e8da3$76491128@news.astraweb.com> On Mon, 28 Nov 2011 11:22:09 -0800, Den wrote: > With respect, I disagree with advice that the use of a language > construct should be rare. All constructs should be used > *appropriately*. And if those appropriate conditions are rare, then the use of the appropriate construct should also be rare. Since it is rare to need to care about identity, use of `is` should be rare too. This is mostly descriptive statement rather than a prescriptive one: it is a fact that use of `is` is much less common than use of ==, and even more so if you disregard the obvious case of "x is None". I am however being a little prescriptive: if somebody thinks they need to care about identity, chances are good -- but not certain -- that they're mistaken. In code that gives you the choice between writing `is` and ==, it is usually, but not often, a bug to write `is`. The proof of this is that in actual, existing code, if you swapped == and `is`, most of the code would stop working correctly. On the other hand if you actually do need to care about identity, then go for it. I'm not saying that caring about identity should be prohibited, only that in practice it is uncommon that you will. > While in general a particular use of a Python construct may be rare, if > the programmer is involved deeply with that rare use, then it is NOT > rare to him/her. Regardless of how common brain surgery might be to a brain surgeon, it is rare in general. That's all I'm saying. If you happen to work for a data recovery centre, then pulling the disk platter out of a hard disk drive might be commonplace to you, nevertheless pulling platters out of disks is vanishingly rare: out of tens of thousands of HDDs, perhaps only a few dozen will be sent to a recover centre at all. [...] > Sorry, you plucked a string of mine. One does not throw a tool out of > your tool box because it might be dangerous. Table saws are incredibly > dangerous, but in the hands of a skilled operator can be competently and > safely used to produce beautiful woodwork. To say *never* use a table > saw because it's dangerous is silly. Fortunately, I didn't say "never". In the case of `is`, one shouldn't avoid using `is` because it is dangerous, but merely because it is the wrong thing to use. In the same way, the average programmer will rarely need to use the math.sinh and math.cosh functions, not because they are bad, evil, or dangerous, but because they are used for specialist purposes that most coders would never care about. Hell, most coders rarely use the standard trigonometric functions sin and cos, let alone the hyperbolic versions! This is not a value judgement. If I, in a misplaced sense of egalitarianism ("Emancipation for maths functions! Right on brothers!") decided to use sinh instead of sin because they looked and sounded similar, my code would almost certain be buggy. Likewise if I decided to use `is` instead of == because in English they have similar meanings, my code would probably be buggy too. Sorry to belabour the point, but we're in violent agreement here -- Steven From d at davea.name Tue Nov 29 03:53:16 2011 From: d at davea.name (Dave Angel) Date: Tue, 29 Nov 2011 03:53:16 -0500 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ed493d8$0$14018$c3e8da3$76491128@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> <4ed493d8$0$14018$c3e8da3$76491128@news.astraweb.com> Message-ID: <4ED49D7C.9000704@davea.name> On 11/29/2011 03:12 AM, Steven D'Aprano wrote: > On Tue, 29 Nov 2011 13:57:32 +1100, Chris Angelico wrote: > >> I'm inclined toward an alternative: explicit recursion. Either a >> different syntax, or a special-case on the use of the function's own >> name, but whichever syntax you use, it compiles in a "recurse" opcode. >> That way, if name bindings change, it's still going to recurse - >> something few languages guarantee, and therefore few languages can >> optimize. > As I recall, Forth uses (or used) a special RECURSE word which turned on > the recursion bit while compiling, so that the compiled word could see > itself. > > By memory, the (incomplete) definition: > > : fact dup 1- fact * ; > > would fail, unless you happened to already have another word called fact > existing at compilation time. To make it recurse correctly, the compiler > needs to make sure that the namespace fact sees includes itself: > > RECURSE : fact dup 1- fact * ; > > which should work, apart from the embarrassing fact that I don't recall > the syntax for conditional jumps and so the recursion never terminates. > > :) > The way I remember it, the current definition was "smudged" which made it invisible (it basically changed the name to something unlikely) during the compilation. After all, if you actually ran it at compile time (which was frequently done), you could fall right into uninitialized space. Anyway, some implementations had an immediate SMUDGE word, which toggled the smudge bit and made it visible again. Other implementations had an immediate word RECURSE, which compiled in whatever word was being currently defined. I'm pretty sure neither FIG nor Forth79 had either of these. But I don't recall the ANSI standard (X3J14 ?), even though I was officially an observer. I can't even remember what happened to my printed copy of the standard. The easiest word for conditional is IF/ELSE/THEN. IF will skip to the ELSE or THEN if the condition is false. So something resembling: : fact dup 1- dup 0<> if recurse * then ; might do it. That's very rough, however. It's been a long time. -- DaveA From ulrich.eckhardt at dominolaser.com Tue Nov 29 04:02:31 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 29 Nov 2011 10:02:31 +0100 Subject: Executing .pyc using python c api In-Reply-To: References: Message-ID: <7mjeq8-ubf.ln1@satorlaser.homedns.org> Am 29.11.2011 08:34, schrieb Mrinalini Kulkarni: > I need to run .pyc files using python c api. if i do PyImport_Import it > executes the script. However, i need to pass a set of variables and > their values which will be accessed from within the script. How can this > be done. I don't think what you want is possible, due to a think-o in your design. Let me explain... Firstly, .pyc files are basically the same as .py files, only in a different presentation. Then, PyImport_Import is basically the same as using "import" in a Python program. Now, and that is where your fault lies, importing a module actually means executing that module! For example, the definition of a function is code that when executed will cause a function to be created and attached to the current scope with the according name. This is what makes it so easy to implement local functions that are parametrized by arguments to the outer function. Still, a function is not something that is "static", like in C or Java, but rather the result of executing its function definition. Now, how to get around this? The specialty about the import is that the __name__ attribute is not set to "__main__", upon which many scripts already react. So, in order to "prevent execution" (in the sense that you probably mean), you simply wrap the according code in a function. The function definition will then be executed, giving you a function that you can call with the according parameters, but the function itself will not be executed automatically. If you want that to happen when executing the .pyc file directly, check the content of __name__ and call the function if it is "__main__". Note that another approach would be introspection, traversing through the namespaces to find out those parameters, but I would consider this solution as hackish if the one above is feasible. Good luck! Uli From andrea.crotti.0 at gmail.com Tue Nov 29 04:51:24 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 29 Nov 2011 09:51:24 +0000 Subject: python 2.5 and ast In-Reply-To: <4ED457C5.2020407@davea.name> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> Message-ID: <4ED4AB1C.3080609@gmail.com> On 11/29/2011 03:55 AM, Dave Angel wrote: > > But don't forget to tag it as version specific, so it gets removed > when the later version of the library is available. There are various > ways of doing that, but the easiest is probably to put a test in the > acceptance suite that fails if this code is used in 2.6 or later. > Ok thanks, something like this is ok? (or maybe I can use a try/catch and export my own if is not found in the standard library?) from sys import version_info if version_info[1] == 5: from psi.devsonly.ast import parse, NodeVisitor else: from ast import parse, NodeVisitor From arnodel at gmail.com Tue Nov 29 05:11:06 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 29 Nov 2011 10:11:06 +0000 Subject: python 2.5 and ast In-Reply-To: <4ED4AB1C.3080609@gmail.com> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> <4ED4AB1C.3080609@gmail.com> Message-ID: On 29 November 2011 09:51, Andrea Crotti wrote: > from sys import version_info > > if version_info[1] == 5: > ? ?from psi.devsonly.ast import parse, NodeVisitor > else: > ? ?from ast import parse, NodeVisitor Why don't you just: try: from ast import parse, NodeVisitor except ImportError: from psi.devsonly.ast import parse, NodeVisitor -- Arnaud From mlto at live.jp Tue Nov 29 05:46:24 2011 From: mlto at live.jp (Toshiyuki Ogura) Date: Tue, 29 Nov 2011 19:46:24 +0900 Subject: Can I submit an issue with Python 2.5.6? Message-ID: Hi. I found a problem with Python 2.5.6. test_commands fails when 'make test'. bugs.python.org doesn't seem to have an option for Python 2.5 in "Versions:" drop-down menu when creating an issue. The problem seems to be the same as #11946. http://bugs.python.org/issue11946 I also made a patch for 2.5.6. --- Python-2.5.6/Lib/test/test_commands.py.orig 2006-06-29 04:10:08.000000000 +0000 +++ Python-2.5.6/Lib/test/test_commands.py 2011-11-29 08:46:29.602607019 +0000 @@ -46,11 +46,7 @@ # drwxr-xr-x 15 Joe User My Group 4096 Aug 12 12:50 / # Note that the first case above has a space in the group name # while the second one has a space in both names. - pat = r'''d......... # It is a directory. - \+? # It may have ACLs. - \s+\d+ # It has some number of links. - [^/]* # Skip user, group, size, and date. - /\. # and end with the name of the file. + pat = r'''^.*(\/\.)[\ ]*[\n\r]*$ ''' self.assert_(re.match(pat, getstatus("/."), re.VERBOSE)) Can I submit the issue at bugs.python.org? I think many people are still using Python 2.5 because of Google App Engine and fixing bugs with 2.5 is still helpful. Toshiyuki Ogura -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Nov 29 06:32:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Nov 2011 11:32:30 GMT Subject: python 2.5 and ast References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> Message-ID: <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> On Tue, 29 Nov 2011 09:51:24 +0000, Andrea Crotti wrote: > On 11/29/2011 03:55 AM, Dave Angel wrote: >> >> But don't forget to tag it as version specific, so it gets removed when >> the later version of the library is available. There are various ways >> of doing that, but the easiest is probably to put a test in the >> acceptance suite that fails if this code is used in 2.6 or later. >> >> > Ok thanks, > something like this is ok? > (or maybe I can use a try/catch and export my own if is not found in the > standard library?) > > from sys import version_info > > if version_info[1] == 5: > from psi.devsonly.ast import parse, NodeVisitor > else: > from ast import parse, NodeVisitor I prefer to check against sys.version. import sys if sys.version <= '2.5': from psi.devsonly.ast import parse, NodeVisitor else: from ast import parse, NodeVisitor Or even: try: from ast import parse, NodeVisitor except ImportError: from ast import parse, NodeVisitor -- Steven From a24061 at ducksburg.com Tue Nov 29 07:50:59 2011 From: a24061 at ducksburg.com (Adam Funk) Date: Tue, 29 Nov 2011 12:50:59 +0000 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) References: <91j4q8xgv9.ln2@news.ducksburg.com> <4ed37a63$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-11-28, Steven D'Aprano wrote: > On Fri, 25 Nov 2011 13:50:01 +0000, Adam Funk wrote: > >> I'm converting JSON data to XML using the standard library's json and >> xml.dom.minidom modules. I get the input this way: >> >> input_source = codecs.open(input_file, 'rb', encoding='UTF-8', >> errors='replace') big_json = json.load(input_source) >> input_source.close() >> >> Then I recurse through the contents of big_json to build an instance of >> xml.dom.minidom.Document (the recursion includes some code to rewrite >> dict keys as valid element names if necessary), > > How are you doing that? What do you consider valid? Regex-replacing all whitespace ('\s+') with '_', and adding 'a_' to the beginning of any potential tag that doesn't start with a letter. This is good enough for my purposes. >> I thought this would force all the output to be valid, but xmlstarlet >> gives some errors like these on a few documents: > > It will force the output to be valid UTF-8 encoded to bytes, not > necessarily valid XML. Yes! >> PCDATA invalid Char value 7 >> PCDATA invalid Char value 31 > > What's xmlstarlet, and at what point does it give this error? It doesn't > appear to be in the standard library. It's a command-line tool I use a lot for finding the bad bits in XML, nothing to do with python. http://xmlstar.sourceforge.net/ >> I guess I need to process each piece of PCDATA to clean out the control >> characters before creating the text node: >> >> text = doc.createTextNode(j) >> root.appendChild(text) >> >> What's the best way to do that, bearing in mind that there can be >> multibyte characters in the strings? > > Are you mixing unicode and byte strings? I don't think I am. > Are you sure that the input source is actually UTF-8? If not, then all > bets are off: even if the decoding step works, and returns a string, it > may contain the wrong characters. This might explain why you are getting > unexpected control characters in the output: they've come from a badly > decoded input. I'm pretty sure that the input is really UTF-8, but has a few control characters (fairly rare). > Another possibility is that your data actually does contain control > characters where there shouldn't be any. I think that's the problem, and I'm looking for an efficient way to delete them from unicode strings. -- Some say the world will end in fire; some say in segfaults. [XKCD 312] From a24061 at ducksburg.com Tue Nov 29 07:57:22 2011 From: a24061 at ducksburg.com (Adam Funk) Date: Tue, 29 Nov 2011 12:57:22 +0000 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) References: <91j4q8xgv9.ln2@news.ducksburg.com> Message-ID: On 2011-11-28, Stefan Behnel wrote: > Adam Funk, 25.11.2011 14:50: >> I'm converting JSON data to XML using the standard library's json and >> xml.dom.minidom modules. I get the input this way: >> >> input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') > > It doesn't make sense to use codecs.open() with a "b" mode. OK, thanks. >> big_json = json.load(input_source) > > You shouldn't decode the input before passing it into json.load(), just > open the file in binary mode. Serialised JSON is defined as being UTF-8 > encoded (or BOM-prefixed), not decoded Unicode. So just do input_source = open(input_file, 'rb') big_json = json.load(input_source) ? >> input_source.close() > > In case of a failure, the file will not be closed safely. All in all, use > this instead: > > with open(input_file, 'rb') as f: > big_json = json.load(f) OK, thanks. >> Then I recurse through the contents of big_json to build an instance >> of xml.dom.minidom.Document (the recursion includes some code to >> rewrite dict keys as valid element names if necessary) > > If the name "big_json" is supposed to hint at a large set of data, you may > want to use something other than minidom. Take a look at the > xml.etree.cElementTree module instead, which is substantially more memory > efficient. Well, the input file in this case contains one big JSON list of reasonably sized elements, each of which I'm turning into a separate XML file. The output files range from 600 to 6000 bytes. >> and I save the document: >> >> xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') >> doc.writexml(xml_file, encoding='UTF-8') >> xml_file.close() > > Same mistakes as above. Especially the double encoding is both unnecessary > and likely to fail. This is also most likely the source of your problems. Well actually, I had the problem with the occasional control characters in the output *before* I started sticking encoding="UTF-8" all over the place (in an unsuccessful attempt to beat them down). >> I thought this would force all the output to be valid, but xmlstarlet >> gives some errors like these on a few documents: >> >> PCDATA invalid Char value 7 >> PCDATA invalid Char value 31 > > This strongly hints at a broken encoding, which can easily be triggered by > your erroneous encode-and-encode cycles above. No, I've checked the JSON input and those exact control characters are there too. I want to suppress them (delete or replace with spaces). > Also, the kind of problem you present here makes it pretty clear that you > are using Python 2.x. In Python 3, you'd get the appropriate exceptions > when trying to write binary data to a Unicode file. Sorry, I forgot to mention the version I'm using, which is "2.7.2+". -- In the 1970s, people began receiving utility bills for -?999,999,996.32 and it became harder to sustain the myth of the infallible electronic brain. (Stob 2001) From cheap.meds4eu at gmail.com Tue Nov 29 08:00:22 2011 From: cheap.meds4eu at gmail.com (cheap meds) Date: Tue, 29 Nov 2011 05:00:22 -0800 (PST) Subject: Viagra - First and Best Cure for Erectile Dysfunction Message-ID: For over a decade Viagra has helped millions of men all over the world to restore their sex lives. Viagra is the medication that has proven to act best over erectile problems in men. This medication is so successful because of its chief key ingredient Sildenafil Citrate. Viagra works by relaxing the arterial wall which affect the penile erection since erection happens when blood circulates and remains in the penis. The primary benefit of Viagra is that it hardens the penis of a man making it erect and stiff so that he can have a satisfactory sexual intercourse. Secondly, Viagra is not required to be taken like a daily prescription drug. You can take it as early as 1 hour to 4 hours before your sexual activity and it would work just the same. Viagra should not be used with other treatments that cause erections. Buy Discount Viagra Online on www.cheap.meds4u.eu Your Satisfaction Reflects our Image! From andrea.crotti.0 at gmail.com Tue Nov 29 08:51:26 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 29 Nov 2011 13:51:26 +0000 Subject: python 2.5 and ast In-Reply-To: <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ED4E35E.6090405@gmail.com> On 11/29/2011 11:32 AM, Steven D'Aprano wrote: > > I prefer to check against sys.version. > > import sys > if sys.version<= '2.5': > from psi.devsonly.ast import parse, NodeVisitor > else: > from ast import parse, NodeVisitor > > > > Or even: > > > try: > from ast import parse, NodeVisitor > except ImportError: > from ast import parse, NodeVisitor > > > The try/except is probably the nicest... I've seen in other places using sys.version <=, but is it a good idea to rely on the fact that the <= on strings has the right semantic? After all that's just a string, version_info looks more correct to me.. From anacrolix at gmail.com Tue Nov 29 09:07:08 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Wed, 30 Nov 2011 01:07:08 +1100 Subject: Can I submit an issue with Python 2.5.6? In-Reply-To: References: Message-ID: Note the re.VERBOSE flag allows this whitespace treatment of the pattern. 2011/11/29 Toshiyuki Ogura : > Hi. > > I found a problem with Python 2.5.6. > test_commands fails when 'make test'. > bugs.python.org doesn't seem to have an option for Python 2.5 in "Versions:" > drop-down menu when creating an issue. > The problem seems to be the same as #11946. > http://bugs.python.org/issue11946 > I also made a patch for 2.5.6. > > --- Python-2.5.6/Lib/test/test_commands.py.orig??? 2006-06-29 > 04:10:08.000000000 +0000 > +++ Python-2.5.6/Lib/test/test_commands.py??? 2011-11-29 08:46:29.602607019 > +0000 > @@ -46,11 +46,7 @@ > ???????? #???? drwxr-xr-x?? 15 Joe User My Group???? 4096 Aug 12 12:50 / > ???????? # Note that the first case above has a space in the group name > ???????? # while the second one has a space in both names. > -? ?????? pat = r'''d.........?? # It is a directory. > -????????????????? \+?????????? # It may have ACLs. > -????????????????? \s+\d+?????? # It has some number of links. > -????????????????? [^/]*??????? # Skip user, group, size, and date. > -????????????????? /\.????????? # and end with the name of the file. > +??????? pat = r'''^.*(\/\.)[\ ]*[\n\r]*$ > ??????????&nbs p;???? ''' > > ???????? self.assert_(re.match(pat, getstatus("/."), re.VERBOSE)) > > > Can I submit the issue at bugs.python.org? > I think many people are still using Python 2.5 because of Google App Engine > and fixing bugs with 2.5 is still helpful. > > Toshiyuki Ogura > > > -- > http://mail.python.org/mailman/listinfo/python-list > From dihedral88888 at googlemail.com Tue Nov 29 09:19:55 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 29 Nov 2011 06:19:55 -0800 (PST) Subject: Executing .pyc using python c api In-Reply-To: <7mjeq8-ubf.ln1@satorlaser.homedns.org> References: <7mjeq8-ubf.ln1@satorlaser.homedns.org> Message-ID: <4302173.419.1322576395669.JavaMail.geo-discussion-forums@prnh1> On Tuesday, November 29, 2011 5:02:31 PM UTC+8, Ulrich Eckhardt wrote: > Am 29.11.2011 08:34, schrieb Mrinalini Kulkarni: > > I need to run .pyc files using python c api. if i do PyImport_Import it > > executes the script. However, i need to pass a set of variables and > > their values which will be accessed from within the script. How can this > > be done. > > I don't think what you want is possible, due to a think-o in your > design. Let me explain... > Firstly, .pyc files are basically the same as .py files, only in a > different presentation. Then, PyImport_Import is basically the same as > using "import" in a Python program. Now, and that is where your fault > lies, importing a module actually means executing that module! For > example, the definition of a function is code that when executed will > cause a function to be created and attached to the current scope with > the according name. This is what makes it so easy to implement local > functions that are parametrized by arguments to the outer function. > Still, a function is not something that is "static", like in C or Java, > but rather the result of executing its function definition. > > Now, how to get around this? The specialty about the import is that the > __name__ attribute is not set to "__main__", upon which many scripts > already react. So, in order to "prevent execution" (in the sense that > you probably mean), you simply wrap the according code in a function. > The function definition will then be executed, giving you a function > that you can call with the according parameters, but the function itself > will not be executed automatically. If you want that to happen when > executing the .pyc file directly, check the content of __name__ and call > the function if it is "__main__". > > Note that another approach would be introspection, traversing through > the namespaces to find out those parameters, but I would consider this > solution as hackish if the one above is feasible. > > Good luck! > > Uli Please use psyco and pyrex and C or whatever that can read saved results in a file, or just learn how to replace a hash or a sort in python's build in library of better speed, don't do reference overheads in those c type variables that won't overflow and underflow and used by other objects in python. Not trivial but well documented to cheer for a race! From stefan_ml at behnel.de Tue Nov 29 09:33:57 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 29 Nov 2011 15:33:57 +0100 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) In-Reply-To: References: <91j4q8xgv9.ln2@news.ducksburg.com> Message-ID: Adam Funk, 29.11.2011 13:57: > On 2011-11-28, Stefan Behnel wrote: >> Adam Funk, 25.11.2011 14:50: >>> Then I recurse through the contents of big_json to build an instance >>> of xml.dom.minidom.Document (the recursion includes some code to >>> rewrite dict keys as valid element names if necessary) >> >> If the name "big_json" is supposed to hint at a large set of data, you may >> want to use something other than minidom. Take a look at the >> xml.etree.cElementTree module instead, which is substantially more memory >> efficient. > > Well, the input file in this case contains one big JSON list of > reasonably sized elements, each of which I'm turning into a separate > XML file. The output files range from 600 to 6000 bytes. It's also substantially easier to use, but if your XML writing code works already, why change it. >>> and I save the document: >>> >>> xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') >>> doc.writexml(xml_file, encoding='UTF-8') >>> xml_file.close() >> >> Same mistakes as above. Especially the double encoding is both unnecessary >> and likely to fail. This is also most likely the source of your problems. > > Well actually, I had the problem with the occasional control > characters in the output *before* I started sticking encoding="UTF-8" > all over the place (in an unsuccessful attempt to beat them down). You should read up on Unicode a bit. >>> I thought this would force all the output to be valid, but xmlstarlet >>> gives some errors like these on a few documents: >>> >>> PCDATA invalid Char value 7 >>> PCDATA invalid Char value 31 >> >> This strongly hints at a broken encoding, which can easily be triggered by >> your erroneous encode-and-encode cycles above. > > No, I've checked the JSON input and those exact control characters are > there too. Ah, right, I didn't look closely enough. Those are forbidden in XML: http://www.w3.org/TR/REC-xml/#charsets It's sad that minidom (apparently) lets them pass through without even a warning. > I want to suppress them (delete or replace with spaces). Ok, then you need to process your string content while creating XML from it. If replacing is enough, take a look at string.maketrans() in the string module and str.translate(), a method on strings. Or maybe just use a regular expression that matches any whitespace character and replace it with a space. Or whatever suits your data best. >> Also, the kind of problem you present here makes it pretty clear that you >> are using Python 2.x. In Python 3, you'd get the appropriate exceptions >> when trying to write binary data to a Unicode file. > > Sorry, I forgot to mention the version I'm using, which is "2.7.2+". Yep, Py2 makes Unicode handling harder than it should be. Stefan From mlto at live.jp Tue Nov 29 10:17:50 2011 From: mlto at live.jp (Toshiyuki Ogura) Date: Wed, 30 Nov 2011 00:17:50 +0900 Subject: Can I submit an issue with Python 2.5.6? In-Reply-To: References: , Message-ID: I mistakenly posted the previous message in html format, and some rubbish text '&nbs p;' was unexpectedly inserted in the patch. I'll post the content of the patch again. Sorry for the inconvenience. --- Python-2.5.6/Lib/test/test_commands.py.orig??? 2006-06-29 04:10:08.000000000 +0000 +++ Python-2.5.6/Lib/test/test_commands.py??? 2011-11-29 08:46:29.602607019 +0000 @@ -46,11 +46,7 @@ ???????? #???? drwxr-xr-x?? 15 Joe User My Group???? 4096 Aug 12 12:50 / ???????? # Note that the first case above has a space in the group name ???????? # while the second one has a space in both names. -??????? pat = r'''d.........?? # It is a directory. -????????????????? \+?????????? # It may have ACLs. -????????????????? \s+\d+?????? # It has some number of links. -????????????????? [^/]*??????? # Skip user, group, size, and date. -????????????????? /\.????????? # and end with the name of the file. +??????? pat = r'''^.*(\/\.)[\ ]*[\n\r]*$ ??????????????? ''' ? ???????? self.assert_(re.match(pat, getstatus("/."), re.VERBOSE)) Toshiyuki Ogura From jmarcedwards at gmail.com Tue Nov 29 10:21:52 2011 From: jmarcedwards at gmail.com (J. Marc Edwards) Date: Tue, 29 Nov 2011 10:21:52 -0500 Subject: Amateur question on class definitions... Message-ID: <4ED4F890.70201@gmail.com> So I am defining my Python classes for a Django data model. I have a the following class hierarchy and would value some expert input on how to best implement this. I have many instances of a particular class which I call a "workflow", e.g. wf_1, wf_2, wf_3, etc. These class instances of workflows can be combined into "composite workflows", e.g. {cwf_1 is comprised of wf1 & wf_3}, {cwf_2 is wf_2 and wf_3}, or {cwf_3 is just wf_2}, etc. The workflows that constitute the composite workflow is positionally dependent, i.e. if cwf_1 is comprised of wf_1 and wf_3, then wf_1 comes 1st AND wf_3 is 2nd. As I have many workflow instances that accumulate in my persistent database (Django data model), then the composite workflows become an ordered collection of workflow instances. My first thought here is that the composite workflow class should have a field that is a simple list of workflows, i.e. list(workflows), but I am somewhat unsure of how to code this correctly. Here is a sample pseudo-code... class a_workflow(models.Model): ... class composite_workflow(models.Model): ...a list of "a_workflows", i.e. a composite workflow, should I use this syntax? set_of_workflows = list(a_workflow) Is this how a pro would do this? Regards, Marc -- J. Marc Edwards Lead Architect - Semiconductor Design Portals Nimbis Services, Inc. Skype: (919) 747-3775 Cell: (919) 345-1021 Fax: (919) 882-8602 marc.edwards at nimbisservices.com www.nimbisservices.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Nov 29 10:59:40 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 30 Nov 2011 02:59:40 +1100 Subject: Amateur question on class definitions... In-Reply-To: <4ED4F890.70201@gmail.com> References: <4ED4F890.70201@gmail.com> Message-ID: On Wed, Nov 30, 2011 at 2:21 AM, J. Marc Edwards wrote: > ??? ...a list of "a_workflows", i.e. a composite workflow, should I use this > syntax? > ??? set_of_workflows = list(a_workflow) > This would be usual: set_of_workflows = [a_workflow] Using the list() constructor directly is for when you have some other iterable; for instance, a string is iterable over its characters: >>> list("Hello") ['H', 'e', 'l', 'l', 'o'] When you want to wrap up a single object in a list, square brackets syntax is what you want. ChrisA From ian.g.kelly at gmail.com Tue Nov 29 11:38:19 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 29 Nov 2011 09:38:19 -0700 Subject: Amateur question on class definitions... In-Reply-To: <4ED4F890.70201@gmail.com> References: <4ED4F890.70201@gmail.com> Message-ID: On Tue, Nov 29, 2011 at 8:21 AM, J. Marc Edwards wrote: > So I am defining my Python classes for a Django data model.? I have a the > following class hierarchy and would value some expert input on how to best > implement this. > > I have many instances of a particular class which I call a "workflow", e.g. > wf_1, wf_2, wf_3, etc. > These class instances of workflows can be combined into "composite > workflows", e.g. {cwf_1 is comprised of wf1 & wf_3}, {cwf_2 is wf_2 and > wf_3}, or {cwf_3 is just wf_2}, etc. > The workflows that constitute the composite workflow is positionally > dependent, i.e. if cwf_1 is comprised of wf_1 and wf_3, then wf_1 comes 1st > AND wf_3 is 2nd. > As I have many workflow instances that accumulate in my persistent database > (Django data model), then the composite workflows become an ordered > collection of workflow instances. > > My first thought here is that the composite workflow class should have a > field that is a simple list of workflows, i.e. list(workflows), but I am > somewhat unsure of how to code this correctly. > > Here is a sample pseudo-code... > > class a_workflow(models.Model): > ... > > class composite_workflow(models.Model): > ??? ...a list of "a_workflows", i.e. a composite workflow, should I use this > syntax? > ??? set_of_workflows = list(a_workflow) > > Is this how a pro would do this? That would work in general, but since these are Django models I assume that this relationship will need to be stored in the database. You'll need to use a ManyToManyField instead. I would do something like this: class Workflow(models.Model): pass class CompositeWorkflow(models.Model): workflow_set = models.ManyToManyField('Workflow', through='CompositeWorkflowOrder') class CompositeWorkflowOrder(models.Model): workflow = models.ForeignKey('Workflow') composite_workflow = models.ForeignKey('CompositeWorkflow') sequence_num = models.IntegerField() The CompositeWorkflowOrder model is then responsible for tracking which workflows are contained by which composite workflows, and in what order they appear (using sequence_num). See the Django docs on ManyToManyFields for more info. Cheers, Ian From patentsvnc at gmail.com Tue Nov 29 12:11:26 2011 From: patentsvnc at gmail.com (Den) Date: Tue, 29 Nov 2011 09:11:26 -0800 (PST) Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed49aba$0$14018$c3e8da3$76491128@news.astraweb.com> Message-ID: <7de6a1b0-299e-468b-9ef2-9809643957a9@t16g2000vba.googlegroups.com> On Nov 29, 12:41?am, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 11:22:09 -0800, Den wrote: > > With respect, I disagree with advice that the use of a language > > construct should be rare. ?All constructs should be used > > *appropriately*. > > And if those appropriate conditions are rare, then the use of the > appropriate construct should also be rare. Since it is rare to need to > care about identity, use of `is` should be rare too. > > This is mostly descriptive statement rather than a prescriptive one: it > is a fact that use of `is` is much less common than use of ==, and even > more so if you disregard the obvious case of "x is None". > > I am however being a little prescriptive: if somebody thinks they need to > care about identity, chances are good -- but not certain -- that they're > mistaken. In code that gives you the choice between writing `is` and ==, > it is usually, but not often, a bug to write `is`. The proof of this is > that in actual, existing code, if you swapped == and `is`, most of the > code would stop working correctly. > > On the other hand if you actually do need to care about identity, then go > for it. I'm not saying that caring about identity should be prohibited, > only that in practice it is uncommon that you will. > > > While in general a particular use of a Python construct may be rare, if > > the programmer is involved deeply with that rare use, then it is NOT > > rare to him/her. > > Regardless of how common brain surgery might be to a brain surgeon, it is > rare in general. That's all I'm saying. If you happen to work for a data > recovery centre, then pulling the disk platter out of a hard disk drive > might be commonplace to you, nevertheless pulling platters out of disks > is vanishingly rare: out of tens of thousands of HDDs, perhaps only a few > dozen will be sent to a recover centre at all. > > [...] > > > Sorry, you plucked a string of mine. ?One does not throw a tool out of > > your tool box because it might be dangerous. ?Table saws are incredibly > > dangerous, but in the hands of a skilled operator can be competently and > > safely used to produce beautiful woodwork. ?To say *never* use a table > > saw because it's dangerous is silly. > > Fortunately, I didn't say "never". > > In the case of `is`, one shouldn't avoid using `is` because it is > dangerous, but merely because it is the wrong thing to use. In the same > way, the average programmer will rarely need to use the math.sinh and > math.cosh functions, not because they are bad, evil, or dangerous, but > because they are used for specialist purposes that most coders would > never care about. Hell, most coders rarely use the standard trigonometric > functions sin and cos, let alone the hyperbolic versions! This is not a > value judgement. > > If I, in a misplaced sense of egalitarianism ("Emancipation for maths > functions! Right on brothers!") decided to use sinh instead of sin > because they looked and sounded similar, my code would almost certain be > buggy. Likewise if I decided to use `is` instead of == because in English > they have similar meanings, my code would probably be buggy too. > > Sorry to belabour the point, but we're in violent agreement here > > -- > Steven ((laugh)) Yes, I believe we are. D From malaclypse2 at gmail.com Tue Nov 29 13:34:00 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 29 Nov 2011 13:34:00 -0500 Subject: Can I submit an issue with Python 2.5.6? In-Reply-To: References: Message-ID: 2011/11/29 Toshiyuki Ogura > I found a problem with Python 2.5.6. > ... > Can I submit the issue at bugs.python.org? > I think many people are still using Python 2.5 because of Google App > Engine and fixing bugs with 2.5 is still helpful. > I don't think they'll be accepted. Python 2.5 is not slated to receive any more releases, ever. Not even source-only security fixes. According to http://www.python.org/getit/releases/2.5.6/, "This release is the final release of Python 2.5; under the current release policy, no security issues in Python 2.5 will be fixed anymore." Given that they're not even accepting security patches, I'm sure they won't accept non-security bugfixes either. If your goal is to get your patch accepted and deployed on google's app engine infrastructure, you could try getting a hold of someone at google, and asking if they accept patches directly, since there will be no further maintenance from the core python developers. I have no idea how difficult it would be to do that, or if there's any interest in accepting patches against python 2.5 at google. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From dpalao.python at gmail.com Tue Nov 29 14:09:44 2011 From: dpalao.python at gmail.com (DPalao) Date: Tue, 29 Nov 2011 20:09:44 +0100 Subject: 70% [* SPAM *] multiprocessing.Queue blocks when sending large object Message-ID: <23330_1322593803_pATJ9jRv011464_201111292009.44527.dpalao.python@gmail.com> Hello, I'm trying to use multiprocessing to parallelize a code. There is a number of tasks (usually 12) that can be run independently. Each task produces a numpy array, and at the end, those arrays must be combined. I implemented this using Queues (multiprocessing.Queue): one for input and another for output. But the code blocks. And it must be related to the size of the item I put on the Queue: if I put a small array, the code works well; if the array is realistically large (in my case if can vary from 160kB to 1MB), the code blocks apparently forever. I have tried this: http://www.bryceboe.com/2011/01/28/the-python-multiprocessing-queue-and-large- objects/ but it didn't work (especifically I put a None sentinel at the end for each worker). Before I change the implementation, is there a way to bypass this problem with multiprocessing.Queue? Should I post the code (or a sketchy version of it)? TIA, David From python.list at tim.thechases.com Tue Nov 29 14:37:58 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 29 Nov 2011 13:37:58 -0600 Subject: cmd.Cmd asking questions? In-Reply-To: References: <4ED37A96.2090905@tim.thechases.com> Message-ID: <4ED53496.6070408@tim.thechases.com> On 11/28/11 06:27, Robert Kern wrote: > On 11/28/11 12:12 PM, Tim Chase wrote: >> I can monkey with printing messages and using raw_input(), >> but I'd like to know if there's a better way (such as >> something interacting with readline for >> text-entry-with-history-and-completion, > > If you import readline, then any following uses of > raw_input() will automatically use readline. You may want to > swap out the history when you use get_string() or confirm() so > they don't mess up the regular Cmd history, but the basic > functionality should work out-of-box. I didn't realize raw_input() was so nicely overloaded. After about 30 minutes of fighting with various bits of code (and learning that pdb's readline doesn't save/restore history), I tweaked up some "save the history; restore the history" wrapper which worked well. >> or raw-character input for Y/N answers rather than the need >> to hit, making it feel more uniform), > > I actually have a preference for needing to press enter for > Y/N answers, too. It's distinctly *less* uniform to have some > questions requiring an enter and some not. It can be > unpleasantly surprising to the user, too. After playing with it, allowing for a default Y/N value seems to make it a one-key selection via , but allow for less-surprising behavior as you detail. Thanks for your input (no pun intended), -tkc From colinh at somewhere.invalid Tue Nov 29 15:06:30 2011 From: colinh at somewhere.invalid (Colin Higwell) Date: Tue, 29 Nov 2011 20:06:30 +0000 (UTC) Subject: Total newbie question: Best practice Message-ID: Hi, I am just starting to learn Python (I have been at it only a few hours), so please bear with me. I have a few very small scripts (do you call them scripts or programs?) which work properly, and produce the results intended. However, they are monolithic in nature; i.e. they begin at the beginning and finish at the end. Having done a little reading, I note that it seems to be quite common to have a function main() at the start (which in turn calls other functions as appropriate), and then to call main() to do the work. Is that standard best practice? Thanks From arnodel at gmail.com Tue Nov 29 15:34:01 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 29 Nov 2011 20:34:01 +0000 Subject: Total newbie question: Best practice In-Reply-To: References: Message-ID: On 29 November 2011 20:06, Colin Higwell wrote: > Hi, Hi Colin, and welcome to Python :) > I am just starting to learn Python (I have been at it only a few hours), > so please bear with me. I have a few very small scripts (do you call them > scripts or programs?) which work properly, and produce the results > intended. I think you can call them either. > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other functions as appropriate), and then to call main() to do the > work. > > Is that standard best practice? When code should be put in a function is a matter of judgement in the end, so it's not an easy question. But roughly speaking: - if you need to perform the same task at several points in you program, then it's a good idea to put this in a function. It avoids duplication of code, minimises the chances for bugs, makes the program easier to read (provided you find a nice name for the function!) and also improves testability. - if there is a task that could be performed is several different ways but with the same result, then it's good to put in a function. This way when reading the program you can focus on the important thing, which is the result of the process, without being distracted by the details of how the result is arrived at. Moreover, it gives you added flexibility as you can later try a different method for performing the same task and very easily plug it into your existing program to see if it improves performance for example. - if you have a piece of code which is too long to be understood easily, consider whether you could break it down into smaller bits, each of which has some meaning of its own, and make each bit into a function with a name that describes clearly what it does. Then rewrite your big piece of code in terms of these functions. It will make your program a lot easier to understand when you come back to it in the future. As for the main() function, I don't think it is standard practice in Python. There is no requirement to have a main() function. You can use the idiom: if __name__ == "__main__": ... which will execute if you call the file as a script (as opposed to importing it as a module) -- Arnaud From rosuav at gmail.com Tue Nov 29 15:36:35 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 30 Nov 2011 07:36:35 +1100 Subject: Total newbie question: Best practice In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 7:06 AM, Colin Higwell wrote: > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other functions as appropriate), and then to call main() to do the > work. The reason for this practice is to allow your .py file to be either a top-level program or an imported module. if __name__ == "__main__": main() When you run a .py file directly, __name__ will be "__main__", and it'll execute main(). (Some programs directly embed the main routine in that if block - appropriate if main() would be very short, eg just calling some other function.) But if you import it as a module in some other program, that won't be the case; so instead, the module's functions are made available to the calling program. For simple scripts that don't have anything to offer as a module, it's fine to not bother with this structure. Python doesn't demand syntactic salt; that's one of its greatest features, IMHO. Chris Angelico From neilc at norwich.edu Tue Nov 29 16:12:48 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 29 Nov 2011 21:12:48 GMT Subject: Total newbie question: Best practice References: Message-ID: <9jl06gFg9oU1@mid.individual.net> On 2011-11-29, Arnaud Delobelle wrote: > As for the main() function, I don't think it is standard > practice in Python. There is no requirement to have a main() > function. You can use the idiom: I don't start off with a main function, but if my script gets long and complicated, or if global names have proliferated and have become confusing, I'll refactor the whole thing into functions, including a "main". With most globals moved into main's namespace, calling subroutines from main forces me to define the context that's actually necessary for each part of the program. The resultant refactored programs are much easier to test, read and maintain. TLDR: "Called-only-once" functions like main are useful as documentation, hooks for testing, and for unraveling a snarl of global variables. -- Neil Cerutti From d at davea.name Tue Nov 29 16:57:18 2011 From: d at davea.name (Dave Angel) Date: Tue, 29 Nov 2011 16:57:18 -0500 Subject: Total newbie question: Best practice In-Reply-To: References: Message-ID: <4ED5553E.4050104@davea.name> On 11/29/2011 03:06 PM, Colin Higwell wrote: > Hi, > > I am just starting to learn Python (I have been at it only a few hours), > so please bear with me. I have a few very small scripts (do you call them > scripts or programs?) which work properly, and produce the results > intended. > > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other functions as appropriate), and then to call main() to do the > work. > > Is that standard best practice? > > Thanks > Welcome to Python, and to the comp.lang.python list. Is this your first experience programming? Yes, factoring your code from "monolithic" to "modular' (several functions, or even functions and classes), is good practice. That's not to say that some problems don't deserve a monolithic answer, but if you're a beginner, i'd like to see you get into a modular habit. You can use the words script and program pretty much interchangeably. in some contexts, each has additional connotations. For example, somebody used to a compiled language may refer to a python source file as a script, implying it's not as sophisticated as his own product. But, closer to home, we usually refer to the file you directly pass to the interpreter as a script, and any added files that get imported, as modules, or libraries. Other times, people will refer to a simple program as a script, implying that all it does is invoke some standard library functions, or even run some external programs. But when it gets more complex, it gradually turns into a "real program." Why break up a monolith? Several reasons. If you factor the code into independent functions, and give them good names, then each piece of the program is easier to understand. You will especially appreciate that if you come back to the code after doing something else for two weeks. Similarly if somebody else has to take over your code, or maybe adapt it to a slightly different purpose. Next, if it doesn't quite work, you can exercise the individual pieces independently, and narrow down the problem more quickly. Next, if the progfram is slow, usually you can narrow it down to a few key functions that take most of the time. You can write two versions of the same function, and do some careful timings to decide which one to use. Next, some of those functions may be useful in the next program you write. If you "reuse" the code by copy & paste, and find a problem in the new one, it's quite possible that the same problem may exist in your first program. it's easier to bring those changes back if they're in a function than if they're in lines 14 through 71. Finally, some of that reusable code may be worth moving to an external file, called a module. Then the same copy can be literally shared between multiple projects. This is how libraries were born, and you can write your own, eventually. there are many other reasons, but some of them might not make sense to you yet. How do you break it up? First, separate the classic parts that most scripts will have. Put the imports at the top, along with a comment describing the whole progfram's purpose. Next put the global variables, which should be few. If there are any constants, use all UPPERCASE for their names. Next, put the function and class definitions. Notice that none of them will be called yet, so the order of execution isn't important to the compiler. Each function needs a name, and you should use a name that makes sense to you. Try to write functions that work at a single level of complexity, and do one complete operation. Try not to do input/output in the same functions that do the computation. And finally, put the actual mainline. It could be as simple as a call to main(), but it may make more sense to you to put the calls to argument processing here, rather than in a main function. By arguments here, i'm referring to the stuff you typed on the command line when youi invoked the script. This part of the code is where you do the magic incantation: if __name__ == "__main__": main() When the number of functions gets unwieldy, it's time to move some of them to a new file. They should be related, and should work at the same level of complexity. And the file name should remind you of their purpose. At that point, you add an import of that file to your main source script. Congratulations, you've created a module. One catch with writing a lengthy reply is that others have already given you good feedback. Hopefully, mine will complement theirs. -- DaveA From xahlee at gmail.com Tue Nov 29 17:53:15 2011 From: xahlee at gmail.com (Xah Lee) Date: Tue, 29 Nov 2011 14:53:15 -0800 (PST) Subject: Programing Language: latitude-longitude-decimalize Message-ID: fun programing exercise. Write a function ?latitude-longitude- decimalize?. It should take a string like this: ?"37?26?36.42?N 06?15?14.28?W"?. The return value should be a pair of numbers, like this: ?[37.44345 -6.25396]?. Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp solution in a couple of days. Xah From colinh at somewhere.invalid Tue Nov 29 18:08:30 2011 From: colinh at somewhere.invalid (Colin Higwell) Date: Tue, 29 Nov 2011 23:08:30 +0000 (UTC) Subject: Total newbie question: Best practice References: Message-ID: On Tue, 29 Nov 2011 16:57:18 -0500, Dave Angel wrote: > On 11/29/2011 03:06 PM, Colin Higwell wrote: >> Hi, >> >> I am just starting to learn Python (I have been at it only a few >> hours), so please bear with me. I have a few very small scripts (do you >> call them scripts or programs?) which work properly, and produce the >> results intended. >> >> However, they are monolithic in nature; i.e. they begin at the >> beginning and finish at the end. Having done a little reading, I note >> that it seems to be quite common to have a function main() at the start >> (which in turn calls other functions as appropriate), and then to call >> main() to do the work. >> >> Is that standard best practice? >> >> Thanks >> > Welcome to Python, and to the comp.lang.python list. Is this your first > experience programming? > > Yes, factoring your code from "monolithic" to "modular' (several > functions, or even functions and classes), is good practice. > > That's not to say that some problems don't deserve a monolithic answer, > but if you're a beginner, i'd like to see you get into a modular habit. > > You can use the words script and program pretty much interchangeably. > in some contexts, each has additional connotations. For example, > somebody used to a compiled language may refer to a python source file > as a script, implying it's not as sophisticated as his own product. > But, closer to home, we usually refer to the file you directly pass to > the interpreter as a script, and any added files that get imported, as > modules, or libraries. > > Other times, people will refer to a simple program as a script, implying > that all it does is invoke some standard library functions, or even run > some external programs. But when it gets more complex, it gradually > turns into a "real program." > > > Why break up a monolith? > > Several reasons. If you factor the code into independent functions, and > give them good names, then each piece of the program is easier to > understand. You will especially appreciate that if you come back to the > code after doing something else for two weeks. Similarly if somebody > else has to take over your code, or maybe adapt it to a slightly > different purpose. > > Next, if it doesn't quite work, you can exercise the individual pieces > independently, and narrow down the problem more quickly. > > Next, if the progfram is slow, usually you can narrow it down to a few > key functions that take most of the time. You can write two versions of > the same function, and do some careful timings to decide which one to > use. > > Next, some of those functions may be useful in the next program you > write. If you "reuse" the code by copy & paste, and find a problem in > the new one, it's quite possible that the same problem may exist in your > first program. it's easier to bring those changes back if they're in a > function than if they're in lines 14 through 71. > > Finally, some of that reusable code may be worth moving to an external > file, called a module. Then the same copy can be literally shared > between multiple projects. This is how libraries were born, and you can > write your own, eventually. > > there are many other reasons, but some of them might not make sense to > you yet. > > > How do you break it up? > > First, separate the classic parts that most scripts will have. Put the > imports at the top, along with a comment describing the whole progfram's > purpose. Next put the global variables, which should be few. If there > are any constants, use all UPPERCASE for their names. > > Next, put the function and class definitions. Notice that none of them > will be called yet, so the order of execution isn't important to the > compiler. Each function needs a name, and you should use a name that > makes sense to you. Try to write functions that work at a single level > of complexity, and do one complete operation. Try not to do > input/output in the same functions that do the computation. > > And finally, put the actual mainline. It could be as simple as a call > to main(), but it may make more sense to you to put the calls to > argument processing here, rather than in a main function. By arguments > here, i'm referring to the stuff you typed on the command line when youi > invoked the script. This part of the code is where you do the magic > incantation: > > if __name__ == "__main__": > main() > > > > When the number of functions gets unwieldy, it's time to move some of > them to a new file. They should be related, and should work at the same > level of complexity. And the file name should remind you of their > purpose. At that point, you add an import of that file to your main > source script. Congratulations, you've created a module. > > One catch with writing a lengthy reply is that others have already given > you good feedback. Hopefully, mine will complement theirs. Thank you, and thanks also to all the other respondents. I have programmed before in a number of other languages, but there is still plenty in this thread for me to digest. From mickyhulse.lists at gmail.com Tue Nov 29 18:29:29 2011 From: mickyhulse.lists at gmail.com (Micky Hulse) Date: Tue, 29 Nov 2011 15:29:29 -0800 Subject: Programing Language: latitude-longitude-decimalize In-Reply-To: References: Message-ID: Last time I did this was using AS3. The format I used was DMS: GPSLongitude: 122,42,47.79 GPSLongitudeRef: W GPSLatitude: 45,30,30.390001198897014 GPSLatitudeRef: N Here's the method: Not shown in above code: If West longitude or South latitude I would make that DD (decimal degree) value negative. Anyway, that was a fun learning experience! :) From ian.g.kelly at gmail.com Tue Nov 29 18:49:18 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 29 Nov 2011 16:49:18 -0700 Subject: Programing Language: latitude-longitude-decimalize In-Reply-To: References: Message-ID: On Tue, Nov 29, 2011 at 3:53 PM, Xah Lee wrote: > fun programing exercise. Write a function ?latitude-longitude- > decimalize?. > > It should take a string like this: ?"37?26?36.42?N 06?15?14.28?W"?. > The return value should be a pair of numbers, like this: ?[37.44345 > -6.25396]?. > > Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp > solution in a couple of days. For Python 3: import re def latitude_longitude_decimalize(string): regex = r"""(\d+)\xb0(\d+)'([\d+.]+)"([NS])\s*(\d+)\xb0(\d+)'([\d+.]+)"([EW])""" match = re.match(regex, string) if not match: raise ValueError("Invalid input string: {0:r}".format(string)) def decimalize(degrees, minutes, seconds, direction): decimal = int(degrees) + int(minutes) / 60 + float(seconds) / 3600 if direction in 'SW': decimal = -decimal return decimal latitude = decimalize(*match.groups()[:4]) longitude = decimalize(*match.groups()[4:8]) return latitude, longitude From thad at thadlabs.com Tue Nov 29 18:50:33 2011 From: thad at thadlabs.com (Thad Floryan) Date: Tue, 29 Nov 2011 15:50:33 -0800 Subject: Programing Language: latitude-longitude-decimalize In-Reply-To: References: Message-ID: <4ED56FC9.5020007@thadlabs.com> On 11/29/2011 2:53 PM, Xah Lee wrote: > fun programing exercise. Write a function ?latitude-longitude- > decimalize?. > > It should take a string like this: ?"37?26?36.42?N 06?15?14.28?W"?. > The return value should be a pair of numbers, like this: ?[37.44345 > -6.25396]?. > > Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp > solution in a couple of days. What a waste of time when the following works fine (probably Java): From Bruce.Nairn at kingcounty.gov Tue Nov 29 19:12:54 2011 From: Bruce.Nairn at kingcounty.gov (Nairn, Bruce) Date: Tue, 29 Nov 2011 16:12:54 -0800 Subject: pythoncom on Windows Server 2008 Message-ID: Hi, I'm trying to move some code to a Windows Server 2008 machine. It runs on Windows 7 and XP, but fails on Windows Server 2008. The python installation is seemingly identical (python 2.6.4, 32 bit). The following replicates the problem: import pythoncom IDispatch = pythoncom.CoCreateInstance ('OPC.Automation', None, pythoncom.CLSCTX_SERVER, pythoncom.IID_IDispatch) On Windows 7 x64 or Windows XP x32: this returns an PyIDispatch object On Windows Server 2008 x64 this gives: com_error: (-2147221005, 'Invalid class string', None, None) Any suggestions would be appreciated! Bruce Nairn King County Wastewater Treatment Division 201 S Jackson St., KSC-NR-0503 Seattle, WA, 98104-3855 206-263-3693 email: bruce.nairn at kingcounty.gov -------------- next part -------------- An HTML attachment was scrubbed... URL: From irmen.NOSPAM at xs4all.nl Tue Nov 29 19:20:10 2011 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Wed, 30 Nov 2011 01:20:10 +0100 Subject: why is bytearray treated so inefficiently by pickle? In-Reply-To: References: <4ed24a33$0$6869$e4fe514c@news2.news.xs4all.nl> Message-ID: <4ed576bb$0$6908$e4fe514c@news2.news.xs4all.nl> On 28-11-2011 3:09, Terry Reedy wrote: > Possibly. The two developers listed as particularly interested in pickle are > 'alexandre.vassalotti,pitrou' (antoine), so if you do open a tracker issue, add them as > nosy. > > Take a look at http://www.python.org/dev/peps/pep-3154/ > by Antoine Pitrou or forwary your message to him. > Created a bug report + patches, http://bugs.python.org/issue13503 I've read the PEP, thanks, it was interesting. But I don't think my changes require a new pickle protocol version bump. Irmen From skippy.hammond at gmail.com Tue Nov 29 19:34:23 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 30 Nov 2011 11:34:23 +1100 Subject: pythoncom on Windows Server 2008 In-Reply-To: References: Message-ID: <4ED57A0F.6080805@gmail.com> On 30/11/2011 11:12 AM, Nairn, Bruce wrote: > Hi, > > I?m trying to move some code to a Windows Server 2008 machine. It runs > on Windows 7 and XP, but fails on Windows Server 2008. The python > installation is seemingly identical (python 2.6.4, 32 bit). The > following replicates the problem: > > import pythoncom > > IDispatch = pythoncom.CoCreateInstance (?OPC.Automation?, None, > pythoncom.CLSCTX_SERVER, pythoncom.IID_IDispatch) > > On Windows 7 x64 or Windows XP x32: > > this returns an PyIDispatch object > > On Windows Server 2008 x64 this gives: > > com_error: (-2147221005, ?Invalid class string?, None, None) > > Any suggestions would be appreciated! The OPC.Automation object isn't installed on the Server 2008 box. I'm not sure what this object is so can't advise on how to install it. Note also that you will need the same "bittedness" of the object as Python itself has - ie, assuming a 32bit Python, you need the 32bit implementation of the COM object, or if a 64bit Python, you need the 64bit COM object. Note that both the 32 and 64bit versions of both will work fine on a 64bit version of Windows - you just need to make sure they match. Mark From jurgenex at hotmail.com Tue Nov 29 20:14:23 2011 From: jurgenex at hotmail.com (Jürgen Exner) Date: Tue, 29 Nov 2011 17:14:23 -0800 Subject: Programing Language: latitude-longitude-decimalize References: <4ED56FC9.5020007@thadlabs.com> Message-ID: Thad Floryan wrote: >On 11/29/2011 2:53 PM, Xah Lee wrote: Please do not reply to the eternal troll Thanks jue From thad at thadlabs.com Tue Nov 29 21:10:17 2011 From: thad at thadlabs.com (Thad Floryan) Date: Tue, 29 Nov 2011 18:10:17 -0800 Subject: Programing Language: latitude-longitude-decimalize In-Reply-To: References: <4ED56FC9.5020007@thadlabs.com> Message-ID: <4ED59089.4000101@thadlabs.com> On 11/29/2011 5:14 PM, J?rgen Exner wrote: > Thad Floryan wrote: >> On 11/29/2011 2:53 PM, Xah Lee wrote: > > Please do not reply to the eternal troll > > Thanks Mea culpa, you're correct. I responded only because the subject is something with which I'm familiar, e.g., one of my posts from 1988 (23 years ago): and :-) From iamforufriends at gmail.com Tue Nov 29 21:42:22 2011 From: iamforufriends at gmail.com (sweet girl) Date: Tue, 29 Nov 2011 18:42:22 -0800 (PST) Subject: This girl want a boy friend for dating Message-ID: This girl want a boy friend for dating http://goo.gl/vPGGP http://goo.gl/vPGGP http://goo.gl/vPGGP http://goo.gl/vPGGP From cs at zip.com.au Tue Nov 29 22:30:38 2011 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 30 Nov 2011 14:30:38 +1100 Subject: cmd.Cmd asking questions? In-Reply-To: <4ED53496.6070408@tim.thechases.com> References: <4ED53496.6070408@tim.thechases.com> Message-ID: <20111130033038.GA19431@cskk.homeip.net> On 29Nov2011 13:37, Tim Chase wrote: | On 11/28/11 06:27, Robert Kern wrote: [...] | >I actually have a preference for needing to press enter for | >Y/N answers, too. It's distinctly *less* uniform to have some | >questions requiring an enter and some not. It can be | >unpleasantly surprising to the user, too. | | After playing with it, allowing for a default Y/N value seems to | make it a one-key selection via , but allow for | less-surprising behavior as you detail. As a matter of good practice, I like default responses (especially yes/no ones) to default to the safer/more-conservative choice, and generally to default to "no", with the question suitably framed so that "no" means "safer/more-conservative". In this way an accidental unthinking has less chance of doing damage. What that means depends on context, but I hope you take the point. (Oh yes, traditionally the default is also capitalised to be evident.) Example: Remove your database now? (y/N) I would want to mean "no" here, usually. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ There are old climbers, and there are bold climbers; but there are no old bold climbers. From k.sahithi2862 at gmail.com Tue Nov 29 22:52:38 2011 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Tue, 29 Nov 2011 19:52:38 -0800 (PST) Subject: XXX HOT PHOTOS&VIDEOS Message-ID: <6118c841-8e22-4601-9102-bdac88037cac@cu3g2000vbb.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ SHRUTI HASSAN HOT IN 3 MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/shruti-hassan-in-3-movie.html PANJA MOVIE LATEST STILLS http://actressgallery-kalyani.blogspot.com/2011/11/panja-movie-stills.html URIMI LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/urimi-movie-stills.html NIPPU MOVIE WORKING STILLS http://actressgallery-kalyani.blogspot.com/2011/11/nippu-movie-stills.html ROUDRAM MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/roudram-movie-stills.html SIMHAPUTHRUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/simhaputhrudu-movie-stills.html SOLO MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/solo-movie-stills.html BEZAWADA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/bezawada-movie-stills.html RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS PAYAL GHOSH HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/payal-ghosh-hot.html PARVATHI MELTON LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/parvathi-melton-hot.html SARAH JANE DIAS HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/sarah-jane-dias-hot.html KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html POONAM KAUR HOT ROMANTIC STILLS http://hotactress-kalyani.blogspot.com/2011/11/poonam-kaur-hot.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From alec.taylor6 at gmail.com Tue Nov 29 23:49:29 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 30 Nov 2011 15:49:29 +1100 Subject: Converting MS Access DB to Postgres or MySQL for ORM support with SQLalchemy Message-ID: Good afternoon, I was recently shown that my client runs MS Access everywhere, rather than a "real" database. There are many features they would be missing that something like a django frontend would provide. So I would like to move them to Postgres or MySQL (since MS Access support was been dropped after 0.4). But I would also like to move there schema &etc to ORM, for easy editing with SQLalchemy (or similar). What approach would you recommend? Thanks for all suggestions, Alec Taylor From guojunquan at gmail.com Wed Nov 30 01:20:30 2011 From: guojunquan at gmail.com (=?UTF-8?B?6YOt5Yab5p2D?=) Date: Wed, 30 Nov 2011 14:20:30 +0800 Subject: How convert a list string to a real list Message-ID: Good after I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it to a list like list = ["aaaa","bbbb","ccc"],what can id do? Thanks. -- ??? ??????????????? guojunquan{at}gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Wed Nov 30 01:24:59 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 30 Nov 2011 17:24:59 +1100 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: import json s = json.dumps([1, 2, 3, 4]) # '[1, 2, 3, 4]' l = json.loads(s) # [1, 2, 3, 4] 2011/11/30 ??? : > Good after > I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert > it to a list like list = ["aaaa","bbbb","ccc"],what can id do? > Thanks. > > > -- > ??? > ??????????????? > guojunquan{at}gmail.com > > > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Wed Nov 30 01:54:22 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Nov 2011 01:54:22 -0500 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: On 11/30/2011 1:20 AM, ??? wrote: > Good after > I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it > to a list like list = ["aaaa","bbbb","ccc"],what can id do? The easiest -- and most dangerous -- way is >>> eval('["aaaa","bbbb","ccc"]') ['aaaa', 'bbbb', 'ccc'] But DO NOT eval unexamined strings from untrusted sources. The reason is that it is much the same as letting an untrusted person sit unsupervised as the keyboard of your computer with a command window open. You would not want to eval "from os import system; system('')" where '' is replaced by something obnoxious for your operating system. -- Terry Jan Reedy From arnodel at gmail.com Wed Nov 30 02:09:48 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 30 Nov 2011 07:09:48 +0000 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: On Nov 30, 2011 6:21 AM, "???" wrote: > > Good after > I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it to a list like list = ["aaaa","bbbb","ccc"],what can id do? > Thanks. > Look up the json module. -- Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Wed Nov 30 02:23:08 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 30 Nov 2011 18:23:08 +1100 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: Arnaud: Already showed that solution On Wed, Nov 30, 2011 at 6:09 PM, Arnaud Delobelle wrote: > > On Nov 30, 2011 6:21 AM, "???" wrote: >> >> Good after >> ? ? I have a string ?liststr = '["aaaa","bbbb","ccc"]' ,and I need convert >> it to a list like list =?["aaaa","bbbb","ccc"],what can id do? >> Thanks. >> > > Look up the json module. > > -- > Arnaud > > > -- > http://mail.python.org/mailman/listinfo/python-list > From Shambhu.Rajak at kpitcummins.com Wed Nov 30 03:50:19 2011 From: Shambhu.Rajak at kpitcummins.com (Shambhu Rajak) Date: Wed, 30 Nov 2011 08:50:19 +0000 Subject: Total newbie question: Best practice In-Reply-To: References: Message-ID: <408F64D89899604FB24015E64E10490C179CAB10@KCHJEXMB02.kpit.com> Collins Congratulations for your first step into Python Programming. You can call them script or programs(not necessarily but depends on what your coding for). Yaa..it's always a good practice to call it through main(), but it doesn't really matter you can call the method in way.... Regards, Shambhu -----Original Message----- From: Colin Higwell [mailto:colinh at somewhere.invalid] Sent: 30/11/2011 1:37 AM To: python-list at python.org Subject: Total newbie question: Best practice Hi, I am just starting to learn Python (I have been at it only a few hours), so please bear with me. I have a few very small scripts (do you call them scripts or programs?) which work properly, and produce the results intended. However, they are monolithic in nature; i.e. they begin at the beginning and finish at the end. Having done a little reading, I note that it seems to be quite common to have a function main() at the start (which in turn calls other functions as appropriate), and then to call main() to do the work. Is that standard best practice? Thanks From __peter__ at web.de Wed Nov 30 03:58:08 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Nov 2011 09:58:08 +0100 Subject: How convert a list string to a real list References: Message-ID: Terry Reedy wrote: > On 11/30/2011 1:20 AM, ??? wrote: >> Good after >> I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it >> to a list like list = ["aaaa","bbbb","ccc"],what can id do? > > The easiest -- and most dangerous -- way is > >>> eval('["aaaa","bbbb","ccc"]') > ['aaaa', 'bbbb', 'ccc'] > > But DO NOT eval unexamined strings from untrusted sources. The reason is > that it is much the same as letting an untrusted person sit unsupervised > as the keyboard of your computer with a command window open. You would > not want to eval > "from os import system; system('')" > where '' is replaced by something obnoxious for your > operating system. You can avoid these problems with ast.literal_eval(): literal_eval(node_or_string) Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None. From jasonveldicott at gmail.com Wed Nov 30 04:34:23 2011 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Wed, 30 Nov 2011 20:34:23 +1100 Subject: Debug python from DLL callback? Message-ID: Hi, I am wondering if anyone here might be able to suggest if there is a way of switching over from python execution into debug mode of an IDE, from python code that is executed as a callback from a C++ DLL? Thanks Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From fabiofz at gmail.com Wed Nov 30 04:48:19 2011 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 30 Nov 2011 07:48:19 -0200 Subject: Debug python from DLL callback? In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 7:34 AM, Jason Veldicott wrote: > Hi, > > I am wondering if anyone here might be able to suggest if there is a way of > switching over from python execution into debug mode of an IDE, from python > code that is executed as a callback from a C++ DLL? > Use a remote debugger: http://pydev.org/manual_adv_remote_debugger.html Cheers, Fabio From robert.kern at gmail.com Wed Nov 30 05:05:52 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 30 Nov 2011 10:05:52 +0000 Subject: cmd.Cmd asking questions? In-Reply-To: <20111130033038.GA19431@cskk.homeip.net> References: <4ED53496.6070408@tim.thechases.com> <20111130033038.GA19431@cskk.homeip.net> Message-ID: On 11/30/11 3:30 AM, Cameron Simpson wrote: > On 29Nov2011 13:37, Tim Chase wrote: > | On 11/28/11 06:27, Robert Kern wrote: > [...] > |>I actually have a preference for needing to press enter for > |>Y/N answers, too. It's distinctly *less* uniform to have some > |>questions requiring an enter and some not. It can be > |>unpleasantly surprising to the user, too. > | > | After playing with it, allowing for a default Y/N value seems to > | make it a one-key selection via, but allow for > | less-surprising behavior as you detail. > > As a matter of good practice, I like default responses (especially > yes/no ones) to default to the safer/more-conservative choice, and > generally to default to "no", with the question suitably framed so that > "no" means "safer/more-conservative". > > In this way an accidental unthinking has less chance of doing > damage. What that means depends on context, but I hope you take the point. > > (Oh yes, traditionally the default is also capitalised to be evident.) > > Example: > > Remove your database now? (y/N) > > I would want to mean "no" here, usually. I would also add that if you can, try to make it such that the user can go back and change their mind before actually doing anything. In the "wizard" scenario that the OP describes, it is frequently the case that you are going to ask a number of questions first before actually doing anything rather than doing something after each question. I don't think that letting the user go back a previous question is particularly common, and every interface for it that I can think of off the top of my head seems awkward, but I think it deserves some thought. At the very least, what you can do is collect all of the answers, show them to the user at the end and ask if there is anything the user wants to change before continuing. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From ben.richardson at gmx.com Wed Nov 30 05:42:26 2011 From: ben.richardson at gmx.com (Ben Richardson) Date: Wed, 30 Nov 2011 02:42:26 -0800 (PST) Subject: Python crashes on segmentation error Message-ID: <8bffed0f-1050-418a-834d-f7060a899ab7@h5g2000yqk.googlegroups.com> Hi! Python crashes every time i run the following command? >>> import cv Segmentation fault: 11 Python quit unexpectedly - any help would be greatly appreciated - thankyou in advance :) Here is crash report? Process: Python [276] Path: /Library/Frameworks/Python.framework/Versions/2.7/ Resources/Python.app/Contents/MacOS/Python Identifier: Python Version: ??? (???) Code Type: X86-64 (Native) Parent Process: bash [271] Date/Time: 2011-11-30 21:40:17.798 +1100 OS Version: Mac OS X 10.7.2 (11C74) Report Version: 9 Interval Since Last Report: 34062 sec Crashes Since Last Report: 3 Per-App Crashes Since Last Report: 3 Anonymous UUID: 559858AC-B741-4FB9-842D- C0E1D157BDFF Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 VM Regions Near 0: --> __TEXT 0000000100000000-0000000100001000 [ 4K] r-x/rwx SM=COW /Library/Frameworks/Python.framework/Versions/2.7/ Resources/Python.app/Contents/MacOS/Python Application Specific Information: objc[276]: garbage collection is OFF Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 ??? 000000000000000000 0 + 0 1 org.python.python 0x00000001006c7885 PyImport_Import + 121 2 org.python.python 0x00000001006c7a1e PyImport_ImportModule + 32 3 cv.so 0x00000001004f5082 initcv + 18 4 org.python.python 0x00000001000dc071 _PyImport_LoadDynamicModule + 177 5 org.python.python 0x00000001000da33f import_submodule + 383 6 org.python.python 0x00000001000da84a load_next + 234 7 org.python.python 0x00000001000dab5b PyImport_ImportModuleLevel + 363 8 org.python.python 0x00000001000b9483 builtin___import__ + 131 9 org.python.python 0x000000010000c5e2 PyObject_Call + 98 10 org.python.python 0x00000001000ba5f7 PyEval_CallObjectWithKeywords + 87 11 org.python.python 0x00000001000bec78 PyEval_EvalFrameEx + 13256 12 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 13 org.python.python 0x00000001000c2e46 PyEval_EvalCode + 54 14 org.python.python 0x00000001000e769c PyRun_InteractiveOneFlags + 380 15 org.python.python 0x00000001000e78fe PyRun_InteractiveLoopFlags + 78 16 org.python.python 0x00000001000e80e1 PyRun_AnyFileExFlags + 161 17 org.python.python 0x00000001000fe77c Py_Main + 2940 18 org.python.python 0x0000000100000f14 0x100000000 + 3860 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000100781870 rbx: 0x00000001019b3030 rcx: 0x00007fff5fbfe968 rdx: 0x0000000000000000 rdi: 0x0000000000000000 rsi: 0x00000001006f5ebc rbp: 0x00007fff5fbfea60 rsp: 0x00007fff5fbfea58 r8: 0x0800000000000100 r9: 0x2000000000000200 r10: 0x0000000000000000 r11: 0x00000001019b6054 r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x00000001019b3030 r15: 0x00007fff5fbfeb80 rip: 0x0000000000000000 rfl: 0x0000000000010206 cr2: 0x0000000000000000 Logical CPU: 1 Binary Images: 0x100000000 - 0x100000fff +org.python.python (2.7.2 - 2.7.2) <639E72E4-F205-C034-8E34-E59DE9C46369> /Library/Frameworks/ Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/ Python 0x100003000 - 0x10016cfef +org.python.python (2.7.2, [c] 2004-2011 Python Software Foundation. - 2.7.2) <49D18B1A-C92D-E32E- A7C1-086D0B14BD76> /Library/Frameworks/Python.framework/Versions/2.7/ Python 0x1002eb000 - 0x1002edfff +readline.so (??? - ???) <25AB2CA6-C3CC-9F24-F619-C85D51AD8A38> /Library/Frameworks/ Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so 0x1002f4000 - 0x1002f7fff +libopencv_flann.2.2.dylib (2.2.0 - compatibility 2.2.0) / usr/local/lib/libopencv_flann.2.2.dylib 0x1004b0000 - 0x1004d4fff libedit.2.dylib (3.0.0 - compatibility 2.0.0) /usr/lib/ libedit.2.dylib 0x1004e4000 - 0x1005fcff7 +cv.so (??? - ???) /usr/local/lib/python2.6/site- packages/cv.so 0x100632000 - 0x10073efff org.python.python (2.6.7 - 2.6.7) /System/Library/ Frameworks/Python.framework/Versions/2.6/Python 0x10079f000 - 0x1007d2ff7 +libopencv_video.2.2.dylib (2.2.0 - compatibility 2.2.0) <152DFA46-7D58-336B-B773-860D856A6FB7> / usr/local/lib/libopencv_video.2.2.dylib 0x101000000 - 0x10128fff7 +libopencv_core.2.2.dylib (2.2.0 - compatibility 2.2.0) <1FD2FD64-F301-31C7-836E-E2E283247BD7> / usr/local/lib/libopencv_core.2.2.dylib 0x1012d2000 - 0x10146ffe7 +libopencv_imgproc.2.2.dylib (2.2.0 - compatibility 2.2.0) <8FB2C0B0-ABA9-39B3-A5AA-574BF8F31C21> / usr/local/lib/libopencv_imgproc.2.2.dylib 0x101546000 - 0x1015a3fff +libopencv_ml.2.2.dylib (2.2.0 - compatibility 2.2.0) <24C6ADCF-EC65-3BE9-A2E1-3FEBE8FA5ECD> /usr/ local/lib/libopencv_ml.2.2.dylib 0x1015b9000 - 0x10168cff7 +libopencv_features2d. 2.2.dylib (2.2.0 - compatibility 2.2.0) /usr/local/lib/libopencv_features2d.2.2.dylib 0x1016bd000 - 0x1017aafe7 +libopencv_highgui.2.2.dylib (2.2.0 - compatibility 2.2.0) <94F7FA85-D4D0-33A4-9FC5-CECF2C3433FF> / usr/local/lib/libopencv_highgui.2.2.dylib 0x1017da000 - 0x101850ff7 +libopencv_calib3d.2.2.dylib (2.2.0 - compatibility 2.2.0) / usr/local/lib/libopencv_calib3d.2.2.dylib 0x10185c000 - 0x10189bfff +libopencv_objdetect.2.2.dylib (2.2.0 - compatibility 2.2.0) <486BD824-717F-3DB4-913B-F9EA66D018B8> / usr/local/lib/libopencv_objdetect.2.2.dylib 0x1018a7000 - 0x101949ff7 +libopencv_legacy.2.2.dylib (2.2.0 - compatibility 2.2.0) <7031719B-6D1D-39F2-86D0-3D6028F1B690> / usr/local/lib/libopencv_legacy.2.2.dylib 0x10196d000 - 0x1019a3fe7 +libopencv_contrib.2.2.dylib (2.2.0 - compatibility 2.2.0) <32C5ABA5-64CF-33A4-95E7-B37B0C68354C> / usr/local/lib/libopencv_contrib.2.2.dylib 0x7fff6316e000 - 0x7fff631a2ac7 dyld (195.5 - ???) <4A6E2B28- C7A2-3528-ADB7-4076B9836041> /usr/lib/dyld 0x7fff8a0b8000 - 0x7fff8a0c3ff7 com.apple.speech.recognition.framework (4.0.19 - 4.0.19) <7ADAAF5B-1D78-32F2-9FFF-D2E3FBB41C2B> /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/ Versions/A/SpeechRecognition 0x7fff8a0c4000 - 0x7fff8a0d2ff7 libkxld.dylib (??? - ???) <9C937433-A362-3E40-BF71-FDABA986B56C> /usr/lib/system/libkxld.dylib 0x7fff8a2aa000 - 0x7fff8a2b1fff com.apple.NetFS (4.0 - 4.0) /System/Library/Frameworks/ NetFS.framework/Versions/A/NetFS 0x7fff8a2b2000 - 0x7fff8a2b5fff com.apple.help (1.3.2 - 42) /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help 0x7fff8a2c2000 - 0x7fff8a361fff com.apple.LaunchServices (480.21 - 480.21) <6BFADEA9-5BC1-3B53-A013-488EB7F1AB57> /System/ Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/ LaunchServices.framework/Versions/A/LaunchServices 0x7fff8a362000 - 0x7fff8a364ff7 com.apple.print.framework.Print (7.1 - 247.1) <8A4925A5- BAA3-373C-9B5D-03E0270C6B12> /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/ Print 0x7fff8a365000 - 0x7fff8a384fff libresolv.9.dylib (46.0.0 - compatibility 1.0.0) <33263568-E6F3-359C-A4FA-66AD1300F7D4> /usr/lib/ libresolv.9.dylib 0x7fff8a47a000 - 0x7fff8a4a2ff7 com.apple.CoreVideo (1.7 - 70.1) <98F917B2-FB53-3EA3-B548-7E97B38309A7> /System/Library/ Frameworks/CoreVideo.framework/Versions/A/CoreVideo 0x7fff8a53e000 - 0x7fff8a544fff libGFXShared.dylib (??? - ???) <343AE6C0-EB02-333C-8D35-DF6093B92758> /System/Library/ Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib 0x7fff8a545000 - 0x7fff8a55bff7 com.apple.ImageCapture (7.0 - 7.0) <69E6E2E1-777E-332E-8BCF-4F0611517DD0> /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/ A/ImageCapture 0x7fff8a55c000 - 0x7fff8a56afff com.apple.NetAuth (1.0 - 3.0) /System/Library/ PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth 0x7fff8a56b000 - 0x7fff8a598ff7 com.apple.opencl (1.50.63 - 1.50.63) /System/Library/ Frameworks/OpenCL.framework/Versions/A/OpenCL 0x7fff8a5a1000 - 0x7fff8a5a3fff libCVMSPluginSupport.dylib (??? - ???) <61D89F3C-C64D-3733-819F-8AAAE4E2E993> /System/Library/ Frameworks/OpenGL.framework/Versions/A/Libraries/ libCVMSPluginSupport.dylib 0x7fff8a641000 - 0x7fff8a650ff7 com.apple.opengl (1.7.5 - 1.7.5) <2945F1A6-910C-3596-9988-5701B04BD821> /System/Library/ Frameworks/OpenGL.framework/Versions/A/OpenGL 0x7fff8a7fc000 - 0x7fff8a8affff com.apple.CoreText (220.11.0 - ???) <4EA8E2DF-542D-38D5-ADB9-C0DAA73F898B> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ CoreText.framework/Versions/A/CoreText 0x7fff8a8b0000 - 0x7fff8a8bdff7 libbz2.1.0.dylib (1.0.5 - compatibility 1.0.0) <8EDE3492-D916-37B2-A066-3E0F054411FD> /usr/lib/ libbz2.1.0.dylib 0x7fff8a8be000 - 0x7fff8a8c5fff libcopyfile.dylib (85.1.0 - compatibility 1.0.0) <172B1985-F24A-34E9-8D8B-A2403C9A0399> /usr/lib/ system/libcopyfile.dylib 0x7fff8a8c6000 - 0x7fff8acf8fff com.apple.VideoToolbox (1.0 - 705.42) /System/Library/ PrivateFrameworks/VideoToolbox.framework/Versions/A/VideoToolbox 0x7fff8acf9000 - 0x7fff8b48dfef com.apple.CoreAUC (6.11.04 - 6.11.04) /System/Library/ PrivateFrameworks/CoreAUC.framework/Versions/A/CoreAUC 0x7fff8b49d000 - 0x7fff8b4b9ff7 com.apple.GenerationalStorage (1.0 - 125) <31F60175-E38D-3C63-8D95-32CFE7062BCB> /System/Library/ PrivateFrameworks/GenerationalStorage.framework/Versions/A/ GenerationalStorage 0x7fff8b520000 - 0x7fff8b55fff7 libGLImage.dylib (??? - ???) <2D1D8488-EC5F-3229-B983-CFDE0BB37586> /System/Library/Frameworks/ OpenGL.framework/Versions/A/Libraries/libGLImage.dylib 0x7fff8b5e6000 - 0x7fff8b6adff7 com.apple.ColorSync (4.7.0 - 4.7.0) /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ ColorSync.framework/Versions/A/ColorSync 0x7fff8b6ae000 - 0x7fff8b729ff7 com.apple.print.framework.PrintCore (7.1 - 366.1) <3F140DEB-9F87-3672-97CC-F983752581AC> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ PrintCore.framework/Versions/A/PrintCore 0x7fff8b72a000 - 0x7fff8b72ffff com.apple.OpenDirectory (10.7 - 146) <91A87249-6A2F-3F89-A8DE-0E95C0B54A3A> /System/Library/ Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory 0x7fff8b835000 - 0x7fff8b916fff com.apple.CoreServices.OSServices (478.29 - 478.29) /System/Library/Frameworks/ CoreServices.framework/Versions/A/Frameworks/OSServices.framework/ Versions/A/OSServices 0x7fff8b921000 - 0x7fff8bf05fff libBLAS.dylib (??? - ???) /System/Library/Frameworks/ Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/ libBLAS.dylib 0x7fff8bf6e000 - 0x7fff8c188fef com.apple.CoreData (104 - 358.12) <33B1FA75-7970-3751-9DCC-FF809D3E1FA2> /System/Library/ Frameworks/CoreData.framework/Versions/A/CoreData 0x7fff8c1c1000 - 0x7fff8c4ddff7 com.apple.CoreServices.CarbonCore (960.18 - 960.18) <6020C3FB-6125-3EAE-A55D-1E77E38BEDEA> /System/Library/Frameworks/ CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/ Versions/A/CarbonCore 0x7fff8c4de000 - 0x7fff8c87cfef com.apple.MediaToolbox (1.0 - 705.42) /System/Library/ PrivateFrameworks/MediaToolbox.framework/Versions/A/MediaToolbox 0x7fff8c87d000 - 0x7fff8ccaafff libLAPACK.dylib (??? - ???) <4F2E1055-2207-340B-BB45-E4F16171EE0D> /System/Library/Frameworks/ Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/ libLAPACK.dylib 0x7fff8ccb7000 - 0x7fff8cd94fef libsystem_c.dylib (763.12.0 - compatibility 1.0.0) /usr/lib/ system/libsystem_c.dylib 0x7fff8d278000 - 0x7fff8d2e0ff7 com.apple.CoreSymbolication (2.1 - 71) <2ADD7C5B-C8C8-3CA8-8A5C-8FB1C7F6A549> /System/Library/ PrivateFrameworks/CoreSymbolication.framework/Versions/A/ CoreSymbolication 0x7fff8d5cd000 - 0x7fff8d651ff7 com.apple.ApplicationServices.ATS (317.5.0 - ???) /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/ Versions/A/ATS 0x7fff8d974000 - 0x7fff8e087587 com.apple.CoreGraphics (1.600.0 - ???) /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ CoreGraphics.framework/Versions/A/CoreGraphics 0x7fff8e088000 - 0x7fff8e092ff7 liblaunch.dylib (392.18.0 - compatibility 1.0.0) <39EF04F2-7F0C-3435-B785-BF283727FFBD> /usr/lib/ system/liblaunch.dylib 0x7fff8e093000 - 0x7fff8e106fff libstdc++.6.dylib (52.0.0 - compatibility 7.0.0) <6BDD43E4-A4B1-379E-9ED5-8C713653DFF2> /usr/lib/ libstdc++.6.dylib 0x7fff8e107000 - 0x7fff8e107fff com.apple.Cocoa (6.6 - ???) <021D4214-9C23-3CD8-AFB2-F331697A4508> /System/Library/Frameworks/ Cocoa.framework/Versions/A/Cocoa 0x7fff8e108000 - 0x7fff8e108fff com.apple.Carbon (153 - 153) /System/Library/Frameworks/ Carbon.framework/Versions/A/Carbon 0x7fff8e109000 - 0x7fff8e109fff com.apple.ApplicationServices (41 - 41) <03F3FA8F-8D2A-3AB6-A8E3-40B001116339> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/ ApplicationServices 0x7fff8e124000 - 0x7fff8e230fff libcrypto.0.9.8.dylib (44.0.0 - compatibility 0.9.8) <3A8E1F89-5E26-3C8B-B538-81F5D61DBF8A> /usr/lib/ libcrypto.0.9.8.dylib 0x7fff8e231000 - 0x7fff8e293fff com.apple.coreui (1.2.1 - 164.1) /System/Library/ PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI 0x7fff8e2be000 - 0x7fff8e2bfff7 libsystem_blocks.dylib (53.0.0 - compatibility 1.0.0) <8BCA214A-8992-34B2-A8B9-B74DEACA1869> / usr/lib/system/libsystem_blocks.dylib 0x7fff8e2c0000 - 0x7fff8e362ff7 com.apple.securityfoundation (5.0 - 55005) <0D59908C-A61B-389E-AF37-741ACBBA6A94> /System/Library/ Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation 0x7fff8e363000 - 0x7fff8e3cbff7 com.apple.audio.CoreAudio (4.0.1 - 4.0.1) <7966E3BE-376B-371A-A21D-9BD763C0BAE7> /System/Library/ Frameworks/CoreAudio.framework/Versions/A/CoreAudio 0x7fff8e3ce000 - 0x7fff8e4acfff com.apple.ImageIO.framework (3.1.1 - 3.1.1) <13E549F8-5BD6-3BAE-8C33-1D0BD269C081> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ ImageIO.framework/Versions/A/ImageIO 0x7fff8e4ad000 - 0x7fff8e4b2fff libcache.dylib (47.0.0 - compatibility 1.0.0) /usr/lib/ system/libcache.dylib 0x7fff8e546000 - 0x7fff8e54afff libmathCommon.A.dylib (2026.0.0 - compatibility 1.0.0) /usr/lib/system/libmathCommon.A.dylib 0x7fff8e54b000 - 0x7fff8e550ff7 libsystem_network.dylib (??? - ???) <5DE7024E-1D2D-34A2-80F4-08326331A75B> /usr/lib/system/ libsystem_network.dylib 0x7fff8e60d000 - 0x7fff8e640ff7 com.apple.GSS (2.1 - 2.0) <9A2C9736-DA10-367A-B376-2C7A584E6C7A> /System/Library/Frameworks/ GSS.framework/Versions/A/GSS 0x7fff8e641000 - 0x7fff8e642fff libunc.dylib (24.0.0 - compatibility 1.0.0) /usr/lib/ system/libunc.dylib 0x7fff8e7af000 - 0x7fff8f3b0ff7 com.apple.AppKit (6.7.2 - 1138.23) <5CD2C850-4F52-3BA2-BA11-3107DFD2D23C> /System/Library/ Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff8f3b1000 - 0x7fff8f5b3fff libicucore.A.dylib (46.1.0 - compatibility 1.0.0) <38CD6ED3-C8E4-3CCD-89AC-9C3198803101> /usr/lib/ libicucore.A.dylib 0x7fff8f5b4000 - 0x7fff8f5eefe7 com.apple.DebugSymbols (2.1 - 87) <149201BE-A8A4-3E40-AD65-E5194B59162E> /System/Library/ PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols 0x7fff8f5ef000 - 0x7fff8f5f5fff libmacho.dylib (800.0.0 - compatibility 1.0.0) /usr/lib/ system/libmacho.dylib 0x7fff8f5f6000 - 0x7fff8f641ff7 com.apple.SystemConfiguration (1.11.1 - 1.11) /System/Library/ Frameworks/SystemConfiguration.framework/Versions/A/ SystemConfiguration 0x7fff8f666000 - 0x7fff8f76bff7 libFontParser.dylib (??? - ???) /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ ATS.framework/Versions/A/Resources/libFontParser.dylib 0x7fff8f76c000 - 0x7fff8f7c7ff7 com.apple.HIServices (1.10 - ???) /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ HIServices.framework/Versions/A/HIServices 0x7fff8f7c8000 - 0x7fff8f84bfef com.apple.Metadata (10.7.0 - 627.20) /System/Library/ Frameworks/CoreServices.framework/Versions/A/Frameworks/ Metadata.framework/Versions/A/Metadata 0x7fff8f84c000 - 0x7fff8f8e2ff7 libvMisc.dylib (325.4.0 - compatibility 1.0.0) <642D8D54-F9F5-3FBB-A96C-EEFE94C6278B> /System/ Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ vecLib.framework/Versions/A/libvMisc.dylib 0x7fff8fd74000 - 0x7fff8fdafff7 libsystem_info.dylib (??? - ???) <9C8C2DCB-96DB-3471-9DCE-ADCC26BE2DD4> /usr/lib/system/ libsystem_info.dylib 0x7fff8fdb0000 - 0x7fff8feb3fff libsqlite3.dylib (9.6.0 - compatibility 9.0.0) <7F60B0FF-4946-3639-89AB-B540D318B249> /usr/lib/ libsqlite3.dylib 0x7fff8feb4000 - 0x7fff8ff29ff7 libc++.1.dylib (19.0.0 - compatibility 1.0.0) /usr/lib/ libc++.1.dylib 0x7fff8ff2a000 - 0x7fff8ff3ffff com.apple.speech.synthesis.framework (4.0.74 - 4.0.74) /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ SpeechSynthesis.framework/Versions/A/SpeechSynthesis 0x7fff8ff40000 - 0x7fff8ff82ff7 libcommonCrypto.dylib (55010.0.0 - compatibility 1.0.0) /usr/lib/system/libcommonCrypto.dylib 0x7fff902d0000 - 0x7fff902e3ff7 libCRFSuite.dylib (??? - ???) <034D4DAA-63F0-35E4-BCEF-338DD7A453DD> /usr/lib/libCRFSuite.dylib 0x7fff902e4000 - 0x7fff9034bff7 com.apple.Symbolication (1.2 - 89) /System/Library/ PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication 0x7fff90769000 - 0x7fff9076cfff libCoreVMClient.dylib (??? - ???) /System/Library/ Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib 0x7fff9076d000 - 0x7fff909e0fff com.apple.CoreImage (7.82 - 1.0.1) <282801B6-5D80-3E2C-88A4-00FE29906D5A> /System/Library/ Frameworks/QuartzCore.framework/Versions/A/Frameworks/ CoreImage.framework/Versions/A/CoreImage 0x7fff90aaf000 - 0x7fff90afdfff libauto.dylib (??? - ???) /usr/lib/libauto.dylib 0x7fff90b0f000 - 0x7fff90b11fff com.apple.TrustEvaluationAgent (2.0 - 1) <1F31CAFF- C1C6-33D3-94E9-11B721761DDF> /System/Library/PrivateFrameworks/ TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent 0x7fff90b12000 - 0x7fff90b66ff7 com.apple.ScalableUserInterface (1.0 - 1) <1873D7BE-2272-31A1-8F85- F70C4D706B3B> /System/Library/Frameworks/QuartzCore.framework/Versions/ A/Frameworks/ScalableUserInterface.framework/Versions/A/ ScalableUserInterface 0x7fff90ea9000 - 0x7fff90eaffff com.apple.DiskArbitration (2.4.1 - 2.4.1) /System/Library/ Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration 0x7fff90f05000 - 0x7fff90f5cfff libTIFF.dylib (??? - ???) /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libTIFF.dylib 0x7fff90f5d000 - 0x7fff90f61fff libdyld.dylib (195.5.0 - compatibility 1.0.0) /usr/lib/ system/libdyld.dylib 0x7fff90fa3000 - 0x7fff90fa4fff libDiagnosticMessagesClient.dylib (??? - ???) <3DCF577B-F126-302B- BCE2-4DB9A95B8598> /usr/lib/libDiagnosticMessagesClient.dylib 0x7fff90fa9000 - 0x7fff912cdfff com.apple.HIToolbox (1.8 - ???) /System/Library/ Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/ Versions/A/HIToolbox 0x7fff912ce000 - 0x7fff915e7ff7 com.apple.Foundation (6.7.1 - 833.20) /System/Library/ Frameworks/Foundation.framework/Versions/C/Foundation 0x7fff91632000 - 0x7fff9164fff7 com.apple.openscripting (1.3.3 - ???) /System/Library/ Frameworks/Carbon.framework/Versions/A/Frameworks/ OpenScripting.framework/Versions/A/OpenScripting 0x7fff91650000 - 0x7fff916bafff com.apple.framework.IOKit (2.0 - ???) <87D55F1D-CDB5-3D13-A5F9-98EA4E22F8EE> /System/Library/ Frameworks/IOKit.framework/Versions/A/IOKit 0x7fff91704000 - 0x7fff91709fff libpam.2.dylib (3.0.0 - compatibility 3.0.0) /usr/lib/ libpam.2.dylib 0x7fff9170a000 - 0x7fff91744fff libncurses.5.4.dylib (5.4.0 - compatibility 5.4.0) <387DE593-9CC5-38C7-911B-A5F2264D34F2> /usr/lib/ libncurses.5.4.dylib 0x7fff91745000 - 0x7fff91762ff7 libxpc.dylib (77.17.0 - compatibility 1.0.0) <72A16104-2F23-3C22-B474-1953F06F9376> /usr/lib/ system/libxpc.dylib 0x7fff91799000 - 0x7fff917e9fff com.apple.CoreMediaIO (210.0 - 3180) <13374EA4-83BE-3407-B9DD-D199426D0E7A> /System/Library/ Frameworks/CoreMediaIO.framework/Versions/A/CoreMediaIO 0x7fff917ea000 - 0x7fff9185afff com.apple.datadetectorscore (3.0 - 179.4) <2A822A13-94B3-3A43-8724-98FDF698BB12> /System/Library/ PrivateFrameworks/DataDetectorsCore.framework/Versions/A/ DataDetectorsCore 0x7fff9185b000 - 0x7fff9185bfff com.apple.Accelerate.vecLib (3.7 - vecLib 3.7) /System/ Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ vecLib.framework/Versions/A/vecLib 0x7fff9185c000 - 0x7fff918affff com.apple.AppleVAFramework (5.0.14 - 5.0.14) <45159B9E-05BF-35B2-AF76-D933490FBFB1> /System/ Library/PrivateFrameworks/AppleVA.framework/Versions/A/AppleVA 0x7fff918b0000 - 0x7fff918b7ff7 com.apple.CommerceCore (1.0 - 17) /System/Library/ PrivateFrameworks/CommerceKit.framework/Versions/A/Frameworks/ CommerceCore.framework/Versions/A/CommerceCore 0x7fff918d8000 - 0x7fff91917fff com.apple.AE (527.7 - 527.7) /System/Library/Frameworks/ CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/ AE 0x7fff91953000 - 0x7fff91956fff libRadiance.dylib (??? - ???) /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libRadiance.dylib 0x7fff91957000 - 0x7fff9195ffff libsystem_dnssd.dylib (??? - ???) <407A48F3-64A0-348B-88E6-70CECD3D0D67> /usr/lib/system/ libsystem_dnssd.dylib 0x7fff91960000 - 0x7fff91969ff7 libsystem_notify.dylib (80.1.0 - compatibility 1.0.0) / usr/lib/system/libsystem_notify.dylib 0x7fff9196a000 - 0x7fff91a4edef libobjc.A.dylib (228.0.0 - compatibility 1.0.0) /usr/lib/ libobjc.A.dylib 0x7fff91c8c000 - 0x7fff91cccff7 libcups.2.dylib (2.9.0 - compatibility 2.0.0) /usr/lib/ libcups.2.dylib 0x7fff91ccd000 - 0x7fff91cd2fff libcompiler_rt.dylib (6.0.0 - compatibility 1.0.0) <98ECD5F6-E85C-32A5-98CD-8911230CB66A> /usr/lib/ system/libcompiler_rt.dylib 0x7fff91cd3000 - 0x7fff91cd3fff libkeymgr.dylib (23.0.0 - compatibility 1.0.0) <61EFED6A-A407-301E-B454-CD18314F0075> /usr/lib/ system/libkeymgr.dylib 0x7fff91d28000 - 0x7fff91d3aff7 libbsm.0.dylib (??? - ???) <349BB16F-75FA-363F-8D98-7A9C3FA90A0D> /usr/lib/libbsm.0.dylib 0x7fff91d3b000 - 0x7fff91d55fff com.apple.CoreMediaAuthoring (2.0 - 889) <99D8E4C6-DDD3-3B0C-BBFB-A513877F10F6> /System/Library/ PrivateFrameworks/CoreMediaAuthoring.framework/Versions/A/ CoreMediaAuthoring 0x7fff91d56000 - 0x7fff91e6eff7 com.apple.DesktopServices (1.6.1 - 1.6.1) <4418EAA6-7163-3A77-ABD3-F8289796C81A> /System/Library/ PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/ DesktopServicesPriv 0x7fff91e6f000 - 0x7fff91e9aff7 libxslt.1.dylib (3.24.0 - compatibility 3.0.0) <8051A3FC-7385-3EA9-9634-78FC616C3E94> /usr/lib/ libxslt.1.dylib 0x7fff91f88000 - 0x7fff91f89ff7 libremovefile.dylib (21.0.0 - compatibility 1.0.0) /usr/lib/ system/libremovefile.dylib 0x7fff91f8a000 - 0x7fff91fa1fff com.apple.CFOpenDirectory (10.7 - 144) <9709423E-8484-3B26-AAE8-EF58D1B8FB3F> /System/Library/ Frameworks/OpenDirectory.framework/Versions/A/Frameworks/ CFOpenDirectory.framework/Versions/A/CFOpenDirectory 0x7fff920a1000 - 0x7fff920a5ff7 com.apple.CommonPanels (1.2.5 - 94) <0BB2C436-C9D5-380B-86B5-E355A7711259> /System/Library/ Frameworks/Carbon.framework/Versions/A/Frameworks/ CommonPanels.framework/Versions/A/CommonPanels 0x7fff92130000 - 0x7fff92142ff7 libz.1.dylib (1.2.5 - compatibility 1.0.0) <30CBEF15-4978-3DED-8629-7109880A19D4> /usr/lib/ libz.1.dylib 0x7fff92143000 - 0x7fff9260afff FaceCoreLight (1.4.7 - compatibility 1.0.0) /System/ Library/PrivateFrameworks/FaceCoreLight.framework/Versions/A/ FaceCoreLight 0x7fff9260b000 - 0x7fff92611fff IOSurface (??? - ???) <2114359C-D839-3855-8735-BBAA2704DB93> /System/Library/Frameworks/ IOSurface.framework/Versions/A/IOSurface 0x7fff92612000 - 0x7fff92672fff libvDSP.dylib (325.4.0 - compatibility 1.0.0) <3A7521E6-5510-3FA7-AB65-79693A7A5839> /System/ Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ vecLib.framework/Versions/A/libvDSP.dylib 0x7fff92697000 - 0x7fff927f0fff com.apple.audio.toolbox.AudioToolbox (1.7.1 - 1.7.1) <4877267E- F736-3019-85D3-40A32A042A80> /System/Library/Frameworks/ AudioToolbox.framework/Versions/A/AudioToolbox 0x7fff927f1000 - 0x7fff927fcfff com.apple.CommonAuth (2.1 - 2.0) /System/Library/ PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth 0x7fff92802000 - 0x7fff92828ff7 com.apple.framework.familycontrols (3.0 - 300) <41A6DFC2- EAF5-390A-83A1-C8832528705C> /System/Library/PrivateFrameworks/ FamilyControls.framework/Versions/A/FamilyControls 0x7fff92c13000 - 0x7fff92cadff7 com.apple.SearchKit (1.4.0 - 1.4.0) <4E70C394-773E-3A4B-A93C-59A88ABA9509> /System/Library/ Frameworks/CoreServices.framework/Versions/A/Frameworks/ SearchKit.framework/Versions/A/SearchKit 0x7fff92cae000 - 0x7fff92caefff com.apple.audio.units.AudioUnit (1.7.1 - 1.7.1) <04C10813- CCE5-3333-8C72-E8E35E417B3B> /System/Library/Frameworks/ AudioUnit.framework/Versions/A/AudioUnit 0x7fff92caf000 - 0x7fff92cdcfe7 libSystem.B.dylib (159.1.0 - compatibility 1.0.0) <095FDD3C-3961-3865-A59B-A5B0A4B8B923> /usr/lib/ libSystem.B.dylib 0x7fff92ea3000 - 0x7fff92f47fef com.apple.ink.framework (1.3.2 - 110) /System/Library/ Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/ Versions/A/Ink 0x7fff92f48000 - 0x7fff92f6cfff com.apple.Kerberos (1.0 - 1) <1F826BCE-DA8F-381D-9C4C-A36AA0EA1CB9> /System/Library/Frameworks/ Kerberos.framework/Versions/A/Kerberos 0x7fff92f6d000 - 0x7fff92f6efff libdnsinfo.dylib (395.6.0 - compatibility 1.0.0) <718A135F-6349-354A-85D5-430B128EFD57> /usr/lib/ system/libdnsinfo.dylib 0x7fff92f6f000 - 0x7fff92f8cfff libPng.dylib (??? - ???) <3C70A94C-9442-3E11-AF51-C1B0EF81680E> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libPng.dylib 0x7fff92f8d000 - 0x7fff92fb6fff libJPEG.dylib (??? - ???) <64D079F9-256A-323B-A837-84628B172F21> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libJPEG.dylib 0x7fff92fdf000 - 0x7fff92fe2ff7 com.apple.securityhi (4.0 - 1) /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/ SecurityHI 0x7fff93022000 - 0x7fff93046ff7 com.apple.RemoteViewServices (1.2 - 39) <862849C8-84C1-32A1-B87E-B29E74778C9F> /System/Library/ PrivateFrameworks/RemoteViewServices.framework/Versions/A/ RemoteViewServices 0x7fff93057000 - 0x7fff9305dff7 libunwind.dylib (30.0.0 - compatibility 1.0.0) <1E9C6C8C-CBE8-3F4B-A5B5-E03E3AB53231> /usr/lib/ system/libunwind.dylib 0x7fff93797000 - 0x7fff937deff7 com.apple.CoreMedia (1.0 - 705.42) /System/Library/ Frameworks/CoreMedia.framework/Versions/A/CoreMedia 0x7fff93b2f000 - 0x7fff93b82fff libFontRegistry.dylib (??? - ???) <57FBD85F-41A6-3DB9-B5F4-FCC6B260F1AD> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ ATS.framework/Versions/A/Resources/libFontRegistry.dylib 0x7fff93e07000 - 0x7fff93e09fff libquarantine.dylib (36.0.0 - compatibility 1.0.0) <4C3BFBC7-E592-3939-B376-1C2E2D7C5389> /usr/lib/ system/libquarantine.dylib 0x7fff93e5a000 - 0x7fff93f93fef com.apple.vImage (5.1 - 5.1) /System/Library/Frameworks/ Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/ vImage 0x7fff93fbc000 - 0x7fff9400eff7 libGLU.dylib (??? - ???) <3C9153A0-8499-3DC0-AAA4-9FA6E488BE13> /System/Library/Frameworks/ OpenGL.framework/Versions/A/Libraries/libGLU.dylib 0x7fff9400f000 - 0x7fff9401aff7 libc++abi.dylib (14.0.0 - compatibility 1.0.0) <8FF3D766-D678-36F6-84AC-423C878E6D14> /usr/lib/ libc++abi.dylib 0x7fff9412d000 - 0x7fff9423afff libJP2.dylib (??? - ???) <6052C973-9354-35CB-AAB9-31D00D8786F9> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libJP2.dylib 0x7fff95175000 - 0x7fff9519cfff com.apple.PerformanceAnalysis (1.10 - 10) <2A058167-292E-3C3A-B1F8-49813336E068> /System/Library/ PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/ PerformanceAnalysis 0x7fff951a0000 - 0x7fff951a0fff com.apple.vecLib (3.7 - vecLib 3.7) <9A58105C-B36E-35B5-812C-4ED693F2618F> /System/Library/ Frameworks/vecLib.framework/Versions/A/vecLib 0x7fff951a1000 - 0x7fff951b5ff7 com.apple.LangAnalysis (1.7.0 - 1.7.0) <04C31EF0-912A-3004-A08F-CEC27030E0B2> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ LangAnalysis.framework/Versions/A/LangAnalysis 0x7fff951b6000 - 0x7fff9538afff com.apple.CoreFoundation (6.7.1 - 635.15) /System/ Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7fff953a0000 - 0x7fff95506fff com.apple.CFNetwork (520.2.5 - 520.2.5) <406712D9-3F0C-3763-B4EB-868D01F1F042> /System/Library/ Frameworks/CoreServices.framework/Versions/A/Frameworks/ CFNetwork.framework/Versions/A/CFNetwork 0x7fff95507000 - 0x7fff95691ff7 com.apple.QTKit (7.7.1 - 2306) /System/Library/ Frameworks/QTKit.framework/Versions/A/QTKit 0x7fff9578d000 - 0x7fff957cefff com.apple.QD (3.12 - ???) <4F3C5629-97C7-3E55-AF3C-ACC524929DA2> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/QD.framework/ Versions/A/QD 0x7fff957cf000 - 0x7fff957d4fff libGIF.dylib (??? - ???) <393E2DB5-9479-39A6-A75A-B5F20B852532> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libGIF.dylib 0x7fff957d5000 - 0x7fff957f5fff libsystem_kernel.dylib (1699.22.81 - compatibility 1.0.0) /usr/lib/system/ libsystem_kernel.dylib 0x7fff957f6000 - 0x7fff958ebfff libiconv.2.dylib (7.0.0 - compatibility 7.0.0) <5C40E880-0706-378F-B864-3C2BD922D926> /usr/lib/ libiconv.2.dylib 0x7fff95960000 - 0x7fff95961fff liblangid.dylib (??? - ???) /usr/lib/liblangid.dylib 0x7fff95962000 - 0x7fff95992ff7 com.apple.DictionaryServices (1.2.1 - 158.2) <3FC86118-7553-38F7-8916-B329D2E94476> /System/Library/ Frameworks/CoreServices.framework/Versions/A/Frameworks/ DictionaryServices.framework/Versions/A/DictionaryServices 0x7fff95b46000 - 0x7fff95b5cfff libGL.dylib (??? - ???) <6A473BF9-4D35-34C6-9F8B-86B68091A9AF> /System/Library/Frameworks/ OpenGL.framework/Versions/A/Libraries/libGL.dylib 0x7fff96239000 - 0x7fff963d8fff com.apple.QuartzCore (1.7 - 270.0) /System/Library/ Frameworks/QuartzCore.framework/Versions/A/QuartzCore 0x7fff963d9000 - 0x7fff963f0fff com.apple.MultitouchSupport.framework (220.62.1 - 220.62.1) /System/Library/ PrivateFrameworks/MultitouchSupport.framework/Versions/A/ MultitouchSupport 0x7fff963f3000 - 0x7fff966cbff7 com.apple.security (7.0 - 55010) <93713FF4-FE86-3B4C-8150-5FCC7F3320C8> /System/Library/ Frameworks/Security.framework/Versions/A/Security 0x7fff9677e000 - 0x7fff96880ff7 libxml2.2.dylib (10.3.0 - compatibility 10.0.0) /usr/lib/ libxml2.2.dylib 0x7fff969c5000 - 0x7fff96a4aff7 com.apple.Heimdal (2.1 - 2.0) /System/Library/ PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal 0x7fff96a4b000 - 0x7fff96a4bfff com.apple.Accelerate (1.7 - Accelerate 1.7) <82DDF6F5-FBC3-323D-B71D-CF7ABC5CF568> /System/Library/ Frameworks/Accelerate.framework/Versions/A/Accelerate 0x7fff96bd7000 - 0x7fff96bd7fff com.apple.CoreServices (53 - 53) <043C8026-8EDD-3241-B090-F589E24062EF> /System/Library/Frameworks/ CoreServices.framework/Versions/A/CoreServices 0x7fff96bd8000 - 0x7fff96be6fff libdispatch.dylib (187.7.0 - compatibility 1.0.0) <712AAEAC-AD90-37F7-B71F-293FF8AE8723> /usr/lib/ system/libdispatch.dylib 0x7fff96be7000 - 0x7fff96be8fff libsystem_sandbox.dylib (??? - ???) <8D14139B-B671-35F4-9E5A-023B4C523C38> /usr/lib/system/ libsystem_sandbox.dylib External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 371 thread_create: 1 thread_set_state: 0 VM Region Summary: ReadOnly portion of Libraries: Total=169.5M resident=106.9M(63%) swapped_out_or_unallocated=62.6M(37%) Writable regions: Total=19.8M written=2360K(12%) resident=3028K(15%) swapped_out=0K(0%) unallocated=16.8M(85%) REGION TYPE VIRTUAL =========== ======= MALLOC 10.6M MALLOC guard page 16K STACK GUARD 56.0M Stack 8192K __CI_BITMAP 80K __DATA 14.2M __IMAGE 1256K __LINKEDIT 49.4M __TEXT 120.0M __UNICODE 544K shared memory 12K =========== ======= TOTAL 260.2M Model: MacBook5,1, BootROM MB51.007D.B03, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.32f8 Graphics: NVIDIA GeForce 9400M, NVIDIA GeForce 9400M, PCI, 256 MB Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1067 MHz, 0x80CE, 0x4D34373142353637334448312D4346382020 Memory Module: BANK 0/DIMM1, 2 GB, DDR3, 1067 MHz, 0x80CE, 0x4D34373142353637334448312D4346382020 AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), Broadcom BCM43xx 1.0 (5.100.98.75.18) Bluetooth: Version 4.0.1f4, 2 service, 18 devices, 1 incoming serial ports Network Service: Wi-Fi, AirPort, en1 Serial ATA Device: FUJITSU MHZ2250BH FFS G1, 250.06 GB Serial ATA Device: HL-DT-ST DVDRW GS21N USB Device: Built-in iSight, apple_vendor_id, 0x8507, 0x24400000 / 2 USB Device: Apple Internal Keyboard / Trackpad, apple_vendor_id, 0x0237, 0x04600000 / 3 USB Device: IR Receiver, apple_vendor_id, 0x8242, 0x04500000 / 2 USB Device: BRCM2046 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0x06100000 / 2 USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x8213, 0x06110000 / 5 From pedro.h.souto at gmail.com Wed Nov 30 06:36:15 2011 From: pedro.h.souto at gmail.com (Pedro Henrique G. Souto) Date: Wed, 30 Nov 2011 09:36:15 -0200 Subject: Total newbie question: Best practice In-Reply-To: <408F64D89899604FB24015E64E10490C179CAB10@KCHJEXMB02.kpit.com> References: <408F64D89899604FB24015E64E10490C179CAB10@KCHJEXMB02.kpit.com> Message-ID: <4ED6152F.3020307@gmail.com> On 30/11/2011 06:50, Shambhu Rajak wrote: > Collins Congratulations for your first step into Python Programming. > You can call them script or programs(not necessarily but depends on what your coding for). > Yaa..it's always a good practice to call it through main(), but it doesn't really matter you > can call the method in way.... > > Regards, > Shambhu > > -----Original Message----- > From: Colin Higwell [mailto:colinh at somewhere.invalid] > Sent: 30/11/2011 1:37 AM > To: python-list at python.org > Subject: Total newbie question: Best practice > > Hi, > > I am just starting to learn Python (I have been at it only a few hours), > so please bear with me. I have a few very small scripts (do you call them > scripts or programs?) which work properly, and produce the results > intended. > > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other functions as appropriate), and then to call main() to do the > work. > > Is that standard best practice? > > Thanks Congratulations on becoming a Pythonist! Like Shambhu said, it doesn't matter where do you put the code, but is interesting to have a main() function when you have a program, and you want to differentiate if it is running directly (i.e. python program.py) or if it is running as a module, imported by other program (i.e. import program). To do so, you do this: main(): # blablabla if __name__ == '__main__': main() If the program is running directly, the variable __name__ will be '__main__', if not, __name__ will be the name of the module ('program', in this case). Att; Pedro From durumdara at gmail.com Wed Nov 30 07:08:13 2011 From: durumdara at gmail.com (durumdara) Date: Wed, 30 Nov 2011 04:08:13 -0800 (PST) Subject: Python 3 - xml - crlf handling problem Message-ID: <3aae0b18-a194-444f-a2fc-da156204bd95@20g2000yqa.googlegroups.com> Hi! As I see that XML parsing is "wrong" in Python. I must use predefined XML files, parsing them, extending them, and produce some result. But as I see that in Windows this is working wrong. When the predefined XMLs are "formatted" (prettied) with CRLFs, then the parser keeps these plus LF characters (not handle the logic that CR = LF = CRLF), and it is appearing in the new result too. xo = parse('test_original.xml') de = xo.documentElement de.setAttribute('b', "2") b = xo.toxml('utf-8') f = open('test_original2.xml', 'wb') f.write(b) f.close() And: if I used text elements, this can extend the information with plus characters and make wrong xml... I can use only "myowngenerated", and not prettied xmls because of this problem! Is this normal? Thanks for your read: dd From ndbecker2 at gmail.com Wed Nov 30 07:32:39 2011 From: ndbecker2 at gmail.com (Neal Becker) Date: Wed, 30 Nov 2011 07:32:39 -0500 Subject: order independent hash? Message-ID: I like to hash a list of words (actually, the command line args of my program) in such a way that different words will create different hash, but not sensitive to the order of the words. Any ideas? From mail at timgolden.me.uk Wed Nov 30 07:38:14 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 30 Nov 2011 12:38:14 +0000 Subject: order independent hash? In-Reply-To: References: Message-ID: <4ED623B6.602@timgolden.me.uk> On 30/11/2011 12:32, Neal Becker wrote: > I like to hash a list of words (actually, the command line args of my program) > in such a way that different words will create different hash, but not sensitive > to the order of the words. Any ideas? How about? hash (frozenset ("hello world".split ())) TJG From __peter__ at web.de Wed Nov 30 07:47:13 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Nov 2011 13:47:13 +0100 Subject: order independent hash? References: Message-ID: Neal Becker wrote: > I like to hash a list of words (actually, the command line args of my > program) in such a way that different words will create different hash, > but not sensitive to the order of the words. Any ideas? You mean a typical python hash value which would be /likely/ to differ for different lists and /guaranteed/ to be equal for equal lists is not good enough? Because that would be easy: args = sys.argv[1:] hash(tuple(sorted(args))) # consider duplicate args hash(frozenset(args)) # ignore duplicate args From lists at cheimes.de Wed Nov 30 07:58:41 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 30 Nov 2011 13:58:41 +0100 Subject: Python crashes on segmentation error In-Reply-To: <8bffed0f-1050-418a-834d-f7060a899ab7@h5g2000yqk.googlegroups.com> References: <8bffed0f-1050-418a-834d-f7060a899ab7@h5g2000yqk.googlegroups.com> Message-ID: Am 30.11.2011 11:42, schrieb Ben Richardson: > Python crashes every time i run the following command? > >>>> import cv > Segmentation fault: 11 > > Python quit unexpectedly - any help would be greatly appreciated - > thankyou in advance :) > > Here is crash report? [...] > > Thread 0 Crashed:: Dispatch queue: com.apple.main-thread > 0 ??? 000000000000000000 0 + 0 > 1 org.python.python 0x00000001006c7885 PyImport_Import > + 121 > 2 org.python.python 0x00000001006c7a1e > PyImport_ImportModule + 32 > 3 cv.so 0x00000001004f5082 initcv + 18 > 4 org.python.python 0x00000001000dc071 > _PyImport_LoadDynamicModule + 177 It looks like you have a faulty 3rd party library with an extension module called cv.so that is causing the segfault. The segfault occurs either inside or during the import of the cv module. initcv() is the init function of the cv module that is called automatically during the import. Christian From stefan_ml at behnel.de Wed Nov 30 08:47:59 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 30 Nov 2011 14:47:59 +0100 Subject: Python 3 - xml - crlf handling problem In-Reply-To: <3aae0b18-a194-444f-a2fc-da156204bd95@20g2000yqa.googlegroups.com> References: <3aae0b18-a194-444f-a2fc-da156204bd95@20g2000yqa.googlegroups.com> Message-ID: durumdara, 30.11.2011 13:08: > As I see that XML parsing is "wrong" in Python. You didn't say what you are using for parsing, but from your example, it appears likely that you are using the xml.dom.minidom module. > I must use predefined XML files, parsing them, extending them, and > produce some result. > > But as I see that in Windows this is working wrong. > > When the predefined XMLs are "formatted" (prettied) with CRLFs, then > the parser keeps these plus LF characters (not handle the logic that > CR = LF = CRLF), and it is appearing in the new result too. I assume that you are referring to XML's newline normalisation algorithm? That should normally be handled by the parser, which, in the case of minidom, is usually expat. And I seriously doubt that expat has a problem with something as basic as newline normalisation. Did you verify that the newlines are really not being converted by the parser? From your example, I can only see that you are serialising the XML tree back into a file, which may or may not alter the line endings by itself. Instead, take a look at the text content in the tree right after parsing to see how line endings look at that level. > xo = parse('test_original.xml') > de = xo.documentElement > de.setAttribute('b', "2") > b = xo.toxml('utf-8') > f = open('test_original2.xml', 'wb') > f.write(b) > f.close() This doesn't do any pretty printing, though, in case that's what you were really after (which appears likely according to your comments). > And: if I used text elements, this can extend the information with > plus characters and make wrong xml... Sorry, I don't understand this sentence. > I can use only "myowngenerated", and not prettied xmls because of this > problem! Then what is the actual problem? Do you get an error somewhere? And if so, could you paste the exact error message and describe what you do to produce it? The mere fact that the line endings use the normal platform specific representation doesn't seem like a problem to me. Stefan From miki.tebeka at gmail.com Wed Nov 30 09:55:10 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 30 Nov 2011 06:55:10 -0800 (PST) Subject: Converting MS Access DB to Postgres or MySQL for ORM support with SQLalchemy In-Reply-To: References: Message-ID: <7671543.1221.1322664911105.JavaMail.geo-discussion-forums@yqny18> You can read data using win32com (ADODB?) and then write it to the desired database using the right package (psycopg2 ...). See example for reading data at http://mail.python.org/pipermail/python-win32/2006-March/004420.html From miki.tebeka at gmail.com Wed Nov 30 09:55:10 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 30 Nov 2011 06:55:10 -0800 (PST) Subject: Converting MS Access DB to Postgres or MySQL for ORM support with SQLalchemy In-Reply-To: References: Message-ID: <7671543.1221.1322664911105.JavaMail.geo-discussion-forums@yqny18> You can read data using win32com (ADODB?) and then write it to the desired database using the right package (psycopg2 ...). See example for reading data at http://mail.python.org/pipermail/python-win32/2006-March/004420.html From alec.taylor6 at gmail.com Wed Nov 30 10:19:31 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 02:19:31 +1100 Subject: Defining a new base-type in Python based off Hexavigesimal Message-ID: Good evening, I have defined a new numbering structure for certain mathematical advantages. How do I implement this in Python, or would I be better off writing this in C or C++? Ultra concise definition: http://i42.tinypic.com/af7w4h.png LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI Thanks for all suggestions, Alec Taylor From steve+comp.lang.python at pearwood.info Wed Nov 30 10:38:58 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Nov 2011 15:38:58 GMT Subject: Defining a new base-type in Python based off Hexavigesimal References: Message-ID: <4ed64e12$0$29988$c3e8da3$5496439d@news.astraweb.com> On Thu, 01 Dec 2011 02:19:31 +1100, Alec Taylor wrote: > Good evening, > > I have defined a new numbering structure for certain mathematical > advantages. > > How do I implement this in Python, or would I be better off writing this > in C or C++? > > Ultra concise definition: http://i42.tinypic.com/af7w4h.png Care to translate it into English? Then translate the English into pseudo-code. And the pseudo-code into Python. Then, if and only if the Python version is too slow, translate it into C. And now you are done! -- Steven From __peter__ at web.de Wed Nov 30 11:00:55 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Nov 2011 17:00:55 +0100 Subject: Defining a new base-type in Python based off Hexavigesimal References: Message-ID: Alec Taylor wrote: > I have defined a new numbering structure for certain mathematical > advantages. > > How do I implement this in Python, or would I be better off writing > this in C or C++? > > Ultra concise definition: http://i42.tinypic.com/af7w4h.png > LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI > > Thanks for all suggestions, I don't know if that helps you with your project but Python already understands some hexavigesimal: >>> int("fool", 26) 280509 From ian.g.kelly at gmail.com Wed Nov 30 11:18:39 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 30 Nov 2011 09:18:39 -0700 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor wrote: > Good evening, > > I have defined a new numbering structure for certain mathematical advantages. > > How do I implement this in Python, or would I be better off writing > this in C or C++? > > Ultra concise definition: http://i42.tinypic.com/af7w4h.png > LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI > > Thanks for all suggestions, So if I am understanding your definition correctly your hexavigesimals are ordered like this? 0, 1, ..., 9, A, B, ..., P, 0A, 0B, ..., 0P, 1A, 1B, ..., 1P, ..., 9A, 9B, ..., 9P, A0, A1, ..., A9, B0, B1, ..., B9, ..., P0, P1, ..., P9 And that's it, since your constraints preclude anything with more than 2 digits? From alec.taylor6 at gmail.com Wed Nov 30 11:26:53 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 03:26:53 +1100 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 3:18 AM, Ian Kelly wrote: > On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor wrote: >> Good evening, >> >> I have defined a new numbering structure for certain mathematical advantages. >> >> How do I implement this in Python, or would I be better off writing >> this in C or C++? >> >> Ultra concise definition: http://i42.tinypic.com/af7w4h.png >> LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI >> >> Thanks for all suggestions, > > So if I am understanding your definition correctly your hexavigesimals > are ordered like this? > > 0, 1, ..., 9, A, B, ..., P, > > 0A, 0B, ..., 0P, > 1A, 1B, ..., 1P, > ..., > 9A, 9B, ..., 9P, > > A0, A1, ..., A9, > B0, B1, ..., B9, > ..., > P0, P1, ..., P9 > > And that's it, since your constraints preclude anything with more than 2 digits? To put it simply: I want a hexavigesimal of length n where each element contains at least one letter {A, B, ..., P} and one number {0, 1, 2, ... }. (unless n is less than 2, in which case only one of those constraints need to be met) and I want addition only for incrementing the element. Why do I want all this I hear you ask? - For use as a unique-identifier. I want a unique-ID of size 3. (3 positions, i.e. P0A) Any suggestions on how to implement this in python would be appreciated. Thanks, Alec Taylor From jeanpierreda at gmail.com Wed Nov 30 12:08:24 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 30 Nov 2011 12:08:24 -0500 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: <4ed64e12$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ed64e12$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: > Care to translate it into English? > > Then translate the English into pseudo-code. And the pseudo-code into > Python. Then, if and only if the Python version is too slow, translate it > into C. And now you are done! Mathematical English is pseudocode. Related: all theorems are also programs and vice versa. That said, I don't understand the notation either. What's \mathbb{M}? What does it mean ti be "in" some natural number n? (Are you using a set theoretic definition of natural numbers: e.g. x in y iff x <= y ?) Devin On Wed, Nov 30, 2011 at 10:38 AM, Steven D'Aprano wrote: > On Thu, 01 Dec 2011 02:19:31 +1100, Alec Taylor wrote: > >> Good evening, >> >> I have defined a new numbering structure for certain mathematical >> advantages. >> >> How do I implement this in Python, or would I be better off writing this >> in C or C++? >> >> Ultra concise definition: http://i42.tinypic.com/af7w4h.png > > Care to translate it into English? > > Then translate the English into pseudo-code. And the pseudo-code into > Python. Then, if and only if the Python version is too slow, translate it > into C. And now you are done! > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From egg1nog at gmail.com Wed Nov 30 12:10:09 2011 From: egg1nog at gmail.com (Michael Hennebry) Date: Wed, 30 Nov 2011 09:10:09 -0800 (PST) Subject: tp_new, tp_alloc, tp_init Message-ID: I've been reading about writing extension types in C and am rather fuzzy about the relationship between tp_new, tp_alloc and tp_init. Most especially, why tp_new? It seems to me that tp_alloc and tp_init would be sufficient. Most of my reading has been in the Noddy and Shoddy portions of docs.python.,org . From andrea.crotti.0 at gmail.com Wed Nov 30 13:03:35 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 30 Nov 2011 18:03:35 +0000 Subject: python 2.5 and ast In-Reply-To: <4ED4E35E.6090405@gmail.com> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ED4E35E.6090405@gmail.com> Message-ID: <4ED66FF7.1030104@gmail.com> Another thing about the AST, I am having fun trying to for example list out all the unused imports. I have already a visitor which works quite nicely I think, but now I would like to get a way to find all the unused imports, so I need more visitors that find out all the used names. I didn't find too much documentation about these kind of things, so any suggestions on how to approach? Pylint and snakefood have similar code, but they use the old "compiler" module, so it's not really helpful. From ian.g.kelly at gmail.com Wed Nov 30 13:38:45 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 30 Nov 2011 11:38:45 -0700 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 9:26 AM, Alec Taylor wrote: > On Thu, Dec 1, 2011 at 3:18 AM, Ian Kelly wrote: >> On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor wrote: >>> Good evening, >>> >>> I have defined a new numbering structure for certain mathematical advantages. >>> >>> How do I implement this in Python, or would I be better off writing >>> this in C or C++? >>> >>> Ultra concise definition: http://i42.tinypic.com/af7w4h.png >>> LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI >>> >>> Thanks for all suggestions, >> >> So if I am understanding your definition correctly your hexavigesimals >> are ordered like this? >> >> 0, 1, ..., 9, A, B, ..., P, >> >> 0A, 0B, ..., 0P, >> 1A, 1B, ..., 1P, >> ..., >> 9A, 9B, ..., 9P, >> >> A0, A1, ..., A9, >> B0, B1, ..., B9, >> ..., >> P0, P1, ..., P9 >> >> And that's it, since your constraints preclude anything with more than 2 digits? > > To put it simply: > > I want a hexavigesimal of length n where each element contains at > least one letter {A, B, ..., P} and one number {0, 1, 2, ... }. > (unless n is less than 2, in which case only one of those constraints > need to be met) > > and I want addition only for incrementing the element. > > Why do I want all this I hear you ask? - For use as a > unique-identifier. I want a unique-ID of size 3. (3 positions, i.e. > P0A) > > Any suggestions on how to implement this in python would be appreciated. Okay, that's much clearer. If you don't actually care about the ordinal value of each element, only about incrementing them, then I suggest implementing increment as follows: 1. Convert the string to an int using the regular base-26 conversion with the int() built-in. 2. In a loop, add 1 to the value. 3. Convert the value back to a string using the same base-26 conversion. I don't know of a built-in that does this, so you'll need to write your own, which isn't too difficult. 4. Check whether the new string meets all your constraints. If it does, return it. If not, go back to 2. and try again with the next integer. At most it will take 17 iterations to find a valid value, but most of the time the first value tried will be valid. I assume you're already aware that with 3 digits you'll only have 12480 possible unique IDs using this scheme? It just doesn't seem like very many to me. Cheers, Ian From detlev at die-offenbachs.de Wed Nov 30 13:55:05 2011 From: detlev at die-offenbachs.de (Detlev Offenbach) Date: Wed, 30 Nov 2011 19:55:05 +0100 Subject: How to get a correct entry in the menu for a Python application on Mac OS X Message-ID: Hello, I am fairly new to Mac OS X and would like to know, what I have to do to make my Python application show the correct name in the menu bar. What did I do so far. I created an application package containing the .plist file with correct entries and a shell script, that starts the correct Python interpreter with the the main script. The menu bar just shows Python instead of the name of my application. If you are interested the application can be found via http://eric-ide.python-projects.org. Regards, Detlev -- Detlev Offenbach detlev at die-offenbachs.de From alec.taylor6 at gmail.com Wed Nov 30 14:00:38 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 06:00:38 +1100 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: References: Message-ID: Excellent, I'll see if I can implement that. I was thinking more base data-type, but that seems impossible in python. 17 iterations (rarghh!) But yeah, I'll try that, thanks. On Thu, Dec 1, 2011 at 5:38 AM, Ian Kelly wrote: > On Wed, Nov 30, 2011 at 9:26 AM, Alec Taylor wrote: >> On Thu, Dec 1, 2011 at 3:18 AM, Ian Kelly wrote: >>> On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor wrote: >>>> Good evening, >>>> >>>> I have defined a new numbering structure for certain mathematical advantages. >>>> >>>> How do I implement this in Python, or would I be better off writing >>>> this in C or C++? >>>> >>>> Ultra concise definition: http://i42.tinypic.com/af7w4h.png >>>> LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI >>>> >>>> Thanks for all suggestions, >>> >>> So if I am understanding your definition correctly your hexavigesimals >>> are ordered like this? >>> >>> 0, 1, ..., 9, A, B, ..., P, >>> >>> 0A, 0B, ..., 0P, >>> 1A, 1B, ..., 1P, >>> ..., >>> 9A, 9B, ..., 9P, >>> >>> A0, A1, ..., A9, >>> B0, B1, ..., B9, >>> ..., >>> P0, P1, ..., P9 >>> >>> And that's it, since your constraints preclude anything with more than 2 digits? >> >> To put it simply: >> >> I want a hexavigesimal of length n where each element contains at >> least one letter {A, B, ..., P} and one number {0, 1, 2, ... }. >> (unless n is less than 2, in which case only one of those constraints >> need to be met) >> >> and I want addition only for incrementing the element. >> >> Why do I want all this I hear you ask? - For use as a >> unique-identifier. I want a unique-ID of size 3. (3 positions, i.e. >> P0A) >> >> Any suggestions on how to implement this in python would be appreciated. > > Okay, that's much clearer. ?If you don't actually care about the > ordinal value of each element, only about incrementing them, then I > suggest implementing increment as follows: > > 1. Convert the string to an int using the regular base-26 conversion > with the int() built-in. > 2. In a loop, add 1 to the value. > 3. Convert the value back to a string using the same base-26 > conversion. ?I don't know of a built-in that does this, so you'll need > to write your own, which isn't too difficult. > 4. Check whether the new string meets all your constraints. ?If it > does, return it. ?If not, go back to 2. and try again with the next > integer. > > At most it will take 17 iterations to find a valid value, but most of > the time the first value tried will be valid. > > I assume you're already aware that with 3 digits you'll only have > 12480 possible unique IDs using this scheme? ?It just doesn't seem > like very many to me. > > Cheers, > Ian From __peter__ at web.de Wed Nov 30 14:05:50 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Nov 2011 20:05:50 +0100 Subject: Defining a new base-type in Python based off Hexavigesimal References: Message-ID: Alec Taylor wrote: > On Thu, Dec 1, 2011 at 3:18 AM, Ian Kelly wrote: >> On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor >> wrote: >>> Good evening, >>> >>> I have defined a new numbering structure for certain mathematical >>> advantages. >>> >>> How do I implement this in Python, or would I be better off writing >>> this in C or C++? >>> >>> Ultra concise definition: http://i42.tinypic.com/af7w4h.png >>> LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI >>> >>> Thanks for all suggestions, >> >> So if I am understanding your definition correctly your hexavigesimals >> are ordered like this? >> >> 0, 1, ..., 9, A, B, ..., P, >> >> 0A, 0B, ..., 0P, >> 1A, 1B, ..., 1P, >> ..., >> 9A, 9B, ..., 9P, >> >> A0, A1, ..., A9, >> B0, B1, ..., B9, >> ..., >> P0, P1, ..., P9 >> >> And that's it, since your constraints preclude anything with more than 2 >> digits? > > To put it simply: > > I want a hexavigesimal of length n where each element contains at > least one letter {A, B, ..., P} and one number {0, 1, 2, ... }. > (unless n is less than 2, in which case only one of those constraints > need to be met) > > and I want addition only for incrementing the element. > > Why do I want all this I hear you ask? - For use as a > unique-identifier. I want a unique-ID of size 3. (3 positions, i.e. > P0A) > > Any suggestions on how to implement this in python would be appreciated. Maybe you don't need a class if you produce the ids with a generator like so: >>> from itertools import product >>> def hxv(n): ... letters = "ABCDEFGHIJKLMNOP" ... digits = "0123456789" ... both = digits + letters ... if n == 1: ... for x in both: ... yield x ... else: ... for x in product(*[both]*n): ... s = "".join(x) ... if not s.isdigit() and not s.isalpha(): ... yield s ... >>> ids = hxv(3) >>> next(ids) '00A' >>> next(ids) '00B' >>> for i, x in enumerate(hxv(3)): pass ... >>> i, x (12479, 'PP9') From nospam at torek.net Wed Nov 30 14:29:31 2011 From: nospam at torek.net (Chris Torek) Date: 30 Nov 2011 19:29:31 GMT Subject: Py2.7/FreeBSD: maximum number of open files References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C26485F@EXVMBX020-12.exch020.serverdata.net> Message-ID: In article Christian Heimes wrote: >Am 14.11.2011 19:28, schrieb Tobias Oberstein: >> Thanks! This is probably the most practical option I can go. >> >> I've just tested: the backported new IO on Python 2.7 will indeed >> open >32k files on FreeBSD. It also creates the files much faster. >> The old, non-monkey-patched version was getting slower and >> slower as more files were opened/created .. > >I wonder what's causing the O(n^2) behavior. Is it the old file type or >BSD's fopen() fault? It is code in libc. My old stdio (still in use on FreeBSD) was never designed to be used in situations with more than roughly 256 file descriptors -- hence the "short" in the file number field. (The OS used to be full of other places that kept the maximum allowable file descriptor fairly small, such as the on-stack copies of fd_set objects in select() calls.) You will want to redesign the code that finds or creates a free "FILE" object, and probably some of the things that work with line-buffered FILEs (specifically calls to _fwalk() when reading from a line-buffered stream). -- In-Real-Life: Chris Torek, Wind River Systems Intel require I note that my opinions are not those of WRS or Intel Salt Lake City, UT, USA (40?39.22'N, 111?50.29'W) +1 801 277 2603 email: gmail (figure it out) http://web.torek.net/torek/index.html From tdldev at gmail.com Wed Nov 30 15:30:48 2011 From: tdldev at gmail.com (Verde Denim) Date: Wed, 30 Nov 2011 15:30:48 -0500 Subject: Py and SQL Message-ID: All I have a sql script that I've included in a simple Py file that gives an error in the SQL. The problem is that the SQL code executes correctly in a database IDE environment (in this case ora developer). So, I'm concluding that I'm doing something amiss in the Py code. Does anyone see why this code would return a 'missing expression' sql error? Essentially, the code should start, ask for a privilege, and then collect the priv, role, and user data. Any input is appreciated. #!/bin/bash import time import cx_Oracle dbConn = cx_Oracle.connect('juser', 'pass', '1.2.3.4:/orcl:DEDICATED', cclass = "ABC", purity = cx_Oracle.ATTR_PURITY_SELF) pStart = time.time() dbVersion = dbConn.version.split(".") majVer = dbVersion[0] print "Oracle Version: %s" %(majVer) print "Full Version: %s" %(dbConn.version) dbCursor1 = dbConn.cursor() dbCursor1.execute('select lpad(' ', 2*level) || c "Privilege, Roles and Users" from ( select null p, name c from system_privilege_map where name like upper(\'%&enter_privliege%\') union select granted_role p, grantee c from dba_role_privs union select privilege p, grantee c from dba_sys_privs) start with p is null connect by p = prior c') dbRowResult = dbCursor1.fetchall() for dbRow in dbRowResult: print dbRow dbCursor1.close() pElapsed = (time.time() - pStart) print pElapsed, " seconds" dbConn.close() -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodperson at rodperson.com Wed Nov 30 15:37:44 2011 From: rodperson at rodperson.com (Rod Person) Date: Wed, 30 Nov 2011 15:37:44 -0500 Subject: Py and SQL In-Reply-To: References: Message-ID: <20111130153744.0000017c@unknown> On Wed, 30 Nov 2011 15:30:48 -0500 Verde Denim wrote: > All > I have a sql script that I've included in a simple Py file that gives > an error in the SQL. The problem is that the SQL code executes > correctly in a database IDE environment (in this case ora developer). > So, I'm concluding that I'm doing something amiss in the Py code. > Does anyone see why this code would return a 'missing expression' sql > error? Essentially, the code should start, ask for a privilege, and > then collect the priv, role, and user data. Any input is appreciated. > > #!/bin/bash > import time > import cx_Oracle > > dbConn = cx_Oracle.connect('juser', 'pass', '1.2.3.4:/orcl:DEDICATED', > cclass = "ABC", purity = cx_Oracle.ATTR_PURITY_SELF) > > pStart = time.time() > > dbVersion = dbConn.version.split(".") > > majVer = dbVersion[0] > > print "Oracle Version: %s" %(majVer) > print "Full Version: %s" %(dbConn.version) > > dbCursor1 = dbConn.cursor() > dbCursor1.execute('select lpad(' ', 2*level) || c "Privilege, Roles > and Users" from ( select null p, name c from system_privilege_map > where name like upper(\'%&enter_privliege%\') union select > granted_role p, grantee c from dba_role_privs union select privilege > p, grantee c from dba_sys_privs) start with p is null connect by p = > prior c') dbRowResult = dbCursor1.fetchall() > for dbRow in dbRowResult: > print dbRow > Try changing the wrapping ' ' to " " and the inside double qoutes to single, like this dbCursor1.execute("select lpad(' ', 2*level) || c 'Privilege, Roles and Users' from ( select null p, name c from system_privilege_map where name like upper(\'%&enter_privliege%\') union select granted_role p, grantee c from dba_role_privs union select privilege p, grantee c from dba_sys_privs) start with p is null connect by p = prior c") -- Rod The club is like groceries, and I jus bag a bi@$&! ? Santonio Holmes on the Twitter From bahamutzero8825 at gmail.com Wed Nov 30 16:03:22 2011 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Wed, 30 Nov 2011 15:03:22 -0600 Subject: Need some IPC pointers Message-ID: <4ED69A1A.3080609@gmail.com> I've done some research, but I'm not sure what's most appropriate for my situation. What I want to do is have a long running process that spawns processes (that aren't necessarily written in Python) and communicates with them. The children can be spawned at any time and communicate at any time. Being able to communicate with non-local processes would be nice, but is not necessary. The implementation needs to be cross-platform, but child processes will use the same OS as the parent during runtime. I don't think I'll ever need to transfer anything complicated or large - just strings or possibly tuples/lists. I'd rather not go outside the standard library (but I'd consider it). I don't need to worry about compatibility with older Python versions; if it only works with Python 3.2, that's not a problem. I'm thinking sockets, but perhaps there's something simpler/easier. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0 From miki.tebeka at gmail.com Wed Nov 30 16:22:25 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 30 Nov 2011 13:22:25 -0800 (PST) Subject: Need some IPC pointers In-Reply-To: References: Message-ID: <3519788.203.1322688146008.JavaMail.geo-discussion-forums@yqfv40> There are two different problems. One is the medium to pass messages, sockets are good but there are other options and depends on your requirement you need to pick the best one. The other is serialization format, here you have marshal, pickle, JSON, XML and more. For me JSON over sockets works well in the past. It has the nice property that you can read messages without need for a special decoder (like in the case of marshal/pickle). From miki.tebeka at gmail.com Wed Nov 30 16:22:25 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 30 Nov 2011 13:22:25 -0800 (PST) Subject: Need some IPC pointers In-Reply-To: References: Message-ID: <3519788.203.1322688146008.JavaMail.geo-discussion-forums@yqfv40> There are two different problems. One is the medium to pass messages, sockets are good but there are other options and depends on your requirement you need to pick the best one. The other is serialization format, here you have marshal, pickle, JSON, XML and more. For me JSON over sockets works well in the past. It has the nice property that you can read messages without need for a special decoder (like in the case of marshal/pickle). From jeanpierreda at gmail.com Wed Nov 30 16:32:31 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 30 Nov 2011 16:32:31 -0500 Subject: Need some IPC pointers In-Reply-To: <4ED69A1A.3080609@gmail.com> References: <4ED69A1A.3080609@gmail.com> Message-ID: > I'm thinking sockets, but perhaps there's something simpler/easier. Sockets are the only thing that will work without threads on all platforms. You could also use threads and pipes. (I'm not actually sure how threads+pipes works, but I'm told that it's a viable approach). Usually things are simpler and easier because they wrap all the cross-platform messiness behind a nice API, and then give you a higher level protocol for IPC on top of that. Unfortunately, the fewer external dependencies you have, the more you have to rewrite yourself. For what it's worth, I wrote something potentially similar using Twisted and AMP. AMP is an Asynchronous Messaging Protocol: this basically means that clients and servers can send messages to each other at any time in any order. Twisted makes sure that the right response gets associated with the right message. This can be very convenient -- you might request something from another process, and then to compute its answer it might ask for some additional information from you, and then you give it that information, and it sends back the final result. All the communication is done over TCP, usually using Twisted. So this does involve bringing in a fairly large dependency. For me, the tradeoff in programmer productivity was worth it, but of course it really depends on your situation. A more synchronous protocol might be more useful to you (although my impression was that perhaps you might be interested in something like AMP), and synchronous protocols directly on top of sockets are not so difficult to implement (although making them work across platforms is still too hard for my taste). Devin On Wed, Nov 30, 2011 at 4:03 PM, Andrew Berg wrote: > I've done some research, but I'm not sure what's most appropriate for my > situation. What I want to do is have a long running process that spawns > processes (that aren't necessarily written in Python) and communicates > with them. The children can be spawned at any time and communicate at > any time. Being able to communicate with non-local processes would be > nice, but is not necessary. The implementation needs to be > cross-platform, but child processes will use the same OS as the parent > during runtime. > I don't think I'll ever need to transfer anything complicated or large - > just strings or possibly tuples/lists. I'd rather not go outside the > standard library (but I'd consider it). I don't need to worry about > compatibility with older Python versions; if it only works with Python > 3.2, that's not a problem. > I'm thinking sockets, but perhaps there's something simpler/easier. > > -- > CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0 > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Wed Nov 30 17:12:10 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Nov 2011 17:12:10 -0500 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: On 11/30/2011 3:58 AM, Peter Otten wrote: > Terry Reedy wrote: > >> On 11/30/2011 1:20 AM, ??? wrote: >>> Good after >>> I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it >>> to a list like list = ["aaaa","bbbb","ccc"],what can id do? >> >> The easiest -- and most dangerous -- way is >> >>> eval('["aaaa","bbbb","ccc"]') >> ['aaaa', 'bbbb', 'ccc'] >> >> But DO NOT eval unexamined strings from untrusted sources. The reason is >> that it is much the same as letting an untrusted person sit unsupervised >> as the keyboard of your computer with a command window open. You would >> not want to eval >> "from os import system; system('')" >> where '' is replaced by something obnoxious for your >> operating system. > > You can avoid these problems with ast.literal_eval(): > > literal_eval(node_or_string) > Safely evaluate an expression node or a string containing a Python > expression. The string or node provided may only consist of the > following Python literal structures: strings, numbers, tuples, lists, > dicts, booleans, and None. I keep forgetting that someone thought to solve the problem of eval being both convinient and dangerous. Maybe if I type it once, I will remember. >>> import ast >>> ast.literal_eval('["aaaa","bbbb","ccc"]') ['aaaa', 'bbbb', 'ccc'] I think it would be better if safe_eval were available as an easily accessible builtin and dangerous_eval were tucked away in a module ;-). -- Terry Jan Reedy From malaclypse2 at gmail.com Wed Nov 30 17:14:57 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 30 Nov 2011 17:14:57 -0500 Subject: Py and SQL In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 3:30 PM, Verde Denim wrote: > dbCursor1.execute('select lpad(' ', 2*level) || c "Privilege, Roles and > Users" from ( select null p, name c from system_privilege_map where name > like upper(\'%&enter_privliege%\') union select granted_role p, grantee c > from dba_role_privs union select privilege p, grantee c from dba_sys_privs) > start with p is null connect by p = prior c') > I think this is your problem. Your string is delimited with single quotes on the outside ('), but you also have a mix of single and double quotes inside your string. If you were to assign this to a variable and print it out, you would probably see the problem right away. You have two options. First, you could flip the outer quotes to double quotes, then switch all of the quotes inside the string to single quotes (I think that will work fine in SQL). Second, you could use a triple-quoted string by switching the outer quotes to ''' or """. Doing that would let you mix whatever kinds of quotes you like inside your string, like this (untested): sql = '''select lpad(' ', 2*level) || c "Privilege, Roles and Users" from ( select null p, name c from system_privilege_map where name like upper(\'%&enter_privliege%\') union select granted_role p, grantee c from dba_role_privs union select privilege p, grantee c from dba_sys_privs) start with p is null connect by p = prior c''' dbCursor1.execute(sql) Once you do that, I think you will find that the "&enter_priviliege" bit in your SQL isn't going to do what you want. I assume you're expecting that to automatically pop up some sort of dialog box asking the user to enter a value for that variable? That isn't going to happen in python. That's a function of the database IDE you use. You'll need to use python to ask the user for the privilege level, then substitute it into the sql yourself. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From bahamutzero8825 at gmail.com Wed Nov 30 17:19:39 2011 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Wed, 30 Nov 2011 16:19:39 -0600 Subject: Need some IPC pointers In-Reply-To: References: <4ED69A1A.3080609@gmail.com> Message-ID: <4ED6ABFB.2040808@gmail.com> On 11/30/2011 3:32 PM, Devin Jeanpierre wrote: > You could also use threads and pipes. (I'm not actually > sure how threads+pipes works, but I'm told that it's a viable > approach). Sounds interesting, but I'm not familiar with threading (not that I wouldn't be willing to learn). Is it even possible to pipe into a running process, though? > For what it's worth, I wrote something potentially similar using Twisted > and AMP. AMP is an Asynchronous Messaging Protocol: this basically > means that clients and servers can send messages to each other at any > time in any order. Twisted makes sure that the right response gets > associated with the right message. This can be very convenient -- you > might request something from another process, and then to compute its > answer it might ask for some additional information from you, and then > you give it that information, and it sends back the final result. > > All the communication is done over TCP, usually using Twisted. So this > does involve bringing in a fairly large dependency. Sounds like overkill, but I'll take a look. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0 From kuaile.xu at gmail.com Wed Nov 30 17:24:45 2011 From: kuaile.xu at gmail.com (kuaile xu) Date: Wed, 30 Nov 2011 14:24:45 -0800 (PST) Subject: unpack('>f', b'\x00\x01\x00\x00') Message-ID: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> Hi: I am working on a python script that parses mp4 video header. Once of the field is a 32-bit fixed-point number. I know that the four bytes are: 00, 01, 00, 00. I have a third party mp4 parsing program which displays this field's value is:1.0. However, the struct.unpack gets a value of 0.0. Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from struct import * >>> unpack('>f', b'\x00\x01\x00\x00') (9.183549615799121e-41,) >>> In addition, there is another field which is a 16-bit fixed point number. How do I unpack two bytes into a float? Thank you very much, From irmen at -NOSPAM-xs4all.nl Wed Nov 30 17:28:15 2011 From: irmen at -NOSPAM-xs4all.nl (Irmen de Jong) Date: Wed, 30 Nov 2011 23:28:15 +0100 Subject: Need some IPC pointers In-Reply-To: References: Message-ID: <4ed6ae00$0$6843$e4fe514c@news2.news.xs4all.nl> On 30-11-11 22:03, Andrew Berg wrote: > I've done some research, but I'm not sure what's most appropriate for my > situation. What I want to do is have a long running process that spawns > processes (that aren't necessarily written in Python) and communicates > with them. The children can be spawned at any time and communicate at > any time. Being able to communicate with non-local processes would be > nice, but is not necessary. The implementation needs to be > cross-platform, but child processes will use the same OS as the parent > during runtime. > I don't think I'll ever need to transfer anything complicated or large - > just strings or possibly tuples/lists. I'd rather not go outside the > standard library (but I'd consider it). I don't need to worry about > compatibility with older Python versions; if it only works with Python > 3.2, that's not a problem. > I'm thinking sockets, but perhaps there's something simpler/easier. > Standard library, local processes: multiprocessing module. If that doesn't suit your needs, maybe check out Pyro: http://packages.python.org/Pyro4/ Pyro allows objects to talk to each other over the network, with minimal programming effort. You can just use normal Python method calls to call objects on other machines (or locally, ofcourse). It's written in 100% pure Python and works on Python 2.6 and upwards (including 3.x). Regards, Irmen de Jong From tjreedy at udel.edu Wed Nov 30 17:29:12 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Nov 2011 17:29:12 -0500 Subject: Python crashes on segmentation error In-Reply-To: References: <8bffed0f-1050-418a-834d-f7060a899ab7@h5g2000yqk.googlegroups.com> Message-ID: On 11/30/2011 7:58 AM, Christian Heimes wrote: > Am 30.11.2011 11:42, schrieb Ben Richardson: >> Python crashes every time i run the following command? >> >>>>> import cv >> Segmentation fault: 11 >> >> Python quit unexpectedly - any help would be greatly appreciated - >> thankyou in advance :) >> >> Here is crash report? > [...] >> >> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread >> 0 ??? 000000000000000000 0 + 0 >> 1 org.python.python 0x00000001006c7885 PyImport_Import >> + 121 >> 2 org.python.python 0x00000001006c7a1e >> PyImport_ImportModule + 32 >> 3 cv.so 0x00000001004f5082 initcv + 18 >> 4 org.python.python 0x00000001000dc071 >> _PyImport_LoadDynamicModule + 177 > > It looks like you have a faulty 3rd party library with an extension > module called cv.so that is causing the segfault. The segfault occurs > either inside or during the import of the cv module. initcv() is the > init function of the cv module that is called automatically during the > import. In other words, contact the authors of the cv module. Or perhaps first check to make sure that the cv.so build you are running is intended to be compatible with the Python build you are running. -- Terry Jan Reedy From irmen at -NOSPAM-xs4all.nl Wed Nov 30 17:31:08 2011 From: irmen at -NOSPAM-xs4all.nl (Irmen de Jong) Date: Wed, 30 Nov 2011 23:31:08 +0100 Subject: Need some IPC pointers In-Reply-To: <4ed6ae00$0$6843$e4fe514c@news2.news.xs4all.nl> References: <4ed6ae00$0$6843$e4fe514c@news2.news.xs4all.nl> Message-ID: <4ed6aeac$0$6843$e4fe514c@news2.news.xs4all.nl> On 30-11-11 23:28, Irmen de Jong wrote: > On 30-11-11 22:03, Andrew Berg wrote: >> processes (that aren't necessarily written in Python) and communicates Oops, missed this on my first read. This rules out my suggestion of Pyro because that requires Python on both ends (or Java/.net on the client side). Sorry for the noise. Irmen From jeanpierreda at gmail.com Wed Nov 30 17:41:33 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 30 Nov 2011 17:41:33 -0500 Subject: Need some IPC pointers In-Reply-To: <4ED6ABFB.2040808@gmail.com> References: <4ED69A1A.3080609@gmail.com> <4ED6ABFB.2040808@gmail.com> Message-ID: > Sounds interesting, but I'm not familiar with threading (not that I > wouldn't be willing to learn). > Is it even possible to pipe into a running process, though? You create the pipe to the process when you start it. e.g. subprocess.Popen(['ls', 'foo'], stdout=subprocess.PIPE, stdin=subprocess.PIPE) Irmen de Jong mentions the multiprocessing module, that might be a better approach. I don't use it for production purposes because it has bad properties when processes are killed abruptly (it can't tell necessarily the difference between a truncated message and a normal message). It doesn't feel safe, you know? (Of course, neither do threads!) Devin On Wed, Nov 30, 2011 at 5:19 PM, Andrew Berg wrote: > On 11/30/2011 3:32 PM, Devin Jeanpierre wrote: >> You could also use threads and pipes. (I'm not actually >> sure how threads+pipes works, but I'm told that it's a viable >> approach). > Sounds interesting, but I'm not familiar with threading (not that I > wouldn't be willing to learn). > Is it even possible to pipe into a running process, though? > >> For what it's worth, I wrote something potentially similar using Twisted >> and AMP. AMP is an Asynchronous Messaging Protocol: this basically >> means that clients and servers can send messages to each other at any >> time in any order. Twisted makes sure that the right response gets >> associated with the right message. This can be very convenient -- you >> might request something from another process, and then to compute its >> answer it might ask for some additional information from you, and then >> you give it that information, and it sends back the final result. >> >> All the communication is done over TCP, usually using Twisted. So this >> does involve bringing in a fairly large dependency. > Sounds like overkill, but I'll take a look. > > -- > CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0 > -- > http://mail.python.org/mailman/listinfo/python-list > From hidura at gmail.com Wed Nov 30 17:48:37 2011 From: hidura at gmail.com (Hidura) Date: Wed, 30 Nov 2011 18:48:37 -0400 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: Why you don't make this "['1','2','3']".strip("[]").split(',') work for me El nov 30, 2011 10:16 p.m., "Terry Reedy" escribi?: > On 11/30/2011 3:58 AM, Peter Otten wrote: > >> Terry Reedy wrote: >> >> On 11/30/2011 1:20 AM, ??? wrote: >>> >>>> Good after >>>> I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it >>>> to a list like list = ["aaaa","bbbb","ccc"],what can id do? >>>> >>> >>> The easiest -- and most dangerous -- way is >>> >>> eval('["aaaa","bbbb","ccc"]') >>> ['aaaa', 'bbbb', 'ccc'] >>> >>> But DO NOT eval unexamined strings from untrusted sources. The reason is >>> that it is much the same as letting an untrusted person sit unsupervised >>> as the keyboard of your computer with a command window open. You would >>> not want to eval >>> "from os import system; system('')" >>> where '' is replaced by something obnoxious for your >>> operating system. >>> >> >> You can avoid these problems with ast.literal_eval(): >> >> literal_eval(node_or_string) >> Safely evaluate an expression node or a string containing a Python >> expression. The string or node provided may only consist of the >> following Python literal structures: strings, numbers, tuples, lists, >> dicts, booleans, and None. >> > > I keep forgetting that someone thought to solve the problem of eval being > both convinient and dangerous. Maybe if I type it once, I will remember. > >>> import ast > >>> ast.literal_eval('["aaaa","**bbbb","ccc"]') > ['aaaa', 'bbbb', 'ccc'] > > I think it would be better if safe_eval were available as an easily > accessible builtin and dangerous_eval were tucked away in a module ;-). > > -- > Terry Jan Reedy > > > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Wed Nov 30 18:02:53 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 30 Nov 2011 15:02:53 -0800 Subject: unpack('>f', b'\x00\x01\x00\x00') In-Reply-To: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> References: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> Message-ID: On Wed, Nov 30, 2011 at 2:24 PM, kuaile xu wrote: > Hi: > > I am working on a python script that parses mp4 video header. Once of > the field is a 32-bit fixed-point number. > > I know that the four bytes are: 00, 01, 00, 00. I have a third party > mp4 parsing program which displays this field's value is:1.0. > > However, the struct.unpack gets a value of 0.0. > > Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit > (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from struct import * >>>> unpack('>f', b'\x00\x01\x00\x00') > (9.183549615799121e-41,) Floating-point and fixed-point are *separate* number formats with distinct representations. You cannot expect to correctly (un)pack one as if it was the other. Similarly, converting between the two formats can introduce range and/or imprecision error. C does not have a built-in fixed-point datatype, so the `struct` module doesn't handle fixed-point numbers directly. You're going to have to unpack it (or parts of it) as something more raw, and then do the necessary bit manipulation yourself. Cheers, Chris -- http://rebertia.com From tjreedy at udel.edu Wed Nov 30 18:12:14 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Nov 2011 18:12:14 -0500 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: <4ED6B84E.6080706@udel.edu> On 11/30/2011 5:48 PM, Hidura wrote: > Why you don't make this "['1','2','3']".strip("[]").split(',') work for me Look more carefully. This is not the same as ast.literal_eval(). >>> "['1','2','3']".strip("[]").split(',') ["'1'", "'2'", "'3'"] # list of 3-char strings >>> ast.literal_eval("['1','2','3']") ['1', '2', '3'] # list of 1-char strings Even if it were the same, it would be specific to lists of strings and would not work for anything else. From kuaile.xu at gmail.com Wed Nov 30 18:25:27 2011 From: kuaile.xu at gmail.com (kuaile xu) Date: Wed, 30 Nov 2011 15:25:27 -0800 (PST) Subject: unpack('>f', b'\x00\x01\x00\x00') References: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> Message-ID: <6628ac4b-f6d2-40b6-b1e6-6b0a4bf4e5e2@c18g2000yqj.googlegroups.com> On Nov 30, 6:02?pm, Chris Rebert wrote: > On Wed, Nov 30, 2011 at 2:24 PM, kuaile xu wrote: > > Hi: > > > I am working on a python script that parses mp4 video header. Once of > > the field is a 32-bit fixed-point number. > > > I know that the four bytes are: 00, 01, 00, 00. I have a third party > > mp4 parsing program which displays this field's value is:1.0. > > > However, the struct.unpack gets a value of 0.0. > > > Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit > > (AMD64)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> from struct import * > >>>> unpack('>f', b'\x00\x01\x00\x00') > > (9.183549615799121e-41,) > > Floating-point and fixed-point are *separate* number formats with > distinct representations. You cannot expect to correctly (un)pack one > as if it was the other. Similarly, converting between the two formats > can introduce range and/or imprecision error. > > C does not have a built-in fixed-point datatype, so the `struct` > module doesn't handle fixed-point numbers directly. You're going to > have to unpack it (or parts of it) as something more raw, and then do > the necessary bit manipulation yourself. > > Cheers, > Chris > --http://rebertia.com > > Thanks a lot. From python.list at tim.thechases.com Wed Nov 30 18:25:46 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 30 Nov 2011 17:25:46 -0600 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: <4ED6BB7A.30809@tim.thechases.com> On 11/30/11 16:48, Hidura wrote: > Why you don't make this "['1','2','3']".strip("[]").split(',') work for me because it breaks on things like s = """ [[1,2,3],42,'''triple the fun!''', "can't touch this, eh?",r'"Back\\\slashes?!", she said.', [4,5,6]] """ Commas can be embedded in strings, strings can be delimited with single, double, or triple quotes, raw strings can be used, more than one opening or closing "["/"]" can appear in a row, leading or trailing whitespace might throw you off...using ast.literal_eval() should just Do the Right Thing?. -tkc From ian.g.kelly at gmail.com Wed Nov 30 18:49:52 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 30 Nov 2011 16:49:52 -0700 Subject: unpack('>f', b'\x00\x01\x00\x00') In-Reply-To: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> References: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> Message-ID: On Wed, Nov 30, 2011 at 3:24 PM, kuaile xu wrote: > Hi: > > I am working on a python script that parses mp4 video header. Once of > the field is a 32-bit fixed-point number. > > I know that the four bytes are: 00, 01, 00, 00. I have a third party > mp4 parsing program which displays this field's value is:1.0. > > However, the struct.unpack gets a value of 0.0. > > Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit > (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from struct import * >>>> unpack('>f', b'\x00\x01\x00\x00') > (9.183549615799121e-41,) >>>> Like Chris said, you can't unpack it as a float. Assuming that's Q16 fixed-point, what you can do is unpack it as an int and then multiply by 2.0 ** -16 to get the corresponding float value. There should be no loss of precision converting to a float since floats store 52 bits of precision, but be aware that you could have overflow or loss of precision when converting in the opposite direction. > In addition, there is another field which is a 16-bit fixed point > number. How do I unpack two bytes into a float? Same as above, just change the multiplier to match the scale. Cheers, Ian From rosuav at gmail.com Wed Nov 30 21:14:26 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 1 Dec 2011 13:14:26 +1100 Subject: Need some IPC pointers In-Reply-To: <4ED69A1A.3080609@gmail.com> References: <4ED69A1A.3080609@gmail.com> Message-ID: On Thu, Dec 1, 2011 at 8:03 AM, Andrew Berg wrote: > processes (that aren't necessarily written in Python) ... > non-local processes would be nice ... > The implementation needs to be cross-platform ... > I don't think I'll ever need to transfer anything complicated or large - > just strings or possibly tuples/lists. > I'm thinking sockets, but perhaps there's something simpler/easier. Definitely sockets, as other posters have said. The only question is, what encapsulation format (since sockets give just a stream of bytes). Since you want non-Python processes to be involved, I would be inclined to avoid using Python's own pickling system; JSON may be viable, and it's well known so you should be able to find support in other languages. Alternatively, take a careful look at your dataset and invent your own system. If your strings will never contain a pipe character, you could define a tuple/list to be simply pipe-separated strings; if they'll never contain newlines, you can specify your protocol to be newline-terminated. For command/response protocols over TCP/IP, I strongly recommend poking around with existing protocols such as the email trio (SMTP, POP, and IMAP); there's many good ideas to be gained from them. If you can, try to keep your protocol to ASCII text. It makes debugging far easier, as you can simply point a telnet/mud client at your server and manually step through things. Chris Angelico From roy at panix.com Wed Nov 30 22:15:27 2011 From: roy at panix.com (Roy Smith) Date: Wed, 30 Nov 2011 22:15:27 -0500 Subject: Clever hack or code abomination? Message-ID: I need to try a bunch of names in sequence until I find one that works (definition of "works" is unimportant). The algorithm is: 1) Given a base name, "foo", first see if just plain "foo" works. 2) If not, try "foo-1", "foo-2", and so on 3) If you reach "foo-20", give up. What would you say if you saw this: for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]: It generates the right sequence of strings. But, if you came upon that code, would it make sense to you, or would you spend half the afternoon trying to figure out what it did and the other half of the afternoon ranting about the deranged lunatic who wrote it? From steve+comp.lang.python at pearwood.info Wed Nov 30 22:38:13 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Dec 2011 03:38:13 GMT Subject: Clever hack or code abomination? References: Message-ID: <4ed6f6a5$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 30 Nov 2011 22:15:27 -0500, Roy Smith wrote: > I need to try a bunch of names in sequence until I find one that works > (definition of "works" is unimportant). The algorithm is: > > 1) Given a base name, "foo", first see if just plain "foo" works. > > 2) If not, try "foo-1", "foo-2", and so on > > 3) If you reach "foo-20", give up. > > What would you say if you saw this: > > for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]: > > It generates the right sequence of strings. But, if you came upon that > code, would it make sense to you, or would you spend half the afternoon > trying to figure out what it did and the other half of the afternoon > ranting about the deranged lunatic who wrote it? Nah, it's fine. Not exactly the clearest piece of code in the world, but hardly worth a rant. I'd be more likely to write that as: for suffix in [''] + ["-%d" % i for i in range(1, 21)]: or if I needed to do it more than once, as a generator: def suffixes(max=20): yield "" for i in range(1, max+1): yield "-%d" % i -- Steven From steve+comp.lang.python at pearwood.info Wed Nov 30 22:42:54 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Dec 2011 03:42:54 GMT Subject: How convert a list string to a real list References: Message-ID: <4ed6f7be$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote: > I think it would be better if safe_eval were available as an easily > accessible builtin and dangerous_eval were tucked away in a module ;-). +100000 -- Steven From anacrolix at gmail.com Wed Nov 30 22:49:46 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Thu, 1 Dec 2011 14:49:46 +1100 Subject: Clever hack or code abomination? In-Reply-To: References: Message-ID: def possible_names(): yield "foo" for i in range(20): yield "foo-" + str(i) ?_? On Thu, Dec 1, 2011 at 2:15 PM, Roy Smith wrote: > I need to try a bunch of names in sequence until I find one that works > (definition of "works" is unimportant). ?The algorithm is: > > 1) Given a base name, "foo", first see if just plain "foo" works. > > 2) If not, try "foo-1", "foo-2", and so on > > 3) If you reach "foo-20", give up. > > What would you say if you saw this: > > for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]: > > It generates the right sequence of strings. ?But, if you came upon that > code, would it make sense to you, or would you spend half the afternoon > trying to figure out what it did and the other half of the afternoon > ranting about the deranged lunatic who wrote it? > -- > http://mail.python.org/mailman/listinfo/python-list From steve+comp.lang.python at pearwood.info Wed Nov 30 23:17:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Dec 2011 04:17:49 GMT Subject: Disable readline Message-ID: <4ed6ffed$0$29986$c3e8da3$5496439d@news.astraweb.com> Is there a way to disable readline support in the interactive interpreter at runtime? Either from within an existing session, or when the session starts up will do. I am trying to test the behaviour of some interactive scripts which rely on readline. I have work-arounds for missing readline (such as on Windows systems) but no way to test them properly on Linux. If all else fails, are there any traps or pitfalls in installing a second Python installation with readline support disabled? Any other suggestions? -- Steven From ben+python at benfinney.id.au Wed Nov 30 23:25:23 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 01 Dec 2011 15:25:23 +1100 Subject: How convert a list string to a real list References: <4ed6f7be$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87ehwo5364.fsf@benfinney.id.au> Steven D'Aprano writes: > On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote: > > > I think it would be better if safe_eval were available as an easily > > accessible builtin and dangerous_eval were tucked away in a module ;-). > > +100000 You do realise that any vote outside the range ?1 through +1 is invalid, right? Every person gets a maximum of 1, positive or negative. Outside that, the vote police come to kick you off the internet. -- \ ?Everything is futile.? ?Marvin of Borg | `\ | _o__) | Ben Finney From alec.taylor6 at gmail.com Wed Nov 30 23:33:51 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 15:33:51 +1100 Subject: How convert a list string to a real list In-Reply-To: <87ehwo5364.fsf@benfinney.id.au> References: <4ed6f7be$0$29986$c3e8da3$5496439d@news.astraweb.com> <87ehwo5364.fsf@benfinney.id.au> Message-ID: Dammit, been awake too long researching on the Internet, but I finally reached the Last Page On Thu, Dec 1, 2011 at 3:25 PM, Ben Finney wrote: > Steven D'Aprano writes: > >> On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote: >> >> > I think it would be better if safe_eval were available as an easily >> > accessible builtin and dangerous_eval were tucked away in a module ;-). >> >> +100000 > > You do realise that any vote outside the range -1 through +1 is invalid, > right? Every person gets a maximum of 1, positive or negative. Outside > that, the vote police come to kick you off the internet. > > -- > \ "Everything is futile." --Marvin of Borg | > `\ | > _o__) | > Ben Finney > -- > http://mail.python.org/mailman/listinfo/python-list From alec.taylor6 at gmail.com Wed Nov 30 23:35:22 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 15:35:22 +1100 Subject: Need some IPC pointers In-Reply-To: <4ED69A1A.3080609@gmail.com> References: <4ED69A1A.3080609@gmail.com> Message-ID: Sure, I'll give you some pointers: 0x3A28213A 0x6339392C 0x7363682E From flt.johnson at gmail.com Tue Nov 1 00:01:45 2011 From: flt.johnson at gmail.com (Fletcher Johnson) Date: Mon, 31 Oct 2011 21:01:45 -0700 (PDT) Subject: Unicode literals and byte string interpretation. References: <8de0e9b7-aaac-44a4-8a07-9c1a20bfc3eb@s7g2000yqa.googlegroups.com> <4eaa545f$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7371ad5a-83f1-45cf-800e-987812f9c6a1@a12g2000vbz.googlegroups.com> On Oct 28, 3:06?am, Steven D'Aprano wrote: > On Thu, 27 Oct 2011 20:05:13 -0700, Fletcher Johnson wrote: > > If I create a newUnicodeobject u'\x82\xb1\x82\xea\x82\xcd' how does > > this creation process interpret the bytes in the byte string? > > It doesn't, because there is no byte-string. You have created aUnicode > object from aliteralstring ofunicodecharacters, not bytes. Those > characters are: > > Dec Hex ?Char > 130 0x82 ? > 177 0xb1 ? > 130 0x82 ? > 234 0xea ? > 130 0x82 ? > 205 0xcd ? > > Don't be fooled that all of the characters happen to be in the range > 0-255, that is irrelevant. > > > Does it > > assume the string represents a utf-16 encoding, at utf-8 encoding, > > etc...? > > None of the above. It assumes nothing. It takes a string of characters, > end of story. > > > For reference the string is ??? in the 'shift-jis' encoding. > > No it is not. The way to get aunicodeliteralwith those characters is > to use aunicode-aware editor or terminal: > > >>> s = u'???' > >>> for c in s: > > ... ? ? print ord(c), hex(ord(c)), c > ... > 12371 0x3053 ? > 12428 0x308c ? > 12399 0x306f ? > > You are confusing characters with bytes. I believe that what you are > thinking of is the following: you start with a byte string, and then > decode it intounicode: > > >>> bytes = '\x82\xb1\x82\xea\x82\xcd' ?# not u'...' > >>> text = bytes.decode('shift-jis') > >>> print text > > ??? > > If you get the encoding wrong, you will get the wrong characters: > > >>> print bytes.decode('utf-16') > > ??? > > If you start with theUnicodecharacters, you can encode it into various > byte strings: > > >>> s = u'???' > >>> s.encode('shift-jis') > > '\x82\xb1\x82\xea\x82\xcd'>>> s.encode('utf-8') > > '\xe3\x81\x93\xe3\x82\x8c\xe3\x81\xaf' > > -- > Steven Thanks Steven. You are right. I was confusing characters with bytes. From pmaupin at gmail.com Tue Nov 1 00:03:59 2011 From: pmaupin at gmail.com (Patrick Maupin) Date: Mon, 31 Oct 2011 21:03:59 -0700 (PDT) Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4EAF175A.6060508@davea.name> <4EAF1C40.6030202@davea.name> <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> Message-ID: <6cc3dd78-3f08-4fe8-92b5-56a6b23b4006@es7g2000vbb.googlegroups.com> On Oct 31, 9:12?pm, Dave Angel wrote: > I would claim that a well-written (in C) translate function, without > using the delete option, should be much quicker than any python loop, > even if it does copy the data. Are you arguing with me? I was agreeing with you, I thought, that translate would be faster than a regex. I also pointed out that the delete function was available as , but OTOH, that might be a little slow because I think it does the deletion before the translate. I think I'd just do something like this: >>> transtab = ''.join(' ' if 32 <= x <= 126 else chr(x) for x in range(256)) >>> 'abc\x05\def\x0aghi'.translate(transtab).replace(' ', '') '\x05\n' Regards, Pat From abhishek.vit at gmail.com Tue Nov 1 01:31:53 2011 From: abhishek.vit at gmail.com (Abhishek Pratap) Date: Mon, 31 Oct 2011 22:31:53 -0700 Subject: Module for Python and SGE interaction Message-ID: Hey Guys I shud mention I am relative new to the language. Could you please let me know based on your experience which module could help me with farm out jobs to our existing clusters(we use SGE here) using python. Ideally I would like to do the following. 1. Submit #N jobs to cluster 2. monitor their progress 3. When all #N finishes, push another set of jobs Thanks! -Abhi -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Nov 1 02:56:51 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Nov 2011 06:56:51 GMT Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> On Mon, 31 Oct 2011 20:44:45 -0400, Terry Reedy wrote: [...] >> def is_ascii_text(text): >> for c in text: >> if c not in LEGAL: >> return False >> return True > > If text is 3.x bytes, this does not work ;-). OP did not specify bytes > or unicode or Python version. The OP specified *string*. Whether that's a byte-string in Python 2, or a unicode string in Python 3, it will still work, so long as both `text` and `LEGAL` are strings. [steve at sylar ~]$ python2 -c "print 'a' in 'abc'" # both byte strings True [steve at sylar ~]$ python2 -c "print u'a' in u'abc'" # both unicode strings True [steve at sylar ~]$ python3 -c "print('a' in 'abc')" # both unicode strings True Mixing bytes and characters may or may not do what you expect. [steve at sylar ~]$ python2 -c "print 'a' in u'abc'" # one of each True Whether that's a good thing or a bad thing is open for debate :) >> Algorithmically, that's as efficient as possible: > > This is a bit strange since you go on to explain that it is inefficient > -- O(n*k) where n = text length and k = legal length -- whereas below is > O(n). But since k is a constant, O(nk) is O(n). When using Big Oh notation, it is acceptable to hand-wave away a lot of detail. For example, it's common to assume that n+7, n//7 and n**7 all take the same constant amount of time, which is patently untrue: division and exponentiation both require more work than addition. In this case, relative to the size of the input text, both a linear string search and a constant-time hash lookup are O(1). That doesn't imply that they *literally* take constant time. [...] >> Since all() is guaranteed to keep short-cut semantics, that will be as >> fast as possible in Python, > > A dangerous statement to make. I like living dangerously :) > 'c in legal' has to get hash(c) and look > that up in the hash table, possible skipping around a bit if t If text > is byte string rather than unicode, a simple lookup 'mask[c]', where > mask is a 0-1 byte array, should be faster (see my other post). Oooh, clever! I like! It's not necessary to assume bytes, nor is it necessary to create a bitmask the size of the entire Unicode range. Here's a version for strings (bytes or unicode in Python 2, unicode in Python 3): LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) # Untested def is_ascii_text(text): for c in text: n = ord(c) if n >= len(MASK) or MASK[n] == '\0': return False return True Optimizing it is left as an exercise :) I *suspect*, even with any optimizations, that this will be slower than the version using a set. > On my > new Pentium Win 7 machine, it is -- by albout 5%. For 100,000,000 legal > bytes, a minimum of 8.69 versus 9.17 seconds. On my old Linux box, I get the opposite result: set lookup is a tiny bit faster, coincidentally also by almost 5%. >>> from time import time >>> legal_set = frozenset(range(32, 128)) >>> text = b'a' * 100000000 >>> t = time(); all(c in legal_set for c in text); time()-t True 27.174341917037964 >>> >>> legal_ray = 128 * b'\1' >>> t = time(); all(legal_ray[c] for c in text); time()-t True 28.39691996574402 -- Steven From steve+comp.lang.python at pearwood.info Tue Nov 1 03:10:50 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Nov 2011 07:10:50 GMT Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4EAF175A.6060508@davea.name> <4EAF1C40.6030202@davea.name> <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> Message-ID: <4eaf9b7a$0$29968$c3e8da3$5496439d@news.astraweb.com> On Mon, 31 Oct 2011 22:12:26 -0400, Dave Angel wrote: > I would claim that a well-written (in C) translate function, without > using the delete option, should be much quicker than any python loop, > even if it does copy the data. I think you are selling short the speed of the Python interpreter. Even for short strings, it's faster to iterate over a string in Python 3 than to copy it with translate: >>> from timeit import Timer >>> t1 = Timer('for c in text: pass', 'text = "abcd"') >>> t2 = Timer('text.translate(mapping)', ... 'text = "abcd"; mapping = "".maketrans("", "")') >>> min(t1.repeat()) 0.450606107711792 >>> min(t2.repeat()) 0.9279451370239258 > Incidentally, on the Pentium family, > there's a machine instruction for that, to do the whole loop in one > instruction (with rep prefix). I'm pretty sure that there isn't a machine instruction for copying an entire terabyte of data in one step. Since the OP explicitly said he was checking text up to a TB in size, whatever solution is used has to scale well. -- Steven From __peter__ at web.de Tue Nov 1 05:21:14 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Nov 2011 10:21:14 +0100 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4EAF175A.6060508@davea.name> <4EAF1C40.6030202@davea.name> <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> <4eaf9b7a$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > On Mon, 31 Oct 2011 22:12:26 -0400, Dave Angel wrote: > >> I would claim that a well-written (in C) translate function, without >> using the delete option, should be much quicker than any python loop, >> even if it does copy the data. > > I think you are selling short the speed of the Python interpreter. Even > for short strings, it's faster to iterate over a string in Python 3 than > to copy it with translate: > >>>> from timeit import Timer >>>> t1 = Timer('for c in text: pass', 'text = "abcd"') >>>> t2 = Timer('text.translate(mapping)', > ... 'text = "abcd"; mapping = "".maketrans("", "")') >>>> min(t1.repeat()) > 0.450606107711792 >>>> min(t2.repeat()) > 0.9279451370239258 Lies, damn lies, and benchmarks ;) Copying is fast: >>> Timer("text + 'x'", "text='abcde '*10**6").timeit(100) 1.819761037826538 >>> Timer("for c in text: pass", "text='abcde '*10**6").timeit(100) 18.89239192008972 The problem with str.translate() (unicode.translate() in 2.x) is that it needs a dictionary lookup for every character. However, if like the OP you are going to read data from a file to check whether it's (a subset of) ascii, there's no point converting to a string, and for bytes (where a lookup table with the byte as an index into that table can be used) the numbers look quite different: >>> t1 = Timer("for c in text: pass", "text = b'abcd '*10**6") >>> t1.timeit(100) 15.818882942199707 >>> t2 = Timer("text.translate(mapping)", "text = b'abcd '*10**6; mapping = b''.maketrans(b'', b'')") >>> t2.timeit(100) 2.821769952774048 From wonjunchoi001 at gmail.com Tue Nov 1 08:03:17 2011 From: wonjunchoi001 at gmail.com (pyman) Date: Tue, 1 Nov 2011 05:03:17 -0700 (PDT) Subject: proving two formula are same each other! Message-ID: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> hello, I need some idea to prove two formula is same. if N = 3, these formula are same each other. each formula has 3 input . To prove this, drawing shape or anything would be possible. how can I do this? please give me your idea! for example: N = 1 : formula1 has a, b, c input value, formula2 has d, e, f input value and each formula's output are different. N = 2 : formula1 has a, b, c input value, formula2 has d, e, f input value and each formula's output are different. N = 3 : formula1 has a, b, c input value, formula2 has d, e, f input value and each formula's output are SAME. Wonjun, Choi From d at davea.name Tue Nov 1 08:17:30 2011 From: d at davea.name (Dave Angel) Date: Tue, 01 Nov 2011 08:17:30 -0400 Subject: proving two formula are same each other! In-Reply-To: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> References: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> Message-ID: <4EAFE35A.7080106@davea.name> On 11/01/2011 08:03 AM, pyman wrote: > hello, I need some idea to prove two formula is same. if N = 3, these > formula are same each other. each formula has 3 input . To prove this, > drawing shape or anything would be possible. how can I do this? please > give me your idea! > > for example: > N = 1 : formula1 has a, b, c input value, formula2 has d, e, f input > value and each formula's output are different. > N = 2 : formula1 has a, b, c input value, formula2 has d, e, f input > value and each formula's output are different. > N = 3 : formula1 has a, b, c input value, formula2 has d, e, f input > value and each formula's output are SAME. > > Wonjun, Choi Python doesn't have formulae, it has functions and methods. So you have to describe more completely what kind of formula you have, math, physics, chemistry? And how is one different than the next? And how can a formula with 3 input use four values, N, a,. b, and c ? Please be more specific, and maybe somebody can help. -- DaveA From d at davea.name Tue Nov 1 09:01:18 2011 From: d at davea.name (Dave Angel) Date: Tue, 01 Nov 2011 09:01:18 -0400 Subject: proving two formula are same each other! In-Reply-To: References: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> <4EAFE35A.7080106@davea.name> Message-ID: <4EAFED9E.1070707@davea.name> (You forgot to do a REPLY-ALL, so that your message didn't get sent to the list) >> >>> Python doesn't have formulae, it has functions and methods. So you have >> to describe more completely > > what kind of formula you have, math, physics, chemistry? > > the formula is related to math. > > >> And how is one different than the next? > > > these formula are completely different each other and it is custom > formula. > for example, when I put 3 input into A formula, it outputs 1 result. > and when I put 3 input into B formula, it outputs 1 result > so each formula have 3 input for example > > A formula : f(x,y,z)=3x+4y+2z+3 > B formula : f(k,j,t)=2k+3j+2t+1 > > this formula is different each other which has 3 input. > and have only 1 result > > and if I loop this formula from 0 to N(for example : N = 3) > if N=1, the result will be different each other. and N=2 too. > but when N=3, the result will be same each other. > Since N isn't a parameter to either function, the results can never change. > so I wanted to prove this. by drawing shape or something so that children > can be understand easily. > > >> > I'm still trying to help you clarify your problem, but you are getting much closer. Those two formulae take three arguments (although you should use the same name for the arguments if the comparison is to mean anything). N doesn't come into it at all. Perhaps by N you mean tuples like (2,1,1) and (4,2,1), and you want to know for which tuples the result will be the same. That could be represented by some 4 dimensional graph, but I don't know any graphing package that could show it, in python or otherwise. -- DaveA From no at mail.de Tue Nov 1 11:04:26 2011 From: no at mail.de (MrSmile) Date: Tue, 01 Nov 2011 16:04:26 +0100 Subject: sending more then 2 messages to SocketServer fasils In-Reply-To: <7699e647-98fb-4a6e-aff4-1694d06fd705@h39g2000prh.googlegroups.com> References: <7699e647-98fb-4a6e-aff4-1694d06fd705@h39g2000prh.googlegroups.com> Message-ID: <4eb00a7a$0$6560$9b4e6d93@newsspool4.arcor-online.net> Hi people! I have asked myself why I am not capable sending 2 messages a time to a Socketserver. Why is that?! Here the Server: import SocketServer from ast import literal_eval class MKTest(object): DSX = [] MKTestInst = None def __init__(self,Daten): MKTest.DSX.append(Daten) def getObj(Daten): if MKTest.MKTestInst == None: MKTest.MKTestInst = MKTest(Daten) return MKTest.MKTestInst getObj = staticmethod(getObj) class MySockX(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) data = literal_eval(data) #MKTest.getObj(data[0]) #MKObj = MKTest(data[0]) MKObj = MKTest.getObj(data[0]) data = MKTest.DSX data = '%s' % data self.request.send(data) if __name__ == "__main__": HOST, PORT = "localhost", 9999 server = SocketServer.TCPServer((HOST,PORT),MySockX) server.serve_forever() and the client: import socket data = [100] received = [None,None] HOST,PORT = "localhost",9999 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((HOST, PORT)) sock.send('%s' % data) received[0] = sock.recv(1024) sock.send('%s' % data) received[1] = sock.recv(1024) sock.close() print received The result is: ['[100]', ''] who can help me solving this problem Tamer From gnarlodious at gmail.com Tue Nov 1 11:05:16 2011 From: gnarlodious at gmail.com (Gnarlodious) Date: Tue, 1 Nov 2011 08:05:16 -0700 (PDT) Subject: Assign values from list to list of instances Message-ID: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This works, even though it reads like doggerel. Is there a more pythonesque way using map or comprehension? -- Gnarlie From no at mail.de Tue Nov 1 11:07:09 2011 From: no at mail.de (MrSmile) Date: Tue, 01 Nov 2011 16:07:09 +0100 Subject: sending more then 2 messages at a time to a SocketServer fails Message-ID: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> Hi people! I have asked myself why I am not capable sending 2 messages a time to a Socketserver. Why is that?! Here the Server: import SocketServer from ast import literal_eval class MKTest(object): DSX = [] MKTestInst = None def __init__(self,Daten): MKTest.DSX.append(Daten) def getObj(Daten): if MKTest.MKTestInst == None: MKTest.MKTestInst = MKTest(Daten) return MKTest.MKTestInst getObj = staticmethod(getObj) class MySockX(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) data = literal_eval(data) #MKTest.getObj(data[0]) #MKObj = MKTest(data[0]) MKObj = MKTest.getObj(data[0]) data = MKTest.DSX data = '%s' % data self.request.send(data) if __name__ == "__main__": HOST, PORT = "localhost", 9999 server = SocketServer.TCPServer((HOST,PORT),MySockX) server.serve_forever() and the client: import socket data = [100] received = [None,None] HOST,PORT = "localhost",9999 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((HOST, PORT)) sock.send('%s' % data) received[0] = sock.recv(1024) sock.send('%s' % data) received[1] = sock.recv(1024) sock.close() print received The result is: ['[100]', ''] who can help me solving this problem Tamer From __peter__ at web.de Tue Nov 1 11:22:02 2011 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Nov 2011 16:22:02 +0100 Subject: Assign values from list to list of instances References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: Gnarlodious wrote: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is there a more > pythonesque way using map or comprehension? for order, place in zip(Orders, locus): order.locus = place From d at davea.name Tue Nov 1 11:31:38 2011 From: d at davea.name (Dave Angel) Date: Tue, 01 Nov 2011 11:31:38 -0400 Subject: Assign values from list to list of instances In-Reply-To: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: <4EB010DA.3040400@davea.name> On 11/01/2011 11:05 AM, Gnarlodious wrote: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is there a more > pythonesque way using map or comprehension? > > -- Gnarlie You can do that with the enumerate function, or with zip for index, instance in enumerate(Orders): instance.locus = locus[index] for instance, place in zip(Orders, locus): instance.locus = locus[index] It would be clearer if you used singular for individual items, and plural for the collections, loci [-2, 21, .... orders = [list of order objects ...] for order, locus in zip(orders, loci): order.locus = locus -- DaveA From christopherbl at gmail.com Tue Nov 1 11:33:28 2011 From: christopherbl at gmail.com (cpbl) Date: Tue, 1 Nov 2011 08:33:28 -0700 (PDT) Subject: modified legend appears out of view! It didn't used to. MWE included. Message-ID: <9794fb7a-db8f-48bd-8254-405f4cf23794@s32g2000prj.googlegroups.com> I seem to be using Python 2.7.2+ (latest update of Ubuntu). The following code used to work nicely, but now gives me an unreadable legend. The legend is showing up mostly out of view below and to the left of the figure. Does that happen for you? Is there a regression bug, or am I doing something wrong? The MWE below is adapted from a function I wrote to allow addition of extra comments within a legend box below the normal legend details. Thanks for any help! Chris !/usr/bin/python import pylab as plt from matplotlib.offsetbox import TextArea, VPacker comments='foodlefish' plt.figure(1) plt.plot([1,2],[3,4], label='test') lh=plt.legend(fancybox=True,shadow=False,title='Foodle',loc='best') if lh: lh.get_frame().set_alpha(0.5) fontsize=lh.get_texts()[0].get_fontsize() legendcomment=TextArea('\n'.join(comments), textprops=dict(size=fontsize)) lh._legend_box = VPacker(pad=5, sep=0, children=[lh._legend_box,legendcomment], align="right") # Or should it be centre? lh._legend_box.set_figure(plt.gcf()) plt.show() From buzzard at urubu.freeserve.co.uk Tue Nov 1 11:37:20 2011 From: buzzard at urubu.freeserve.co.uk (duncan smith) Date: Tue, 01 Nov 2011 15:37:20 +0000 Subject: Assign values from list to list of instances In-Reply-To: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: On 01/11/11 15:05, Gnarlodious wrote: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is there a more > pythonesque way using map or comprehension? > for obj, val in zip(Orders, locus): obj.locus = val I'm not sure how worthwhile it is converting the above to a list comprehension (when the list would just be thrown away). Having said that the call to zip creates an unnecessary list. You could use izip or maybe, for i, val in enumerate(locus): Orders[i].locus = val Duncan From ulrich.eckhardt at dominolaser.com Tue Nov 1 11:40:52 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 01 Nov 2011 16:40:52 +0100 Subject: Assign values from list to list of instances In-Reply-To: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: <4hg5o8-kt3.ln1@satorlaser.homedns.org> Am 01.11.2011 16:05, schrieb Gnarlodious: > I want to assign a list of variables: > locus=[-2, 21, -10, 2, 12, -11, 0, 3] > > updating a list of objects each value to its respective instance: > > for order in range(len(Orders)): > Orders[order].locus=locus[order] > > This works, even though it reads like doggerel. Is there a more > pythonesque way using map or comprehension? Use enumerate: for object, index in enumerate(Orders): object.locus = locus[index] I'm not 100% I understood your description though, but it looks like this would do what you want and be descriptive at the same time. Uli From stefan_ml at behnel.de Tue Nov 1 11:57:02 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 01 Nov 2011 16:57:02 +0100 Subject: C API: Making a context manager In-Reply-To: References: Message-ID: Chris Kaynor, 31.10.2011 19:34: > I am currently rewritting a class using the Python C API to improve > performance of it, however I have not been able to find any > documentation about how to make a context manager using the C API. You should take a look at Cython. It makes these things *so* much easier. > The code I am working to produce is the following (its a method of a class): > > @contextlib.contextmanager > def connected(self, *args, **kwargs): > connection = self.connect(*args, **kwargs) > try: > yield > finally: > connection.disconnect() You can use the above in Cython code unmodified, and it's likely going to be good enough (depending on what kind of connection we are talking about here). In case that's also performance critical, however, it's likely faster to spell it out as a class, i.e. ... def connected(self, *args, **kwargs): return ConnectionManager(self, args, kwargs) cdef class ConnectionManager: cdef object args, kwargs, connection, connect def __init__(self, connector, args, kwargs): self.args, self.kwargs = args, kwargs self.connect = connector.connect def __enter__(self): self.connection = self.connect(*self.args, **self.kwargs) def __exit__(self, *exc): self.connection.disconnect() return True # or False? I always forget which means what Not that much longer either. Stefan From miki.tebeka at gmail.com Tue Nov 1 12:13:21 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Tue, 1 Nov 2011 09:13:21 -0700 (PDT) Subject: sending more then 2 messages at a time to a SocketServer fails In-Reply-To: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> References: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <14258539.1164.1320164001987.JavaMail.geo-discussion-forums@prgt10> MKTest.getObj(data[0]) will return the same object on every call(with the same data that was initialized 1'st time). Any Daten parameter after the 1'st call is ignored. From ckaynor at zindagigames.com Tue Nov 1 12:19:46 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 1 Nov 2011 09:19:46 -0700 Subject: C API: Making a context manager In-Reply-To: References: Message-ID: On Tue, Nov 1, 2011 at 8:57 AM, Stefan Behnel wrote: > Chris Kaynor, 31.10.2011 19:34: >> >> I am currently rewritting a class using the Python C API to improve >> performance of it, however I have not been able to find any >> documentation about how to make a context manager using the C API. > > You should take a look at Cython. It makes these things *so* much easier. Unfortunately, all of the code has to be fully compatible with CPython 2.6 - it needs to function inside of Maya, which has CPython 2.6 embedded, and to which we do not have the source code. While not all parts of our code base are used inside of Maya, most of the performance-critical items are to some degree or another. In this particular case, the connected context manager is not heavily used (outside of unittests) and itself is not performance critical, but the much of the rest of the package (and thus the class) it is part of is. Chris From chen.1381 at gmail.com Tue Nov 1 12:57:56 2011 From: chen.1381 at gmail.com (Wei) Date: Tue, 1 Nov 2011 09:57:56 -0700 (PDT) Subject: Does anyone use Python Tools for visual studio? Message-ID: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> I got several buggy things going on. First, the view of class tree stops expanding after creating more than two classes. Second, after 800 lines of code the classes and methods can't be folded. (meaning the + sign is gone) P.S. there is no warning or errors in my code. From chen.1381 at gmail.com Tue Nov 1 13:01:21 2011 From: chen.1381 at gmail.com (Wei) Date: Tue, 1 Nov 2011 10:01:21 -0700 (PDT) Subject: Does anyone use Python Tools for visual studio? References: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> Message-ID: <202fcd81-b383-4909-8112-33999df09512@t38g2000prg.googlegroups.com> On Nov 1, 12:57?pm, Wei wrote: > I got several buggy things going on. > First, the view of class tree stops expanding after creating more than > two classes. > Second, after 800 lines of code the classes and methods can't be > folded. (meaning the + sign is gone) > P.S. there is no warning or errors in my code. Also, I am using 64 bit win7 professional. From stefan_ml at behnel.de Tue Nov 1 13:03:12 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 01 Nov 2011 18:03:12 +0100 Subject: C API: Making a context manager In-Reply-To: References: Message-ID: Chris Kaynor, 01.11.2011 17:19: > On Tue, Nov 1, 2011 at 8:57 AM, Stefan Behnel wrote: >> Chris Kaynor, 31.10.2011 19:34: >>> I am currently rewritting a class using the Python C API to improve >>> performance of it, however I have not been able to find any >>> documentation about how to make a context manager using the C API. >> >> You should take a look at Cython. It makes these things *so* much easier. > > Unfortunately, all of the code has to be fully compatible with CPython > 2.6 - it needs to function inside of Maya, which has CPython 2.6 > embedded, and to which we do not have the source code. This sounds like you're misunderstanding what Cython is. Cython compiles (and optimises) your Python code into fast C code that uses the C-API (and that can happily call into external C code etc.). So you get basically the same (and sometimes better) speed, but without all the C-level hassle and maintenance issues. The C code that Cython generates is fully compatible with CPython 2.4 up to the latest 3.3, and that includes 2.6. > While not all parts of our code base are used inside of Maya, most of > the performance-critical items are to some degree or another. > > In this particular case, the connected context manager is not heavily > used (outside of unittests) and itself is not performance critical, > but the much of the rest of the package (and thus the class) it is > part of is. In that case, I advise you to leave the context manager code as is, and just compile the module that you are trying to speed up (and which, IIUC is currently written in Python) with Cython, then optimise the parts of it that need more speed by injecting static typing. Here's a quick howto: http://docs.cython.org/src/quickstart/cythonize.html Stefan From abhishek.vit at gmail.com Tue Nov 1 13:31:34 2011 From: abhishek.vit at gmail.com (Abhishek Pratap) Date: Tue, 1 Nov 2011 10:31:34 -0700 Subject: Module for Python and SGE interaction In-Reply-To: References: Message-ID: Hey Guys Pushing this one again just in case it was missed last night. Best, -Abhi On Mon, Oct 31, 2011 at 10:31 PM, Abhishek Pratap wrote: > Hey Guys > > I shud mention I am relative new to the language. Could you please let me > know based on your experience which module could help me with farm out jobs > to our existing clusters(we use SGE here) using python. > > Ideally I would like to do the following. > > 1. Submit #N jobs to cluster > 2. monitor their progress > 3. When all #N finishes, push another set of jobs > > Thanks! > -Abhi > -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Tue Nov 1 13:56:25 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 01 Nov 2011 17:56:25 +0000 Subject: sending more then 2 messages at a time to a SocketServer fails In-Reply-To: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> References: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <4EB032C9.5060104@mrabarnett.plus.com> On 01/11/2011 15:07, MrSmile wrote: > Hi people! > I have asked myself why I am not capable sending 2 messages a time to a > Socketserver. Why is that?! > > > Here the Server: > > import SocketServer > from ast import literal_eval > > class MKTest(object): > DSX = [] > MKTestInst = None > > def __init__(self,Daten): > MKTest.DSX.append(Daten) > > def getObj(Daten): > if MKTest.MKTestInst == None: > MKTest.MKTestInst = MKTest(Daten) > return MKTest.MKTestInst > > getObj = staticmethod(getObj) > > class MySockX(SocketServer.BaseRequestHandler): > def handle(self): > data = self.request.recv(1024) > data = literal_eval(data) > #MKTest.getObj(data[0]) > #MKObj = MKTest(data[0]) > MKObj = MKTest.getObj(data[0]) > data = MKTest.DSX > data = '%s' % data > self.request.send(data) > > if __name__ == "__main__": > HOST, PORT = "localhost", 9999 > server = SocketServer.TCPServer((HOST,PORT),MySockX) > server.serve_forever() > [snip] I think that in the 'handle' function you should be putting the code in a 'while' loop: def handle(self): # The client has opened a socket to the server. while True: data = self.request.recv(1024) if not data: # The client has closed the socket to the server. break ... From duncan.booth at invalid.invalid Tue Nov 1 14:54:09 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 1 Nov 2011 18:54:09 GMT Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' > MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) > > # Untested > def is_ascii_text(text): > for c in text: > n = ord(c) > if n >= len(MASK) or MASK[n] == '\0': return False > return True > > > Optimizing it is left as an exercise :) > #untested LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' MASK = [True if chr(n) in LEGAL else False for n in range(128)] # Untested def is_ascii_text(text): try: return all(MASK[ord(c)] for c in text) except IndexError: return False -- Duncan Booth http://kupuguy.blogspot.com From th982a at googlemail.com Tue Nov 1 15:12:46 2011 From: th982a at googlemail.com (Tamer Higazi) Date: Tue, 01 Nov 2011 20:12:46 +0100 Subject: sending more then 2 messages at a time to a SocketServer fails In-Reply-To: <14258539.1164.1320164001987.JavaMail.geo-discussion-forums@prgt10> References: <4eb00b1d$0$6560$9b4e6d93@newsspool4.arcor-online.net> <14258539.1164.1320164001987.JavaMail.geo-discussion-forums@prgt10> Message-ID: <4EB044AE.1020207@googlemail.com> Am 01.11.2011 17:13, schrieb Miki Tebeka: > MKTest.getObj(data[0]) will return the same object on every call(with the same data that was initialized 1'st time). Any Daten parameter after the 1'st call is ignored. Not true! The singleton object has nothing todo. Here one more example for you: Client: import socket data = ['Tamer'] received = [None,None] HOST,PORT = "localhost",9999 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((HOST, PORT)) sock.send('%s' % data) received[0] = sock.recv(1024) sock.send('%s' % data) received[1] = sock.recv(1024) sock.close() print received Server: import SocketServer from ast import literal_eval class MySockX(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) data = literal_eval(data) data = '%s' % data[0] self.request.send('%s %s' % ('Halloaaa',data)) if __name__ == "__main__": HOST, PORT = "localhost", 9999 server = SocketServer.TCPServer((HOST,PORT),MySockX) server.serve_forever() with it's result: ['Halloaaa Tamer', ''] the 2nd argument from the list is EMPTY. Now tell me why?! From th982a at googlemail.com Tue Nov 1 15:14:57 2011 From: th982a at googlemail.com (Tamer Higazi) Date: Tue, 01 Nov 2011 20:14:57 +0100 Subject: Does anyone use Python Tools for visual studio? In-Reply-To: <202fcd81-b383-4909-8112-33999df09512@t38g2000prg.googlegroups.com> References: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> <202fcd81-b383-4909-8112-33999df09512@t38g2000prg.googlegroups.com> Message-ID: <4EB04531.8090207@googlemail.com> buy wingIDE or use PyDEV If you tell me that you are using IronPython then buy wingIDE, there you can make use of the .net classes in python too. Tamer Am 01.11.2011 18:01, schrieb Wei: > On Nov 1, 12:57 pm, Wei wrote: >> I got several buggy things going on. >> First, the view of class tree stops expanding after creating more than >> two classes. >> Second, after 800 lines of code the classes and methods can't be >> folded. (meaning the + sign is gone) >> P.S. there is no warning or errors in my code. > > Also, I am using 64 bit win7 professional. From ian.g.kelly at gmail.com Tue Nov 1 15:25:42 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 1 Nov 2011 13:25:42 -0600 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? In-Reply-To: <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4EAF175A.6060508@davea.name> <4EAF1C40.6030202@davea.name> <3bd5234e-dbbe-4f67-84fb-e654650decb6@hv4g2000vbb.googlegroups.com> Message-ID: On Mon, Oct 31, 2011 at 6:32 PM, Patrick Maupin wrote: > On Oct 31, 5:52?pm, Ian Kelly wrote: >>?For instance, split() will split on vertical tab, >> which is not one of the characters the OP wanted. > > That's just the default behavior. ?You can explicitly specify the > separator to split on. ?But it's probably more efficient to just use > translate with deletechars. As I understood it, the point of using the default behavior was to merge whitespace, which cannot be done when the separator is explicitly specified. For example: >>> " ".split() [] >>> " ".split(" ") ['', '', '', '', '', ''] It is easy to check that the first is empty. The second is a bit more annoying and is O(n). Your point about deletechars is good, though, definitely better than a regular expression. From tres.bailey at gmail.com Tue Nov 1 15:26:19 2011 From: tres.bailey at gmail.com (tres.bailey at gmail.com) Date: Tue, 1 Nov 2011 12:26:19 -0700 (PDT) Subject: getting columns attributes in declarative style with sqlalchemy In-Reply-To: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> References: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> Message-ID: <17209707.1599.1320175579736.JavaMail.geo-discussion-forums@vbak12> Hi Gabriele, I'm not an Alchemy expert, but I have used the ColumnProperty of the model/column objects to solve this problem in the past. So to get the column name for the description column in your example above, you would use the following syntax: Country.description.property.columns[0].name And this would avoid having to use additional objects than the one you're working on. The ColumnProperty object (and the Column object attribute it contains) will provide you with information such as column name, type, default vals, primary_key, and nullable. You could also get more generic by iterating through your model object's __table__ attribute and grab each column: [col.name for col in Country.__table__.columns._all_cols] More information can be found here: http://www.sqlalchemy.org/docs/core/schema.html?highlight=schema.column#sqlalchemy.schema.Column and http://www.sqlalchemy.org/docs/orm/internals.html?highlight=columnproperty#sqlalchemy.orm.properties.ColumnProperty From pacopyc at gmail.com Tue Nov 1 15:27:16 2011 From: pacopyc at gmail.com (pacopyc) Date: Tue, 1 Nov 2011 12:27:16 -0700 (PDT) Subject: understand program used to create file Message-ID: Hi, I have about 10000 files .doc and I want know the program used to create them: writer? word? abiword? else? I'd like develop a script python to do this. Is there a module to do it? Can you help me? Thanks From python at mrabarnett.plus.com Tue Nov 1 15:29:50 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 01 Nov 2011 19:29:50 +0000 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? In-Reply-To: References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4EB048AE.2030301@mrabarnett.plus.com> On 01/11/2011 18:54, Duncan Booth wrote: > Steven D'Aprano wrote: > >> LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' >> MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) >> >> # Untested >> def is_ascii_text(text): >> for c in text: >> n = ord(c) >> if n>= len(MASK) or MASK[n] == '\0': return False >> return True >> >> >> Optimizing it is left as an exercise :) >> > > #untested > LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' > MASK = [True if chr(n) in LEGAL else False for n in range(128)] > Instead of: True if chr(n) in LEGAL else False why not: if chr(n) in LEGAL > # Untested > def is_ascii_text(text): > try: > return all(MASK[ord(c)] for c in text) > except IndexError: > return False > From Ric at rdo Tue Nov 1 15:34:46 2011 From: Ric at rdo (Ric at rdo) Date: Tue, 01 Nov 2011 14:34:46 -0500 Subject: Sort items in wxListCtrl Message-ID: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> I am trying to create a small application in wxPython and would like to ask for some help. I am trying to display folders and files in ListCtrl but sorted first folders followed by files (like in a file manager style) but not sure how to do this? Would I need to do this in code somehow or ListCtrl would help me? I am trying to do this and learn at the same time. Would appreciate any advice. Thank you. From tres.bailey at gmail.com Tue Nov 1 15:37:42 2011 From: tres.bailey at gmail.com (tres.bailey at gmail.com) Date: Tue, 1 Nov 2011 12:37:42 -0700 (PDT) Subject: getting columns attributes in declarative style with sqlalchemy In-Reply-To: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> References: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> Message-ID: <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> Sorry for the repost, if it does in fact repost. I'm no SQLAlchemy expert, but I have used the Table and Column attribute objects from the model object to solve a similar problem in the past. You can use the following syntax to do it: [col.name for col in Country.__table__.columns._all_cols] which should return you a list of ['cancelled', 'description']. You can find more information on the attributes you are using here: http://www.sqlalchemy.org/docs/core/schema.html?highlight=schema.column#sqlalchemy.schema.Column and http://www.sqlalchemy.org/docs/core/schema.html?highlight=schema.table#sqlalchemy.schema.Table From stefan_ml at behnel.de Tue Nov 1 15:47:02 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 01 Nov 2011 20:47:02 +0100 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? In-Reply-To: <1320090874.6062.140660992866273@webmail.messagingengine.com> References: <1320090874.6062.140660992866273@webmail.messagingengine.com> Message-ID: python at bdurham.com, 31.10.2011 20:54: > Wondering if there's a fast/efficient built-in way to determine > if a string has non-ASCII chars outside the range ASCII 32-127, > CR, LF, or Tab? > > I know I can look at the chars of a string individually and > compare them against a set of legal chars using standard Python > code (and this works fine), but I will be working with some very > large files in the 100's Gb to several Tb size range so I'd > thought I'd check to see if there was a built-in in C that might > handle this type of check more efficiently. > > Does this sound like a use case for cython or pypy? Cython. For data of that size, likely read from a fast local RAID drive I guess, you certainly don't want to read (part of) the file into a memory buffer, then copy that memory buffer into a Python bytes string, and then search it character by character, copying each of the characters into a new string object just to compare them. Instead, you'd want to use low-level I/O to read a not-so-small part of the file into a memory buffer, run through it looking for unwanted characters, and then read the next chunk, without any further copying. The comparison loop could look like this, for example: cdef unsigned char current_byte cdef unsigned char* byte_buffer = libc.stdlib.malloc(BUFFER_SIZE) # while read chunk ... for current_byte in byte_buffer[:BUFFER_SIZE]: if current_byte < 32 or current_byte > 127: if current_byte not in b'\t\r\n': raise ValueError() What kind of I/O API you use is up to you. You may want to use the functions declared in libc.stdio (ships with Cython). Stefan From d at davea.name Tue Nov 1 16:08:50 2011 From: d at davea.name (Dave Angel) Date: Tue, 01 Nov 2011 16:08:50 -0400 Subject: understand program used to create file In-Reply-To: References: Message-ID: <4EB051D2.4000204@davea.name> On 11/01/2011 03:27 PM, pacopyc wrote: > Hi, I have about 10000 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? > > Thanks If you're on Linux, just use the process module to invoke "file" and examine the results. If you're not, then be more specific about the environment. -- DaveA From gagsl-py2 at yahoo.com.ar Tue Nov 1 16:22:25 2011 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Nov 2011 17:22:25 -0300 Subject: When I use Python under Windows. I found some file handles are not closed, References: Message-ID: En Mon, 31 Oct 2011 12:57:15 -0300, ???(Yonggang Luo) escribi?: > How did detecting where those handlers are created to tracing it and > close > it. > Mainly because I was using C binding library(subvertpy) and file is not > closed. A better place to ask is python-list at python.org Please include the Python version you're using. Also, a small, complete, runnable code example showing the problem would be very valuable. Usually, in building such example, you may well find out where your problem is. -- Gabriel Genellina From duncan.booth at invalid.invalid Tue Nov 1 16:47:26 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 1 Nov 2011 20:47:26 GMT Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: MRAB wrote: > On 01/11/2011 18:54, Duncan Booth wrote: >> Steven D'Aprano wrote: >> >>> LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' >>> MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range (128)) >>> >>> # Untested >>> def is_ascii_text(text): >>> for c in text: >>> n = ord(c) >>> if n>= len(MASK) or MASK[n] == '\0': return False >>> return True >>> >>> >>> Optimizing it is left as an exercise :) >>> >> >> #untested >> LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' >> MASK = [True if chr(n) in LEGAL else False for n in range(128)] >> > Instead of: > > True if chr(n) in LEGAL else False > > why not: > > if chr(n) in LEGAL > I think you meant to drop the 'if' also. MASK = [chr(n) in LEGAL for n in range(128)] But yes, I was concentrating on the function body rather than the initialisation. -- Duncan Booth http://kupuguy.blogspot.com From rosuav at gmail.com Tue Nov 1 16:53:47 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Nov 2011 07:53:47 +1100 Subject: understand program used to create file In-Reply-To: References: Message-ID: On Wed, Nov 2, 2011 at 6:27 AM, pacopyc wrote: > Hi, I have about 10000 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? > Technically, you can't find out just from the file what it was that created it. But if you mean "figure out what type of file each one is" (eg recognize an ODF, a PDF, a DOC, etc), then the easiest way is to read in the first few bytes of the file and look for well-known magic numbers[1]. As Dave says, Linux comes with a command that does exactly that (and a bit more), called 'file'. ChrisA [1] http://en.wikipedia.org/wiki/Magic_number_(programming) From joncle at googlemail.com Tue Nov 1 16:58:42 2011 From: joncle at googlemail.com (Jon Clements) Date: Tue, 1 Nov 2011 13:58:42 -0700 (PDT) Subject: understand program used to create file References: Message-ID: On Nov 1, 7:27?pm, pacopyc wrote: > Hi, I have about 10000 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? > > Thanks My suggestion would be the same as DaveA's. This gives you the format it was *written* in. (Saved a blank OO document as 95/97/XP Word DOC under Linux) jon at forseti:~/filetest$ file * saved-by-OO.doc: CDF V2 Document, Little Endian, Os: Windows, Version 1.0, Code page: -535, Author: jon , Revision Number: 0, Create Time/ Date: Mon Oct 31 20:47:30 2011 I'd be impressed if you could discover the program that did *write* it; I'd imagine you'd need something that understood some meta-data in the format (if the format has a kind of 'created_by' field, for instance), or depend on nuisances which give away that a certain program wrote data in another's native format. Assuming the former, what might be possible: 1) Grab a "magic number" lookup list 2) Grab 8 (I think that should be all that's needed, but hey ummm..) bytes from the start of each file 3) Look it up in the "magic number" list 4) If you got something great, if not compare 7, 6, 5, 4 bytes... etc... until you get a hit or bail out (Or just find a Windows port of 'file') HTH Jon. From brian.curtin at gmail.com Tue Nov 1 17:16:39 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 1 Nov 2011 16:16:39 -0500 Subject: Does anyone use Python Tools for visual studio? In-Reply-To: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> References: <46f83adf-83ce-4935-9af5-eaf6b55bcec0@g27g2000pre.googlegroups.com> Message-ID: On Tue, Nov 1, 2011 at 11:57, Wei wrote: > I got several buggy things going on. > First, the view of class tree stops expanding after creating more than > two classes. > Second, after 800 lines of code the classes and methods can't be > folded. (meaning the + sign is gone) > P.S. there is no warning or errors in my code. > -- > http://mail.python.org/mailman/listinfo/python-list > Yes, I use it. If you're having issues with it, you should report them at http://pytools.codeplex.com/ From tjreedy at udel.edu Tue Nov 1 17:33:34 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Nov 2011 17:33:34 -0400 Subject: Assign values from list to list of instances In-Reply-To: References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: On 11/1/2011 11:37 AM, duncan smith wrote: > On 01/11/11 15:05, Gnarlodious wrote: >> I want to assign a list of variables: >> locus=[-2, 21, -10, 2, 12, -11, 0, 3] >> >> updating a list of objects each value to its respective instance: >> >> for order in range(len(Orders)): >> Orders[order].locus=locus[order] >> >> This works, even though it reads like doggerel. Is there a more >> pythonesque way using map or comprehension? >> > > for obj, val in zip(Orders, locus): > obj.locus = val > > > I'm not sure how worthwhile it is converting the above to a list > comprehension (when the list would just be thrown away). Having said > that the call to zip creates an unnecessary list. Not in Py 3 -- Terry Jan Reedy From wonjunchoi001 at gmail.com Tue Nov 1 17:35:11 2011 From: wonjunchoi001 at gmail.com (pyman) Date: Tue, 1 Nov 2011 14:35:11 -0700 (PDT) Subject: proving two formula are same each other! References: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> <4EAFE35A.7080106@davea.name> Message-ID: <965c33e2-8ba4-4278-9517-730ce4639492@d33g2000prb.googlegroups.com> first of all, thank you for trying to understand my issue. do you know sigma? I omitted sigma it means sum... From pauldavidmena at gmail.com Tue Nov 1 18:13:25 2011 From: pauldavidmena at gmail.com (extraspecialbitter) Date: Tue, 1 Nov 2011 15:13:25 -0700 (PDT) Subject: parsing text from "ethtool" command Message-ID: I'm still trying to write that seemingly simple Python script to print out network interfaces (as found in the "ifconfig -a" command) and their speed ("ethtool "). The idea is to loop for each interface and print out its speed. I'm looping correctly, but have some issues parsing the output for all interfaces except for the "pan0" interface. I'm running on eth1, and the "ifconfig -a" command also shows an eth0, and of course lo. My script is trying to match on the string "Speed", but I never seem to successfully enter the "if" clause. First, here is the output of "ethtool eth1": ================= Settings for eth1: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on MDI-X: off Supports Wake-on: pumbag Wake-on: g Current message level: 0x00000001 (1) Link detected: yes ================= The script *should* match on the string "Speed" and then assign "100Mb/ s" to a variable, but is never getting past the second if statement below: ================= #!/usr/bin/python # Quick and dirty script to print out available interfaces and their speed # Initializations output = " Interface: %s Speed: %s" noinfo = "(Speed Unknown)" speed = noinfo import os, socket, types, subprocess fp = os.popen("ifconfig -a") dat=fp.read() dat=dat.split('\n') for line in dat: if line[10:20] == "Link encap": interface=line[:9] cmd = "ethtool " + interface gp = os.popen(cmd) fat=gp.read() fat=fat.split('\n') for line in fat: if line[0:6] == "Speed": try: speed=line[8:] except: speed=noinfo print output % (interface, speed) ================= Again, I appreciate everyone's patience, as I'm obviously I'm a python newbie. Thanks in advance! From whatsjacksemail at gmail.com Tue Nov 1 18:27:02 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Tue, 1 Nov 2011 22:27:02 +0000 Subject: Chaco for real-time plot of PySerial data Message-ID: Hi there, I asked this question on the enthought chaco mailing list some time last by have yet to receive a reply. Thought I'd ask here to see if anyone could shed some light on things for me. I have been considering using chaco / traits for close to a year now and am finally biting the bullet so to speak. What I would really like to do to begin with is to make a real-time plotting application which gets its data from the serial port. Can anyone please point me in the right direction for doing this? Since I didn't get a reply on the chaco list I'm now thinking it might be a dangerous route to go down since it will be difficult to get help. Any recommendations? Thanks very much, Jack -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From miki.tebeka at gmail.com Tue Nov 1 19:14:50 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Tue, 1 Nov 2011 16:14:50 -0700 (PDT) Subject: Sort items in wxListCtrl In-Reply-To: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> Message-ID: <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> Why not use the build in wx.FileDialog? Also, have a look at the demo that comes with wxPython. It has an example with a sortable list control. From miki.tebeka at gmail.com Tue Nov 1 19:19:25 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Tue, 1 Nov 2011 16:19:25 -0700 (PDT) Subject: parsing text from "ethtool" command In-Reply-To: References: Message-ID: <5544686.62.1320189565337.JavaMail.geo-discussion-forums@prog16> In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust. From steve+comp.lang.python at pearwood.info Tue Nov 1 19:24:34 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Nov 2011 23:24:34 GMT Subject: proving two formula are same each other! References: <694c9f55-1f3d-4a20-94dc-74dbf031e8a5@u10g2000prl.googlegroups.com> Message-ID: <4eb07fb2$0$29968$c3e8da3$5496439d@news.astraweb.com> On Tue, 01 Nov 2011 05:03:17 -0700, pyman wrote: > hello, I need some idea to prove two formula is same. Impossible. As you explained further on, they are different formula. If they are different, they aren't the same. This has nothing to do with Python. In another message, you tell us: "these formula are completely different each other" and give the formula: A formula : f(x,y,z)=3x+4y+2z+3 B formula : f(k,j,t)=2k+3j+2t+1 Perhaps what you mean is that you want to solve for when the two formula give equal results? Here's a simpler example: f(x) = 2x + 1 g(x) = 3x - 2 Solving for x: f(x) = g(x) 2x + 1 = 3x - 2 1 = 3x - 2 - 2x 1 + 2 = 3x - 2x 3 = x so the solution is x = 3, f(3) = 7 = g(3). This is also not easy, since you have SIX variables (x, y, z, k, j, t) and only two equations. This is known as an under-determined system, and means that there is no exact solution. Perhaps something like Mathematica could do something useful with it? Is there some way you can use the same variables in each formula? For example, if x=t, y=j, z=k (or some other combination), then you have a simpler three-dimensional problem: f(x,y,z) = 3x + 4y + 2z + 3 g(x,y,z) = 2z + 3y + 2x + 1 which is still under-determined, but not as badly (now you have three variables and only two equations). In any case, you *might* be able to solve this using numpy. http://numpy.scipy.org/ -- Steven From tjreedy at udel.edu Tue Nov 1 19:27:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Nov 2011 19:27:44 -0400 Subject: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab? In-Reply-To: <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> References: <1320090874.6062.140660992866273@webmail.messagingengine.com> <4eaf28f7$0$29968$c3e8da3$5496439d@news.astraweb.com> <4eaf9832$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/1/2011 2:56 AM, Steven D'Aprano wrote: > On Mon, 31 Oct 2011 20:44:45 -0400, Terry Reedy wrote: > > [...] >>> def is_ascii_text(text): >>> for c in text: >>> if c not in LEGAL: >>> return False >>> return True >> >> If text is 3.x bytes, this does not work ;-). OP did not specify bytes >> or unicode or Python version. > > The OP specified *string*. A. People sometimes use 'string' loosely, to include text stored in bytes. B. We are solving slightly different problems. The OP specified terabytes of ascii text on disk that he wants to check for contamination. For that purpose, using 3.x, it is sensible to read the data in binary mode into bytes objects rather than decoding into unicode. (The exception would be if the text uses some 7 bit encoding like UTF-7. But that is relatively unlikely for disk storage.) It is irrelevant to that specified purpose whether one calls the internal implementation type a 'string' or not. While my 3.2 bytes version was only slightly faster, given data in memory, adding decoding time for your string version and any other extra overhead for text mode reading would make the bytes version look even better. I am pretty sure the best disk reading speed would come from reading blocks of 4k*N, for some N, in binary mode. If the Python code were compliled (with Cython, for instance), the process might be input bound, depending on the system. >> 'c in legal' has to get hash(c) and look >> that up in the hash table, possible skipping around a bit if t If text >> is byte string rather than unicode, a simple lookup 'mask[c]', where >> mask is a 0-1 byte array, should be faster (see my other post). > > Oooh, clever! I like! It's not necessary to assume bytes, nor is it > necessary to create a bitmask the size of the entire Unicode range. You are right; I had been thinking it would be. > Here's a version for strings (bytes or unicode in Python 2, unicode in > Python 3): > > LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' > MASK = ''.join('\01' if chr(n) in LEGAL else '\0' for n in range(128)) > > # Untested > def is_ascii_text(text): > for c in text: > n = ord(c) > if n>= len(MASK) or MASK[n] == '\0': return False > return True > Optimizing it is left as an exercise :) The test for n >= len() can be accomplished with try:..except IndexError around the loop construct. Then the explicit loop can be replaced with any(), as before. > I *suspect*, even with any optimizations, that this will be slower than > the version using a set. If you suspect that because of the need with true 'strings' for MASK[ord(c)] instead of MASK[c], you are right. Redoing the test runs with unicode strings instead of bytes, the set lookup time is about the same (9.2 seconds) whereas the 100 000 000 ord() calls add over 4 seconds to the MASK lookups, raising them up to 13.1 seconds. -- Terry Jan Reedy From ian.g.kelly at gmail.com Tue Nov 1 19:35:10 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 1 Nov 2011 17:35:10 -0600 Subject: parsing text from "ethtool" command In-Reply-To: <5544686.62.1320189565337.JavaMail.geo-discussion-forums@prog16> References: <5544686.62.1320189565337.JavaMail.geo-discussion-forums@prog16> Message-ID: On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka wrote: > In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust. Or simply: if "Speed" in line: There is no need for a regular expression here. This would also work and be a bit more discriminating: if line.strip().startswith("Speed") BTW, to the OP, note that your condition (line[0:6] == "Speed") cannot match, since line[0:6] is a 6-character slice, while "Speed" is a 5-character string. Cheers, Ian From tjreedy at udel.edu Tue Nov 1 19:41:28 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Nov 2011 19:41:28 -0400 Subject: Module for Python and SGE interaction In-Reply-To: References: Message-ID: On 11/1/2011 1:31 PM, Abhishek Pratap wrote: > On Mon, Oct 31, 2011 at 10:31 PM, Abhishek Pratap > > wrote: > > Hey Guys > > I shud mention I am relative new to the language. Could you please > let me know based on your experience which module could help me with > farm out jobs to our existing clusters(we use SGE here) using python. > > Ideally I would like to do the following. > > 1. Submit #N jobs to cluster > 2. monitor their progress > 3. When all #N finishes, push another set of jobs Have you searched with Google? on pypi.python.org? with what keywords? -- Terry Jan Reedy From Ric at rdo Tue Nov 1 21:13:17 2011 From: Ric at rdo (Ric at rdo) Date: Tue, 01 Nov 2011 20:13:17 -0500 Subject: Sort items in wxListCtrl References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> Message-ID: On Tue, 1 Nov 2011 16:14:50 -0700 (PDT), Miki Tebeka wrote: >Why not use the build in wx.FileDialog? > >Also, have a look at the demo that comes with wxPython. It has an example with a sortable list control. Thanks for responding, How would wx.FileDialog help me in this case? I am trying to display files and directories in the ListCtrl in sorted way. Folders first followed by files. From roy at panix.com Tue Nov 1 21:23:26 2011 From: roy at panix.com (Roy Smith) Date: Tue, 01 Nov 2011 21:23:26 -0400 Subject: sending more then 2 messages to SocketServer fasils References: <7699e647-98fb-4a6e-aff4-1694d06fd705@h39g2000prh.googlegroups.com> <4eb00a7a$0$6560$9b4e6d93@newsspool4.arcor-online.net> Message-ID: In article <4eb00a7a$0$6560$9b4e6d93 at newsspool4.arcor-online.net>, MrSmile wrote: > Hi people! > I have asked myself why I am not capable sending 2 messages a time to a > Socketserver. Why is that?! There's a lot of confusing code here. It would help when asking these kinds of questions to reduce it down to the smallest possible example that demonstrates your problem. I'm not sure what this MTTest class is all about, but I'm guessing it's not essential to demonstrate what's going wrong. Why not just send strings back and forth? Also, it would help to have names that made more sense. I have no idea what a MKTest is, or what DSX means. Names like that make it more difficult to read your code and understand what you probably intended. In any case, I think the problem is a basic misunderstanding of how stream sockets work. You're sending hunks of data with send() calls and expecting that the recv() calls will get the same data. That works with UDP (datagram sockets), but not TCP. There are no record boundaries in TCP. The system could buffer up the data from multiple send() calls and deliver them in a single recv(). Or break up one send() into multiple recv() calls. Or any combination. In any particular situation, the system will probably do whatever is most inconvenient, confusing, and damaging to your program :-) My recommendation is to strip out all the test gunk and get it down to the bare network calls. Send some strings back and forth, and print out what each send() call is sending and what each recv() call receives. Hopefully, things will start to make more sense then. > > > Here the Server: > > import SocketServer > from ast import literal_eval > > class MKTest(object): > DSX = [] > MKTestInst = None > > def __init__(self,Daten): > MKTest.DSX.append(Daten) > > def getObj(Daten): > if MKTest.MKTestInst == None: > MKTest.MKTestInst = MKTest(Daten) > return MKTest.MKTestInst > > getObj = staticmethod(getObj) > > class MySockX(SocketServer.BaseRequestHandler): > def handle(self): > data = self.request.recv(1024) > data = literal_eval(data) > #MKTest.getObj(data[0]) > #MKObj = MKTest(data[0]) > MKObj = MKTest.getObj(data[0]) > data = MKTest.DSX > data = '%s' % data > self.request.send(data) > > if __name__ == "__main__": > HOST, PORT = "localhost", 9999 > server = SocketServer.TCPServer((HOST,PORT),MySockX) > server.serve_forever() > > > > and the client: > > import socket > > data = [100] > received = [None,None] > HOST,PORT = "localhost",9999 > sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > sock.connect((HOST, PORT)) > sock.send('%s' % data) > received[0] = sock.recv(1024) > sock.send('%s' % data) > received[1] = sock.recv(1024) > sock.close() > > print received > > > > The result is: > > ['[100]', ''] > > > > who can help me solving this problem > > > > Tamer From cosmo_general at yahoo.com Tue Nov 1 22:59:10 2011 From: cosmo_general at yahoo.com (Muddy Coder) Date: Tue, 1 Nov 2011 19:59:10 -0700 (PDT) Subject: How filecmp walk into subdirectories? Message-ID: Hi Folks, I tried to compare two directories, each with hundreds of files in multiple level subdirectories, to find out the different files. I used filecmp module to the job as: comp=filecmp.dircmp(adir, bdir) comp.report() It worked, and printed out the identical and different files. However, it did not go through the directory trees, just did the job in the first level. I wonder somebody can help? Thanks in advance! Cosmo From gordon at panix.com Tue Nov 1 23:14:44 2011 From: gordon at panix.com (John Gordon) Date: Wed, 2 Nov 2011 03:14:44 +0000 (UTC) Subject: How filecmp walk into subdirectories? References: Message-ID: In Muddy Coder writes: > I tried to compare two directories, each with hundreds of files in > multiple level subdirectories, to find out the different files. I used > filecmp module to the job as: > comp=filecmp.dircmp(adir, bdir) > comp.report() > It worked, and printed out the identical and different files. However, > it did not go through the directory trees, just did the job in the > first level. I wonder somebody can help? Thanks in advance! report() only prints information on the first-level contents of the two directores, as you saw. It doesn't do subdirectories. If you want subdirectories, use report_full_closure(). -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From wuwei23 at gmail.com Tue Nov 1 23:22:57 2011 From: wuwei23 at gmail.com (alex23) Date: Tue, 1 Nov 2011 20:22:57 -0700 (PDT) Subject: understand program used to create file References: Message-ID: On Nov 2, 5:27?am, pacopyc wrote: > Hi, I have about 10000 files .doc and I want know the program used to > create them: writer? word? abiword? else? I'd like develop a script > python to do this. Is there a module to do it? Can you help me? Word documents store metadata inside of them, one field of which is the program used to create them. This shows you how to use pywin32 to access them: http://www.galalaly.me/index.php/2011/09/use-python-to-parse-microsoft-word-documents-using-pywin32-library/ This won't be a foolproof solution, unfortunately. A random examination of doc files shows that not all of them have the required field set. From kwa at kuwata-lab.com Wed Nov 2 00:02:40 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Wed, 2 Nov 2011 13:02:40 +0900 Subject: Question about metaclass Message-ID: Hi, I want to define a special class which groups functions, like: class Greepting(FuncGroup): def hello(): # no self, no @staticmethod! print("Hello!") def goodbye(): # no self, no @staticmethod! print("Good Bye!") Geeting.hello(): #=> "Hello!" Geeting.goodbye(): #=> "Good Bye!" I tried the following code which converts instance mthods into static method automatically, but I don't get result what I want. (python 2.5.5) import sys from types import FunctionType class MetaClass(type): def __init__(cls, name, bases, dct): ## converts instance methods to static methods automatically for k in dct.keys(): v = dct[k] if isinstance(v, FunctionType): dct[k] = staticmethod(v) print("*** debug: dct[%r] = %r" % (k, dct[k])) #=> class FuncGroup(object): __metaclass__ = MetaClass class Greeting(FuncGroup): def hello(): print("Hello!") def goodbye(): print("Good Bye!") print("*** type(Greeting.hello)=%r" % type(Greeting.hello) #=> print("*** type(Greeting.goodbye)=%r" % type(Greeting.goodbye) #=> Could you give me advice? -- regards, makoto kuwata From ian.g.kelly at gmail.com Wed Nov 2 00:40:17 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 1 Nov 2011 22:40:17 -0600 Subject: Question about metaclass In-Reply-To: References: Message-ID: On Tue, Nov 1, 2011 at 10:02 PM, Makoto Kuwata wrote: > I tried the following code which converts instance mthods into > static method automatically, but I don't get result what I want. > (python 2.5.5) > > ? ?import sys > ? ?from types import FunctionType > > ? ?class MetaClass(type): > ? ? ? ?def __init__(cls, name, bases, dct): > ? ? ? ? ? ?## converts instance methods to static methods automatically > ? ? ? ? ? ?for k in dct.keys(): > ? ? ? ? ? ? ? ?v = dct[k] > ? ? ? ? ? ? ? ?if isinstance(v, FunctionType): > ? ? ? ? ? ? ? ? ? ?dct[k] = staticmethod(v) > ? ? ? ? ? ? ? ? ? ?print("*** debug: dct[%r] = %r" % (k, dct[k])) If you want to customize the dict you need to do it in __new__, not __init__. By the time __init__ is called, the class has already been created. class MetaClass(type): def __new__(mcs, name, bases, dict): for k, v in dict.items(): if isinstance(v, FunctionType): dict[k] = staticmethod(v) return type.__new__(mcs, name, bases, dict) If you were using a more recent Python version, I would suggest using a class decorator instead of a metaclass. You can still do this in Python 2.5, but the syntax will be more awkward. # Python 2.6+ def FuncGroup(class_): for k, v in class_.__dict__.items(): if isinstance(v, FunctionType): setattr(class_, k, staticmethod(v)) return class_ @FuncGroup class Greeting(object): def hello(): print("Hello!") # Python 2.5 class Greeting(object): def hello(): print("Hello!") Greeting = FuncGroup(Greeting) Cheers, Ian From pmaupin at gmail.com Wed Nov 2 00:42:04 2011 From: pmaupin at gmail.com (Patrick Maupin) Date: Tue, 1 Nov 2011 21:42:04 -0700 (PDT) Subject: Question about metaclass References: Message-ID: <2dbd03f2-c93e-4457-8d57-9cc2ebe5223f@k10g2000yqn.googlegroups.com> On Nov 1, 11:02?pm, Makoto Kuwata wrote: > Hi, > > I want to define a special class which groups functions, like: > > ? ? class Greepting(FuncGroup): > ? ? ? ? def hello(): ? ? ? ? ?# no self, no @staticmethod! > ? ? ? ? ? ? print("Hello!") > ? ? ? ? def goodbye(): ? ? ? ?# no self, no @staticmethod! > ? ? ? ? ? ? print("Good Bye!") > > ? ? Geeting.hello(): ? ?#=> "Hello!" > ? ? Geeting.goodbye(): ?#=> "Good Bye!" > > I tried the following code which converts instance mthods into > static method automatically, but I don't get result what I want. > (python 2.5.5) > > ? ? import sys > ? ? from types import FunctionType > > ? ? class MetaClass(type): > ? ? ? ? def __init__(cls, name, bases, dct): > ? ? ? ? ? ? ## converts instance methods to static methods automatically > ? ? ? ? ? ? for k in dct.keys(): > ? ? ? ? ? ? ? ? v = dct[k] > ? ? ? ? ? ? ? ? if isinstance(v, FunctionType): > ? ? ? ? ? ? ? ? ? ? dct[k] = staticmethod(v) > ? ? ? ? ? ? ? ? ? ? print("*** debug: dct[%r] = %r" % (k, dct[k])) > #=> > > ? ? class FuncGroup(object): > ? ? ? ? __metaclass__ = MetaClass > > ? ? class Greeting(FuncGroup): > ? ? ? ? def hello(): > ? ? ? ? ? ? print("Hello!") > ? ? ? ? def goodbye(): > ? ? ? ? ? ? print("Good Bye!") > > ? ? print("*** type(Greeting.hello)=%r" % type(Greeting.hello) > #=> > ? ? print("*** type(Greeting.goodbye)=%r" % type(Greeting.goodbye) > #=> > > Could you give me advice? > > -- > regards, > makoto kuwata I think you need to unwrap the instance methods first: >>> class foo(object): ... def bar(): ... print "Hi there" ... >>> foo.bar2 = staticmethod(foo.bar.im_func) >>> >>> foo.bar2() Hi there >>> From gnarlodious at gmail.com Wed Nov 2 00:52:16 2011 From: gnarlodious at gmail.com (Gnarlodious) Date: Tue, 1 Nov 2011 21:52:16 -0700 (PDT) Subject: Assign values from list to list of instances References: <2adc5424-33f1-4ab0-bab0-7fd8742532e4@u10g2000prl.googlegroups.com> Message-ID: <99202d33-48d2-4148-942c-bd2210971b28@s35g2000pra.googlegroups.com> On Nov 1, 3:33?pm, Terry Reedy wrote: > > for obj, val in zip(Orders, locus): > > obj.locus = val > > > I'm not sure how worthwhile it is converting the above to a list > > comprehension (when the list would just be thrown away). Having said > > that the call to zip creates an unnecessary list. > > Not in Py 3 Thanks for that tip, this works well in Py3. -- Gnarlie From kwa at kuwata-lab.com Wed Nov 2 00:58:41 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Wed, 2 Nov 2011 13:58:41 +0900 Subject: Question about metaclass In-Reply-To: References: Message-ID: On Wed, Nov 2, 2011 at 1:40 PM, Ian Kelly wrote: > > If you want to customize the dict you need to do it in __new__, not > __init__. ?By the time __init__ is called, the class has already been > created. > > class MetaClass(type): > ? ?def __new__(mcs, name, bases, dict): > ? ? ? ?for k, v in dict.items(): > ? ? ? ? ? ?if isinstance(v, FunctionType): > ? ? ? ? ? ? ? ?dict[k] = staticmethod(v) > ? ? ? ?return type.__new__(mcs, name, bases, dict) Great! It works perfectly! > If you were using a more recent Python version, I would suggest using > a class decorator instead of a metaclass. ?You can still do this in > Python 2.5, but the syntax will be more awkward. > > # Python 2.6+ > def FuncGroup(class_): > ? ?for k, v in class_.__dict__.items(): > ? ? ? ?if isinstance(v, FunctionType): > ? ? ? ? ? ?setattr(class_, k, staticmethod(v)) > ? ?return class_ > > @FuncGroup > class Greeting(object): > ? ?def hello(): > ? ? ? ?print("Hello!") > > # Python 2.5 > class Greeting(object): > ? ?def hello(): > ? ? ? ?print("Hello!") > Greeting = FuncGroup(Greeting) This is so good method. Thank you, Ian. -- regards, makoto kuwata From devplayer at gmail.com Wed Nov 2 01:50:48 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 1 Nov 2011 22:50:48 -0700 (PDT) Subject: How to mix-in __getattr__ after the fact? References: <4630c4d0-86bc-4295-8bbb-6f58415191c8@v15g2000vbm.googlegroups.com> <4EAAF264.1050307@stoneleaf.us> <8bc11029-860e-4d3a-8770-062e16e31514@j39g2000yqc.googlegroups.com> Message-ID: On Oct 31, 8:01?am, dhyams wrote: > Thanks for all of the responses; everyone was exactly correct, and > obeying the binding rules for special methods did work in the example > above. ?Unfortunately, I only have read-only access to the class > itself (it was a VTK class wrapped with SWIG), so I had to find > another way to accomplish what I was after. > Please share what you found as the other way. From jeanmichel at sequans.com Wed Nov 2 07:04:35 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 02 Nov 2011 12:04:35 +0100 Subject: __init__ with multiple list values In-Reply-To: <1acb0d4c-069b-4356-8a9e-cd5640023c2b@g27g2000pre.googlegroups.com> References: <1acb0d4c-069b-4356-8a9e-cd5640023c2b@g27g2000pre.googlegroups.com> Message-ID: <4EB123C3.3040406@sequans.com> Gnarlodious wrote: > Initializing a list of objects with one value: > > class Order: > def __init__(self, ratio): > self.ratio=ratio > def __call__(self): > return self.ratio > > ratio=[1, 2, 3, 4, 5] > Orders=[Order(x) for x in ratio] > > > But now I want to __init__ with 3 values: > > class Order: > def __init__(self, ratio, bias, locus): > self.ratio=ratio > self.bias=bias > self.locus=locus > def __call__(self): > return self.ratio, self.bias, self.locus > > ratio=[1, 2, 3, 4, 5] > bias=[True, False, True, False, True] > locus=['A', 'B', 'C', 'D', 'E'] > Orders=[Order(x,y,z) for x,y,z in [ratio, bias, locus]] > > >>>> ValueError: too many values to unpack (expected 3) >>>> > > How to do it? > > -- Gnarlie > I'm a little off topic but you may want to avoid having inconsistent interfaces for your class methods, especially when it comes to special methods like __init__ and __call__. Having __call__ return a tuple with different length depending on the initialization of the object is a bad idea. You will surely end up in unpacking error in the future. Same things for your attributes, the presence of bias is conditioned by the object creation... Very bad idea :o) o1 = Order([1,2,3]) o2 = Order([1,2,3], [4, 5, 6, [7, 8, 9]) print o1.bias > Unknown attribute ratio, bias, locus = o2.call() ratio, bias, locus = o1.call() > Unpacking error You could do the following : class Order: def __init__(self, ratio, bias=None, locus=None): self.ratio=ratio self.bias=bias self.locus=locus def __call__(self): return self.ratio, self.bias, self.locus It would allow you to create your object with just the ratio and keep a consistent interface. Unpacking the __call__ return will never fail, and if you're interested in keeping only ratios, then you can write ratio, _, _ = o1.call() JM PS : accessing attributes using the __call__ method sounds like a little bit of magic for the lazy guy :o) People expect something to be executed when calling an object, not getting its attributes. It would be better to stick with the classic way : o1.ratio From pauldavidmena at gmail.com Wed Nov 2 08:44:40 2011 From: pauldavidmena at gmail.com (extraspecialbitter) Date: Wed, 2 Nov 2011 05:44:40 -0700 (PDT) Subject: parsing text from "ethtool" command References: <5544686.62.1320189565337.JavaMail.geo-discussion-forums@prog16> Message-ID: On Nov 1, 7:35?pm, Ian Kelly wrote: > On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka wrote: > > In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust. > > Or simply: > > if "Speed" in line: > > There is no need for a regular expression here. ?This would also work > and be a bit more discriminating: > > if line.strip().startswith("Speed") > > BTW, to the OP, note that your condition (line[0:6] == "Speed") cannot > match, since line[0:6] is a 6-character slice, while "Speed" is a > 5-character string. > > Cheers, > Ian Ian, Replacing my regular expression with line.strip().startswith did the trick. Thanks for the tip! Paul From andrea.crotti.0 at gmail.com Wed Nov 2 10:03:09 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 02 Nov 2011 14:03:09 +0000 Subject: leftover pyc files Message-ID: <4EB14D9D.8080309@gmail.com> In our current setup, the script in charge to run our applications also scan all the directories and if it finds any "pyc" file without the corresponding module, it removes it. This was done because when you rename something, the old "pyc" remains there and can cause problems. Is it the only way possible to scan through and remove all of them or is there a smarter way? From jeanmichel at sequans.com Wed Nov 2 10:39:19 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 02 Nov 2011 15:39:19 +0100 Subject: parsing text from "ethtool" command In-Reply-To: References: Message-ID: <4EB15617.4000509@sequans.com> extraspecialbitter wrote: > I'm still trying to write that seemingly simple Python script to print > out network interfaces (as found in the "ifconfig -a" command) and > their speed ("ethtool "). The idea is to loop for each > interface and > print out its speed. I'm looping correctly, but have some issues > parsing the output for all interfaces except for the "pan0" > interface. I'm running on eth1, and the "ifconfig -a" command also > shows an eth0, and of course lo. My script is trying to match on the > string "Speed", but I never seem to successfully enter the "if" > clause. > > First, here is the output of "ethtool eth1": > > ================= > > Settings for eth1: > Supported ports: [ TP ] > Supported link modes: 10baseT/Half 10baseT/Full > 100baseT/Half 100baseT/Full > Supports auto-negotiation: Yes > Advertised link modes: 10baseT/Half 10baseT/Full > 100baseT/Half 100baseT/Full > Advertised pause frame use: No > Advertised auto-negotiation: Yes > Speed: 100Mb/s > Duplex: Full > Port: Twisted Pair > PHYAD: 1 > Transceiver: internal > Auto-negotiation: on > MDI-X: off > Supports Wake-on: pumbag > Wake-on: g > Current message level: 0x00000001 (1) > Link detected: yes > > ================= > > The script *should* match on the string "Speed" and then assign "100Mb/ > s" to a variable, but is never getting past the second if statement > below: > > ================= > > #!/usr/bin/python > > # Quick and dirty script to print out available interfaces and their > speed > > # Initializations > > output = " Interface: %s Speed: %s" > noinfo = "(Speed Unknown)" > speed = noinfo > > import os, socket, types, subprocess > > fp = os.popen("ifconfig -a") > dat=fp.read() > dat=dat.split('\n') > for line in dat: > if line[10:20] == "Link encap": > interface=line[:9] > cmd = "ethtool " + interface > gp = os.popen(cmd) > fat=gp.read() > fat=fat.split('\n') > for line in fat: > if line[0:6] == "Speed": > try: > speed=line[8:] > except: > speed=noinfo > print output % (interface, speed) > > ================= > > Again, I appreciate everyone's patience, as I'm obviously I'm a python > newbie. Thanks in advance! > Hi, without starting a flamewar about regular expression, they sometimes can become usefull and really simplify code: s1 = """eth0 Link encap:Ethernet HWaddr 00:1d:09:2b:d2:be inet addr:192.168.200.176 Bcast:192.168.200.255 Mask:255.255.255.0 inet6 addr: fe80::21d:9ff:fe2b:d2be/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:297475688 errors:0 dropped:7 overruns:0 frame:2 TX packets:248662722 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2795194692 (2.6 GiB) TX bytes:2702265420 (2.5 GiB) Interrupt:17 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:5595504 errors:0 dropped:0 overruns:0 frame:0 TX packets:5595504 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1601266268 (1.4 GiB) TX bytes:1601266268 (1.4 GiB) """ import re itfs = [section for section in s1.split('\n\n') if section and section != '\n'] # list of interfaces sections, filter the empty sections for itf in itfs: match = re.search('^(\w+)', itf) # search the word at the begining of the section interface = match and match.group(1) match = re.search('MTU:(\d+)', itf) # search for the field MTU: and capture its digital value mtu = (match and match.group(1)) or 'MTU not found' print interface, mtu >>> eth0 1500 >>> lo 16436 If you're not familiar with python regexp, I would advise to use kodos.py (google it), it really does help. The strong point about the code above, is that it removes all the tedious if then else logic and the arbitrary slice indexes. JM PS : I cannot test the 'Speed' because it's absent from my ifconfig display, but you should be able to figure it out :o) From __peter__ at web.de Wed Nov 2 11:03:48 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 02 Nov 2011 16:03:48 +0100 Subject: leftover pyc files References: <4EB14D9D.8080309@gmail.com> Message-ID: Andrea Crotti wrote: > In our current setup, the script in charge to run our applications also > scan all the directories and if it finds any "pyc" file without the > corresponding > module, it removes it. > > This was done because when you rename something, the old "pyc" remains > there and can cause problems. > > Is it the only way possible to scan through and remove all of them or is > there a smarter way? Switch to Python3.2 ;) http://docs.python.org/dev/py3k/whatsnew/3.2.html#pep-3147-pyc-repository-directories http://www.python.org/dev/peps/pep-3147/#case-4-legacy-pyc-files-and-source-less-imports From miki.tebeka at gmail.com Wed Nov 2 11:08:48 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 2 Nov 2011 08:08:48 -0700 (PDT) Subject: Sort items in wxListCtrl In-Reply-To: References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> Message-ID: <28740627.642.1320246528964.JavaMail.geo-discussion-forums@pref15> wx.FileDialog shows files and directories. If you need the user to pick one, this is the standard way. Otherwise, if you need custom view on the file system then probably list control is the right way to go. Again, the demo has a working example with sortable list control. From nospam at a.it Wed Nov 2 11:15:27 2011 From: nospam at a.it (Hanss) Date: Wed, 02 Nov 2011 15:15:27 +0000 Subject: getting columns attributes in declarative style with sqlalchemy In-Reply-To: <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> References: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> Message-ID: Il 01/11/2011 19.37, tres.bailey at gmail.com ha scritto: > > I'm no SQLAlchemy expert, but I have used the Table and Column attribute objects from the model object to solve a similar problem in the past. You can use the following syntax to do it: > > [col.name for col in Country.__table__.columns._all_cols] Thank you very much! This is exactly what I was looking for! Thanks! From nospam at a.it Wed Nov 2 11:17:37 2011 From: nospam at a.it (Gabriele) Date: Wed, 02 Nov 2011 15:17:37 +0000 Subject: getting columns attributes in declarative style with sqlalchemy In-Reply-To: <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> References: <372ac973-575c-466a-9322-a879f099d86a@v5g2000vbh.googlegroups.com> <20870384.611.1320176262266.JavaMail.geo-discussion-forums@yqnx19> Message-ID: Il 01/11/2011 19.37, tres.bailey at gmail.com ha scritto: > Sorry for the repost, if it does in fact repost. > > I'm no SQLAlchemy expert, but I have used the Table and Column attribute objects from the model object to solve a similar problem in the past. You can use the following syntax to do it: > > [col.name for col in Country.__table__.columns._all_cols] Thank you very much! This is exactly what I was looking for! Thanks! Gabriele From andrea.crotti.0 at gmail.com Wed Nov 2 11:45:43 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 02 Nov 2011 15:45:43 +0000 Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <4EB165A7.3050102@gmail.com> On 11/02/2011 03:03 PM, Peter Otten wrote: > Switch to Python3.2 ;) Yes I saw that and it would be great, unfortunately we're stuck with Python 2.5 :O for some more time. Anyway now the code that does it is a recursive thing ilke def _clean_orphaned_pycs(self, directory, simulate=False): """Remove all the pyc files without a correspondent module """ files = listdir(directory) # going down the tree recursively (like os.walk) for x in files: if x.endswith('.pyc'): py_file = x.split('.pyc')[0] + '.py' if (not simulate) and (py_file not in files): deletable_pyc = path.join(directory, x) print 'DELETING pyc %s as it has no py %s' % \ (deletable_pyc, py_file) remove(deletable_pyc) #TODO: move out these special cases if path.isdir(path.join(directory, x)) \ and x != '.svn' \ and not x.endswith('.egg-info'): self._clean_orphaned_pycs(path.join(directory, x)) Can be done much better probably with os.walk or os.path.walk, any suggestions? From ckaynor at zindagigames.com Wed Nov 2 12:06:37 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 2 Nov 2011 09:06:37 -0700 Subject: leftover pyc files In-Reply-To: <4EB165A7.3050102@gmail.com> References: <4EB14D9D.8080309@gmail.com> <4EB165A7.3050102@gmail.com> Message-ID: If you can at least upgrade to Python 2.6, another option, if you don't mind losing the byte code caching all together (it may worsen load times, however probably not significantly), you can set PYTHONDONTWRITEBYTECODE to prevent the writing of .pyc files. Alternatively, again in 2.6+, you can also specify the -B command-line argument. See http://docs.python.org/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE and http://docs.python.org/using/cmdline.html#cmdoption-unittest-discover-B Chris On Wed, Nov 2, 2011 at 8:45 AM, Andrea Crotti wrote: > On 11/02/2011 03:03 PM, Peter Otten wrote: >> >> Switch to Python3.2 ;) > > Yes I saw that and it would be great, unfortunately we're stuck with Python > 2.5 :O > for some more time. > > Anyway now the code that does it is a recursive thing ilke > def _clean_orphaned_pycs(self, directory, simulate=False): > ? ?"""Remove all the pyc files without a correspondent module > ? ?""" > ? ?files = listdir(directory) > ? ?# going down the tree recursively (like os.walk) > ? ?for x in files: > ? ? ? ?if x.endswith('.pyc'): > ? ? ? ? ? ?py_file = x.split('.pyc')[0] + '.py' > > ? ? ? ? ? ?if (not simulate) and (py_file not in files): > ? ? ? ? ? ? ? ?deletable_pyc = path.join(directory, x) > ? ? ? ? ? ? ? ?print 'DELETING pyc %s as it has no py %s' % \ > ? ? ? ? ? ? ? ? ? ?(deletable_pyc, py_file) > ? ? ? ? ? ? ? ?remove(deletable_pyc) > > ? ? ? ?#TODO: move out these special cases > ? ? ? ?if path.isdir(path.join(directory, x)) \ > ? ? ? ? ? ?and x != '.svn' \ > ? ? ? ? ? ?and not x.endswith('.egg-info'): > > ? ? ? ? ? ?self._clean_orphaned_pycs(path.join(directory, x)) > > > Can be done much better probably with os.walk or os.path.walk, > any suggestions? > -- > http://mail.python.org/mailman/listinfo/python-list > From andrea.crotti.0 at gmail.com Wed Nov 2 12:43:53 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 02 Nov 2011 16:43:53 +0000 Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <4EB165A7.3050102@gmail.com> Message-ID: <4EB17349.6030100@gmail.com> On 11/02/2011 04:06 PM, Chris Kaynor wrote: > If you can at least upgrade to Python 2.6, another option, if you > don't mind losing the byte code caching all together (it may worsen > load times, however probably not significantly), you can set > PYTHONDONTWRITEBYTECODE to prevent the writing of .pyc files. > Alternatively, again in 2.6+, you can also specify the -B command-line > argument. See http://docs.python.org/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE > and http://docs.python.org/using/cmdline.html#cmdoption-unittest-discover-B > > Chris > Unfortunately not possible :( So well the hand-made removal is also fine, maybe if I'm able to run it as a service it should not impact on the run-time either, which would be nice... From Ric at rdo Wed Nov 2 14:50:00 2011 From: Ric at rdo (Ric at rdo) Date: Wed, 02 Nov 2011 13:50:00 -0500 Subject: Sort items in wxListCtrl References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> <28740627.642.1320246528964.JavaMail.geo-discussion-forums@pref15> Message-ID: On Wed, 2 Nov 2011 08:08:48 -0700 (PDT), Miki Tebeka wrote: >wx.FileDialog shows files and directories. If you need the user to pick one, this is the standard way. Otherwise, if you need custom view on the file system then probably list control is the right way to go. Again, the demo has a working example with sortable list control. Thanks, Do you know if List control has an click event that if you double click on a directory displayed in the control an action can occur? Sorry if its right there but I just did not see. From vonkes at gmail.com Wed Nov 2 15:21:03 2011 From: vonkes at gmail.com (vonkes) Date: Wed, 2 Nov 2011 12:21:03 -0700 (PDT) Subject: understand program used to create file References: Message-ID: <46219926-741e-407d-8773-8a5efa81dbc3@q13g2000vbd.googlegroups.com> Ho trovato questo script in una directory dove sono conservati molti demo per python non era funzionante,sono riuscito a capirne le finalit? e cos? l'ho reso funzionante. Esamina un file di testo e analizza il carattere di fine riga. le possibilit? dipendono dal sistema operativo usato. Nei file di testo sotto S.O. Unix il carattere di fine riga in genere ? un CR o carriage return. Sotto Mac questo carattere in genere ? un LF linee feed mentre sotto s.o. windows in genere ? CRLF sulla base di ci? l'applicativo osserva tutti i fine riga e ne fa un confronto. Osservando il sorgente si dovrebbe comprendere come il controllo viene fatto. Nell'ipotesi che ci si voglia divertire e non si dia un nome di file o si dia un nome inesistente, l'applicativo fa il controllo su se stesso e poi da le risposte. Provate: ecco il sorgente: __________ inizio applicativo______________ !/usr/bin/python # -*- coding: utf-8 -*- """Controlla file di testo - Controlla quale sia il carattere di fine riga per determinarne lo stile Se la riga termina con CR abbiamo lo stile UNIX Se " " " " LF abbiamo lo stile MAC Se " " " " CRLF abbiamo lo stile Win/MS-Dos Mettiamo una alternativa all'inserimento del file aggiungiamo una parte di codice che nel caso non venga indicato un nome di file o ne indicassimo uno mancante o assente, vada a cercare il file dal quale siamo partiti cioe' questo stesso che dovrebbe essere contenuto nella variabile argv che come e' noto e' una lista di parametri passati dalla linea di comando e il primo elemento della lista e' proprio il nome di questo applicativo che seppure non ? il classico file di testo anch'esso ha i caratteri di fine riga esattamente come quelli dei classici file di testo e quindi possiamo esaminarli per decidere quale stile seguono. """ #---------- fine commento------------- import sys,os import string def Message(parametro): #print "\nquesta e' la funzione che stampera' Il parametro ricevuto" print "\n:",parametro def ChiediFiledaAprire(message): print "\n"+message nome = raw_input( "\ninserisci il nome di un file di testo completo di estensione \n: ") return nome #pathname = sys.path #print "pathname=",pathname def main(): #print os.listdir(sys.path[0]) while True: name = ChiediFiledaAprire(message='Per controllo del carattere di fine linea presente nel file') if name == "": print "Poiche non hai digitato alcun nome il controllo lo effettuer??\ il controllo sul file "+ sys.argv[0] name = sys.argv[0];break elif not name: print "Attenzione !! Il nome file digitato non esiste, effettuer?? controllo sul file "+sys.argv[0] +" che ?n esecuzione " name = sys.argv[0];break else: break fp = open(name, 'rb') try: data = fp.read() #print "nel file",name," abbiamo trovato",data except MemoryError: Message("Attenzione, Il file e' troppo grande.") sys.exit(0) if len(data) == 0: Message('Il File e vuoto.') sys.exit(0) number_cr = string.count(data, '\r') number_lf = string.count(data, '\n') if number_cr == number_lf == 0: Message('Nel File '+name+' manca il carattere di fine riga.') if number_cr != 0 and chr(10) not in data: Message('Il File '+name+' presenta lo style unix con fine riga = CR') elif number_lf != 0 and chr(13) not in data: Message('Il File '+name+' presenta lo style mac con fine riga = LF') elif number_cr == number_lf: Message('Il File '+name+' presenta lo style Win/MS-Dos con fine riga =CRLF') else: Message('Il File '+name+' presenta un fine riga non riconosciuto (binary file?)') sys.exit(0) #----------------fine applicativo---------- Ciao vonkes From Catherine.M.Moroney at jpl.nasa.gov Wed Nov 2 15:31:48 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Wed, 02 Nov 2011 12:31:48 -0700 Subject: fast copying of large files in python Message-ID: Hello, I'm working on an application that as part of its processing, needs to copy 50 Meg binary files from one NFS mounted disk to another. The simple-minded approach of shutil.copyfile is very slow, and I'm guessing that this is due to the default 16K buffer size. Using shtil.copyfileobj is faster when I set a larger buffer size, but it's still slow compared to a "os.system("cp %s %s" % (f1,f2))" call. Is this because of the overhead entailed in having to open the files in copyfileobj? I'm not worried about portability, so should I just do the os.system call as described above and be done with it? Is that the fastest method in this case? Are there any "pure python" ways of getting the same speed as os.system? Thanks, Catherine From macmanes at gmail.com Wed Nov 2 17:13:34 2011 From: macmanes at gmail.com (Matt) Date: Wed, 2 Nov 2011 14:13:34 -0700 (PDT) Subject: simple file flow question with csv.reader Message-ID: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> Hi All, I am trying to do a really simple file operation, yet, it befuddles me... I have a few hundred .csv files, and to each file, I want to manipulate the data, then save back to the original file. The code below will open up the files, and do the proper manipulations-- but I can't seem to save the files after the manipulation.. How can I save the files-- or do I need to try something else maybe with split, join, etc.. import os import csv for filename in os.listdir("/home/matthew/Desktop/pero.ngs/blast"): with open(filename, 'rw') as f: reader = csv.reader(f) for row in reader: print ">",row[0],row[4],"\n",row[1], "\n", ">", row[2], "\n", row[3] Thanks in advance, Matt From d at davea.name Wed Nov 2 17:26:16 2011 From: d at davea.name (Dave Angel) Date: Wed, 02 Nov 2011 17:26:16 -0400 Subject: fast copying of large files in python In-Reply-To: References: Message-ID: <4EB1B578.801@davea.name> On 11/02/2011 03:31 PM, Catherine Moroney wrote: > Hello, > > I'm working on an application that as part of its processing, needs to > copy 50 Meg binary files from one NFS mounted disk to another. > > The simple-minded approach of shutil.copyfile is very slow, and I'm > guessing that this is due to the default 16K buffer size. Using > shtil.copyfileobj is faster when I set a larger buffer size, but it's > still slow compared to a "os.system("cp %s %s" % (f1,f2))" call. > Is this because of the overhead entailed in having to open the files > in copyfileobj? > > I'm not worried about portability, so should I just do the > os.system call as described above and be done with it? Is that the > fastest method in this case? Are there any "pure python" ways of > getting the same speed as os.system? > > Thanks, > > Catherine I suspect the fastest way would be to use scp, and not try to use your local mount for either file. There are some options on scp that tell it to just connect the (up to) two machines to each other and transfer, where it won't even come to your local machine. I do that sort of thing when I'm connecting over slow internet (and vpn) to two machines that are on the same local subnet. -- DaveA From python.list at tim.thechases.com Wed Nov 2 19:06:39 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 02 Nov 2011 18:06:39 -0500 Subject: simple file flow question with csv.reader In-Reply-To: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> References: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> Message-ID: <4EB1CCFF.4050208@tim.thechases.com> On 11/02/11 16:13, Matt wrote: > Hi All, > > I am trying to do a really simple file operation, yet, it befuddles me... > > I have a few hundred .csv files, and to each file, I want to manipulate the data, then save back to the original file. The code below will open up the files, and do the proper manipulations-- but I can't seem to save the files after the manipulation.. > > How can I save the files-- or do I need to try something else maybe with split, join, etc.. > > > import os > import csv > for filename in os.listdir("/home/matthew/Desktop/pero.ngs/blast"): > with open(filename, 'rw') as f: > reader = csv.reader(f) > for row in reader: > print ">",row[0],row[4],"\n",row[1], "\n",">", row[2], "\n", row[3] Your last line just prints the data to standard-out. You can either pipe the output to a file: python myprog.py > output.txt or you can write them to a single output file: out = file('output.txt', 'w') for filename in os.listdir(...): with open(filename, 'rw') as f: reader = csv.reader(f) for row in reader: out.write(">%s%s\n%s\n>%s\n>%s\n%s" % ( row[0], row[4], row[1], row[2], row[3])) or you can write them to output files on a per-input basis: for filename in os.listdir(SOURCE_LOC): with open(filename, 'r') as f: outname = os.path.join( DEST_LOC, os.path.basename(filename), ) with file(outname, 'wb') as out: for row in reader: out.write(">%s%s\n%s\n>%s\n>%s\n%s" % ( row[0], row[4], row[1], row[2], row[3])) -tkc From tjreedy at udel.edu Wed Nov 2 19:50:36 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Nov 2011 19:50:36 -0400 Subject: simple file flow question with csv.reader In-Reply-To: References: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> Message-ID: On 11/2/2011 7:06 PM, Dennis Lee Bieber wrote: > On Wed, 2 Nov 2011 14:13:34 -0700 (PDT), Matt > declaimed the following in gmane.comp.python.general: > >> I have a few hundred .csv files, and to each file, I want to >> manipulate the data, then save back to the original file. That is dangerous. Better to replace the file with a new one of the same name. > Option 1: Read the file completely into memory (your example is > reading line by line); close the reader and its file; reopen the > file for "wb" (delete, create new); open CSV writer on that file; > write the memory contents. and lose data if your system crashes or freezes during the write. > Option 2: Open a temporary file "wb"; open a CSV writer on the file; > for each line from the reader, update the data, send to the writer; > at end of reader, close reader and file; delete original file; > rename temporary file to the original name. This works best if new file is given a name related to the original name, in case rename fails. Alternative is to rename original x to x.bak, write or rename new file, then delete .bak file. -- Terry Jan Reedy From fzadrozny at appcelerator.com Wed Nov 2 19:52:44 2011 From: fzadrozny at appcelerator.com (Fabio Zadrozny) Date: Wed, 2 Nov 2011 21:52:44 -0200 Subject: PyDev 2.2.4 Released Message-ID: Hi All, PyDev 2.2.4 has been released Details on PyDev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: ------------------------------- **Cython** * Cython is now supported in PyDev (.pyx files may be opened with the PyDev editor). **Globals Token Browser (Ctrl+Shift+T)** * Packages/Modules can now be reached through the globals browser (so, __init__.py files can now be easily gotten through the package they represent) **Handling external files** * External libraries configured in a project appearing in the PyDev Package Explorer * Show in > PyDev Package Explorer working for files that are under the interpreter or external libraries. * Show in > PyDev Package Explorer working for files inside .zip archives. * External files that were opened when Eclipse is closed are properly reopened. **Editor** * New option in the code-formatter to only apply code-formatting on changed lines on save. * from __future__ import now properly appears as first even if grouping is enabled. * it's now possible to have a minimap of the code in the overview ruler (enable in preferences > PyDev > Editor > Overview Ruler Minimap). **Unittest runner** * exc_clear() no longer called if it's not available. * Fixed issue where class tearDown was executed twice. **Debugger** * It's now possible to enable/disable stepping into properties while in the debugger. Menu: Run > Disable step into properties (patch by Hussain Bohra) * Show in outline view activated in debug perspective (patch by Hussain Bohra) * Watch expressions can be properly expanded in the watch view (patch by Hussain Bohra) * Breakpoints in external files are properly shown. * Remote debugger: starting the remote debugger no longer shows a launch configuration * Remote debugger: when the server is stopped, the server socket is properly closed **Minors** * Fixed issue in rename (Alt+Shift+R) / find references (Ctrl+Shift+G) on top level module variables. * Fixed issue where create class/method/field action was not ok because of comment. * Fixed issue where doing create class/method/field action on file with tabs ended up adding spaces. What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python, Jython and IronPython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer Appcelerator http://appcelerator.com/ Aptana http://aptana.com/ PyDev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com From radha at leapship.com Wed Nov 2 20:05:47 2011 From: radha at leapship.com (Radhika Bauerle) Date: Wed, 2 Nov 2011 17:05:47 -0700 Subject: Full time Job opening -Python lead in washington area. Message-ID: Hello eveyone: we are looking for a Python lead in washington area. Strong on Python Strong on OOAD Worked on high performance web application Cheers, Radhika Bauerle. Leapship, Inc. radha at leapship.com 408.355.8462 -- Radhika Bauerle. Leapship, Inc. radha at leapship.com 408.355.8462 -------------- next part -------------- An HTML attachment was scrubbed... URL: From miki.tebeka at gmail.com Wed Nov 2 20:06:33 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 2 Nov 2011 17:06:33 -0700 (PDT) Subject: Sort items in wxListCtrl In-Reply-To: References: <4uh0b79l43lb2hamit7jjbt4c1ligu8shb@4ax.com> <27515703.32.1320189290076.JavaMail.geo-discussion-forums@pref15> <28740627.642.1320246528964.JavaMail.geo-discussion-forums@pref15> Message-ID: <15871079.2079.1320278793045.JavaMail.geo-discussion-forums@prgt40> You probably want wx.EVT_LEFT_DCLICK, see the ListCtrl demo in the wx demo. From joncle at googlemail.com Wed Nov 2 20:47:02 2011 From: joncle at googlemail.com (Jon Clements) Date: Wed, 2 Nov 2011 17:47:02 -0700 (PDT) Subject: simple file flow question with csv.reader References: <16701610.1994.1320268414468.JavaMail.geo-discussion-forums@prgt40> Message-ID: <6e0fc699-1047-41c6-8387-b9f402e98e2a@w7g2000yqc.googlegroups.com> On Nov 2, 11:50?pm, Terry Reedy wrote: > On 11/2/2011 7:06 PM, Dennis Lee Bieber wrote: > > > On Wed, 2 Nov 2011 14:13:34 -0700 (PDT), Matt > > declaimed the following in gmane.comp.python.general: > > >> I have a few hundred .csv files, and to each file, I want to > >> manipulate the data, then save back to the original file. > > That is dangerous. Better to replace the file with a new one of the same > name. > > > Option 1: ?Read the file completely into memory (your example is > > reading line by line); close the reader and its file; reopen the > > file for "wb" (delete, create new); open CSV writer on that file; > > write the memory contents. > > and lose data if your system crashes or freezes during the write. > > > Option 2: ?Open a temporary file "wb"; open a CSV writer on the file; > > for each line from the reader, update the data, send to the writer; > > at end of reader, close reader and file; delete original file; > > rename temporary file to the original name. > > This works best if new file is given a name related to the original > name, in case rename fails. Alternative is to rename original x to > x.bak, write or rename new file, then delete .bak file. > > -- > Terry Jan Reedy To the OP, I agree with Terry, but will add my 2p. What is this meant to achieve? >>> row = range(10) >>> print ">",row[0],row[4],"\n",row[1], "\n", ">", row[2], "\n", row[3] > 0 4 1 > 2 3 Is something meant to read this afterwards? I'd personally create a subdir called db, create a sqlite3 db, then load all the required fields into it (with a column for filename)... it will either work or fail, then if it succeeds, start overwriting the originals - just a "select * from some_table" will do, using itertools.groupby on the filename column, changing the open() request etc... just my 2p mind you, Jon. From stefan_ml at behnel.de Thu Nov 3 02:59:48 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 03 Nov 2011 07:59:48 +0100 Subject: Full time Job opening -Python lead in washington area. In-Reply-To: References: Message-ID: Radhika Bauerle, 03.11.2011 01:05: > Hello eveyone: Well, and here's the problem already: "everyone". Note that it's commonly considered inappropriate to post job offers on this list. Please use the Python job board instead: http://python.org/community/jobs/ (easy to find by clicking on "python jobs" on the Python.org front page) Stefan From tartley at tartley.com Thu Nov 3 03:49:35 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 00:49:35 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> A task like this is more suited to bash than Python: find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 03:49:35 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 00:49:35 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> A task like this is more suited to bash than Python: find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 03:50:37 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 00:50:37 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <33506962.66.1320306638033.JavaMail.geo-discussion-forums@yqie15> This can be added to git as a post-checkout hook: In your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 03:50:37 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 00:50:37 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <33506962.66.1320306638033.JavaMail.geo-discussion-forums@yqie15> This can be added to git as a post-checkout hook: In your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 04:45:53 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 01:45:53 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <17659765.658.1320309953278.JavaMail.geo-discussion-forums@yqnv12> This can be added to your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' From tartley at tartley.com Thu Nov 3 04:45:53 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 3 Nov 2011 01:45:53 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> Message-ID: <17659765.658.1320309953278.JavaMail.geo-discussion-forums@yqnv12> This can be added to your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' From jacob.abraham at gmail.com Thu Nov 3 05:22:57 2011 From: jacob.abraham at gmail.com (Jacob Abraham) Date: Thu, 3 Nov 2011 14:52:57 +0530 Subject: Paramiko Question Message-ID: Hi All, I need help with the below mentioned script. The second time I call a.execute, self.transport.open_session() fails with an EOF error. Is this a paramiko bug or am I doing something wrong? import paramiko class Connection(object): def __init__(self, host, username = None, password = None, private_key = None, \ port = 22): self.transport = paramiko.Transport((host, port)) self.live = True self.transport.connect(username = username, password = password) def execute(self, command): channel = self.transport.open_session() channel.exec_command(command) output = channel.makefile('rb', -1).readlines() if output: print output else: print channel.makefile_stderr('rb', -1).readlines() def close(self): if self.live: self.transport.close() self.live = False def __del__(self): self.close() if __name__ == '__main__': a= Connection('ip_or_hostname', 'root', '') print a.execute('version') print a.execute('version') print a.execute('version') a.close() Regards, Jacob Abraham From robert.kern at gmail.com Thu Nov 3 05:56:40 2011 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 03 Nov 2011 09:56:40 +0000 Subject: Chaco for real-time plot of PySerial data In-Reply-To: References: Message-ID: On 11/1/11 10:27 PM, Jack Keegan wrote: > Hi there, > > I asked this question on the enthought chaco mailing list some time last by have > yet to receive a reply. Thought I'd ask here to see if anyone could shed some > light on things for me. I have been considering using chaco / traits for close > to a year now and am finally biting the bullet so to speak. What I would really > like to do to begin with is to make a real-time plotting application which gets > its data from the serial port. Can anyone please point me in the right direction > for doing this? > > Since I didn't get a reply on the chaco list I'm now thinking it might be a > dangerous route to go down since it will be difficult to get help. Any > recommendations? I'm sorry we didn't respond to you. The chaco-users mailing list is not well-subscribed or well-trafficked, but the enthought-dev at enthought.com mailing list is. We haven't done a good job of letting new people know they should be on the chaco-users list to answer questions or updating the documentation to point users to enthought-dev instead. Anyways, to answer your question, we have several examples of how one sets up a plot then updates it with new data: https://github.com/enthought/chaco/tree/master/examples/demo/updating_plot I can't help much with the PySerial part, I'm afraid. Integrating that with the GUI event loop is probably going to be the trickiest bit. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From landa.martin at gmail.com Thu Nov 3 06:07:36 2011 From: landa.martin at gmail.com (Martin Landa) Date: Thu, 3 Nov 2011 03:07:36 -0700 (PDT) Subject: ctypes: catch system exit from C library Message-ID: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> Hi all, in my python application I am calling functions from a C library via `ctypes` interface. Some fns from that C library calls `exit()` on error. It causes that the python application crashes even without any notification. Is it possible to catch library system exit calls from such python application? Thanks in advance, Martin From alec.taylor6 at gmail.com Thu Nov 3 06:19:24 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 3 Nov 2011 21:19:24 +1100 Subject: Database access benchmarks for use in web-frameworks - How does Python compare? Message-ID: Good afternoon, I'm building a large e-commerce site, and it is very important that what I write can: - Handle larger server load - Deliver pages quickly - Make transactions quickly as well as have a small development time (i.e. pre-built modules for e-commerce are available, and extendible). Are there recent accessible statistics available, comparing these metrics across the most popular web-frameworks? (i.e. Symfony, DJango, Rails, ASP.NET &etc) Thanks for all suggestions, Alec Taylor From __peter__ at web.de Thu Nov 3 06:51:48 2011 From: __peter__ at web.de (Peter Otten) Date: Thu, 03 Nov 2011 11:51:48 +0100 Subject: leftover pyc files References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: Jonathan Hartley wrote: > A task like this is more suited to bash than Python: > > find . -name '*.pyc' -exec rm '{}' ';' You forgot to exclude the .svn directory from the search and didn't limit the deletion to pyc-files whose corresponding py-file doesn't exist. How would your line look with these modifications? From duncan.booth at invalid.invalid Thu Nov 3 07:32:35 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 3 Nov 2011 11:32:35 GMT Subject: ctypes: catch system exit from C library References: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> Message-ID: Martin Landa wrote: > Hi all, > > in my python application I am calling functions from a C library via > `ctypes` interface. Some fns from that C library calls `exit()` on > error. It causes that the python application crashes even without any > notification. Is it possible to catch library system exit calls from > such python application? > > Thanks in advance, Martin There is no safe way to do this. An unsafe way would be to install an atexit() handler and longjmp out of it, but that would mess up any other atexit processing and quite likely crash the program. Or you could just move the essential cleanup into atexit() but not attempt to stop the program termination. The clean (but not necessarily easy) solution would be to move all of the code that uses the library into a separate subprocess and then you can catch and handle the subprocess exiting in your main code. -- Duncan Booth http://kupuguy.blogspot.com From ulrich.eckhardt at dominolaser.com Thu Nov 3 08:28:17 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 03 Nov 2011 13:28:17 +0100 Subject: ctypes: catch system exit from C library In-Reply-To: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> References: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> Message-ID: <10eao8-84g.ln1@satorlaser.homedns.org> Am 03.11.2011 11:07, schrieb Martin Landa: > in my python application I am calling functions from a C library via > `ctypes` interface. Some fns from that C library calls `exit()` on > error. Just curious, which library is that? Uli From invalid at invalid.invalid Thu Nov 3 10:16:50 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 3 Nov 2011 14:16:50 +0000 (UTC) Subject: ctypes: catch system exit from C library References: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> <10eao8-84g.ln1@satorlaser.homedns.org> Message-ID: On 2011-11-03, Ulrich Eckhardt wrote: > Am 03.11.2011 11:07, schrieb Martin Landa: >> in my python application I am calling functions from a C library via >> `ctypes` interface. Some fns from that C library calls `exit()` on >> error. > > Just curious, which library is that? And who should we have thrashed and pilloried for writing it that way? -- Grant Edwards grant.b.edwards Yow! BARRY ... That was at the most HEART-WARMING gmail.com rendition of "I DID IT MY WAY" I've ever heard!! From brandon.harris at reelfx.com Thu Nov 3 10:42:08 2011 From: brandon.harris at reelfx.com (Brandon Harris) Date: Thu, 03 Nov 2011 09:42:08 -0500 Subject: Python Pickling Issue Message-ID: <4EB2A840.5060108@reelfx.com> I have written a fairly large DAG with python and I've run into an issue when attempting to pickle the data to disk. It will pickle fine the first time, but if I call pickle again, it throws this error. /usr/lib64/python2.6/copy_reg.py in _reduce_ex(self, proto) 68 else: 69 if base is self.__class__: ---> 70 raise TypeError, "can't pickle %s objects" % base.__name__ 71 state = base(self) 72 args = (self.__class__, base, state) TypeError: can't pickle function objects I'm calling save_file = open('my_file.rsf', 'w') cPickle.dump(self, save_file) I have attempted to pickle the object to a different file after the first time, but the error is still thrown. This wouldn't be very hard to track down if the error gave any indication as to where or what this function it can't pickle is, so if there's any possible way to at least get the name of what's failing to be pickled, that would be a win. Thanks in advance for all replies. Brandon L. Harris From brandon.harris at reelfx.com Thu Nov 3 10:58:51 2011 From: brandon.harris at reelfx.com (Brandon Harris) Date: Thu, 03 Nov 2011 09:58:51 -0500 Subject: Python Pickling Issue In-Reply-To: <4EB2A840.5060108@reelfx.com> References: <4EB2A840.5060108@reelfx.com> Message-ID: <4EB2AC2B.3050301@reelfx.com> After digging around a while I discovered I was attempting to pickle a third party class that can't be pickled. Initially I was removing it before pickling and everything was kosher, but at some point it got back onto the class. Apologies. Brandon L. Harris On 11/03/2011 09:42 AM, Brandon Harris wrote: > I have written a fairly large DAG with python and I've run into an > issue when attempting to pickle the data to disk. > It will pickle fine the first time, but if I call pickle again, it > throws this error. > > /usr/lib64/python2.6/copy_reg.py in _reduce_ex(self, proto) > 68 else: > 69 if base is self.__class__: > ---> 70 raise TypeError, "can't pickle %s objects" % > base.__name__ > 71 state = base(self) > 72 args = (self.__class__, base, state) > > TypeError: can't pickle function objects > > I'm calling > save_file = open('my_file.rsf', 'w') > cPickle.dump(self, save_file) > > I have attempted to pickle the object to a different file after the > first time, but the error is still thrown. > > This wouldn't be very hard to track down if the error gave any > indication as to where or what this function it can't pickle is, so > if there's any possible way to at least get the name of what's failing > to be pickled, that would be a win. > > Thanks in advance for all replies. > > Brandon L. Harris > From python at mrabarnett.plus.com Thu Nov 3 11:38:33 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 03 Nov 2011 15:38:33 +0000 Subject: Paramiko Question In-Reply-To: References: Message-ID: <4EB2B579.5060901@mrabarnett.plus.com> On 03/11/2011 09:22, Jacob Abraham wrote: > Hi All, > > I need help with the below mentioned script. The second time I > call a.execute, self.transport.open_session() fails with an EOF error. > Is this a paramiko bug or am I doing something wrong? > > > import paramiko > > class Connection(object): > def __init__(self, host, username = None, password = None, > private_key = None, \ > port = 22): > self.transport = paramiko.Transport((host, port)) > self.live = True > self.transport.connect(username = username, password = password) > > def execute(self, command): > channel = self.transport.open_session() > channel.exec_command(command) > output = channel.makefile('rb', -1).readlines() > if output: > print output > else: > print channel.makefile_stderr('rb', -1).readlines() > > def close(self): > if self.live: > self.transport.close() > self.live = False > > def __del__(self): > self.close() > > if __name__ == '__main__': > a= Connection('ip_or_hostname', 'root', '') > print a.execute('version') > print a.execute('version') > print a.execute('version') > a.close() > I notice that in the 'execute' method you're opening the session, but not closing it. Could that be the cause of the problem? I also notice that in that method you're printing the output, not returning it, but when you call the execute method you're trying to print the result, which will be None. From davidj411 at gmail.com Thu Nov 3 12:48:58 2011 From: davidj411 at gmail.com (davidj411) Date: Thu, 3 Nov 2011 09:48:58 -0700 (PDT) Subject: AIX installation can't find zlib In-Reply-To: <20000728185514.E266@xs4all.nl> References: <8ls045$1522$1@news.rchland.ibm.com> <20000728185514.E266@xs4all.nl> Message-ID: <5936806.117.1320338938935.JavaMail.geo-discussion-forums@prap37> we using RPM to install python 2.7.x and same issue there, can't import gzip b/c zlib is missing. we used RPM to install zlib, but did not effect python. you mentioned modules and uncommenting something. could you be more specific? also , we are not compiling. would that be required for python after uncommenting zlib? From andrea.crotti.0 at gmail.com Thu Nov 3 13:54:52 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Thu, 03 Nov 2011 17:54:52 +0000 Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <4EB2D56C.6070208@gmail.com> All these ideas (shell and git hooks) are nice, but unfortunately - it's svn not git - it's windows not *nix - we have to remove only the ones without the corresponding *py... From bkamrani at gmail.com Thu Nov 3 14:13:43 2011 From: bkamrani at gmail.com (Behnam) Date: Thu, 3 Nov 2011 11:13:43 -0700 (PDT) Subject: Python advanced course (preferably in NA) Message-ID: Anybody is aware of any advanced course in Python preferably in north america? I've been partly coding in Python for couple of years now and have used PyQt. What I'd like to learn more is a kind of advance OOP in python. Any idea? BTW, I'm not a computer engineer and have mechanical background. Thanks in advance! From ericsnowcurrently at gmail.com Thu Nov 3 14:29:14 2011 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Thu, 3 Nov 2011 12:29:14 -0600 Subject: Python advanced course (preferably in NA) In-Reply-To: References: Message-ID: On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: > Anybody is aware of any advanced course in Python preferably in north > america? > > I've been partly coding in Python for couple of years now and have > used PyQt. What I'd like to learn more is a kind of advance OOP in > python. Any idea? While I don't know specifically, check out the following link (from the Python site): http://wiki.python.org/moin/PythonTraining I have taken a class each (PyCon tutorial) from Raymond Hettinger, David Beazley, and Brian Jones, and found each of them to be outstanding courses. Only David is listed on that page to which I linked, though I know Raymond does courses at least from time to time. I've also heard a talk from Wesley Chun and found him to be fantastic. -eric > > BTW, I'm not a computer engineer and have mechanical background. > > Thanks in advance! > -- > http://mail.python.org/mailman/listinfo/python-list > From scottdware at gmail.com Thu Nov 3 14:46:54 2011 From: scottdware at gmail.com (Scott Ware) Date: Thu, 3 Nov 2011 11:46:54 -0700 (PDT) Subject: Dictionary sorting Message-ID: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Python newbie here. So, when creating dictionaries, I am noticing that each time I print it out, that its not in the same order as when I typed it in. They seem to be getting sorted somehow. Is there a way to not sort them and leave the order as is? Thanks! From gordon at panix.com Thu Nov 3 14:57:27 2011 From: gordon at panix.com (John Gordon) Date: Thu, 3 Nov 2011 18:57:27 +0000 (UTC) Subject: Dictionary sorting References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: In <16245908.783.1320346014867.JavaMail.geo-discussion-forums at yqhd1> Scott Ware writes: > Python newbie here. So, when creating dictionaries, I am noticing that > each time I print it out, that its not in the same order as when I typed > it in. They seem to be getting sorted somehow. Is there a way to not sort > them and leave the order as is? Dictionaries don't maintain the order of the items. If you want to keep track of the order in which the items were inserted, you'll need to do that yourself using a separate mechanism (a list, for example.) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From scottdware at gmail.com Thu Nov 3 15:00:27 2011 From: scottdware at gmail.com (Scott Ware) Date: Thu, 3 Nov 2011 12:00:27 -0700 (PDT) Subject: Dictionary sorting In-Reply-To: References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <9836933.743.1320346827670.JavaMail.geo-discussion-forums@yqbl36> Great! Thanks, John for the quick response! From ckaynor at zindagigames.com Thu Nov 3 15:13:46 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 3 Nov 2011 12:13:46 -0700 Subject: Dictionary sorting In-Reply-To: <9836933.743.1320346827670.JavaMail.geo-discussion-forums@yqbl36> References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <9836933.743.1320346827670.JavaMail.geo-discussion-forums@yqbl36> Message-ID: Note that there are a number of recipes available for free online, and if you are using a newer version of Python (2.7 or higher), the collections module includes an OrderedDict class (http://docs.python.org/library/collections.html#collections.OrderedDict - this also include a library for Python 2.4 and higher as well). Note that there are a lot of different possible behaviors, so any particular recipe may or may not behave exactly as you desire. Chris On Thu, Nov 3, 2011 at 12:00 PM, Scott Ware wrote: > Great! Thanks, John for the quick response! > -- > http://mail.python.org/mailman/listinfo/python-list > From insomnia at gmail.com Thu Nov 3 16:01:36 2011 From: insomnia at gmail.com (insomnia at gmail.com) Date: Thu, 3 Nov 2011 13:01:36 -0700 (PDT) Subject: Dictionary sorting In-Reply-To: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <19322439.785.1320350496479.JavaMail.geo-discussion-forums@yqpp12> Moreover, for on-the-fly ordering you can consider to use sorted() on yourdict.keys(), like: for k in sorted(yourdict.keys()): print k, yourdict[k] I think it has no side effects, except that the orderering can be slow on huge data sets, and that you need to call it every time after updating the dict keys. Regards, insomniac From Catherine.M.Moroney at jpl.nasa.gov Thu Nov 3 17:15:19 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Thu, 03 Nov 2011 14:15:19 -0700 Subject: Python advanced course (preferably in NA) In-Reply-To: References: Message-ID: <4EB30467.5050905@jpl.nasa.gov> I've taken two Python classes from David Beazley and can second Eric's recommendation. The "advanced" class is really advanced and goes into some pretty mind-blowing stuff. The class comes with lots of problems and solutions, and a book of all the slides which are a great reference. Well worth the time and money! Catherine Eric Snow wrote: > On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: >> Anybody is aware of any advanced course in Python preferably in north >> america? >> >> I've been partly coding in Python for couple of years now and have >> used PyQt. What I'd like to learn more is a kind of advance OOP in >> python. Any idea? > > While I don't know specifically, check out the following link (from > the Python site): > > http://wiki.python.org/moin/PythonTraining > > I have taken a class each (PyCon tutorial) from Raymond Hettinger, > David Beazley, and Brian Jones, and found each of them to be > outstanding courses. Only David is listed on that page to which I > linked, though I know Raymond does courses at least from time to time. > I've also heard a talk from Wesley Chun and found him to be > fantastic. > > -eric > > >> BTW, I'm not a computer engineer and have mechanical background. >> >> Thanks in advance! >> -- >> http://mail.python.org/mailman/listinfo/python-list >> From Catherine.M.Moroney at jpl.nasa.gov Thu Nov 3 17:18:20 2011 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine Moroney) Date: Thu, 03 Nov 2011 14:18:20 -0700 Subject: Python advanced course (preferably in NA) In-Reply-To: References: Message-ID: <4EB3051C.2010202@jpl.nasa.gov> I've taken two Python classes from David Beazley and can second Eric's recommendation. The "advanced" class is really advanced and goes into some pretty mind-blowing stuff. The class comes with lots of problems and solutions, and a book of all the slides which are a great reference. Well worth the time and money! Catherine Eric Snow wrote: > On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: >> Anybody is aware of any advanced course in Python preferably in north >> america? >> >> I've been partly coding in Python for couple of years now and have >> used PyQt. What I'd like to learn more is a kind of advance OOP in >> python. Any idea? > > While I don't know specifically, check out the following link (from > the Python site): > > http://wiki.python.org/moin/PythonTraining > > I have taken a class each (PyCon tutorial) from Raymond Hettinger, > David Beazley, and Brian Jones, and found each of them to be > outstanding courses. Only David is listed on that page to which I > linked, though I know Raymond does courses at least from time to time. > I've also heard a talk from Wesley Chun and found him to be > fantastic. > > -eric > > >> BTW, I'm not a computer engineer and have mechanical background. >> >> Thanks in advance! >> -- >> http://mail.python.org/mailman/listinfo/python-list >> From emile at fenx.com Thu Nov 3 17:25:03 2011 From: emile at fenx.com (Emile van Sebille) Date: Thu, 03 Nov 2011 14:25:03 -0700 Subject: Python advanced course (preferably in NA) In-Reply-To: References: Message-ID: On 11/3/2011 11:13 AM Behnam said... > Anybody is aware of any advanced course in Python preferably in north > america? > > I've been partly coding in Python for couple of years now and have > used PyQt. What I'd like to learn more is a kind of advance OOP in > python. Any idea? This list works well for that. Try answering all OOP related questions as completely as possible and provide example code. Those that know the difference will promptly point out the improved and generally preferred approaches. When no one corrects you, you're done. Only-slightly-tongue-in-cheek-ly y'rs, Emile From lconrad at Go2France.com Thu Nov 3 17:28:34 2011 From: lconrad at Go2France.com (Len Conrad) Date: Thu, 3 Nov 2011 22:28:34 +0100 Subject: Python advanced course (preferably in NA) Message-ID: <201111032228.AA278266012@mail.Go2France.com> http://www.dabeaz.com/pythonmaster.html ---------- Original Message ---------------------------------- From: Emile van Sebille Date: Thu, 03 Nov 2011 14:25:03 -0700 >On 11/3/2011 11:13 AM Behnam said... >> Anybody is aware of any advanced course in Python preferably in north >> america? >> >> I've been partly coding in Python for couple of years now and have >> used PyQt. What I'd like to learn more is a kind of advance OOP in >> python. Any idea? > >This list works well for that. Try answering all OOP related questions >as completely as possible and provide example code. Those that know the >difference will promptly point out the improved and generally preferred >approaches. When no one corrects you, you're done. > >Only-slightly-tongue-in-cheek-ly y'rs, > >Emile > >-- >http://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Thu Nov 3 17:36:15 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Nov 2011 08:36:15 +1100 Subject: leftover pyc files In-Reply-To: <4EB2D56C.6070208@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <4EB2D56C.6070208@gmail.com> Message-ID: On Fri, Nov 4, 2011 at 4:54 AM, Andrea Crotti wrote: > All these ideas (shell and git hooks) are nice, but unfortunately > - it's svn not git > - it's windows not *nix > - we have to remove only the ones without the corresponding *py... Windows? Well, Windows shell scripting isn't quite as rich as bash/csh/etc, but it's possible. I'll leave recursion as an exercise for the reader, but this (untested) should do it for one directory: for %d in (*.pyc) do ( set fn=%d if not exist !fn:~0,-1! del %d ) This needs to be run with 'cmd /v' to enable delayed variable evaluation. Of course, it'd be really easy to do if Windows Batch had anything like decent string manipulation. ChrisA From tjreedy at udel.edu Thu Nov 3 17:36:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 03 Nov 2011 17:36:25 -0400 Subject: Dictionary sorting In-Reply-To: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On 11/3/2011 2:46 PM, Scott Ware wrote: > Python newbie here. So, when creating dictionaries, I am noticing > that each time I print it out, that its not in the same order as when > I typed it in. They seem to be getting sorted somehow. No, the entries are not being sorted at all. > Is there a way to not sort them and leave the order as is? CPython iterates (and prints) dict items in their arbitrary internal hash table order, which depends on the number and entry order of the items. It is a bug to depend on that arbitrary order in any way. If you want to keep the dict sorted by entry order (as far as the user view goes), use collections.OrderedDict. -- Terry Jan Reedy From joshua.landau.ws at gmail.com Thu Nov 3 18:24:09 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Thu, 3 Nov 2011 22:24:09 +0000 Subject: SystemError when defining Message-ID: Try this out (Python 3.2.2 (default, Sep 5 2011, 04:52:19)): global_variable = None > (lambda *, keyword_only=global_variable: None) # Works, as > expected > (lambda: (lambda argument=global_variable: None))() # Works, as > expected > (lambda: (lambda *, keyword_only=global_variable: None))() # Fails??? > (lambda: (lambda argument=fake_variable: None))() # Fails, as > expected > (lambda: (lambda *, keyword_only=fake_variable: None))() # Fails??? Non-lambdas work as expected, but a lambda inside a non-lambda still exhibits this behaviour. Conclusion: When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython is unable to access the global scope and raises SystemError. -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Thu Nov 3 19:01:38 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 03 Nov 2011 18:01:38 -0500 Subject: Dictionary sorting In-Reply-To: References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <4EB31D52.3080707@tim.thechases.com> On 11/03/11 16:36, Terry Reedy wrote: > > Is there a way to not sort them and leave the order as is? > > CPython iterates (and prints) dict items in their arbitrary internal > hash table order, which depends on the number and entry order of the > items. It is a bug to depend on that arbitrary order in any way. Does this "never trust it" hold even for two consecutive iterations over an unchanged dict? I didn't see anything in the docs[1] to make such a claim, but at least from my experience, one can reliably assert d = {} randomly_populate(d) list1 = list(d.iterkeys()) list2 = list(d.iterkeys()) assert list1 == list2 I understand all bets are off if one adds/removes (or maybe changes the values) of the dict between iterations, but I didn't know if what I saw was merely an implementation detail that shouldn't be counted on. -tkc [1] http://docs.python.org/library/stdtypes.html#mapping-types-dict From rosuav at gmail.com Thu Nov 3 19:51:46 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Nov 2011 10:51:46 +1100 Subject: SystemError when defining In-Reply-To: References: Message-ID: On Fri, Nov 4, 2011 at 9:24 AM, Joshua Landau wrote: > Non-lambdas work as expected, but a lambda inside a non-lambda still > exhibits this behaviour. > Conclusion: > When setting defaults to keyword-only arguments in lambdas which are inside > non-global scopes, cPython is unable to access the global scope and raises > SystemError. Fascinating! I did some introspection with this: >>> def foo(): a=1 # to make sure local variables do exist return (lambda *,keyword_only=global_variable: None)() >>> dis.dis(foo) 2 0 LOAD_CONST 1 (1) 3 STORE_FAST 0 (a) 3 6 LOAD_CONST 2 ('keyword_only') 9 LOAD_NAME 0 (global_variable) 12 LOAD_CONST 3 ( at 0x00FC7340, file "", line 3>) 15 MAKE_FUNCTION 256 18 CALL_FUNCTION 0 21 RETURN_VALUE >>> def foo(): a=1 return (lambda argument=global_variable: None)() >>> dis.dis(foo) 2 0 LOAD_CONST 1 (1) 3 STORE_FAST 0 (a) 3 6 LOAD_GLOBAL 0 (global_variable) 9 LOAD_CONST 2 ( at 0x00F95E30, file "", line 3>) 12 MAKE_FUNCTION 1 15 CALL_FUNCTION 0 18 RETURN_VALUE Variations on the theme show that during compilation of foo, the name is normally cemented as either a global or a local - but if it's keyword-only, then a LOAD_NAME opcode is emitted. It's the code for LOAD_NAME that looks for locals, which presumably a lambda doesn't have. ChrisA From rosuav at gmail.com Thu Nov 3 19:59:43 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Nov 2011 10:59:43 +1100 Subject: Dictionary sorting In-Reply-To: <4EB31D52.3080707@tim.thechases.com> References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <4EB31D52.3080707@tim.thechases.com> Message-ID: On Fri, Nov 4, 2011 at 10:01 AM, Tim Chase wrote: > list1 = list(d.iterkeys()) > ?list2 = list(d.iterkeys()) > ?assert list1 == list2 > There is such a guarantee in Python 2. From http://docs.python.org/library/stdtypes.html: "If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond. This allows the creation of (value, key) pairs using zip(): pairs = zip(d.values(), d.keys()). The same relationship holds for the iterkeys() and itervalues() methods: pairs = zip(d.itervalues(), d.iterkeys()) provides the same value for pairs. Another way to create the same list is pairs = [(v, k) for (k, v) in d.iteritems()]." Python 3 does things quite differently (with views), and I can't find a corresponding promise, but I expect that this would still be the case. ChrisA From ben+python at benfinney.id.au Thu Nov 3 20:06:20 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 04 Nov 2011 11:06:20 +1100 Subject: Dictionary sorting References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <8739e4n43n.fsf@benfinney.id.au> Tim Chase writes: > On 11/03/11 16:36, Terry Reedy wrote: > > CPython iterates (and prints) dict items in their arbitrary internal > > hash table order, which depends on the number and entry order of the > > items. It is a bug to depend on that arbitrary order in any way. > > Does this "never trust it" hold even for two consecutive iterations > over an unchanged dict? I didn't see anything in the docs[1] to make > such a claim, Exactly. The order of retrieval is entirely up to the implementation. There is no guarantee that the order will be the same the next time you iterate over the same dict. It is a bug to depend on a reliable order of retrieving the items. > I didn't know if what I saw was merely an implementation detail that > shouldn't be counted on. If the docs don't specify some particular observed behaviour in Python, you should consider it an implementation detail. -- \ ?Pray, v. To ask that the laws of the universe be annulled in | `\ behalf of a single petitioner confessedly unworthy.? ?Ambrose | _o__) Bierce, _The Devil's Dictionary_, 1906 | Ben Finney From drobinow at gmail.com Thu Nov 3 20:14:31 2011 From: drobinow at gmail.com (David Robinow) Date: Thu, 3 Nov 2011 20:14:31 -0400 Subject: leftover pyc files In-Reply-To: <4EB2D56C.6070208@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <4EB2D56C.6070208@gmail.com> Message-ID: On Thu, Nov 3, 2011 at 1:54 PM, Andrea Crotti wrote: > All these ideas (shell and git hooks) are nice, but unfortunately > - it's svn not git > - it's windows not *nix > - we have to remove only the ones without the corresponding *py... > -- > http://mail.python.org/mailman/listinfo/python-list > Barely tested. Change the print functions to removes. Pass the top directory as the argument. import os, sys for dirpath, dirnames, filenames in os.walk(sys.argv[1]): if dirpath.endswith("__pycache__"): thispath = dirpath[:-11] for f in filenames: if f.endswith(".pyc"): if not os.path.exists(os.path.join(thispath,f[:-1])): print("delete " + os.path.join(thispath,f)) else: for f in filenames: if f.endswith(".pyc"): if not os.path.exists(os.path.join(dirpath,f[:-1])): print("delete " + os.path.join(dirpath,f)) #os.remove(os.path.join(dirpath,f)) From anthony.hw.kong at gmail.com Thu Nov 3 20:33:04 2011 From: anthony.hw.kong at gmail.com (Anthony Kong) Date: Thu, 3 Nov 2011 17:33:04 -0700 (PDT) Subject: Design Pattern and Python: Any book recommendation? Your view? Message-ID: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Sorry to resurrect this topic. By google search the last discussion was in 2003. I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy From roy at panix.com Thu Nov 3 21:46:53 2011 From: roy at panix.com (Roy Smith) Date: Thu, 03 Nov 2011 21:46:53 -0400 Subject: Design Pattern and Python: Any book recommendation? Your view? References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: In article <6097694.446.1320366784098.JavaMail.geo-discussion-forums at prap37>, Anthony Kong wrote: > Sorry to resurrect this topic. By google search the last discussion was in > 2003. What? We're bring it up again, SO SOON!? > I would like to find out what is the current prevailing view or consensus (if > any) on the use of Design Pattern in python? > [...] > I myself pretty much subscribe to the view that the nature of python language > actually do away much of the need of the use of DP To a certain extent, I agree. I don't have a huge amount of experience in Design Patterns, but have read (years ago) the obligatory Gang Of Four book. My impression was that much of that book was about how to build sane data structures to do useful things given the uber-bondage constraints of the C++ and Java typing systems. For example, let's look at Singleton. It's a useful pattern. Here's how I would implement Singleton in Python (hand-waving a bit about the syntax details): class Printer: thePrinter = None @staticmethod def get(): if Printer.thePrinter is None: Printer.thePrinter = Printer() return thePrinter def print(self): "print some stuff" whatever That seems to cover everything Singleton needs to do. In your application code, you do: myPrinter = Printer.get() myPrinter.print(....) and you can sleep easy knowing you've got the same Printer instance every time. The GoF version for C++ is filled with minutia about private constructors and assignment operators. All that stuff is important to get right in C++, but it has nothing to do with Singleton, per se. It's just all the gunk you have to worry about to correctly implement Singleton in C++. From clp2 at rebertia.com Thu Nov 3 22:15:02 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 3 Nov 2011 19:15:02 -0700 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: On Thu, Nov 3, 2011 at 5:33 PM, Anthony Kong wrote: > Sorry to resurrect this topic. By google search the last discussion was in 2003. > > I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? I can only speak for myself, but the whole idea of design patterns is broken. The existence of nontrivial design patterns indicates language deficiencies. For more extensive corroborating discussions, see: http://www.codinghorror.com/blog/2005/06/are-design-patterns-how-languages-evolve.html http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures Python thankfully has relatively few/minor deficiencies (so long as one judges it within its dynamic language niche), so design patterns per se aren't too relevant to it. The canonical Python-specific design pattern is Borg (http://code.activestate.com/recipes/66531-singleton-we-dont-need-no-stinkin-singleton-the-bo/ ) [a variation on Singleton], and nowadays it (like its parent, Singleton) is considered to be of dubious utility/advisability. > I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. The closest alternative would be some publication that gave examples of using some of Python's fancier, higher-level features, such as metaclasses and context managers. I haven't been in the market for such a book, so I have no good recommendations to give. Closest I could suggest would be the Language Reference (http://docs.python.org/reference/ ) and relevant PEPs (http://www.python.org/dev/peps/ ; they tend to include examples by way of motivating use-cases). > I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy I am glad you agree. Cheers, Chris -- http://rebertia.com From macmanes at gmail.com Thu Nov 3 22:55:29 2011 From: macmanes at gmail.com (Matt) Date: Thu, 3 Nov 2011 19:55:29 -0700 (PDT) Subject: match, concatenate based on filename Message-ID: <31568428.553.1320375329695.JavaMail.geo-discussion-forums@prgt40> Hi All, I am trying to concatenate several hundred files based on their filename.. Filenames are like this: Q1.HOMOblast.fasta Q1.mus.blast.fasta Q1.query.fasta Q2.HOMOblast.fasta Q2.mus.blast.fasta Q2.query.fasta ... Q1223.HOMOblast.fasta Q1223.mus.blast.fasta Q1223.query.fasta All the Q1's should be concatenated together in a single file = Q1.concat.fasta.. Q2's go together, Q3's and so on... I envision something like for file in os.listdir("/home/matthew/Desktop/pero.ngs/fasta/final/"): if file.startswith("Q%i"): concatenate... But I can't figure out how to iterate this process over Q-numbers 1-1223 Any help appreciate. From pmaupin at gmail.com Thu Nov 3 23:08:42 2011 From: pmaupin at gmail.com (Patrick Maupin) Date: Thu, 3 Nov 2011 20:08:42 -0700 (PDT) Subject: match, concatenate based on filename References: <31568428.553.1320375329695.JavaMail.geo-discussion-forums@prgt40> Message-ID: <483db563-19e7-4219-8854-9a65a8c4a88d@v5g2000vbh.googlegroups.com> On Nov 3, 9:55?pm, Matt wrote: > Hi All, > > I am trying to concatenate several hundred files based on their filename.. ?Filenames are like this: > > Q1.HOMOblast.fasta > Q1.mus.blast.fasta > Q1.query.fasta > Q2.HOMOblast.fasta > Q2.mus.blast.fasta > Q2.query.fasta > ... > Q1223.HOMOblast.fasta > Q1223.mus.blast.fasta > Q1223.query.fasta > > All the Q1's should be concatenated together in a single file = Q1.concat.fasta.. Q2's go together, Q3's and so on... > > I envision something like > > for file in os.listdir("/home/matthew/Desktop/pero.ngs/fasta/final/"): > ? ? ? ? if file.startswith("Q%i"): > ? ? ? ? ? ?concatenate... > > But I can't figure out how to iterate this process over Q-numbers 1-1223 > > Any help appreciate. I haven't tested this, so may have a typo or something, but it's often much cleaner to gather your information, massage it, and then use, than it is to gather it and use it in one go. from collections import defaultdict filedict = defaultdict(list) for fname in sorted(os.listdir(mydir)): if fname.startswith('Q') and '.' in fname: filedict[fname[:fname.find('.')]].append(fname) for prefix, fnames in filedict.iteritems(): #print prefix, fnames concatenate... HTH, Pat From gordon at panix.com Thu Nov 3 23:17:34 2011 From: gordon at panix.com (John Gordon) Date: Fri, 4 Nov 2011 03:17:34 +0000 (UTC) Subject: match, concatenate based on filename References: <31568428.553.1320375329695.JavaMail.geo-discussion-forums@prgt40> Message-ID: In <31568428.553.1320375329695.JavaMail.geo-discussion-forums at prgt40> Matt writes: > But I can't figure out how to iterate this process over Q-numbers 1-1223 for i in xrange(1, 1224): Q = "Q%d" % i file1 = "%s.HOMOblast.fasta" % Q file2 = "%s.mus.blast.fasta" % Q file3 = "%s.query.fasta" % Q target = "%s.concat.fasta" % Q concatenate(file1, file2, file3, target) Assuming that there are exactly three files to be concatenated for each value of i. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From dihedral88888 at googlemail.com Fri Nov 4 02:24:03 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 3 Nov 2011 23:24:03 -0700 (PDT) Subject: Database access benchmarks for use in web-frameworks - How does Python compare? In-Reply-To: References: Message-ID: <292753.379.1320387843748.JavaMail.geo-discussion-forums@prev11> I suggest that the use of dynamical page forwarding to different severs which run the same software package. This can be done in python! From dihedral88888 at googlemail.com Fri Nov 4 02:24:03 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 3 Nov 2011 23:24:03 -0700 (PDT) Subject: Database access benchmarks for use in web-frameworks - How does Python compare? In-Reply-To: References: Message-ID: <292753.379.1320387843748.JavaMail.geo-discussion-forums@prev11> I suggest that the use of dynamical page forwarding to different severs which run the same software package. This can be done in python! From steve+comp.lang.python at pearwood.info Fri Nov 4 02:48:35 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Nov 2011 06:48:35 GMT Subject: leftover pyc files References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <4eb38ac2$0$29968$c3e8da3$5496439d@news.astraweb.com> On Thu, 03 Nov 2011 17:54:52 +0000, Andrea Crotti wrote: > All these ideas (shell and git hooks) are nice, but unfortunately - it's > svn not git > - it's windows not *nix > - we have to remove only the ones without the corresponding *py... Does it matter? The other .pyc files will be recreated when they are next needed. Just nuke all the .pyc files and be done with it. Or if you can't bear having to wait for Python to compile them as needed, you can force compilation by running your test suite (you do have a test suite, don't you?) or by using the compileall.py script. python -m compileall some_directory should do the trick. -- Steven From nobody at nowhere.com Fri Nov 4 04:26:25 2011 From: nobody at nowhere.com (Nobody) Date: Fri, 04 Nov 2011 08:26:25 +0000 Subject: ctypes: catch system exit from C library References: <4877ad6b-1a35-4561-bed7-b143c9d8a3f2@r7g2000vbg.googlegroups.com> <10eao8-84g.ln1@satorlaser.homedns.org> Message-ID: On Thu, 03 Nov 2011 14:16:50 +0000, Grant Edwards wrote: >>> in my python application I am calling functions from a C library via >>> `ctypes` interface. Some fns from that C library calls `exit()` on >>> error. >> Just curious, which library is that? I'm reasonably sure that he's talking about the GRASS libraries. In which, the standard error-handling mechanism is to call G_fatal_error(), which ultimately calls exit(). AKA the "samurai principle": return victorious, or don't return at all. [FWIW, re-writing everying in C++ and using exceptions is not a realistic option]. > And who should we have thrashed and pilloried for writing it that way? No-one. It's a perfectly rational design given the context. GRASS consists of ~350 command-line programs ("modules") in the traditional Unix style (read command-line arguments, do processing, terminate). The libraries exist to support the creation of such modules, and are fit for that particular purpose. Handling errors by having status codes which propagate up the call chain would add a significant amount of code. More importantly, it would push the burden of handling errors onto the authors of the various modules (and historical evidence suggests that checking for (let alone handling) errors is unlikely to occur). The mechanism works fine, so long as you don't try to use the libraries for purposes for which they weren't designed (e.g. long-running programs such as interactive applications or servers). As the story goes ... Patient: "Doctor, when I do this ... it hurts" Doctor: "Well don't do it then!" From stefan_ml at behnel.de Fri Nov 4 04:34:33 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 04 Nov 2011 09:34:33 +0100 Subject: Database access benchmarks for use in web-frameworks - How does Python compare? In-Reply-To: References: Message-ID: Alec Taylor, 03.11.2011 11:19: > I'm building a large e-commerce site, and it is very important that > what I write can: > - Handle larger server load > - Deliver pages quickly > - Make transactions quickly Those are pretty broad requirements. If a framework can satisfy them or not depends more on how you set it up and deploy it (e.g. how many servers you run, what kind of load balancing you use, how you serve your static content, etc.) than the actual framework you choose, I'd say. > as well as have a small development time (i.e. pre-built modules for > e-commerce are available, and extendible). "e-commerce" is also a very broad term. But I'd expect that any of the recent web frameworks (certainly including Django) will satisfy your needs in some way. > Are there recent accessible statistics available, comparing these > metrics across the most popular web-frameworks? (i.e. Symfony, DJango, > Rails, ASP.NET&etc) Not that I know of. Stefan From tartley at tartley.com Fri Nov 4 05:27:58 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Fri, 4 Nov 2011 02:27:58 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> I like to install a Bash shell of some kind on windows boxes I work on, specifically so I can use shell commands like this, just like on any other operating system. Cywin works just fine for this. svn also has hooks, but sadly not a checkout hook: http://svnbook.red-bean.com/en/1.1/ch05s02.html I guess you could write your own two-line wrapper script which does the checkout and then deletes the pyc files. I don't understand why deleting only some pyc files is important. Can't you just delete them all and let Python re generate the ones you need? I once saw someone create the longest python file they could to see how long generating pyc files takes, and it is very very quick indeed. A human could not notice the delay even for the largest of projects. Finally, someone asked about skipping .svn dirs: find has a '-prune' option, you can read about it on the manpage. From tartley at tartley.com Fri Nov 4 05:27:58 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Fri, 4 Nov 2011 02:27:58 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> I like to install a Bash shell of some kind on windows boxes I work on, specifically so I can use shell commands like this, just like on any other operating system. Cywin works just fine for this. svn also has hooks, but sadly not a checkout hook: http://svnbook.red-bean.com/en/1.1/ch05s02.html I guess you could write your own two-line wrapper script which does the checkout and then deletes the pyc files. I don't understand why deleting only some pyc files is important. Can't you just delete them all and let Python re generate the ones you need? I once saw someone create the longest python file they could to see how long generating pyc files takes, and it is very very quick indeed. A human could not notice the delay even for the largest of projects. Finally, someone asked about skipping .svn dirs: find has a '-prune' option, you can read about it on the manpage. From tartley at tartley.com Fri Nov 4 05:29:49 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Fri, 4 Nov 2011 02:29:49 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <8460773.112.1320398989273.JavaMail.geo-discussion-forums@yqie15> Apologies for all my messasges appearing twice. I'm using google groups web ui and have no idea why it's doing that. I'll stop using it. From ulrich.eckhardt at dominolaser.com Fri Nov 4 05:49:07 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 04 Nov 2011 10:49:07 +0100 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: Am 04.11.2011 01:33, schrieb Anthony Kong: > I would like to find out what is the current prevailing view or > consensus (if any) on the use of Design Pattern in python? My consensus with myself is that design patterns are language-agnostic. If I write "class Foo serves as view and controller for class Bar in a model-view-controller (MVC) design", everybody that knows MVC has immediately a very high-level understanding of how those two classes interact. > I am doing some 'fact-finding' in this area on request of my > colleagues. Some of them want to buy a book or two in this subject > area. Hopefully the newsgroup can give me some book recommendation > and insight in this topic. The Gang of Four book on design patterns is one you will probably come across, and there are many that refer to it. > I myself pretty much subscribe to the view that the nature of python > language actually do away much of the need of the use of DP, but it > is just a personal view. It comes form my experience of migrating > from webware4py (webframework based on J2EE/servlet idea) to > cherrypy "webframework based on J2EE/servlet" - apart from J2EE being a specific implementation, this also describes a design pattern, i.e. one where (forgive me if I'm slightly off, this is not actually my field of programming) the UI is browser-based and the program logic runs on a server. Instead of explaining it in many words, you reused the known design pattern to describe it, and that is also IMHO what design patterns are about. They serve as a tool to make software that follows known patterns, so that people that know the pattern will recognize them and then get easier understanding. It also serves as tool when talking about things, you don't have to explain the design when you can refer to a pattern. In that sense, I fully disagree that design patterns are obsolete in Python. However, there are other patterns that are more language-specific, like e.g. RAII in C++, so if you rather meant those, I would agree with you. Cheers! Uli From hniksic at xemacs.org Fri Nov 4 06:20:06 2011 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Fri, 04 Nov 2011 11:20:06 +0100 Subject: Dictionary sorting References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <8739e4n43n.fsf@benfinney.id.au> Message-ID: <87d3d8mbop.fsf@xemacs.org> Ben Finney writes: > Tim Chase writes: > >> On 11/03/11 16:36, Terry Reedy wrote: >> > CPython iterates (and prints) dict items in their arbitrary internal >> > hash table order, which depends on the number and entry order of the >> > items. It is a bug to depend on that arbitrary order in any way. >> >> Does this "never trust it" hold even for two consecutive iterations >> over an unchanged dict? I didn't see anything in the docs[1] to make >> such a claim, > > Exactly. This is false. The docs say: If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond. This allows the creation of (value, key) pairs using zip(): pairs = zip(d.values(), d.keys()). (http://docs.python.org/library/stdtypes.html#mapping-types-dict) > The order of retrieval is entirely up to the implementation. This part is still true, but the order won't change behind your back if you're not touching the dict. From andrea.crotti.0 at gmail.com Fri Nov 4 06:34:11 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 04 Nov 2011 10:34:11 +0000 Subject: leftover pyc files In-Reply-To: <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> Message-ID: <4EB3BFA3.4090802@gmail.com> On 11/04/2011 09:27 AM, Jonathan Hartley wrote: > I like to install a Bash shell of some kind on windows boxes I work on, specifically so I can use shell commands like this, just like on any other operating system. Cywin works just fine for this. > > svn also has hooks, but sadly not a checkout hook: > http://svnbook.red-bean.com/en/1.1/ch05s02.html > I guess you could write your own two-line wrapper script which does the checkout and then deletes the pyc files. > > I don't understand why deleting only some pyc files is important. Can't you just delete them all and let Python re generate the ones you need? I once saw someone create the longest python file they could to see how long generating pyc files takes, and it is very very quick indeed. A human could not notice the delay even for the largest of projects. > > Finally, someone asked about skipping .svn dirs: find has a '-prune' option, you can read about it on the manpa Uhm yes it makes sense also to just remove all of them, I don't know why it was done like this but probably for "performance" reasons. I will try both ways, but I would definitively avoid the shell scripting, because it's mainly windows but it has to be multi-platform.. From rosuav at gmail.com Fri Nov 4 06:39:14 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Nov 2011 21:39:14 +1100 Subject: leftover pyc files In-Reply-To: <4EB3BFA3.4090802@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> Message-ID: On Fri, Nov 4, 2011 at 9:34 PM, Andrea Crotti wrote: > Uhm yes it makes sense also to just remove all of them, I don't know why it > was done like this but > probably for "performance" reasons. > > I will try both ways, but I would definitively avoid the shell scripting, > because it's mainly windows > but it has to be multi-platform.. If you're removing them all, you don't need to use a powerful shell. Much much easier! Just recursively del *.pyc and you're done. ChrisA From joshua.landau.ws at gmail.com Fri Nov 4 06:49:39 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Fri, 4 Nov 2011 10:49:39 +0000 Subject: SystemError when defining In-Reply-To: References: Message-ID: On 11/3/11, Chris Angelico wrote: > Fascinating! Awesome to know! > I did some introspection with this: > *snip* > > Variations on the theme show that during compilation of foo, the name > is normally cemented as either a global or a local - but if it's > keyword-only, then a LOAD_NAME opcode is emitted. It's the code for > LOAD_NAME that looks for locals, which presumably a lambda doesn't > have. What is the LOAD_NAME for? The non-keyword default doesn't seem to need it. From andrea.crotti.0 at gmail.com Fri Nov 4 07:00:50 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 04 Nov 2011 11:00:50 +0000 Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> Message-ID: <4EB3C5E2.3020702@gmail.com> On 11/04/2011 10:39 AM, Chris Angelico wrote: > If you're removing them all, you don't need to use a powerful shell. > Much much easier! Just recursively del *.pyc and you're done. ChrisA Discussing with the guy that did it I think it's actually a good idea instead, because removing them *all* means. - remove a few thousand files every time where maybe 0 would be removed otherwise - recompile the same thousand of files It might not be so relevant but for 10 lines of code more I guess it's fine.. From lbrt Fri Nov 4 07:48:02 2011 From: lbrt (lbrt) Date: 04 Nov 2011 11:48:02 GMT Subject: python-based downloader (youtube-dl) missing critical feature ... Message-ID: <1320407282.243739@nntp.aceinnovative.com> python-based youtube-dl ~ http://rg3.github.com/youtube-dl/ ~ is sorely missing a flag in order to indicate the maximum file length of the data feed it would download (well, unless, for some reason, it is considered a "feature"). ~ I wonder what developers were thinking about when they came up this nice piece of code. If you actually look in the code ~ ... data = urllib2.urlopen(basic_request) content_length = data.info()['Content-Length'] ... ~ you will see they get the content length of the actual data feed and they also print the progress status based on the content length ~ Implementing an if statement a la: ~ max_indicated_content_length = self.params.get('max_content_length', None); ~ if( content_length > max_indicated_content_length ){ [do not download, just report "data feed too large"] } else{ [do] } ~ shouldn't be hard at all ~ youtube-dl is under the Creative Commons License copyrighted by 2006-2011 Ricardo Garcia Gonzalez and maintained by him and a group of python developers ~ They are the ones keeping a mental map of that project. It would be a plus if they implement this feature, but anyother python developer can implemented (please, let me know if/when you do) ~ lbrtchx From ben+python at benfinney.id.au Fri Nov 4 08:19:25 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 04 Nov 2011 23:19:25 +1100 Subject: Dictionary sorting References: <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> <8739e4n43n.fsf@benfinney.id.au> <87d3d8mbop.fsf@xemacs.org> Message-ID: <87y5vwkrle.fsf@benfinney.id.au> Hrvoje Niksic writes: > Ben Finney writes: > > > Tim Chase writes: > >> Does this "never trust it" hold even for two consecutive iterations > >> over an unchanged dict? I didn't see anything in the docs[1] to make > >> such a claim, > > > > Exactly. > > This is false. The docs say: > > If items(), keys(), values(), iteritems(), iterkeys(), and > itervalues() are called with no intervening modifications to the > dictionary, the lists will directly correspond. This allows the > creation of (value, key) pairs using zip(): pairs = zip(d.values(), > d.keys()). > > (http://docs.python.org/library/stdtypes.html#mapping-types-dict) Thank you for this correction. -- \ ?Firmness in decision is often merely a form of stupidity. It | `\ indicates an inability to think the same thing out twice.? | _o__) ?Henry L. Mencken | Ben Finney From johnroth1 at gmail.com Fri Nov 4 08:28:23 2011 From: johnroth1 at gmail.com (John Roth) Date: Fri, 4 Nov 2011 05:28:23 -0700 (PDT) Subject: Design Pattern and Python: Any book recommendation? Your view? References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: <0531d3c1-61c6-41f6-a74a-fe3d24a731fb@x2g2000vbd.googlegroups.com> On Nov 3, 6:33?pm, Anthony Kong wrote: > Sorry to resurrect this topic. By google search the last discussion was in 2003. > > I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? > > I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. > > I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy I don't know of a book on design patterns in Python. I've got a couple of observations. The first is that if you use TDD (Test Driven Development) and refactor relentlessly to remove duplication, most of the basic design patterns will emerge naturally from the code as you work. The second is that, as far as I'm concerned, the utility of a design patterns book is in the discussion of what the pattern is good for, and what it isn't good for. That is, as another poster says, language agnostic. John Roth From steve+comp.lang.python at pearwood.info Fri Nov 4 08:32:08 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Nov 2011 12:32:08 GMT Subject: python-based downloader (youtube-dl) missing critical feature ... References: <1320407282.243739@nntp.aceinnovative.com> Message-ID: <4eb3db48$0$29968$c3e8da3$5496439d@news.astraweb.com> On Fri, 04 Nov 2011 11:48:02 +0000, lbrt chx _ gemale wrote: > python-based youtube-dl > ~ > http://rg3.github.com/youtube-dl/ > ~ > is sorely missing a flag in order to indicate the maximum file length > of the data feed it would download (well, unless, for some reason, it > is considered a "feature"). If you are making a feature request, you should make it directly to the project developer, and not here. Since you consider that feature "shouldn't be hard at all" (your words), perhaps you should consider providing a patch? Don't forget the documentation and tests for it. Or did you mean "it shouldn't be hard for me, if somebody else does the work"? > ~ > I wonder what developers were thinking about when they came up this > nice piece of code. If you actually look in the code [...] Lbrtchx, it's possible that English is not your natural language. Please be aware that, in English, "what they were thinking..." is often used sarcastically, as in "they weren't actually thinking". Particularly following your use of scare quotes around "feature". (Even more so for the similar form, "what were they thinking?".) It's probably not going to help you get a feature added to the project if you imply (even by accident) that lack of that feature is an indication that the developer wasn't thinking. -- Steven From goon12 at gmail.com Fri Nov 4 08:41:00 2011 From: goon12 at gmail.com (Joe Riopel) Date: Fri, 4 Nov 2011 08:41:00 -0400 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <0531d3c1-61c6-41f6-a74a-fe3d24a731fb@x2g2000vbd.googlegroups.com> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> <0531d3c1-61c6-41f6-a74a-fe3d24a731fb@x2g2000vbd.googlegroups.com> Message-ID: On Fri, Nov 4, 2011 at 8:28 AM, John Roth wrote: > The first is that if you use TDD (Test Driven Development) and > refactor relentlessly to remove duplication, most of the basic design > patterns will emerge naturally from the code as you work. I agree, and there is a pretty good series of articles on developerWorks that covers this: http://www.ibm.com/developerworks/java/library/j-eaed2/index.html The author used Java in this series, but as Ulrich mentioned, I feel that design patterns (and emergent design) are "language-agnostic.". From phihag at phihag.de Fri Nov 4 08:45:23 2011 From: phihag at phihag.de (Philipp Hagemeister) Date: Fri, 04 Nov 2011 13:45:23 +0100 Subject: python-based downloader (youtube-dl) missing critical feature ... In-Reply-To: <1320407282.243739@nntp.aceinnovative.com> References: <1320407282.243739@nntp.aceinnovative.com> Message-ID: <4EB3DE63.4050900@phihag.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 As already said, you should file your request at https://github.com/rg3/youtube-dl/issue , not here. A few things to note: * Not all sites necessarily send the Content-Length header. * RTMP URLs would have to be treated differently * Sending a Range header might allow for a better implementation. Why do you want to restrict the filesize of the download in the first place? I can't see a use case, but that doesn't mean there isn't one. Due to me not having lots of time at the moment, your best chance to get any youtube-dl feature implemented is providing a patch (in form of a github pull-request, if possible). - -- Philipp (youtube-dl developer) lbrt at mail.python.org wrote: > python-based youtube-dl > ~ > http://rg3.github.com/youtube-dl/ > ~ > is sorely missing a flag in order to indicate the maximum file length of the data feed it would download (well, unless, for some reason, it is considered a "feature"). > ~ > I wonder what developers were thinking about when they came up this nice piece of code. If you actually look in the code > ~ > ... > data = urllib2.urlopen(basic_request) > content_length = data.info()['Content-Length'] > ... > ~ > you will see they get the content length of the actual data feed and they also print the progress status based on the content length > ~ > Implementing an if statement a la: > ~ > max_indicated_content_length = self.params.get('max_content_length', None); > ~ > if( content_length > max_indicated_content_length ){ [do not download, just report "data feed too large"] } > else{ [do] } > ~ > shouldn't be hard at all > ~ > youtube-dl is under the Creative Commons License copyrighted by 2006-2011 Ricardo Garcia Gonzalez and maintained by him and a group of python developers > ~ > They are the ones keeping a mental map of that project. It would be a plus if they implement this feature, but anyother python developer can implemented (please, let me know if/when you do) > ~ > lbrtchx -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEAREKAAYFAk6z3mMACgkQ9eq1gvr7CFyr1wCgpqf8xuORDC4LBVY8WFmtAufG k+AAoIX+mXa7SGLULP2M67IQ34sBgk1o =duyH -----END PGP SIGNATURE----- From andrea.crotti.0 at gmail.com Fri Nov 4 08:46:10 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 04 Nov 2011 12:46:10 +0000 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> Message-ID: <4EB3DE92.7040108@gmail.com> On 11/04/2011 12:33 AM, Anthony Kong wrote: > Sorry to resurrect this topic. By google search the last discussion was in 2003. > > I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? > > I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. > > I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy > > > Well this book is work in progress https://bitbucket.org/BruceEckel/python-3-patterns-idioms/src but it actually looks very interesting From bkamrani at gmail.com Fri Nov 4 09:17:16 2011 From: bkamrani at gmail.com (Behnam) Date: Fri, 4 Nov 2011 06:17:16 -0700 (PDT) Subject: Python advanced course (preferably in NA) References: <4EB3051C.2010202@jpl.nasa.gov> Message-ID: <10127b29-23c5-4929-a20c-8a89ce6e385d@t8g2000yql.googlegroups.com> This was great. Thank you all! /Behnam On Nov 3, 5:18?pm, Catherine Moroney wrote: > I've taken twoPythonclasses from David Beazley and can second > Eric's recommendation. ?The "advanced" class is reallyadvanced > and goes into some pretty mind-blowing stuff. ?The class comes with > lots of problems and solutions, and a book of all the slides which are > a great reference. ?Well worth the time and money! > > Catherine > > > > > > > > Eric Snow wrote: > > On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: > >> Anybody is aware of anyadvancedcourseinPythonpreferably in north > >> america? > > >> I've been partly coding inPythonfor couple of years now and have > >> used PyQt. What I'd like to learn more is a kind of advance OOP in > >>python. Any idea? > > > While I don't know specifically, check out the following link (from > > thePythonsite): > > >http://wiki.python.org/moin/PythonTraining > > > I have taken a class each (PyCon tutorial) from Raymond Hettinger, > > David Beazley, and Brian Jones, and found each of them to be > > outstanding courses. ?Only David is listed on that page to which I > > linked, though I know Raymond does courses at least from time to time. > > ?I've also heard a talk from Wesley Chun and found him to be > > fantastic. > > > -eric > > >> BTW, I'm not a computer engineer and have mechanical background. > > >> Thanks in advance! > >> -- > >>http://mail.python.org/mailman/listinfo/python-list From dihedral88888 at googlemail.com Fri Nov 4 09:31:32 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 4 Nov 2011 06:31:32 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> Message-ID: <24728053.972.1320413492633.JavaMail.geo-discussion-forums@prog16> Uhn, thanks for the easy way Just delete all *.pyc recursively. spend another 5-20 minutes to recompile all to get everything sync.. That is trivial! From dihedral88888 at googlemail.com Fri Nov 4 09:31:32 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 4 Nov 2011 06:31:32 -0700 (PDT) Subject: leftover pyc files In-Reply-To: References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> Message-ID: <24728053.972.1320413492633.JavaMail.geo-discussion-forums@prog16> Uhn, thanks for the easy way Just delete all *.pyc recursively. spend another 5-20 minutes to recompile all to get everything sync.. That is trivial! From jeanmichel at sequans.com Fri Nov 4 09:31:42 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 04 Nov 2011 14:31:42 +0100 Subject: python-based downloader (youtube-dl) missing critical feature ... In-Reply-To: <4eb3db48$0$29968$c3e8da3$5496439d@news.astraweb.com> References: <1320407282.243739@nntp.aceinnovative.com> <4eb3db48$0$29968$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4EB3E93E.50500@sequans.com> Steven D'Aprano wrote: > On Fri, 04 Nov 2011 11:48:02 +0000, lbrt chx _ gemale wrote: > > >> python-based youtube-dl >> ~ >> http://rg3.github.com/youtube-dl/ >> ~ >> is sorely missing a flag in order to indicate the maximum file length >> of the data feed it would download (well, unless, for some reason, it >> is considered a "feature"). >> > > If you are making a feature request, you should make it directly to the > project developer, and not here. > > Since you consider that feature "shouldn't be hard at all" (your words), > perhaps you should consider providing a patch? Don't forget the > documentation and tests for it. > > Or did you mean "it shouldn't be hard for me, if somebody else does the > work"? > > > >> ~ >> I wonder what developers were thinking about when they came up this >> nice piece of code. If you actually look in the code >> > [...] > > Lbrtchx, it's possible that English is not your natural language. Please > be aware that, in English, "what they were thinking..." is often used > sarcastically, as in "they weren't actually thinking". Particularly > following your use of scare quotes around "feature". > > (Even more so for the similar form, "what were they thinking?".) > > It's probably not going to help you get a feature added to the project if > you imply (even by accident) that lack of that feature is an indication > that the developer wasn't thinking. > > > Maybe Lbrtchx is one of the Sheldon Cooper's nicknames :o) JM PS : I have the feeling that my nerdy reference will fall flat... From slehar at gmail.com Fri Nov 4 11:10:58 2011 From: slehar at gmail.com (Steven Lehar) Date: Fri, 4 Nov 2011 11:10:58 -0400 Subject: Line continuation issue\ Message-ID: Is this the right place to propose language extensions? My Python code keeps expanding rightwards, it is difficult to keep it contained within reasonable limits. But the standard line continuation \ is positively anti-Pythonic because an *invisible* white space between \ and [CR] will render it useless. How about a new Python symbol, maybe \\ that CAN have following whitespace which is ignored, so that seeing a \\ in the code forces it to continue on the next line. Has this issue been discussed already? slehar -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Fri Nov 4 11:38:32 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 04 Nov 2011 16:38:32 +0100 Subject: Line continuation issue\ References: Message-ID: Steven Lehar wrote: > Is this the right place to propose language extensions? > > My Python code keeps expanding rightwards, it is difficult to keep it > contained within reasonable limits. You should attack this by breaking large expressions into smaller ones and factoring out some of your code into helper functions. > But the standard line continuation \ > is positively anti-Pythonic because an *invisible* white space between \ > and [CR] will render it useless. Useless? You get a SyntaxError, remove the offending whitespace, and that's it. > How about a new Python symbol, maybe \\ that CAN have following whitespace > which is ignored, so that seeing a \\ in the code forces it to continue on > the next line. Did you know that there already is a pythonic alternative that works well in most cases? An open (, [, or { will allow you to continue on the next line, e. g. items = [(foo(item), bar(item)) for row in rows for item in row if baz( alpha=1, beta=item)] no strings attached. From rosuav at gmail.com Fri Nov 4 11:42:11 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Nov 2011 02:42:11 +1100 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: On Sat, Nov 5, 2011 at 2:10 AM, Steven Lehar wrote: > But the standard line continuation \ > is positively anti-Pythonic because an *invisible* white space between \ and > [CR] will render it useless. How's it anti-Pythonic for invisible whitespace differences to be significant? ChrisA *grinning, running, and ducking* From slehar at gmail.com Fri Nov 4 11:53:57 2011 From: slehar at gmail.com (Steven Lehar) Date: Fri, 4 Nov 2011 11:53:57 -0400 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: > How's it anti-Pythonic for invisible whitespace differences to be significant? A central idea of Python was to replace {curly;braces{and;parentheses;}}, which are easily overlooked by the programmer, and use WHITESPACE instead, something that is clearly visible to the programmer, as the defining syntax. Make what is visible to humans significant to the interpreter. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Fri Nov 4 11:56:19 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Nov 2011 02:56:19 +1100 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: On Sat, Nov 5, 2011 at 2:53 AM, Steven Lehar wrote: > > > > How's it anti-Pythonic for invisible whitespace differences to be significant? > A central idea of Python was to replace {curly;braces{and;parentheses;}}, which are easily overlooked by the programmer, and use WHITESPACE instead, something that is clearly visible to the programmer, as the defining syntax. Make what is visible to humans significant to the interpreter. > I refer more to the problems that perpetually plagued Python programmers regarding tabs vs spaces (which I think was finally closed off only in Python 3). ChrisA From k.sahithi2862 at gmail.com Fri Nov 4 12:50:52 2011 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Fri, 4 Nov 2011 09:50:52 -0700 (PDT) Subject: HOT HOT HOT Message-ID: ` FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR ONLY HOT GUYS SEE THIS TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html From lbrt Fri Nov 4 13:37:28 2011 From: lbrt (lbrt) Date: 04 Nov 2011 17:37:28 GMT Subject: short reading materials about anthropological, universal themes for students with no reading habit ... In-Reply-To: <1320407282.243739@nntp.aceinnovative.com> Message-ID: <1320428248.15512@nntp.aceinnovative.com> > A few things to note: > * Not all sites necessarily send the Content-Length header. > * RTMP URLs would have to be treated differently ~ No some don't, but at least for the ones that do (like youtube) it would be a useful feature. The Content-Length header is used in the code anyway ~ > * Sending a Range header might allow for a better implementation. ~ Yes, it would ~ > Why do you want to restrict the filesize of the download in the first > place? I can't see a use case, but that doesn't mean there isn't one. ~ OK, I see your point. Say, you have a list of youtube urls, which feeds you want to download using a script or a playlist someone put together, but you don't want to download files that are too large, which may not be of any use to you. For example, I teach and it doesn't make any sense to use a full movie as part of a class set. So I would like for youtube-dl to let me know which files are larger than a given size (and possibly save them in a file) for me to check the files first My languages are ANSI C, C++ and java. When I was young and silly would blab girls just because they crossed my way, now I don't like to even look into anything that I don't want to invest my time in on an ongoing basis. I would let people that code python and have a mental map of that code base do it themselves lbrtchx From joshua.landau.ws at gmail.com Fri Nov 4 15:10:00 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Fri, 4 Nov 2011 19:10:00 +0000 Subject: SystemError when defining In-Reply-To: References: Message-ID: > > >>> def x(nonlocal_var): ... def y(): ... z = lambda *, keyword_only=nonlocal_var: None ... return y ... >>> x(None)() Traceback (most recent call last): File "", line 1, in File "", line 3, in y SystemError: no locals when loading 'nonlocal_var' >>> dis.dis(x) 2 0 LOAD_CONST 1 ( 0x7f1fa5d57030, file "", line 2>) 3 MAKE_FUNCTION 0 6 STORE_FAST 1 (y) > 4 9 LOAD_FAST 1 (y) 12 RETURN_VALUE >>> dis.dis(x(None)) 3 0 LOAD_CONST 1 ('keyword_only') 3 LOAD_NAME 0 (nonlocal_var) 6 LOAD_CONST 2 ( at > 0x7f1fa626aa48, file "", line 3>) 9 MAKE_FUNCTION 256 12 STORE_FAST 0 (z) 15 LOAD_CONST 0 (None) 18 RETURN_VALUE Conclusion: When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython is unable to access *either the free variables or global scope* and raises SystemError. This is cool, though: > >>> def y(): > ... global_var > ... z = lambda *, keyword_only=global_var: None > ... > >>> y() > >>> >>> dis.dis(y) > 2 0 LOAD_GLOBAL 0 (global_var) > 3 POP_TOP > 3 4 LOAD_CONST 1 ('keyword_only') > 7 LOAD_GLOBAL 0 (global_var) > 10 LOAD_CONST 2 ( at > 0x7f1fa5d4fd78, file "", line 3>) > 13 MAKE_FUNCTION 256 > 16 STORE_FAST 0 (z) > 19 LOAD_CONST 0 (None) > 22 RETURN_VALUE >>> def x(nonlocal_var): > ... def y(): > ... nonlocal_var > ... z = lambda *, keyword_only=nonlocal_var: None > ... return y > ... > >>> x(None)() > >>> What is happening is that LOAD_NAME is trying to access the value 'nonlocal_var' from y.__code__.co_freevars, but compilation doesn't push it there from the lambda, so adding a call to it causes it to work. The change of opcode implies that locality is decided before the opcodes are made, and so not being pushed to co_freevars changes the opcode. AKA: *When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython doesn't push the name to co_freevars.* Now - where shall I report this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Fri Nov 4 15:45:26 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 04 Nov 2011 15:45:26 -0400 Subject: Design Pattern and Python: Any book recommendation? Your view? In-Reply-To: <4EB3DE92.7040108@gmail.com> References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> <4EB3DE92.7040108@gmail.com> Message-ID: On 11/4/2011 8:46 AM, Andrea Crotti wrote: > Well this book is work in progress Though not touched since May 2009 > https://bitbucket.org/BruceEckel/python-3-patterns-idioms/src > > but it actually looks very interesting The slightly older .pdf version is a bit bizarre as parts of both text and code are only half-translated from Java. The testing chapter contains obviously untested code like TestDemo.py [sic] with Java lines like id = ++objCounter # this is supposed to increment objCounter TestDemo test1 = TestDemo('test1') # I presume this declares test1 as a TestDemo object and text with Javaisms like *static*, *public*, *private*, *protected*, and *friendly* and "a little review of Java packages". Perhaps the later sections are more useful. -- Terry Jan Reedy From tjreedy at udel.edu Fri Nov 4 16:01:14 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 04 Nov 2011 16:01:14 -0400 Subject: leftover pyc files In-Reply-To: <4EB3C5E2.3020702@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> <4EB3C5E2.3020702@gmail.com> Message-ID: For those not aware, the compiled file caching and import system was changed for 3.2. Given test.py, the compiled file is no longer test.pyc, in the same directory, but (for cpython32) __pycache__/test.cpython-32.pyc. Given the statement 'import test', the __pycache__ directory is only searched (for the name given above) after finding test.py. So if 'test.py' is deleted or renamed to 'mytest.py', an unchanged 'import test' will *fail* instead of importing the obsolete .pyc file. So there is no longer a functional reason to delete such obsolete files. However, the OP is stuck with 2.5. -- Terry Jan Reedy From tjreedy at udel.edu Fri Nov 4 16:06:05 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 04 Nov 2011 16:06:05 -0400 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: On 11/4/2011 11:10 AM, Steven Lehar wrote: > Is this the right place to propose language extensions? Yes, especially for beginners not familiar with previous discussions. > > My Python code keeps expanding rightwards, it is difficult to keep it > contained within reasonable limits. But the standard line continuation \ > is positively anti-Pythonic because an *invisible* white space between \ > and [CR] will render it useless. > > How about a new Python symbol, maybe \\ that CAN have following > whitespace which is ignored, so that seeing a \\ in the code forces it > to continue on the next line. > > Has this issue been discussed already? Yes ;=) Peter already gave the standard answers. -- Terry Jan Reedy From nad at acm.org Fri Nov 4 16:11:14 2011 From: nad at acm.org (Ned Deily) Date: Fri, 04 Nov 2011 13:11:14 -0700 Subject: Design Pattern and Python: Any book recommendation? Your view? References: <6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37> <4EB3DE92.7040108@gmail.com> Message-ID: Search for presentations and videos by Alex Martelli. He's the goto (so to speak) person on Python design patterns. Here, for instance: http://code.google.com/edu/languages/#_python_patterns -- Ned Deily, nad at acm.org From steve+comp.lang.python at pearwood.info Fri Nov 4 19:15:01 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Nov 2011 23:15:01 GMT Subject: leftover pyc files References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <5204871.568.1320398878314.JavaMail.geo-discussion-forums@yqiu15> <4EB3BFA3.4090802@gmail.com> <4EB3C5E2.3020702@gmail.com> Message-ID: <4eb471f4$0$29968$c3e8da3$5496439d@news.astraweb.com> On Fri, 04 Nov 2011 16:01:14 -0400, Terry Reedy wrote: > For those not aware, the compiled file caching and import system was > changed for 3.2. Given test.py, the compiled file is no longer test.pyc, > in the same directory, but (for cpython32) > __pycache__/test.cpython-32.pyc. Given the statement 'import test', the > __pycache__ directory is only searched (for the name given above) after > finding test.py. So if 'test.py' is deleted or renamed to 'mytest.py', > an unchanged 'import test' will *fail* instead of importing the obsolete > .pyc file. So there is no longer a functional reason to delete such > obsolete files. However, the OP is stuck with 2.5. Oh, I don't know, removing obsolete and useless crud from your file system seems like a good enough functional reason to me :) However, the behaviour of Python 3.2 is a little more complicated than the above, since it must still support .pyc only software. If you have a .pyc file in the PYTHONPATH, but *outside* of a __pycache__ directory, and it is compiled for the correct version of Python, it will still be imported as usual. I'm not sure what happens if you have two .pyc files, one inside the cache and one outside. -- Steven From tjreedy at udel.edu Fri Nov 4 20:42:02 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 04 Nov 2011 20:42:02 -0400 Subject: SystemError when defining In-Reply-To: References: Message-ID: On 11/4/2011 3:10 PM, Joshua Landau wrote: > > >> def x(nonlocal_var): > ... def y(): > ... z = lambda *, keyword_only=nonlocal_var: None > ... return y > ... > >>> x(None)() ... > SystemError: no locals when loading 'nonlocal_var' ... > Now - where shall I report this? Joshua found bugs.python.org and, 2 hours later, a fix was applied. http://bugs.python.org/issue13343 -- Terry Jan Reedy From joshua.landau.ws at gmail.com Fri Nov 4 21:53:17 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Sat, 5 Nov 2011 01:53:17 +0000 Subject: SystemError when defining In-Reply-To: References: Message-ID: > > Joshua found bugs.python.org and, 2 hours later, a fix was applied. > http://bugs.python.org/**issue13343 > It was impressively fast. Those python devs are like a hawk. Although I wasn't expecting a three-line patch (plus a three line test). -------------- next part -------------- An HTML attachment was scrubbed... URL: From jhsu802701 at gmail.com Sat Nov 5 01:27:58 2011 From: jhsu802701 at gmail.com (Jason Hsu, Mr. Swift Linux) Date: Fri, 4 Nov 2011 22:27:58 -0700 (PDT) Subject: Can I fully replace GNU Bash with Python? Message-ID: This question concerns my process of creating Swift Linux from the base distro (antiX Linux in the past, Linux Mint Debian Edition now). (NOTE: The process I'm describing here is an oversimplification.) All of my development work takes place in the ~/develop directory. This is the directory where I enter the "git clone" command to download the repositories from GitHub. These repositories are 1- build, majorfunction1, majorfunction2, and so on. After I download these repositories, I have the directories ~/develop/1-build, ~/ develop/majorfunction1, ~/develop/majorfunction2, and so on. The ~/develop/1-build directory contains the scripts that build Swift Linux. Each major function needed to create Swift Linux (such as changing web browser configuration files, changing login manager configuration files, etc.) has its own majorfunction# repository. For developing the latest version of Swift Linux, I had the swift.sh script in the ~/develop/1-build directory call scripts in the majorfunction directories with commands like: sh ~/develop/majorfunction1/main.sh sh ~/develop/majorfunction2/main.sh and so on Please note that one can run any of these major functions independently OR as part of the ~/develop/1-build/swift.sh script. The ability to run any major function independently means I can focus on just one function that's not working as it should WITHOUT messing around with other functions. This ability will be especially important when I have an actual team working on Swift Linux. What I'd like to do is replace GNU Bash with Python. I know I can replace the main.sh scripts with main.py scripts. Then the commands in the swift.sh script would be: python ~/develop/majorfunction1/main.py python ~/develop/majorfunction2/main.py and so on Is there a way I can replace the ~/develop/1-build/swift.sh script with a ~/develop/1-build/swift.py script, yet still retain the ability to work on one major function WITHOUT requiring the other major functions and the 1-build directory to be present? From kwa at kuwata-lab.com Sat Nov 5 02:06:55 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Sat, 5 Nov 2011 15:06:55 +0900 Subject: [ANN] pyKook 0.7.0 - task automation tool for Python, similar to Rake or Ant Message-ID: Hi, I have released pyKook 0.7.0. http://pypi.python.org/pypi/Kook/ http://www.kuwata-lab.com/kook/ http://www.kuwata-lab.com/kook/pykook-users-guide.html In this release, you can run commands on remote machines using ssh. This is very useful to deploy your application. pyKook Overview --------------- pyKook is a task automation tool for Python, similar to Rake or Ant. (Kookbook.py): kookbook.default = 'build' ## task @recipe(None, ['hello']) def build(c): """build all""" pass ## file @recipe('hello', ['hello.o']) def file_hello(c): """build 'hello' from 'hello.o'""" system(c%'gcc -o $(product) $(ingred)') ## rule @recipe('*.o', ['$(1).c', '$(1).h']) def file_o(c): system(c%'gcc -c $(ingred)') Command-line: bash> kk # or pykook $ gcc -c hello.c ### *** hello.o (recipe=file_o) $ gcc -c hello.c ### ** hello (recipe=file_hello) $ gcc -o hello hello.o ### * build (recipe=build) See http://www.kuwata-lab.com/kook/pykook-users-guide.html for details. Enhancements in this release ---------------------------- * (EXPERIMENTAL!!) Remote command execution (ssh and sftp) is available. This is very useful to deploy your application into servers. Ex (Kookbook.py):: from kook.remote import Remote remote = Remote( hosts = ['www1', 'www2', 'user3 at www3:10022'], port = 22, user = 'user1', #password = None, # for login, '~/.ssh/id_rsa' and sudo passphrase = None, # only for '~/.ssh/id_rsa' sudo_password = 'xxx', # only for sudo command ) @recipe @remotes(remote) def hostinfo(c): """show hostname""" ssh = c.ssh ssh('hostname') # run command with ssh ssh('whomai') # run command with ssh ssh.sudo('whoami') # run command with sudo @recipe @remotes(remote) def exchange(c): """upload and download files""" ssh = c.ssh with ssh.pushd('work/apps'): ssh.get('file.remote') # download a file ssh.put('file.local') # upload a file ssh.mget('remote.*') # download files ssh.mput('local.*') # upload files Notice that you must configure ssh at first and confirm that you can log into servers without typing password:: bash> ssh user1 at www1 bash> ssh user1 at www2 bash> ssh -p 10022 user3 at www3 bash> kk hostinfo ### * showinfo (recipe=showinfo) [user1 at www1]$ hostame www1 [user1 at www1]$ whoami user1 [user1 at www1]$ sudo whoami root [user2 at www2]$ hostame www2 [user2 at www2]$ whoami user2 [user2 at www2]$ sudo whoami root [user3 at www3]$ hostame www3 [user3 at www3]$ whami user3 [user3 at www3]$ sudo whoami root Currently commands are executed sequencially (not in parallel). * (EXPERIMENTAL!!) Password object supported. Password object asks you to enter password in prompt when necessary. Ex (Kookbook.py):: from kook.remote import Remote, Password remote = Remote( hosts = ['user1 at www1:22'], #password = Password('login'), passphrase = Password('~/.ssh/id_rsa'), sudo_password = Password('sudo command') ) # @recipe @remotes(remote) def remote_test(c): ssh = c.ssh ssh.sudo('whoami') Output example:: bash> kk remote_test ### * remote_test (recipe=remote_test) Password for ~/.ssh/id_rsa: Password for sudo command: [user1 at www1]$ sudo whoami root It is easy to share password object. Ex (Kookbook.py):: from kook.remote import Remote, Password passwd = Password() remote = Remote( hosts = ['user1 at www1:22'], password = passwd, passphrase = passwd, sudo_password = passwd, ) Changes in this release ----------------------- * Category class is changed to convers all instance methods into staticmethods. Ex (Kookbook.py): class apache(Category): @recipe def start(c): system('apachectl start') ## start() is converted into staticmethod assert type(apache.__dict__['start']) == staticmethod from types import FunctionType assert type(apache.start) == FuntionType This makes execution of other recipes in category easier:: class apache(Category): @recipe def start(c): ... @recipe def stop(c): ... @recipe def restart(c): apache.start(c) # execute other recipe apache.stop(c) # execute other recipe * (internal) kook.config.stdout and kook.config.stderr are removed. See http://www.kuwata-lab.com/kook/pykook-CHANGES.txt for details. Have fun! -- regards, makoto kuwata From tjreedy at udel.edu Sat Nov 5 03:50:42 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 05 Nov 2011 03:50:42 -0400 Subject: SystemError when defining In-Reply-To: References: Message-ID: On 11/4/2011 9:53 PM, Joshua Landau wrote: > Joshua found bugs.python.org and, 2 hours > later, a fix was applied. > http://bugs.python.org/__issue13343 > > > It was impressively fast. Those python devs are like a hawk. > Although I wasn't expecting a three-line patch (plus a three line test). We are not always so fast, but the public perception of our speed is skewed by a) the occasional bug that sits on the tracker for years and b) the near invisibility of bugs caught and quickly fixed by a developer without posting an issue on the tracker. In this case, you made a very good report with a minimal reproducible buggy code snippet, plus a report of similar snippets that worked. Then it was quickly seen by someone familiar with the relevant file. -- Terry Jan Reedy From jeanpierreda at gmail.com Sat Nov 5 07:11:42 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sat, 5 Nov 2011 07:11:42 -0400 Subject: Can I fully replace GNU Bash with Python? In-Reply-To: References: Message-ID: > Is there a way I can replace the ~/develop/1-build/swift.sh script > with a ~/develop/1-build/swift.py script, yet still retain the ability > to work on one major function WITHOUT requiring the other major > functions and the 1-build directory to be present? I thought I followed along, but I don't see where the problem is here. Did you try something and it didn't work, or are you asking if in principle it can work? In principle, it can work fine. the mainfunction modules can be importable modules with some functions, or they can be (like they are in sh) runnable scripts called by your build script, or whatever. You can diverge as much as you want from how sh works, or stay as close as you want, down to the level of only interoperating with other python modules by invoking them as programs. Devin On Sat, Nov 5, 2011 at 1:27 AM, Jason Hsu, Mr. Swift Linux wrote: > This question concerns my process of creating Swift Linux from the > base distro (antiX Linux in the past, Linux Mint Debian Edition now). > (NOTE: The process I'm describing here is an oversimplification.) > > All of my development work takes place in the ~/develop directory. > This is the directory where I enter the "git clone" command to > download the repositories from GitHub. ?These repositories are 1- > build, majorfunction1, majorfunction2, and so on. ?After I download > these repositories, I have the directories ~/develop/1-build, ~/ > develop/majorfunction1, ~/develop/majorfunction2, and so on. > > The ~/develop/1-build directory contains the scripts that build Swift > Linux. ?Each major function needed to create Swift Linux (such as > changing web browser configuration files, changing login manager > configuration files, etc.) has its own majorfunction# repository. > > For developing the latest version of Swift Linux, I had the swift.sh > script in the ?~/develop/1-build directory call scripts in the > majorfunction directories with commands like: > sh ~/develop/majorfunction1/main.sh > sh ~/develop/majorfunction2/main.sh > and so on > > Please note that one can run any of these major functions > independently OR as part of the ~/develop/1-build/swift.sh script. > The ability to run any major function independently means I can focus > on just one function that's not working as it should WITHOUT messing > around with other functions. ?This ability will be especially > important when I have an actual team working on Swift Linux. > > What I'd like to do is replace GNU Bash with Python. ?I know I can > replace the main.sh scripts with main.py scripts. ?Then the commands > in the swift.sh script would be: > python ~/develop/majorfunction1/main.py > python ~/develop/majorfunction2/main.py > and so on > > Is there a way I can replace the ~/develop/1-build/swift.sh script > with a ~/develop/1-build/swift.py script, yet still retain the ability > to work on one major function WITHOUT requiring the other major > functions and the 1-build directory to be present? > -- > http://mail.python.org/mailman/listinfo/python-list > From pacopyc at gmail.com Sat Nov 5 08:50:38 2011 From: pacopyc at gmail.com (pacopyc) Date: Sat, 5 Nov 2011 05:50:38 -0700 (PDT) Subject: xml-rpc server on wine Message-ID: <650e9d68-e606-4424-bca7-174295306d82@ht6g2000vbb.googlegroups.com> Hi, I have a XML-RPC server python running on VM Windows (on Linux) and a XML-RPC client python on Linux. Server and client have different IP address. I'd like migrate server on wine. How can communicate server and client? IP address is different or is the same? Can you help me? Thanks From ross at biostat.ucsf.edu Sat Nov 5 15:03:27 2011 From: ross at biostat.ucsf.edu (Ross Boylan) Date: Sat, 05 Nov 2011 12:03:27 -0700 Subject: inserting \ in regular expressions [solved] In-Reply-To: <1319658482.13425.9.camel@corn.betterworld.us> References: <1319658482.13425.9.camel@corn.betterworld.us> Message-ID: <1320519807.18391.5.camel@corn.betterworld.us> On Wed, 2011-10-26 at 12:48 -0700, Ross Boylan wrote: > I want to replace every \ and " (the two characters for backslash and > double quotes) with a \ and the same character, i.e., > \ -> \\ > " -> \" I'd like to thank Ian, Dave, MRAB, and John for their helpful responses. I hadn't realized the interpreter was giving me the repr, and that differed from the str. I've since found one other solution: email.utils.quote() does exactly the substitution I was looking for--not surprising, since I was doing it for email. Here's my little test program: #! /usr/bin/python import email, email.utils, re s0 = r'I am " a silly \quote' print s0 print re.sub(r'(\\|")', r'\\\1', s0) print email.utils.quote(s0) Output I am " a silly \quote I am \" a silly \\quote I am \" a silly \\quote Ross From logic at op.pl Sat Nov 5 15:30:12 2011 From: logic at op.pl (wojciech777) Date: Sat, 5 Nov 2011 12:30:12 -0700 (PDT) Subject: httpd.conf configuration for mod_wsgi.so on wamp (apache)? Message-ID: Hi there. Is there any way to run python web application (or simple web page in web.py) on Windows with wamp without starting built-in wsgi server manually (python run.py). I know there's a documentation on http://webpy.org/install#apachemodwsgi, but it doesn't show where exactly in httpd.conf I should place the commands. In my example I would like to get start page, simply by typing in my browser e.g. http://localhost:8070, and my file is located in: c:/ wamp/ www/xaura/run.py source of run.py: #!/usr/bin/env python import web urls = ('/', 'hello', '', 'hello') class hello: def GET(self): return "Hello, world." app = web.application(urls, globals()) if __name__ == "__main__": app.run() Any help will be appreciated. Thanks Wojciech Ka?mierczak From jehugaleahsa at gmail.com Sat Nov 5 16:11:28 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sat, 5 Nov 2011 13:11:28 -0700 (PDT) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django Message-ID: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> Hello: A new guy showed up at work a few weeks ago and has started talking about replacing a 6 month old project, written in ASP.NET MVC, with an open source solution that can handle massive scaling. I think his primary concern is the "potential" need for massive web farms in the future. In order to prevent high licensing costs, I think he wants to move everything to open source technologies, such as the LAMP stack. I also don't think he truly understands what ASP.NET MVC is and thinks it is the older WebForms. I have been researching open source MVC frameworks and came across Django. It looks like an awesome tool, but I am willing to look at others. I have experience in Python (and enough in PHP to want to avoid it and absolutely none in Ruby) so I think it would be a good language to develop in. I was wondering if there were any ORMs for Python that used POPOs (plain old Python objects). There is a lot of business logic in my system, and so I want to keep my data objects simple and stupid. I want the ORM to be responsible for detecting changes to objects after I send them back to the data layer (rather than during business layer execution). Additionally, being a stateless environment, tracking objects' states isn't very useful anyway. Honestly, I doubt this guy is going to get his wish. The people paying for the application aren't going to be willing to throw 6 months of work down the drain. Never the less, I want to have plenty of research under my belt before being asked what my thoughts are. He was talking about using the Zend Framework with PHP, but I want to avoid that if possible. Django seems like one of the best MVC solutions in the Python arena. I would be willing to replace Django's ORM solution with something else, especially if it supported POPOs. I could even map all of the non-POPOs to POPOs if I needed to, I guess. Finally, I wanted to ask whether anyone has tried having Django call out to Python 3 routines. I am okay using Python 2.7 in Django, if I can have the controllers call business logic implemented in Python 3, accepting POPOs from the data layer. Django would really just be a coordinator: grab data from Django ORM, convert results into POPOs, load up Python 3 module with business logic, passing POPOs, returning POPOs and then converting those to view models. I'm sweating just thinking about it. My guess is that there would be a severe penalty for crossing process boundaries... but any insights would be appreciated. Thanks, Travis Parks From nawijn at gmail.com Sat Nov 5 16:35:55 2011 From: nawijn at gmail.com (Marco Nawijn) Date: Sat, 5 Nov 2011 13:35:55 -0700 (PDT) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> Message-ID: <0fe2f129-bbe2-4c7e-99e7-48f21b87a3bf@c1g2000vbw.googlegroups.com> On Nov 5, 9:11?pm, Travis Parks wrote: > Hello: > > A new guy showed up at work a few weeks ago and has started talking > about replacing a 6 month old project, written in ASP.NET MVC, with an > open source solution that can handle massive scaling. I think his > primary concern is the "potential" need for massive web farms in the > future. In order to prevent high licensing costs, I think he wants to > move everything to open source technologies, such as the LAMP stack. I > also don't think he truly understands what ASP.NET MVC is and thinks > it is the older WebForms. > > I have been researching open source MVC frameworks and came across > Django. It looks like an awesome tool, but I am willing to look at > others. I have experience in Python (and enough in PHP to want to > avoid it and absolutely none in Ruby) so I think it would be a good > language to develop in. > > I was wondering if there were any ORMs for Python that used POPOs > (plain old Python objects). There is a lot of business logic in my > system, and so I want to keep my data objects simple and stupid. I > want the ORM to be responsible for detecting changes to objects after > I send them back to the data layer (rather than during business layer > execution). Additionally, being a stateless environment, tracking > objects' states isn't very useful anyway. > > Honestly, I doubt this guy is going to get his wish. The people paying > for the application aren't going to be willing to throw 6 months of > work down the drain. Never the less, I want to have plenty of research > under my belt before being asked what my thoughts are. He was talking > about using the Zend Framework with PHP, but I want to avoid that if > possible. Django seems like one of the best MVC solutions in the > Python arena. I would be willing to replace Django's ORM solution with > something else, especially if it supported POPOs. I could even map all > of the non-POPOs to POPOs if I needed to, I guess. > > Finally, I wanted to ask whether anyone has tried having Django call > out to Python 3 routines. I am okay using Python 2.7 in Django, if I > can have the controllers call business logic implemented in Python 3, > accepting POPOs from the data layer. Django would really just be a > coordinator: grab data from Django ORM, convert results into POPOs, > load up Python 3 module with business logic, passing POPOs, returning > POPOs and then converting those to view models. I'm sweating just > thinking about it. My guess is that there would be a severe penalty > for crossing process boundaries... but any insights would be > appreciated. > > Thanks, > Travis Parks Hello Travis, I am not an expert in the field, but I have used SQLAlchemy (www.sqlalchemy.org) for a while and was very happy with it. It should be able to scale up to pretty complex applications and large amounts of data. Regards, Marco From rosuav at gmail.com Sat Nov 5 18:09:25 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 6 Nov 2011 09:09:25 +1100 Subject: Python ORMs Supporting POPOs and Substituting Layers in Django In-Reply-To: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> Message-ID: On Sun, Nov 6, 2011 at 7:11 AM, Travis Parks wrote: > Finally, I wanted to ask whether anyone has tried having Django call > out to Python 3 routines. I am okay using Python 2.7 in Django, if I > can have the controllers call business logic implemented in Python 3, > accepting POPOs from the data layer. What you're going to have is completely separate processes; either invoking Python3 and having it terminate after one action, or keeping it running concurrently and passing data between them. Has anyone ever extended AND embedded Python at the same time? Written a Python module that ... executes Python code? Might be a bit tricky, but possibly isolating the Py2 and Py3 code into different C source files would help conserve programmer sanity (at the possible cost of performance). Would be a tricky thing to juggle, but if you can pull it off, you'd be able to - effectively - have a module in Django that's written in Python 3, and directly callable. Propagating parameters and return values would be a matter of unpacking them into C objects and repacking them on the other side. Propagating exceptions would be.... fun? ChrisA From jehugaleahsa at gmail.com Sat Nov 5 23:22:34 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sat, 5 Nov 2011 20:22:34 -0700 (PDT) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> Message-ID: <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> On Nov 5, 4:11?pm, Travis Parks wrote: > Hello: > > A new guy showed up at work a few weeks ago and has started talking > about replacing a 6 month old project, written in ASP.NET MVC, with an > open source solution that can handle massive scaling. I think his > primary concern is the "potential" need for massive web farms in the > future. In order to prevent high licensing costs, I think he wants to > move everything to open source technologies, such as the LAMP stack. I > also don't think he truly understands what ASP.NET MVC is and thinks > it is the older WebForms. > > I have been researching open source MVC frameworks and came across > Django. It looks like an awesome tool, but I am willing to look at > others. I have experience in Python (and enough in PHP to want to > avoid it and absolutely none in Ruby) so I think it would be a good > language to develop in. > > I was wondering if there were any ORMs for Python that used POPOs > (plain old Python objects). There is a lot of business logic in my > system, and so I want to keep my data objects simple and stupid. I > want the ORM to be responsible for detecting changes to objects after > I send them back to the data layer (rather than during business layer > execution). Additionally, being a stateless environment, tracking > objects' states isn't very useful anyway. > > Honestly, I doubt this guy is going to get his wish. The people paying > for the application aren't going to be willing to throw 6 months of > work down the drain. Never the less, I want to have plenty of research > under my belt before being asked what my thoughts are. He was talking > about using the Zend Framework with PHP, but I want to avoid that if > possible. Django seems like one of the best MVC solutions in the > Python arena. I would be willing to replace Django's ORM solution with > something else, especially if it supported POPOs. I could even map all > of the non-POPOs to POPOs if I needed to, I guess. > > Finally, I wanted to ask whether anyone has tried having Django call > out to Python 3 routines. I am okay using Python 2.7 in Django, if I > can have the controllers call business logic implemented in Python 3, > accepting POPOs from the data layer. Django would really just be a > coordinator: grab data from Django ORM, convert results into POPOs, > load up Python 3 module with business logic, passing POPOs, returning > POPOs and then converting those to view models. I'm sweating just > thinking about it. My guess is that there would be a severe penalty > for crossing process boundaries... but any insights would be > appreciated. > > Thanks, > Travis Parks Which web frameworks have people here used and which have they found to be: scalable, RAD compatible, performant, stable and/or providing good community support? I am really trying to get as much feedback as I can, to help form an unbiased opinion in case I need to make a recommendation... or fight an all out battle. From simeon.chaos at gmail.com Sun Nov 6 00:45:39 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Sat, 5 Nov 2011 21:45:39 -0700 (PDT) Subject: What would happen when lisp meets prolog in python? Dao and Dinpy arises! Message-ID: Dao is the new generation programming system implemented by a functional logic solver, unifying code with data, grammar with program, logic with functional, compiling with running. Would you please to have a look at my dao and dinpy? http://pypi.python.org/pypi/daot https://github.com/chaosim/dao The feature of dao and dinpy: * Mix functional and logic programming like prolog and lisp in python. * A most powerful parser is provided, which have the power all of the other parsers do not have. below is the list of some parser and algorithms: parsec(haskell), packrat, earley parser, glr parser, antlr, lex/yacc. What's the magic behind the dao? See samples\sexpression.py and testsexpression.py for a sample. this is the key tips to the dao's dynamic grammar, which will become a most powerful tool: (sexpression, function( # dynamic grammar arises! ([Result], and_p(char('{'), sexpression(Expr2), char('}'), setvalue(Result, eval_(pycall(sexpression2daoexpression, Expr2))))), ([Expr], atom_expression(Expr)), ([Expr], bracketExpression(Expr)), ([Expr], puncExpression(Expr))), # the kernel of dynamic grammar (eval_parse_result, function( ([Result], and_p(sexpression(Expr2), eoi, is_(Result, eval_(pycall(sexpression2daoexpression, Expr2))))))), From frank at chagford.com Sun Nov 6 03:54:48 2011 From: frank at chagford.com (Frank Millman) Date: Sun, 6 Nov 2011 10:54:48 +0200 Subject: Question about 'iterable cursors' Message-ID: Hi all I am using a few DB_API adaptors - ceODBC for Sql Server, psycopg2 for PostgreSQL, and sqlite3 for sqlite3. They all offer the feature that if a cursor executes a SELECT, the cursor returns an iterator which can be used to fetch one row at a time. I have been using this feature for a while and it seems like a 'good thing'. Now I am not so sure. I am using a connection pool to maintain connections to the database. A principle I am following is that a connection must be returned quickly, so that it is available for reuse. I have been happily returning the connection, but keeping the cursor open while processing the rows selected. I now realise that this is dangerous. Therefore I have changed my system to execute fetchall() on the cursor before returning the connection. This obviously loses the benefit of the iterator. I would appreciate confirmation that my thinking is correct on this issue. Or is there any way that I can have my cake and eat it? Thanks Frank Millman From alain at dpt-info.u-strasbg.fr Sun Nov 6 04:16:22 2011 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Sun, 06 Nov 2011 10:16:22 +0100 Subject: Question about 'iterable cursors' References: Message-ID: <87pqh54nmh.fsf@dpt-info.u-strasbg.fr> "Frank Millman" writes: > I am using a few DB_API adaptors - ceODBC for Sql Server, psycopg2 for > PostgreSQL, and sqlite3 for sqlite3. > > They all offer the feature that if a cursor executes a SELECT, the > cursor returns an iterator which can be used to fetch one row at a > time. I have been using this feature for a while and it seems like a > good thing'. > > Now I am not so sure. I am using a connection pool to maintain > connections to the database. A principle I am following is that a > connection must be returned quickly, so that it is available for > reuse. > > I have been happily returning the connection, but keeping the cursor > open while processing the rows selected. I now realise that this is > dangerous. Therefore I have changed my system to execute fetchall() on > the cursor before returning the connection. This obviously loses the > benefit of the iterator. > > I would appreciate confirmation that my thinking is correct on this > issue. Or is there any way that I can have my cake and eat it? Your thinking is correct: you need to keep the connection while processing the cursor. Databases are made to scale, you may well be processing the first lines of the result before the DBMS has even finished scanning tables. View this as a pipe, the cursor being one end of the pipe. The usual setting, fetching one line at a time, lets you overlap your processing with the network transfers. Fetching all data, returning the connection, and then start processing only makes sense if the processing take a lot of time (I mean: a lot more than fetching results), which is a rare case. Unless you are in such an extreme situation, I would suggest leaving the optimization to the connection pool, which is here to solve what you are trying to solve. -- Alain. From frank at chagford.com Sun Nov 6 04:39:56 2011 From: frank at chagford.com (Frank Millman) Date: Sun, 6 Nov 2011 11:39:56 +0200 Subject: Question about 'iterable cursors' References: <87pqh54nmh.fsf@dpt-info.u-strasbg.fr> Message-ID: "Alain Ketterlin" wrote > "Frank Millman" writes: > >> I am using a few DB_API adaptors - ceODBC for Sql Server, psycopg2 for >> PostgreSQL, and sqlite3 for sqlite3. >> >> They all offer the feature that if a cursor executes a SELECT, the >> cursor returns an iterator which can be used to fetch one row at a >> time. I have been using this feature for a while and it seems like a >> good thing'. >> >> Now I am not so sure. I am using a connection pool to maintain >> connections to the database. A principle I am following is that a >> connection must be returned quickly, so that it is available for >> reuse. >> >> I have been happily returning the connection, but keeping the cursor >> open while processing the rows selected. I now realise that this is >> dangerous. Therefore I have changed my system to execute fetchall() on >> the cursor before returning the connection. This obviously loses the >> benefit of the iterator. >> >> I would appreciate confirmation that my thinking is correct on this >> issue. Or is there any way that I can have my cake and eat it? > > Your thinking is correct: you need to keep the connection while > processing the cursor. Databases are made to scale, you may well be > processing the first lines of the result before the DBMS has even > finished scanning tables. View this as a pipe, the cursor being one end > of the pipe. The usual setting, fetching one line at a time, lets you > overlap your processing with the network transfers. > > Fetching all data, returning the connection, and then start processing > only makes sense if the processing take a lot of time (I mean: a lot > more than fetching results), which is a rare case. Unless you are in > such an extreme situation, I would suggest leaving the optimization to > the connection pool, which is here to solve what you are trying to > solve. > Thank you, Alain. That is very clear. So my analysis of the problem is correct, but my solution is wrong. Instead of executing fetchall() and returning the connection, I should retain the connection until I have exhausted the cursor. That makes a lot of sense. Frank From merwin.irc at gmail.com Sun Nov 6 04:44:06 2011 From: merwin.irc at gmail.com (Merwin) Date: Sun, 06 Nov 2011 10:44:06 +0100 Subject: SQLAlchemy DB Migration Message-ID: <4EB656E6.2020805@gmail.com> Hi everybody, I'm looking for a way to migrate SQLAlchemy based database easily. I found Migrate, but finally it's almost the same as doing the migration by hand. If this doesn't exists, do you think that it would be hard to do a simple migration tool which would : - Add/Delete columns from DB if they are not anymore in the models (With a confirmation for deletion) - Add/Delete constraints/sequences on table if they are not on the model too We could also imagine a way to : - Handle column rename, with data copy from one to another - Handle column type change, with proper data conversion Of course, such a system can't be 100% automated, that's not the goal. Human interventation will be needed, but it might be more simpler for simple cases than Migrate. -- Thibaut From huhai102 at gmail.com Sun Nov 6 07:06:13 2011 From: huhai102 at gmail.com (wholesale brand sunglasses) Date: Sun, 6 Nov 2011 04:06:13 -0800 (PST) Subject: nfl jerseys on sale in www.nike-black.com Message-ID: <1eb24ce9-4f70-4cb8-b970-fa2a0236b4f0@h23g2000pra.googlegroups.com> (www.nike-black.com) cheap wholesale nfl jerseys , mlb jerseys ,nhl jerseys , nba jerseys , soccer jerseys . NFL Jerseys Arizona CardinalsAtlanta Falcons JerseysBaltimore Ravens Jerseys Buffalo BillsCarolina PanthersChicago Bears Cincinnati BengalsCleveland BrownsDallas Cowboys Denver BroncosDetriot lionsGreen Bay Packers Houston TexansIndianapolis ColtsJacksonville Jaguars Kansas City ChiefsMiami DolphinsMinnesota Vikings New England PatriotsNew Orleans SaintsNew York Giants New York JetsOakland RaidersPhiladelphia Eagles Pittsburgh SteelersSan Diego ChargersSan Francisco 49ers San Louis RamsTampa Bay BuccaneersTennessee Titans Washington Redskins website: http://www.nike-black.com From kevin.e.kenny at gmail.com Sun Nov 6 08:18:08 2011 From: kevin.e.kenny at gmail.com (Kev) Date: Sun, 6 Nov 2011 05:18:08 -0800 (PST) Subject: How to undo a Python setuptools --prefix path blunder Message-ID: <543f5b85-1248-4039-a12d-5bbcb2fb0f51@o19g2000vbk.googlegroups.com> When I installed Python's setuptools I absent mindedly tacked on a -- prefix path I had been using on another machine: sh setuptools-0.6c11-py2.7.egg --prefix=/opt/python2.7.2 Now after this blunder when I try to install pip I get the following error: [root at kkdev src]# easy_install pip Searching for pip Best match: pip 1.0.2 Processing pip-1.0.2-py2.7.egg pip 1.0.2 is already the active version in easy-install.pth Installing pip script to /usr/bin error: /usr/bin/pip: No such file or directory What's happening is that a symbolic link is being created that points to the folder I specified in the --prefix path which is obviously wrong: [root at kkdev src]# ls -al /usr/bin/pip lrwxrwxrwx 1 root root 24 Nov 5 17:01 /usr/bin/pip -> /opt/ python2.7.2/bin/pip I deleted this link and then re-ran the setuptools installer and specified the correct prefix (my Python install lives in /usr/lib/ python2.7): sh setuptools-0.6c11-py2.7.egg --prefix=/usr I then re-ran easy_install pip and it looked like I'd fixed my finger trouble. However when I went to install virtualenv I encountered the same problem: [root at kkdev src]# pip install virtualenv [uninteresting installer output snipped] Installing virtualenv script to /usr/bin error: /usr/bin/virtualenv: No such file or directory Again the wrong path is being used to create the symbolic link to where virtualenv is installed: [root at kkdev src]# ls -al /usr/bin/virtualenv lrwxrwxrwx 1 root root 31 Nov 5 17:01 /usr/bin/virtualenv -> /opt/ python2.7.2/bin/virtualenv (I'm running Fedora 15 32bit which has Python 2.7.1 installed out of the box) How do I fix/repair this permanently? Thanks Kevin From jfine at pytex.org Sun Nov 6 10:17:54 2011 From: jfine at pytex.org (Jonathan Fine) Date: Sun, 06 Nov 2011 15:17:54 +0000 Subject: A Python script to put CTAN into git (from DVDs) Message-ID: <4EB6A522.3020909@pytex.org> Hi This it to let you know that I'm writing (in Python) a script that places the content of CTAN into a git repository. https://bitbucket.org/jfine/python-ctantools I'm working from the TeX Collection DVDs that are published each year by the TeX user groups, which contain a snapshot of CTAN (about 100,000 files occupying 4Gb), which means I have to unzip folders and do a few other things. CTAN is the Comprehensive TeX Archive Network. CTAN keeps only the latest version of each file, but old CTAN snapshots will provide many earlier versions. I'm working on putting old CTAN files into modern version control. Martin Scharrer is working in the other direction. He's putting new files added to CTAN into Mercurial. http://ctanhg.scharrer-online.de/ My script works already as a proof of concept, but needs more work (and documentation) before it becomes useful. I've requested that follow up goes to comp.text.tex. Longer terms goals are git as * http://en.wikipedia.org/wiki/Content-addressable_storage * a resource editing and linking system If you didn't know, a git tree is much like an immutable JSON object, except that it does not have arrays or numbers. If my project interests you, reply to this message or contact me directly (or both). -- Jonathan From jnareb at gmail.com Sun Nov 6 11:42:23 2011 From: jnareb at gmail.com (Jakub Narebski) Date: Sun, 06 Nov 2011 08:42:23 -0800 (PST) Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: <4EB6A522.3020909@pytex.org> References: <4EB6A522.3020909@pytex.org> Message-ID: Jonathan Fine writes: > Hi > > This it to let you know that I'm writing (in Python) a script that > places the content of CTAN into a git repository. > https://bitbucket.org/jfine/python-ctantools I hope that you meant "repositories" (plural) here, one per tool, rather than putting all of CTAN into single Git repository. > I'm working from the TeX Collection DVDs that are published each year > by the TeX user groups, which contain a snapshot of CTAN (about > 100,000 files occupying 4Gb), which means I have to unzip folders and > do a few other things. There is 'contrib/fast-import/import-zips.py' in git.git repository. If you are not using it, or its equivalent, it might be worth checking out. > CTAN is the Comprehensive TeX Archive Network. CTAN keeps only the > latest version of each file, but old CTAN snapshots will provide many > earlier versions. There was similar effort done in putting CPAN (Comprehensive _Perl_ Archive Network) in Git, hosting repositories on GitHub[1], by the name of gitPAN, see e.g.: "The gitPAN Import is Complete" http://perlisalive.com/articles/36 [1]: https://github.com/gitpan > I'm working on putting old CTAN files into modern version > control. Martin Scharrer is working in the other direction. He's > putting new files added to CTAN into Mercurial. > http://ctanhg.scharrer-online.de/ Nb. thanks to tools such as git-hg and fast-import / fast-export we have quite good interoperability and convertability between Git and Mercurial. P.S. I'd point to reposurgeon tool, which can be used to do fixups after import, but it would probably won't work on such large (set of) repositories. P.P.S. Can you forward it to comp.text.tex? -- Jakub Nar?bski From doctordr22 at gmail.com Sun Nov 6 11:55:30 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 08:55:30 -0800 (PST) Subject: oxycodone no prescription overnight cod delivery buy oxycodone no prescription needed Message-ID: <5793e048-810e-4749-be82-33c8658d0a8a@es7g2000vbb.googlegroups.com> oxycodone cheapest. Lowest prices for oxycodone online. Buy oxycodone online without no prescription. Buy cheap oxycodone next day no prescription! oxycodone BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=oxycodone <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=oxycodone http://buypharmasite.com/?q=Buy+online+oxycodone http://buypharmasite.com/?q=Buy+order+oxycodone http://buypharmasite.com/?q=Buy+oxycodone http://buypharmasite.com/?q=Buy+cheap+oxycodone http://buypharmasite.com/?q=Order+oxycodone http://buypharmasite.com/?q=Online+oxycodone cheap online pharmacy oxycodone oxycodone online saturday delivery online oxycodone and fedex cheap order prescription oxycodone cheap oxycodone by money order buy oxycodone from mexico online oxycodone no prescription usa fedex shipping overnight delivery oxycodone buy oxycodone online without a prescription and no membership no prescription needed oxycodone cod shipped oxycodone not expensive order prescription oxycodone oxycodone money order oxycodone without a perscription online buy oxycodone oxycodone fedex buy no online prescription oxycodone oxycodone pharmacies accepting cod delivery oxycodone online consultant online pharmacy fedex cod oxycodone buy oxycodone no scams oxycodone c.o.d overnight delivery buy oxycodone no prescription cod overnight oxycodone order oxycodone online doctors buy oxycodone on line no prescription oxycodone no prescription usa fedex shipping oxycodone online uk watson brand oxycodone medicine online oxycodone order oxycodone samples sent buy oxycodone no prescription order oxycodone without a prescription oxycodone no prescription drug cheap online order oxycodone get oxycodone over the counter online order oxycodone next day buy oxycodone no perscription cod real oxycodone fed ex oxycodone no prescription cod does cv/ pharmacy carry oxycodone no prescription cod oxycodone cheap oxycodone without rx oxycodone online health insurance lead buy oxycodone online with overnight delivery oxycodone no rx fed ex buy oxycodone without a perscription lowest prices for oxycodone online buy oxycodone paypal online without prescription cheap non prescription oxycodone oxycodone ups oxycodone for cheap buy oxycodone no visa online without prescription cheapest oxycodone cash on delivery oxycodone order a prepaid mastercard buy online oxycodone purchase oxycodone mail order oxycodone without a prescription online with overnight delivery oxycodone from canada buy oxycodone with no rx overnight delivery of oxycodone with no prescription cash on delivery oxycodone no rx oxycodone by cod buy oxycodone over the counter cod overnight overnight oxycodone order oxycodone without prescription from us pharmacy cheap oxycodone free fedex shipping order oxycodone over the counter where to buy oxycodone no prescription no fees only oxycodone free consult cod delivery oxycodone oxycodone no prescription oxycodone online overnight delivery cod order oxycodone over the counter fedex oxycodone saturday delivery buy oxycodone money order oxycodone without prescription mexico buy cheap oxycodone without prescription oxycodone non prescription for next day delivery oxycodone ups delivery only buy oxycodone usa cod oxycodone with next day delivery no prescriptions needed for oxycodone cheap oxycodone overnight prescription oxycodone cheap oxycodone overnight delivery oxycodone non prescription fedex overnight free order oxycodone no creditcard buy cheap oxycodone no Prescription buy oxycodone over the counter fedex oxycodone no doctor presribe needed cheap watson oxycodone online cheap discount oxycodone buy oxycodone without a prescription online cheapest oxycodone free delivery buy oxycodone online overseas buy oxycodone over the counter online not expensive oxycodone next day shipping order oxycodone cod next day delivery oxycodone cheap oxycodone buy in UK oxycodone next day cod fedex oxycodone to buy cheap order oxycodone next day oxycodone oxycodone overnight no consult cheap watson oxycodone no prescription needed oxycodone without prescription medications overnight delivery of oxycodone with no perscription buy oxycodone.com oxycodone cod next day delivery buy cheap discount online oxycodone buy oxycodone drug oxycodone overnight delivery cheap overnight delivery of oxycodone in US no prescription needed purchase oxycodone free next day airoxycodone on line cheap oxycodone without a prescription oxycodone cheap cod oxycodone buy no prepaid cheap oxycodone next day buy oxycodone cod accepted online pharmacies oxycodone saturday delivery buy oxycodone pay pal oxycodone shipped on saturday oxycodone pharmacy cod saturday delivery buy online oxycodone prescriptions free fedex delivery oxycodone oxycodone without prescription cash on delivery buy discount oxycodone oxycodone overnight cheap best oxycodone online pill images of oxycodone oxycodone U.P.S SHIPPING COD oxycodone cod pharmacy buy oxycodone online cod oxycodone cod overnight delivery oxycodone no rx overnight buy oxycodone overnight COD online pharmacy oxycodone cod order oxycodone insurance oxycodone cash delivery cod buy oxycodone cheap cod no rx online pharmacy oxycodone sale nextday oxycodone oxycodone pill oxycodone online ordering oxycodone online without prescription oxycodone no script needed cod overnight how to buy oxycodone online without a prescription cheap oxycodone without prescription cheap oxycodone online no rx saturday delivery order oxycodone over the counter for sale oxycodone next day delivery cod order oxycodone online without prescription no prescription next day delivery oxycodone overnight oxycodone C.O.D oxycodone without prescription oxycodone discount fedex no prescription buy oxycodone amex oxycodone online next day oxycodone shipped with no prescription oxycodone online cheap cheap oxycodone without prescription overnight delivery buy oxycodone over the counter for sale oxycodone no prescriptions needed cod oxycodone fed ex cheap overnight delivery of oxycodone free prescription oxycodone free shipping not expensive legal oxycodone for sale buy oxycodone cod oxycodone for saturday oxycodone price cash for oxycodone cash on delivery oxycodone oxycodone without a prescription and cod delivery buying oxycodone without a prescription order oxycodone no rx buy oxycodone without rx oxycodone cheapest buy oxycodone online pharmacy buy cheap oxycodone overnight delivery oxycodone and online pharmacy oxycodone next day oxycodone drug no prescription where can i buy oxycodone no prescription oxycodone with saturday delivery oxycodone online overnight oxycodone no prescription worldwide buy cheap oxycodone cod ordering oxycodone online Buy oxycodone overnight shipping oxycodone overnight US delivery cheap real oxycodone for sale oxycodone no prescriptions needed COD buy oxycodone no prescription needed oxycodone no prescription overnight cod delivery cheap oxycodone cash on delivery no prescription required for oxycodone order oxycodone c.o.d. not expensive oxycodone prescriptions oxycodone online Cash on Delivery buy oxycodone overnight delivery oxycodone online without presciption buy oxycodone prescription online no prescription saturday delivery oxycodone where to buy cheap oxycodone no prescription oxycodone wo get oxycodone over the counter fedex oxycodone with no rx and free shipping order oxycodone over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 11:59:57 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 08:59:57 -0800 (PST) Subject: how to buy Adderall online without a prescription cheap Adderall online no rx saturday delivery Message-ID: <20144e7f-528f-45cc-8c2d-36f8dd57113c@v8g2000vbe.googlegroups.com> Adderall cheapest. Lowest prices for Adderall online. Buy Adderall online without no prescription. Buy cheap Adderall next day no prescription! Adderall BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Adderall <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Adderall http://buypharmasite.com/?q=Buy+online+Adderall http://buypharmasite.com/?q=Buy+order+Adderall http://buypharmasite.com/?q=Buy+Adderall http://buypharmasite.com/?q=Buy+cheap+Adderall http://buypharmasite.com/?q=Order+Adderall http://buypharmasite.com/?q=Online+Adderall cheap online pharmacy Adderall Adderall online saturday delivery online Adderall and fedex cheap order prescription Adderall cheap Adderall by money order buy Adderall from mexico online Adderall no prescription usa fedex shipping overnight delivery Adderall buy Adderall online without a prescription and no membership no prescription needed Adderall cod shipped Adderall not expensive order prescription Adderall Adderall money order Adderall without a perscription online buy Adderall Adderall fedex buy no online prescription Adderall Adderall pharmacies accepting cod delivery Adderall online consultant online pharmacy fedex cod Adderall buy Adderall no scams Adderall c.o.d overnight delivery buy Adderall no prescription cod overnight Adderall order Adderall online doctors buy Adderall on line no prescription Adderall no prescription usa fedex shipping Adderall online uk watson brand Adderall medicine online Adderall order Adderall samples sent buy Adderall no prescription order Adderall without a prescription Adderall no prescription drug cheap online order Adderall get Adderall over the counter online order Adderall next day buy Adderall no perscription cod real Adderall fed ex Adderall no prescription cod does cv/ pharmacy carry Adderall no prescription cod Adderall cheap Adderall without rx Adderall online health insurance lead buy Adderall online with overnight delivery Adderall no rx fed ex buy Adderall without a perscription lowest prices for Adderall online buy Adderall paypal online without prescription cheap non prescription Adderall Adderall ups Adderall for cheap buy Adderall no visa online without prescription cheapest Adderall cash on delivery Adderall order a prepaid mastercard buy online Adderall purchase Adderall mail order Adderall without a prescription online with overnight delivery Adderall from canada buy Adderall with no rx overnight delivery of Adderall with no prescription cash on delivery Adderall no rx Adderall by cod buy Adderall over the counter cod overnight overnight Adderall order Adderall without prescription from us pharmacy cheap Adderall free fedex shipping order Adderall over the counter where to buy Adderall no prescription no fees only Adderall free consult cod delivery Adderall Adderall no prescription Adderall online overnight delivery cod order Adderall over the counter fedex Adderall saturday delivery buy Adderall money order Adderall without prescription mexico buy cheap Adderall without prescription Adderall non prescription for next day delivery Adderall ups delivery only buy Adderall usa cod Adderall with next day delivery no prescriptions needed for Adderall cheap Adderall overnight prescription Adderall cheap Adderall overnight delivery Adderall non prescription fedex overnight free order Adderall no creditcard buy cheap Adderall no Prescription buy Adderall over the counter fedex Adderall no doctor presribe needed cheap watson Adderall online cheap discount Adderall buy Adderall without a prescription online cheapest Adderall free delivery buy Adderall online overseas buy Adderall over the counter online not expensive Adderall next day shipping order Adderall cod next day delivery Adderall cheap Adderall buy in UK Adderall next day cod fedex Adderall to buy cheap order Adderall next day Adderall Adderall overnight no consult cheap watson Adderall no prescription needed Adderall without prescription medications overnight delivery of Adderall with no perscription buy Adderall.com Adderall cod next day delivery buy cheap discount online Adderall buy Adderall drug Adderall overnight delivery cheap overnight delivery of Adderall in US no prescription needed purchase Adderall free next day airAdderall on line cheap Adderall without a prescription Adderall cheap cod Adderall buy no prepaid cheap Adderall next day buy Adderall cod accepted online pharmacies Adderall saturday delivery buy Adderall pay pal Adderall shipped on saturday Adderall pharmacy cod saturday delivery buy online Adderall prescriptions free fedex delivery Adderall Adderall without prescription cash on delivery buy discount Adderall Adderall overnight cheap best Adderall online pill images of Adderall Adderall U.P.S SHIPPING COD Adderall cod pharmacy buy Adderall online cod Adderall cod overnight delivery Adderall no rx overnight buy Adderall overnight COD online pharmacy Adderall cod order Adderall insurance Adderall cash delivery cod buy Adderall cheap cod no rx online pharmacy Adderall sale nextday Adderall Adderall pill Adderall online ordering Adderall online without prescription Adderall no script needed cod overnight how to buy Adderall online without a prescription cheap Adderall without prescription cheap Adderall online no rx saturday delivery order Adderall over the counter for sale Adderall next day delivery cod order Adderall online without prescription no prescription next day delivery Adderall overnight Adderall C.O.D Adderall without prescription Adderall discount fedex no prescription buy Adderall amex Adderall online next day Adderall shipped with no prescription Adderall online cheap cheap Adderall without prescription overnight delivery buy Adderall over the counter for sale Adderall no prescriptions needed cod Adderall fed ex cheap overnight delivery of Adderall free prescription Adderall free shipping not expensive legal Adderall for sale buy Adderall cod Adderall for saturday Adderall price cash for Adderall cash on delivery Adderall Adderall without a prescription and cod delivery buying Adderall without a prescription order Adderall no rx buy Adderall without rx Adderall cheapest buy Adderall online pharmacy buy cheap Adderall overnight delivery Adderall and online pharmacy Adderall next day Adderall drug no prescription where can i buy Adderall no prescription Adderall with saturday delivery Adderall online overnight Adderall no prescription worldwide buy cheap Adderall cod ordering Adderall online Buy Adderall overnight shipping Adderall overnight US delivery cheap real Adderall for sale Adderall no prescriptions needed COD buy Adderall no prescription needed Adderall no prescription overnight cod delivery cheap Adderall cash on delivery no prescription required for Adderall order Adderall c.o.d. not expensive Adderall prescriptions Adderall online Cash on Delivery buy Adderall overnight delivery Adderall online without presciption buy Adderall prescription online no prescription saturday delivery Adderall where to buy cheap Adderall no prescription Adderall wo get Adderall over the counter fedex Adderall with no rx and free shipping order Adderall over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 12:04:06 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 09:04:06 -0800 (PST) Subject: Novartis pharmacies accepting cod delivery, buy no online prescription Novartis, Novartis no prescription usa fedex shipping Message-ID: <3c6e6a40-cdff-4dfd-8cfe-79508262d0a4@hv4g2000vbb.googlegroups.com> Novartis cheapest. Lowest prices for Novartis online. Buy Novartis online without no prescription. Buy cheap Novartis next day no prescription! Novartis BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Novartis <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Novartis http://buypharmasite.com/?q=Buy+online+Novartis http://buypharmasite.com/?q=Buy+order+Novartis http://buypharmasite.com/?q=Buy+Novartis http://buypharmasite.com/?q=Buy+cheap+Novartis http://buypharmasite.com/?q=Order+Novartis http://buypharmasite.com/?q=Online+Novartis cheap online pharmacy Novartis Novartis online saturday delivery online Novartis and fedex cheap order prescription Novartis cheap Novartis by money order buy Novartis from mexico online Novartis no prescription usa fedex shipping overnight delivery Novartis buy Novartis online without a prescription and no membership no prescription needed Novartis cod shipped Novartis not expensive order prescription Novartis Novartis money order Novartis without a perscription online buy Novartis Novartis fedex buy no online prescription Novartis Novartis pharmacies accepting cod delivery Novartis online consultant online pharmacy fedex cod Novartis buy Novartis no scams Novartis c.o.d overnight delivery buy Novartis no prescription cod overnight Novartis order Novartis online doctors buy Novartis on line no prescription Novartis no prescription usa fedex shipping Novartis online uk watson brand Novartis medicine online Novartis order Novartis samples sent buy Novartis no prescription order Novartis without a prescription Novartis no prescription drug cheap online order Novartis get Novartis over the counter online order Novartis next day buy Novartis no perscription cod real Novartis fed ex Novartis no prescription cod does cv/ pharmacy carry Novartis no prescription cod Novartis cheap Novartis without rx Novartis online health insurance lead buy Novartis online with overnight delivery Novartis no rx fed ex buy Novartis without a perscription lowest prices for Novartis online buy Novartis paypal online without prescription cheap non prescription Novartis Novartis ups Novartis for cheap buy Novartis no visa online without prescription cheapest Novartis cash on delivery Novartis order a prepaid mastercard buy online Novartis purchase Novartis mail order Novartis without a prescription online with overnight delivery Novartis from canada buy Novartis with no rx overnight delivery of Novartis with no prescription cash on delivery Novartis no rx Novartis by cod buy Novartis over the counter cod overnight overnight Novartis order Novartis without prescription from us pharmacy cheap Novartis free fedex shipping order Novartis over the counter where to buy Novartis no prescription no fees only Novartis free consult cod delivery Novartis Novartis no prescription Novartis online overnight delivery cod order Novartis over the counter fedex Novartis saturday delivery buy Novartis money order Novartis without prescription mexico buy cheap Novartis without prescription Novartis non prescription for next day delivery Novartis ups delivery only buy Novartis usa cod Novartis with next day delivery no prescriptions needed for Novartis cheap Novartis overnight prescription Novartis cheap Novartis overnight delivery Novartis non prescription fedex overnight free order Novartis no creditcard buy cheap Novartis no Prescription buy Novartis over the counter fedex Novartis no doctor presribe needed cheap watson Novartis online cheap discount Novartis buy Novartis without a prescription online cheapest Novartis free delivery buy Novartis online overseas buy Novartis over the counter online not expensive Novartis next day shipping order Novartis cod next day delivery Novartis cheap Novartis buy in UK Novartis next day cod fedex Novartis to buy cheap order Novartis next day Novartis Novartis overnight no consult cheap watson Novartis no prescription needed Novartis without prescription medications overnight delivery of Novartis with no perscription buy Novartis.com Novartis cod next day delivery buy cheap discount online Novartis buy Novartis drug Novartis overnight delivery cheap overnight delivery of Novartis in US no prescription needed purchase Novartis free next day airNovartis on line cheap Novartis without a prescription Novartis cheap cod Novartis buy no prepaid cheap Novartis next day buy Novartis cod accepted online pharmacies Novartis saturday delivery buy Novartis pay pal Novartis shipped on saturday Novartis pharmacy cod saturday delivery buy online Novartis prescriptions free fedex delivery Novartis Novartis without prescription cash on delivery buy discount Novartis Novartis overnight cheap best Novartis online pill images of Novartis Novartis U.P.S SHIPPING COD Novartis cod pharmacy buy Novartis online cod Novartis cod overnight delivery Novartis no rx overnight buy Novartis overnight COD online pharmacy Novartis cod order Novartis insurance Novartis cash delivery cod buy Novartis cheap cod no rx online pharmacy Novartis sale nextday Novartis Novartis pill Novartis online ordering Novartis online without prescription Novartis no script needed cod overnight how to buy Novartis online without a prescription cheap Novartis without prescription cheap Novartis online no rx saturday delivery order Novartis over the counter for sale Novartis next day delivery cod order Novartis online without prescription no prescription next day delivery Novartis overnight Novartis C.O.D Novartis without prescription Novartis discount fedex no prescription buy Novartis amex Novartis online next day Novartis shipped with no prescription Novartis online cheap cheap Novartis without prescription overnight delivery buy Novartis over the counter for sale Novartis no prescriptions needed cod Novartis fed ex cheap overnight delivery of Novartis free prescription Novartis free shipping not expensive legal Novartis for sale buy Novartis cod Novartis for saturday Novartis price cash for Novartis cash on delivery Novartis Novartis without a prescription and cod delivery buying Novartis without a prescription order Novartis no rx buy Novartis without rx Novartis cheapest buy Novartis online pharmacy buy cheap Novartis overnight delivery Novartis and online pharmacy Novartis next day Novartis drug no prescription where can i buy Novartis no prescription Novartis with saturday delivery Novartis online overnight Novartis no prescription worldwide buy cheap Novartis cod ordering Novartis online Buy Novartis overnight shipping Novartis overnight US delivery cheap real Novartis for sale Novartis no prescriptions needed COD buy Novartis no prescription needed Novartis no prescription overnight cod delivery cheap Novartis cash on delivery no prescription required for Novartis order Novartis c.o.d. not expensive Novartis prescriptions Novartis online Cash on Delivery buy Novartis overnight delivery Novartis online without presciption buy Novartis prescription online no prescription saturday delivery Novartis where to buy cheap Novartis no prescription Novartis wo get Novartis over the counter fedex Novartis with no rx and free shipping order Novartis over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 12:08:25 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 09:08:25 -0800 (PST) Subject: Methylphenidate non prescription fedex overnight free no prescriptions needed for Methylphenidate Methylphenidate without prescription mexico Message-ID: <30310bce-b34f-4e84-b20b-78aa531ca8e0@ek5g2000vbb.googlegroups.com> Methylphenidate cheapest. Lowest prices for Methylphenidate online. Buy Methylphenidate online without no prescription. Buy cheap Methylphenidate next day no prescription! Methylphenidate BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Methylphenidate <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Methylphenidate http://buypharmasite.com/?q=Buy+online+Methylphenidate http://buypharmasite.com/?q=Buy+order+Methylphenidate http://buypharmasite.com/?q=Buy+Methylphenidate http://buypharmasite.com/?q=Buy+cheap+Methylphenidate http://buypharmasite.com/?q=Order+Methylphenidate http://buypharmasite.com/?q=Online+Methylphenidate cheap online pharmacy Methylphenidate Methylphenidate online saturday delivery online Methylphenidate and fedex cheap order prescription Methylphenidate cheap Methylphenidate by money order buy Methylphenidate from mexico online Methylphenidate no prescription usa fedex shipping overnight delivery Methylphenidate buy Methylphenidate online without a prescription and no membership no prescription needed Methylphenidate cod shipped Methylphenidate not expensive order prescription Methylphenidate Methylphenidate money order Methylphenidate without a perscription online buy Methylphenidate Methylphenidate fedex buy no online prescription Methylphenidate Methylphenidate pharmacies accepting cod delivery Methylphenidate online consultant online pharmacy fedex cod Methylphenidate buy Methylphenidate no scams Methylphenidate c.o.d overnight delivery buy Methylphenidate no prescription cod overnight Methylphenidate order Methylphenidate online doctors buy Methylphenidate on line no prescription Methylphenidate no prescription usa fedex shipping Methylphenidate online uk watson brand Methylphenidate medicine online Methylphenidate order Methylphenidate samples sent buy Methylphenidate no prescription order Methylphenidate without a prescription Methylphenidate no prescription drug cheap online order Methylphenidate get Methylphenidate over the counter online order Methylphenidate next day buy Methylphenidate no perscription cod real Methylphenidate fed ex Methylphenidate no prescription cod does cv/ pharmacy carry Methylphenidate no prescription cod Methylphenidate cheap Methylphenidate without rx Methylphenidate online health insurance lead buy Methylphenidate online with overnight delivery Methylphenidate no rx fed ex buy Methylphenidate without a perscription lowest prices for Methylphenidate online buy Methylphenidate paypal online without prescription cheap non prescription Methylphenidate Methylphenidate ups Methylphenidate for cheap buy Methylphenidate no visa online without prescription cheapest Methylphenidate cash on delivery Methylphenidate order a prepaid mastercard buy online Methylphenidate purchase Methylphenidate mail order Methylphenidate without a prescription online with overnight delivery Methylphenidate from canada buy Methylphenidate with no rx overnight delivery of Methylphenidate with no prescription cash on delivery Methylphenidate no rx Methylphenidate by cod buy Methylphenidate over the counter cod overnight overnight Methylphenidate order Methylphenidate without prescription from us pharmacy cheap Methylphenidate free fedex shipping order Methylphenidate over the counter where to buy Methylphenidate no prescription no fees only Methylphenidate free consult cod delivery Methylphenidate Methylphenidate no prescription Methylphenidate online overnight delivery cod order Methylphenidate over the counter fedex Methylphenidate saturday delivery buy Methylphenidate money order Methylphenidate without prescription mexico buy cheap Methylphenidate without prescription Methylphenidate non prescription for next day delivery Methylphenidate ups delivery only buy Methylphenidate usa cod Methylphenidate with next day delivery no prescriptions needed for Methylphenidate cheap Methylphenidate overnight prescription Methylphenidate cheap Methylphenidate overnight delivery Methylphenidate non prescription fedex overnight free order Methylphenidate no creditcard buy cheap Methylphenidate no Prescription buy Methylphenidate over the counter fedex Methylphenidate no doctor presribe needed cheap watson Methylphenidate online cheap discount Methylphenidate buy Methylphenidate without a prescription online cheapest Methylphenidate free delivery buy Methylphenidate online overseas buy Methylphenidate over the counter online not expensive Methylphenidate next day shipping order Methylphenidate cod next day delivery Methylphenidate cheap Methylphenidate buy in UK Methylphenidate next day cod fedex Methylphenidate to buy cheap order Methylphenidate next day Methylphenidate Methylphenidate overnight no consult cheap watson Methylphenidate no prescription needed Methylphenidate without prescription medications overnight delivery of Methylphenidate with no perscription buy Methylphenidate.com Methylphenidate cod next day delivery buy cheap discount online Methylphenidate buy Methylphenidate drug Methylphenidate overnight delivery cheap overnight delivery of Methylphenidate in US no prescription needed purchase Methylphenidate free next day airMethylphenidate on line cheap Methylphenidate without a prescription Methylphenidate cheap cod Methylphenidate buy no prepaid cheap Methylphenidate next day buy Methylphenidate cod accepted online pharmacies Methylphenidate saturday delivery buy Methylphenidate pay pal Methylphenidate shipped on saturday Methylphenidate pharmacy cod saturday delivery buy online Methylphenidate prescriptions free fedex delivery Methylphenidate Methylphenidate without prescription cash on delivery buy discount Methylphenidate Methylphenidate overnight cheap best Methylphenidate online pill images of Methylphenidate Methylphenidate U.P.S SHIPPING COD Methylphenidate cod pharmacy buy Methylphenidate online cod Methylphenidate cod overnight delivery Methylphenidate no rx overnight buy Methylphenidate overnight COD online pharmacy Methylphenidate cod order Methylphenidate insurance Methylphenidate cash delivery cod buy Methylphenidate cheap cod no rx online pharmacy Methylphenidate sale nextday Methylphenidate Methylphenidate pill Methylphenidate online ordering Methylphenidate online without prescription Methylphenidate no script needed cod overnight how to buy Methylphenidate online without a prescription cheap Methylphenidate without prescription cheap Methylphenidate online no rx saturday delivery order Methylphenidate over the counter for sale Methylphenidate next day delivery cod order Methylphenidate online without prescription no prescription next day delivery Methylphenidate overnight Methylphenidate C.O.D Methylphenidate without prescription Methylphenidate discount fedex no prescription buy Methylphenidate amex Methylphenidate online next day Methylphenidate shipped with no prescription Methylphenidate online cheap cheap Methylphenidate without prescription overnight delivery buy Methylphenidate over the counter for sale Methylphenidate no prescriptions needed cod Methylphenidate fed ex cheap overnight delivery of Methylphenidate free prescription Methylphenidate free shipping not expensive legal Methylphenidate for sale buy Methylphenidate cod Methylphenidate for saturday Methylphenidate price cash for Methylphenidate cash on delivery Methylphenidate Methylphenidate without a prescription and cod delivery buying Methylphenidate without a prescription order Methylphenidate no rx buy Methylphenidate without rx Methylphenidate cheapest buy Methylphenidate online pharmacy buy cheap Methylphenidate overnight delivery Methylphenidate and online pharmacy Methylphenidate next day Methylphenidate drug no prescription where can i buy Methylphenidate no prescription Methylphenidate with saturday delivery Methylphenidate online overnight Methylphenidate no prescription worldwide buy cheap Methylphenidate cod ordering Methylphenidate online Buy Methylphenidate overnight shipping Methylphenidate overnight US delivery cheap real Methylphenidate for sale Methylphenidate no prescriptions needed COD buy Methylphenidate no prescription needed Methylphenidate no prescription overnight cod delivery cheap Methylphenidate cash on delivery no prescription required for Methylphenidate order Methylphenidate c.o.d. not expensive Methylphenidate prescriptions Methylphenidate online Cash on Delivery buy Methylphenidate overnight delivery Methylphenidate online without presciption buy Methylphenidate prescription online no prescription saturday delivery Methylphenidate where to buy cheap Methylphenidate no prescription Methylphenidate wo get Methylphenidate over the counter fedex Methylphenidate with no rx and free shipping order Methylphenidate over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 12:11:24 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 09:11:24 -0800 (PST) Subject: buy vicodin online without a prescription and no membership | vicodin no prescription usa fedex shipping Message-ID: <78b8fe50-3adc-498c-a02a-9947c06dce25@o19g2000vbk.googlegroups.com> vicodin cheapest. Lowest prices for vicodin online. Buy vicodin online without no prescription. Buy cheap vicodin next day no prescription! vicodin BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=vicodin <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=vicodin http://buypharmasite.com/?q=Buy+online+vicodin http://buypharmasite.com/?q=Buy+order+vicodin http://buypharmasite.com/?q=Buy+vicodin http://buypharmasite.com/?q=Buy+cheap+vicodin http://buypharmasite.com/?q=Order+vicodin http://buypharmasite.com/?q=Online+vicodin cheap online pharmacy vicodin vicodin online saturday delivery online vicodin and fedex cheap order prescription vicodin cheap vicodin by money order buy vicodin from mexico online vicodin no prescription usa fedex shipping overnight delivery vicodin buy vicodin online without a prescription and no membership no prescription needed vicodin cod shipped vicodin not expensive order prescription vicodin vicodin money order vicodin without a perscription online buy vicodin vicodin fedex buy no online prescription vicodin vicodin pharmacies accepting cod delivery vicodin online consultant online pharmacy fedex cod vicodin buy vicodin no scams vicodin c.o.d overnight delivery buy vicodin no prescription cod overnight vicodin order vicodin online doctors buy vicodin on line no prescription vicodin no prescription usa fedex shipping vicodin online uk watson brand vicodin medicine online vicodin order vicodin samples sent buy vicodin no prescription order vicodin without a prescription vicodin no prescription drug cheap online order vicodin get vicodin over the counter online order vicodin next day buy vicodin no perscription cod real vicodin fed ex vicodin no prescription cod does cv/ pharmacy carry vicodin no prescription cod vicodin cheap vicodin without rx vicodin online health insurance lead buy vicodin online with overnight delivery vicodin no rx fed ex buy vicodin without a perscription lowest prices for vicodin online buy vicodin paypal online without prescription cheap non prescription vicodin vicodin ups vicodin for cheap buy vicodin no visa online without prescription cheapest vicodin cash on delivery vicodin order a prepaid mastercard buy online vicodin purchase vicodin mail order vicodin without a prescription online with overnight delivery vicodin from canada buy vicodin with no rx overnight delivery of vicodin with no prescription cash on delivery vicodin no rx vicodin by cod buy vicodin over the counter cod overnight overnight vicodin order vicodin without prescription from us pharmacy cheap vicodin free fedex shipping order vicodin over the counter where to buy vicodin no prescription no fees only vicodin free consult cod delivery vicodin vicodin no prescription vicodin online overnight delivery cod order vicodin over the counter fedex vicodin saturday delivery buy vicodin money order vicodin without prescription mexico buy cheap vicodin without prescription vicodin non prescription for next day delivery vicodin ups delivery only buy vicodin usa cod vicodin with next day delivery no prescriptions needed for vicodin cheap vicodin overnight prescription vicodin cheap vicodin overnight delivery vicodin non prescription fedex overnight free order vicodin no creditcard buy cheap vicodin no Prescription buy vicodin over the counter fedex vicodin no doctor presribe needed cheap watson vicodin online cheap discount vicodin buy vicodin without a prescription online cheapest vicodin free delivery buy vicodin online overseas buy vicodin over the counter online not expensive vicodin next day shipping order vicodin cod next day delivery vicodin cheap vicodin buy in UK vicodin next day cod fedex vicodin to buy cheap order vicodin next day vicodin vicodin overnight no consult cheap watson vicodin no prescription needed vicodin without prescription medications overnight delivery of vicodin with no perscription buy vicodin.com vicodin cod next day delivery buy cheap discount online vicodin buy vicodin drug vicodin overnight delivery cheap overnight delivery of vicodin in US no prescription needed purchase vicodin free next day airvicodin on line cheap vicodin without a prescription vicodin cheap cod vicodin buy no prepaid cheap vicodin next day buy vicodin cod accepted online pharmacies vicodin saturday delivery buy vicodin pay pal vicodin shipped on saturday vicodin pharmacy cod saturday delivery buy online vicodin prescriptions free fedex delivery vicodin vicodin without prescription cash on delivery buy discount vicodin vicodin overnight cheap best vicodin online pill images of vicodin vicodin U.P.S SHIPPING COD vicodin cod pharmacy buy vicodin online cod vicodin cod overnight delivery vicodin no rx overnight buy vicodin overnight COD online pharmacy vicodin cod order vicodin insurance vicodin cash delivery cod buy vicodin cheap cod no rx online pharmacy vicodin sale nextday vicodin vicodin pill vicodin online ordering vicodin online without prescription vicodin no script needed cod overnight how to buy vicodin online without a prescription cheap vicodin without prescription cheap vicodin online no rx saturday delivery order vicodin over the counter for sale vicodin next day delivery cod order vicodin online without prescription no prescription next day delivery vicodin overnight vicodin C.O.D vicodin without prescription vicodin discount fedex no prescription buy vicodin amex vicodin online next day vicodin shipped with no prescription vicodin online cheap cheap vicodin without prescription overnight delivery buy vicodin over the counter for sale vicodin no prescriptions needed cod vicodin fed ex cheap overnight delivery of vicodin free prescription vicodin free shipping not expensive legal vicodin for sale buy vicodin cod vicodin for saturday vicodin price cash for vicodin cash on delivery vicodin vicodin without a prescription and cod delivery buying vicodin without a prescription order vicodin no rx buy vicodin without rx vicodin cheapest buy vicodin online pharmacy buy cheap vicodin overnight delivery vicodin and online pharmacy vicodin next day vicodin drug no prescription where can i buy vicodin no prescription vicodin with saturday delivery vicodin online overnight vicodin no prescription worldwide buy cheap vicodin cod ordering vicodin online Buy vicodin overnight shipping vicodin overnight US delivery cheap real vicodin for sale vicodin no prescriptions needed COD buy vicodin no prescription needed vicodin no prescription overnight cod delivery cheap vicodin cash on delivery no prescription required for vicodin order vicodin c.o.d. not expensive vicodin prescriptions vicodin online Cash on Delivery buy vicodin overnight delivery vicodin online without presciption buy vicodin prescription online no prescription saturday delivery vicodin where to buy cheap vicodin no prescription vicodin wo get vicodin over the counter fedex vicodin with no rx and free shipping order vicodin over the counter cod overnight From doctordr22 at gmail.com Sun Nov 6 12:14:28 2011 From: doctordr22 at gmail.com (Doctor Ibolet) Date: Sun, 6 Nov 2011 09:14:28 -0800 (PST) Subject: cheap Tramadol without prescription overnight delivery | order Tramadol online without prescription Message-ID: <1f306d71-a178-4905-9c88-69621b9765d9@gk10g2000vbb.googlegroups.com> Tramadol cheapest. Lowest prices for Tramadol online. Buy Tramadol online without no prescription. Buy cheap Tramadol next day no prescription! Tramadol BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Tramadol <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Tramadol http://buypharmasite.com/?q=Buy+online+Tramadol http://buypharmasite.com/?q=Buy+order+Tramadol http://buypharmasite.com/?q=Buy+Tramadol http://buypharmasite.com/?q=Buy+cheap+Tramadol http://buypharmasite.com/?q=Order+Tramadol http://buypharmasite.com/?q=Online+Tramadol cheap online pharmacy Tramadol Tramadol online saturday delivery online Tramadol and fedex cheap order prescription Tramadol cheap Tramadol by money order buy Tramadol from mexico online Tramadol no prescription usa fedex shipping overnight delivery Tramadol buy Tramadol online without a prescription and no membership no prescription needed Tramadol cod shipped Tramadol not expensive order prescription Tramadol Tramadol money order Tramadol without a perscription online buy Tramadol Tramadol fedex buy no online prescription Tramadol Tramadol pharmacies accepting cod delivery Tramadol online consultant online pharmacy fedex cod Tramadol buy Tramadol no scams Tramadol c.o.d overnight delivery buy Tramadol no prescription cod overnight Tramadol order Tramadol online doctors buy Tramadol on line no prescription Tramadol no prescription usa fedex shipping Tramadol online uk watson brand Tramadol medicine online Tramadol order Tramadol samples sent buy Tramadol no prescription order Tramadol without a prescription Tramadol no prescription drug cheap online order Tramadol get Tramadol over the counter online order Tramadol next day buy Tramadol no perscription cod real Tramadol fed ex Tramadol no prescription cod does cv/ pharmacy carry Tramadol no prescription cod Tramadol cheap Tramadol without rx Tramadol online health insurance lead buy Tramadol online with overnight delivery Tramadol no rx fed ex buy Tramadol without a perscription lowest prices for Tramadol online buy Tramadol paypal online without prescription cheap non prescription Tramadol Tramadol ups Tramadol for cheap buy Tramadol no visa online without prescription cheapest Tramadol cash on delivery Tramadol order a prepaid mastercard buy online Tramadol purchase Tramadol mail order Tramadol without a prescription online with overnight delivery Tramadol from canada buy Tramadol with no rx overnight delivery of Tramadol with no prescription cash on delivery Tramadol no rx Tramadol by cod buy Tramadol over the counter cod overnight overnight Tramadol order Tramadol without prescription from us pharmacy cheap Tramadol free fedex shipping order Tramadol over the counter where to buy Tramadol no prescription no fees only Tramadol free consult cod delivery Tramadol Tramadol no prescription Tramadol online overnight delivery cod order Tramadol over the counter fedex Tramadol saturday delivery buy Tramadol money order Tramadol without prescription mexico buy cheap Tramadol without prescription Tramadol non prescription for next day delivery Tramadol ups delivery only buy Tramadol usa cod Tramadol with next day delivery no prescriptions needed for Tramadol cheap Tramadol overnight prescription Tramadol cheap Tramadol overnight delivery Tramadol non prescription fedex overnight free order Tramadol no creditcard buy cheap Tramadol no Prescription buy Tramadol over the counter fedex Tramadol no doctor presribe needed cheap watson Tramadol online cheap discount Tramadol buy Tramadol without a prescription online cheapest Tramadol free delivery buy Tramadol online overseas buy Tramadol over the counter online not expensive Tramadol next day shipping order Tramadol cod next day delivery Tramadol cheap Tramadol buy in UK Tramadol next day cod fedex Tramadol to buy cheap order Tramadol next day Tramadol Tramadol overnight no consult cheap watson Tramadol no prescription needed Tramadol without prescription medications overnight delivery of Tramadol with no perscription buy Tramadol.com Tramadol cod next day delivery buy cheap discount online Tramadol buy Tramadol drug Tramadol overnight delivery cheap overnight delivery of Tramadol in US no prescription needed purchase Tramadol free next day airTramadol on line cheap Tramadol without a prescription Tramadol cheap cod Tramadol buy no prepaid cheap Tramadol next day buy Tramadol cod accepted online pharmacies Tramadol saturday delivery buy Tramadol pay pal Tramadol shipped on saturday Tramadol pharmacy cod saturday delivery buy online Tramadol prescriptions free fedex delivery Tramadol Tramadol without prescription cash on delivery buy discount Tramadol Tramadol overnight cheap best Tramadol online pill images of Tramadol Tramadol U.P.S SHIPPING COD Tramadol cod pharmacy buy Tramadol online cod Tramadol cod overnight delivery Tramadol no rx overnight buy Tramadol overnight COD online pharmacy Tramadol cod order Tramadol insurance Tramadol cash delivery cod buy Tramadol cheap cod no rx online pharmacy Tramadol sale nextday Tramadol Tramadol pill Tramadol online ordering Tramadol online without prescription Tramadol no script needed cod overnight how to buy Tramadol online without a prescription cheap Tramadol without prescription cheap Tramadol online no rx saturday delivery order Tramadol over the counter for sale Tramadol next day delivery cod order Tramadol online without prescription no prescription next day delivery Tramadol overnight Tramadol C.O.D Tramadol without prescription Tramadol discount fedex no prescription buy Tramadol amex Tramadol online next day Tramadol shipped with no prescription Tramadol online cheap cheap Tramadol without prescription overnight delivery buy Tramadol over the counter for sale Tramadol no prescriptions needed cod Tramadol fed ex cheap overnight delivery of Tramadol free prescription Tramadol free shipping not expensive legal Tramadol for sale buy Tramadol cod Tramadol for saturday Tramadol price cash for Tramadol cash on delivery Tramadol Tramadol without a prescription and cod delivery buying Tramadol without a prescription order Tramadol no rx buy Tramadol without rx Tramadol cheapest buy Tramadol online pharmacy buy cheap Tramadol overnight delivery Tramadol and online pharmacy Tramadol next day Tramadol drug no prescription where can i buy Tramadol no prescription Tramadol with saturday delivery Tramadol online overnight Tramadol no prescription worldwide buy cheap Tramadol cod ordering Tramadol online Buy Tramadol overnight shipping Tramadol overnight US delivery cheap real Tramadol for sale Tramadol no prescriptions needed COD buy Tramadol no prescription needed Tramadol no prescription overnight cod delivery cheap Tramadol cash on delivery no prescription required for Tramadol order Tramadol c.o.d. not expensive Tramadol prescriptions Tramadol online Cash on Delivery buy Tramadol overnight delivery Tramadol online without presciption buy Tramadol prescription online no prescription saturday delivery Tramadol where to buy cheap Tramadol no prescription Tramadol wo get Tramadol over the counter fedex Tramadol with no rx and free shipping order Tramadol over the counter cod overnight From gheskett at wdtv.com Sun Nov 6 13:14:43 2011 From: gheskett at wdtv.com (gene heskett) Date: Sun, 6 Nov 2011 13:14:43 -0500 Subject: Python lesson please Message-ID: <201111061314.43744.gheskett@wdtv.com> Greetings experts: I just dl'd the duqu driver finder script from a link to NSS on /., and fixed enough of the tabs in it to make it run error-free. At least python isn't having a litter of cows over the indentation now. But it also runs instantly on linux. This line looks suspect to me: rootdir = sys.argv[1] And I have a suspicion it is null on a linux box. How can I fix that best? Thanks. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Most of the fear that spoils our life comes from attacking difficulties before we get to them. -- Dr. Frank Crane From jfine at pytex.org Sun Nov 6 13:19:39 2011 From: jfine at pytex.org (Jonathan Fine) Date: Sun, 06 Nov 2011 18:19:39 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> Message-ID: <4EB6CFBB.2090901@pytex.org> On 06/11/11 16:42, Jakub Narebski wrote: > Jonathan Fine writes: > >> Hi >> >> This it to let you know that I'm writing (in Python) a script that >> places the content of CTAN into a git repository. >> https://bitbucket.org/jfine/python-ctantools > > I hope that you meant "repositories" (plural) here, one per tool, > rather than putting all of CTAN into single Git repository. There are complex dependencies among LaTeX macro packages, and TeX is often distributed and installed from a DVD. So it makes sense here to put *all* the content of a DVD into a repository. Once you've done that, it is then possible and sensible to select suitable interesting subsets, such as releases of a particular package. Users could even define their own subsets, such as "all resources needed to process this file, exactly as it processes on my machine". In addition, many TeX users have a TeX DVD. If they import it into a git repository (using for example my script) then the update from 2011 to 2012 would require much less bandwidth. Finally, I'd rather be working within git that modified copy of the ISO when doing the subsetting. I'm pretty sure that I can manage to pull the small repositories from the big git-CTAN repository. But as I proceed, perhaps I'll change my mind (smile). >> I'm working from the TeX Collection DVDs that are published each year >> by the TeX user groups, which contain a snapshot of CTAN (about >> 100,000 files occupying 4Gb), which means I have to unzip folders and >> do a few other things. > > There is 'contrib/fast-import/import-zips.py' in git.git repository. > If you are not using it, or its equivalent, it might be worth checking > out. Well, I didn't know about that. I took a look, and it doesn't do what I want. I need to walk the tree (on a mounted ISO) and unpack some (but not all) zip files as I come across them. For details see: https://bitbucket.org/jfine/python-ctantools/src/tip/ctantools/filetools.py In addition, I don't want to make a commit. I just want to make a ref at the end of building the tree. This is because I want the import of a TeX DVD to give effectively identical results for all users, and so any commit information would be effectively constant. >> CTAN is the Comprehensive TeX Archive Network. CTAN keeps only the >> latest version of each file, but old CTAN snapshots will provide many >> earlier versions. > > There was similar effort done in putting CPAN (Comprehensive _Perl_ > Archive Network) in Git, hosting repositories on GitHub[1], by the name > of gitPAN, see e.g.: > > "The gitPAN Import is Complete" > http://perlisalive.com/articles/36 > > [1]: https://github.com/gitpan This is really good to know!!! Not only has this been done already, for similar reasons, but github is hosting it. Life is easier when there is a good example to follow. >> I'm working on putting old CTAN files into modern version >> control. Martin Scharrer is working in the other direction. He's >> putting new files added to CTAN into Mercurial. >> http://ctanhg.scharrer-online.de/ > > Nb. thanks to tools such as git-hg and fast-import / fast-export > we have quite good interoperability and convertability between > Git and Mercurial. > > P.S. I'd point to reposurgeon tool, which can be used to do fixups > after import, but it would probably won't work on such large (set of) > repositories. Thank you for the pointer to reposurgeon. My approach is a bit different. First, get all the files into git, and then 'edit the tree' to create new trees. And then commit worthwhile new trees. As I recall the first 'commit' to the git repository for the Linux kernel was just a tree, with a reference to that tree as a tag. But no commit. > P.P.S. Can you forward it to comp.text.tex? Done. -- Jonathan From jfine at pytex.org Sun Nov 6 13:19:39 2011 From: jfine at pytex.org (Jonathan Fine) Date: Sun, 06 Nov 2011 18:19:39 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> Message-ID: <4EB6CFBB.2090901@pytex.org> On 06/11/11 16:42, Jakub Narebski wrote: > Jonathan Fine writes: > >> Hi >> >> This it to let you know that I'm writing (in Python) a script that >> places the content of CTAN into a git repository. >> https://bitbucket.org/jfine/python-ctantools > > I hope that you meant "repositories" (plural) here, one per tool, > rather than putting all of CTAN into single Git repository. There are complex dependencies among LaTeX macro packages, and TeX is often distributed and installed from a DVD. So it makes sense here to put *all* the content of a DVD into a repository. Once you've done that, it is then possible and sensible to select suitable interesting subsets, such as releases of a particular package. Users could even define their own subsets, such as "all resources needed to process this file, exactly as it processes on my machine". In addition, many TeX users have a TeX DVD. If they import it into a git repository (using for example my script) then the update from 2011 to 2012 would require much less bandwidth. Finally, I'd rather be working within git that modified copy of the ISO when doing the subsetting. I'm pretty sure that I can manage to pull the small repositories from the big git-CTAN repository. But as I proceed, perhaps I'll change my mind (smile). >> I'm working from the TeX Collection DVDs that are published each year >> by the TeX user groups, which contain a snapshot of CTAN (about >> 100,000 files occupying 4Gb), which means I have to unzip folders and >> do a few other things. > > There is 'contrib/fast-import/import-zips.py' in git.git repository. > If you are not using it, or its equivalent, it might be worth checking > out. Well, I didn't know about that. I took a look, and it doesn't do what I want. I need to walk the tree (on a mounted ISO) and unpack some (but not all) zip files as I come across them. For details see: https://bitbucket.org/jfine/python-ctantools/src/tip/ctantools/filetools.py In addition, I don't want to make a commit. I just want to make a ref at the end of building the tree. This is because I want the import of a TeX DVD to give effectively identical results for all users, and so any commit information would be effectively constant. >> CTAN is the Comprehensive TeX Archive Network. CTAN keeps only the >> latest version of each file, but old CTAN snapshots will provide many >> earlier versions. > > There was similar effort done in putting CPAN (Comprehensive _Perl_ > Archive Network) in Git, hosting repositories on GitHub[1], by the name > of gitPAN, see e.g.: > > "The gitPAN Import is Complete" > http://perlisalive.com/articles/36 > > [1]: https://github.com/gitpan This is really good to know!!! Not only has this been done already, for similar reasons, but github is hosting it. Life is easier when there is a good example to follow. >> I'm working on putting old CTAN files into modern version >> control. Martin Scharrer is working in the other direction. He's >> putting new files added to CTAN into Mercurial. >> http://ctanhg.scharrer-online.de/ > > Nb. thanks to tools such as git-hg and fast-import / fast-export > we have quite good interoperability and convertability between > Git and Mercurial. > > P.S. I'd point to reposurgeon tool, which can be used to do fixups > after import, but it would probably won't work on such large (set of) > repositories. Thank you for the pointer to reposurgeon. My approach is a bit different. First, get all the files into git, and then 'edit the tree' to create new trees. And then commit worthwhile new trees. As I recall the first 'commit' to the git repository for the Linux kernel was just a tree, with a reference to that tree as a tag. But no commit. > P.P.S. Can you forward it to comp.text.tex? Done. -- Jonathan From drsalists at gmail.com Sun Nov 6 15:00:59 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 6 Nov 2011 12:00:59 -0800 Subject: RSS feed creation? Message-ID: Is there an opensource Python tool for creating RSS feeds, that doesn't require large dependencies? I found feedformatter.py on pypi, but it seems a little old, and its sole automated test gives a traceback. Is there a better starting point? (I'd of course prefer something that'll run on 3.x and 2.x, but will settle for either) -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Sun Nov 6 15:21:12 2011 From: d at davea.name (Dave Angel) Date: Sun, 06 Nov 2011 15:21:12 -0500 Subject: Python lesson please In-Reply-To: <201111061314.43744.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> Message-ID: <4EB6EC38.20708@davea.name> On 11/06/2011 01:14 PM, gene heskett wrote: > Greetings experts: > > I just dl'd the duqu driver finder script from a link to NSS on /., and > fixed enough of the tabs in it to make it run error-free. At least python > isn't having a litter of cows over the indentation now. > > But it also runs instantly on linux. > > This line looks suspect to me: > rootdir = sys.argv[1] > > And I have a suspicion it is null on a linux box. > > How can I fix that best? > > Thanks. > > Cheers, Gene Nothing wrong with that line, assuming the user of the script happened to provide an argument for rootpath. Probably it should be preceded by a a conditional: if len(argv) <2: tell.user.that.she's.missing.the.rootdir.parameter else: rootdir = sys.argv[1] etc. What does the help text show when you run the script with the --help argument? -- DaveA From jnareb at gmail.com Sun Nov 6 15:28:33 2011 From: jnareb at gmail.com (Jakub Narebski) Date: 06 Nov 2011 21:28:33 +0100 Subject: A Python script to put CTAN into git (from DVDs) References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> Message-ID: Jonathan Fine writes: > On 06/11/11 16:42, Jakub Narebski wrote: >> Jonathan Fine writes: >> >>> This it to let you know that I'm writing (in Python) a script that >>> places the content of CTAN into a git repository. >>> https://bitbucket.org/jfine/python-ctantools >> >> I hope that you meant "repositories" (plural) here, one per tool, >> rather than putting all of CTAN into single Git repository. [moved] >> There was similar effort done in putting CPAN (Comprehensive _Perl_ >> Archive Network) in Git, hosting repositories on GitHub[1], by the name >> of gitPAN, see e.g.: >> >> "The gitPAN Import is Complete" >> http://perlisalive.com/articles/36 >> >> [1]: https://github.com/gitpan [/moved] > There are complex dependencies among LaTeX macro packages, and TeX is > often distributed and installed from a DVD. So it makes sense here to > put *all* the content of a DVD into a repository. Note that for gitPAN each "distribution" (usually but not always corresponding to single Perl module) is in separate repository. The dependencies are handled by CPAN / CPANPLUS / cpanm client (i.e. during install). Putting all DVD (is it "TeX Live" DVD by the way?) into single repository would put quite a bit of stress to git; it was created for software development (although admittedly of large project like Linux kernel), not 4GB+ trees. > Once you've done that, it is then possible and sensible to select > suitable interesting subsets, such as releases of a particular > package. Users could even define their own subsets, such as "all > resources needed to process this file, exactly as it processes on my > machine". This could be handled using submodules, by having superrepository that consist solely of references to other repositories by the way of submodules... plus perhaps some administrativa files (like README for whole CTAN, or search tool, or DVD install, etc.) This could be the used to get for example contents of DVD from 2010. But even though submodules (c.f. Subversion svn:external, Mecurial forest extension, etc.) are in Git for quite a bit of time, it doesn't have best user interface. > In addition, many TeX users have a TeX DVD. If they import it into a > git repository (using for example my script) then the update from 2011 > to 2012 would require much less bandwidth. ??? > Finally, I'd rather be working within git that modified copy of the > ISO when doing the subsetting. I'm pretty sure that I can manage to > pull the small repositories from the big git-CTAN repository. No you cannot. It is all or nothing; there is no support for partial _clone_ (yet), and it looks like it is a hard problem. Nb. there is support for partial _checkout_, but this is something different. > But as I proceed, perhaps I'll change my mind (smile). > >>> I'm working from the TeX Collection DVDs that are published each year >>> by the TeX user groups, which contain a snapshot of CTAN (about >>> 100,000 files occupying 4Gb), which means I have to unzip folders and >>> do a few other things. >> >> There is 'contrib/fast-import/import-zips.py' in git.git repository. >> If you are not using it, or its equivalent, it might be worth checking >> out. > > Well, I didn't know about that. I took a look, and it doesn't do what > I want. I need to walk the tree (on a mounted ISO) and unpack some > (but not all) zip files as I come across them. For details see: > https://bitbucket.org/jfine/python-ctantools/src/tip/ctantools/filetools.py > > In addition, I don't want to make a commit. I just want to make a ref > at the end of building the tree. This is because I want the import of > a TeX DVD to give effectively identical results for all users, and so > any commit information would be effectively constant. Commit = tree + parent + metadata. I think you would very much want to have linear sequence of trees, ordered via DAG of commits. "Naked" trees are rather bad idea, I think. > As I recall the first 'commit' to the git repository for the Linux > kernel was just a tree, with a reference to that tree as a tag. But > no commit. That was a bad accident that there is a tag that points directly to a tree of _initial import_, not something to copy. -- Jakub Nar?bski From jnareb at gmail.com Sun Nov 6 15:29:28 2011 From: jnareb at gmail.com (Jakub Narebski) Date: Sun, 06 Nov 2011 12:29:28 -0800 (PST) Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: <4EB6CFBB.2090901@pytex.org> References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> Message-ID: The following message is a courtesy copy of an article that has been posted to comp.lang.python,comp.text.tex as well. Jonathan Fine writes: > On 06/11/11 16:42, Jakub Narebski wrote: >> Jonathan Fine writes: >> >>> This it to let you know that I'm writing (in Python) a script that >>> places the content of CTAN into a git repository. >>> https://bitbucket.org/jfine/python-ctantools >> >> I hope that you meant "repositories" (plural) here, one per tool, >> rather than putting all of CTAN into single Git repository. [moved] >> There was similar effort done in putting CPAN (Comprehensive _Perl_ >> Archive Network) in Git, hosting repositories on GitHub[1], by the name >> of gitPAN, see e.g.: >> >> "The gitPAN Import is Complete" >> http://perlisalive.com/articles/36 >> >> [1]: https://github.com/gitpan [/moved] > There are complex dependencies among LaTeX macro packages, and TeX is > often distributed and installed from a DVD. So it makes sense here to > put *all* the content of a DVD into a repository. Note that for gitPAN each "distribution" (usually but not always corresponding to single Perl module) is in separate repository. The dependencies are handled by CPAN / CPANPLUS / cpanm client (i.e. during install). Putting all DVD (is it "TeX Live" DVD by the way?) into single repository would put quite a bit of stress to git; it was created for software development (although admittedly of large project like Linux kernel), not 4GB+ trees. > Once you've done that, it is then possible and sensible to select > suitable interesting subsets, such as releases of a particular > package. Users could even define their own subsets, such as "all > resources needed to process this file, exactly as it processes on my > machine". This could be handled using submodules, by having superrepository that consist solely of references to other repositories by the way of submodules... plus perhaps some administrativa files (like README for whole CTAN, or search tool, or DVD install, etc.) This could be the used to get for example contents of DVD from 2010. But even though submodules (c.f. Subversion svn:external, Mecurial forest extension, etc.) are in Git for quite a bit of time, it doesn't have best user interface. > In addition, many TeX users have a TeX DVD. If they import it into a > git repository (using for example my script) then the update from 2011 > to 2012 would require much less bandwidth. ??? > Finally, I'd rather be working within git that modified copy of the > ISO when doing the subsetting. I'm pretty sure that I can manage to > pull the small repositories from the big git-CTAN repository. No you cannot. It is all or nothing; there is no support for partial _clone_ (yet), and it looks like it is a hard problem. Nb. there is support for partial _checkout_, but this is something different. > But as I proceed, perhaps I'll change my mind (smile). > >>> I'm working from the TeX Collection DVDs that are published each year >>> by the TeX user groups, which contain a snapshot of CTAN (about >>> 100,000 files occupying 4Gb), which means I have to unzip folders and >>> do a few other things. >> >> There is 'contrib/fast-import/import-zips.py' in git.git repository. >> If you are not using it, or its equivalent, it might be worth checking >> out. > > Well, I didn't know about that. I took a look, and it doesn't do what > I want. I need to walk the tree (on a mounted ISO) and unpack some > (but not all) zip files as I come across them. For details see: > https://bitbucket.org/jfine/python-ctantools/src/tip/ctantools/filetools.py > > In addition, I don't want to make a commit. I just want to make a ref > at the end of building the tree. This is because I want the import of > a TeX DVD to give effectively identical results for all users, and so > any commit information would be effectively constant. Commit = tree + parent + metadata. I think you would very much want to have linear sequence of trees, ordered via DAG of commits. "Naked" trees are rather bad idea, I think. > As I recall the first 'commit' to the git repository for the Linux > kernel was just a tree, with a reference to that tree as a tag. But > no commit. That was a bad accident that there is a tag that points directly to a tree of _initial import_, not something to copy. -- Jakub Nar?bski From cs at zip.com.au Sun Nov 6 15:34:29 2011 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 7 Nov 2011 07:34:29 +1100 Subject: Python lesson please In-Reply-To: <201111061314.43744.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> Message-ID: <20111106203429.GA4790@cskk.homeip.net> On 06Nov2011 13:14, gene heskett wrote: | Greetings experts: | | I just dl'd the duqu driver finder script from a link to NSS on /., and | fixed enough of the tabs in it to make it run error-free. At least python | isn't having a litter of cows over the indentation now. | | But it also runs instantly on linux. | | This line looks suspect to me: | rootdir = sys.argv[1] | | And I have a suspicion it is null on a linux box. That line collects the first command line argument. sys.argv is the command line; argv[0] is the command name, argv[1] the first argument and so forth. Also, if there is no first argument then trying to access argv[1] will raise an IndexError exception, not return a null value. If you're this new to python, note that easy debugging statements can be written: print >>sys.stderr, "the value of foo is", foo and so forth. Perhaps more relevantly: If you have unmangled a lot of tabs, remember that control flow is indentation based in python, and you may have broken some logic. (For this reason a number of us set our editors to work only in spaces). Anyway, while changing: statement1 statement2 into: statement1 statement2 will usually make python complain, changing: if some test here: statement1 statement2 into: if some test here: statement1 statement2 just means that statement2 is no longer inside the if-statement, and elicit no compaints. But will elicit bugs! Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The ZZR-1100 is not the bike for me, but the day they invent "nerf" roads and ban radars I'll be the first in line......AMCN From gheskett at wdtv.com Sun Nov 6 18:10:03 2011 From: gheskett at wdtv.com (gene heskett) Date: Sun, 6 Nov 2011 18:10:03 -0500 Subject: Python lesson please In-Reply-To: <4EB6EC38.20708@davea.name> References: <201111061314.43744.gheskett@wdtv.com> <4EB6EC38.20708@davea.name> Message-ID: <201111061810.03728.gheskett@wdtv.com> On Sunday, November 06, 2011 06:07:36 PM Dave Angel did opine: > On 11/06/2011 01:14 PM, gene heskett wrote: > > Greetings experts: > > > > I just dl'd the duqu driver finder script from a link to NSS on /., > > and fixed enough of the tabs in it to make it run error-free. At > > least python isn't having a litter of cows over the indentation now. > > > > But it also runs instantly on linux. > > > > This line looks suspect to me: > > rootdir = sys.argv[1] > > > > And I have a suspicion it is null on a linux box. > > > > How can I fix that best? > > > > Thanks. > > > > Cheers, Gene > > Nothing wrong with that line, assuming the user of the script happened > to provide an argument for rootpath. Probably it should be preceded by > a a conditional: > > if len(argv) <2: > tell.user.that.she's.missing.the.rootdir.parameter > else: > rootdir = sys.argv[1] > etc. > > What does the help text show when you run the script with the --help > argument? It has no --help: [root at coyote gene]# ./duqu-drivers-detect.py --help [root at coyote gene]# Sorry. Thanks & Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Expedience is the best teacher. From devplayer at gmail.com Sun Nov 6 18:23:02 2011 From: devplayer at gmail.com (DevPlayer) Date: Sun, 6 Nov 2011 15:23:02 -0800 (PST) Subject: Usefulness of the "not in" operator References: <4e902932$0$23273$426a34cc@news.free.fr> <87ehyn8xlp.fsf@dpt-info.u-strasbg.fr> <4acd4e59-cf83-47f5-ac6c-ee0cbec8aa34@u13g2000vbx.googlegroups.com> <4e9a6614$0$29971$c3e8da3$5496439d@news.astraweb.com> Message-ID: <35178454-e3e3-4268-8841-8709c93a4719@g7g2000vbv.googlegroups.com> On Oct 16, 12:05?am, Steven D'Aprano wrote: > On Sat, 15 Oct 2011 15:04:24 -0700, DevPlayer wrote: > > I thought "x not in y" was later added as syntax sugar for "not x in y" > > meaning they used the same set of tokens. (Too lazy to check the actual > > tokens) Stated in response to OP wanting a seperate token for "not in" verse "is not". > Whether the compiler has a special token for "not in" is irrelevant. I don't know. > Perhaps it uses one token, or two, or none at all because a > pre-processor changes "x not in y" to "not x in y". That's > an implementation detail. I agree. > What's important is whether it is valid syntax or not, and how it is > implemented. I agree. > As it turns out, the Python compiler does not distinguish the two forms: > > >>> from dis import dis > >>> dis(compile('x not in y', '', 'single')) > > ? 1 ? ? ? ? ? 0 LOAD_NAME ? ? ? ? ? ? ? ?0 (x) > ? ? ? ? ? ? ? 3 LOAD_NAME ? ? ? ? ? ? ? ?1 (y) > ? ? ? ? ? ? ? 6 COMPARE_OP ? ? ? ? ? ? ? 7 (not in) > ? ? ? ? ? ? ? 9 PRINT_EXPR > ? ? ? ? ? ? ?10 LOAD_CONST ? ? ? ? ? ? ? 0 (None) > ? ? ? ? ? ? ?13 RETURN_VALUE ? ? ? ?>>> dis(compile('not x in y', '', 'single')) > > ? 1 ? ? ? ? ? 0 LOAD_NAME ? ? ? ? ? ? ? ?0 (x) > ? ? ? ? ? ? ? 3 LOAD_NAME ? ? ? ? ? ? ? ?1 (y) > ? ? ? ? ? ? ? 6 COMPARE_OP ? ? ? ? ? ? ? 7 (not in) > ? ? ? ? ? ? ? 9 PRINT_EXPR > ? ? ? ? ? ? ?10 LOAD_CONST ? ? ? ? ? ? ? 0 (None) > ? ? ? ? ? ? ?13 RETURN_VALUE So cool! Thanks for showing how to do that. I tried to say implementing a seperate method was not efficient. > Also for what it is worth, "x not in y" goes back to at least Python 1.5, > and possibly even older. (I don't have any older versions available to > test.) So "not in" was added as an alternative (just a long time ago). I too am glad they added it. > (2) Instead of writing "True if blah else False", write "bool(blah)". Good tip! I like. > > > class Y(object): > > ? ? def __contains__(self, x): > > ? ? ? ? for item in y: > > ? ? ? ? if x == y: > > ? ? ? ? ? ? return True > > ? ? ? ? return False > > You don't have to define a __contains__ method if you just want to test > each item sequentially. All you need is to obey the sequence protocol and > define a __getitem__ that works in the conventional way: Didn't intend to show how to implement __contains__ using "==" and __not_contains__ "<>" in python but to show that python didn't benefit from the not_in loop as much as for example assembly language does it's loop (x86 LOOPE/LOOPZ vs LOOPNZ/LOOPNE). > > >>> class Test: > > ... ? ? def __init__(self, args): > ... ? ? ? ? ? ? self._data = list(args) > ... ? ? def __getitem__(self, i): > ... ? ? ? ? ? ? return self._data[i] > ...>>> t = Test("abcde") > >>> "c" in t > True > >>> "x" in t > False Another new thing for me. > > Defining a specialist __contains__ method is only necessary for non- > sequences, or if you have some fast method for testing whether an item is > in the object quickly. If all you do is test each element one at a time, > in numeric order, don't bother writing __contains__. > > > And if you wanted "x not in y" to be a different token you'd have to ADD > > Tokens are irrelevant. "x not in y" is defined to be the same as "not x > in y" no matter what. > You can't define "not in" to do something completely different. I agree they are not implemented differently. I agree that they shouldn't be implemented differently. I disagree they can not be implemented differently. I think they can. But I see no reason too. > > class Y(object): > > ? ? def __not_contained__(self, x): > > ? ? ? ? for item in self: > > ? ? ? ? ? ? if x == y: > > ? ? ? ? ? ? ? ? return False > > ? ? ? ? return True > > > AND with __not_contained__() you'd always have to iterate the entire > > sequence to make sure even the last item doesn't match. > > SO with one token "x not in y" you DON'T have to itterate through the > > entire sequence thus it is more effiecient. > That's not correct. > Steven I tried to prove my point and failded and instead proved (to myself) you are correct. It is not more efficient. Also I should have used if <> y: continue to have better tried to make the point but it wouldn't have mattered. I still would have been wrong. But I did walk away from this topic with some goodie tips. Thanks Steven. From d at davea.name Sun Nov 6 18:27:23 2011 From: d at davea.name (Dave Angel) Date: Sun, 06 Nov 2011 18:27:23 -0500 Subject: Python lesson please In-Reply-To: <201111061810.03728.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <4EB6EC38.20708@davea.name> <201111061810.03728.gheskett@wdtv.com> Message-ID: <4EB717DB.2000303@davea.name> On 11/06/2011 06:10 PM, gene heskett wrote: > On Sunday, November 06, 2011 06:07:36 PM Dave Angel did opine: > >> On 11/06/2011 01:14 PM, gene heskett wrote: >>> Greetings experts: >>> >>> I just dl'd the duqu driver finder script from a link to NSS on /., >>> and fixed enough of the tabs in it to make it run error-free. At >>> least python isn't having a litter of cows over the indentation now. >>> >>> But it also runs instantly on linux. >>> >>> This line looks suspect to me: >>> rootdir = sys.argv[1] >>> >>> And I have a suspicion it is null on a linux box. >>> >>> How can I fix that best? >>> >>> Thanks. >>> >>> Cheers, Gene >> >> Nothing wrong with that line, assuming the user of the script happened >> to provide an argument for rootpath. Probably it should be preceded by >> a a conditional: >> >> if len(argv)<2: >> tell.user.that.she's.missing.the.rootdir.parameter >> else: >> rootdir = sys.argv[1] >> etc. >> >> What does the help text show when you run the script with the --help >> argument? > > It has no --help: > [root at coyote gene]# ./duqu-drivers-detect.py --help > [root at coyote gene]# > > Sorry. > > Thanks& Cheers, Gene So is there any documentation? If not, your first job is to guess what it's supposed to do, figure out if you care, and then document it. In the process you'll probably find a few bugs. First bug is it silently quits when you run it with no arguments. Is that true? If so, figure out where it quits, since it clearly never reaches the line you quote. Actually I'd probably start with the assumption that you might have messed up the tab expansion somewhere. How did you expand the tabs? Perhaps by using the Linux expands utility? Or did you do it manually? -- DaveA From fraveydank at gmail.com Sun Nov 6 18:54:46 2011 From: fraveydank at gmail.com (David Riley) Date: Sun, 6 Nov 2011 18:54:46 -0500 Subject: Python lesson please In-Reply-To: <20111106203429.GA4790@cskk.homeip.net> References: <201111061314.43744.gheskett@wdtv.com> <20111106203429.GA4790@cskk.homeip.net> Message-ID: <2FF5E7E0-B119-4906-91A7-93A095E8D620@gmail.com> On Nov 6, 2011, at 3:34 PM, Cameron Simpson wrote: > Perhaps more relevantly: > > If you have unmangled a lot of tabs, remember that control flow is > indentation based in python, and you may have broken some logic. > (For this reason a number of us set our editors to work only in spaces). I would absolutely check this first. I can't count the number of programs I've screwed up in difficult-to-detect ways because I've converted from tabs to spaces incorrectly. It's how I've finally learned to let a program/script do it for me, because Python is the first language I've used with significant leading whitespace. - Dave From jiayuaw at yahoo.com.sg Sun Nov 6 20:26:43 2011 From: jiayuaw at yahoo.com.sg (Kristen Aw) Date: Mon, 7 Nov 2011 09:26:43 +0800 (SGT) Subject: question about Tkinter delete Message-ID: <1320629203.53499.YahooMailNeo@web77904.mail.sg1.yahoo.com> Hi all I don't understand why I get this error. I'm trying to delete the existing points, then redraw them after this bit of code to 'animate' my simulation. def update(self, point1, point2): ? ? ? ? # Deletes existing points ? ? ? ? if self.point1: ? ? ? ? ? ? self.w.delete(point1) ? ? ? ? ? ? self.master.update_idletasks() ? ? ? ? if self.point2: ? ? ? ? ? ? self.w.delete(point2) ? ? ? ? ? ? self.master.update_idletasks() #draw new point # . . . The error message that I get is: . . .?in update ? ? self.w.delete(point1) ? File "C:\PYTHON26\LIB\LIB-TK\Tkinter.py", line 2181, in delete ? ? self.tk.call((self._w, 'delete') + args) TclError: invalid command name ".44593760" -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Sun Nov 6 21:54:16 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Nov 2011 02:54:16 GMT Subject: Python lesson please References: Message-ID: <4eb74858$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sun, 06 Nov 2011 13:14:43 -0500, gene heskett wrote: > I just dl'd the duqu driver finder script from a link to NSS on /., and > fixed enough of the tabs in it to make it run error-free. At least > python isn't having a litter of cows over the indentation now. Presumably the script should be working. If it is known to be not working, then you probably need to fix a lot more than just indentation. If this is "pre-alpha, doesn't even compile" software, then good luck, you'll need to read the source and understand it to make it work. It's not sufficient to just get it to a point where you can say "Cool, it compiles!" by fixing some indentation. If this is supposed to be working, there's a reason why it's not working for you. Perhaps you are trying to use it with the wrong version of Python. Perhaps the download is corrupted. Fix those before mangling indentation in random ways: start with a fresh, uncorrupted download. Check that the md5 sum matches that provided by the download site (assuming they provide one). Find out what version of Python is supported, and use that. > This line looks suspect to me: > rootdir = sys.argv[1] What makes you think that line is suspect? It looks fine to me. > And I have a suspicion it is null on a linux box. This is Python, not bash. Sys arguments are not filled in with "null", whatever you think "null" is. (The None built-in? The empty string?) Have you tried giving the script an argument when you call it? If in doubt, call it with "." (the current directory) as argument. My wild guess is that you actually need to supply a meaningful directory path before the script will do anything, and until then, it will silently fail. Which is terrible design. > How can I fix that best? If it's not broken, it doesn't need to be fixed. Don't make assumptions about what code needs to be fixed based on nothing more than gut feeling. -- Steven From kwa at kuwata-lab.com Sun Nov 6 23:12:58 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Mon, 7 Nov 2011 13:12:58 +0900 Subject: [ANN] Oktest.py 0.10.0 released - a new-style testing library Message-ID: Hi, I released Oktest.py 0.10.0. http://packages.python.org/Oktest/ http://www.kuwata-lab.com/oktest/ Oktest.py is a new-style testing library for Python. :: from oktest import ok, NG ok (x) > 0 # same as assertTrue(x > 0) ok (s) == 'foo' # same as assertEqual(s, 'foo') ok (s) != 'foo' # same as assertNotEqual(s, 'foo') ok (f).raises(ValueError) # same as assertRaises(ValueError, f) ok (u'foo').is_a(unicode) # same as assertTrue(isinstance(u'foo', unicode)) NG (u'foo').is_a(int) # same as assertTrue(not isinstance(u'foo', int)) ok ('A.txt').is_file() # same as assertTrue(os.path.isfile('A.txt')) NG ('A.txt').is_dir() # same as assertTrue(not os.path.isdir('A.txt')) See http://www.kuwata-lab.com/oktest/oktest-py_users-guide.html for details. Changes and Enhancements ------------------------ * [change] 'oktest.spec()' is obsoleted completely. It will print warning message if you use it. * [change] 'oktest.helper' module is renamed to 'oktest.util'. ('oktest.helper' is still available for backward compabibility.) * [enhance] Add 'oktest.main()' which is a replacement of 'oktest.run()'. Using 'oktest.main()' instead of 'oktest.run()', command options are available. ex:: ## for example: $ python test/foobar_test.py -sp -f test='*keyword*' ## is almost same as: $ python -m oktest test/foobar_test.py -sp -f test='*keyword*' * [enhance] Add 'oktest.fail(message)' which is same as 'unittest.fail(message)'. ex:: from oktest import fail fail("not impelmented yet") # will raise AssertionError * [enhance] (Experimental) Add '@todo' decorator which is equivarent to '@unittest.expectedFailure'. ex:: from oktest import ok, test, todo def add(x, y): return 0 # not implemented yet! class AddTest(unittest.TestCase): @test("returns sum of arguments.") @todo # equivarent to @unittest.expectedFailure def _(self): ok (10, 20) == 30 ## will be failed expectedly ## (because not implemented yet) Expected failure of assertion is reported as '[TODO]', not '[Failed]'. * [enhance] (Experimental) Test context supported. It helps you to describe specification in structured style. ex:: from oktest import ok, test from oktest.context import subject, situation class SampleTestCase(unittest.TestCase): SUBJECT = "class 'Sample'" with subject("method1()"): with situation("when condition:"): @test("spec1") def _(self): ... @test("spec2") def _(self): ... with situation("else:"): @test("spec3") def _(self): ... Output exmple:: $ python test/example_test.py * class 'Sample' + method1() + when condition: - [ok] spec1 - [ok] spec2 + else: - [ok] spec3 ## total:3, passed:3, failed:0, error:0, skipped:0 (elapsed 0.000) -- regards, makoto kuwata From nagle at animats.com Mon Nov 7 01:04:43 2011 From: nagle at animats.com (John Nagle) Date: Sun, 06 Nov 2011 22:04:43 -0800 Subject: Question about 'iterable cursors' In-Reply-To: References: <87pqh54nmh.fsf@dpt-info.u-strasbg.fr> Message-ID: <4eb77503$0$1692$742ec2ed@news.sonic.net> On 11/6/2011 12:04 PM, Dennis Lee Bieber wrote: > On Sun, 6 Nov 2011 11:39:56 +0200, "Frank Millman" > declaimed the following in gmane.comp.python.general: > >> >> So my analysis of the problem is correct, but my solution is wrong. >> >> Instead of executing fetchall() and returning the connection, I should >> retain the connection until I have exhausted the cursor. >> >> That makes a lot of sense. >> > Especially if all you are processing are read-only activities. > > If you have a connection/cursor doing write operations, you may not > be able to commit those writes until all reading cursors have closed. > (Read the documentation on the SQLite3 locking system -- though the > newest version has added a second type of locking which may complicate > the matter. The original/normal scheme has potential readers "outside" > SQLite3, active readers "inside" SQLite3 -- when an active reader cursor > advances to a pending write, it blocks all the potential readers from > entering, but is itself blocked until all other active readers have > exited) Right. The scarce resource is database locks, not connections. Especially with SQLite, which has, by necessity, a rather brutal locking strategy. Realize that SQLite is not a high-performance multi-user database. You use SQLite to store your browser preferences, not your customer database. If you're doing enough transactions from multiple processes that performance is an issue, you need to move up to MySQL or Postgres. If almost all transactions are SELECTs, performance may not be too bad, but if there are INSERT and UPDATE transactions on the same table, performance will be awful. John Nagle From mcepl at redhat.com Mon Nov 7 01:50:36 2011 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 07 Nov 2011 07:50:36 +0100 Subject: How to undo a Python setuptools --prefix path blunder In-Reply-To: <543f5b85-1248-4039-a12d-5bbcb2fb0f51@o19g2000vbk.googlegroups.com> References: <543f5b85-1248-4039-a12d-5bbcb2fb0f51@o19g2000vbk.googlegroups.com> Message-ID: Dne 6.11.2011 14:18, Kev napsal(a): > Again the wrong path is being used to create the symbolic link to > where virtualenv is installed: http://packages.python.org/distribute/easy_install.html#administrator-installation for list of additional configuration files which might go wrong (namely *.pth and distutils.cfg). Is that it? Mat?j From stefan_ml at behnel.de Mon Nov 7 02:22:37 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Nov 2011 08:22:37 +0100 Subject: RSS feed creation? In-Reply-To: References: Message-ID: Dan Stromberg, 06.11.2011 21:00: > Is there an opensource Python tool for creating RSS feeds, that doesn't > require large dependencies? > > I found feedformatter.py on pypi, but it seems a little old, and its sole > automated test gives a traceback. > > Is there a better starting point? > > (I'd of course prefer something that'll run on 3.x and 2.x, but will settle > for either) I'd just go with ElementTree and builder.py. http://effbot.org/zone/element-builder.htm http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py Building an RSS-API on top of that is so trivial that it's not worth any further dependencies anyway. Not sure if this version of builder.py runs in Py3, but it certainly won't be hard to fix even if it doesn't currently. Stefan From stefan_ml at behnel.de Mon Nov 7 03:24:59 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Nov 2011 09:24:59 +0100 Subject: RSS feed creation? In-Reply-To: References: Message-ID: Stefan Behnel, 07.11.2011 08:22: > Dan Stromberg, 06.11.2011 21:00: >> Is there an opensource Python tool for creating RSS feeds, that doesn't >> require large dependencies? >> >> I found feedformatter.py on pypi, but it seems a little old, and its sole >> automated test gives a traceback. >> >> Is there a better starting point? >> >> (I'd of course prefer something that'll run on 3.x and 2.x, but will settle >> for either) > > I'd just go with ElementTree and builder.py. > > http://effbot.org/zone/element-builder.htm > > http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py Hmm, interesting, that last link doesn't seem to work for me anymore. Here's a copy, however: http://svn.effbot.org/public/stuff/sandbox/elementlib/builder.py There's also an extended version for lxml.etree: https://raw.github.com/lxml/lxml/master/src/lxml/builder.py You'll quickly see if it works as expected with plain ET when you use it. It should in general. > Building an RSS-API on top of that is so trivial that it's not worth any > further dependencies anyway. Not sure if this version of builder.py runs in > Py3, but it certainly won't be hard to fix even if it doesn't currently. Stefan From __peter__ at web.de Mon Nov 7 04:00:02 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 10:00:02 +0100 Subject: Python lesson please References: <201111061314.43744.gheskett@wdtv.com> Message-ID: gene heskett wrote: > Greetings experts: > > I just dl'd the duqu driver finder script from a link to NSS on /., and > fixed enough of the tabs in it to make it run error-free. At least python > isn't having a litter of cows over the indentation now. > > But it also runs instantly on linux. > > This line looks suspect to me: > rootdir = sys.argv[1] > > And I have a suspicion it is null on a linux box. > > How can I fix that best? Are you talking about this one? https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns.py With a current checkout I don't get any tab-related (nor other) errors, so I would prefer to run the script as-is. Also, the README clearly states that you have to invoke it with python DuquDriverPatterns.py ./directoryOfMalware and the line you are quoting then puts the value "./directoryOfMalware" into the rootdir variable. If you want to normalize the code to 4-space indents I recomment that you use http://hg.python.org/cpython/file/bbc929bc2224/Tools/scripts/reindent.py On Ubuntu (and probably any other Debian-based distro) you'll find a version of that in /usr/share/doc/python2.6/examples/Tools/scripts/reindent.py or similar once you've installed the python-examples package. From __peter__ at web.de Mon Nov 7 04:22:28 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 10:22:28 +0100 Subject: question about Tkinter delete References: <1320629203.53499.YahooMailNeo@web77904.mail.sg1.yahoo.com> Message-ID: Kristen Aw wrote: > I don't understand why I get this error. I'm trying to delete the existing points, then redraw them after this bit of code to 'animate' my simulation. > > def update(self, point1, point2): > # Deletes existing points > if self.point1: > self.w.delete(point1) > self.master.update_idletasks() > if self.point2: > self.w.delete(point2) > self.master.update_idletasks() > #draw new point > # . . . > > The error message that I get is: > . . . in update > self.w.delete(point1) > File "C:\PYTHON26\LIB\LIB-TK\Tkinter.py", line 2181, in delete > self.tk.call((self._w, 'delete') + args) > TclError: invalid command name ".44593760" Your snippet and your problem description are both a bit short to be sure. Is self.w a Tkinter.Canvas widget? It seems the canvas doesn't exist anymore when you're trying to delete objects on it. Here's a demonstration: >>> import Tkinter as tk >>> root = tk.Tk() >>> canvas = tk.Canvas(root, height=100, width=100) >>> canvas.delete("123") >>> canvas.destroy() >>> canvas.delete("123") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 2184, in delete self.tk.call((self._w, 'delete') + args) _tkinter.TclError: invalid command name ".139675427025264" From gheskett at wdtv.com Mon Nov 7 06:22:39 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 06:22:39 -0500 Subject: Python lesson please In-Reply-To: References: <201111061314.43744.gheskett@wdtv.com> Message-ID: <201111070622.39473.gheskett@wdtv.com> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > gene heskett wrote: > > Greetings experts: > > > > I just dl'd the duqu driver finder script from a link to NSS on /., > > and fixed enough of the tabs in it to make it run error-free. At > > least python isn't having a litter of cows over the indentation now. > > > > But it also runs instantly on linux. > > > > This line looks suspect to me: > > rootdir = sys.argv[1] > > > > And I have a suspicion it is null on a linux box. > > > > How can I fix that best? > > Are you talking about this one? > > https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns > .py Yes. My save as renamed it, still has about 30k of tabs in it. But I pulled it again, using the 'raw' link, saved it, no extra tabs. But it still doesn't work for linux. My python is 2.6.6 > With a current checkout I don't get any tab-related (nor other) errors, > so I would prefer to run the script as-is. Also, the README clearly > states that you have to invoke it with > > python DuquDriverPatterns.py ./directoryOfMalware > > and the line you are quoting then puts the value "./directoryOfMalware" > into the rootdir variable. If only it would... Using this version, the failure is silent and instant. Besides, the malware could be anyplace on the system. But it needs to skip /dev since it hangs on the midi tree, /mnt and /media because they are not part of the running system even if disks are mounted there. > If you want to normalize the code to 4-space indents I recomment that > you use > > http://hg.python.org/cpython/file/bbc929bc2224/Tools/scripts/reindent.py Got it, where does it normally live? I apparently have a python-2.6.6 install. > On Ubuntu (and probably any other Debian-based distro) you'll find a > version of that in > PCLos is rpm based, lots of mandriva stuff in it. > /usr/share/doc/python2.6/examples/Tools/scripts/reindent.py > Path does not exist. Ends at /usr/share/doc from there I have: gene at coyote doc]$ ls|grep python gimp-python-2.6.11/ gnome-python-gconf-2.28.1/ gnome-python-gnomeprint-2.32.0/ gnome-python-gtksourceview-2.32.0/ libxml2-python-2.7.8/ python-2.6.6/ python3-3.2.1/ python3-docs-3.2.1/ python-cairo-1.10.0/ python-configobj-4.7.2/ python-decorator-3.3.1/ python-docs-2.6.6/ python-enchant-1.5.3/ python-gobject-2.28.6/ python-gpgme-0.1/ python-gtksourceview-2.10.0/ python-libxml2dom-0.4.7/ python-lxml-2.2.8/ python-markupsafe-0.9.3/ python-notify-0.1.1/ python-paramiko-1.7.6/ python-paste-1.7.4/ python-pkg-resources-0.6c11/ python-psyco-1.6/ python-pybluez-0.18/ python-pycrypto-2.3/ python-pygments-1.3.1/ python-pytools-2011.3/ python-pyxml-0.8.4/ python-rhpl-0.212/ python-sexy-0.1.9/ python-simpletal-4.2/ python-sympy-0.6.7/ python-utmp-0.8/ The python-2.6.6 and 3.2.1 directories only contain a README.mdv > or similar once you've installed the python-examples package. On PCLos it doesn't even exist in the repo's. Good links, thank you. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: "Elvis is my copilot." -- Cal Keegan From gabor.farkas at gmail.com Mon Nov 7 07:53:05 2011 From: gabor.farkas at gmail.com (=?ISO-8859-1?Q?G=E1bor_Farkas?=) Date: Mon, 7 Nov 2011 13:53:05 +0100 Subject: logging: handle everything EXCEPT certain loggers Message-ID: hi, is there a way to setup log-handlers in a way that they log logs from every logger, exept certain ones? basically i want the handler to handle everything, except log-records that were generated by loggers from "something.*" can this be done? i tried to create filters, but the log-record does not have access to his logger, so i cannot filter based on it's "path". right now the only idea i have is to setup a filter for the "something.*" path, have it mark somehow the log-records, and then create a filter on the global level, that will drop such log-records. is there a simpler solution? thanks, gabor From andreas.perstinger at gmx.net Mon Nov 7 08:14:05 2011 From: andreas.perstinger at gmx.net (Andreas Perstinger) Date: Mon, 07 Nov 2011 14:14:05 +0100 Subject: Python lesson please In-Reply-To: <201111070622.39473.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> Message-ID: <4EB7D99D.5010604@gmx.net> On 2011-11-07 12:22, gene heskett wrote: > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: >> Are you talking about this one? >> >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns >> .py > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > pulled it again, using the 'raw' link, saved it, no extra tabs. > > But it still doesn't work for linux. My python is 2.6.6 Go to the directory where you've downloaded the file and type: python DuquDriverPatterns.py . What output do you get? Bye, Andreas From d at davea.name Mon Nov 7 08:30:15 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 08:30:15 -0500 Subject: Python lesson please In-Reply-To: <201111070622.39473.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> Message-ID: <4EB7DD67.5070606@davea.name> On 11/07/2011 06:22 AM, gene heskett wrote: > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > >> Are you talking about this one? >> >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns >> .py > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > pulled it again, using the 'raw' link, saved it, no extra tabs. > > But it still doesn't work for linux. My python is 2.6.6 > To start with, what's the md5 of the file you downloaded and are testing? I get c4592a187f8f7880d3b685537e3bf9a5 from md5sum. If you get something different, one of us changed the file, or you got it before today. The whole tab issue is a red-herring in this case. But I don't see how you can find 30k tabs in a thousand lines. And if I were going to detab it, I'd pick 4 spaces, so the code doesn't stretch across the page. > >> python DuquDriverPatterns.py ./directoryOfMalware >> >> and the line you are quoting then puts the value "./directoryOfMalware" >> into the rootdir variable. > If only it would... Using this version, the failure is silent and instant. > Besides, the malware could be anyplace on the system. But it needs to skip > /dev since it hangs on the midi tree, /mnt and /media because they are not > part of the running system even if disks are mounted there. > First, run it on the current directory, and it should list the files in that directory: I ran it in the directory I unzipped it into, so there are two files, the README and the source file itself. $ python DuquDriverPatterns.py . Scanning ./README: No match for pattern #0 on file named: README No match for pattern #1 on file named: README No match for pattern #2 on file named: README etc. The only way I can see to get NO output is to run it on an empty directory: $mkdir junk $ python DuquDriverPatterns.py junk As for skipping certain directories, we can deal with that as soon as you get proper behavior for any subtree of directories. Have you tried adding a print ("Hello World " + rootdir) just before the for root, subFolders, files in os.walk(rootdir): line ? Or putting a print len(files) just after it (indented, of course) ? -- DaveA From jeanmichel at sequans.com Mon Nov 7 08:39:17 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 07 Nov 2011 14:39:17 +0100 Subject: logging: handle everything EXCEPT certain loggers In-Reply-To: References: Message-ID: <4EB7DF85.7060909@sequans.com> G?bor Farkas wrote: > hi, > > is there a way to setup log-handlers in a way that they log logs from > every logger, exept certain ones? > > basically i want the handler to handle everything, except log-records > that were generated by loggers from "something.*" > can this be done? > > i tried to create filters, but the log-record does not have access to > his logger, so i cannot filter based on it's "path". > > right now the only idea i have is to setup a filter for the > "something.*" path, have it mark somehow the log-records, > and then create a filter on the global level, that will drop such > log-records. is there a simpler solution? > > thanks, > gabor > Are you sure ? LogRecord objects have a name attribute. You could do something like return 'IdontWantYou' not in record.name in your filter. JM From huhai101 at gmail.com Mon Nov 7 09:02:57 2011 From: huhai101 at gmail.com (wholesale nfl) Date: Mon, 7 Nov 2011 06:02:57 -0800 (PST) Subject: (www.nike-black.com) cheap wholesale nfl jerseys, mlb jerseys , nhl jerseys, nba jerseys Message-ID: <36edf286-d093-4ed4-9d96-15e8ad8a43ff@i13g2000prg.googlegroups.com> (www.nike-black.com) cheap wholesale nfl jerseys, mlb jerseys , nhl jerseys, nba jerseys NFL Football Jerseys 2011 Super Bowl NFL Hats NCAA Jerseys Customized NFL Jerseys Hot NFL Jerseys (www.nike-black.com) Women NFL Jerseys Youth NFL Jerseys Super Bowl Jerseys Pro Bowl Jerseys New NFL Jerseys Arizona Cardinals (www.nike-black.com) Atlanta Falcons Baltimore Ravens Buffalo Bills Carolina Panthers Chicago Bears Cincinnati Bengals Cleveland Browns (www.nike-black.com) Dallas Cowboys Denver Broncos Detroit Lions Green Bay Packers Houston Texans Indianapolis Colts (www.nike-black.com) Jacksonville Jaguars Kansas City Chiefs Miami Dolphins Minnesota Vikings New England Patriots New Orleans Saints New York Giants New York Jets Oakland Raiders Philadelphia Eagles (www.nike-black.com) Pittsburgh Steelers San Diego Chargers San Francisco 49ers Seattle Seahawks (www.nike-black.com) St.Louis Rams Tampa Bay Buccaneers Tennessee Titans Washington Redskins website: http://www.nike-black.com From huhai101 at gmail.com Mon Nov 7 09:02:57 2011 From: huhai101 at gmail.com (wholesale nfl) Date: Mon, 7 Nov 2011 06:02:57 -0800 (PST) Subject: (www.nike-black.com) cheap wholesale nfl jerseys, mlb jerseys , nhl jerseys, nba jerseys Message-ID: <3e9c772e-7e74-423b-9a24-9fc81b54fefc@i13g2000prg.googlegroups.com> (www.nike-black.com) cheap wholesale nfl jerseys, mlb jerseys , nhl jerseys, nba jerseys NFL Football Jerseys 2011 Super Bowl NFL Hats NCAA Jerseys Customized NFL Jerseys Hot NFL Jerseys (www.nike-black.com) Women NFL Jerseys Youth NFL Jerseys Super Bowl Jerseys Pro Bowl Jerseys New NFL Jerseys Arizona Cardinals (www.nike-black.com) Atlanta Falcons Baltimore Ravens Buffalo Bills Carolina Panthers Chicago Bears Cincinnati Bengals Cleveland Browns (www.nike-black.com) Dallas Cowboys Denver Broncos Detroit Lions Green Bay Packers Houston Texans Indianapolis Colts (www.nike-black.com) Jacksonville Jaguars Kansas City Chiefs Miami Dolphins Minnesota Vikings New England Patriots New Orleans Saints New York Giants New York Jets Oakland Raiders Philadelphia Eagles (www.nike-black.com) Pittsburgh Steelers San Diego Chargers San Francisco 49ers Seattle Seahawks (www.nike-black.com) St.Louis Rams Tampa Bay Buccaneers Tennessee Titans Washington Redskins website: http://www.nike-black.com From __peter__ at web.de Mon Nov 7 09:15:53 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 15:15:53 +0100 Subject: Python lesson please References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> Message-ID: gene heskett wrote: > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > >> gene heskett wrote: >> > Greetings experts: >> > >> > I just dl'd the duqu driver finder script from a link to NSS on /., >> > and fixed enough of the tabs in it to make it run error-free. At >> > least python isn't having a litter of cows over the indentation now. >> > >> > But it also runs instantly on linux. >> > >> > This line looks suspect to me: >> > rootdir = sys.argv[1] >> > >> > And I have a suspicion it is null on a linux box. >> > >> > How can I fix that best? >> >> Are you talking about this one? >> >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns >> .py > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > pulled it again, using the 'raw' link, saved it, no extra tabs. > > But it still doesn't work for linux. My python is 2.6.6 Maybe the browser messes up things. Try installing git and then make a clone: $ git clone git://github.com/halsten/Duqu-detectors >> With a current checkout I don't get any tab-related (nor other) errors, >> so I would prefer to run the script as-is. Also, the README clearly >> states that you have to invoke it with >> >> python DuquDriverPatterns.py ./directoryOfMalware >> >> and the line you are quoting then puts the value "./directoryOfMalware" >> into the rootdir variable. > > If only it would... Using this version, the failure is silent and > instant. The actual code which comprises only the last 30 lines of the script looks like it is written by a newbie. Try replacing the bare except: with something noisy along the lines of except Exception as e: print e continue > Besides, the malware could be anyplace on the system. But it needs to > skip /dev since it hangs on the midi tree, /mnt and /media because they > are not part of the running system even if disks are mounted there. I don't think the script is meant to find malware on a running system. Rather you would mount a suspicious harddisk and pass the mountpoint to the script. Of course I'm only guessing... >> or similar once you've installed the python-examples package. > > On PCLos it doesn't even exist in the repo's. Maybe it's in python's srpm, or in a python-dev.rpm or similar. If all else fails you can download the source distribution from python.org at http://www.python.org/download/releases/2.6.7/ From gabor.farkas at gmail.com Mon Nov 7 09:18:35 2011 From: gabor.farkas at gmail.com (=?ISO-8859-1?Q?G=E1bor_Farkas?=) Date: Mon, 7 Nov 2011 15:18:35 +0100 Subject: logging: handle everything EXCEPT certain loggers In-Reply-To: <4EB7DF85.7060909@sequans.com> References: <4EB7DF85.7060909@sequans.com> Message-ID: 2011/11/7 Jean-Michel Pichavant : > G?bor Farkas wrote: >> >> is there a way to setup log-handlers in a way that they log logs from >> every logger, exept certain ones? >> >> i tried to create filters, but the log-record does not have access to >> his logger, so i cannot filter based on it's "path". > > Are you sure ? > LogRecord objects have a name attribute. You could do something like > > return 'IdontWantYou' not in record.name > > in your filter. d'oh .. thanks, i somehow overlooked the name attribute. it's exactly what i need. thanks, gabor From jaroslav.dobrek at gmail.com Mon Nov 7 09:23:12 2011 From: jaroslav.dobrek at gmail.com (Jaroslav Dobrek) Date: Mon, 7 Nov 2011 06:23:12 -0800 (PST) Subject: read from file with mixed encodings in Python3 Message-ID: <406195f9-d51f-416a-b32c-e9ab07e219c7@n13g2000vbv.googlegroups.com> Hello, in Python3, I often have this problem: I want to do something with every line of a file. Like Python3, I presuppose that every line is encoded in utf-8. If this isn't the case, I would like Python3 to do something specific (like skipping the line, writing the line to standard error, ...) Like so: try: .... except UnicodeDecodeError: ... Yet, there is no place for this construction. If I simply do: for line in f: print(line) this will result in a UnicodeDecodeError if some line is not utf-8, but I can't tell Python3 to stop: This will not work: for line in f: try: print(line) except UnicodeDecodeError: ... because the UnicodeDecodeError is caused in the "for line in f"-part. How can I catch such exceptions? Note that recoding the file before opening it is not an option, because often files contain many different strings in many different encodings. Jaroslav From d at davea.name Mon Nov 7 09:33:33 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 09:33:33 -0500 Subject: read from file with mixed encodings in Python3 In-Reply-To: <406195f9-d51f-416a-b32c-e9ab07e219c7@n13g2000vbv.googlegroups.com> References: <406195f9-d51f-416a-b32c-e9ab07e219c7@n13g2000vbv.googlegroups.com> Message-ID: <4EB7EC3D.4070809@davea.name> On 11/07/2011 09:23 AM, Jaroslav Dobrek wrote: > Hello, > > in Python3, I often have this problem: I want to do something with > every line of a file. Like Python3, I presuppose that every line is > encoded in utf-8. If this isn't the case, I would like Python3 to do > something specific (like skipping the line, writing the line to > standard error, ...) > > Like so: > > try: > .... > except UnicodeDecodeError: > ... > > Yet, there is no place for this construction. If I simply do: > > for line in f: > print(line) > > this will result in a UnicodeDecodeError if some line is not utf-8, > but I can't tell Python3 to stop: > > This will not work: > > for line in f: > try: > print(line) > except UnicodeDecodeError: > ... > > because the UnicodeDecodeError is caused in the "for line in f"-part. > > How can I catch such exceptions? > > Note that recoding the file before opening it is not an option, > because often files contain many different strings in many different > encodings. > > Jaroslav A file with mixed encodings isn't a text file. So open it with 'rb' mode, and use read() on it. Find your own line-endings, since a given '\n' byte may or may not be a line-ending. Once you've got something that looks like a line, explicitly decode it using utf-8. Some invalid lines will give an exception and some will not. But perhaps you've got some other gimmick to tell the encoding for each line. -- DaveA From __peter__ at web.de Mon Nov 7 09:42:47 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 15:42:47 +0100 Subject: read from file with mixed encodings in Python3 References: <406195f9-d51f-416a-b32c-e9ab07e219c7@n13g2000vbv.googlegroups.com> Message-ID: Jaroslav Dobrek wrote: > Hello, > > in Python3, I often have this problem: I want to do something with > every line of a file. Like Python3, I presuppose that every line is > encoded in utf-8. If this isn't the case, I would like Python3 to do > something specific (like skipping the line, writing the line to > standard error, ...) > > Like so: > > try: > .... > except UnicodeDecodeError: > ... > > Yet, there is no place for this construction. If I simply do: > > for line in f: > print(line) > > this will result in a UnicodeDecodeError if some line is not utf-8, > but I can't tell Python3 to stop: > > This will not work: > > for line in f: > try: > print(line) > except UnicodeDecodeError: > ... > > because the UnicodeDecodeError is caused in the "for line in f"-part. > > How can I catch such exceptions? > > Note that recoding the file before opening it is not an option, > because often files contain many different strings in many different > encodings. I don't see those files often, but I think they are all seriously broken. There's no way to recover the information from files with unknown mixed encodings. However, here's an approach that may sometimes work: >>> with open("tmp.txt", "rb") as f: ... for line in f: ... try: ... line = "UTF-8 " + line.decode("utf-8") ... except UnicodeDecodeError: ... line = "Latin-1 " + line.decode("latin-1") ... print(line, end="") ... UTF-8 ??? Latin-1 ??? UTF-8 ??? From gordon at panix.com Mon Nov 7 10:33:03 2011 From: gordon at panix.com (John Gordon) Date: Mon, 7 Nov 2011 15:33:03 +0000 (UTC) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: In <415d875d-bc6d-4e69-bcf8-39754b45030a at n18g2000vbv.googlegroups.com> Travis Parks writes: > Which web frameworks have people here used and which have they found > to be: scalable, RAD compatible, performant, stable and/or providing > good community support? I am really trying to get as much feedback as I've used Django and it seems to be a very nice framework. However I've only done one project so I haven't delved too deeply. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From gheskett at wdtv.com Mon Nov 7 11:30:16 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 11:30:16 -0500 Subject: Python lesson please In-Reply-To: <4EB7D99D.5010604@gmx.net> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7D99D.5010604@gmx.net> Message-ID: <201111071130.16751.gheskett@wdtv.com> On Monday, November 07, 2011 10:38:32 AM Andreas Perstinger did opine: > On 2011-11-07 12:22, gene heskett wrote: > > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > >> Are you talking about this one? > >> > >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatt > >> erns .py > > > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > > pulled it again, using the 'raw' link, saved it, no extra tabs. > > > > But it still doesn't work for linux. My python is 2.6.6 > > Go to the directory where you've downloaded the file and type: > > python DuquDriverPatterns.py . > > What output do you get? Well now, I'll be dipped. It scanned that directory, took it perhaps 15 minutes, without finding anything. So I gave it two dots & its munching its way through the ../Mail/inbox now. Why the hell can't it be given a valid absolute path without editing it directly into the rootdir = statement? This may be a usable tool, but I think that before it was committed to a daily cron script, we would need some history as to where to look for such shenanigans as its certainly not fast enough to turn it loose to scan the whole system on a daily basis. This on a quad core 2.1Ghz phenom, 4 gigs of dram. And I just found one of its Achilles heels, it is now stuck on a pipe file at /home/gene/.kde4/share/apps/kaffeine/dvbpipe: prw------- 1 gene gene 0 Sep 24 18:50 dvbpipe.m2t| And using no cpu. I was going to ctl+c it but this is where, after several such, that it took the machine down yesterday. But it appears as only one process to htop (I keep a copy of it running as root here) and that killed it clean, no crash. So, it needs an exception (or likely several) of file types to stay away from, starting with pipes like the above. But I am not the one to carve that code as I have NDI how to go about writing a check stanza for that condition in python. Perhaps winderz does not have 'pipe' files so the authors never got caught out on this? The only windows experience I have is the copy of xp that was on the lappy I bought back in 2005 or so to take with me when I am on the road (I am a broadcast engineer who gets sent here and there to "put out the fires" when the station is off the air. Despite being retired for 9 years now at 77 yo, my phone still rings occasionally) I went straight from amigados-3.2 to redhat-5.0 in the late '90's, bypassing windows completely. I built the redhat machine from scratch. The lappy's xp, used only for warranty testing, got overwritten by mandriva 2008 when the warranty had expired. You could call me anti-M$ I think. :) > Bye, Andreas Thanks for listening, Andreas. Now I wonder how to get a message back to the authors that its broken in at least two aspects... Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: From gheskett at wdtv.com Mon Nov 7 11:40:12 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 11:40:12 -0500 Subject: Python lesson please In-Reply-To: <4EB7DD67.5070606@davea.name> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7DD67.5070606@davea.name> Message-ID: <201111071140.12374.gheskett@wdtv.com> On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine: Back on the list.. > On 11/07/2011 06:22 AM, gene heskett wrote: > > On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > > > > > >> Are you talking about this one? > >> > >> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatte > >> rns .py > > > > Yes. My save as renamed it, still has about 30k of tabs in it. But I > > pulled it again, using the 'raw' link, saved it, no extra tabs. > > > > But it still doesn't work for linux. My python is 2.6.6 > > To start with, what's the md5 of the file you downloaded and are > testing? I get c4592a187f8f7880d3b685537e3bf9a5 [root at coyote Download]# md5sum DuquDriverPatterns.py c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as yours. > from md5sum. If you get something different, one of us changed the > file, or you got it before today. > > The whole tab issue is a red-herring in this case. But I don't see how > you can find 30k tabs in a thousand lines. And if I were going to detab > it, I'd pick 4 spaces, so the code doesn't stretch across the page. Down toward the bottom of the file, the tab indentations were as high as 33 leading tabs per line. Each stanza of the data was tab indented 2 additional tabs from the one above it in the original file. 30k was perhaps a poor SWAG, but 10 to 15k seems an entirely reasonable guess. > > > > > >> python DuquDriverPatterns.py ./directoryOfMalware > >> > >> and the line you are quoting then puts the value > >> "./directoryOfMalware" into the rootdir variable. > > > > If only it would... Using this version, the failure is silent and > > instant. Besides, the malware could be anyplace on the system. But > > it needs to skip /dev since it hangs on the midi tree, /mnt and > > /media because they are not part of the running system even if disks > > are mounted there. > > First, run it on the current directory, and it should list the files in > that directory: > > I ran it in the directory I unzipped it into, so there are two files, > the README and the source file itself. > > $ python DuquDriverPatterns.py . > Scanning ./README: > No match for pattern #0 on file named: README > No match for pattern #1 on file named: README > No match for pattern #2 on file named: README > > etc. > > The only way I can see to get NO output is to run it on an empty > directory: $mkdir junk > $ python DuquDriverPatterns.py junk > > As for skipping certain directories, we can deal with that as soon as > you get proper behavior for any subtree of directories. > > Have you tried adding a print ("Hello World " + rootdir) just before the > > for root, subFolders, files in os.walk(rootdir): > > line ? Or putting a print len(files) just after it (indented, of > course) ? No, I did try to print the value of rootdir though, indented the same, and got a null printout, not even a line feed. Thanks Dave. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: The older I grow, the less important the comma becomes. Let the reader catch his own breath. -- Elizabeth Clarkson Zwart From awilliam at whitemice.org Mon Nov 7 11:54:52 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 07 Nov 2011 11:54:52 -0500 Subject: RSS feed creation? In-Reply-To: References: Message-ID: <1320684893.8941.9.camel@linux-yu4c.site> On Mon, 2011-11-07 at 08:22 +0100, Stefan Behnel wrote: > Dan Stromberg, 06.11.2011 21:00: > > Is there an opensource Python tool for creating RSS feeds, that doesn't > > require large dependencies? > > I found feedformatter.py on pypi, but it seems a little old, and its sole > > automated test gives a traceback. > > Is there a better starting point? > > (I'd of course prefer something that'll run on 3.x and 2.x, but will settle > > for either) > I'd just go with ElementTree and builder.py. > http://effbot.org/zone/element-builder.htm +1 RSS is just XML, just use the XML toolchain. And use to check what you create. From awilliam at whitemice.org Mon Nov 7 11:57:10 2011 From: awilliam at whitemice.org (Adam Tauno Williams) Date: Mon, 07 Nov 2011 11:57:10 -0500 Subject: xml-rpc server on wine In-Reply-To: <650e9d68-e606-4424-bca7-174295306d82@ht6g2000vbb.googlegroups.com> References: <650e9d68-e606-4424-bca7-174295306d82@ht6g2000vbb.googlegroups.com> Message-ID: <1320685031.8941.11.camel@linux-yu4c.site> On Sat, 2011-11-05 at 05:50 -0700, pacopyc wrote: > Hi, I have a XML-RPC server python running on VM Windows (on Linux) > and a XML-RPC client python on Linux. Server and client have different > IP address. I'd like migrate server on wine. How can communicate > server and client? IP address is different or is the same? > Can you help me? Not really, this doesn't have much of anything to do with Python. If you run a network application on wine [assuming that even works] the application will have the same IP/interface as any other application or service running on the host. Wine is not a 'virtualization' solution. From josephmeiring at gmail.com Mon Nov 7 12:12:13 2011 From: josephmeiring at gmail.com (JoeM) Date: Mon, 7 Nov 2011 09:12:13 -0800 (PST) Subject: Extracting elements over multiple lists? Message-ID: Howdy, If I have a few lists like a=[1,2,3,4,5] b=["one", "two", "three", "four", "five"] c=["cat", "dog", "parrot", "clam", "ferret"] what is the most pythonic method of removing the first element from all of the lists? A list comprehension such as [arr[1:] for arr in a,b,c] gives a single 2d list, which is not what I'm shooting for. Any suggestions? From gordon at panix.com Mon Nov 7 12:37:27 2011 From: gordon at panix.com (John Gordon) Date: Mon, 7 Nov 2011 17:37:27 +0000 (UTC) Subject: Extracting elements over multiple lists? References: Message-ID: In JoeM writes: > a=[1,2,3,4,5] > b=["one", "two", "three", "four", "five"] > c=["cat", "dog", "parrot", "clam", "ferret"] > what is the most pythonic method of removing the first element from > all of the lists? for arr in [a,b,c]: arr.pop(0) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From gordon at panix.com Mon Nov 7 12:44:15 2011 From: gordon at panix.com (John Gordon) Date: Mon, 7 Nov 2011 17:44:15 +0000 (UTC) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: In John Gordon writes: > In <415d875d-bc6d-4e69-bcf8-39754b45030a at n18g2000vbv.googlegroups.com> Travis Parks writes: > > Which web frameworks have people here used and which have they found > > to be: scalable, RAD compatible, performant, stable and/or providing > > good community support? I am really trying to get as much feedback as > I've used Django and it seems to be a very nice framework. However I've > only done one project so I haven't delved too deeply. You are probably looking for more detail than "It's a nice framework" :-) The database model in Django is powerful; it allows you to do queries in native Python code without delving into backend SQL stuff. I don't know how scalable/performant the database model is, as the one project I worked on didn't deal with a ton of data. (But I'd be surprised if it had poor performance.) The URL dispatcher provides a very nice and logical way to associate a given URL with a given method call. Community support is excellent. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From moky.math at gmail.com Mon Nov 7 12:44:59 2011 From: moky.math at gmail.com (Laurent Claessens) Date: Mon, 07 Nov 2011 18:44:59 +0100 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: Le 07/11/2011 18:12, JoeM a ?crit : > Howdy, > > If I have a few lists like > > a=[1,2,3,4,5] > b=["one", "two", "three", "four", "five"] > c=["cat", "dog", "parrot", "clam", "ferret"] > > what is the most pythonic method of removing the first element from > all of the lists? Do you want to remove the first item of each list, or to create new lists that contain the same as a,b,c but with one element less ? Something like what you wrote : [arr[1:] for arr in a,b,c] will create *new* lists. Assuming you don't want new lists, I would do : a=[1,2,3,4,5] b=["one", "two", "three", "four", "five"] c=["cat", "dog", "parrot", "clam", "ferret"] for x in [a,b,c]: x.remove(x[0]) print a print b print c I think that writing >>> [x.remove(x[0]) for x in [a,b,c]] instead of the for loop is cheating ... but it also does the job. Have a good after noon Laurent From josephmeiring at gmail.com Mon Nov 7 13:01:42 2011 From: josephmeiring at gmail.com (JoeM) Date: Mon, 7 Nov 2011 10:01:42 -0800 (PST) Subject: Extracting elements over multiple lists? References: Message-ID: Thanks guys, I was just looking for a one line solution instead of a for loop if possible. Why do you consider [x.remove(x[0]) for x in [a,b,c]] cheating? It seems compact and elegant enough for me. Cheers From d at davea.name Mon Nov 7 13:14:50 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 13:14:50 -0500 Subject: Python lesson please In-Reply-To: <201111071140.12374.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7DD67.5070606@davea.name> <201111071140.12374.gheskett@wdtv.com> Message-ID: <4EB8201A.6080401@davea.name> On 11/07/2011 11:40 AM, gene heskett wrote: > On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine: > Back on the list.. >> On 11/07/2011 06:22 AM, gene heskett wrote: >>> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: >>> >>> >>>> Are you talking about this one? >>>> >>>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatte >>>> rns .py >>> >>> Yes. My save as renamed it, still has about 30k of tabs in it. But I >>> pulled it again, using the 'raw' link, saved it, no extra tabs. >>> >>> But it still doesn't work for linux. My python is 2.6.6 >> >> To start with, what's the md5 of the file you downloaded and are >> testing? I get c4592a187f8f7880d3b685537e3bf9a5 > > [root at coyote Download]# md5sum DuquDriverPatterns.py > c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as yours. > >> from md5sum. If you get something different, one of us changed the >> file, or you got it before today. >> >> The whole tab issue is a red-herring in this case. But I don't see how >> you can find 30k tabs in a thousand lines. And if I were going to detab >> it, I'd pick 4 spaces, so the code doesn't stretch across the page. > > Down toward the bottom of the file, the tab indentations were as high as 33 > leading tabs per line. Each stanza of the data was tab indented 2 > additional tabs from the one above it in the original file. 30k was > perhaps a poor SWAG, but 10 to 15k seems an entirely reasonable guess. > What program are you using to read the file and support that claim? Neither emacs nor gedit shows more than one leading tab on any line I looked. And if you set tabs to 4 columns, the file looks quite reasonable. Doing a quick scan I see max of 5 tabs on any single line, and 1006 total. maxtabs = 0 totaltabs = 0 f = open("DuquDriverPatterns.py", "r") for line in f: cline = line.replace("\t", "") tabs = len(line) - len(cline) if tabs: print tabs maxtabs = max(maxtabs, tabs) totaltabs += tabs print "max=", maxtabs print "total=", totaltabs >>> >>> >>>> python DuquDriverPatterns.py ./directoryOfMalware >>>> >>>> and the line you are quoting then puts the value >>>> "./directoryOfMalware" into the rootdir variable. >>> >>> If only it would... Using this version, the failure is silent and >>> instant. The only way I've been able to make it "silent and instant" was to give it the name of an empty directory, or a typo representing no directory at all. >>> Besides, the malware could be anyplace on the system. But >>> it needs to skip /dev since it hangs on the midi tree, /mnt and >>> /media because they are not part of the running system even if disks >>> are mounted there. >> >> First, run it on the current directory, and it should list the files in >> that directory: >> >> I ran it in the directory I unzipped it into, so there are two files, >> the README and the source file itself. >> >> $ python DuquDriverPatterns.py . >> Scanning ./README: >> No match for pattern #0 on file named: README >> No match for pattern #1 on file named: README >> No match for pattern #2 on file named: README >> >> etc. >> >> The only way I can see to get NO output is to run it on an empty >> directory: $mkdir junk >> $ python DuquDriverPatterns.py junk >> >> As for skipping certain directories, we can deal with that as soon as >> you get proper behavior for any subtree of directories. >> >> Have you tried adding a print ("Hello World " + rootdir) just before the >> >> for root, subFolders, files in os.walk(rootdir): >> >> line ? Or putting a print len(files) just after it (indented, of >> course) ? > > No, I did try to print the value of rootdir though, indented the same, and > got a null printout, not even a line feed. > If you had put the print I suggested, it would at least print the words "Hello World". Since it did not, you probably didn't actually add the line where I suggested. > Thanks Dave. > > Cheers, Gene In another message you said it doesn't work on absolute file paths. But it does. You can replace any relative directory name with the absolute version, and it won't change the behavior. I suspect you were caught up by a typo for the absolute path string. -- DaveA From gordon at panix.com Mon Nov 7 13:22:00 2011 From: gordon at panix.com (John Gordon) Date: Mon, 7 Nov 2011 18:22:00 +0000 (UTC) Subject: Extracting elements over multiple lists? References: Message-ID: In JoeM writes: > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > [x.remove(x[0]) for x in [a,b,c]] > cheating? It seems compact and elegant enough for me. I wouldn't call it cheating, but that solution does a fair bit of unneccessary work (creating a list comprehension that is never used.) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From __peter__ at web.de Mon Nov 7 13:33:01 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Nov 2011 19:33:01 +0100 Subject: Extracting elements over multiple lists? References: Message-ID: JoeM wrote: > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > > [x.remove(x[0]) for x in [a,b,c]] > > cheating? It seems compact and elegant enough for me. I think it's a misconception that you are avoiding the for-loop. You move it into [...] and declare it more elegant, but in reality you are creating a throwaway list of None-s. You are adding cruft to your code. That is not only superfluous, but also misleading. A simple for-loop like for x in a, b, c: del x[0] on the other hand makes your intention crystal-clear. From jeanmichel at sequans.com Mon Nov 7 13:51:31 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 07 Nov 2011 19:51:31 +0100 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: <4EB828B3.1020509@sequans.com> JoeM wrote: > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > > [x.remove(x[0]) for x in [a,b,c]] > > cheating? It seems compact and elegant enough for me. > > > > Cheers > This is a one liner, but since you asked something *pythonic*, John's solution is the best imo: for arr in [a,b,c]: arr.pop(0) (Peter's "del" solution is quite close, but I find the 'del' statement tricky in python and will mislead many python newcomers) JM From Juan.Declet-Barreto at MesaAZ.gov Mon Nov 7 14:43:05 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Mon, 7 Nov 2011 12:43:05 -0700 Subject: memory management Message-ID: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> Hi, Can anyone provide links or basic info on memory management, variable dereferencing, or the like? I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directories, but when I set it loose on a directory with thousands of dirs/subdirs, it crashes the DOS session and also the Python shell (when I run it from the shell). This makes it difficult to figure out if the allocated memory or heap space for the DOS/shell session have overflown, or why it is crashing. Juan Declet-Barreto [cid:image001.png at 01CC9D4A.CB6B9D70] GIS Specialist, Information Technology Dept. City of Mesa Office: 480.644.4751 juan.declet-barreto at mesaaz.gov [cid:image002.png at 01CC9D4A.CB6B9D70] -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 1454 bytes Desc: image001.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.png Type: image/png Size: 11402 bytes Desc: image002.png URL: From gheskett at wdtv.com Mon Nov 7 15:00:49 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 15:00:49 -0500 Subject: Python lesson please In-Reply-To: <4EB8201A.6080401@davea.name> References: <201111061314.43744.gheskett@wdtv.com> <201111071140.12374.gheskett@wdtv.com> <4EB8201A.6080401@davea.name> Message-ID: <201111071500.49230.gheskett@wdtv.com> On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine: > On 11/07/2011 11:40 AM, gene heskett wrote: > > On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine: > > Back on the list.. > > > >> On 11/07/2011 06:22 AM, gene heskett wrote: > >>> On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: > >>> > >>> > >>>> Are you talking about this one? > >>>> > >>>> https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPat > >>>> te rns .py > >>> > >>> Yes. My save as renamed it, still has about 30k of tabs in it. But > >>> I pulled it again, using the 'raw' link, saved it, no extra tabs. > >>> > >>> But it still doesn't work for linux. My python is 2.6.6 > >> > >> To start with, what's the md5 of the file you downloaded and are > >> testing? I get c4592a187f8f7880d3b685537e3bf9a5 > > > > [root at coyote Download]# md5sum DuquDriverPatterns.py > > c4592a187f8f7880d3b685537e3bf9a5 DuquDriverPatterns.py, same as > > yours. > > > >> from md5sum. If you get something different, one of us changed the > >> file, or you got it before today. > >> > >> The whole tab issue is a red-herring in this case. But I don't see > >> how you can find 30k tabs in a thousand lines. And if I were going > >> to detab it, I'd pick 4 spaces, so the code doesn't stretch across > >> the page. > > > > Down toward the bottom of the file, the tab indentations were as high > > as 33 leading tabs per line. Each stanza of the data was tab > > indented 2 additional tabs from the one above it in the original > > file. 30k was perhaps a poor SWAG, but 10 to 15k seems an entirely > > reasonable guess. > > What program are you using to read the file and support that claim? vim. But remember, this first one started out as a copy/paste from the firefox-7.0.1 screen. > Neither emacs nor gedit shows more than one leading tab on any line I > looked. And if you set tabs to 4 columns, the file looks quite > reasonable. Doing a quick scan I see max of 5 tabs on any single line, > and 1006 total. I have no tabs left in the operative code, the python interpreter was having a cow if even one was in that last 30-35 lines of code. > > > maxtabs = 0 > totaltabs = 0 > f = open("DuquDriverPatterns.py", "r") > for line in f: > > cline = line.replace("\t", "") > tabs = len(line) - len(cline) > if tabs: > print tabs > maxtabs = max(maxtabs, tabs) > totaltabs += tabs > > print "max=", maxtabs > print "total=", totaltabs > > >>> > The only way I've been able to make it "silent and instant" was to give > it the name of an empty directory, or a typo representing no directory > at all. > [...] > >> line ? Or putting a print len(files) just after it (indented, of > >> course) ? > > > > No, I did try to print the value of rootdir though, indented the same, > > and got a null printout, not even a line feed. Indented the same as the rootdir statement itself, which in python would seem to make it immediately sequential to the roodir = statement. > If you had put the print I suggested, it would at least print the words > "Hello World". Since it did not, you probably didn't actually add the > line where I suggested. > > > Thanks Dave. > > > > Cheers, Gene > > In another message you said it doesn't work on absolute file paths. But > it does. You can replace any relative directory name with the absolute > version, and it won't change the behavior. I suspect you were caught up > by a typo for the absolute path string. I am gene, running as gene, what could be wrong with giving it /home/gene as the argument? I have another dir in /home/amanda, that I build the alpha and beta amanda stuff in. Let me try that. And again, this works but I forgot about the .ccache directory, so it will take a while to finish. Now, as a python lesson to me, I will do a blink compare between the 2 files this evening & see what I munged. ATM, I am working on a gunstock for as long as my feet and back can stand the standing, so sitting here is a 'break' from that. Yeah, I occasionally call myself a JOAT. ;-) Thanks Dave. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Experience is that marvelous thing that enables you recognize a mistake when you make it again. -- Franklin P. Jones From d at davea.name Mon Nov 7 15:06:25 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 15:06:25 -0500 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: <4EB83A41.9050802@davea.name> On 11/07/2011 01:01 PM, JoeM wrote: > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > > [x.remove(x[0]) for x in [a,b,c]] > > cheating? It seems compact and elegant enough for me. > > > > Cheers Are you considering the possibility that two of these names might reference the same list? a = [42, 44, 6, 19, 48] b = a c = b for x in [a,b,c]: x.remove(x[0]) now a will have [19,48] as its content. -- DaveA From davea at dejaviewphoto.com Mon Nov 7 15:19:53 2011 From: davea at dejaviewphoto.com (Dave Angel) Date: Mon, 07 Nov 2011 15:19:53 -0500 Subject: memory management In-Reply-To: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> Message-ID: <4EB83D69.2000409@dejaviewphoto.com> On 11/07/2011 02:43 PM, Juan Declet-Barreto wrote: > Hi, > > Can anyone provide links or basic info on memory management, variable dereferencing, or the like? I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directories, but when I set it loose on a directory with thousands of dirs/subdirs, it crashes the DOS session and also the Python shell (when I run it from the shell). This makes it difficult to figure out if the allocated memory or heap space for the DOS/shell session have overflown, or why it is crashing. > > Juan Declet-Barreto [ciId:image001.png at 01CC9D4A.CB6B9D70] I don't have any reference to point you to, but CPython's memory management is really pretty simple. However, it's important to tell us the build of Python, as there are several, with very different memory rules. For example Jython, which is Python running in a Java VM, lets the java garbage collector handle things, and it's entirely different. Likewise, the OS may be relevant. You're using Windows-kind of terminology, but that doesn't prove you're on Windows, nor does it say what version. Assuming 32 bit CPython 2.7 on XP, the principles are simple. When an object is no longer accessible, it gets garbage collected*. So if you build a list inside a function, and the only reference is from a function's local var, then the whole list will be freed when the function exits. The mistakes many people make are unnecessarily using globals, and using lists when iterables would work just as well. The tool on XP to tell how much memory is in use is the task manager. As you point out, its hard to catch a short-running app in the act. So you want to add a counter to your code (global), and see how high it gets when it crashes. Then put a test in your code for the timer value, and do an "input" somewhat earlier. At that point, see how much memory the program is actually using. Now, when an object is freed, a new one of the same size is likely to immediately re-use the space. But if they're all different sizes, it's somewhat statistical. You might get fragmentation, for example. When Python's pool is full, it asks the OS for more (perhaps using swap space), but I don't think it ever gives it back. So your memory use is a kind of ceiling case. That's why it's problematic to build a huge data structure, and then walk through it, then delete it. The script will probably continue to show the peak memory use, indefinitely. * (technically, this is ref counted. When the ref reaches zero the object is freed. Real gc is more lazy scanning) From jfine at pytex.org Mon Nov 7 15:21:49 2011 From: jfine at pytex.org (Jonathan Fine) Date: Mon, 07 Nov 2011 20:21:49 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> Message-ID: <4EB83DDD.1080103@pytex.org> On 06/11/11 20:28, Jakub Narebski wrote: > Note that for gitPAN each "distribution" (usually but not always > corresponding to single Perl module) is in separate repository. > The dependencies are handled by CPAN / CPANPLUS / cpanm client > (i.e. during install). Thank you for your interest, Jakub, and also for this information. With TeX there's a difficult which Perl, I think, does not have. With TeX we process documents, which may demand specific versions of packages. LaTeX users are concerned that move on to a later version will cause documents to break. > Putting all DVD (is it "TeX Live" DVD by the way?) into single > repository would put quite a bit of stress to git; it was created for > software development (although admittedly of large project like Linux > kernel), not 4GB+ trees. I'm impressed by how well git manages it. It took about 15 minutes to build the 4GB tree, and it was disk speed rather than CPU which was the bottleneck. >> Once you've done that, it is then possible and sensible to select >> suitable interesting subsets, such as releases of a particular >> package. Users could even define their own subsets, such as "all >> resources needed to process this file, exactly as it processes on my >> machine". > > This could be handled using submodules, by having superrepository that > consist solely of references to other repositories by the way of > submodules... plus perhaps some administrativa files (like README for > whole CTAN, or search tool, or DVD install, etc.) > > This could be the used to get for example contents of DVD from 2010. We may be at cross purposes. My first task is get the DVD tree into git, performing necessary transformations such as expanding zip files along the way. Breaking the content into submodules can, I believe, be done afterwards. With DVDs from several years it could take several hours to load everything into git. For myself, I'd like to do that once, more or less as a batch process, and then move on to the more interesting topics. Getting the DVD contents into git is already a significant piece of work. Once done, I can them move on to what you're interested in, which is organising the material. And I hope that others in the TeX community will get involved with that, because I'm not building this repository just for myself. > But even though submodules (c.f. Subversion svn:external, Mecurial > forest extension, etc.) are in Git for quite a bit of time, it doesn't > have best user interface. > >> In addition, many TeX users have a TeX DVD. If they import it into a >> git repository (using for example my script) then the update from 2011 >> to 2012 would require much less bandwidth. > > ??? A quick way to bring your TeX distribution up to date is to do a delta with a later distribution, and download the difference. That's what git does, and it does it well. So I'm keen to convert a TeX DVD into a git repository, and then differences can be downloaded. >> Finally, I'd rather be working within git that modified copy of the >> ISO when doing the subsetting. I'm pretty sure that I can manage to >> pull the small repositories from the big git-CTAN repository. > > No you cannot. It is all or nothing; there is no support for partial > _clone_ (yet), and it looks like it is a hard problem. > > Nb. there is support for partial _checkout_, but this is something > different. From what I know, I'm confident that I can achieve what I want using git. I'm also confident that my approach is not closing off any possible approached. But if I'm wrong you'll be able to say: I told you so. > Commit = tree + parent + metadata. Actually, any number of parents, including none. What metadata do I have to provide? At this time nothing, I think, beyond that provided by the name of a reference (to the root of a tree). > I think you would very much want to have linear sequence of trees, > ordered via DAG of commits. "Naked" trees are rather bad idea, I think. > >> As I recall the first 'commit' to the git repository for the Linux >> kernel was just a tree, with a reference to that tree as a tag. But >> no commit. > > That was a bad accident that there is a tag that points directly to a > tree of _initial import_, not something to copy. Because git is a distributed version control system, anyone who wants to can create such a directed acyclic graph of commits. And if it's useful I'll gladly add it to my copy of the repository. best regards Jonathan From jfine at pytex.org Mon Nov 7 15:21:49 2011 From: jfine at pytex.org (Jonathan Fine) Date: Mon, 07 Nov 2011 20:21:49 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> Message-ID: <4EB83DDD.1080103@pytex.org> On 06/11/11 20:28, Jakub Narebski wrote: > Note that for gitPAN each "distribution" (usually but not always > corresponding to single Perl module) is in separate repository. > The dependencies are handled by CPAN / CPANPLUS / cpanm client > (i.e. during install). Thank you for your interest, Jakub, and also for this information. With TeX there's a difficult which Perl, I think, does not have. With TeX we process documents, which may demand specific versions of packages. LaTeX users are concerned that move on to a later version will cause documents to break. > Putting all DVD (is it "TeX Live" DVD by the way?) into single > repository would put quite a bit of stress to git; it was created for > software development (although admittedly of large project like Linux > kernel), not 4GB+ trees. I'm impressed by how well git manages it. It took about 15 minutes to build the 4GB tree, and it was disk speed rather than CPU which was the bottleneck. >> Once you've done that, it is then possible and sensible to select >> suitable interesting subsets, such as releases of a particular >> package. Users could even define their own subsets, such as "all >> resources needed to process this file, exactly as it processes on my >> machine". > > This could be handled using submodules, by having superrepository that > consist solely of references to other repositories by the way of > submodules... plus perhaps some administrativa files (like README for > whole CTAN, or search tool, or DVD install, etc.) > > This could be the used to get for example contents of DVD from 2010. We may be at cross purposes. My first task is get the DVD tree into git, performing necessary transformations such as expanding zip files along the way. Breaking the content into submodules can, I believe, be done afterwards. With DVDs from several years it could take several hours to load everything into git. For myself, I'd like to do that once, more or less as a batch process, and then move on to the more interesting topics. Getting the DVD contents into git is already a significant piece of work. Once done, I can them move on to what you're interested in, which is organising the material. And I hope that others in the TeX community will get involved with that, because I'm not building this repository just for myself. > But even though submodules (c.f. Subversion svn:external, Mecurial > forest extension, etc.) are in Git for quite a bit of time, it doesn't > have best user interface. > >> In addition, many TeX users have a TeX DVD. If they import it into a >> git repository (using for example my script) then the update from 2011 >> to 2012 would require much less bandwidth. > > ??? A quick way to bring your TeX distribution up to date is to do a delta with a later distribution, and download the difference. That's what git does, and it does it well. So I'm keen to convert a TeX DVD into a git repository, and then differences can be downloaded. >> Finally, I'd rather be working within git that modified copy of the >> ISO when doing the subsetting. I'm pretty sure that I can manage to >> pull the small repositories from the big git-CTAN repository. > > No you cannot. It is all or nothing; there is no support for partial > _clone_ (yet), and it looks like it is a hard problem. > > Nb. there is support for partial _checkout_, but this is something > different. From what I know, I'm confident that I can achieve what I want using git. I'm also confident that my approach is not closing off any possible approached. But if I'm wrong you'll be able to say: I told you so. > Commit = tree + parent + metadata. Actually, any number of parents, including none. What metadata do I have to provide? At this time nothing, I think, beyond that provided by the name of a reference (to the root of a tree). > I think you would very much want to have linear sequence of trees, > ordered via DAG of commits. "Naked" trees are rather bad idea, I think. > >> As I recall the first 'commit' to the git repository for the Linux >> kernel was just a tree, with a reference to that tree as a tag. But >> no commit. > > That was a bad accident that there is a tag that points directly to a > tree of _initial import_, not something to copy. Because git is a distributed version control system, anyone who wants to can create such a directed acyclic graph of commits. And if it's useful I'll gladly add it to my copy of the repository. best regards Jonathan From Juan.Declet-Barreto at MesaAZ.gov Mon Nov 7 15:33:09 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Mon, 7 Nov 2011 13:33:09 -0700 Subject: memory management In-Reply-To: <4EB83D69.2000409@dejaviewphoto.com> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> Message-ID: <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. -----Original Message----- From: Dave Angel [mailto:davea at dejaviewphoto.com] Sent: Monday, November 07, 2011 1:20 PM To: Juan Declet-Barreto Cc: python-list at python.org Subject: Re: memory management On 11/07/2011 02:43 PM, Juan Declet-Barreto wrote: > Hi, > > Can anyone provide links or basic info on memory management, variable dereferencing, or the like? I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directories, but when I set it loose on a directory with thousands of dirs/subdirs, it crashes the DOS session and also the Python shell (when I run it from the shell). This makes it difficult to figure out if the allocated memory or heap space for the DOS/shell session have overflown, or why it is crashing. > > Juan Declet-Barreto [ciId:image001.png at 01CC9D4A.CB6B9D70] I don't have any reference to point you to, but CPython's memory management is really pretty simple. However, it's important to tell us the build of Python, as there are several, with very different memory rules. For example Jython, which is Python running in a Java VM, lets the java garbage collector handle things, and it's entirely different. Likewise, the OS may be relevant. You're using Windows-kind of terminology, but that doesn't prove you're on Windows, nor does it say what version. Assuming 32 bit CPython 2.7 on XP, the principles are simple. When an object is no longer accessible, it gets garbage collected*. So if you build a list inside a function, and the only reference is from a function's local var, then the whole list will be freed when the function exits. The mistakes many people make are unnecessarily using globals, and using lists when iterables would work just as well. The tool on XP to tell how much memory is in use is the task manager. As you point out, its hard to catch a short-running app in the act. So you want to add a counter to your code (global), and see how high it gets when it crashes. Then put a test in your code for the timer value, and do an "input" somewhat earlier. At that point, see how much memory the program is actually using. Now, when an object is freed, a new one of the same size is likely to immediately re-use the space. But if they're all different sizes, it's somewhat statistical. You might get fragmentation, for example. When Python's pool is full, it asks the OS for more (perhaps using swap space), but I don't think it ever gives it back. So your memory use is a kind of ceiling case. That's why it's problematic to build a huge data structure, and then walk through it, then delete it. The script will probably continue to show the peak memory use, indefinitely. * (technically, this is ref counted. When the ref reaches zero the object is freed. Real gc is more lazy scanning) From stefan-usenet at bytereef.org Mon Nov 7 15:47:16 2011 From: stefan-usenet at bytereef.org (Stefan Krah) Date: Mon, 7 Nov 2011 21:47:16 +0100 Subject: memory management In-Reply-To: <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> Message-ID: <20111107204716.GA14201@sleipnir.bytereef.org> Juan Declet-Barreto wrote: > Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which > ships with ESRI's ArcGIS. In addition, I am using some functions in the > arcgisscripting Python geoprocessing module for geographic information > systems (GIS) applications, which can complicate things. I am currently > isolating standard library Python code (e.g., os.walk()) from the > arcgisscripting module to evaluate in which module the environment > crash is occurring. It might be a good idea to check if the problem also occurs with Python 2.7 since Python 2.5 is no longer maintained. Stefan Krah From d at davea.name Mon Nov 7 15:50:19 2011 From: d at davea.name (Dave Angel) Date: Mon, 07 Nov 2011 15:50:19 -0500 Subject: memory management In-Reply-To: <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> Message-ID: <4EB8448B.7030709@davea.name> On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: > Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. You top-posted. In this mailing list, one should type new information after the quoted information, not before. Perhaps a pre-emptive strike is in order. On the assumption that it may be a memory problem, how about you turn the app inside out. Instead of walking the entire tree, getting a list with all the paths, and then working on the list, how about doing the work on each file as you get it. Or even make your own generator from os.walk, so the app can call your logic on each file, and never have all the file (name)s in memory at the same time. Generator: def filelist(top, criteria): for a, b, c in os.walk(): for fiile in files: apply some criteria yield file Now the main app can iterate through this "list" in the usual way for filename in filelist(top, "*.txt"): dosomething... -- DaveA From brenNOSPAMbarn at NObrenSPAMbarn.net Mon Nov 7 16:00:53 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Mon, 7 Nov 2011 21:00:53 +0000 (UTC) Subject: all() is slow? Message-ID: I noticed this (Python 2.6.5 on Windows XP): >>> import random, timeit >>> def myAll(x): ... for a in x: ... if a not in (True, False): ... return False ... return True >>> x = [random.choice([True, False]) for a in xrange(0, 5000000)] >>> timeit.timeit('myAll(x)', 'from __main__ import myAll, x', number=10) 0: 9.7685158309226452 >>> timeit.timeit('all(a in (True, False) for a in x)', 'from __main__ import x', number=10) 1: 12.348196768024984 >>> x = [random.randint(0,100) for a in xrange(0, 5000000)] >>> def myAll(x): ... for a in x: ... if not a <= 100: ... return False ... return True >>> timeit.timeit('myAll(x)', 'from __main__ import myAll, x', number=10) 4: 2.8248207523582209 >>> timeit.timeit('all(a <= 100 for a in x)', 'gc.enable(); from __main__ import x', number=10) 5: 4.6433557896324942 What is the point of the all() function being a builtin if it's slower than writing a function to do the check myself? -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From ramit.prasad at jpmorgan.com Mon Nov 7 16:34:08 2011 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Mon, 7 Nov 2011 16:34:08 -0500 Subject: python-based downloader (youtube-dl) missing critical feature ... In-Reply-To: <4EB3E93E.50500@sequans.com> References: <1320407282.243739@nntp.aceinnovative.com> <4eb3db48$0$29968$c3e8da3$5496439d@news.astraweb.com> <4EB3E93E.50500@sequans.com> Message-ID: <0604E20B5F6F2F4784C9C8C71C5DD4DD2FDF6DD8E0@EMARC112VS01.exchad.jpmchase.net> >Maybe Lbrtchx is one of the Sheldon Cooper's nicknames :o) > >JM > >PS : I have the feeling that my nerdy reference will fall flat... Not completely ;) Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From clp2 at rebertia.com Mon Nov 7 16:39:57 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 7 Nov 2011 13:39:57 -0800 Subject: all() is slow? In-Reply-To: References: Message-ID: On Mon, Nov 7, 2011 at 1:00 PM, OKB (not okblacke) wrote: > ? ? ? ?What is the point of the all() function being a builtin if it's > slower than writing a function to do the check myself? Regardless of whether it's slower (which I expect someone will be along to debunk or explain shortly), do you really want to have to write an additional boilerplate function or block of code /every single time/ you want to do such a check? The runtime speed difference is unlikely to be worth your time as a developer in many cases. And by Murphy's Law, you *will* make errors writing these repetitive code blocks (e.g. forget to negate the conditional), whereas reusing all() makes that much less likely. The trade-off is run-time speed for developer productivity/convenience; Python tends to lean towards the latter (to varying degrees). Cheers, Chris From rosuav at gmail.com Mon Nov 7 16:40:56 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 08:40:56 +1100 Subject: memory management In-Reply-To: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> Message-ID: On Tue, Nov 8, 2011 at 6:43 AM, Juan Declet-Barreto wrote: > > I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directories, but when I set it loose on a directory with thousands of dirs/subdirs, it crashes the DOS session and also the Python shell (when I run it from the shell). This seems a little unusual - it crashes more than its own process? If you use Start... Run and type in "cmd" (or use the "Command Prompt" icon, whereever that is), and invoke Python from there, it crashes cmd as well as Python? If so, I'd be suspecting either some really weird bug in the Python interpreter (try upgrading to 2.7), or a hardware fault in your computer (try running MemTest or running it on a different computer). ChrisA From codewarrior0 at gmail.com Mon Nov 7 16:46:25 2011 From: codewarrior0 at gmail.com (david vierra) Date: Mon, 7 Nov 2011 13:46:25 -0800 (PST) Subject: all() is slow? References: Message-ID: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> On Nov 7, 11:00?am, "OKB (not okblacke)" wrote: > ? ? ? ? What is the point of the all() function being a builtin if it's > slower than writing a function to do the check myself? > But, you didn't write an all() function. You wrote a more specialized allBoolean() function. I think this comparison is more fair to the builtin all(): >>> def myAll(x): ... for a in x: ... if not a: return False ... return True ... >>> timeit.timeit('myAll(a in (True, False) for a in x)', 'from __main__ import myAll, x', number=10) 14.510986388627998 >>> timeit.timeit('all(a in (True, False) for a in x)', 'from __main__ import x', number=10) 12.209779342432576 From jnareb at gmail.com Mon Nov 7 16:50:23 2011 From: jnareb at gmail.com (Jakub Narebski) Date: Mon, 07 Nov 2011 13:50:23 -0800 (PST) Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: <4EB83DDD.1080103@pytex.org> References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> <4EB83DDD.1080103@pytex.org> Message-ID: The following message is a courtesy copy of an article that has been posted to comp.text.tex as well. Jonathan Fine writes: > On 06/11/11 20:28, Jakub Narebski wrote: > > > Note that for gitPAN each "distribution" (usually but not always > > corresponding to single Perl module) is in separate repository. > > The dependencies are handled by CPAN / CPANPLUS / cpanm client > > (i.e. during install). > > Thank you for your interest, Jakub, and also for this information. > With TeX there's a difficult which Perl, I think, does not have. With > TeX we process documents, which may demand specific versions of > packages. LaTeX users are concerned that move on to a later version > will cause documents to break. How you can demand specific version of package? In the "\usepackage[options]{packages}[version]" LaTeX command the argument specifies _minimal_ (oldest) version. The same is true for Perl "use Module VERSION LIST". Nevertheless while with "use Module VERSION" / "use Module VERSION LIST" you can request minimal version of Perl Module, the META build-time spec can include requirement of exact version of required package: http://p3rl.org/CPAN::Meta::Spec Version Ranges ~~~~~~~~~~~~~~ Some fields (prereq, optional_features) indicate the particular version(s) of some other module that may be required as a prerequisite. This section details the Version Range type used to provide this information. The simplest format for a Version Range is just the version number itself, e.g. 2.4. This means that *at least* version 2.4 must be present. To indicate that *any* version of a prerequisite is okay, even if the prerequisite doesn't define a version at all, use the version 0. Alternatively, a version range *may* use the operators < (less than), <= (less than or equal), > (greater than), >= (greater than or equal), == (equal), and != (not equal). For example, the specification < 2.0 means that any version of the prerequisite less than 2.0 is suitable. For more complicated situations, version specifications *may* be AND-ed together using commas. The specification >= 1.2, != 1.5, < 2.0 indicates a version that must be *at least* 1.2, *less than* 2.0, and *not equal to* 1.5. > > Putting all DVD (is it "TeX Live" DVD by the way?) into single > > repository would put quite a bit of stress to git; it was created for > > software development (although admittedly of large project like Linux > > kernel), not 4GB+ trees. > > I'm impressed by how well git manages it. It took about 15 minutes to > build the 4GB tree, and it was disk speed rather than CPU which was > the bottleneck. I still think that using modified contrib/fast-import/import-zips.py (or import-tars.perl, or import-directories.perl) would be a better solution here... [...] > We may be at cross purposes. My first task is get the DVD tree into > git, performing necessary transformations such as expanding zip files > along the way. Breaking the content into submodules can, I believe, > be done afterwards. 'reposurgeon' might help there... or might not. Same with git-subtree tool. But now I understand that you are just building tree objects, and creating references to them (with implicit ordering given by names, I guess). This is to be a start of further work, isn't it? > With DVDs from several years it could take several hours to load > everything into git. For myself, I'd like to do that once, more or > less as a batch process, and then move on to the more interesting > topics. Getting the DVD contents into git is already a significant > piece of work. > > Once done, I can them move on to what you're interested in, which is > organising the material. And I hope that others in the TeX community > will get involved with that, because I'm not building this repository > just for myself. [...] > > > In addition, many TeX users have a TeX DVD. If they import it into a > > > git repository (using for example my script) then the update from 2011 > > > to 2012 would require much less bandwidth. > > > > ??? > > A quick way to bring your TeX distribution up to date is to do a delta > with a later distribution, and download the difference. That's what > git does, and it does it well. So I'm keen to convert a TeX DVD into > a git repository, and then differences can be downloaded. Here perhaps you should take a look at git-based 'bup' backup system. Anyway I am not sure if for git to be able to generate deltas well you have to have DAG of commits, so Git can notice what you have and what you have not. Trees might be not enough here. (!) > > Commit = tree + parent + metadata. > > Actually, any number of parents, including none. What metadata do I > have to provide? At this time nothing, I think, beyond that provided > by the name of a reference (to the root of a tree). Metadata = commit message (here you can e.g. put the official name of DVD), author and committer info (name, email, date and time, timezone; date and time you can get from mtime / creation time of DVD). [cut] -- Jakub Nar?bski From jfine at pytex.org Mon Nov 7 17:03:09 2011 From: jfine at pytex.org (Jonathan Fine) Date: Mon, 07 Nov 2011 22:03:09 +0000 Subject: A Python script to put CTAN into git (from DVDs) In-Reply-To: References: <4EB6A522.3020909@pytex.org> <4EB6CFBB.2090901@pytex.org> <4EB83DDD.1080103@pytex.org> Message-ID: <4EB8559D.8080704@pytex.org> On 07/11/11 21:49, Jakub Narebski wrote: [snip] > But now I understand that you are just building tree objects, and > creating references to them (with implicit ordering given by names, > I guess). This is to be a start of further work, isn't it? Yes, that's exactly the point, and my apologies if I was not clear enough. I'll post again when I've finished the script and performed placed several years of DVD into git. Then the discussion will be more concrete - we have this tree, how do we make it more useful. Thank you for your contributions, particularly telling me about gitpan. -- Jonathan From garyfallidis at gmail.com Mon Nov 7 17:06:40 2011 From: garyfallidis at gmail.com (Eleftherios Garyfallidis) Date: Mon, 7 Nov 2011 23:06:40 +0100 Subject: ctypes accessing functions with double pointers Message-ID: Hello, Is it possible using ctypes to call C functions from a shared object containing double pointers e.g. int foo(float **i) and if yes how? Best wishes, Eleftherios -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Nov 7 17:06:56 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 09:06:56 +1100 Subject: all() is slow? In-Reply-To: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On Tue, Nov 8, 2011 at 8:46 AM, david vierra wrote: > But, you didn't write an all() function. ?You wrote a more specialized > allBoolean() function. I think this comparison is more fair to the > builtin all(): So really, it's not "all() is slow" but "function calls are slow". Maybe it'd be worthwhile making an all-factory: def my_all(code,lst): exec("""def tmp_all(x): for a in x: if not ("""+code+"""): return False return True """) return tmp_all(lst) timeit.timeit('my_all("a in (True, False)",x)','from __main__ import my_all,x',number=10) Bad code imho, but it _is_ faster than both the original and the builtin. ChrisA From clp2 at rebertia.com Mon Nov 7 17:29:46 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 7 Nov 2011 14:29:46 -0800 Subject: ctypes accessing functions with double pointers In-Reply-To: References: Message-ID: On Mon, Nov 7, 2011 at 2:06 PM, Eleftherios Garyfallidis wrote: > Hello, > > Is it possible using ctypes to call C functions from a shared object > containing double pointers e.g. int foo(float **i) and if yes how? (Untested conjecture:) import ctypes # ...create ctypes_wrapped_foo... the_float = ctypes.c_float(42.1) float_ptr = ctypes.byref(the_float) i = ctypes.byref(float_ptr) result_integer = ctypes_wrapped_foo(i) Cheers, Chris From joshua.landau.ws at gmail.com Mon Nov 7 17:51:21 2011 From: joshua.landau.ws at gmail.com (Joshua Landau) Date: Mon, 7 Nov 2011 22:51:21 +0000 Subject: all() is slow? In-Reply-To: References: Message-ID: See these all vs myAll tests: %~> python all_test 0.5427970886230469 1.1579840183258057 3.3052260875701904 3.4992029666900635 3.303942918777466 1.7343430519104004 3.18320894241333 1.6191949844360352 In the first pair and the second pair, the pairs receive the same input. The builtin all outperforms the user-defined. In the second pair, the builtin receives a generator whereas the function just runs. A generator has to be called once every iteration, and this significantly slows it. The main use of "all" is ease, though, as mentioned before. The second is speed when testing lists/generators that don't need to be wrapped. Note: %~> pypy all_test 0.0657250881195 0.0579369068146 0.751952171326 0.657609939575 0.748466968536 0.0586581230164 0.801791906357 0.0550608634949 If speed is your concern, there are simple solutions. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Mon Nov 7 19:06:53 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 07 Nov 2011 19:06:53 -0500 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: On 11/7/2011 1:22 PM, John Gordon wrote: > In JoeM writes: > >> Thanks guys, I was just looking for a one line solution instead of a >> for loop if possible. Why do you consider > >> [x.remove(x[0]) for x in [a,b,c]] > >> cheating? It seems compact and elegant enough for me. It looks like incomplete code with 'somelists = ' or other context omitted. It saves no keypresses '[',...,SPACE,...,']' versus ...,':',ENTER,TAB,... . (TAB with a decent Python aware editor.) > I wouldn't call it cheating, but that solution does a fair bit of > unneccessary work (creating a list comprehension that is never used.) The comprehension ( the code) is used, but the result is not. If the source iterator has a large number of items rather than 3, the throwaway list could become an issue. Example. fin = open('source.txt') fout= open('dest.txt, 'w') for line in fin: fout.write(line.strip()) # versus [fout.write(line.strip()) for line in fin] If source.txt has 100 millions lines, the 'clever' code looks less clever ;=). Comprehensions are intended for creating collections (that one actually wants) and for normal Python coding are best used for that. -- Terry Jan Reedy From tjreedy at udel.edu Mon Nov 7 19:17:09 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 07 Nov 2011 19:17:09 -0500 Subject: memory management In-Reply-To: <20111107204716.GA14201@sleipnir.bytereef.org> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> <20111107204716.GA14201@sleipnir.bytereef.org> Message-ID: On 11/7/2011 3:47 PM, Stefan Krah wrote: > Juan Declet-Barreto wrote: >> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which >> ships with ESRI's ArcGIS. In addition, I am using some functions in the >> arcgisscripting Python geoprocessing module for geographic information >> systems (GIS) applications, which can complicate things. I am currently >> isolating standard library Python code (e.g., os.walk()) from the >> arcgisscripting module to evaluate in which module the environment >> crash is occurring. What *exactly* do you mean by "crash"? > It might be a good idea to check if the problem also occurs with Python 2.7 > since Python 2.5 is no longer maintained. And 2.7 has hundreds of more recent bug fixes. Just one could make a difference. -- Terry Jan Reedy From tjreedy at udel.edu Mon Nov 7 19:23:50 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 07 Nov 2011 19:23:50 -0500 Subject: Python lesson please In-Reply-To: <201111071130.16751.gheskett@wdtv.com> References: <201111061314.43744.gheskett@wdtv.com> <201111070622.39473.gheskett@wdtv.com> <4EB7D99D.5010604@gmx.net> <201111071130.16751.gheskett@wdtv.com> Message-ID: On 11/7/2011 11:30 AM, gene heskett wrote: > Perhaps winderz does not have 'pipe' files so the authors never got caught > out on this? Last I know, Windows not only had no pipe files but also no real in-memory pipes. Maybe one or both of those has changed. -- Terry Jan Reedy From gheskett at wdtv.com Mon Nov 7 19:36:46 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 7 Nov 2011 19:36:46 -0500 Subject: Python lesson please In-Reply-To: References: <201111061314.43744.gheskett@wdtv.com> <201111071130.16751.gheskett@wdtv.com> Message-ID: <201111071936.46138.gheskett@wdtv.com> On Monday, November 07, 2011 07:34:05 PM Terry Reedy did opine: > On 11/7/2011 11:30 AM, gene heskett wrote: > > Perhaps winderz does not have 'pipe' files so the authors never got > > caught out on this? > > Last I know, Windows not only had no pipe files but also no real > in-memory pipes. Maybe one or both of those has changed. Sheesh.. How the heck do you get anything done on winderz then. :( Answer not needed as they regularly reinvent the wheel because everything has to be self contained, poorly IMO. Most of their wheels ride a bit rough. ;) Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: I believe that professional wrestling is clean and everything else in the world is fixed. -- Frank Deford, sports writer From jehugaleahsa at gmail.com Mon Nov 7 21:21:52 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 7 Nov 2011 18:21:52 -0800 (PST) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: On Nov 7, 12:44?pm, John Gordon wrote: > In John Gordon writes: > > > In <415d875d-bc6d-4e69-bcf8-39754b450... at n18g2000vbv.googlegroups.com> Travis Parks writes: > > > Which web frameworks have people here used and which have they found > > > to be: scalable, RAD compatible, performant, stable and/or providing > > > good community support? I am really trying to get as much feedback as > > I've used Django and it seems to be a very nice framework. ?However I've > > only done one project so I haven't delved too deeply. > > You are probably looking for more detail than "It's a nice framework" :-) > > The database model in Django is powerful; it allows you to do queries in > native Python code without delving into backend SQL stuff. > > I don't know how scalable/performant the database model is, as the one > project I worked on didn't deal with a ton of data. ?(But I'd be surprised > if it had poor performance.) > > The URL dispatcher provides a very nice and logical way to associate a > given URL with a given method call. > > Community support is excellent. > > -- > John Gordon ? ? ? ? ? ? ? ? ? A is for Amy, who fell down the stairs > gor... at panix.com ? ? ? ? ? ? ?B is for Basil, assaulted by bears > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -- Edward Gorey, "The Gashlycrumb Tinies" I started the battle today. The "new guy" was trying to sell me on CodeIgnitor. I haven't looked at it, but it is PHP, so I really want to avoid it. The good thing is that all of his "friends" have been telling him to get into Python. I have been trying to convince him that PHP isn't cut out for background services and is mostly a front- end language. Python is much more geared towards hardcore data processing. Why write the system in two languages? I have been spending a lot of time looking at the Pyramid project: the next generation of the Pylons project. It looks powerful, but it seems to be a lot more complex than Django. From lie.1296 at gmail.com Mon Nov 7 23:17:14 2011 From: lie.1296 at gmail.com (Lie Ryan) Date: Tue, 08 Nov 2011 15:17:14 +1100 Subject: How to mix-in __getattr__ after the fact? In-Reply-To: <8bc11029-860e-4d3a-8770-062e16e31514@j39g2000yqc.googlegroups.com> References: <4630c4d0-86bc-4295-8bbb-6f58415191c8@v15g2000vbm.googlegroups.com> <4EAAF264.1050307@stoneleaf.us> <8bc11029-860e-4d3a-8770-062e16e31514@j39g2000yqc.googlegroups.com> Message-ID: On 10/31/2011 11:01 PM, dhyams wrote: > > Thanks for all of the responses; everyone was exactly correct, and > obeying the binding rules for special methods did work in the example > above. Unfortunately, I only have read-only access to the class > itself (it was a VTK class wrapped with SWIG), so I had to find > another way to accomplish what I was after. > As a big huge hack, you can always write a wrapper class: class Wrapper(object): def __init__(self, *args, **kwargs): self.__object = MySWIGClass(*args, **kwargs) def __getattr__(self, attr): try: return getattr(self.__object, attr) except AttributeError: ... From kwa at kuwata-lab.com Mon Nov 7 23:32:46 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Tue, 8 Nov 2011 13:32:46 +0900 Subject: easy_install doesn't install non-package *.py file Message-ID: I got trouble about easy_install command. My package: README.rst setup.py foobar/ foobar/__init__.py foobar/data/ foobar/data/template.py In the above example, 'foobar/data/template.py' is just a template data file (= not a python module file). (notice that 'foobar/data/__init__.py' doesn't exist.) In this case, 'foobar/data/template.py' file is NOT installed when trying 'easy_install foobar'. This is trouble what I got. I found that: * foobar.tar.gz created by 'easy_install sdist' contains 'foobar/data/template.py' correctly. * foobar.egg created by 'easy_install bdist' doesn't contain 'foobar/data/template.py' file. Question: how can I enforce easy_install command to install 'foobar/data/template.py' (or non-package *.py file)? -- regars, makoto kuwata From cs at zip.com.au Mon Nov 7 23:59:00 2011 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 8 Nov 2011 15:59:00 +1100 Subject: Python lesson please In-Reply-To: <201111071500.49230.gheskett@wdtv.com> References: <201111071500.49230.gheskett@wdtv.com> Message-ID: <20111108045900.GA12613@cskk.homeip.net> On 07Nov2011 15:00, gene heskett wrote: | On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine: | > On 11/07/2011 11:40 AM, gene heskett wrote: | > > Down toward the bottom of the file, the tab indentations were as high | > > as 33 leading tabs per line. Each stanza of the data was tab | > > indented 2 additional tabs from the one above it in the original | > > file. 30k was perhaps a poor SWAG, but 10 to 15k seems an entirely | > > reasonable guess. | > | > What program are you using to read the file and support that claim? | | vim. But remember, this first one started out as a copy/paste from the | firefox-7.0.1 screen. I don't suppose you had autoident turned on? I hate using cu/paste to fetch data; _always_ use a "download" link, or use the browser's "save page as" facility. But still, if your MD5 checksums now match... Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Footnotes that extend to a second page are an abject failure of design. - Bringhurst, _The Elements of Typographic Style_ From lie.1296 at gmail.com Tue Nov 8 00:09:56 2011 From: lie.1296 at gmail.com (Lie Ryan) Date: Tue, 08 Nov 2011 16:09:56 +1100 Subject: Python ORMs Supporting POPOs and Substituting Layers in Django In-Reply-To: References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: On 11/08/2011 01:21 PM, Travis Parks wrote: > On Nov 7, 12:44 pm, John Gordon wrote: >> In John Gordon writes: >> >>> In<415d875d-bc6d-4e69-bcf8-39754b450... at n18g2000vbv.googlegroups.com> Travis Parks writes: >>>> Which web frameworks have people here used and which have they found >>>> to be: scalable, RAD compatible, performant, stable and/or providing >>>> good community support? I am really trying to get as much feedback as >>> I've used Django and it seems to be a very nice framework. However I've >>> only done one project so I haven't delved too deeply. >> >> You are probably looking for more detail than "It's a nice framework" :-) >> >> The database model in Django is powerful; it allows you to do queries in >> native Python code without delving into backend SQL stuff. >> >> I don't know how scalable/performant the database model is, as the one >> project I worked on didn't deal with a ton of data. (But I'd be surprised >> if it had poor performance.) >> >> The URL dispatcher provides a very nice and logical way to associate a >> given URL with a given method call. >> >> Community support is excellent. >> >> -- >> John Gordon A is for Amy, who fell down the stairs >> gor... at panix.com B is for Basil, assaulted by bears >> -- Edward Gorey, "The Gashlycrumb Tinies" > > I started the battle today. The "new guy" was trying to sell me on > CodeIgnitor. I haven't looked at it, but it is PHP, so I really want > to avoid it. The good thing is that all of his "friends" have been > telling him to get into Python. I have been trying to convince him > that PHP isn't cut out for background services and is mostly a front- > end language. Python is much more geared towards hardcore data > processing. Why write the system in two languages? > > I have been spending a lot of time looking at the Pyramid project: the > next generation of the Pylons project. It looks powerful, but it seems > to be a lot more complex than Django. CodeIgniter is a very fine framework, however it builds on top of a shitty excuse of a language called PHP. I've found that Django has a much better debugging tools; when a Django page produces an exception, it would always produce a useful error page. I haven't been able to do the same in CodeIgniter (nor in any PHP framework I've used, I'm starting to think it's a language limitation); often when you have errors, PHP would just silently return empty or partial pages even with all the debugging flags on. IMO, Python has a much nicer choice of built-in data structure for data processing. Python has a much more mature object-orientation, e.g. I prefer writing l.append(x) rather than array_push(l, x). I think these qualities are what makes you think Python is much, much more suitable for data processing than PHP; and I wholesomely agree. Database abstraction-wise, Django's ORM wins hands down against CodeIgniter's ActiveRecord. CodeIgniter's ActiveRecord is basically just a thin wrapper that abstracts the perks of various database engine. Django's ORM is a full blown ORM, it handles foreign key relationships in OO way. The only disadvantage of Django's ORM is that since it's written in Python, if you need to write a program working on the same database that doesn't use Django nor Python, then you'll have a problem since you'll have to duplicate the foreign key relationships. With all the bashing of PHP, PHP do have a few advantages. PHP and CodeIgniter is much easier to set up and running than Django; and the ability to create a .php file and have it running without having to write the routing file is sometimes a bliss. And PHP are often used as their own templating language; in contrast with Django which uses a separate templating language. Having a full blown language as your templating language can be a double-edged sword, but it is useful nevertheless for experimental work. IMO, while it is easier to get up and running in PHP, in the long run Python is much better in almost any other aspects. From simeon.chaos at gmail.com Tue Nov 8 00:10:59 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Mon, 7 Nov 2011 21:10:59 -0800 (PST) Subject: overview on dao Message-ID: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> Dao is a a functional logic solver (similar to lambdaProlog, Curry) written in python. The links related to dao are here: pypi distribution and document: http://pypi.python.org/pypi/daot code repository: https://github.com/chaosim/dao dao groups on google: Group name: daot, Group home page: http://groups.google.com/group/daot, Group email address: daot at googlegroups.com old stuffs: http://code.google.com/p/daot(old, deprecated) google+ pages: https://plus.google.com/112050694070234685790 Dao has the features such as * lisp style programming: * call/cc, block/return-from, unwind-protect, catch/throw; Dao is implemented by continuation passing style, so it is natural to implement such stuff. And I have some little improvement to the trampoline technology because I need it coexist with the technology of using yield statement to implement unifying and backtracking. The code for evaluating lisp style expression is borrowed from the book "Lisp in Small Pieces" wrote by Christian Queinnec and Ecole Polytechnique. * function and macro; The concept of function and macro in dao become more general than in lisp, because we can define them with multiple rules and take advantage of unifying and backtracking. * eval, so called meta circular evaluation. * prolog style programming: * logic variable and unify; * backtracking; * findall, repeat/fail, call, once, and so on; * cut. At first, unify is implemented by using exception, and backtracking by using two continuations(succeed continuation and fail continuation) technology, borrowed the code from pypy prolog. Now, the fail continuation is removed, and both unifying and backtracking is implemented by using 'yield' statement, which I learned from YieldProlog (http://yieldprolog.sourceforge.net). Dao run faster than before by using yield statement, removing class definition of continuation, and not boxing atomic and list values(compare to pypy prolog without translation or jit). Up to now I do not use the pypy's translation or jit feature to speedup, and all of the tests in dao 0.7.3 run in about two minutes. * many other useful builtins that simulate lisp and prolog primitives. * some builtins that cooperate with python. * builtin parser, which is the most powerful parser I have seen. The parser in dao is basically a recursive decent parser with backtracking, but It also support direct or indirect left recursive rules by using memorization when needed. The programmer can toggle memorization of any command that is not left recursive. the grammar in dao is some similar to DCG(definite clause grammar), but is more flexible than DCG. It have the expressive power beyond context free or sensitive grammar, parsing expression grammar. Dao can be used to parse any object, not limiting to text. Many builtin terminal and combinative parsing primitives are provided. In dao, I have found and implemented the unrivalled technology to uniting parser and evaluator by the meta circular evaluation. So Dao can be used to implement a programming language in which the syntax is dynamic, that is to say, the syntax can be defined on the fly by the programmer easily. A little sample to demonstrate this technology is given in the files dao/samples/sexpression.py and dao/dao/tests/ testsexpresson.py. ------------------------------------------------------------------------- Dinpy: a child language born and live in python. Dinpy can be looked as the syntax sugar for dao in python. It arises accidentally when I wrote tests for dao. A detailed introduction is as follows: I hate the too many parentheses when I wrote tests for the 'let' statement of lisp, so I replace embedded tuples with dict for the bindings, and after the spark of inspiration, the door to dinpy was open. I learned a new method for inventing a new language from it: use the syntax based on the operator of the mother language for building the child language. -------------------------------------------------------------------------- I have written some Chinese documents for dao, but few English. The Chinese document is not complete yet. With the functional logic programming and dynamic grammar on the shoulders of the great python, many possibilities arises with dao, such as parsing, inventing embedded DSL with operator syntax, independent domain specific language or general language, text processing, natural language processing, expert system, artificial intelligence, web application, and so on. Now: * I hope more people know and use dao. Or maybe something wrong in dao prevent it being used in real application, and I hope to know what it is. * Maybe anyone have interest and time to join in developing dao or writing some documents or articles? * More tests are needed always, and I hope to get some bug report from any other people. * the benchmarks of the dao, comparation with similar package, and so on. * I have a long todo list, I hope someone else can join in dao project. From lie.1296 at gmail.com Tue Nov 8 00:29:25 2011 From: lie.1296 at gmail.com (Lie Ryan) Date: Tue, 08 Nov 2011 16:29:25 +1100 Subject: Question about 'iterable cursors' In-Reply-To: <4eb77503$0$1692$742ec2ed@news.sonic.net> References: <87pqh54nmh.fsf@dpt-info.u-strasbg.fr> <4eb77503$0$1692$742ec2ed@news.sonic.net> Message-ID: On 11/07/2011 05:04 PM, John Nagle wrote: > Realize that SQLite is not a high-performance multi-user database. > You use SQLite to store your browser preferences, not your customer > database. I agree with SQLite is not multi-user; I disagree that SQLite is not a high-performance database. In single user cases, SQLite should far outperform a client-server-based database engine since it doesn't have the client-server overhead. From simeon.chaos at gmail.com Tue Nov 8 00:34:55 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Mon, 7 Nov 2011 21:34:55 -0800 (PST) Subject: simpler over view on dao: a functional logic solver with builtin parsing power, and dinpy, the sugar syntax for dao in python Message-ID: Dao is a a functional logic solver (similar to lambdaProlog, Curry) written in python. The links related to dao are here: pypi distribution and document: http://pypi.python.org/pypi/daot code repository: https://github.com/chaosim/dao dao groups on google: http://groups.google.com/group/daot, daot at googlegroups.com old stuffs: http://code.google.com/p/daot(old, deprecated) google+ pages: https://plus.google.com/112050694070234685790 Dao has the features such as * lisp style programming: * call/cc, block/return-from, unwind-protect, catch/throw; * function and macro; * eval, so called meta circular evaluation. * prolog style programming: * logic variable and unify; * backtracking; * findall, repeat/fail, call, once, and so on; * cut. * many other useful builtins that simulate lisp and prolog primitives. * some builtins that cooperate with python. * builtin parser, which is the most powerful parser I have seen, it support the features as below: * paramater grammar, similar to DCG( definite clause grammar), but more flexible * dynamic grammar, * left recursive * memoriaziont parsing result * many builtins, include terminal and cominative matchers. ------------------------------------------------------------------------- Dinpy: a child language born and live in python. Dinpy can be looked as the syntax sugar for dao in python. A piece of code in dinpy is listed as below: parse_text(char(x1)+any(~char('b')+some(char(x1)))+eoi, 'abaaaa'), let( i<<0 ). do[ repeat, prin(i), ++i, iff(i<3).do[fail] ], letr( a << fun(x) [ and_p(b(x),c(x)) ] [ d(x) ], b << fun(1) ['b1'] (4) ['b4'], c << fun(4) ['c4'], d << fun(3) ['d3'], ).do[ a(x), prin(x) ], each(i)[1:3]. loop[prin(i)], i << 0, loop[ i << i+1, prin(i)].when(i==3), case(1). of(1)[prin(1)]. of(2)[prin(2)] -------------------------------------------------------------------------- Some Chinese documents for dao is written, but few English. The Chinese document is not complete yet. With the functional logic programming and dynamic grammar on the shoulders of the great python, many possibilities arises with dao, such as parsing, inventing embedded DSL with operator syntax, independent domain specific language or general language, text processing, natural language processing, expert system, artificial intelligence, web application, and so on. Now: * I hope more people know and use dao. Or maybe something wrong in dao prevent it being used in real application, and I hope to know what it is. * Maybe anyone have interest and time to join in developing dao or writing some documents or articles? * More tests are needed always, and I hope to get some bug report from any other people. * the benchmarks of the dao, comparation with similar package, and so on. * I have a long todo list, I hope someone else can join in dao project. From steve+comp.lang.python at pearwood.info Tue Nov 8 00:58:17 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Nov 2011 05:58:17 GMT Subject: How to mix-in __getattr__ after the fact? References: <4630c4d0-86bc-4295-8bbb-6f58415191c8@v15g2000vbm.googlegroups.com> <4EAAF264.1050307@stoneleaf.us> <8bc11029-860e-4d3a-8770-062e16e31514@j39g2000yqc.googlegroups.com> Message-ID: <4eb8c4f9$0$29988$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Nov 2011 15:17:14 +1100, Lie Ryan wrote: > On 10/31/2011 11:01 PM, dhyams wrote: >> >> Thanks for all of the responses; everyone was exactly correct, and >> obeying the binding rules for special methods did work in the example >> above. Unfortunately, I only have read-only access to the class itself >> (it was a VTK class wrapped with SWIG), so I had to find another way to >> accomplish what I was after. >> >> > As a big huge hack, you can always write a wrapper class: > > class Wrapper(object): > def __init__(self, *args, **kwargs): > self.__object = MySWIGClass(*args, **kwargs) > def __getattr__(self, attr): > try: > return getattr(self.__object, attr) > except AttributeError: > ... That's not a hack, that's a well-respected design pattern called Delegation. http://rosettacode.org/wiki/Delegate http://en.wikipedia.org/wiki/Delegation_pattern In this case, you've implemented about half of automatic delegation: http://code.activestate.com/recipes/52295 which used to be much more important in Python prior to the type/class unification in version 2.2. To also delegate special dunder methods using new-style classes, see this: http://code.activestate.com/recipes/252151 -- Steven From gheskett at wdtv.com Tue Nov 8 01:29:46 2011 From: gheskett at wdtv.com (gene heskett) Date: Tue, 8 Nov 2011 01:29:46 -0500 Subject: Python lesson please In-Reply-To: <20111108045900.GA12613@cskk.homeip.net> References: <201111071500.49230.gheskett@wdtv.com> <20111108045900.GA12613@cskk.homeip.net> Message-ID: <201111080129.46728.gheskett@wdtv.com> On Tuesday, November 08, 2011 12:53:20 AM Cameron Simpson did opine: > On 07Nov2011 15:00, gene heskett wrote: > | On Monday, November 07, 2011 02:43:11 PM Dave Angel did opine: > | > On 11/07/2011 11:40 AM, gene heskett wrote: > | > > Down toward the bottom of the file, the tab indentations were as > | > > high as 33 leading tabs per line. Each stanza of the data was > | > > tab indented 2 additional tabs from the one above it in the > | > > original file. 30k was perhaps a poor SWAG, but 10 to 15k seems > | > > an entirely reasonable guess. > | > > | > What program are you using to read the file and support that claim? > | > | vim. But remember, this first one started out as a copy/paste from > | the firefox-7.0.1 screen. > > I don't suppose you had autoident turned on? > I think it is. I gave up turning it off long ago because it was always on on the next launch. Today I've forgotten how to turn it off. Like hitting oneself in the head with a hammer, it feels so good when you stop. :) > I hate using cu/paste to fetch data; _always_ use a "download" link, or > use the browser's "save page as" facility. Which would have saved all the html codes too, this code was being displayed in a window of the main window. > But still, if your MD5 checksums now match... Not on that file, but on the next pull it was, and works now. And on the first file, the blink compare disclosed I had some indentation wrong, and that there was a lowercase b in front of all the opening double quotes used that I didn't get originally. I have no clue what this: b"hex data" means to python. > Cheers, Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: To love is good, love being difficult. From rosuav at gmail.com Tue Nov 8 01:42:20 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 17:42:20 +1100 Subject: Python lesson please In-Reply-To: <201111080129.46728.gheskett@wdtv.com> References: <201111071500.49230.gheskett@wdtv.com> <20111108045900.GA12613@cskk.homeip.net> <201111080129.46728.gheskett@wdtv.com> Message-ID: On Tue, Nov 8, 2011 at 5:29 PM, gene heskett wrote: > Not on that file, but on the next pull it was, and works now. ?And on the > first file, the blink compare disclosed I had some indentation wrong, and > that there was a lowercase b in front of all the opening double quotes used > that I didn't get originally. ?I have no clue what this: > ? ? ? ?b"hex data" means to python. That's the repr() of a Bytes string (as opposed to a Unicode string) in Python 3. If that's your only issue, I'd say you have it working fine under Python 3; if there are other problems, try running it under Python 2.7. ChrisA From moky.math at gmail.com Tue Nov 8 02:07:39 2011 From: moky.math at gmail.com (Laurent Claessens) Date: Tue, 08 Nov 2011 08:07:39 +0100 Subject: Extracting elements over multiple lists? In-Reply-To: References: Message-ID: Le 07/11/2011 19:01, JoeM a ?crit : > Thanks guys, I was just looking for a one line solution instead of a > for loop if possible. Why do you consider > > [x.remove(x[0]) for x in [a,b,c]] > > cheating? It seems compact and elegant enough for me. I have the feeling that it does not do what I expect it does just by seeing the line. It is list comprehension, but the point is absolutely not in creating a list. I'd say it breaks the rule ?Explicit is better than implicit.? while ?Special cases aren't special enough to break the rules.? But well... could be a matter of taste; I prefer the loop. Laurent From rosuav at gmail.com Tue Nov 8 02:35:32 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 18:35:32 +1100 Subject: Python ORMs Supporting POPOs and Substituting Layers in Django In-Reply-To: References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: On Tue, Nov 8, 2011 at 4:09 PM, Lie Ryan wrote: > IMO, Python has a much nicer choice of built-in data structure for data > processing. Python has a much more mature object-orientation, e.g. I prefer > writing l.append(x) rather than array_push(l, x). I think these qualities > are what makes you think Python is much, much more suitable for data > processing than PHP; and I wholesomely agree. > Two more examples where Python's lists are superior to PHP's arrays. Array literal syntax feels like a function call, but list literals are slim and easy to use inside expressions (try creating a nested array as a function argument - you'll get a forest of parens). Also, dereferencing an array only works on an array variable - if you have a function that returns an array, you can't dereference it directly: $foo = func()[1]; # doesn't work $foo = func(); $foo=$foo[1]; # works I much prefer the "everything's an object" notion. C's array literals are just as weird (although in C, you can directly dereference a literal character array - "ABCDEFG"[note_idx] will give you a note name as a char)... much easier when a variable name is just an expression, a function call is an expression, a literal is an expression, and you can work with them all the same way. ChrisA From vaira20ster at gmail.com Tue Nov 8 05:05:53 2011 From: vaira20ster at gmail.com (vaira muthu) Date: Tue, 8 Nov 2011 15:35:53 +0530 Subject: file extension while saving Python files Message-ID: Team, In Python IDE, while we save the script, it will prompt the save Dialog. If we specify the filename as "Test". Then file will be saved without extension as "Test" and not "Test.py". Is it possible to save the script with .py extension automatically (as Test.py)? Thanks, vairamuthu. From lycka at carmen.se Tue Nov 8 05:50:53 2011 From: lycka at carmen.se (=?ISO-8859-1?Q?Magnus_Lyck=E5?=) Date: Tue, 08 Nov 2011 11:50:53 +0100 Subject: file extension while saving Python files In-Reply-To: References: Message-ID: On 2011-11-08 11:05, vaira muthu wrote: > In Python IDE, ... Which Python IDE? There are dozens: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments From hfaber at invalid.net Tue Nov 8 07:09:20 2011 From: hfaber at invalid.net (Henrik Faber) Date: Tue, 08 Nov 2011 13:09:20 +0100 Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On 07.11.2011 23:06, Chris Angelico wrote: > On Tue, Nov 8, 2011 at 8:46 AM, david vierra wrote: >> But, you didn't write an all() function. You wrote a more specialized >> allBoolean() function. I think this comparison is more fair to the >> builtin all(): > > So really, it's not "all() is slow" but "function calls are slow". > Maybe it'd be worthwhile making an all-factory: PLEASE say you're joking. If I saw code like that on any of our project, this would definitely qualify for a DailyWTF. Regards, Henrik From rosuav at gmail.com Tue Nov 8 07:14:09 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Nov 2011 23:14:09 +1100 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On Tue, Nov 8, 2011 at 11:09 PM, Henrik Faber wrote: > On 07.11.2011 23:06, Chris Angelico wrote: >> So really, it's not "all() is slow" but "function calls are slow". >> Maybe it'd be worthwhile making an all-factory: > > PLEASE say you're joking. If I saw code like that on any of our project, > this would definitely qualify for a DailyWTF. For the benefit of anyone who was actually in doubt: YES, I was joking. Do *not* put code like this into any production project. But it's still fun to write bad code once in a while. It's like Mythbusters getting to crash cars. Fun partly _because_ it's something you normally don't want to do. ChrisA From d at davea.name Tue Nov 8 07:58:19 2011 From: d at davea.name (Dave Angel) Date: Tue, 08 Nov 2011 07:58:19 -0500 Subject: Python ORMs Supporting POPOs and Substituting Layers in Django In-Reply-To: References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: <4EB9276B.7070207@davea.name> On 11/08/2011 02:35 AM, Chris Angelico wrote: > On Tue, Nov 8, 2011 at 4:09 PM, Lie Ryan wrote: > > I much prefer the "everything's an object" notion. C's array literals > are just as weird (although in C, you can directly dereference a > literal character array - "ABCDEFG"[note_idx] will give you a note > name as a char) Hey, in C you can also do note_idx["ABCDEFG"] and get the selected character as if you had written what you showed. Plenty of opportunity in C to write illegible code. -- DaveA From gnarlodious at gmail.com Tue Nov 8 08:20:51 2011 From: gnarlodious at gmail.com (Gnarlodious) Date: Tue, 8 Nov 2011 05:20:51 -0800 (PST) Subject: Help catching error message Message-ID: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> What I say is this: def SaveEvents(self,events): try: plistlib.writePlist(events, self.path+'/Data/Events.plist') # None if OK except IOError: return "IOError: [Errno 13] Apache can't write Events.plist file" Note that success returns"None" while failure returns a string. I catch the error like this: errorStatus=Data.Dict.SaveEvents(Data.Plist.Events) if errorStatus: content=errorStatus It works, but isn there a more elegant way to do it? As in, one line? I can imagine if success returned nothing then content would remain unchanged. Isn't there a built-in way to send an error string back and then catch it as a variable name? This is Py3 inside WSGI. -- Gnarlie From garyfallidis at gmail.com Tue Nov 8 08:21:29 2011 From: garyfallidis at gmail.com (Eleftherios Garyfallidis) Date: Tue, 8 Nov 2011 14:21:29 +0100 Subject: ctypes accessing functions with double pointers In-Reply-To: References: Message-ID: Thank you Chris :-) On Mon, Nov 7, 2011 at 11:29 PM, Chris Rebert wrote: > On Mon, Nov 7, 2011 at 2:06 PM, Eleftherios Garyfallidis > wrote: > > Hello, > > > > Is it possible using ctypes to call C functions from a shared object > > containing double pointers e.g. int foo(float **i) and if yes how? > > (Untested conjecture:) > > import ctypes > # ...create ctypes_wrapped_foo... > the_float = ctypes.c_float(42.1) > float_ptr = ctypes.byref(the_float) > i = ctypes.byref(float_ptr) > result_integer = ctypes_wrapped_foo(i) > > Cheers, > Chris > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon at panix.com Tue Nov 8 10:17:19 2011 From: gordon at panix.com (John Gordon) Date: Tue, 8 Nov 2011 15:17:19 +0000 (UTC) Subject: file extension while saving Python files References: Message-ID: In vaira muthu writes: > Team, > In Python IDE, while we save the script, it will prompt the save > Dialog. If we specify the filename as "Test". Then file will be saved > without extension as "Test" and not "Test.py". Is there a drop-down list selection for specifying the file type? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From rajcspalani at gmail.com Tue Nov 8 10:53:52 2011 From: rajcspalani at gmail.com (mannan) Date: Tue, 8 Nov 2011 07:53:52 -0800 (PST) Subject: file extension while saving Python files In-Reply-To: References: Message-ID: <6395.778.1320767632967.JavaMail.geo-discussion-forums@prap37> if it is not a python ide then, you have to explicitly specify the extension. From rajcspalani at gmail.com Tue Nov 8 10:53:52 2011 From: rajcspalani at gmail.com (mannan) Date: Tue, 8 Nov 2011 07:53:52 -0800 (PST) Subject: file extension while saving Python files In-Reply-To: References: Message-ID: <6395.778.1320767632967.JavaMail.geo-discussion-forums@prap37> if it is not a python ide then, you have to explicitly specify the extension. From jeanmichel at sequans.com Tue Nov 8 12:15:40 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 08 Nov 2011 18:15:40 +0100 Subject: Help catching error message In-Reply-To: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> Message-ID: <4EB963BC.7080506@sequans.com> Gnarlodious wrote: > What I say is this: > > def SaveEvents(self,events): > try: > plistlib.writePlist(events, self.path+'/Data/Events.plist') # > None if OK > except IOError: > return "IOError: [Errno 13] Apache can't write Events.plist > file" > > Note that success returns"None" while failure returns a string. > > I catch the error like this: > > errorStatus=Data.Dict.SaveEvents(Data.Plist.Events) > if errorStatus: content=errorStatus > > It works, but isn there a more elegant way to do it? As in, one line? > I can imagine if success returned nothing then content would remain > unchanged. Isn't there a built-in way to send an error string back and > then catch it as a variable name? > > This is Py3 inside WSGI. > > -- Gnarlie > Hi, There's no need to rephrase an exception unless you want to *add* information. def saveEvents(self,events): plistlib.writePlist(events, self.path+'/Data/Events.plist') try: Data.Dict.SaveEvents(Data.Plist.Events) except IOError, exc: # i'm using python 2.5, this except clause may have changed in py3 content = str(exc) JM From jeanmichel at sequans.com Tue Nov 8 12:24:30 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 08 Nov 2011 18:24:30 +0100 Subject: Help catching error message In-Reply-To: <4EB963BC.7080506@sequans.com> References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> <4EB963BC.7080506@sequans.com> Message-ID: <4EB965CE.4020300@sequans.com> Jean-Michel Pichavant wrote: > Gnarlodious wrote: >> What I say is this: >> >> def SaveEvents(self,events): >> try: >> plistlib.writePlist(events, self.path+'/Data/Events.plist') # >> None if OK >> except IOError: >> return "IOError: [Errno 13] Apache can't write Events.plist >> file" >> >> Note that success returns"None" while failure returns a string. >> >> I catch the error like this: >> >> errorStatus=Data.Dict.SaveEvents(Data.Plist.Events) >> if errorStatus: content=errorStatus >> >> It works, but isn there a more elegant way to do it? As in, one line? >> I can imagine if success returned nothing then content would remain >> unchanged. Isn't there a built-in way to send an error string back and >> then catch it as a variable name? >> >> This is Py3 inside WSGI. >> >> -- Gnarlie >> > Hi, > > There's no need to rephrase an exception unless you want to *add* > information. > > def saveEvents(self,events): > plistlib.writePlist(events, self.path+'/Data/Events.plist') > try: Data.Dict.SaveEvents(Data.Plist.Events) > except IOError, exc: # i'm using python 2.5, this except clause may > have changed in py3 > content = str(exc) > > JM > looks like for whatever reason the formating has gone crazy. http://www.copypastecode.com/100088/ jm From nad at acm.org Tue Nov 8 12:28:28 2011 From: nad at acm.org (Ned Deily) Date: Tue, 08 Nov 2011 09:28:28 -0800 Subject: file extension while saving Python files References: Message-ID: In article , vaira muthu wrote: > In Python IDE, while we save the script, it will prompt the save > Dialog. If we specify the filename as "Test". Then file will be saved > without extension as "Test" and not "Test.py". > > Is it possible to save the script with .py extension automatically (as > Test.py)? If the IDE you are referring to is IDLE, there is an issue recently opened that requests this change: http://bugs.python.org/issue10364 -- Ned Deily, nad at acm.org From tjreedy at udel.edu Tue Nov 8 14:09:18 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 08 Nov 2011 14:09:18 -0500 Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: On 11/7/2011 11:32 PM, Makoto Kuwata wrote: > I got trouble about easy_install command. > > My package: > > README.rst > setup.py > foobar/ > foobar/__init__.py > foobar/data/ > foobar/data/template.py > > In the above example, 'foobar/data/template.py' is just a > template data file (= not a python module file). Then why is it .py? If it is just data, use .txt. If .py, it should be python code run either directly or imported, though I suppose you could exec it. (I have no idea how renaming would affect your problem.) > (notice that 'foobar/data/__init__.py' doesn't exist.) I did, and no, I do not know the answer to your question. -- Terry Jan Reedy From anikom15 at gmail.com Tue Nov 8 14:11:58 2011 From: anikom15 at gmail.com (Westley =?iso-8859-1?Q?Mart=EDnez?=) Date: Tue, 8 Nov 2011 11:11:58 -0800 Subject: Line continuation issue\ In-Reply-To: References: Message-ID: <20111108191158.GA21926@kubrick> On Fri, Nov 04, 2011 at 11:10:58AM -0400, Steven Lehar wrote: > Is this the right place to propose language extensions? > > My Python code keeps expanding rightwards, it is difficult to keep it > contained within reasonable limits. But the standard line continuation \ > is positively anti-Pythonic because an *invisible* white space between \ > and [CR] will render it useless. > > How about a new Python symbol, maybe \\ that CAN have following whitespace > which is ignored, so that seeing a \\ in the code forces it to continue on > the next line. > > Has this issue been discussed already? > > slehar Use subroutines. From ramit.prasad at jpmorgan.com Tue Nov 8 14:34:30 2011 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 8 Nov 2011 14:34:30 -0500 Subject: xml-rpc server on wine In-Reply-To: <1320685031.8941.11.camel@linux-yu4c.site> References: <650e9d68-e606-4424-bca7-174295306d82@ht6g2000vbb.googlegroups.com> <1320685031.8941.11.camel@linux-yu4c.site> Message-ID: <0604E20B5F6F2F4784C9C8C71C5DD4DD2FDF6DE578@EMARC112VS01.exchad.jpmchase.net> >> Hi, I have a XML-RPC server python running on VM Windows (on Linux) >> and a XML-RPC client python on Linux. Server and client have different >> IP address. I'd like migrate server on wine. How can communicate >> server and client? IP address is different or is the same? >> Can you help me? >Not really, this doesn't have much of anything to do with Python. If >you run a network application on wine [assuming that even works] the >application will have the same IP/interface as any other application or >service running on the host. Wine is not a 'virtualization' solution. Unless you have a specific need to run it in a virtual machine (which WINE is not), why not run it directly from Linux? I generally prefer to use a DNS name or hostname to connect instead of IP because the IP addresses can be dynamic (especially when you start accessing it from outside your local network). Even internally, I tend to use hostnames and not IP addresses, but mostly because it is faster/easier for me to type (I assign static IPs internally). Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From steve+comp.lang.python at pearwood.info Tue Nov 8 17:16:33 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Nov 2011 22:16:33 GMT Subject: Help catching error message References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> Message-ID: <4eb9aa41$0$29970$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Nov 2011 05:20:51 -0800, Gnarlodious wrote: > What I say is this: > > def SaveEvents(self,events): > try: > plistlib.writePlist(events, self.path+'/Data/Events.plist') # > None if OK > except IOError: > return "IOError: [Errno 13] Apache can't write Events.plist > file" > > Note that success returns"None" while failure returns a string. I started off writing a sarcastic response about people who refuse to learn idiomatic Python and instead insist on writing (e.g.) Java or PHPP in Python. But then I eventually got to the *very last line* of your post where you noted that you were doing this in WSGI. For future reference, when writing unidiomatic code *deliberately*, please say so up front, at the start of your message rather than at the end, and save your readers (or at least *me*) from jumping to the wrong conclusion. Change the function to this: def SaveEvents(self,events): try: plistlib.writePlist(events, self.path+'/Data/Events.plist') return '' except IOError as e: return str(e) # or if you prefer, your own custom error string # "IOError: [Errno 13] Apache can't write Events.plist file" I return a string in both cases so that you can, if you choose, use the output of SaveEvents anywhere where a string is expected without worrying about whether it returns None or a string: content = Data.Dict.SaveEvents(Data.Plist.Events) # content will be the empty string if no error, otherwise error message. If you don't care about that, just delete the return '' line and the function will fall back on returning None by default. Either way, you can also use it like this: content = Data.Dict.SaveEvents(Data.Plist.Events) or content This will leave content unchanged if no error is returned, otherwise it will replace the value. Note that content must have an initial value to start with (presumably the empty string). -- Steven From no at mail.de Tue Nov 8 17:19:13 2011 From: no at mail.de (MrSmile) Date: Tue, 08 Nov 2011 23:19:13 +0100 Subject: getting command line in python Message-ID: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Hi people! I am looking for a way to get the command line in the script. Let us say I am in the folder "/tmp" okay! now from /tmp I execute in the console this: python /home/tamer/MyApp/MyScript.py in the app itself, I want to grep the path and the scriptname itself, like: /home/tamer/MyApp is being somewhere available. Tamer From irmen.NOSPAM at xs4all.nl Tue Nov 8 17:24:58 2011 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Tue, 08 Nov 2011 23:24:58 +0100 Subject: getting command line in python In-Reply-To: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <4eb9ac3b$0$6908$e4fe514c@news2.news.xs4all.nl> On 8-11-2011 23:19, MrSmile wrote: > Hi people! > I am looking for a way to get the command line in the script. > > Let us say I am in the folder "/tmp" okay! > > now from /tmp I execute in the console this: > python /home/tamer/MyApp/MyScript.py > > in the app itself, I want to grep the path and the scriptname itself, > like: /home/tamer/MyApp is being somewhere available. > > > Tamer sys.argv Irmen From clp2 at rebertia.com Tue Nov 8 17:32:30 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 8 Nov 2011 14:32:30 -0800 Subject: getting command line in python In-Reply-To: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Message-ID: On Tue, Nov 8, 2011 at 2:19 PM, MrSmile wrote: > Hi people! > I am looking for a way to get the command line in the script. > > Let us say I am in the folder "/tmp" okay! > > now from /tmp I execute in the console this: > python /home/tamer/MyApp/MyScript.py > > in the app itself, I want to grep the path and the scriptname itself, > like: /home/tamer/MyApp is being somewhere available. Under your example conditions: sys.argv[0] will be "/home/tamer/MyApp/MyScript.py". (A) os.getcwd() will return "/tmp". (B) The `os.path` module is also very relevant: http://docs.python.org/library/os.path.html Cheers, Chris -- http://rebertia.com (A): http://docs.python.org/library/sys.html#sys.argv (B): http://docs.python.org/library/os.html#os.getcwd From cs at zip.com.au Tue Nov 8 17:32:38 2011 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 9 Nov 2011 09:32:38 +1100 Subject: getting command line in python In-Reply-To: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <20111108223238.GA24364@cskk.homeip.net> On 08Nov2011 23:19, MrSmile wrote: | I am looking for a way to get the command line in the script. | | Let us say I am in the folder "/tmp" okay! | | now from /tmp I execute in the console this: | python /home/tamer/MyApp/MyScript.py | | in the app itself, I want to grep the path and the scriptname itself, | like: /home/tamer/MyApp is being somewhere available. Have you looked in sys.argv[0]? -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ It is not true that life is one damn thing after another -- it's one damn thing over and over. - Edna St. Vincent Millay From no at mail.de Tue Nov 8 17:36:13 2011 From: no at mail.de (MrSmile) Date: Tue, 08 Nov 2011 23:36:13 +0100 Subject: getting command line in python In-Reply-To: References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> Message-ID: <4eb9aedd$0$6567$9b4e6d93@newsspool4.arcor-online.net> Thank you all, that was it that I was searching for you. Tamer Am 08.11.2011 23:32, schrieb Cameron Simpson: > On 08Nov2011 23:19, MrSmile wrote: > | I am looking for a way to get the command line in the script. > | > | Let us say I am in the folder "/tmp" okay! > | > | now from /tmp I execute in the console this: > | python /home/tamer/MyApp/MyScript.py > | > | in the app itself, I want to grep the path and the scriptname itself, > | like: /home/tamer/MyApp is being somewhere available. > > Have you looked in sys.argv[0]? From jjposner at optimum.net Tue Nov 8 17:51:27 2011 From: jjposner at optimum.net (John Posner) Date: Tue, 08 Nov 2011 17:51:27 -0500 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: <4EB9B26F.3050704@optimum.net> On 2:59 PM, Chris Angelico wrote: >>> So really, it's not "all() is slow" but "function calls are slow". >>> Maybe it'd be worthwhile making an all-factory: >> PLEASE say you're joking. If I saw code like that on any of our project, >> this would definitely qualify for a DailyWTF. > For the benefit of anyone who was actually in doubt: YES, I was > joking. Do *not* put code like this into any production project. Because an all-factory would produce code smell? :-) From tim at akwebsoft.com Tue Nov 8 18:54:12 2011 From: tim at akwebsoft.com (Tim Johnson) Date: Tue, 8 Nov 2011 14:54:12 -0900 Subject: Decouplable CMS in python? Message-ID: <20111108235412.GK3736@akwebsoft.com> :)I'm sure decouplable is a word. If not it should be. I have written my own framework. This has been a work in progress as a consequence of projects that I have done over the last 10 years. I need a CMS that sits "on top of" the framework. One of the starting points that I have considered is finding a fairly simple, but well-written CMS in python and adapting it. It may very well turn out that I would have to start from 'scratch', nevertheless, reviewing code for such a simple CMS would be informative. I'm thinking that, as an example - django-cms - would be too complex, regardless of its merits. Any recommendations? thanks -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com From python.list at tim.thechases.com Tue Nov 8 18:56:48 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 08 Nov 2011 17:56:48 -0600 Subject: all() is slow? In-Reply-To: <4EB9B26F.3050704@optimum.net> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4EB9B26F.3050704@optimum.net> Message-ID: <4EB9C1C0.2050302@tim.thechases.com> On 11/08/2011 04:51 PM, John Posner wrote: > On 2:59 PM, Chris Angelico wrote: > >>>> So really, it's not "all() is slow" but "function calls are slow". >>>> Maybe it'd be worthwhile making an all-factory: >>> PLEASE say you're joking. If I saw code like that on any of our project, >>> this would definitely qualify for a DailyWTF. >> For the benefit of anyone who was actually in doubt: YES, I was >> joking. Do *not* put code like this into any production project. > > Because an all-factory would produce code smell? :-) Groan...that word-play is the pits! :) -tkc From simeon.chaos at gmail.com Tue Nov 8 19:13:12 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Tue, 8 Nov 2011 16:13:12 -0800 (PST) Subject: overview on dao References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> Message-ID: <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> On Nov 9, 1:52?am, Dennis Lee Bieber wrote: > On Mon, 7 Nov 2011 21:10:59 -0800 (PST), Simeon Chaos > declaimed the following in > gmane.comp.python.general: > > > Dao is a a functional logic solver (similar to lambdaProlog, Curry) > > written in python. The links related to dao are here: > > ? ? ? ? Unfortunately the name is in conflict with M$ DAO (Data Access > Objects), the precursor to ADO. Every time I see "Dao" my mind goes "JET > database". > -- > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ Yeah, here "dao" is from The book of Dao" by Laozi, means the way of the world go. From jeanpierreda at gmail.com Tue Nov 8 19:44:18 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 8 Nov 2011 19:44:18 -0500 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: Clearly what we need is a modern hygienic macro system to avoid this exec mess! defmacro defall(name, cond): def name(lst): for a in lst: if not cond: return False return True invoke defall(all, cond) Only slightly tongue in cheek. We have that stupid exec trick in the Python stdlib. It has to die. http://hg.python.org/cpython/file/6bf07db23445/Lib/collections/__init__.py#l240 Devin On Mon, Nov 7, 2011 at 5:06 PM, Chris Angelico wrote: > On Tue, Nov 8, 2011 at 8:46 AM, david vierra wrote: >> But, you didn't write an all() function. ?You wrote a more specialized >> allBoolean() function. I think this comparison is more fair to the >> builtin all(): > > So really, it's not "all() is slow" but "function calls are slow". > Maybe it'd be worthwhile making an all-factory: > > def my_all(code,lst): > ? ?exec("""def tmp_all(x): > ? ? ? ?for a in x: > ? ? ? ? ? ?if not ("""+code+"""): return False > ? ? ? ?return True > """) > ? ?return tmp_all(lst) > timeit.timeit('my_all("a in (True, False)",x)','from __main__ import > my_all,x',number=10) > > Bad code imho, but it _is_ faster than both the original and the builtin. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > From python at mrabarnett.plus.com Tue Nov 8 19:55:35 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 09 Nov 2011 00:55:35 +0000 Subject: overview on dao In-Reply-To: <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> Message-ID: <4EB9CF87.6060202@mrabarnett.plus.com> On 09/11/2011 00:13, Simeon Chaos wrote: > On Nov 9, 1:52 am, Dennis Lee Bieber wrote: >> On Mon, 7 Nov 2011 21:10:59 -0800 (PST), Simeon Chaos >> declaimed the following in >> gmane.comp.python.general: >> >>> Dao is a a functional logic solver (similar to lambdaProlog, Curry) >>> written in python. The links related to dao are here: >> >> Unfortunately the name is in conflict with M$ DAO (Data Access >> Objects), the precursor to ADO. Every time I see "Dao" my mind goes "JET >> database". >> -- >> Wulfraed Dennis Lee Bieber AF6VN >> wlfr... at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > Yeah, here "dao" is from The book of Dao" by Laozi, means the way of > the world go. Perhaps you should call it "LaoZiDao". From rosuav at gmail.com Tue Nov 8 20:19:42 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Nov 2011 12:19:42 +1100 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On Wed, Nov 9, 2011 at 11:44 AM, Devin Jeanpierre wrote: > Clearly what we need is a modern hygienic macro system to avoid this exec mess! > > defmacro defall(name, cond): > ? ?def name(lst): > ? ? ? ?for a in lst: > ? ? ? ? ? ?if not cond: > ? ? ? ? ? ? ? ?return False > ? ? ? ?return True #define defall(name,cond) def name(lst): \ for a in lst: \ if not cond: return False \ return True gcc -E myprog.pyi -o myprog.py There's no code you can't make more opaque using the C preprocessor. Python doesn't have inline functions? Ha! In your FACE, evil Python development cabal! You can't tell ME what I can't do! ChrisA PS. Don't try this at home. We have years of experience with bad code. Don't write code like this unless you have a life insurance policy that covers angry mobs. From clp2 at rebertia.com Tue Nov 8 20:30:48 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 8 Nov 2011 17:30:48 -0800 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: On Tue, Nov 8, 2011 at 5:19 PM, Chris Angelico wrote: > On Wed, Nov 9, 2011 at 11:44 AM, Devin Jeanpierre > wrote: >> Clearly what we need is a modern hygienic macro system to avoid this exec mess! >> >> defmacro defall(name, cond): >> ? ?def name(lst): >> ? ? ? ?for a in lst: >> ? ? ? ? ? ?if not cond: >> ? ? ? ? ? ? ? ?return False >> ? ? ? ?return True > > #define defall(name,cond) def name(lst): \ > ? ?for a in lst: \ > ? ? ? ?if not cond: return False \ > ? ?return True > > gcc -E myprog.pyi -o myprog.py > > There's no code you can't make more opaque using the C preprocessor. > > Python doesn't have inline functions? Ha! In your FACE, evil Python > development cabal! You can't tell ME what I can't do! > > ChrisA > PS. Don't try this at home. We have years of experience with bad code. > Don't write code like this unless you have a life insurance policy > that covers angry mobs. Burn him! Witch! Witch! Burn him! His code turned me into a newt! -- Sent nailed to a coconut carried by swallow. From gnarlodious at gmail.com Tue Nov 8 20:48:57 2011 From: gnarlodious at gmail.com (Gnarlodious) Date: Tue, 8 Nov 2011 17:48:57 -0800 (PST) Subject: Help catching error message References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> <4eb9aa41$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 8, 3:16?pm, Steven D'Aprano wrote: > content = Data.Dict.SaveEvents(Data.Plist.Events) or content > > This will leave content unchanged if no error is returned, otherwise it > will replace the value. Ah, the 'or' operator does it. Thank you, that is exactly what I was looking for. I should confess, I am not a programmer and don't even know what "idiomatic" means in this context. I don't know Java or PHP, only a little Forth from the HP calculator era. Advanced topics I just skip over because I don't understand them. But I am learning slowly and appreciate the help. -- Rachel http://Sectrum.com From steve+comp.lang.python at pearwood.info Tue Nov 8 21:47:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Nov 2011 02:47:30 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Nov 2011 19:44:18 -0500, Devin Jeanpierre wrote: > We have that stupid exec trick in the Python stdlib. It has to die. > > http://hg.python.org/cpython/file/6bf07db23445/Lib/collections/__init__.py#l240 http://bugs.python.org/issue3974 http://blog.ccpgames.com/kristjan/2011/05/28/namedtuple-and-exec/ If it were someone other than Raymond Hettinger responsible for the use of exec in namedtuple, I'd be a lot more suspicious of it. -- Steven From steve+comp.lang.python at pearwood.info Tue Nov 8 21:57:28 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Nov 2011 02:57:28 GMT Subject: Help catching error message References: <8629ed5b-a657-4bda-9930-a0571279f4d6@p20g2000prm.googlegroups.com> <4eb9aa41$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4eb9ec18$0$29988$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Nov 2011 17:48:57 -0800, Gnarlodious wrote: > On Nov 8, 3:16?pm, Steven D'Aprano wrote: > >> content = Data.Dict.SaveEvents(Data.Plist.Events) or content >> >> This will leave content unchanged if no error is returned, otherwise it >> will replace the value. > Ah, the 'or' operator does it. Thank you, that is exactly what I was > looking for. > > I should confess, I am not a programmer and don't even know what > "idiomatic" means in this context. I don't know Java or PHP, only a > little Forth from the HP calculator era. Advanced topics I just skip > over because I don't understand them. But I am learning slowly and > appreciate the help. Idiomatic in this context means that the code follows standard styles, patterns or techniques commonly accepted by most good programmers of the language. This implies that the code works with the language, playing to its strengths, rather than against it. Non-idiomatic code tends to be slower than it could be, or harder to read, or harder to maintain, or all three. Idiomatic is relative to the language: what is idiomatic for one language may not be for another. For instance, if I were to ask "How do I do something with each item of a list?", the idiomatic way in Python would be: for item in some_list: do_something_with(item) rather than: for i in range(len(some_list)): item = some_list[index] do_something_with(item) and especially not this: index = 0 while index < len(some_list): item = some_list[index] do_something_with(item) index += 1 Regards, -- Steven From mcepl at redhat.com Wed Nov 9 05:20:08 2011 From: mcepl at redhat.com (Matej Cepl) Date: Wed, 09 Nov 2011 11:20:08 +0100 Subject: getting command line in python In-Reply-To: <4eb9aedd$0$6567$9b4e6d93@newsspool4.arcor-online.net> References: <4eb9aae1$0$6549$9b4e6d93@newsspool4.arcor-online.net> <4eb9aedd$0$6567$9b4e6d93@newsspool4.arcor-online.net> Message-ID: Dne 8.11.2011 23:36, MrSmile napsal(a): > Thank you all, that was it that I was searching for you. Except that most likely it wasn't the right answer. Take a look at http://docs.python.org/library/argparse.html (or optparse, if you are on Python < 2.7). Best, Mat?j From simeon.chaos at gmail.com Wed Nov 9 06:17:28 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Wed, 9 Nov 2011 03:17:28 -0800 (PST) Subject: overview on dao References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> Message-ID: <96a0fc78-aa96-4830-bc26-b3efbb75e65b@f3g2000pri.googlegroups.com> On Nov 9, 8:55?am, MRAB wrote: > On 09/11/2011 00:13, Simeon Chaos wrote: > > > > > > > > > > > On Nov 9, 1:52 am, Dennis Lee Bieber ?wrote: > >> On Mon, 7 Nov 2011 21:10:59 -0800 (PST), Simeon Chaos > >> ?declaimed the following in > >> gmane.comp.python.general: > > >>> Dao is a a functional logic solver (similar to lambdaProlog, Curry) > >>> written in python. The links related to dao are here: > > >> ? ? ? ? ?Unfortunately the name is in conflict with M$ DAO (Data Access > >> Objects), the precursor to ADO. Every time I see "Dao" my mind goes "JET > >> database". > >> -- > >> ? ? ? ? ?Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > >> ? ? ? ? ?wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ > > > Yeah, ?here "dao" is from The book of Dao" by Laozi, means the way of > > the world go. > > Perhaps you should call it "LaoZiDao". I just prefer shorter name. From Juan.Declet-Barreto at MesaAZ.gov Wed Nov 9 09:53:02 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Wed, 9 Nov 2011 07:53:02 -0700 Subject: memory management In-Reply-To: <4EB8448B.7030709@davea.name> References: <3CB1190388197146B35D522652EAB501014C71D0C4@MESAMAIL01.acctcom.mesa> <4EB83D69.2000409@dejaviewphoto.com> <3CB1190388197146B35D522652EAB501014C71D167@MESAMAIL01.acctcom.mesa> <4EB8448B.7030709@davea.name> Message-ID: <3CB1190388197146B35D522652EAB501014CDF2323@MESAMAIL01.acctcom.mesa> After some exception catching, I have found that my program is throwing a MemoryError exception numerous times (~7 iterations of the main loop that processes list elements) until python25\python.exe crashes (Windows XP environment). I implemented Dave Angel's suggestions re: processing each list element (a file) as I get it. So my question would be how to begin troubleshooting the conditions under which the exception is raised. Is there any more information in the exception object about how much memory is being consumed, or any other indicators as to what led to the exception? -juan -----Original Message----- From: Dave Angel [mailto:d at davea.name] Sent: Monday, November 07, 2011 1:50 PM To: Juan Declet-Barreto Cc: python-list at python.org Subject: Re: memory management On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: > Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. You top-posted. In this mailing list, one should type new information after the quoted information, not before. Perhaps a pre-emptive strike is in order. On the assumption that it may be a memory problem, how about you turn the app inside out. Instead of walking the entire tree, getting a list with all the paths, and then working on the list, how about doing the work on each file as you get it. Or even make your own generator from os.walk, so the app can call your logic on each file, and never have all the file (name)s in memory at the same time. Generator: def filelist(top, criteria): for a, b, c in os.walk(): for fiile in files: apply some criteria yield file Now the main app can iterate through this "list" in the usual way for filename in filelist(top, "*.txt"): dosomething... -- DaveA From hansmu at xs4all.nl Wed Nov 9 10:41:08 2011 From: hansmu at xs4all.nl (Hans Mulder) Date: Wed, 09 Nov 2011 16:41:08 +0100 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> Message-ID: <4eba9f14$0$6987$e4fe514c@news2.news.xs4all.nl> On 9/11/11 02:30:48, Chris Rebert wrote: > Burn him! Witch! Witch! Burn him! > His code turned me into a newt! > -- > Sent nailed to a coconut carried by swallow. Is that a European swallow or an African swallow? -- HansM From dihedral88888 at googlemail.com Wed Nov 9 10:56:01 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Wed, 9 Nov 2011 07:56:01 -0800 (PST) Subject: file extension while saving Python files In-Reply-To: References: Message-ID: <18518506.120.1320854161026.JavaMail.geo-discussion-forums@pref15> In testing and debug it is better that a program can be easily modified and easy to set break point and dump values. Thus an interpreter environment is more convenient. But in the final version a compiler can speed up a lot! From Juan.Declet-Barreto at MesaAZ.gov Wed Nov 9 14:08:09 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Wed, 9 Nov 2011 12:08:09 -0700 Subject: guppy Message-ID: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> I am trying to build guppy on Python 2.5, but am getting an "initializer element is not constant" error from gcc. I have found very little on this issue in the fora when looking for the general cause of the error; there is even less that is specific to a guppy build on Python 2.5. One recommendation I have seen is recompiling Python, but apparently that brings up the possibility of rendering it incompatible with non-standard packages like arcpy or arcgisscripting, which are critical to my application. I am using Cygwin. -----Original Message----- From: Dominic Binks [mailto:dbinks at codeaurora.org] Sent: Wednesday, November 09, 2011 9:31 AM To: Juan Declet-Barreto Subject: Re: memory management On 11/9/2011 6:53 AM, Juan Declet-Barreto wrote: > After some exception catching, I have found that my program is throwing a MemoryError exception numerous times (~7 iterations of the main loop that processes list elements) until python25\python.exe crashes (Windows XP environment). I implemented Dave Angel's suggestions re: processing each list element (a file) as I get it. > > So my question would be how to begin troubleshooting the conditions under which the exception is raised. Is there any more information in the exception object about how much memory is being consumed, or any other indicators as to what led to the exception? > > -juan > > -----Original Message----- > From: Dave Angel [mailto:d at davea.name] > Sent: Monday, November 07, 2011 1:50 PM > To: Juan Declet-Barreto > Cc: python-list at python.org > Subject: Re: memory management > > On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: >> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. > You top-posted. In this mailing list, one should type new information after the quoted information, not before. > > Perhaps a pre-emptive strike is in order. On the assumption that it may be a memory problem, how about you turn the app inside out. Instead of walking the entire tree, getting a list with all the paths, and then working on the list, how about doing the work on each file as you get it. Or even make your own generator from os.walk, so the app can call your logic on each file, and never have all the file (name)s in memory at the same time. > > > Generator: > > def filelist(top, criteria): > for a, b, c in os.walk(): > for fiile in files: > apply some criteria > yield file > > > Now the main app can iterate through this "list" in the usual way > > for filename in filelist(top, "*.txt"): > dosomething... > > > Look for a tool called heapy. I had a process that was consuming 10+G of RAM to run. Using heapy I identified the culprit and reduced down to a more manageable 400M. Dominic -- Dominic Binks: dbinks at codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum From lists at cheimes.de Wed Nov 9 14:20:30 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 09 Nov 2011 20:20:30 +0100 Subject: guppy In-Reply-To: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> Message-ID: Am 09.11.2011 20:08, schrieb Juan Declet-Barreto: > I am trying to build guppy on Python 2.5, but am getting an "initializer element is not constant" error from gcc. I have found very little on this issue in the fora when looking for the general cause of the error; there is even less that is specific to a guppy build on Python 2.5. > > One recommendation I have seen is recompiling Python, but apparently that brings up the possibility of rendering it incompatible with non-standard packages like arcpy or arcgisscripting, which are critical to my application. > > I am using Cygwin. Please show us the full error message with context. Are you using a Cygwin build of Python or a native Windows build? What GCC version and flavor are you using? I'm not sure if Cygwin is even supported. I recommend that you use MinGW with GCC 4.x if you can't afford VS 2003. Christian From benjamin.kaplan at case.edu Wed Nov 9 14:28:11 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 9 Nov 2011 14:28:11 -0500 Subject: guppy In-Reply-To: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> Message-ID: On Wed, Nov 9, 2011 at 2:08 PM, Juan Declet-Barreto wrote: > > I am trying to build guppy on Python 2.5, but am getting an "initializer element is not constant" error from gcc. I have found very little on this issue in the fora when looking for the general cause of the error; there is even less that is specific to a guppy build on Python 2.5. > > One recommendation I have seen is recompiling Python, but apparently that brings up the possibility of rendering it incompatible with non-standard packages like arcpy or arcgisscripting, which are critical to my application. > > I am using Cygwin. > > Mixing Cygwin libraries and normal Windows libraries usually doesn't always work too well. Are you using a Cygwin-compiled version of Python? > > -----Original Message----- > From: Dominic Binks [mailto:dbinks at codeaurora.org] > Sent: Wednesday, November 09, 2011 9:31 AM > To: Juan Declet-Barreto > Subject: Re: memory management > > On 11/9/2011 6:53 AM, Juan Declet-Barreto wrote: > > After some exception catching, I have found that my program is throwing a MemoryError exception numerous times (~7 iterations of the main loop that processes list elements) until python25\python.exe crashes (Windows XP environment). ? I implemented Dave Angel's suggestions re: processing each list element (a file) as I get it. > > > > So my question would be how to begin troubleshooting the conditions under which the exception is raised. Is there any more information in the exception object about how much memory is being consumed, or any other indicators as to what led to the exception? > > > > -juan > > > > -----Original Message----- > > From: Dave Angel [mailto:d at davea.name] > > Sent: Monday, November 07, 2011 1:50 PM > > To: Juan Declet-Barreto > > Cc: python-list at python.org > > Subject: Re: memory management > > > > On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: > >> Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, which can complicate things. I am currently isolating standard library Python code (e.g., os.walk()) from the arcgisscripting module to evaluate in which module the environment crash is occurring. > > You top-posted. ?In this mailing list, one should type new information after the quoted information, not before. > > > > Perhaps a pre-emptive strike is in order. ?On the assumption that it may be a memory problem, how about you turn the app inside out. ?Instead of walking the entire tree, getting a list with all the paths, and then working on the list, how about doing the work on each file as you get it. ?Or even make your own generator from os.walk, so the app can call your logic on each file, and never have all the file (name)s in memory at the same time. > > > > > > Generator: > > > > def ?filelist(top, criteria): > > ? ? ? ? for ?a, b, c in os.walk(): > > ? ? ? ? ? ? ? ?for fiile in files: > > ? ? ? ? ? ? ? ? ? ? ?apply some criteria > > ? ? ? ? ? ? ? ? ? ? ?yield file > > > > > > Now the main app can iterate through this "list" in the usual way > > > > for filename in filelist(top, "*.txt"): > > ? ? ? ? ?dosomething... > > > > > > > > Look for a tool called heapy. ?I had a process that was consuming 10+G of RAM to run. ?Using heapy I identified the culprit and reduced down to a more manageable 400M. > > Dominic > > -- > Dominic Binks: dbinks at codeaurora.org > Employee of Qualcomm Innovation Center, Inc. > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum > -- > http://mail.python.org/mailman/listinfo/python-list From Juan.Declet-Barreto at MesaAZ.gov Wed Nov 9 14:38:03 2011 From: Juan.Declet-Barreto at MesaAZ.gov (Juan Declet-Barreto) Date: Wed, 9 Nov 2011 12:38:03 -0700 Subject: guppy In-Reply-To: References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> Message-ID: <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> I am using Cygwin build of Python2.6. This Cygwin install has both a Cygwin gcc (versions 3.4.4 and 4.5.3) and mingw32 (3.4.4), as listed in lib/gcc/. I also tried the mingw32 shell separately, but I get the same results even when I pass the "-c mingw32" option. The error is reproduced below: $ python setup.py build running build running build_py running build_ext building 'guppy.sets.setsc' extension gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/python2.6 -c src/sets/sets.c -o build/temp.cygwin-1.7.9-i686-2.6/src/sets/sets.o src/sets/sets.c:68:5: error: initializer element is not constant src/sets/sets.c:68:5: error: (near initialization for `nysets_heapdefs[0].type') src/sets/sets.c:69:5: error: initializer element is not constant src/sets/sets.c:69:5: error: (near initialization for `nysets_heapdefs[1].type') src/sets/sets.c:70:5: error: initializer element is not constant src/sets/sets.c:70:5: error: (near initialization for `nysets_heapdefs[2].type') error: command 'gcc' failed with exit status 1 -----Original Message----- From: python-list-bounces+juan.declet-barreto=mesaaz.gov at python.org [mailto:python-list-bounces+juan.declet-barreto=mesaaz.gov at python.org] On Behalf Of Christian Heimes Sent: Wednesday, November 09, 2011 12:21 PM To: python-list at python.org Subject: Re: guppy Am 09.11.2011 20:08, schrieb Juan Declet-Barreto: > I am trying to build guppy on Python 2.5, but am getting an "initializer element is not constant" error from gcc. I have found very little on this issue in the fora when looking for the general cause of the error; there is even less that is specific to a guppy build on Python 2.5. > > One recommendation I have seen is recompiling Python, but apparently that brings up the possibility of rendering it incompatible with non-standard packages like arcpy or arcgisscripting, which are critical to my application. > > I am using Cygwin. Please show us the full error message with context. Are you using a Cygwin build of Python or a native Windows build? What GCC version and flavor are you using? I'm not sure if Cygwin is even supported. I recommend that you use MinGW with GCC 4.x if you can't afford VS 2003. Christian -- http://mail.python.org/mailman/listinfo/python-list From lists at cheimes.de Wed Nov 9 15:38:02 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 09 Nov 2011 21:38:02 +0100 Subject: guppy In-Reply-To: <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> Message-ID: Am 09.11.2011 20:38, schrieb Juan Declet-Barreto: > I am using Cygwin build of Python2.6. This Cygwin install has both a Cygwin gcc (versions 3.4.4 and 4.5.3) and mingw32 (3.4.4), as listed in lib/gcc/. > > I also tried the mingw32 shell separately, but I get the same results even when I pass the "-c mingw32" option. > > The error is reproduced below: > > $ python setup.py build > running build > running build_py > running build_ext > building 'guppy.sets.setsc' extension > gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/python2.6 -c src/sets/sets.c -o build/temp.cygwin-1.7.9-i686-2.6/src/sets/sets.o > src/sets/sets.c:68:5: error: initializer element is not constant > src/sets/sets.c:68:5: error: (near initialization for `nysets_heapdefs[0].type') > src/sets/sets.c:69:5: error: initializer element is not constant > src/sets/sets.c:69:5: error: (near initialization for `nysets_heapdefs[1].type') > src/sets/sets.c:70:5: error: initializer element is not constant > src/sets/sets.c:70:5: error: (near initialization for `nysets_heapdefs[2].type') > > error: command 'gcc' failed with exit status 1 static NyHeapDef nysets_heapdefs[] = { {0, 0, (NyHeapDef_SizeGetter) mutbitset_indisize}, {0, 0, 0, cplbitset_traverse}, {0, 0, nodeset_indisize, nodeset_traverse, nodeset_relate}, {0} }; nysets_heapdefs[0].type = &NyMutBitSet_Type; nysets_heapdefs[1].type = &NyCplBitSet_Type; nysets_heapdefs[2].type = &NyNodeSet_Type; The code looks fine to me and compiles with GCC 4.6. It seems your GCC chokes on "nysets_heapdefs[0].type = &NyMutBitSet_Type;". It's not a file local static but an extern declaration. Are you sure that you are using a recent version of GCC 4.x? I had some issues with GCC 3.x in the past. Cygwin has GCC 3.x as default gcc. For Python 2.6 you can use the free VS 2008 Express version. I've compiled guppy for 32bit Python 2.7 a couple of days ago w/o any issue From nagle at animats.com Wed Nov 9 17:16:23 2011 From: nagle at animats.com (John Nagle) Date: Wed, 09 Nov 2011 14:16:23 -0800 Subject: all() is slow? In-Reply-To: References: Message-ID: <4ebafbb7$0$1724$742ec2ed@news.sonic.net> On 11/7/2011 1:00 PM, OKB (not okblacke) wrote: > I noticed this (Python 2.6.5 on Windows XP): CPython is slow. It's a naive interpreter. There's almost no optimization during compilation. Try PyPy or Shed Skin. John Nagle From jeanpierreda at gmail.com Wed Nov 9 18:01:16 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Nov 2011 18:01:16 -0500 Subject: all() is slow? In-Reply-To: <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: > If it were someone other than Raymond Hettinger responsible for the use > of exec in namedtuple, I'd be a lot more suspicious of it. I'm not going to be less suspicious based on a name. It reads like insanity, and the justification was terrible. Devin On Tue, Nov 8, 2011 at 9:47 PM, Steven D'Aprano wrote: > On Tue, 08 Nov 2011 19:44:18 -0500, Devin Jeanpierre wrote: > >> We have that stupid exec trick in the Python stdlib. It has to die. >> >> http://hg.python.org/cpython/file/6bf07db23445/Lib/collections/__init__.py#l240 > > > http://bugs.python.org/issue3974 > http://blog.ccpgames.com/kristjan/2011/05/28/namedtuple-and-exec/ > > If it were someone other than Raymond Hettinger responsible for the use > of exec in namedtuple, I'd be a lot more suspicious of it. > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From steve+comp.lang.python at pearwood.info Wed Nov 9 18:11:51 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Nov 2011 23:11:51 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Nov 2011 18:01:16 -0500, Devin Jeanpierre wrote: >> If it were someone other than Raymond Hettinger responsible for the use >> of exec in namedtuple, I'd be a lot more suspicious of it. > > I'm not going to be less suspicious based on a name. Neither am I. I am less suspicious based on a reputation. Raymond is a well-known, trusted senior Python developer who knows what he is doing. > It reads like > insanity, and the justification was terrible. It reads fine, and the justification is perfectly valid. You're right to be cautious of exec. You're wrong to be phobic about it. What do you think is going to happen? The exec call inside namedtuple is going to creep out of the module in the wee hours of the night, contaminating other functions and modules while you sleep? Be serious. If you have an actual concrete security vulnerability caused by the use of exec inside namedtuple, or some other bug, then say so. Otherwise, your paranoia is unjustified. -- Steven From rosuav at gmail.com Wed Nov 9 18:15:07 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Nov 2011 10:15:07 +1100 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 10, 2011 at 10:01 AM, Devin Jeanpierre wrote: >> If it were someone other than Raymond Hettinger responsible for the use >> of exec in namedtuple, I'd be a lot more suspicious of it. > > I'm not going to be less suspicious based on a name. It reads like > insanity, and the justification was terrible. It's said that code exists foremost for humans to read, and only incidentally for computers to execute. I believe that this is inverted for library code; as long as the _interface_ is clean, you can get away with some messy internals, because it's going to be executed far more often than actually read. Python programmers can use namedtuples happily without knowing that the implementation uses exec. The justification is, if I understand correctly, that the alternative is worse. That's plenty of justification imho. ChrisA From kwa at kuwata-lab.com Wed Nov 9 19:58:15 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Thu, 10 Nov 2011 09:58:15 +0900 Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: On Wed, Nov 9, 2011 at 4:09 AM, Terry Reedy wrote: > On 11/7/2011 11:32 PM, Makoto Kuwata wrote: >> >> I got trouble about easy_install command. >> >> My package: >> >> ? README.rst >> ? setup.py >> ? foobar/ >> ? foobar/__init__.py >> ? foobar/data/ >> ? foobar/data/template.py >> >> In the above example, 'foobar/data/template.py' is just a >> template data file (= not a python module file). > > Then why is it .py? If it is just data, use .txt. If .py, it should be > python code run either directly or imported, though I suppose you could exec > it. (I have no idea how renaming would affect your problem.) > I want to use template names according to language, such as template.py, template.html, template.rst, template.js, and so on. My question is "how to include non-python files into egg file?" I may change file name suffix from '.py' to '.py.template', but it doesn't solve my problem. -- regards, makoto kuwata From jeanpierreda at gmail.com Wed Nov 9 20:26:56 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Nov 2011 20:26:56 -0500 Subject: all() is slow? In-Reply-To: <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: > Neither am I. I am less suspicious based on a reputation. Raymond is a > well-known, trusted senior Python developer who knows what he is doing. I don't really know anything about him or why people respect him, so I have no reason to share your faith. > It reads fine, and the justification is perfectly valid. Well. It reads fine in a certain sense, in that I can figure out what's going on (although I have some troubles figuring out why the heck certain things are in the code). The issue is that what's going on is otherworldly: this is not a Python pattern, this is not a normal approach. To me, that means it does not read fine. The use of exec also results in (seemingly) arbitrary constraints on the input. Like, why can't "--" be a name? Because exec? Is there some other reason? I don't like the use of exec, and I don't like the justification (it seems handwavy). I pointed this out in a thread full of people saying "never EVER use exec this way", so it's obviously not just me that thinks this is awful. > You're right to be cautious of exec. You're wrong to be phobic about it. > What do you think is going to happen? I think somebody will read it and think this is a good idea. Devin On Wed, Nov 9, 2011 at 6:11 PM, Steven D'Aprano wrote: > On Wed, 09 Nov 2011 18:01:16 -0500, Devin Jeanpierre wrote: > >>> If it were someone other than Raymond Hettinger responsible for the use >>> of exec in namedtuple, I'd be a lot more suspicious of it. >> >> I'm not going to be less suspicious based on a name. > > Neither am I. I am less suspicious based on a reputation. Raymond is a > well-known, trusted senior Python developer who knows what he is doing. > > >> It reads like >> insanity, and the justification was terrible. > > It reads fine, and the justification is perfectly valid. > > You're right to be cautious of exec. You're wrong to be phobic about it. > What do you think is going to happen? The exec call inside namedtuple is > going to creep out of the module in the wee hours of the night, > contaminating other functions and modules while you sleep? Be serious. If > you have an actual concrete security vulnerability caused by the use of > exec inside namedtuple, or some other bug, then say so. Otherwise, your > paranoia is unjustified. > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanpierreda at gmail.com Wed Nov 9 20:35:02 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Nov 2011 20:35:02 -0500 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: > Well. It reads fine in a certain sense, in that I can figure out > what's going on (although I have some troubles figuring out why the > heck certain things are in the code). The issue is that what's going > on is otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. Sorry for the double post, but I think I damaged my statement a little in the edit process here. I have a hard time reading the code, and the implications of using exec on how initialization works is not obvious. I do believe that this solution is significantly less readable than it would be in a language with "real" macros, or using an alternate dict-based approach. I don't mean to just say "it's different, therefore it's wrong" -- it takes more than just being unusual (not that the unusualness helps). Devin On Wed, Nov 9, 2011 at 8:26 PM, Devin Jeanpierre wrote: >> Neither am I. I am less suspicious based on a reputation. Raymond is a >> well-known, trusted senior Python developer who knows what he is doing. > > I don't really know anything about him or why people respect him, so I > have no reason to share your faith. > >> It reads fine, and the justification is perfectly valid. > > Well. It reads fine in a certain sense, in that I can figure out > what's going on (although I have some troubles figuring out why the > heck certain things are in the code). The issue is that what's going > on is otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. > > The use of exec also results in (seemingly) arbitrary constraints on > the input. Like, why can't "--" be a name? Because exec? Is there some > other reason? > > I don't like the use of exec, and I don't like the justification (it > seems handwavy). I pointed this out in a thread full of people saying > "never EVER use exec this way", so it's obviously not just me that > thinks this is awful. > >> You're right to be cautious of exec. You're wrong to be phobic about it. >> What do you think is going to happen? > > I think somebody will read it and think this is a good idea. > > Devin > > > On Wed, Nov 9, 2011 at 6:11 PM, Steven D'Aprano > wrote: >> On Wed, 09 Nov 2011 18:01:16 -0500, Devin Jeanpierre wrote: >> >>>> If it were someone other than Raymond Hettinger responsible for the use >>>> of exec in namedtuple, I'd be a lot more suspicious of it. >>> >>> I'm not going to be less suspicious based on a name. >> >> Neither am I. I am less suspicious based on a reputation. Raymond is a >> well-known, trusted senior Python developer who knows what he is doing. >> >> >>> It reads like >>> insanity, and the justification was terrible. >> >> It reads fine, and the justification is perfectly valid. >> >> You're right to be cautious of exec. You're wrong to be phobic about it. >> What do you think is going to happen? The exec call inside namedtuple is >> going to creep out of the module in the wee hours of the night, >> contaminating other functions and modules while you sleep? Be serious. If >> you have an actual concrete security vulnerability caused by the use of >> exec inside namedtuple, or some other bug, then say so. Otherwise, your >> paranoia is unjustified. >> >> >> >> -- >> Steven >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > From drobinow at gmail.com Wed Nov 9 21:06:26 2011 From: drobinow at gmail.com (David Robinow) Date: Wed, 9 Nov 2011 21:06:26 -0500 Subject: guppy In-Reply-To: <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> References: <3CB1190388197146B35D522652EAB501014CDF2783@MESAMAIL01.acctcom.mesa> <3CB1190388197146B35D522652EAB501014CDF27DA@MESAMAIL01.acctcom.mesa> Message-ID: On Wed, Nov 9, 2011 at 2:38 PM, Juan Declet-Barreto wrote: > I am using Cygwin build of Python2.6. ?This Cygwin install has both a Cygwin gcc (versions 3.4.4 and 4.5.3) and mingw32 (3.4.4), as listed in lib/gcc/. > > I also tried the mingw32 shell separately, but I get the same results even when I pass the "-c mingw32" option. > > The error is reproduced below: > ... It works for me. guppy 0.1.9 gcc 4.5.3 Python 2.6.5 cygwin 1.7.9 [I have no idea if it works as intended. I don't use guppy.] From ian.g.kelly at gmail.com Wed Nov 9 21:10:27 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 9 Nov 2011 19:10:27 -0700 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Nov 9, 2011 at 6:26 PM, Devin Jeanpierre wrote: > The use of exec also results in (seemingly) arbitrary constraints on > the input. Like, why can't "--" be a name? Because exec? Is there some > other reason? That's by design, not because of exec. The names are supposed to be actual Python names, things that can used to designate keyword arguments ("MyTuple(foo=42)") or to retrieve elements using attribute lookup ("my_tuple.foo"). Using "--" as a name would be a syntax error in either of those cases. Cheers, Ian From kwa at kuwata-lab.com Wed Nov 9 22:25:06 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Thu, 10 Nov 2011 12:25:06 +0900 Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: On Thu, Nov 10, 2011 at 9:58 AM, Makoto Kuwata wrote: > On Wed, Nov 9, 2011 at 4:09 AM, Terry Reedy wrote: >> On 11/7/2011 11:32 PM, Makoto Kuwata wrote: >>> >>> I got trouble about easy_install command. >>> >>> My package: >>> >>> ? README.rst >>> ? setup.py >>> ? foobar/ >>> ? foobar/__init__.py >>> ? foobar/data/ >>> ? foobar/data/template.py >>> >>> In the above example, 'foobar/data/template.py' is just a >>> template data file (= not a python module file). >> >> Then why is it .py? If it is just data, use .txt. If .py, it should be >> python code run either directly or imported, though I suppose you could exec >> it. (I have no idea how renaming would affect your problem.) >> > > I want to use template names according to language, > such as template.py, template.html, template.rst, template.js, and so on. > > My question is "how to include non-python files into egg file?" > I may change file name suffix from '.py' to '.py.template', > but it doesn't solve my problem. I create sample project to explain my trouble. Sample project source code: https://bitbucket.org/kwatch/helloworld/src When 'python setup.py sdist', all files are copied correctly. https://bitbucket.org/kwatch/helloworld/wiki/python_setup.py_sdist $ python setup.py sdist .... hard linking helloworld/__init__.py -> HelloWorld-0.1.0/helloworld hard linking helloworld/foo.py -> HelloWorld-0.1.0/helloworld hard linking helloworld/sub/__init__.py -> HelloWorld-0.1.0/helloworld/sub hard linking helloworld/sub/bar.py -> HelloWorld-0.1.0/helloworld/sub .... But when 'python setup.py bdist_egg', some files are not copied. https://bitbucket.org/kwatch/helloworld/wiki/python_setup.py_bdist_egg $ python setup.py bdist # 'helloworld/sub/{__init__,bar}.py' are not copied! .... copying build/lib/helloworld/__init__.py -> build/bdist.macosx-10.4-x86_64/egg/helloworld copying build/lib/helloworld/foo.py -> build/bdist.macosx-10.4-x86_64/egg/helloworld .... Could you help me? -- regards, makoto kuwata From wuwei23 at gmail.com Wed Nov 9 22:50:42 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 9 Nov 2011 19:50:42 -0800 (PST) Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2f026694-0905-49f8-bcae-7e4d55df5d49@z22g2000prd.googlegroups.com> On Nov 10, 11:26?am, Devin Jeanpierre wrote: > I don't really know anything about him or why people respect him, so I > have no reason to share your faith. But you're happy to accept the opinions of random posters saying "exec is evil"? (And it's really not a good idea to be proud of your ignorance...) > Like, why can't "--" be a name? Why would you ever want it to be? > I don't like the use of exec, and I don't like the justification (it > seems handwavy). As opposed to your in-depth critique? > I pointed this out in a thread full of people saying > "never EVER use exec this way", so it's obviously not just me that > thinks this is awful. No, instead you have a thread full of people happy to criticise something for which they're providing no alternative implementation. You can't exactly say _why_ it's bad, other than other people have echoed it, but you won't actually do anything about it. > I think somebody will read it and think this is a good idea. Just as I thought. From wuwei23 at gmail.com Wed Nov 9 22:52:35 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 9 Nov 2011 19:52:35 -0800 (PST) Subject: all() is slow? References: <4ebafbb7$0$1724$742ec2ed@news.sonic.net> Message-ID: <8f077318-a150-4ca2-b6e6-5f8dfcd85d8d@u10g2000prl.googlegroups.com> On Nov 10, 8:16?am, John Nagle wrote: > ? ? ?CPython is slow. It's a naive interpreter. ?There's > almost no optimization during compilation. ?Try PyPy > or Shed Skin. Sometimes people need to understand the performance characteristics of CPython because it's what they have to use. Pointing them at alternative implementations isn't an answer. From jeanpierreda at gmail.com Wed Nov 9 23:40:25 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Nov 2011 23:40:25 -0500 Subject: all() is slow? In-Reply-To: <2f026694-0905-49f8-bcae-7e4d55df5d49@z22g2000prd.googlegroups.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <2f026694-0905-49f8-bcae-7e4d55df5d49@z22g2000prd.googlegroups.com> Message-ID: > (And it's really not a good idea to be proud of your > ignorance...) I wasn't bragging. > But you're happy to accept the opinions of random posters saying "exec > is evil"? [...] > As opposed to your in-depth critique? [...] > No, instead you have a thread full of people happy to criticise > something for which they're providing no alternative implementation. > You can't exactly say _why_ it's bad, other than other people have > echoed it, but you won't actually do anything about it. I said it was bad because I found it difficult to read and it was "weird". I also mentioned that it's conceivable that it has security flaws, but that's not as big a deal. I believe I also said that it was bad because it resulted in """arbitrary""" limitations in functionality. So, yes, I did say why it's bad, and it's not just because other people say so. My reasons are weak, but that's a different story. I also mentioned the alternative implementation, which uses a dict. There was even already a patch submitted to make namedtuple work this way, so I don't think I had to be too specific. R. Hettinger rejected this patch, which was what I was referring to when I was referring to handwaviness. So, no. > Just as I thought. Woo condescension. Devin On Wed, Nov 9, 2011 at 10:50 PM, alex23 wrote: > On Nov 10, 11:26?am, Devin Jeanpierre wrote: >> I don't really know anything about him or why people respect him, so I >> have no reason to share your faith. > > But you're happy to accept the opinions of random posters saying "exec > is evil"? (And it's really not a good idea to be proud of your > ignorance...) > >> Like, why can't "--" be a name? > > Why would you ever want it to be? > >> I don't like the use of exec, and I don't like the justification (it >> seems handwavy). > > As opposed to your in-depth critique? > >> I pointed this out in a thread full of people saying >> "never EVER use exec this way", so it's obviously not just me that >> thinks this is awful. > > No, instead you have a thread full of people happy to criticise > something for which they're providing no alternative implementation. > You can't exactly say _why_ it's bad, other than other people have > echoed it, but you won't actually do anything about it. > >> I think somebody will read it and think this is a good idea. > > Just as I thought. > -- > http://mail.python.org/mailman/listinfo/python-list > From paulalgray71 at gmail.com Thu Nov 10 00:29:56 2011 From: paulalgray71 at gmail.com (paula gray) Date: Thu, 10 Nov 2011 00:29:56 -0500 Subject: mailing list Message-ID: -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Nov 10 00:32:24 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Nov 2011 16:32:24 +1100 Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: On Thu, Nov 10, 2011 at 11:58 AM, Makoto Kuwata wrote: > I want to use template names according to language, > such as template.py, template.html, template.rst, template.js, and so on. > You may have another problem here. Everyone and everything that looks at these will expect them to be Python, HTML, etc files. If they're not, it may cause confusion in other ways. Can you switch it around, py.template and html.template etc? ChrisA From steve+comp.lang.python at pearwood.info Thu Nov 10 02:35:48 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 07:35:48 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <2f026694-0905-49f8-bcae-7e4d55df5d49@z22g2000prd.googlegroups.com> Message-ID: <4ebb7ed3$0$29988$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Nov 2011 19:50:42 -0800, alex23 wrote: >> I pointed this out in a thread full of people saying "never EVER use >> exec this way", so it's obviously not just me that thinks this is >> awful. > > No, instead you have a thread full of people happy to criticise > something for which they're providing no alternative implementation. You > can't exactly say _why_ it's bad, other than other people have echoed > it, but you won't actually do anything about it. In fairness there are alternative implementations. They are not identical to the version using exec. There is at least one use-case for *not* using exec, even at the cost of functionality: a restricted Python environment without exec. On the other hand, a restricted Python without exec is not actually Python. -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 10 02:48:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 07:48:49 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Nov 2011 20:26:56 -0500, Devin Jeanpierre wrote: >> Neither am I. I am less suspicious based on a reputation. Raymond is a >> well-known, trusted senior Python developer who knows what he is doing. > > I don't really know anything about him or why people respect him, so I > have no reason to share your faith. That's fine. I don't expect you to take my word on it (and why should you, I could be an idiot or a sock-puppet), but you could always try googling for "Raymond Hettinger python" and see what comes up. He is not some fly-by Python coder who snuck some dubious n00b code into the standard library when no-one was looking :) The mere fact that it was accepted into the standard library should tell you that core Python developers consider it an acceptable technique. That's not to say the technique is uncontroversial. But there are still people who dislike "x if flag else y" and @decorator syntax -- controversy, in and of itself, isn't necessarily a reason to avoid certain idioms. Are you familiar with the idea of "code smell"? http://www.codinghorror.com/blog/2006/05/code-smells.html http://www.joelonsoftware.com/articles/Wrong.html I would agree that the use of exec is a code smell. But that doesn't mean it is wrong or bad, merely that it needs a second look before accepting it. There's a world of difference between "You MUST NOT use exec" and "You SHOULD NOT use exec". See RFC 2119 if you are unclear on the difference: http://www.ietf.org/rfc/rfc2119.txt >> It reads fine, and the justification is perfectly valid. > > Well. It reads fine in a certain sense, in that I can figure out what's > going on (although I have some troubles figuring out why the heck > certain things are in the code). The issue is that what's going on is > otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. There's nothing inside the template being exec'ed that couldn't be found in non-exec code. So if you're having trouble figuring out parts of the code, the presence of the exec is not the problem. Having said that, dynamic code generation is well known for often being harder to read than "ordinary" code. But then, pointers are hard too. > The use of exec also results in (seemingly) arbitrary constraints on the > input. Like, why can't "--" be a name? Because exec? Is there some other > reason? Because Python doesn't allow "--" to be an attribute name, and so namedtuple doesn't let you try: t = namedtuple("T", "foo -- bar")(1, 2, 3) print(t.foo) print(t.--) print(t.bar) -- Steven From simeon.chaos at gmail.com Thu Nov 10 03:35:06 2011 From: simeon.chaos at gmail.com (Simeon Chaos) Date: Thu, 10 Nov 2011 00:35:06 -0800 (PST) Subject: dao 0.7.4 released Message-ID: <20d8f55c-6803-4574-92c8-1704b4918b99@p20g2000prm.googlegroups.com> ---------------------------- What's new in dao 0.7.4? ---------------------------- *Release date: 2011-11-10 * new in code: * quasiquote, unquote, unquote_slicing is implemented. * directly evaluate sexpression in solver * some builtins for define, set and get global, outer and local var * lisp style macro: expand and eval on UserMacro From jeanpierreda at gmail.com Thu Nov 10 03:51:10 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 10 Nov 2011 03:51:10 -0500 Subject: all() is slow? In-Reply-To: <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: > I don't expect you to take my word on it (and why should you, I could be > an idiot or a sock-puppet), but you could always try googling for > "Raymond Hettinger python" and see what comes up. He is not some fly-by > Python coder who snuck some dubious n00b code into the standard library > when no-one was looking :) Alright, I know *something* about him. I knew he was a core developer, and that he was responsible for namedtuple. I also discovered (when I looked up his activestate profile) some other stuff he wrote. I don't really know anything about him outside of that -- i.e. I have no idea what parts of Python he's contributed things to in the past that could make me go, "oh, wow, _he_ did that?" and so on. I don't really feel like a few minutes research would give me the right feel, it generally has to come up organically. Anyway, if we step back, for a trustworthy developer who wrote something seemingly-crazy, I should be willing to suspend judgement until I see the relevant facts about something that the developer might have and I don't. But he did give the facts, ( http://bugs.python.org/issue3974 again) , and I'm not convinced. Things can go terribly wrong when abusing exec e.g. http://www.gossamer-threads.com/lists/python/bugs/568206 . That shouldn't ever happen with a function such as this. exec opens doors that should not be opened without a really good reason, and those reasons don't strike me that way. > The mere fact that it was accepted into the standard library should tell > you that core Python developers consider it an acceptable technique. I've seen core developers rail against the namedtuple source code. In fairness, I don't believe exec was the subject of the rant -- nonetheless its presence isn't evidence of general support, and even if it were, my tastes have always differed from that of the core developers. > That's not to say the technique is uncontroversial. But there are still > people who dislike "x if flag else y" and @decorator syntax -- > controversy, in and of itself, isn't necessarily a reason to avoid > certain idioms. I think there's somewhat a difference in magnitude of objections between using exec as a hacked-together macro system, and using "x if flag else y" when if statements would do. If the exec trick is reasonable, we should normalize it in the form of a real, useful macro system, that can protect us against exec's many flaws (code injection, accidental syntax errors, etc.) and tell future programmers how to do this safely and in a semi-approvable way. > I would agree that the use of exec is a code smell. But that doesn't mean > it is wrong or bad, merely that it needs a second look before accepting > it. There's a world of difference between "You MUST NOT use exec" and > "You SHOULD NOT use exec". Do I really need a second look? I see exec, I wonder what it's doing. It isn't doing anything that couldn't be done subjectively better with e.g. a dict, so I disapprove of the usage of exec. > There's nothing inside the template being exec'ed that couldn't be found > in non-exec code. So if you're having trouble figuring out parts of the > code, the presence of the exec is not the problem. There's more overhead going back and forth to the template, and there's related things that I can't be sure are because of exec or because of design decisions, etc. It makes code reading more challenging, even if it's still possible. That said, sure, some of these are problems with whatever else he's done. > Having said that, dynamic code generation is well known for often being > harder to read than "ordinary" code. But then, pointers are hard too. And on the other other hand, Python lacks explicit support for both pointers and code generation (unless you count strings and ctypes). > Because Python doesn't allow "--" to be an attribute name, and so > namedtuple doesn't let you try: > > t = namedtuple("T", "foo -- bar")(1, 2, 3) > print(t.foo) > print(t.--) > print(t.bar) '--' is a valid attribute name on virtually any object that supports attribute setting (e.g. function objects). Of course, you need to use setattr() and getattr(). Is this really the reason, or is it a limitation caused primarily by the usage of exec and the need to prevent code injection? If somebody added this feature later on, would this create a security vulnerability in certain projects that used namedtuple in certain ways? Devin On Thu, Nov 10, 2011 at 2:48 AM, Steven D'Aprano wrote: > On Wed, 09 Nov 2011 20:26:56 -0500, Devin Jeanpierre wrote: > >>> Neither am I. I am less suspicious based on a reputation. Raymond is a >>> well-known, trusted senior Python developer who knows what he is doing. >> >> I don't really know anything about him or why people respect him, so I >> have no reason to share your faith. > > That's fine. > > I don't expect you to take my word on it (and why should you, I could be > an idiot or a sock-puppet), but you could always try googling for > "Raymond Hettinger python" and see what comes up. He is not some fly-by > Python coder who snuck some dubious n00b code into the standard library > when no-one was looking :) > > The mere fact that it was accepted into the standard library should tell > you that core Python developers consider it an acceptable technique. > That's not to say the technique is uncontroversial. But there are still > people who dislike "x if flag else y" and @decorator syntax -- > controversy, in and of itself, isn't necessarily a reason to avoid > certain idioms. > > > Are you familiar with the idea of "code smell"? > > http://www.codinghorror.com/blog/2006/05/code-smells.html > http://www.joelonsoftware.com/articles/Wrong.html > > I would agree that the use of exec is a code smell. But that doesn't mean > it is wrong or bad, merely that it needs a second look before accepting > it. There's a world of difference between "You MUST NOT use exec" and > "You SHOULD NOT use exec". > > See RFC 2119 if you are unclear on the difference: > > http://www.ietf.org/rfc/rfc2119.txt > > > >>> It reads fine, and the justification is perfectly valid. >> >> Well. It reads fine in a certain sense, in that I can figure out what's >> going on (although I have some troubles figuring out why the heck >> certain things are in the code). The issue is that what's going on is >> otherworldly: this is not a Python pattern, this is not a normal >> approach. To me, that means it does not read fine. > > There's nothing inside the template being exec'ed that couldn't be found > in non-exec code. So if you're having trouble figuring out parts of the > code, the presence of the exec is not the problem. > > Having said that, dynamic code generation is well known for often being > harder to read than "ordinary" code. But then, pointers are hard too. > > > >> The use of exec also results in (seemingly) arbitrary constraints on the >> input. Like, why can't "--" be a name? Because exec? Is there some other >> reason? > > Because Python doesn't allow "--" to be an attribute name, and so > namedtuple doesn't let you try: > > t = namedtuple("T", "foo -- bar")(1, 2, 3) > print(t.foo) > print(t.--) > print(t.bar) > > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From tartley at tartley.com Thu Nov 10 04:08:12 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 10 Nov 2011 01:08:12 -0800 (PST) Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: <5611883.2927.1320916092038.JavaMail.geo-discussion-forums@yqni5> Hey. I don't know the details, but your setup.py needs to use either the 'package_data' or the 'data_files' entry in the dict you pass to setup. These can specify files you want included in the sdist which aren't package files. There are many complications with using them though. One of them in particular (I don't remember which one) installs the files you specify in a different place depending on whether the user is installing the sdist from local files (python setup.py install) or using pip, so be sure to test both ways. From tartley at tartley.com Thu Nov 10 04:08:12 2011 From: tartley at tartley.com (Jonathan Hartley) Date: Thu, 10 Nov 2011 01:08:12 -0800 (PST) Subject: easy_install doesn't install non-package *.py file In-Reply-To: References: Message-ID: <5611883.2927.1320916092038.JavaMail.geo-discussion-forums@yqni5> Hey. I don't know the details, but your setup.py needs to use either the 'package_data' or the 'data_files' entry in the dict you pass to setup. These can specify files you want included in the sdist which aren't package files. There are many complications with using them though. One of them in particular (I don't remember which one) installs the files you specify in a different place depending on whether the user is installing the sdist from local files (python setup.py install) or using pip, so be sure to test both ways. From baptiste.lepilleur at gmail.com Thu Nov 10 05:51:15 2011 From: baptiste.lepilleur at gmail.com (Baptiste Lepilleur) Date: Thu, 10 Nov 2011 11:51:15 +0100 Subject: How to derive from datetime.timezone class? Message-ID: Hi, I want to sub-class the datetime.timezone class, but when I derive from datetime.timezone I get an error message "TypeError: type 'datetime.timezone' is not an acceptable base type". Why do I get this error? Is there something specific to do to avoid it? Below is an example of code: Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> datetime.timezone >>> class Utc(datetime.timezone): ... pass ... Traceback (most recent call last): File "", line 1, in TypeError: type 'datetime.timezone' is not an acceptable base type Baptiste. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 08:15:39 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 21:15:39 +0800 Subject: The python implementation of the "relationships between classes". Message-ID: Greetings: As you know, there are several kinds of relationships between classes in the UML -- dependency, association, aggregation, composition. Q1. Is there any article or code example on its implementation in python? Q2. For example, in composition model, the container object may be responsible for the handling of embedded objects' lifecycle. What is the python pattern of such implementation? would it be adding __del__ to the container class to del embedded objects or something else? Thanks! Biao -------------- next part -------------- An HTML attachment was scrubbed... URL: From gheskett at wdtv.com Thu Nov 10 08:20:54 2011 From: gheskett at wdtv.com (gene heskett) Date: Thu, 10 Nov 2011 08:20:54 -0500 Subject: all() is slow? In-Reply-To: References: <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <201111100820.54520.gheskett@wdtv.com> On Thursday, November 10, 2011 08:13:13 AM Devin Jeanpierre did opine: > > I don't expect you to take my word on it (and why should you, I could > > be an idiot or a sock-puppet), but you could always try googling for > > "Raymond Hettinger python" and see what comes up. He is not some > > fly-by Python coder who snuck some dubious n00b code into the > > standard library when no-one was looking :) > > Alright, I know *something* about him. I knew he was a core developer, > and that he was responsible for namedtuple. I also discovered (when I > looked up his activestate profile) some other stuff he wrote. I don't > really know anything about him outside of that -- i.e. I have no idea > what parts of Python he's contributed things to in the past that could > make me go, "oh, wow, _he_ did that?" and so on. I don't really feel > like a few minutes research would give me the right feel, it generally > has to come up organically. > > Anyway, if we step back, for a trustworthy developer who wrote > something seemingly-crazy, I should be willing to suspend judgement > until I see the relevant facts about something that the developer > might have and I don't. But he did give the facts, > ( http://bugs.python.org/issue3974 again) , and I'm not convinced. > > Things can go terribly wrong when abusing exec e.g. > http://www.gossamer-threads.com/lists/python/bugs/568206 . That > shouldn't ever happen with a function such as this. exec opens doors > that should not be opened without a really good reason, and those > reasons don't strike me that way. If, in the sense that this python 'exec' essentially duplicates the bash version, then I have found it quite useful, it was taught to me several years ago by another teacher who was a long time Solaris fan, and if it were to go away, I have several bash scripts running here right now that would require major re-writes. > > The mere fact that it was accepted into the standard library should > > tell you that core Python developers consider it an acceptable > > technique. Well, its certainly not a new concept. All the major 'shell interpreters' have it, why not python? > I've seen core developers rail against the namedtuple source code. In > fairness, I don't believe exec was the subject of the rant -- > nonetheless its presence isn't evidence of general support, and even > if it were, my tastes have always differed from that of the core > developers. > > > That's not to say the technique is uncontroversial. But there are > > still people who dislike "x if flag else y" and @decorator syntax -- > > controversy, in and of itself, isn't necessarily a reason to avoid > > certain idioms. > > I think there's somewhat a difference in magnitude of objections > between using exec as a hacked-together macro system, and using "x if > flag else y" when if statements would do. > > If the exec trick is reasonable, we should normalize it in the form of > a real, useful macro system, that can protect us against exec's many > flaws (code injection, accidental syntax errors, etc.) and tell future > programmers how to do this safely and in a semi-approvable way. > > > I would agree that the use of exec is a code smell. But that doesn't > > mean it is wrong or bad, merely that it needs a second look before > > accepting it. There's a world of difference between "You MUST NOT use > > exec" and "You SHOULD NOT use exec". > > Do I really need a second look? I see exec, I wonder what it's doing. > It isn't doing anything that couldn't be done subjectively better with > e.g. a dict, so I disapprove of the usage of exec. > > > There's nothing inside the template being exec'ed that couldn't be > > found in non-exec code. So if you're having trouble figuring out > > parts of the code, the presence of the exec is not the problem. > > There's more overhead going back and forth to the template, and > there's related things that I can't be sure are because of exec or > because of design decisions, etc. It makes code reading more > challenging, even if it's still possible. That said, sure, some of > these are problems with whatever else he's done. > > > Having said that, dynamic code generation is well known for often > > being harder to read than "ordinary" code. But then, pointers are > > hard too. > > And on the other other hand, Python lacks explicit support for both > pointers and code generation (unless you count strings and ctypes). > > > Because Python doesn't allow "--" to be an attribute name, and so > > namedtuple doesn't let you try: > > > > t = namedtuple("T", "foo -- bar")(1, 2, 3) > > print(t.foo) > > print(t.--) > > print(t.bar) > > '--' is a valid attribute name on virtually any object that supports > attribute setting (e.g. function objects). Of course, you need to use > setattr() and getattr(). Is this really the reason, or is it a > limitation caused primarily by the usage of exec and the need to > prevent code injection? If somebody added this feature later on, would > this create a security vulnerability in certain projects that used > namedtuple in certain ways? > > Devin > > On Thu, Nov 10, 2011 at 2:48 AM, Steven D'Aprano > > wrote: > > On Wed, 09 Nov 2011 20:26:56 -0500, Devin Jeanpierre wrote: > >>> Neither am I. I am less suspicious based on a reputation. Raymond is > >>> a well-known, trusted senior Python developer who knows what he is > >>> doing. > >> > >> I don't really know anything about him or why people respect him, so > >> I have no reason to share your faith. > > > > That's fine. > > > > I don't expect you to take my word on it (and why should you, I could > > be an idiot or a sock-puppet), but you could always try googling for > > "Raymond Hettinger python" and see what comes up. He is not some > > fly-by Python coder who snuck some dubious n00b code into the > > standard library when no-one was looking :) > > > > The mere fact that it was accepted into the standard library should > > tell you that core Python developers consider it an acceptable > > technique. That's not to say the technique is uncontroversial. But > > there are still people who dislike "x if flag else y" and @decorator > > syntax -- controversy, in and of itself, isn't necessarily a reason > > to avoid certain idioms. > > > > > > Are you familiar with the idea of "code smell"? > > > > http://www.codinghorror.com/blog/2006/05/code-smells.html > > http://www.joelonsoftware.com/articles/Wrong.html > > > > I would agree that the use of exec is a code smell. But that doesn't > > mean it is wrong or bad, merely that it needs a second look before > > accepting it. There's a world of difference between "You MUST NOT use > > exec" and "You SHOULD NOT use exec". > > > > See RFC 2119 if you are unclear on the difference: > > > > http://www.ietf.org/rfc/rfc2119.txt > > > >>> It reads fine, and the justification is perfectly valid. > >> > >> Well. It reads fine in a certain sense, in that I can figure out > >> what's going on (although I have some troubles figuring out why the > >> heck certain things are in the code). The issue is that what's going > >> on is otherworldly: this is not a Python pattern, this is not a > >> normal approach. To me, that means it does not read fine. > > > > There's nothing inside the template being exec'ed that couldn't be > > found in non-exec code. So if you're having trouble figuring out > > parts of the code, the presence of the exec is not the problem. > > > > Having said that, dynamic code generation is well known for often > > being harder to read than "ordinary" code. But then, pointers are > > hard too. > > > >> The use of exec also results in (seemingly) arbitrary constraints on > >> the input. Like, why can't "--" be a name? Because exec? Is there > >> some other reason? > > > > Because Python doesn't allow "--" to be an attribute name, and so > > namedtuple doesn't let you try: > > > > t = namedtuple("T", "foo -- bar")(1, 2, 3) > > print(t.foo) > > print(t.--) > > print(t.bar) > > > > > > > > > > -- > > Steven > > -- > > http://mail.python.org/mailman/listinfo/python-list Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: >Ever heard of .cshrc? That's a city in Bosnia. Right? (Discussion in comp.os.linux.misc on the intuitiveness of commands.) From rosuav at gmail.com Thu Nov 10 08:26:37 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Nov 2011 00:26:37 +1100 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 12:15 AM, Jerry Zhang wrote: > For example, in composition model, the container object may be responsible > for the handling of embedded objects' lifecycle. What is the python pattern > of such implementation? Here's an example: class Test(object): def __init__(self): self.lst=[1,2,3] self.map={"foo":12,"bar":34} This is a container that has a list and a dictionary in it. When an instance of the container is destroyed, its list and dictionary will be destroyed too (assuming nobody's made other references to them). You don't need to code anything explicitly for that. Chris Angelico From jerry.scofield at gmail.com Thu Nov 10 08:58:41 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 21:58:41 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: Hi Chris, Firstly thanks for your quick reply. 1. Your code example gives a point, but i may not reach my question yet, maybe because i did not make myself understood yet. Here is a more detail example question. I have a classes sets described by UML, which could be refered as Cls_A, Cls_B, CLs_C, Cls_D, Cls_E. There are four relationship between them--dependency, association, aggregation, composition. What i need to do is define all of the classes by python, and,of course, the class definition should describe there relationship correctly. For example, implement composition relationship between Cls_A and Cls_B, which may means a instance of Cls_B is created and destroyed by a Cls_A instance, My code may be like this(not sure since i am not quite familiar with python yet): Cls_a: def __init__(self): self.at1 = 1 Cls_b: def __init__(self): self.com1 = Cls_a() def __del__(self): del self.com1 Is it a right implementation for composition? and i need also do other relationship definition into class, like dependency, association, aggregation... Is there any article or code example on the relationships implementation? Thanks! Biao 2011/11/10 Chris Angelico > On Fri, Nov 11, 2011 at 12:15 AM, Jerry Zhang > wrote: > > For example, in composition model, the container object may be > responsible > > for the handling of embedded objects' lifecycle. What is the python > pattern > > of such implementation? > > Here's an example: > > class Test(object): > def __init__(self): > self.lst=[1,2,3] > self.map={"foo":12,"bar":34} > > This is a container that has a list and a dictionary in it. When an > instance of the container is destroyed, its list and dictionary will > be destroyed too (assuming nobody's made other references to them). > You don't need to code anything explicitly for that. > > Chris Angelico > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Nov 10 09:09:07 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Nov 2011 01:09:07 +1100 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang wrote: > Cls_a: > ? ? def __init__(self): > ? ? ? ? self.at1 = 1 > Cls_b: > ? ? def __init__(self): > ? ? ? ? self.com1 = Cls_a() > ? ? def __del__(self): > ? ? ? ? del self.com1 > Is it a right implementation for composition? Yes, except that you don't need to explicitly del it. Python (at least, CPython) is reference-counted; your Cls_b object owns a reference to the Cls_a object, so (assuming nothing else has a reference) that Cls_a will be happily cleaned up when the Cls_b is. Python doesn't really talk about "composition" etc. It's much simpler: everything's an object, and you have references to that object. A named variable is a reference to some object. A member on an object is, too. Whenever an object is expired, all objects that it references lose one reference, and if that was the sole reference, those objects get expired too. It's a change of thinking, perhaps, but not a difficult one in my opinion; and it's so easy to work with when you grok it. ChrisA From jerry.scofield at gmail.com Thu Nov 10 09:25:35 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 22:25:35 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: 2011/11/10 Chris Angelico > On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang > wrote: > > Cls_a: > > def __init__(self): > > self.at1 = 1 > > Cls_b: > > def __init__(self): > > self.com1 = Cls_a() > > def __del__(self): > > del self.com1 > > Is it a right implementation for composition? > > Yes, except that you don't need to explicitly del it. Python (at > least, CPython) is reference-counted; your Cls_b object owns a > reference to the Cls_a object, so (assuming nothing else has a > reference) that Cls_a will be happily cleaned up when the Cls_b is. > > Python doesn't really talk about "composition" etc. It's much simpler: > everything's an object, and you have references to that object. A > named variable is a reference to some object. A member on an object > is, too. Whenever an object is expired, all objects that it references > lose one reference, and if that was the sole reference, those objects > get expired too. It's a change of thinking, perhaps, but not a > difficult one in my opinion; and it's so easy to work with when you > grok it. > Unfortunately there is a difference between composition and aggregation in my real word, and my application really care this since it is trying to simulate this real world model, so my system should track this difference accurately, otherwise the system may not work well. For example, a. the Cls_arm and Cls_body may be composition, but not aggregation. My app must ensure that " one arm instance only live with one body instance, if the body instance die, the arm instance must die. b. the Cls_auto and the Cls_tyre may be aggregation. "One tyre still can live even the auto is dead." Meanwhile, I have a ZODB running, which stores all the living objects. > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 09:31:36 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 22:31:36 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: 2011/11/10 Jerry Zhang > > > 2011/11/10 Chris Angelico > >> On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang >> wrote: >> > Cls_a: >> > def __init__(self): >> > self.at1 = 1 >> > Cls_b: >> > def __init__(self): >> > self.com1 = Cls_a() >> > def __del__(self): >> > del self.com1 >> > Is it a right implementation for composition? >> >> Yes, except that you don't need to explicitly del it. Python (at >> least, CPython) is reference-counted; your Cls_b object owns a >> reference to the Cls_a object, so (assuming nothing else has a >> reference) that Cls_a will be happily cleaned up when the Cls_b is. >> >> Python doesn't really talk about "composition" etc. It's much simpler: >> everything's an object, and you have references to that object. A >> named variable is a reference to some object. A member on an object >> is, too. Whenever an object is expired, all objects that it references >> lose one reference, and if that was the sole reference, those objects >> get expired too. It's a change of thinking, perhaps, but not a >> difficult one in my opinion; and it's so easy to work with when you >> grok it. >> > > Unfortunately there is a difference between composition and aggregation in > my real word, and my application really care this since it is trying to > simulate this real world model, so my system should track this difference accurately, > otherwise the system may not work well. > > For example, > a. the Cls_arm and Cls_body may be composition, but not aggregation. My > app must ensure that " one arm instance only live with one body instance, > if the body instance die, the arm instance must die. > b. the Cls_auto and the Cls_tyre may be aggregation. "One tyre still can > live even the auto is dead." > > Meanwhile, I have a ZODB running, which stores all the living objects. > So lifecycle should be ensured by class definition. I originally thought this topic would be talked somewhere since many python OOP designer should have met this, or am i wrong on some point? > > >> ChrisA >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iamforufriends at gmail.com Thu Nov 10 09:35:34 2011 From: iamforufriends at gmail.com (sweet girl) Date: Thu, 10 Nov 2011 06:35:34 -0800 (PST) Subject: she want a boy friend for dating Message-ID: she want a boy friend for dating http://alturl.com/b5ikf http://alturl.com/b5ikf http://alturl.com/b5ikf http://alturl.com/b5ikf From vs at it.uu.se Thu Nov 10 09:47:43 2011 From: vs at it.uu.se (Virgil Stokes) Date: Thu, 10 Nov 2011 15:47:43 +0100 Subject: Agent-based modeling Message-ID: <4EBBE40F.9030009@it.uu.se> Python seems like a good language to use for agent-based modeling. However, before starting to work on a Python package for this, I would be very interested in knowing about any existing Python code for agent-based modeling. --V -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 10:16:14 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Thu, 10 Nov 2011 23:16:14 +0800 Subject: Agent-based modeling In-Reply-To: <4EBBE40F.9030009@it.uu.se> References: <4EBBE40F.9030009@it.uu.se> Message-ID: 2011/11/10 Virgil Stokes > Python seems like a good language to use for agent-based modeling. > However, before starting to work on a Python package for this, I would be > very interested in knowing about any existing Python code for agent-based > modeling. > I am assuming you are talking about the pattern design -- agent pattern, right? > > > --V > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Thu Nov 10 10:44:29 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Thu, 10 Nov 2011 15:44:29 +0000 Subject: simple import hook Message-ID: <4EBBF15D.9090401@gmail.com> So I would really like to accomplish the following: run a program normally and keep track of all the imports that were actually done. I studied the PEP 302, but I'm still a bit confused about how to do it. I thought that instead of implementing everything I could just record the request and then delegate to the "imp" module, so I did this: class MyLoader(object): """ Loader object """ def __init__(self): self.loaded = set() def find_module(self, module_name, package=None): print("requesting %s" % module_name) self.loaded.add(module_name) return self def load_module(self, fullname): #XXX: the find_module is actually doing nothing, since # everything is delegated to the "imp" module fp, pathname, stuff = imp.find_module(fullname) imp.load_module(fullname, fp, pathname, stuff) myl = MyLoader() sys.meta_path.append(myl) try: import random import os print(random.random()) Which doesn't work, and very strangely it doesn't even look deterministic! Sometimes it stops at first import sometimes it's able to do a few of them. How can that be? And how could I do solve my problem? From tim.wintle at teamrubber.com Thu Nov 10 11:09:08 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Thu, 10 Nov 2011 16:09:08 +0000 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: <1320941348.7601.57.camel@tim-laptop> On Thu, 2011-11-10 at 22:25 +0800, Jerry Zhang wrote: > > > 2011/11/10 Chris Angelico > On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang > wrote: > > Cls_a: > > def __init__(self): > > self.at1 = 1 > > Cls_b: > > def __init__(self): > > self.com1 = Cls_a() > > def __del__(self): > > del self.com1 > > Is it a right implementation for composition? > > > Yes, except that you don't need to explicitly del it. Python > (at > least, CPython) is reference-counted; your Cls_b object owns a > reference to the Cls_a object, so (assuming nothing else has a > reference) that Cls_a will be happily cleaned up when the > Cls_b is. > > Python doesn't really talk about "composition" etc. It's much > simpler: > everything's an object, and you have references to that > object. A > named variable is a reference to some object. A member on an > object > is, too. Whenever an object is expired, all objects that it > references > lose one reference, and if that was the sole reference, those > objects > get expired too. It's a change of thinking, perhaps, but not a > difficult one in my opinion; and it's so easy to work with > when you > grok it. > > > Unfortunately there is a difference between composition and > aggregation in my real word, and my application really care this since > it is trying to simulate this real world model, so my system should > track this difference accurately, otherwise the system may not work > well. You might want to look into weak references: http://docs.python.org/library/weakref.html Although I agree with Chris that it sounds like your code might be easier with a change of perspective (I've not done much UML, but the way you're describing things sounds like a java-ish way of looking at it to me) > For example, > a. the Cls_arm and Cls_body may be composition, but not aggregation. > My app must ensure that " one arm instance only live with one body > instance, if the body instance die, the arm instance must die. > b. the Cls_auto and the Cls_tyre may be aggregation. "One tyre still > can live even the auto is dead." That behaviour isn't really hard-coded as part of the language in python, as it's not required for memory management in the same way it would be in C++ or langauges without GCs. As long as no objects other than body objects hold a reference to arm objects then the arm object will be deleted. For The tyre object to be deleted when the auto object is deleted, there would have to be no references left to the tyre object. If there aren't any references then you can't know if it exists or not anyway, so the distinction isn't useful. > Meanwhile, I have a ZODB running, which stores all the living > objects. The ZODB is append only and stores all objects. Deleting references to an object (which would causes deletion of standard python objects) won't delete it from the zodb, it'll just delete the references. From k.sahithi2862 at gmail.com Thu Nov 10 11:34:07 2011 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Thu, 10 Nov 2011 08:34:07 -0800 (PST) Subject: WORLD BEST PICS Message-ID: <9094454c-45ad-45d4-834d-43cbf645df87@i13g2000prg.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html From vs at it.uu.se Thu Nov 10 12:15:37 2011 From: vs at it.uu.se (Virgil Stokes) Date: Thu, 10 Nov 2011 18:15:37 +0100 Subject: Agent-based modeling In-Reply-To: References: <4EBBE40F.9030009@it.uu.se> Message-ID: <4EBC06B9.6030201@it.uu.se> On 10-Nov-2011 16:16, Jerry Zhang wrote: > > > 2011/11/10 Virgil Stokes > > > Python seems like a good language to use for agent-based modeling. > However, before starting to work on a Python package for this, I would be > very interested in knowing about any existing Python code for agent-based > modeling. > > > I am assuming you are talking about the pattern design -- agent pattern, right? > > > > --V > > -- > http://mail.python.org/mailman/listinfo/python-list > > Sorry Jerry if my email was unclear. I am referring to agent-based modeling as defined at http://en.wikipedia.org/wiki/Agent-based_model -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at cheimes.de Thu Nov 10 12:23:15 2011 From: lists at cheimes.de (Christian Heimes) Date: Thu, 10 Nov 2011 18:23:15 +0100 Subject: The python implementation of the "relationships between classes". In-Reply-To: <1320941348.7601.57.camel@tim-laptop> References: <1320941348.7601.57.camel@tim-laptop> Message-ID: Am 10.11.2011 17:09, schrieb Tim Wintle: >> Meanwhile, I have a ZODB running, which stores all the living >> objects. > > The ZODB is append only and stores all objects. Deleting references to > an object (which would causes deletion of standard python objects) won't > delete it from the zodb, it'll just delete the references. That's not entirely correct. In fact you *CAN* delete references to objects that are stored in ZODB. An unreferenced object is no longer accessible from future transactions. The object is only available from the transaction history log and thus still stored in the database file until the ZODB is packed. Once the ZODB is packed, all unreferenced objects are gone for good. ZODB is much more than a simple pickle jar. It's a transparent and poweful object database that behaves like an ordinary tree of Python objects. From andrea.crotti.0 at gmail.com Thu Nov 10 12:46:07 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Thu, 10 Nov 2011 17:46:07 +0000 Subject: simple import hook In-Reply-To: References: <4EBBF15D.9090401@gmail.com> Message-ID: <4EBC0DDF.9000708@gmail.com> On 11/10/2011 05:02 PM, Eric Snow wrote: > > Yeah, I'm working on a reference for imports in Python. They're just > a little too mysterious relative to the rest of the language. But > it's not too helpful yet. In the meantime... Yes it's quite mysterious, and it's actually not as hard as it looks.. Anyway I'm glad to say that I reached what I basically wanted. This script actually compiles the code and runs it, reporting the imports done in the end. Any suggestion is still welcome :) """ This script is used to analyse the imports which are actually being done """ import argparse import os import sys class CollectImports(object): """ Loader object """ def __init__(self): self.loaded = set() def __str__(self): return str(self.loaded) def find_module(self, module_name, package=None): print("requesting %s" % module_name) self.loaded.add(module_name) if __name__ == '__main__': parser = argparse.ArgumentParser(description='analyse the imports made') parser.add_argument('script') parser.add_argument('arguments', nargs='*') ns = parser.parse_args() progname = ns.script sys.path.insert(0, os.path.dirname(progname)) cl = CollectImports() # TODO: maybe we can create a with clause also for this thing sys.meta_path.append(cl) # TODO: catch the exit signal and present the output code = compile(open(progname).read(), progname, 'exec') exec(code) print("imports done: %s" % str(cl)) > That _is_ pretty strange. > > After what I recommended above, are you still getting the wierdness? > It could just be a side-effect of your use of the imp functions. in > load_module(), so getting rid of it would help. > > What version of Python are you using? If not 2.7 or 3.2, do you get > the same problem when you run the code under one of those latest > versions? > > Even when the number of imports is different, are they always in the > same order? Highly unlikely, but if you say no then this is extra > fishy. > It was python 2.7 on Arch-linux, but thanks to your suggestions everything was actually fixed.. From jerry.scofield at gmail.com Thu Nov 10 13:06:18 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 02:06:18 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: <1320941348.7601.57.camel@tim-laptop> References: <1320941348.7601.57.camel@tim-laptop> Message-ID: 2011/11/11 Tim Wintle > On Thu, 2011-11-10 at 22:25 +0800, Jerry Zhang wrote: > > > > > > 2011/11/10 Chris Angelico > > On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang > > wrote: > > > Cls_a: > > > def __init__(self): > > > self.at1 = 1 > > > Cls_b: > > > def __init__(self): > > > self.com1 = Cls_a() > > > def __del__(self): > > > del self.com1 > > > Is it a right implementation for composition? > > > > > > Yes, except that you don't need to explicitly del it. Python > > (at > > least, CPython) is reference-counted; your Cls_b object owns a > > reference to the Cls_a object, so (assuming nothing else has a > > reference) that Cls_a will be happily cleaned up when the > > Cls_b is. > > > > Python doesn't really talk about "composition" etc. It's much > > simpler: > > everything's an object, and you have references to that > > object. A > > named variable is a reference to some object. A member on an > > object > > is, too. Whenever an object is expired, all objects that it > > references > > lose one reference, and if that was the sole reference, those > > objects > > get expired too. It's a change of thinking, perhaps, but not a > > difficult one in my opinion; and it's so easy to work with > > when you > > grok it. > > > > > > Unfortunately there is a difference between composition and > > aggregation in my real word, and my application really care this since > > it is trying to simulate this real world model, so my system should > > track this difference accurately, otherwise the system may not work > > well. > > You might want to look into weak references: > http://docs.python.org/library/weakref.html > > Although I agree with Chris that it sounds like your code might be > easier with a change of perspective (I've not done much UML, but the way > you're describing things sounds like a java-ish way of looking at it to > me) > > > For example, > > a. the Cls_arm and Cls_body may be composition, but not aggregation. > > My app must ensure that " one arm instance only live with one body > > instance, if the body instance die, the arm instance must die. > > b. the Cls_auto and the Cls_tyre may be aggregation. "One tyre still > > can live even the auto is dead." > > That behaviour isn't really hard-coded as part of the language in > python, as it's not required for memory management in the same way it > would be in C++ or langauges without GCs. > > As long as no objects other than body objects hold a reference to arm > objects then the arm object will be deleted. > > For The tyre object to be deleted when the auto object is deleted, there > would have to be no references left to the tyre object. If there aren't > any references then you can't know if it exists or not anyway, so the > distinction isn't useful. > I just did an example code to describe what i am looking for. /*------------------------------------------------------------------------------------------------*/ # ... class Head: def __init__(self): self.size = 5 class Hat: def __init__(self): self.color = red def took_on(self, body): self.body = body def took_off(self, body): del self.body class Body: def __init__(self): self.head = Head() def take_on_hat(self, hat): self.hat = hat hat.take_on(self) def take_off_hat(self): hat.take_off(self) del self.hat def go_to_heaven(self): take_off_hat(self) del self.head /*----------------------------------------------------------------------------------------------------------*/ In this example, Head and body are COMPOSITION, which means a. A head only live with one body, it can not live with other body. It can not even live without body b. If the body go to die, the head also go to die. Body and Hat are aggregation, which means a. A hat live isolate with body, its life circle is isolate b. A hat only live with one body at a specific time, it can not live with two body(association would be more than one) So when the body die, the clean dead should include take_off Hat and del Head, otherwise, the code definition is not prciselly describing the relationship, which may cause a mess system, for example, a body has dead, but one hat is still associated with a unreferenced body. A point on this issue, maybe python is smart that the take_off_hat(self) is not needed in go_to_heaven() method(i am not sure yet), but the del self.head is sure needed, otherwise, we will have a no_body_head in our ZODB, that is extremely horrible, right? All of these points one, the four kinds of class relationship in UML precisely describe the real word, if the implementation is not precisely, you will have unexpected results. Of course, python may be smart to achieve such goal with less effort, that is why i am asking for a code example for all of the four relationships. > > > Meanwhile, I have a ZODB running, which stores all the living > > objects. > > The ZODB is append only and stores all objects. Deleting references to > an object (which would causes deletion of standard python objects) won't > delete it from the zodb, it'll just delete the references. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 13:13:37 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 02:13:37 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <1320941348.7601.57.camel@tim-laptop> Message-ID: 2011/11/11 Christian Heimes > Am 10.11.2011 17:09, schrieb Tim Wintle: > >> Meanwhile, I have a ZODB running, which stores all the living > >> objects. > > > > The ZODB is append only and stores all objects. Deleting references to > > an object (which would causes deletion of standard python objects) won't > > delete it from the zodb, it'll just delete the references. > > That's not entirely correct. In fact you *CAN* delete references to > objects that are stored in ZODB. An unreferenced object is no longer > accessible from future transactions. The object is only available from > the transaction history log and thus still stored in the database file > until the ZODB is packed. Once the ZODB is packed, all unreferenced > objects are gone for good. > > ZODB is much more than a simple pickle jar. It's a transparent and > poweful object database that behaves like an ordinary tree of Python > objects. > > I am verifying the ZODB solution, not clear yet, anyway, your points regarding this sounds reasonable to me. i am almost sure the python and ZODB designer has already did a good job to make us handle such case easily, all i am trying to do is find the right path. Thanks a lot. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From numansenm at gmail.com Thu Nov 10 13:25:41 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:25:41 -0800 (PST) Subject: buy Paxil online without a prescription and no membership no prescription needed Paxil Message-ID: <23d833f3-ab6a-4f07-a1f3-428908ce0252@w3g2000vbw.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Paxil/Paxil pills with every Order ______________________________________________________________________ BUY Paxil ONLINE http://buypharmasite.com/?q=Paxil CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Paxil ONLINE http://buypharmasite.com/?q=Paxil CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Paxil Paxil online saturday delivery online Paxil and fedex cheap order prescription Paxil cheap Paxil by money order buy Paxil from mexico online Paxil no prescription usa fedex shipping overnight delivery Paxil buy Paxil online without a prescription and no membership no prescription needed Paxil cod shipped Paxil not expensive order prescription Paxil Paxil money order Paxil without a perscription online buy Paxil Paxil fedex buy no online prescription Paxil Paxil pharmacies accepting cod delivery Paxil online consultant online pharmacy fedex cod Paxil buy Paxil no scams Paxil c.o.d overnight delivery buy Paxil no prescription cod overnight Paxil order Paxil online doctors buy Paxil on line no prescription Paxil no prescription usa fedex shipping Paxil online uk watson brand Paxil medicine online Paxil order Paxil samples sent buy Paxil no prescription order Paxil without a prescription Paxil no prescription drug cheap online order Paxil get Paxil over the counter online order Paxil next day buy Paxil no perscription cod real Paxil fed ex Paxil no prescription cod does cv/ pharmacy carry Paxil no prescription cod Paxil cheap Paxil without rx Paxil online health insurance lead buy Paxil online with overnight delivery Paxil no rx fed ex buy Paxil without a perscription lowest prices for Paxil online buy Paxil paypal online without prescription cheap non prescription Paxil Paxil ups Paxil for cheap buy Paxil no visa online without prescription cheapest Paxil cash on delivery Paxil order a prepaid mastercard buy online Paxil purchase Paxil mail order Paxil without a prescription online with overnight delivery Paxil from canada buy Paxil with no rx overnight delivery of Paxil with no prescription cash on delivery Paxil no rx Paxil by cod buy Paxil over the counter cod overnight overnight Paxil order Paxil without prescription from us pharmacy cheap Paxil free fedex shipping order Paxil over the counter where to buy Paxil no prescription no fees only Paxil free consult cod delivery Paxil Paxil no prescription Paxil online overnight delivery cod order Paxil over the counter fedex Paxil saturday delivery buy Paxil money order Paxil without prescription mexico buy cheap Paxil without prescription Paxil non prescription for next day delivery Paxil ups delivery only buy Paxil usa cod Paxil with next day delivery no prescriptions needed for Paxil cheap Paxil overnight prescription Paxil cheap Paxil overnight delivery Paxil non prescription fedex overnight free order Paxil no creditcard buy cheap Paxil no Prescription buy Paxil over the counter fedex Paxil no doctor presribe needed cheap watson Paxil online cheap discount Paxil buy Paxil without a prescription online cheapest Paxil free delivery buy Paxil online overseas buy Paxil over the counter online not expensive Paxil next day shipping order Paxil cod next day delivery Paxil cheap Paxil buy in UK Paxil next day cod fedex Paxil to buy cheap order Paxil next day Paxil Paxil overnight no consult cheap watson Paxil no prescription needed Paxil without prescription medications overnight delivery of Paxil with no perscription buy Paxil.com Paxil cod next day delivery buy cheap discount online Paxil buy Paxil drug Paxil overnight delivery cheap overnight delivery of Paxil in US no prescription needed purchase Paxil free next day airPaxil on line cheap Paxil without a prescription Paxil cheap cod Paxil buy no prepaid cheap Paxil next day buy Paxil cod accepted online pharmacies Paxil saturday delivery buy Paxil pay pal Paxil shipped on saturday Paxil pharmacy cod saturday delivery buy online Paxil prescriptions free fedex delivery Paxil Paxil without prescription cash on delivery buy discount Paxil Paxil overnight cheap best Paxil online pill images of Paxil Paxil U.P.S SHIPPING COD Paxil cod pharmacy buy Paxil online cod Paxil cod overnight delivery Paxil no rx overnight buy Paxil overnight COD online pharmacy Paxil cod order Paxil insurance Paxil cash delivery cod buy Paxil cheap cod no rx online pharmacy Paxil sale nextday Paxil Paxil pill Paxil online ordering Paxil online without prescription Paxil no script needed cod overnight how to buy Paxil online without a prescription cheap Paxil without prescription cheap Paxil online no rx saturday delivery order Paxil over the counter for sale Paxil next day delivery cod order Paxil online without prescription no prescription next day delivery Paxil overnight Paxil C.O.D Paxil without prescription Paxil discount fedex no prescription buy Paxil amex Paxil online next day Paxil shipped with no prescription Paxil online cheap cheap Paxil without prescription overnight delivery buy Paxil over the counter for sale Paxil no prescriptions needed cod Paxil fed ex cheap overnight delivery of Paxil free prescription Paxil free shipping not expensive legal Paxil for sale buy Paxil cod Paxil for saturday Paxil price cash for Paxil cash on delivery Paxil Paxil without a prescription and cod delivery buying Paxil without a prescription order Paxil no rx buy Paxil without rx Paxil cheapest buy Paxil online pharmacy buy cheap Paxil overnight delivery Paxil and online pharmacy Paxil next day Paxil drug no prescription where can i buy Paxil no prescription Paxil with saturday delivery Paxil online overnight Paxil no prescription worldwide buy cheap Paxil cod ordering Paxil online Buy Paxil overnight shipping Paxil overnight US delivery cheap real Paxil for sale Paxil no prescriptions needed COD buy Paxil no prescription needed Paxil no prescription overnight cod delivery cheap Paxil cash on delivery no prescription required for Paxil order Paxil c.o.d. not expensive Paxil prescriptions Paxil online Cash on Delivery buy Paxil overnight delivery Paxil online without presciption buy Paxil prescription online no prescription saturday delivery Paxil where to buy cheap Paxil no prescription Paxil wo get Paxil over the counter fedex Paxil with no rx and free shipping order Paxil over the counter cod overnight Paxil Fedex Without Prescription Paxil Online With Next Day Shipping Buy Cheap Paxil online | purchase Paxil without prescription online | Paxil Online Prescriptions With No Membership Paxil Cheap next day | Buy Cheap Paxil fedex overnight | original Paxil pill | Purchase Paxil pharmacy r x online | Paxil cod Orders | Buy Paxil online pharmacy | Paxil cod ne xt day delivery | order Paxil online no membership overnight shipping | B uy Cheap Paxil Online No Prescription Order Paxil cod next day delivery | Paxil Discount cards | Buy genuine Paxil online | buying Paxil without a prescription | Where To Buy Paxil No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Paxil fedex without prescription | U ltram consumer information | pills Cheap generic Paxil | Buy Paxil onlin e no prescription | Paxil Buy | Buy Cheap Paxil Online No Prescription B uy Paxil online | purchase Paxil without prescription | Buying Paxil On line Without Prescription Paxil Overnight COD no prescription | Cheap onli ne Buy Paxil | Low Price Paxil Saturday Delivery No Prescription Paxil w ithout a prescription no generics | Buy Paxil Without Prescription Paxil overnight | Buy With No Prescription Paxil Online Order Paxil no rx overn ight delivery | Order Paxil Saturday Delivery No Prescription Paxil onlin e no prescription | Paxil Discount cards | Buy Paxil no script | Paxil by phone no script | Buy Paxil Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Paxil online without a prescription and no me mbership | Buy Without Prescription Paxil Online buy no prescription Ultra m | Order Paxil Cheap no membership fees no prescription | Paxil order n o script | Paxil lowest cost | online Buy Paxil | Overnight Paxil With out A Prescription Paxil Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Paxil Without A Prescription no script Paxil | Paxil Buy phone | Paxil paid with mastercard | Paxil With No Prescript ion Paxil to purchase | Order Paxil online with no prescription | Paxil Buying online Paxil drugs | Paxil free Overnight fedex delivery | Ultra m best online pharmacy | purchase Paxil without a prescription overnight d elivery | Buy Paxil online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Paxil From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Paxil next day | Where To Buy Paxil No Prescription No Fees Paxil ups cod | Order Paxil cash on delive ry | Paxil overnight shipping no prescription | purchase Paxil without p rescription online | Buy Paxil online without dr approval | Buy Paxil on line without dr approval | Paxil ups | Paxil Buy | Buy Paxil in Idaho | Paxil cheapest | Buy Paxil pay with mastercard | ordering Buy Paxil online | Paxil Overnight COD no prescription | Paxil order cod | Paxil No Prescription Paxil overnight delivery Cheap | Paxil order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Paxil usa online pharmacy | U ltram free consultation | how to Order Paxil without doctors | Purchase U ltram online | comprar Paxil | No Prescription Required For Paxil Paxil cod ordering | Cheap Paxil without prescription | Buy Cheap Paxil fast | Paxil Buy | Buy Paxil online without a prescription and no membership | Cheap Paxil without prescription overnight delivery | cash on delivery online prescriptions Paxil | Paxil with no prescription | ordering Ultra m online without a prescription | Paxil Cheap order | Paxil online no pr escription | No Prescription Needed Paxil Low Price Paxil With No Prescri ption Buy Paxil Online Without Prescription buy no prescription Paxil | B uy Paxil online discount | Paxil order cod | Order Cheap Paxil very Buy without prescription | Paxil cod next day delivery | Order Paxil Online Without Prescription Paxil free Overnight fedex delivery | Cheap Paxil b y money Order | Buy Paxil online discount | overnight Paxil | 8 Buy Ult ram online | Cheap Paxil c.o.d. | Buy Paxil Tablets Without Prescription Overnight Paxil for sale | Buy Paxil online sales | natural Paxil | U ltram manufacturer | Paxil Online No Prescription Paxil adiction | geniu ne Paxil no prescription | Paxil Pharmacy Cod Saturday Delivery With No P rescription Paxil Buy phone | Buy Paxil online prescription | Order Ultr am without prescription from us pharmacy | Buy real Paxil with mastercard | Paxil without a rx | doctor online prescription Paxil | Paxil Free O vernight Fedex Delivery order Paxil online cash on delivery | Cheap Paxil next day | Buy Paxil Cheap online us pharmacy | Paxil delivery to uk fe dex Overnight | Find Cheap Paxil no prescription | online pharmacy Paxil | Buy Paxil Online Without A Prescription And No Membership Paxil to pur chase | Paxil Same Day Delivery No Prescription Paxil by phone no script | Buy Paxil without | discount Paxil overnight | Buy Cheap Paxil, Buy Cheap Paxil online | Paxil Buy fedex | Paxil shipped with no prescripti on | Buy Paxil online money order | purchase Paxil without a prescriptio n | Paxil ups cod | Buy Paxil Online No Prescription Buy Paxil online | Paxil with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Paxil cod | how to get Paxil prescription | Low Price Paxil With No Prescription Buy the Cheapest Paxil online index | prescription U ltram | Order Paxil No Prescription Order Paxil medicine online without p rescription | Low Price Paxil Saturday Delivery No Prescription Cheap Ultr am overnight | Paxil Online No Prescription Paxil online cash on delivery | Fedex Paxil Without Prescription Buy Paxil online usa | Paxil for sa le without a prescription | to Buy Paxil without a prescription | Paxil Overnight no script mastercard accepted | Buy Cheap Paxil No Prescription Cheap Paxil free consultant | Buy Paxil Cheap online us pharmacy | Buy C heap Paxil No Prescription Paxil lowest cost | Where To Buy Paxil No Pre scription No Fees Cheapest Paxil Online Without Prescription cheapest Ultra m | Paxil amphetimine | Buy Paxil 120 tabs | Buy Paxil Without A Presc ription Or Membership Paxil Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Paxil | Paxil conversion | overnight Paxil ups cod | Buy Paxil online Cheap | Paxil No Script Required Express Delivery With No P rescription Paxil free consultation u.s. pharmacy | Paxil cod no script | Paxil ups cod | Paxil online no prescription | purchase Paxil with co d | Canadian Paxil Pills No Prescription Buy Paxil in North Carolina | buy Paxil in Denmark, buy Paxil in Egypt, buy Paxil in Israel, buy Paxil in Ireland, buy Paxil in Spain, buy Paxil in Italy, buy Paxil in Canada, buy Paxil in Cyprus, buy Paxil in Mexico, buy Paxil in Netherlands, buy Paxil in New zealand, buy Paxil in Kingston, buy Paxil in Australia, buy Paxil in AU, buy Paxil in New South Wales, buy Paxil in NSW, buy Paxil i n Sydney, buy Paxil in Brisbane, buy Paxil in South Australia, buy Paxil in Hobart, buy Paxil in the United states, buy Paxil in Finland, buy Ultra m in France, buy Paxil in Chekhiya, buy Paxil in Switzerland, buy Paxil i n Sweden, buy Paxil in Alberta, buy Paxil in Labrador, buy Paxil in Toron to, buy Paxil in Ottawa, buy Paxil in Mississauga, buy Paxil in Hamilton, buy Paxil in Brampton, buy Paxil in London, buy Paxil in Markham, buy Ul tram in Vaughan, buy Paxil in Windsor, buy Paxil in Kitchener, buy Paxil in Montreal, buy Paxil in Mauricie, buy Paxil in Vancouver, buy Paxil in Victoria, buy Paxil in Kelowna, buy Paxil in Abbotsford, buy Paxil in Kam loops, buy Paxil in Nanaimo, buy Paxil in Vernon, buy Paxil in Lethbridge , buy Paxil in United Kingdom, buy Paxil in England, buy Paxil in Wales, buy Paxil in Scotland, buy Paxil in Northern Ireland, buy Paxil in Belfas t, buy Paxil in Cardiff, buy Paxil in London, buy Paxil in Glasgow, buy U ltram in Liverpool, buy Paxil in Leeds, buy Paxil in Victoria, buy Paxil in Melbourne, buy Paxil in Western Australia, buy Paxil in Perth, buy Ultr am in Alabama, buy Paxil in Arizona, buy Paxil in Arkansas, buy Paxil in California, buy Paxil in Colorado, buy Paxil in Connecticut, buy Paxil in Delaware, buy Paxil in Florida, buy Paxil in Georgia, buy Paxil in Hawai i, buy Paxil in Idaho, buy Paxil in Illinois, buy Paxil in Indiana, buy U ltram in Iowa, buy Paxil in Kansas, buy Paxil in Kentucky, buy Paxil in L ouisiana, buy Paxil in Maine, buy Paxil in Montana, buy Paxil in Nebraska , buy Paxil in Nevada, buy Paxil in New Jersey, buy Paxil in New Mexico, buy Paxil in New York, buy Paxil in North Carolina, buy Paxil in North Da kota, buy Paxil in Ohio, buy Paxil in Oklahoma, buy Paxil in Texas, buy U ltram in Utah, buy Paxil in Vermont, buy Paxil in Virginia, buy Paxil in Washington, buy Paxil in West Virginia, buy Paxil in Wisconsin, buy Paxil in Wyoming, buy Paxil in Montgomery, buy Paxil in Juneau, buy Paxil in P hoenix, buy Paxil in Little Rock, buy Paxil in Sacramento, buy Paxil in D enver, buy Paxil in Hartford, buy Paxil in Dover, buy Paxil in Tallahasse e, buy Paxil in Atlanta, buy Paxil in Springfield, buy Paxil in Indianapo lis, buy Paxil in Des Moines, buy Paxil in Annapolis, buy Paxil in Boston , buy Paxil in Lansing, buy Paxil in Helena, buy Paxil in Lincoln, buy Ul tram in Santa Fe, buy Paxil in Albany, buy Paxil in Raleigh, buy Paxil in Bismarck, buy Paxil in Columbus, buy Paxil in Salem, buy Paxil in Columb ia, buy Paxil in Salt Lake City, buy Paxil in Montpelier, buy Paxil in Ch arleston, buy Paxil in Madison, buy Paxil in Cheyenne, buy Paxil in Austr alia, buy Paxil in Austria, buy Paxil in Argentina, buy Paxil in Belgium, buy Paxil in Bulgaria, buy Paxil in Brasilia, buy Paxil in Great britain , buy Paxil in Hungary, buy Paxil in Germany, buy Paxil in Greece, buy Ul tram in South Africa, buy Paxil in Japan From numansenm at gmail.com Thu Nov 10 13:28:13 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:28:13 -0800 (PST) Subject: buy Oxycontin paypal online without prescription | Oxycontin online health insurance lead Message-ID: <48ea0afa-6e46-482f-a868-e6035699754a@z20g2000yqc.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Oxycontin/Oxycontin pills with every Order ______________________________________________________________________ BUY Oxycontin ONLINE http://buypharmasite.com/?q=Oxycontin CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Oxycontin ONLINE http://buypharmasite.com/?q=Oxycontin CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Oxycontin Oxycontin online saturday delivery online Oxycontin and fedex cheap order prescription Oxycontin cheap Oxycontin by money order buy Oxycontin from mexico online Oxycontin no prescription usa fedex shipping overnight delivery Oxycontin buy Oxycontin online without a prescription and no membership no prescription needed Oxycontin cod shipped Oxycontin not expensive order prescription Oxycontin Oxycontin money order Oxycontin without a perscription online buy Oxycontin Oxycontin fedex buy no online prescription Oxycontin Oxycontin pharmacies accepting cod delivery Oxycontin online consultant online pharmacy fedex cod Oxycontin buy Oxycontin no scams Oxycontin c.o.d overnight delivery buy Oxycontin no prescription cod overnight Oxycontin order Oxycontin online doctors buy Oxycontin on line no prescription Oxycontin no prescription usa fedex shipping Oxycontin online uk watson brand Oxycontin medicine online Oxycontin order Oxycontin samples sent buy Oxycontin no prescription order Oxycontin without a prescription Oxycontin no prescription drug cheap online order Oxycontin get Oxycontin over the counter online order Oxycontin next day buy Oxycontin no perscription cod real Oxycontin fed ex Oxycontin no prescription cod does cv/ pharmacy carry Oxycontin no prescription cod Oxycontin cheap Oxycontin without rx Oxycontin online health insurance lead buy Oxycontin online with overnight delivery Oxycontin no rx fed ex buy Oxycontin without a perscription lowest prices for Oxycontin online buy Oxycontin paypal online without prescription cheap non prescription Oxycontin Oxycontin ups Oxycontin for cheap buy Oxycontin no visa online without prescription cheapest Oxycontin cash on delivery Oxycontin order a prepaid mastercard buy online Oxycontin purchase Oxycontin mail order Oxycontin without a prescription online with overnight delivery Oxycontin from canada buy Oxycontin with no rx overnight delivery of Oxycontin with no prescription cash on delivery Oxycontin no rx Oxycontin by cod buy Oxycontin over the counter cod overnight overnight Oxycontin order Oxycontin without prescription from us pharmacy cheap Oxycontin free fedex shipping order Oxycontin over the counter where to buy Oxycontin no prescription no fees only Oxycontin free consult cod delivery Oxycontin Oxycontin no prescription Oxycontin online overnight delivery cod order Oxycontin over the counter fedex Oxycontin saturday delivery buy Oxycontin money order Oxycontin without prescription mexico buy cheap Oxycontin without prescription Oxycontin non prescription for next day delivery Oxycontin ups delivery only buy Oxycontin usa cod Oxycontin with next day delivery no prescriptions needed for Oxycontin cheap Oxycontin overnight prescription Oxycontin cheap Oxycontin overnight delivery Oxycontin non prescription fedex overnight free order Oxycontin no creditcard buy cheap Oxycontin no Prescription buy Oxycontin over the counter fedex Oxycontin no doctor presribe needed cheap watson Oxycontin online cheap discount Oxycontin buy Oxycontin without a prescription online cheapest Oxycontin free delivery buy Oxycontin online overseas buy Oxycontin over the counter online not expensive Oxycontin next day shipping order Oxycontin cod next day delivery Oxycontin cheap Oxycontin buy in UK Oxycontin next day cod fedex Oxycontin to buy cheap order Oxycontin next day Oxycontin Oxycontin overnight no consult cheap watson Oxycontin no prescription needed Oxycontin without prescription medications overnight delivery of Oxycontin with no perscription buy Oxycontin.com Oxycontin cod next day delivery buy cheap discount online Oxycontin buy Oxycontin drug Oxycontin overnight delivery cheap overnight delivery of Oxycontin in US no prescription needed purchase Oxycontin free next day airOxycontin on line cheap Oxycontin without a prescription Oxycontin cheap cod Oxycontin buy no prepaid cheap Oxycontin next day buy Oxycontin cod accepted online pharmacies Oxycontin saturday delivery buy Oxycontin pay pal Oxycontin shipped on saturday Oxycontin pharmacy cod saturday delivery buy online Oxycontin prescriptions free fedex delivery Oxycontin Oxycontin without prescription cash on delivery buy discount Oxycontin Oxycontin overnight cheap best Oxycontin online pill images of Oxycontin Oxycontin U.P.S SHIPPING COD Oxycontin cod pharmacy buy Oxycontin online cod Oxycontin cod overnight delivery Oxycontin no rx overnight buy Oxycontin overnight COD online pharmacy Oxycontin cod order Oxycontin insurance Oxycontin cash delivery cod buy Oxycontin cheap cod no rx online pharmacy Oxycontin sale nextday Oxycontin Oxycontin pill Oxycontin online ordering Oxycontin online without prescription Oxycontin no script needed cod overnight how to buy Oxycontin online without a prescription cheap Oxycontin without prescription cheap Oxycontin online no rx saturday delivery order Oxycontin over the counter for sale Oxycontin next day delivery cod order Oxycontin online without prescription no prescription next day delivery Oxycontin overnight Oxycontin C.O.D Oxycontin without prescription Oxycontin discount fedex no prescription buy Oxycontin amex Oxycontin online next day Oxycontin shipped with no prescription Oxycontin online cheap cheap Oxycontin without prescription overnight delivery buy Oxycontin over the counter for sale Oxycontin no prescriptions needed cod Oxycontin fed ex cheap overnight delivery of Oxycontin free prescription Oxycontin free shipping not expensive legal Oxycontin for sale buy Oxycontin cod Oxycontin for saturday Oxycontin price cash for Oxycontin cash on delivery Oxycontin Oxycontin without a prescription and cod delivery buying Oxycontin without a prescription order Oxycontin no rx buy Oxycontin without rx Oxycontin cheapest buy Oxycontin online pharmacy buy cheap Oxycontin overnight delivery Oxycontin and online pharmacy Oxycontin next day Oxycontin drug no prescription where can i buy Oxycontin no prescription Oxycontin with saturday delivery Oxycontin online overnight Oxycontin no prescription worldwide buy cheap Oxycontin cod ordering Oxycontin online Buy Oxycontin overnight shipping Oxycontin overnight US delivery cheap real Oxycontin for sale Oxycontin no prescriptions needed COD buy Oxycontin no prescription needed Oxycontin no prescription overnight cod delivery cheap Oxycontin cash on delivery no prescription required for Oxycontin order Oxycontin c.o.d. not expensive Oxycontin prescriptions Oxycontin online Cash on Delivery buy Oxycontin overnight delivery Oxycontin online without presciption buy Oxycontin prescription online no prescription saturday delivery Oxycontin where to buy cheap Oxycontin no prescription Oxycontin wo get Oxycontin over the counter fedex Oxycontin with no rx and free shipping order Oxycontin over the counter cod overnight Oxycontin Fedex Without Prescription Oxycontin Online With Next Day Shipping Buy Cheap Oxycontin online | purchase Oxycontin without prescription online | Oxycontin Online Prescriptions With No Membership Oxycontin Cheap next day | Buy Cheap Oxycontin fedex overnight | original Oxycontin pill | Purchase Oxycontin pharmacy r x online | Oxycontin cod Orders | Buy Oxycontin online pharmacy | Oxycontin cod ne xt day delivery | order Oxycontin online no membership overnight shipping | B uy Cheap Oxycontin Online No Prescription Order Oxycontin cod next day delivery | Oxycontin Discount cards | Buy genuine Oxycontin online | buying Oxycontin without a prescription | Where To Buy Oxycontin No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Oxycontin fedex without prescription | U ltram consumer information | pills Cheap generic Oxycontin | Buy Oxycontin onlin e no prescription | Oxycontin Buy | Buy Cheap Oxycontin Online No Prescription B uy Oxycontin online | purchase Oxycontin without prescription | Buying Oxycontin On line Without Prescription Oxycontin Overnight COD no prescription | Cheap onli ne Buy Oxycontin | Low Price Oxycontin Saturday Delivery No Prescription Oxycontin w ithout a prescription no generics | Buy Oxycontin Without Prescription Oxycontin overnight | Buy With No Prescription Oxycontin Online Order Oxycontin no rx overn ight delivery | Order Oxycontin Saturday Delivery No Prescription Oxycontin onlin e no prescription | Oxycontin Discount cards | Buy Oxycontin no script | Oxycontin by phone no script | Buy Oxycontin Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Oxycontin online without a prescription and no me mbership | Buy Without Prescription Oxycontin Online buy no prescription Ultra m | Order Oxycontin Cheap no membership fees no prescription | Oxycontin order n o script | Oxycontin lowest cost | online Buy Oxycontin | Overnight Oxycontin With out A Prescription Oxycontin Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Oxycontin Without A Prescription no script Oxycontin | Oxycontin Buy phone | Oxycontin paid with mastercard | Oxycontin With No Prescript ion Oxycontin to purchase | Order Oxycontin online with no prescription | Oxycontin Buying online Oxycontin drugs | Oxycontin free Overnight fedex delivery | Ultra m best online pharmacy | purchase Oxycontin without a prescription overnight d elivery | Buy Oxycontin online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Oxycontin From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Oxycontin next day | Where To Buy Oxycontin No Prescription No Fees Oxycontin ups cod | Order Oxycontin cash on delive ry | Oxycontin overnight shipping no prescription | purchase Oxycontin without p rescription online | Buy Oxycontin online without dr approval | Buy Oxycontin on line without dr approval | Oxycontin ups | Oxycontin Buy | Buy Oxycontin in Idaho | Oxycontin cheapest | Buy Oxycontin pay with mastercard | ordering Buy Oxycontin online | Oxycontin Overnight COD no prescription | Oxycontin order cod | Oxycontin No Prescription Oxycontin overnight delivery Cheap | Oxycontin order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Oxycontin usa online pharmacy | U ltram free consultation | how to Order Oxycontin without doctors | Purchase U ltram online | comprar Oxycontin | No Prescription Required For Oxycontin Oxycontin cod ordering | Cheap Oxycontin without prescription | Buy Cheap Oxycontin fast | Oxycontin Buy | Buy Oxycontin online without a prescription and no membership | Cheap Oxycontin without prescription overnight delivery | cash on delivery online prescriptions Oxycontin | Oxycontin with no prescription | ordering Ultra m online without a prescription | Oxycontin Cheap order | Oxycontin online no pr escription | No Prescription Needed Oxycontin Low Price Oxycontin With No Prescri ption Buy Oxycontin Online Without Prescription buy no prescription Oxycontin | B uy Oxycontin online discount | Oxycontin order cod | Order Cheap Oxycontin very Buy without prescription | Oxycontin cod next day delivery | Order Oxycontin Online Without Prescription Oxycontin free Overnight fedex delivery | Cheap Oxycontin b y money Order | Buy Oxycontin online discount | overnight Oxycontin | 8 Buy Ult ram online | Cheap Oxycontin c.o.d. | Buy Oxycontin Tablets Without Prescription Overnight Oxycontin for sale | Buy Oxycontin online sales | natural Oxycontin | U ltram manufacturer | Oxycontin Online No Prescription Oxycontin adiction | geniu ne Oxycontin no prescription | Oxycontin Pharmacy Cod Saturday Delivery With No P rescription Oxycontin Buy phone | Buy Oxycontin online prescription | Order Ultr am without prescription from us pharmacy | Buy real Oxycontin with mastercard | Oxycontin without a rx | doctor online prescription Oxycontin | Oxycontin Free O vernight Fedex Delivery order Oxycontin online cash on delivery | Cheap Oxycontin next day | Buy Oxycontin Cheap online us pharmacy | Oxycontin delivery to uk fe dex Overnight | Find Cheap Oxycontin no prescription | online pharmacy Oxycontin | Buy Oxycontin Online Without A Prescription And No Membership Oxycontin to pur chase | Oxycontin Same Day Delivery No Prescription Oxycontin by phone no script | Buy Oxycontin without | discount Oxycontin overnight | Buy Cheap Oxycontin, Buy Cheap Oxycontin online | Oxycontin Buy fedex | Oxycontin shipped with no prescripti on | Buy Oxycontin online money order | purchase Oxycontin without a prescriptio n | Oxycontin ups cod | Buy Oxycontin Online No Prescription Buy Oxycontin online | Oxycontin with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Oxycontin cod | how to get Oxycontin prescription | Low Price Oxycontin With No Prescription Buy the Cheapest Oxycontin online index | prescription U ltram | Order Oxycontin No Prescription Order Oxycontin medicine online without p rescription | Low Price Oxycontin Saturday Delivery No Prescription Cheap Ultr am overnight | Oxycontin Online No Prescription Oxycontin online cash on delivery | Fedex Oxycontin Without Prescription Buy Oxycontin online usa | Oxycontin for sa le without a prescription | to Buy Oxycontin without a prescription | Oxycontin Overnight no script mastercard accepted | Buy Cheap Oxycontin No Prescription Cheap Oxycontin free consultant | Buy Oxycontin Cheap online us pharmacy | Buy C heap Oxycontin No Prescription Oxycontin lowest cost | Where To Buy Oxycontin No Pre scription No Fees Cheapest Oxycontin Online Without Prescription cheapest Ultra m | Oxycontin amphetimine | Buy Oxycontin 120 tabs | Buy Oxycontin Without A Presc ription Or Membership Oxycontin Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Oxycontin | Oxycontin conversion | overnight Oxycontin ups cod | Buy Oxycontin online Cheap | Oxycontin No Script Required Express Delivery With No P rescription Oxycontin free consultation u.s. pharmacy | Oxycontin cod no script | Oxycontin ups cod | Oxycontin online no prescription | purchase Oxycontin with co d | Canadian Oxycontin Pills No Prescription Buy Oxycontin in North Carolina | buy Oxycontin in Denmark, buy Oxycontin in Egypt, buy Oxycontin in Israel, buy Oxycontin in Ireland, buy Oxycontin in Spain, buy Oxycontin in Italy, buy Oxycontin in Canada, buy Oxycontin in Cyprus, buy Oxycontin in Mexico, buy Oxycontin in Netherlands, buy Oxycontin in New zealand, buy Oxycontin in Kingston, buy Oxycontin in Australia, buy Oxycontin in AU, buy Oxycontin in New South Wales, buy Oxycontin in NSW, buy Oxycontin i n Sydney, buy Oxycontin in Brisbane, buy Oxycontin in South Australia, buy Oxycontin in Hobart, buy Oxycontin in the United states, buy Oxycontin in Finland, buy Ultra m in France, buy Oxycontin in Chekhiya, buy Oxycontin in Switzerland, buy Oxycontin i n Sweden, buy Oxycontin in Alberta, buy Oxycontin in Labrador, buy Oxycontin in Toron to, buy Oxycontin in Ottawa, buy Oxycontin in Mississauga, buy Oxycontin in Hamilton, buy Oxycontin in Brampton, buy Oxycontin in London, buy Oxycontin in Markham, buy Ul tram in Vaughan, buy Oxycontin in Windsor, buy Oxycontin in Kitchener, buy Oxycontin in Montreal, buy Oxycontin in Mauricie, buy Oxycontin in Vancouver, buy Oxycontin in Victoria, buy Oxycontin in Kelowna, buy Oxycontin in Abbotsford, buy Oxycontin in Kam loops, buy Oxycontin in Nanaimo, buy Oxycontin in Vernon, buy Oxycontin in Lethbridge , buy Oxycontin in United Kingdom, buy Oxycontin in England, buy Oxycontin in Wales, buy Oxycontin in Scotland, buy Oxycontin in Northern Ireland, buy Oxycontin in Belfas t, buy Oxycontin in Cardiff, buy Oxycontin in London, buy Oxycontin in Glasgow, buy U ltram in Liverpool, buy Oxycontin in Leeds, buy Oxycontin in Victoria, buy Oxycontin in Melbourne, buy Oxycontin in Western Australia, buy Oxycontin in Perth, buy Ultr am in Alabama, buy Oxycontin in Arizona, buy Oxycontin in Arkansas, buy Oxycontin in California, buy Oxycontin in Colorado, buy Oxycontin in Connecticut, buy Oxycontin in Delaware, buy Oxycontin in Florida, buy Oxycontin in Georgia, buy Oxycontin in Hawai i, buy Oxycontin in Idaho, buy Oxycontin in Illinois, buy Oxycontin in Indiana, buy U ltram in Iowa, buy Oxycontin in Kansas, buy Oxycontin in Kentucky, buy Oxycontin in L ouisiana, buy Oxycontin in Maine, buy Oxycontin in Montana, buy Oxycontin in Nebraska , buy Oxycontin in Nevada, buy Oxycontin in New Jersey, buy Oxycontin in New Mexico, buy Oxycontin in New York, buy Oxycontin in North Carolina, buy Oxycontin in North Da kota, buy Oxycontin in Ohio, buy Oxycontin in Oklahoma, buy Oxycontin in Texas, buy U ltram in Utah, buy Oxycontin in Vermont, buy Oxycontin in Virginia, buy Oxycontin in Washington, buy Oxycontin in West Virginia, buy Oxycontin in Wisconsin, buy Oxycontin in Wyoming, buy Oxycontin in Montgomery, buy Oxycontin in Juneau, buy Oxycontin in P hoenix, buy Oxycontin in Little Rock, buy Oxycontin in Sacramento, buy Oxycontin in D enver, buy Oxycontin in Hartford, buy Oxycontin in Dover, buy Oxycontin in Tallahasse e, buy Oxycontin in Atlanta, buy Oxycontin in Springfield, buy Oxycontin in Indianapo lis, buy Oxycontin in Des Moines, buy Oxycontin in Annapolis, buy Oxycontin in Boston , buy Oxycontin in Lansing, buy Oxycontin in Helena, buy Oxycontin in Lincoln, buy Ul tram in Santa Fe, buy Oxycontin in Albany, buy Oxycontin in Raleigh, buy Oxycontin in Bismarck, buy Oxycontin in Columbus, buy Oxycontin in Salem, buy Oxycontin in Columb ia, buy Oxycontin in Salt Lake City, buy Oxycontin in Montpelier, buy Oxycontin in Ch arleston, buy Oxycontin in Madison, buy Oxycontin in Cheyenne, buy Oxycontin in Austr alia, buy Oxycontin in Austria, buy Oxycontin in Argentina, buy Oxycontin in Belgium, buy Oxycontin in Bulgaria, buy Oxycontin in Brasilia, buy Oxycontin in Great britain , buy Oxycontin in Hungary, buy Oxycontin in Germany, buy Oxycontin in Greece, buy Ul tram in South Africa, buy Oxycontin in Japan From numansenm at gmail.com Thu Nov 10 13:30:07 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:30:07 -0800 (PST) Subject: Oxycodone without a prescription online with overnight delivery | buy Oxycodone no visa online without prescription Message-ID: ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Oxycodone/Oxycodone pills with every Order ______________________________________________________________________ BUY Oxycodone ONLINE http://buypharmasite.com/?q=Oxycodone CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Oxycodone ONLINE http://buypharmasite.com/?q=Oxycodone CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Oxycodone Oxycodone online saturday delivery online Oxycodone and fedex cheap order prescription Oxycodone cheap Oxycodone by money order buy Oxycodone from mexico online Oxycodone no prescription usa fedex shipping overnight delivery Oxycodone buy Oxycodone online without a prescription and no membership no prescription needed Oxycodone cod shipped Oxycodone not expensive order prescription Oxycodone Oxycodone money order Oxycodone without a perscription online buy Oxycodone Oxycodone fedex buy no online prescription Oxycodone Oxycodone pharmacies accepting cod delivery Oxycodone online consultant online pharmacy fedex cod Oxycodone buy Oxycodone no scams Oxycodone c.o.d overnight delivery buy Oxycodone no prescription cod overnight Oxycodone order Oxycodone online doctors buy Oxycodone on line no prescription Oxycodone no prescription usa fedex shipping Oxycodone online uk watson brand Oxycodone medicine online Oxycodone order Oxycodone samples sent buy Oxycodone no prescription order Oxycodone without a prescription Oxycodone no prescription drug cheap online order Oxycodone get Oxycodone over the counter online order Oxycodone next day buy Oxycodone no perscription cod real Oxycodone fed ex Oxycodone no prescription cod does cv/ pharmacy carry Oxycodone no prescription cod Oxycodone cheap Oxycodone without rx Oxycodone online health insurance lead buy Oxycodone online with overnight delivery Oxycodone no rx fed ex buy Oxycodone without a perscription lowest prices for Oxycodone online buy Oxycodone paypal online without prescription cheap non prescription Oxycodone Oxycodone ups Oxycodone for cheap buy Oxycodone no visa online without prescription cheapest Oxycodone cash on delivery Oxycodone order a prepaid mastercard buy online Oxycodone purchase Oxycodone mail order Oxycodone without a prescription online with overnight delivery Oxycodone from canada buy Oxycodone with no rx overnight delivery of Oxycodone with no prescription cash on delivery Oxycodone no rx Oxycodone by cod buy Oxycodone over the counter cod overnight overnight Oxycodone order Oxycodone without prescription from us pharmacy cheap Oxycodone free fedex shipping order Oxycodone over the counter where to buy Oxycodone no prescription no fees only Oxycodone free consult cod delivery Oxycodone Oxycodone no prescription Oxycodone online overnight delivery cod order Oxycodone over the counter fedex Oxycodone saturday delivery buy Oxycodone money order Oxycodone without prescription mexico buy cheap Oxycodone without prescription Oxycodone non prescription for next day delivery Oxycodone ups delivery only buy Oxycodone usa cod Oxycodone with next day delivery no prescriptions needed for Oxycodone cheap Oxycodone overnight prescription Oxycodone cheap Oxycodone overnight delivery Oxycodone non prescription fedex overnight free order Oxycodone no creditcard buy cheap Oxycodone no Prescription buy Oxycodone over the counter fedex Oxycodone no doctor presribe needed cheap watson Oxycodone online cheap discount Oxycodone buy Oxycodone without a prescription online cheapest Oxycodone free delivery buy Oxycodone online overseas buy Oxycodone over the counter online not expensive Oxycodone next day shipping order Oxycodone cod next day delivery Oxycodone cheap Oxycodone buy in UK Oxycodone next day cod fedex Oxycodone to buy cheap order Oxycodone next day Oxycodone Oxycodone overnight no consult cheap watson Oxycodone no prescription needed Oxycodone without prescription medications overnight delivery of Oxycodone with no perscription buy Oxycodone.com Oxycodone cod next day delivery buy cheap discount online Oxycodone buy Oxycodone drug Oxycodone overnight delivery cheap overnight delivery of Oxycodone in US no prescription needed purchase Oxycodone free next day airOxycodone on line cheap Oxycodone without a prescription Oxycodone cheap cod Oxycodone buy no prepaid cheap Oxycodone next day buy Oxycodone cod accepted online pharmacies Oxycodone saturday delivery buy Oxycodone pay pal Oxycodone shipped on saturday Oxycodone pharmacy cod saturday delivery buy online Oxycodone prescriptions free fedex delivery Oxycodone Oxycodone without prescription cash on delivery buy discount Oxycodone Oxycodone overnight cheap best Oxycodone online pill images of Oxycodone Oxycodone U.P.S SHIPPING COD Oxycodone cod pharmacy buy Oxycodone online cod Oxycodone cod overnight delivery Oxycodone no rx overnight buy Oxycodone overnight COD online pharmacy Oxycodone cod order Oxycodone insurance Oxycodone cash delivery cod buy Oxycodone cheap cod no rx online pharmacy Oxycodone sale nextday Oxycodone Oxycodone pill Oxycodone online ordering Oxycodone online without prescription Oxycodone no script needed cod overnight how to buy Oxycodone online without a prescription cheap Oxycodone without prescription cheap Oxycodone online no rx saturday delivery order Oxycodone over the counter for sale Oxycodone next day delivery cod order Oxycodone online without prescription no prescription next day delivery Oxycodone overnight Oxycodone C.O.D Oxycodone without prescription Oxycodone discount fedex no prescription buy Oxycodone amex Oxycodone online next day Oxycodone shipped with no prescription Oxycodone online cheap cheap Oxycodone without prescription overnight delivery buy Oxycodone over the counter for sale Oxycodone no prescriptions needed cod Oxycodone fed ex cheap overnight delivery of Oxycodone free prescription Oxycodone free shipping not expensive legal Oxycodone for sale buy Oxycodone cod Oxycodone for saturday Oxycodone price cash for Oxycodone cash on delivery Oxycodone Oxycodone without a prescription and cod delivery buying Oxycodone without a prescription order Oxycodone no rx buy Oxycodone without rx Oxycodone cheapest buy Oxycodone online pharmacy buy cheap Oxycodone overnight delivery Oxycodone and online pharmacy Oxycodone next day Oxycodone drug no prescription where can i buy Oxycodone no prescription Oxycodone with saturday delivery Oxycodone online overnight Oxycodone no prescription worldwide buy cheap Oxycodone cod ordering Oxycodone online Buy Oxycodone overnight shipping Oxycodone overnight US delivery cheap real Oxycodone for sale Oxycodone no prescriptions needed COD buy Oxycodone no prescription needed Oxycodone no prescription overnight cod delivery cheap Oxycodone cash on delivery no prescription required for Oxycodone order Oxycodone c.o.d. not expensive Oxycodone prescriptions Oxycodone online Cash on Delivery buy Oxycodone overnight delivery Oxycodone online without presciption buy Oxycodone prescription online no prescription saturday delivery Oxycodone where to buy cheap Oxycodone no prescription Oxycodone wo get Oxycodone over the counter fedex Oxycodone with no rx and free shipping order Oxycodone over the counter cod overnight Oxycodone Fedex Without Prescription Oxycodone Online With Next Day Shipping Buy Cheap Oxycodone online | purchase Oxycodone without prescription online | Oxycodone Online Prescriptions With No Membership Oxycodone Cheap next day | Buy Cheap Oxycodone fedex overnight | original Oxycodone pill | Purchase Oxycodone pharmacy r x online | Oxycodone cod Orders | Buy Oxycodone online pharmacy | Oxycodone cod ne xt day delivery | order Oxycodone online no membership overnight shipping | B uy Cheap Oxycodone Online No Prescription Order Oxycodone cod next day delivery | Oxycodone Discount cards | Buy genuine Oxycodone online | buying Oxycodone without a prescription | Where To Buy Oxycodone No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Oxycodone fedex without prescription | U ltram consumer information | pills Cheap generic Oxycodone | Buy Oxycodone onlin e no prescription | Oxycodone Buy | Buy Cheap Oxycodone Online No Prescription B uy Oxycodone online | purchase Oxycodone without prescription | Buying Oxycodone On line Without Prescription Oxycodone Overnight COD no prescription | Cheap onli ne Buy Oxycodone | Low Price Oxycodone Saturday Delivery No Prescription Oxycodone w ithout a prescription no generics | Buy Oxycodone Without Prescription Oxycodone overnight | Buy With No Prescription Oxycodone Online Order Oxycodone no rx overn ight delivery | Order Oxycodone Saturday Delivery No Prescription Oxycodone onlin e no prescription | Oxycodone Discount cards | Buy Oxycodone no script | Oxycodone by phone no script | Buy Oxycodone Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Oxycodone online without a prescription and no me mbership | Buy Without Prescription Oxycodone Online buy no prescription Ultra m | Order Oxycodone Cheap no membership fees no prescription | Oxycodone order n o script | Oxycodone lowest cost | online Buy Oxycodone | Overnight Oxycodone With out A Prescription Oxycodone Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Oxycodone Without A Prescription no script Oxycodone | Oxycodone Buy phone | Oxycodone paid with mastercard | Oxycodone With No Prescript ion Oxycodone to purchase | Order Oxycodone online with no prescription | Oxycodone Buying online Oxycodone drugs | Oxycodone free Overnight fedex delivery | Ultra m best online pharmacy | purchase Oxycodone without a prescription overnight d elivery | Buy Oxycodone online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Oxycodone From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Oxycodone next day | Where To Buy Oxycodone No Prescription No Fees Oxycodone ups cod | Order Oxycodone cash on delive ry | Oxycodone overnight shipping no prescription | purchase Oxycodone without p rescription online | Buy Oxycodone online without dr approval | Buy Oxycodone on line without dr approval | Oxycodone ups | Oxycodone Buy | Buy Oxycodone in Idaho | Oxycodone cheapest | Buy Oxycodone pay with mastercard | ordering Buy Oxycodone online | Oxycodone Overnight COD no prescription | Oxycodone order cod | Oxycodone No Prescription Oxycodone overnight delivery Cheap | Oxycodone order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Oxycodone usa online pharmacy | U ltram free consultation | how to Order Oxycodone without doctors | Purchase U ltram online | comprar Oxycodone | No Prescription Required For Oxycodone Oxycodone cod ordering | Cheap Oxycodone without prescription | Buy Cheap Oxycodone fast | Oxycodone Buy | Buy Oxycodone online without a prescription and no membership | Cheap Oxycodone without prescription overnight delivery | cash on delivery online prescriptions Oxycodone | Oxycodone with no prescription | ordering Ultra m online without a prescription | Oxycodone Cheap order | Oxycodone online no pr escription | No Prescription Needed Oxycodone Low Price Oxycodone With No Prescri ption Buy Oxycodone Online Without Prescription buy no prescription Oxycodone | B uy Oxycodone online discount | Oxycodone order cod | Order Cheap Oxycodone very Buy without prescription | Oxycodone cod next day delivery | Order Oxycodone Online Without Prescription Oxycodone free Overnight fedex delivery | Cheap Oxycodone b y money Order | Buy Oxycodone online discount | overnight Oxycodone | 8 Buy Ult ram online | Cheap Oxycodone c.o.d. | Buy Oxycodone Tablets Without Prescription Overnight Oxycodone for sale | Buy Oxycodone online sales | natural Oxycodone | U ltram manufacturer | Oxycodone Online No Prescription Oxycodone adiction | geniu ne Oxycodone no prescription | Oxycodone Pharmacy Cod Saturday Delivery With No P rescription Oxycodone Buy phone | Buy Oxycodone online prescription | Order Ultr am without prescription from us pharmacy | Buy real Oxycodone with mastercard | Oxycodone without a rx | doctor online prescription Oxycodone | Oxycodone Free O vernight Fedex Delivery order Oxycodone online cash on delivery | Cheap Oxycodone next day | Buy Oxycodone Cheap online us pharmacy | Oxycodone delivery to uk fe dex Overnight | Find Cheap Oxycodone no prescription | online pharmacy Oxycodone | Buy Oxycodone Online Without A Prescription And No Membership Oxycodone to pur chase | Oxycodone Same Day Delivery No Prescription Oxycodone by phone no script | Buy Oxycodone without | discount Oxycodone overnight | Buy Cheap Oxycodone, Buy Cheap Oxycodone online | Oxycodone Buy fedex | Oxycodone shipped with no prescripti on | Buy Oxycodone online money order | purchase Oxycodone without a prescriptio n | Oxycodone ups cod | Buy Oxycodone Online No Prescription Buy Oxycodone online | Oxycodone with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Oxycodone cod | how to get Oxycodone prescription | Low Price Oxycodone With No Prescription Buy the Cheapest Oxycodone online index | prescription U ltram | Order Oxycodone No Prescription Order Oxycodone medicine online without p rescription | Low Price Oxycodone Saturday Delivery No Prescription Cheap Ultr am overnight | Oxycodone Online No Prescription Oxycodone online cash on delivery | Fedex Oxycodone Without Prescription Buy Oxycodone online usa | Oxycodone for sa le without a prescription | to Buy Oxycodone without a prescription | Oxycodone Overnight no script mastercard accepted | Buy Cheap Oxycodone No Prescription Cheap Oxycodone free consultant | Buy Oxycodone Cheap online us pharmacy | Buy C heap Oxycodone No Prescription Oxycodone lowest cost | Where To Buy Oxycodone No Pre scription No Fees Cheapest Oxycodone Online Without Prescription cheapest Ultra m | Oxycodone amphetimine | Buy Oxycodone 120 tabs | Buy Oxycodone Without A Presc ription Or Membership Oxycodone Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Oxycodone | Oxycodone conversion | overnight Oxycodone ups cod | Buy Oxycodone online Cheap | Oxycodone No Script Required Express Delivery With No P rescription Oxycodone free consultation u.s. pharmacy | Oxycodone cod no script | Oxycodone ups cod | Oxycodone online no prescription | purchase Oxycodone with co d | Canadian Oxycodone Pills No Prescription Buy Oxycodone in North Carolina | buy Oxycodone in Denmark, buy Oxycodone in Egypt, buy Oxycodone in Israel, buy Oxycodone in Ireland, buy Oxycodone in Spain, buy Oxycodone in Italy, buy Oxycodone in Canada, buy Oxycodone in Cyprus, buy Oxycodone in Mexico, buy Oxycodone in Netherlands, buy Oxycodone in New zealand, buy Oxycodone in Kingston, buy Oxycodone in Australia, buy Oxycodone in AU, buy Oxycodone in New South Wales, buy Oxycodone in NSW, buy Oxycodone i n Sydney, buy Oxycodone in Brisbane, buy Oxycodone in South Australia, buy Oxycodone in Hobart, buy Oxycodone in the United states, buy Oxycodone in Finland, buy Ultra m in France, buy Oxycodone in Chekhiya, buy Oxycodone in Switzerland, buy Oxycodone i n Sweden, buy Oxycodone in Alberta, buy Oxycodone in Labrador, buy Oxycodone in Toron to, buy Oxycodone in Ottawa, buy Oxycodone in Mississauga, buy Oxycodone in Hamilton, buy Oxycodone in Brampton, buy Oxycodone in London, buy Oxycodone in Markham, buy Ul tram in Vaughan, buy Oxycodone in Windsor, buy Oxycodone in Kitchener, buy Oxycodone in Montreal, buy Oxycodone in Mauricie, buy Oxycodone in Vancouver, buy Oxycodone in Victoria, buy Oxycodone in Kelowna, buy Oxycodone in Abbotsford, buy Oxycodone in Kam loops, buy Oxycodone in Nanaimo, buy Oxycodone in Vernon, buy Oxycodone in Lethbridge , buy Oxycodone in United Kingdom, buy Oxycodone in England, buy Oxycodone in Wales, buy Oxycodone in Scotland, buy Oxycodone in Northern Ireland, buy Oxycodone in Belfas t, buy Oxycodone in Cardiff, buy Oxycodone in London, buy Oxycodone in Glasgow, buy U ltram in Liverpool, buy Oxycodone in Leeds, buy Oxycodone in Victoria, buy Oxycodone in Melbourne, buy Oxycodone in Western Australia, buy Oxycodone in Perth, buy Ultr am in Alabama, buy Oxycodone in Arizona, buy Oxycodone in Arkansas, buy Oxycodone in California, buy Oxycodone in Colorado, buy Oxycodone in Connecticut, buy Oxycodone in Delaware, buy Oxycodone in Florida, buy Oxycodone in Georgia, buy Oxycodone in Hawai i, buy Oxycodone in Idaho, buy Oxycodone in Illinois, buy Oxycodone in Indiana, buy U ltram in Iowa, buy Oxycodone in Kansas, buy Oxycodone in Kentucky, buy Oxycodone in L ouisiana, buy Oxycodone in Maine, buy Oxycodone in Montana, buy Oxycodone in Nebraska , buy Oxycodone in Nevada, buy Oxycodone in New Jersey, buy Oxycodone in New Mexico, buy Oxycodone in New York, buy Oxycodone in North Carolina, buy Oxycodone in North Da kota, buy Oxycodone in Ohio, buy Oxycodone in Oklahoma, buy Oxycodone in Texas, buy U ltram in Utah, buy Oxycodone in Vermont, buy Oxycodone in Virginia, buy Oxycodone in Washington, buy Oxycodone in West Virginia, buy Oxycodone in Wisconsin, buy Oxycodone in Wyoming, buy Oxycodone in Montgomery, buy Oxycodone in Juneau, buy Oxycodone in P hoenix, buy Oxycodone in Little Rock, buy Oxycodone in Sacramento, buy Oxycodone in D enver, buy Oxycodone in Hartford, buy Oxycodone in Dover, buy Oxycodone in Tallahasse e, buy Oxycodone in Atlanta, buy Oxycodone in Springfield, buy Oxycodone in Indianapo lis, buy Oxycodone in Des Moines, buy Oxycodone in Annapolis, buy Oxycodone in Boston , buy Oxycodone in Lansing, buy Oxycodone in Helena, buy Oxycodone in Lincoln, buy Ul tram in Santa Fe, buy Oxycodone in Albany, buy Oxycodone in Raleigh, buy Oxycodone in Bismarck, buy Oxycodone in Columbus, buy Oxycodone in Salem, buy Oxycodone in Columb ia, buy Oxycodone in Salt Lake City, buy Oxycodone in Montpelier, buy Oxycodone in Ch arleston, buy Oxycodone in Madison, buy Oxycodone in Cheyenne, buy Oxycodone in Austr alia, buy Oxycodone in Austria, buy Oxycodone in Argentina, buy Oxycodone in Belgium, buy Oxycodone in Bulgaria, buy Oxycodone in Brasilia, buy Oxycodone in Great britain , buy Oxycodone in Hungary, buy Oxycodone in Germany, buy Oxycodone in Greece, buy Ul tram in South Africa, buy Oxycodone in Japan From numansenm at gmail.com Thu Nov 10 13:32:23 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:32:23 -0800 (PST) Subject: Ritalin without prescription medications | Ritalin no prescription usa fedex shipping | buy no online prescription Ritalin Message-ID: <1ed9a1b0-48a8-4d01-997a-3a7bf87cf96e@d5g2000yqg.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Ritalin/Ritalin pills with every Order ______________________________________________________________________ BUY Ritalin ONLINE http://buypharmasite.com/?q=Ritalin CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Ritalin ONLINE http://buypharmasite.com/?q=Ritalin CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Ritalin Ritalin online saturday delivery online Ritalin and fedex cheap order prescription Ritalin cheap Ritalin by money order buy Ritalin from mexico online Ritalin no prescription usa fedex shipping overnight delivery Ritalin buy Ritalin online without a prescription and no membership no prescription needed Ritalin cod shipped Ritalin not expensive order prescription Ritalin Ritalin money order Ritalin without a perscription online buy Ritalin Ritalin fedex buy no online prescription Ritalin Ritalin pharmacies accepting cod delivery Ritalin online consultant online pharmacy fedex cod Ritalin buy Ritalin no scams Ritalin c.o.d overnight delivery buy Ritalin no prescription cod overnight Ritalin order Ritalin online doctors buy Ritalin on line no prescription Ritalin no prescription usa fedex shipping Ritalin online uk watson brand Ritalin medicine online Ritalin order Ritalin samples sent buy Ritalin no prescription order Ritalin without a prescription Ritalin no prescription drug cheap online order Ritalin get Ritalin over the counter online order Ritalin next day buy Ritalin no perscription cod real Ritalin fed ex Ritalin no prescription cod does cv/ pharmacy carry Ritalin no prescription cod Ritalin cheap Ritalin without rx Ritalin online health insurance lead buy Ritalin online with overnight delivery Ritalin no rx fed ex buy Ritalin without a perscription lowest prices for Ritalin online buy Ritalin paypal online without prescription cheap non prescription Ritalin Ritalin ups Ritalin for cheap buy Ritalin no visa online without prescription cheapest Ritalin cash on delivery Ritalin order a prepaid mastercard buy online Ritalin purchase Ritalin mail order Ritalin without a prescription online with overnight delivery Ritalin from canada buy Ritalin with no rx overnight delivery of Ritalin with no prescription cash on delivery Ritalin no rx Ritalin by cod buy Ritalin over the counter cod overnight overnight Ritalin order Ritalin without prescription from us pharmacy cheap Ritalin free fedex shipping order Ritalin over the counter where to buy Ritalin no prescription no fees only Ritalin free consult cod delivery Ritalin Ritalin no prescription Ritalin online overnight delivery cod order Ritalin over the counter fedex Ritalin saturday delivery buy Ritalin money order Ritalin without prescription mexico buy cheap Ritalin without prescription Ritalin non prescription for next day delivery Ritalin ups delivery only buy Ritalin usa cod Ritalin with next day delivery no prescriptions needed for Ritalin cheap Ritalin overnight prescription Ritalin cheap Ritalin overnight delivery Ritalin non prescription fedex overnight free order Ritalin no creditcard buy cheap Ritalin no Prescription buy Ritalin over the counter fedex Ritalin no doctor presribe needed cheap watson Ritalin online cheap discount Ritalin buy Ritalin without a prescription online cheapest Ritalin free delivery buy Ritalin online overseas buy Ritalin over the counter online not expensive Ritalin next day shipping order Ritalin cod next day delivery Ritalin cheap Ritalin buy in UK Ritalin next day cod fedex Ritalin to buy cheap order Ritalin next day Ritalin Ritalin overnight no consult cheap watson Ritalin no prescription needed Ritalin without prescription medications overnight delivery of Ritalin with no perscription buy Ritalin.com Ritalin cod next day delivery buy cheap discount online Ritalin buy Ritalin drug Ritalin overnight delivery cheap overnight delivery of Ritalin in US no prescription needed purchase Ritalin free next day airRitalin on line cheap Ritalin without a prescription Ritalin cheap cod Ritalin buy no prepaid cheap Ritalin next day buy Ritalin cod accepted online pharmacies Ritalin saturday delivery buy Ritalin pay pal Ritalin shipped on saturday Ritalin pharmacy cod saturday delivery buy online Ritalin prescriptions free fedex delivery Ritalin Ritalin without prescription cash on delivery buy discount Ritalin Ritalin overnight cheap best Ritalin online pill images of Ritalin Ritalin U.P.S SHIPPING COD Ritalin cod pharmacy buy Ritalin online cod Ritalin cod overnight delivery Ritalin no rx overnight buy Ritalin overnight COD online pharmacy Ritalin cod order Ritalin insurance Ritalin cash delivery cod buy Ritalin cheap cod no rx online pharmacy Ritalin sale nextday Ritalin Ritalin pill Ritalin online ordering Ritalin online without prescription Ritalin no script needed cod overnight how to buy Ritalin online without a prescription cheap Ritalin without prescription cheap Ritalin online no rx saturday delivery order Ritalin over the counter for sale Ritalin next day delivery cod order Ritalin online without prescription no prescription next day delivery Ritalin overnight Ritalin C.O.D Ritalin without prescription Ritalin discount fedex no prescription buy Ritalin amex Ritalin online next day Ritalin shipped with no prescription Ritalin online cheap cheap Ritalin without prescription overnight delivery buy Ritalin over the counter for sale Ritalin no prescriptions needed cod Ritalin fed ex cheap overnight delivery of Ritalin free prescription Ritalin free shipping not expensive legal Ritalin for sale buy Ritalin cod Ritalin for saturday Ritalin price cash for Ritalin cash on delivery Ritalin Ritalin without a prescription and cod delivery buying Ritalin without a prescription order Ritalin no rx buy Ritalin without rx Ritalin cheapest buy Ritalin online pharmacy buy cheap Ritalin overnight delivery Ritalin and online pharmacy Ritalin next day Ritalin drug no prescription where can i buy Ritalin no prescription Ritalin with saturday delivery Ritalin online overnight Ritalin no prescription worldwide buy cheap Ritalin cod ordering Ritalin online Buy Ritalin overnight shipping Ritalin overnight US delivery cheap real Ritalin for sale Ritalin no prescriptions needed COD buy Ritalin no prescription needed Ritalin no prescription overnight cod delivery cheap Ritalin cash on delivery no prescription required for Ritalin order Ritalin c.o.d. not expensive Ritalin prescriptions Ritalin online Cash on Delivery buy Ritalin overnight delivery Ritalin online without presciption buy Ritalin prescription online no prescription saturday delivery Ritalin where to buy cheap Ritalin no prescription Ritalin wo get Ritalin over the counter fedex Ritalin with no rx and free shipping order Ritalin over the counter cod overnight Ritalin Fedex Without Prescription Ritalin Online With Next Day Shipping Buy Cheap Ritalin online | purchase Ritalin without prescription online | Ritalin Online Prescriptions With No Membership Ritalin Cheap next day | Buy Cheap Ritalin fedex overnight | original Ritalin pill | Purchase Ritalin pharmacy r x online | Ritalin cod Orders | Buy Ritalin online pharmacy | Ritalin cod ne xt day delivery | order Ritalin online no membership overnight shipping | B uy Cheap Ritalin Online No Prescription Order Ritalin cod next day delivery | Ritalin Discount cards | Buy genuine Ritalin online | buying Ritalin without a prescription | Where To Buy Ritalin No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Ritalin fedex without prescription | U ltram consumer information | pills Cheap generic Ritalin | Buy Ritalin onlin e no prescription | Ritalin Buy | Buy Cheap Ritalin Online No Prescription B uy Ritalin online | purchase Ritalin without prescription | Buying Ritalin On line Without Prescription Ritalin Overnight COD no prescription | Cheap onli ne Buy Ritalin | Low Price Ritalin Saturday Delivery No Prescription Ritalin w ithout a prescription no generics | Buy Ritalin Without Prescription Ritalin overnight | Buy With No Prescription Ritalin Online Order Ritalin no rx overn ight delivery | Order Ritalin Saturday Delivery No Prescription Ritalin onlin e no prescription | Ritalin Discount cards | Buy Ritalin no script | Ritalin by phone no script | Buy Ritalin Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Ritalin online without a prescription and no me mbership | Buy Without Prescription Ritalin Online buy no prescription Ultra m | Order Ritalin Cheap no membership fees no prescription | Ritalin order n o script | Ritalin lowest cost | online Buy Ritalin | Overnight Ritalin With out A Prescription Ritalin Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Ritalin Without A Prescription no script Ritalin | Ritalin Buy phone | Ritalin paid with mastercard | Ritalin With No Prescript ion Ritalin to purchase | Order Ritalin online with no prescription | Ritalin Buying online Ritalin drugs | Ritalin free Overnight fedex delivery | Ultra m best online pharmacy | purchase Ritalin without a prescription overnight d elivery | Buy Ritalin online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Ritalin From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Ritalin next day | Where To Buy Ritalin No Prescription No Fees Ritalin ups cod | Order Ritalin cash on delive ry | Ritalin overnight shipping no prescription | purchase Ritalin without p rescription online | Buy Ritalin online without dr approval | Buy Ritalin on line without dr approval | Ritalin ups | Ritalin Buy | Buy Ritalin in Idaho | Ritalin cheapest | Buy Ritalin pay with mastercard | ordering Buy Ritalin online | Ritalin Overnight COD no prescription | Ritalin order cod | Ritalin No Prescription Ritalin overnight delivery Cheap | Ritalin order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Ritalin usa online pharmacy | U ltram free consultation | how to Order Ritalin without doctors | Purchase U ltram online | comprar Ritalin | No Prescription Required For Ritalin Ritalin cod ordering | Cheap Ritalin without prescription | Buy Cheap Ritalin fast | Ritalin Buy | Buy Ritalin online without a prescription and no membership | Cheap Ritalin without prescription overnight delivery | cash on delivery online prescriptions Ritalin | Ritalin with no prescription | ordering Ultra m online without a prescription | Ritalin Cheap order | Ritalin online no pr escription | No Prescription Needed Ritalin Low Price Ritalin With No Prescri ption Buy Ritalin Online Without Prescription buy no prescription Ritalin | B uy Ritalin online discount | Ritalin order cod | Order Cheap Ritalin very Buy without prescription | Ritalin cod next day delivery | Order Ritalin Online Without Prescription Ritalin free Overnight fedex delivery | Cheap Ritalin b y money Order | Buy Ritalin online discount | overnight Ritalin | 8 Buy Ult ram online | Cheap Ritalin c.o.d. | Buy Ritalin Tablets Without Prescription Overnight Ritalin for sale | Buy Ritalin online sales | natural Ritalin | U ltram manufacturer | Ritalin Online No Prescription Ritalin adiction | geniu ne Ritalin no prescription | Ritalin Pharmacy Cod Saturday Delivery With No P rescription Ritalin Buy phone | Buy Ritalin online prescription | Order Ultr am without prescription from us pharmacy | Buy real Ritalin with mastercard | Ritalin without a rx | doctor online prescription Ritalin | Ritalin Free O vernight Fedex Delivery order Ritalin online cash on delivery | Cheap Ritalin next day | Buy Ritalin Cheap online us pharmacy | Ritalin delivery to uk fe dex Overnight | Find Cheap Ritalin no prescription | online pharmacy Ritalin | Buy Ritalin Online Without A Prescription And No Membership Ritalin to pur chase | Ritalin Same Day Delivery No Prescription Ritalin by phone no script | Buy Ritalin without | discount Ritalin overnight | Buy Cheap Ritalin, Buy Cheap Ritalin online | Ritalin Buy fedex | Ritalin shipped with no prescripti on | Buy Ritalin online money order | purchase Ritalin without a prescriptio n | Ritalin ups cod | Buy Ritalin Online No Prescription Buy Ritalin online | Ritalin with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Ritalin cod | how to get Ritalin prescription | Low Price Ritalin With No Prescription Buy the Cheapest Ritalin online index | prescription U ltram | Order Ritalin No Prescription Order Ritalin medicine online without p rescription | Low Price Ritalin Saturday Delivery No Prescription Cheap Ultr am overnight | Ritalin Online No Prescription Ritalin online cash on delivery | Fedex Ritalin Without Prescription Buy Ritalin online usa | Ritalin for sa le without a prescription | to Buy Ritalin without a prescription | Ritalin Overnight no script mastercard accepted | Buy Cheap Ritalin No Prescription Cheap Ritalin free consultant | Buy Ritalin Cheap online us pharmacy | Buy C heap Ritalin No Prescription Ritalin lowest cost | Where To Buy Ritalin No Pre scription No Fees Cheapest Ritalin Online Without Prescription cheapest Ultra m | Ritalin amphetimine | Buy Ritalin 120 tabs | Buy Ritalin Without A Presc ription Or Membership Ritalin Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Ritalin | Ritalin conversion | overnight Ritalin ups cod | Buy Ritalin online Cheap | Ritalin No Script Required Express Delivery With No P rescription Ritalin free consultation u.s. pharmacy | Ritalin cod no script | Ritalin ups cod | Ritalin online no prescription | purchase Ritalin with co d | Canadian Ritalin Pills No Prescription Buy Ritalin in North Carolina | buy Ritalin in Denmark, buy Ritalin in Egypt, buy Ritalin in Israel, buy Ritalin in Ireland, buy Ritalin in Spain, buy Ritalin in Italy, buy Ritalin in Canada, buy Ritalin in Cyprus, buy Ritalin in Mexico, buy Ritalin in Netherlands, buy Ritalin in New zealand, buy Ritalin in Kingston, buy Ritalin in Australia, buy Ritalin in AU, buy Ritalin in New South Wales, buy Ritalin in NSW, buy Ritalin i n Sydney, buy Ritalin in Brisbane, buy Ritalin in South Australia, buy Ritalin in Hobart, buy Ritalin in the United states, buy Ritalin in Finland, buy Ultra m in France, buy Ritalin in Chekhiya, buy Ritalin in Switzerland, buy Ritalin i n Sweden, buy Ritalin in Alberta, buy Ritalin in Labrador, buy Ritalin in Toron to, buy Ritalin in Ottawa, buy Ritalin in Mississauga, buy Ritalin in Hamilton, buy Ritalin in Brampton, buy Ritalin in London, buy Ritalin in Markham, buy Ul tram in Vaughan, buy Ritalin in Windsor, buy Ritalin in Kitchener, buy Ritalin in Montreal, buy Ritalin in Mauricie, buy Ritalin in Vancouver, buy Ritalin in Victoria, buy Ritalin in Kelowna, buy Ritalin in Abbotsford, buy Ritalin in Kam loops, buy Ritalin in Nanaimo, buy Ritalin in Vernon, buy Ritalin in Lethbridge , buy Ritalin in United Kingdom, buy Ritalin in England, buy Ritalin in Wales, buy Ritalin in Scotland, buy Ritalin in Northern Ireland, buy Ritalin in Belfas t, buy Ritalin in Cardiff, buy Ritalin in London, buy Ritalin in Glasgow, buy U ltram in Liverpool, buy Ritalin in Leeds, buy Ritalin in Victoria, buy Ritalin in Melbourne, buy Ritalin in Western Australia, buy Ritalin in Perth, buy Ultr am in Alabama, buy Ritalin in Arizona, buy Ritalin in Arkansas, buy Ritalin in California, buy Ritalin in Colorado, buy Ritalin in Connecticut, buy Ritalin in Delaware, buy Ritalin in Florida, buy Ritalin in Georgia, buy Ritalin in Hawai i, buy Ritalin in Idaho, buy Ritalin in Illinois, buy Ritalin in Indiana, buy U ltram in Iowa, buy Ritalin in Kansas, buy Ritalin in Kentucky, buy Ritalin in L ouisiana, buy Ritalin in Maine, buy Ritalin in Montana, buy Ritalin in Nebraska , buy Ritalin in Nevada, buy Ritalin in New Jersey, buy Ritalin in New Mexico, buy Ritalin in New York, buy Ritalin in North Carolina, buy Ritalin in North Da kota, buy Ritalin in Ohio, buy Ritalin in Oklahoma, buy Ritalin in Texas, buy U ltram in Utah, buy Ritalin in Vermont, buy Ritalin in Virginia, buy Ritalin in Washington, buy Ritalin in West Virginia, buy Ritalin in Wisconsin, buy Ritalin in Wyoming, buy Ritalin in Montgomery, buy Ritalin in Juneau, buy Ritalin in P hoenix, buy Ritalin in Little Rock, buy Ritalin in Sacramento, buy Ritalin in D enver, buy Ritalin in Hartford, buy Ritalin in Dover, buy Ritalin in Tallahasse e, buy Ritalin in Atlanta, buy Ritalin in Springfield, buy Ritalin in Indianapo lis, buy Ritalin in Des Moines, buy Ritalin in Annapolis, buy Ritalin in Boston , buy Ritalin in Lansing, buy Ritalin in Helena, buy Ritalin in Lincoln, buy Ul tram in Santa Fe, buy Ritalin in Albany, buy Ritalin in Raleigh, buy Ritalin in Bismarck, buy Ritalin in Columbus, buy Ritalin in Salem, buy Ritalin in Columb ia, buy Ritalin in Salt Lake City, buy Ritalin in Montpelier, buy Ritalin in Ch arleston, buy Ritalin in Madison, buy Ritalin in Cheyenne, buy Ritalin in Austr alia, buy Ritalin in Austria, buy Ritalin in Argentina, buy Ritalin in Belgium, buy Ritalin in Bulgaria, buy Ritalin in Brasilia, buy Ritalin in Great britain , buy Ritalin in Hungary, buy Ritalin in Germany, buy Ritalin in Greece, buy Ul tram in South Africa, buy Ritalin in Japan From numansenm at gmail.com Thu Nov 10 13:36:34 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:36:34 -0800 (PST) Subject: overnight delivery of Levitra in US no prescription needed | Levitra without prescription medications Message-ID: ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Levitra/Levitra pills with every Order ______________________________________________________________________ BUY Levitra ONLINE http://buypharmasite.com/?q=Levitra CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Levitra ONLINE http://buypharmasite.com/?q=Levitra CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Levitra Levitra online saturday delivery online Levitra and fedex cheap order prescription Levitra cheap Levitra by money order buy Levitra from mexico online Levitra no prescription usa fedex shipping overnight delivery Levitra buy Levitra online without a prescription and no membership no prescription needed Levitra cod shipped Levitra not expensive order prescription Levitra Levitra money order Levitra without a perscription online buy Levitra Levitra fedex buy no online prescription Levitra Levitra pharmacies accepting cod delivery Levitra online consultant online pharmacy fedex cod Levitra buy Levitra no scams Levitra c.o.d overnight delivery buy Levitra no prescription cod overnight Levitra order Levitra online doctors buy Levitra on line no prescription Levitra no prescription usa fedex shipping Levitra online uk watson brand Levitra medicine online Levitra order Levitra samples sent buy Levitra no prescription order Levitra without a prescription Levitra no prescription drug cheap online order Levitra get Levitra over the counter online order Levitra next day buy Levitra no perscription cod real Levitra fed ex Levitra no prescription cod does cv/ pharmacy carry Levitra no prescription cod Levitra cheap Levitra without rx Levitra online health insurance lead buy Levitra online with overnight delivery Levitra no rx fed ex buy Levitra without a perscription lowest prices for Levitra online buy Levitra paypal online without prescription cheap non prescription Levitra Levitra ups Levitra for cheap buy Levitra no visa online without prescription cheapest Levitra cash on delivery Levitra order a prepaid mastercard buy online Levitra purchase Levitra mail order Levitra without a prescription online with overnight delivery Levitra from canada buy Levitra with no rx overnight delivery of Levitra with no prescription cash on delivery Levitra no rx Levitra by cod buy Levitra over the counter cod overnight overnight Levitra order Levitra without prescription from us pharmacy cheap Levitra free fedex shipping order Levitra over the counter where to buy Levitra no prescription no fees only Levitra free consult cod delivery Levitra Levitra no prescription Levitra online overnight delivery cod order Levitra over the counter fedex Levitra saturday delivery buy Levitra money order Levitra without prescription mexico buy cheap Levitra without prescription Levitra non prescription for next day delivery Levitra ups delivery only buy Levitra usa cod Levitra with next day delivery no prescriptions needed for Levitra cheap Levitra overnight prescription Levitra cheap Levitra overnight delivery Levitra non prescription fedex overnight free order Levitra no creditcard buy cheap Levitra no Prescription buy Levitra over the counter fedex Levitra no doctor presribe needed cheap watson Levitra online cheap discount Levitra buy Levitra without a prescription online cheapest Levitra free delivery buy Levitra online overseas buy Levitra over the counter online not expensive Levitra next day shipping order Levitra cod next day delivery Levitra cheap Levitra buy in UK Levitra next day cod fedex Levitra to buy cheap order Levitra next day Levitra Levitra overnight no consult cheap watson Levitra no prescription needed Levitra without prescription medications overnight delivery of Levitra with no perscription buy Levitra.com Levitra cod next day delivery buy cheap discount online Levitra buy Levitra drug Levitra overnight delivery cheap overnight delivery of Levitra in US no prescription needed purchase Levitra free next day airLevitra on line cheap Levitra without a prescription Levitra cheap cod Levitra buy no prepaid cheap Levitra next day buy Levitra cod accepted online pharmacies Levitra saturday delivery buy Levitra pay pal Levitra shipped on saturday Levitra pharmacy cod saturday delivery buy online Levitra prescriptions free fedex delivery Levitra Levitra without prescription cash on delivery buy discount Levitra Levitra overnight cheap best Levitra online pill images of Levitra Levitra U.P.S SHIPPING COD Levitra cod pharmacy buy Levitra online cod Levitra cod overnight delivery Levitra no rx overnight buy Levitra overnight COD online pharmacy Levitra cod order Levitra insurance Levitra cash delivery cod buy Levitra cheap cod no rx online pharmacy Levitra sale nextday Levitra Levitra pill Levitra online ordering Levitra online without prescription Levitra no script needed cod overnight how to buy Levitra online without a prescription cheap Levitra without prescription cheap Levitra online no rx saturday delivery order Levitra over the counter for sale Levitra next day delivery cod order Levitra online without prescription no prescription next day delivery Levitra overnight Levitra C.O.D Levitra without prescription Levitra discount fedex no prescription buy Levitra amex Levitra online next day Levitra shipped with no prescription Levitra online cheap cheap Levitra without prescription overnight delivery buy Levitra over the counter for sale Levitra no prescriptions needed cod Levitra fed ex cheap overnight delivery of Levitra free prescription Levitra free shipping not expensive legal Levitra for sale buy Levitra cod Levitra for saturday Levitra price cash for Levitra cash on delivery Levitra Levitra without a prescription and cod delivery buying Levitra without a prescription order Levitra no rx buy Levitra without rx Levitra cheapest buy Levitra online pharmacy buy cheap Levitra overnight delivery Levitra and online pharmacy Levitra next day Levitra drug no prescription where can i buy Levitra no prescription Levitra with saturday delivery Levitra online overnight Levitra no prescription worldwide buy cheap Levitra cod ordering Levitra online Buy Levitra overnight shipping Levitra overnight US delivery cheap real Levitra for sale Levitra no prescriptions needed COD buy Levitra no prescription needed Levitra no prescription overnight cod delivery cheap Levitra cash on delivery no prescription required for Levitra order Levitra c.o.d. not expensive Levitra prescriptions Levitra online Cash on Delivery buy Levitra overnight delivery Levitra online without presciption buy Levitra prescription online no prescription saturday delivery Levitra where to buy cheap Levitra no prescription Levitra wo get Levitra over the counter fedex Levitra with no rx and free shipping order Levitra over the counter cod overnight Levitra Fedex Without Prescription Levitra Online With Next Day Shipping Buy Cheap Levitra online | purchase Levitra without prescription online | Levitra Online Prescriptions With No Membership Levitra Cheap next day | Buy Cheap Levitra fedex overnight | original Levitra pill | Purchase Levitra pharmacy r x online | Levitra cod Orders | Buy Levitra online pharmacy | Levitra cod ne xt day delivery | order Levitra online no membership overnight shipping | B uy Cheap Levitra Online No Prescription Order Levitra cod next day delivery | Levitra Discount cards | Buy genuine Levitra online | buying Levitra without a prescription | Where To Buy Levitra No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Levitra fedex without prescription | U ltram consumer information | pills Cheap generic Levitra | Buy Levitra onlin e no prescription | Levitra Buy | Buy Cheap Levitra Online No Prescription B uy Levitra online | purchase Levitra without prescription | Buying Levitra On line Without Prescription Levitra Overnight COD no prescription | Cheap onli ne Buy Levitra | Low Price Levitra Saturday Delivery No Prescription Levitra w ithout a prescription no generics | Buy Levitra Without Prescription Levitra overnight | Buy With No Prescription Levitra Online Order Levitra no rx overn ight delivery | Order Levitra Saturday Delivery No Prescription Levitra onlin e no prescription | Levitra Discount cards | Buy Levitra no script | Levitra by phone no script | Buy Levitra Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Levitra online without a prescription and no me mbership | Buy Without Prescription Levitra Online buy no prescription Ultra m | Order Levitra Cheap no membership fees no prescription | Levitra order n o script | Levitra lowest cost | online Buy Levitra | Overnight Levitra With out A Prescription Levitra Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Levitra Without A Prescription no script Levitra | Levitra Buy phone | Levitra paid with mastercard | Levitra With No Prescript ion Levitra to purchase | Order Levitra online with no prescription | Levitra Buying online Levitra drugs | Levitra free Overnight fedex delivery | Ultra m best online pharmacy | purchase Levitra without a prescription overnight d elivery | Buy Levitra online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Levitra From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Levitra next day | Where To Buy Levitra No Prescription No Fees Levitra ups cod | Order Levitra cash on delive ry | Levitra overnight shipping no prescription | purchase Levitra without p rescription online | Buy Levitra online without dr approval | Buy Levitra on line without dr approval | Levitra ups | Levitra Buy | Buy Levitra in Idaho | Levitra cheapest | Buy Levitra pay with mastercard | ordering Buy Levitra online | Levitra Overnight COD no prescription | Levitra order cod | Levitra No Prescription Levitra overnight delivery Cheap | Levitra order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Levitra usa online pharmacy | U ltram free consultation | how to Order Levitra without doctors | Purchase U ltram online | comprar Levitra | No Prescription Required For Levitra Levitra cod ordering | Cheap Levitra without prescription | Buy Cheap Levitra fast | Levitra Buy | Buy Levitra online without a prescription and no membership | Cheap Levitra without prescription overnight delivery | cash on delivery online prescriptions Levitra | Levitra with no prescription | ordering Ultra m online without a prescription | Levitra Cheap order | Levitra online no pr escription | No Prescription Needed Levitra Low Price Levitra With No Prescri ption Buy Levitra Online Without Prescription buy no prescription Levitra | B uy Levitra online discount | Levitra order cod | Order Cheap Levitra very Buy without prescription | Levitra cod next day delivery | Order Levitra Online Without Prescription Levitra free Overnight fedex delivery | Cheap Levitra b y money Order | Buy Levitra online discount | overnight Levitra | 8 Buy Ult ram online | Cheap Levitra c.o.d. | Buy Levitra Tablets Without Prescription Overnight Levitra for sale | Buy Levitra online sales | natural Levitra | U ltram manufacturer | Levitra Online No Prescription Levitra adiction | geniu ne Levitra no prescription | Levitra Pharmacy Cod Saturday Delivery With No P rescription Levitra Buy phone | Buy Levitra online prescription | Order Ultr am without prescription from us pharmacy | Buy real Levitra with mastercard | Levitra without a rx | doctor online prescription Levitra | Levitra Free O vernight Fedex Delivery order Levitra online cash on delivery | Cheap Levitra next day | Buy Levitra Cheap online us pharmacy | Levitra delivery to uk fe dex Overnight | Find Cheap Levitra no prescription | online pharmacy Levitra | Buy Levitra Online Without A Prescription And No Membership Levitra to pur chase | Levitra Same Day Delivery No Prescription Levitra by phone no script | Buy Levitra without | discount Levitra overnight | Buy Cheap Levitra, Buy Cheap Levitra online | Levitra Buy fedex | Levitra shipped with no prescripti on | Buy Levitra online money order | purchase Levitra without a prescriptio n | Levitra ups cod | Buy Levitra Online No Prescription Buy Levitra online | Levitra with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Levitra cod | how to get Levitra prescription | Low Price Levitra With No Prescription Buy the Cheapest Levitra online index | prescription U ltram | Order Levitra No Prescription Order Levitra medicine online without p rescription | Low Price Levitra Saturday Delivery No Prescription Cheap Ultr am overnight | Levitra Online No Prescription Levitra online cash on delivery | Fedex Levitra Without Prescription Buy Levitra online usa | Levitra for sa le without a prescription | to Buy Levitra without a prescription | Levitra Overnight no script mastercard accepted | Buy Cheap Levitra No Prescription Cheap Levitra free consultant | Buy Levitra Cheap online us pharmacy | Buy C heap Levitra No Prescription Levitra lowest cost | Where To Buy Levitra No Pre scription No Fees Cheapest Levitra Online Without Prescription cheapest Ultra m | Levitra amphetimine | Buy Levitra 120 tabs | Buy Levitra Without A Presc ription Or Membership Levitra Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Levitra | Levitra conversion | overnight Levitra ups cod | Buy Levitra online Cheap | Levitra No Script Required Express Delivery With No P rescription Levitra free consultation u.s. pharmacy | Levitra cod no script | Levitra ups cod | Levitra online no prescription | purchase Levitra with co d | Canadian Levitra Pills No Prescription Buy Levitra in North Carolina | buy Levitra in Denmark, buy Levitra in Egypt, buy Levitra in Israel, buy Levitra in Ireland, buy Levitra in Spain, buy Levitra in Italy, buy Levitra in Canada, buy Levitra in Cyprus, buy Levitra in Mexico, buy Levitra in Netherlands, buy Levitra in New zealand, buy Levitra in Kingston, buy Levitra in Australia, buy Levitra in AU, buy Levitra in New South Wales, buy Levitra in NSW, buy Levitra i n Sydney, buy Levitra in Brisbane, buy Levitra in South Australia, buy Levitra in Hobart, buy Levitra in the United states, buy Levitra in Finland, buy Ultra m in France, buy Levitra in Chekhiya, buy Levitra in Switzerland, buy Levitra i n Sweden, buy Levitra in Alberta, buy Levitra in Labrador, buy Levitra in Toron to, buy Levitra in Ottawa, buy Levitra in Mississauga, buy Levitra in Hamilton, buy Levitra in Brampton, buy Levitra in London, buy Levitra in Markham, buy Ul tram in Vaughan, buy Levitra in Windsor, buy Levitra in Kitchener, buy Levitra in Montreal, buy Levitra in Mauricie, buy Levitra in Vancouver, buy Levitra in Victoria, buy Levitra in Kelowna, buy Levitra in Abbotsford, buy Levitra in Kam loops, buy Levitra in Nanaimo, buy Levitra in Vernon, buy Levitra in Lethbridge , buy Levitra in United Kingdom, buy Levitra in England, buy Levitra in Wales, buy Levitra in Scotland, buy Levitra in Northern Ireland, buy Levitra in Belfas t, buy Levitra in Cardiff, buy Levitra in London, buy Levitra in Glasgow, buy U ltram in Liverpool, buy Levitra in Leeds, buy Levitra in Victoria, buy Levitra in Melbourne, buy Levitra in Western Australia, buy Levitra in Perth, buy Ultr am in Alabama, buy Levitra in Arizona, buy Levitra in Arkansas, buy Levitra in California, buy Levitra in Colorado, buy Levitra in Connecticut, buy Levitra in Delaware, buy Levitra in Florida, buy Levitra in Georgia, buy Levitra in Hawai i, buy Levitra in Idaho, buy Levitra in Illinois, buy Levitra in Indiana, buy U ltram in Iowa, buy Levitra in Kansas, buy Levitra in Kentucky, buy Levitra in L ouisiana, buy Levitra in Maine, buy Levitra in Montana, buy Levitra in Nebraska , buy Levitra in Nevada, buy Levitra in New Jersey, buy Levitra in New Mexico, buy Levitra in New York, buy Levitra in North Carolina, buy Levitra in North Da kota, buy Levitra in Ohio, buy Levitra in Oklahoma, buy Levitra in Texas, buy U ltram in Utah, buy Levitra in Vermont, buy Levitra in Virginia, buy Levitra in Washington, buy Levitra in West Virginia, buy Levitra in Wisconsin, buy Levitra in Wyoming, buy Levitra in Montgomery, buy Levitra in Juneau, buy Levitra in P hoenix, buy Levitra in Little Rock, buy Levitra in Sacramento, buy Levitra in D enver, buy Levitra in Hartford, buy Levitra in Dover, buy Levitra in Tallahasse e, buy Levitra in Atlanta, buy Levitra in Springfield, buy Levitra in Indianapo lis, buy Levitra in Des Moines, buy Levitra in Annapolis, buy Levitra in Boston , buy Levitra in Lansing, buy Levitra in Helena, buy Levitra in Lincoln, buy Ul tram in Santa Fe, buy Levitra in Albany, buy Levitra in Raleigh, buy Levitra in Bismarck, buy Levitra in Columbus, buy Levitra in Salem, buy Levitra in Columb ia, buy Levitra in Salt Lake City, buy Levitra in Montpelier, buy Levitra in Ch arleston, buy Levitra in Madison, buy Levitra in Cheyenne, buy Levitra in Austr alia, buy Levitra in Austria, buy Levitra in Argentina, buy Levitra in Belgium, buy Levitra in Bulgaria, buy Levitra in Brasilia, buy Levitra in Great britain , buy Levitra in Hungary, buy Levitra in Germany, buy Levitra in Greece, buy Ul tram in South Africa, buy Levitra in Japan From numansenm at gmail.com Thu Nov 10 13:37:28 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:37:28 -0800 (PST) Subject: Lowest prices for Alprazolam online. Buy Alprazolam online without prescription. Buy Cheap Alprazolam next day no prescription! Message-ID: <57b92492-2577-4f47-9ea1-2ecb53b4b628@w1g2000vba.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Alprazolam/Alprazolam pills with every Order ______________________________________________________________________ BUY Alprazolam ONLINE http://buypharmasite.com/?q=Alprazolam CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Alprazolam ONLINE http://buypharmasite.com/?q=Alprazolam CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Alprazolam Alprazolam online saturday delivery online Alprazolam and fedex cheap order prescription Alprazolam cheap Alprazolam by money order buy Alprazolam from mexico online Alprazolam no prescription usa fedex shipping overnight delivery Alprazolam buy Alprazolam online without a prescription and no membership no prescription needed Alprazolam cod shipped Alprazolam not expensive order prescription Alprazolam Alprazolam money order Alprazolam without a perscription online buy Alprazolam Alprazolam fedex buy no online prescription Alprazolam Alprazolam pharmacies accepting cod delivery Alprazolam online consultant online pharmacy fedex cod Alprazolam buy Alprazolam no scams Alprazolam c.o.d overnight delivery buy Alprazolam no prescription cod overnight Alprazolam order Alprazolam online doctors buy Alprazolam on line no prescription Alprazolam no prescription usa fedex shipping Alprazolam online uk watson brand Alprazolam medicine online Alprazolam order Alprazolam samples sent buy Alprazolam no prescription order Alprazolam without a prescription Alprazolam no prescription drug cheap online order Alprazolam get Alprazolam over the counter online order Alprazolam next day buy Alprazolam no perscription cod real Alprazolam fed ex Alprazolam no prescription cod does cv/ pharmacy carry Alprazolam no prescription cod Alprazolam cheap Alprazolam without rx Alprazolam online health insurance lead buy Alprazolam online with overnight delivery Alprazolam no rx fed ex buy Alprazolam without a perscription lowest prices for Alprazolam online buy Alprazolam paypal online without prescription cheap non prescription Alprazolam Alprazolam ups Alprazolam for cheap buy Alprazolam no visa online without prescription cheapest Alprazolam cash on delivery Alprazolam order a prepaid mastercard buy online Alprazolam purchase Alprazolam mail order Alprazolam without a prescription online with overnight delivery Alprazolam from canada buy Alprazolam with no rx overnight delivery of Alprazolam with no prescription cash on delivery Alprazolam no rx Alprazolam by cod buy Alprazolam over the counter cod overnight overnight Alprazolam order Alprazolam without prescription from us pharmacy cheap Alprazolam free fedex shipping order Alprazolam over the counter where to buy Alprazolam no prescription no fees only Alprazolam free consult cod delivery Alprazolam Alprazolam no prescription Alprazolam online overnight delivery cod order Alprazolam over the counter fedex Alprazolam saturday delivery buy Alprazolam money order Alprazolam without prescription mexico buy cheap Alprazolam without prescription Alprazolam non prescription for next day delivery Alprazolam ups delivery only buy Alprazolam usa cod Alprazolam with next day delivery no prescriptions needed for Alprazolam cheap Alprazolam overnight prescription Alprazolam cheap Alprazolam overnight delivery Alprazolam non prescription fedex overnight free order Alprazolam no creditcard buy cheap Alprazolam no Prescription buy Alprazolam over the counter fedex Alprazolam no doctor presribe needed cheap watson Alprazolam online cheap discount Alprazolam buy Alprazolam without a prescription online cheapest Alprazolam free delivery buy Alprazolam online overseas buy Alprazolam over the counter online not expensive Alprazolam next day shipping order Alprazolam cod next day delivery Alprazolam cheap Alprazolam buy in UK Alprazolam next day cod fedex Alprazolam to buy cheap order Alprazolam next day Alprazolam Alprazolam overnight no consult cheap watson Alprazolam no prescription needed Alprazolam without prescription medications overnight delivery of Alprazolam with no perscription buy Alprazolam.com Alprazolam cod next day delivery buy cheap discount online Alprazolam buy Alprazolam drug Alprazolam overnight delivery cheap overnight delivery of Alprazolam in US no prescription needed purchase Alprazolam free next day airAlprazolam on line cheap Alprazolam without a prescription Alprazolam cheap cod Alprazolam buy no prepaid cheap Alprazolam next day buy Alprazolam cod accepted online pharmacies Alprazolam saturday delivery buy Alprazolam pay pal Alprazolam shipped on saturday Alprazolam pharmacy cod saturday delivery buy online Alprazolam prescriptions free fedex delivery Alprazolam Alprazolam without prescription cash on delivery buy discount Alprazolam Alprazolam overnight cheap best Alprazolam online pill images of Alprazolam Alprazolam U.P.S SHIPPING COD Alprazolam cod pharmacy buy Alprazolam online cod Alprazolam cod overnight delivery Alprazolam no rx overnight buy Alprazolam overnight COD online pharmacy Alprazolam cod order Alprazolam insurance Alprazolam cash delivery cod buy Alprazolam cheap cod no rx online pharmacy Alprazolam sale nextday Alprazolam Alprazolam pill Alprazolam online ordering Alprazolam online without prescription Alprazolam no script needed cod overnight how to buy Alprazolam online without a prescription cheap Alprazolam without prescription cheap Alprazolam online no rx saturday delivery order Alprazolam over the counter for sale Alprazolam next day delivery cod order Alprazolam online without prescription no prescription next day delivery Alprazolam overnight Alprazolam C.O.D Alprazolam without prescription Alprazolam discount fedex no prescription buy Alprazolam amex Alprazolam online next day Alprazolam shipped with no prescription Alprazolam online cheap cheap Alprazolam without prescription overnight delivery buy Alprazolam over the counter for sale Alprazolam no prescriptions needed cod Alprazolam fed ex cheap overnight delivery of Alprazolam free prescription Alprazolam free shipping not expensive legal Alprazolam for sale buy Alprazolam cod Alprazolam for saturday Alprazolam price cash for Alprazolam cash on delivery Alprazolam Alprazolam without a prescription and cod delivery buying Alprazolam without a prescription order Alprazolam no rx buy Alprazolam without rx Alprazolam cheapest buy Alprazolam online pharmacy buy cheap Alprazolam overnight delivery Alprazolam and online pharmacy Alprazolam next day Alprazolam drug no prescription where can i buy Alprazolam no prescription Alprazolam with saturday delivery Alprazolam online overnight Alprazolam no prescription worldwide buy cheap Alprazolam cod ordering Alprazolam online Buy Alprazolam overnight shipping Alprazolam overnight US delivery cheap real Alprazolam for sale Alprazolam no prescriptions needed COD buy Alprazolam no prescription needed Alprazolam no prescription overnight cod delivery cheap Alprazolam cash on delivery no prescription required for Alprazolam order Alprazolam c.o.d. not expensive Alprazolam prescriptions Alprazolam online Cash on Delivery buy Alprazolam overnight delivery Alprazolam online without presciption buy Alprazolam prescription online no prescription saturday delivery Alprazolam where to buy cheap Alprazolam no prescription Alprazolam wo get Alprazolam over the counter fedex Alprazolam with no rx and free shipping order Alprazolam over the counter cod overnight Alprazolam Fedex Without Prescription Alprazolam Online With Next Day Shipping Buy Cheap Alprazolam online | purchase Alprazolam without prescription online | Alprazolam Online Prescriptions With No Membership Alprazolam Cheap next day | Buy Cheap Alprazolam fedex overnight | original Alprazolam pill | Purchase Alprazolam pharmacy r x online | Alprazolam cod Orders | Buy Alprazolam online pharmacy | Alprazolam cod ne xt day delivery | order Alprazolam online no membership overnight shipping | B uy Cheap Alprazolam Online No Prescription Order Alprazolam cod next day delivery | Alprazolam Discount cards | Buy genuine Alprazolam online | buying Alprazolam without a prescription | Where To Buy Alprazolam No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Alprazolam fedex without prescription | U ltram consumer information | pills Cheap generic Alprazolam | Buy Alprazolam onlin e no prescription | Alprazolam Buy | Buy Cheap Alprazolam Online No Prescription B uy Alprazolam online | purchase Alprazolam without prescription | Buying Alprazolam On line Without Prescription Alprazolam Overnight COD no prescription | Cheap onli ne Buy Alprazolam | Low Price Alprazolam Saturday Delivery No Prescription Alprazolam w ithout a prescription no generics | Buy Alprazolam Without Prescription Alprazolam overnight | Buy With No Prescription Alprazolam Online Order Alprazolam no rx overn ight delivery | Order Alprazolam Saturday Delivery No Prescription Alprazolam onlin e no prescription | Alprazolam Discount cards | Buy Alprazolam no script | Alprazolam by phone no script | Buy Alprazolam Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Alprazolam online without a prescription and no me mbership | Buy Without Prescription Alprazolam Online buy no prescription Ultra m | Order Alprazolam Cheap no membership fees no prescription | Alprazolam order n o script | Alprazolam lowest cost | online Buy Alprazolam | Overnight Alprazolam With out A Prescription Alprazolam Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Alprazolam Without A Prescription no script Alprazolam | Alprazolam Buy phone | Alprazolam paid with mastercard | Alprazolam With No Prescript ion Alprazolam to purchase | Order Alprazolam online with no prescription | Alprazolam Buying online Alprazolam drugs | Alprazolam free Overnight fedex delivery | Ultra m best online pharmacy | purchase Alprazolam without a prescription overnight d elivery | Buy Alprazolam online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Alprazolam From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Alprazolam next day | Where To Buy Alprazolam No Prescription No Fees Alprazolam ups cod | Order Alprazolam cash on delive ry | Alprazolam overnight shipping no prescription | purchase Alprazolam without p rescription online | Buy Alprazolam online without dr approval | Buy Alprazolam on line without dr approval | Alprazolam ups | Alprazolam Buy | Buy Alprazolam in Idaho | Alprazolam cheapest | Buy Alprazolam pay with mastercard | ordering Buy Alprazolam online | Alprazolam Overnight COD no prescription | Alprazolam order cod | Alprazolam No Prescription Alprazolam overnight delivery Cheap | Alprazolam order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Alprazolam usa online pharmacy | U ltram free consultation | how to Order Alprazolam without doctors | Purchase U ltram online | comprar Alprazolam | No Prescription Required For Alprazolam Alprazolam cod ordering | Cheap Alprazolam without prescription | Buy Cheap Alprazolam fast | Alprazolam Buy | Buy Alprazolam online without a prescription and no membership | Cheap Alprazolam without prescription overnight delivery | cash on delivery online prescriptions Alprazolam | Alprazolam with no prescription | ordering Ultra m online without a prescription | Alprazolam Cheap order | Alprazolam online no pr escription | No Prescription Needed Alprazolam Low Price Alprazolam With No Prescri ption Buy Alprazolam Online Without Prescription buy no prescription Alprazolam | B uy Alprazolam online discount | Alprazolam order cod | Order Cheap Alprazolam very Buy without prescription | Alprazolam cod next day delivery | Order Alprazolam Online Without Prescription Alprazolam free Overnight fedex delivery | Cheap Alprazolam b y money Order | Buy Alprazolam online discount | overnight Alprazolam | 8 Buy Ult ram online | Cheap Alprazolam c.o.d. | Buy Alprazolam Tablets Without Prescription Overnight Alprazolam for sale | Buy Alprazolam online sales | natural Alprazolam | U ltram manufacturer | Alprazolam Online No Prescription Alprazolam adiction | geniu ne Alprazolam no prescription | Alprazolam Pharmacy Cod Saturday Delivery With No P rescription Alprazolam Buy phone | Buy Alprazolam online prescription | Order Ultr am without prescription from us pharmacy | Buy real Alprazolam with mastercard | Alprazolam without a rx | doctor online prescription Alprazolam | Alprazolam Free O vernight Fedex Delivery order Alprazolam online cash on delivery | Cheap Alprazolam next day | Buy Alprazolam Cheap online us pharmacy | Alprazolam delivery to uk fe dex Overnight | Find Cheap Alprazolam no prescription | online pharmacy Alprazolam | Buy Alprazolam Online Without A Prescription And No Membership Alprazolam to pur chase | Alprazolam Same Day Delivery No Prescription Alprazolam by phone no script | Buy Alprazolam without | discount Alprazolam overnight | Buy Cheap Alprazolam, Buy Cheap Alprazolam online | Alprazolam Buy fedex | Alprazolam shipped with no prescripti on | Buy Alprazolam online money order | purchase Alprazolam without a prescriptio n | Alprazolam ups cod | Buy Alprazolam Online No Prescription Buy Alprazolam online | Alprazolam with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Alprazolam cod | how to get Alprazolam prescription | Low Price Alprazolam With No Prescription Buy the Cheapest Alprazolam online index | prescription U ltram | Order Alprazolam No Prescription Order Alprazolam medicine online without p rescription | Low Price Alprazolam Saturday Delivery No Prescription Cheap Ultr am overnight | Alprazolam Online No Prescription Alprazolam online cash on delivery | Fedex Alprazolam Without Prescription Buy Alprazolam online usa | Alprazolam for sa le without a prescription | to Buy Alprazolam without a prescription | Alprazolam Overnight no script mastercard accepted | Buy Cheap Alprazolam No Prescription Cheap Alprazolam free consultant | Buy Alprazolam Cheap online us pharmacy | Buy C heap Alprazolam No Prescription Alprazolam lowest cost | Where To Buy Alprazolam No Pre scription No Fees Cheapest Alprazolam Online Without Prescription cheapest Ultra m | Alprazolam amphetimine | Buy Alprazolam 120 tabs | Buy Alprazolam Without A Presc ription Or Membership Alprazolam Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Alprazolam | Alprazolam conversion | overnight Alprazolam ups cod | Buy Alprazolam online Cheap | Alprazolam No Script Required Express Delivery With No P rescription Alprazolam free consultation u.s. pharmacy | Alprazolam cod no script | Alprazolam ups cod | Alprazolam online no prescription | purchase Alprazolam with co d | Canadian Alprazolam Pills No Prescription Buy Alprazolam in North Carolina | buy Alprazolam in Denmark, buy Alprazolam in Egypt, buy Alprazolam in Israel, buy Alprazolam in Ireland, buy Alprazolam in Spain, buy Alprazolam in Italy, buy Alprazolam in Canada, buy Alprazolam in Cyprus, buy Alprazolam in Mexico, buy Alprazolam in Netherlands, buy Alprazolam in New zealand, buy Alprazolam in Kingston, buy Alprazolam in Australia, buy Alprazolam in AU, buy Alprazolam in New South Wales, buy Alprazolam in NSW, buy Alprazolam i n Sydney, buy Alprazolam in Brisbane, buy Alprazolam in South Australia, buy Alprazolam in Hobart, buy Alprazolam in the United states, buy Alprazolam in Finland, buy Ultra m in France, buy Alprazolam in Chekhiya, buy Alprazolam in Switzerland, buy Alprazolam i n Sweden, buy Alprazolam in Alberta, buy Alprazolam in Labrador, buy Alprazolam in Toron to, buy Alprazolam in Ottawa, buy Alprazolam in Mississauga, buy Alprazolam in Hamilton, buy Alprazolam in Brampton, buy Alprazolam in London, buy Alprazolam in Markham, buy Ul tram in Vaughan, buy Alprazolam in Windsor, buy Alprazolam in Kitchener, buy Alprazolam in Montreal, buy Alprazolam in Mauricie, buy Alprazolam in Vancouver, buy Alprazolam in Victoria, buy Alprazolam in Kelowna, buy Alprazolam in Abbotsford, buy Alprazolam in Kam loops, buy Alprazolam in Nanaimo, buy Alprazolam in Vernon, buy Alprazolam in Lethbridge , buy Alprazolam in United Kingdom, buy Alprazolam in England, buy Alprazolam in Wales, buy Alprazolam in Scotland, buy Alprazolam in Northern Ireland, buy Alprazolam in Belfas t, buy Alprazolam in Cardiff, buy Alprazolam in London, buy Alprazolam in Glasgow, buy U ltram in Liverpool, buy Alprazolam in Leeds, buy Alprazolam in Victoria, buy Alprazolam in Melbourne, buy Alprazolam in Western Australia, buy Alprazolam in Perth, buy Ultr am in Alabama, buy Alprazolam in Arizona, buy Alprazolam in Arkansas, buy Alprazolam in California, buy Alprazolam in Colorado, buy Alprazolam in Connecticut, buy Alprazolam in Delaware, buy Alprazolam in Florida, buy Alprazolam in Georgia, buy Alprazolam in Hawai i, buy Alprazolam in Idaho, buy Alprazolam in Illinois, buy Alprazolam in Indiana, buy U ltram in Iowa, buy Alprazolam in Kansas, buy Alprazolam in Kentucky, buy Alprazolam in L ouisiana, buy Alprazolam in Maine, buy Alprazolam in Montana, buy Alprazolam in Nebraska , buy Alprazolam in Nevada, buy Alprazolam in New Jersey, buy Alprazolam in New Mexico, buy Alprazolam in New York, buy Alprazolam in North Carolina, buy Alprazolam in North Da kota, buy Alprazolam in Ohio, buy Alprazolam in Oklahoma, buy Alprazolam in Texas, buy U ltram in Utah, buy Alprazolam in Vermont, buy Alprazolam in Virginia, buy Alprazolam in Washington, buy Alprazolam in West Virginia, buy Alprazolam in Wisconsin, buy Alprazolam in Wyoming, buy Alprazolam in Montgomery, buy Alprazolam in Juneau, buy Alprazolam in P hoenix, buy Alprazolam in Little Rock, buy Alprazolam in Sacramento, buy Alprazolam in D enver, buy Alprazolam in Hartford, buy Alprazolam in Dover, buy Alprazolam in Tallahasse e, buy Alprazolam in Atlanta, buy Alprazolam in Springfield, buy Alprazolam in Indianapo lis, buy Alprazolam in Des Moines, buy Alprazolam in Annapolis, buy Alprazolam in Boston , buy Alprazolam in Lansing, buy Alprazolam in Helena, buy Alprazolam in Lincoln, buy Ul tram in Santa Fe, buy Alprazolam in Albany, buy Alprazolam in Raleigh, buy Alprazolam in Bismarck, buy Alprazolam in Columbus, buy Alprazolam in Salem, buy Alprazolam in Columb ia, buy Alprazolam in Salt Lake City, buy Alprazolam in Montpelier, buy Alprazolam in Ch arleston, buy Alprazolam in Madison, buy Alprazolam in Cheyenne, buy Alprazolam in Austr alia, buy Alprazolam in Austria, buy Alprazolam in Argentina, buy Alprazolam in Belgium, buy Alprazolam in Bulgaria, buy Alprazolam in Brasilia, buy Alprazolam in Great britain , buy Alprazolam in Hungary, buy Alprazolam in Germany, buy Alprazolam in Greece, buy Ul tram in South Africa, buy Alprazolam in Japan From numansenm at gmail.com Thu Nov 10 13:38:37 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:38:37 -0800 (PST) Subject: Buying Alprazolam in UK! Alprazolam Online UK! Alprazolam no prescription! Buy Alprazolam meds Online! Message-ID: <1653db5a-5b5b-4d48-84e2-cf5a3bff2b27@y12g2000vba.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Alprazolam/Alprazolam pills with every Order ______________________________________________________________________ BUY Alprazolam ONLINE http://buypharmasite.com/?q=Alprazolam CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Alprazolam ONLINE http://buypharmasite.com/?q=Alprazolam CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Alprazolam Alprazolam online saturday delivery online Alprazolam and fedex cheap order prescription Alprazolam cheap Alprazolam by money order buy Alprazolam from mexico online Alprazolam no prescription usa fedex shipping overnight delivery Alprazolam buy Alprazolam online without a prescription and no membership no prescription needed Alprazolam cod shipped Alprazolam not expensive order prescription Alprazolam Alprazolam money order Alprazolam without a perscription online buy Alprazolam Alprazolam fedex buy no online prescription Alprazolam Alprazolam pharmacies accepting cod delivery Alprazolam online consultant online pharmacy fedex cod Alprazolam buy Alprazolam no scams Alprazolam c.o.d overnight delivery buy Alprazolam no prescription cod overnight Alprazolam order Alprazolam online doctors buy Alprazolam on line no prescription Alprazolam no prescription usa fedex shipping Alprazolam online uk watson brand Alprazolam medicine online Alprazolam order Alprazolam samples sent buy Alprazolam no prescription order Alprazolam without a prescription Alprazolam no prescription drug cheap online order Alprazolam get Alprazolam over the counter online order Alprazolam next day buy Alprazolam no perscription cod real Alprazolam fed ex Alprazolam no prescription cod does cv/ pharmacy carry Alprazolam no prescription cod Alprazolam cheap Alprazolam without rx Alprazolam online health insurance lead buy Alprazolam online with overnight delivery Alprazolam no rx fed ex buy Alprazolam without a perscription lowest prices for Alprazolam online buy Alprazolam paypal online without prescription cheap non prescription Alprazolam Alprazolam ups Alprazolam for cheap buy Alprazolam no visa online without prescription cheapest Alprazolam cash on delivery Alprazolam order a prepaid mastercard buy online Alprazolam purchase Alprazolam mail order Alprazolam without a prescription online with overnight delivery Alprazolam from canada buy Alprazolam with no rx overnight delivery of Alprazolam with no prescription cash on delivery Alprazolam no rx Alprazolam by cod buy Alprazolam over the counter cod overnight overnight Alprazolam order Alprazolam without prescription from us pharmacy cheap Alprazolam free fedex shipping order Alprazolam over the counter where to buy Alprazolam no prescription no fees only Alprazolam free consult cod delivery Alprazolam Alprazolam no prescription Alprazolam online overnight delivery cod order Alprazolam over the counter fedex Alprazolam saturday delivery buy Alprazolam money order Alprazolam without prescription mexico buy cheap Alprazolam without prescription Alprazolam non prescription for next day delivery Alprazolam ups delivery only buy Alprazolam usa cod Alprazolam with next day delivery no prescriptions needed for Alprazolam cheap Alprazolam overnight prescription Alprazolam cheap Alprazolam overnight delivery Alprazolam non prescription fedex overnight free order Alprazolam no creditcard buy cheap Alprazolam no Prescription buy Alprazolam over the counter fedex Alprazolam no doctor presribe needed cheap watson Alprazolam online cheap discount Alprazolam buy Alprazolam without a prescription online cheapest Alprazolam free delivery buy Alprazolam online overseas buy Alprazolam over the counter online not expensive Alprazolam next day shipping order Alprazolam cod next day delivery Alprazolam cheap Alprazolam buy in UK Alprazolam next day cod fedex Alprazolam to buy cheap order Alprazolam next day Alprazolam Alprazolam overnight no consult cheap watson Alprazolam no prescription needed Alprazolam without prescription medications overnight delivery of Alprazolam with no perscription buy Alprazolam.com Alprazolam cod next day delivery buy cheap discount online Alprazolam buy Alprazolam drug Alprazolam overnight delivery cheap overnight delivery of Alprazolam in US no prescription needed purchase Alprazolam free next day airAlprazolam on line cheap Alprazolam without a prescription Alprazolam cheap cod Alprazolam buy no prepaid cheap Alprazolam next day buy Alprazolam cod accepted online pharmacies Alprazolam saturday delivery buy Alprazolam pay pal Alprazolam shipped on saturday Alprazolam pharmacy cod saturday delivery buy online Alprazolam prescriptions free fedex delivery Alprazolam Alprazolam without prescription cash on delivery buy discount Alprazolam Alprazolam overnight cheap best Alprazolam online pill images of Alprazolam Alprazolam U.P.S SHIPPING COD Alprazolam cod pharmacy buy Alprazolam online cod Alprazolam cod overnight delivery Alprazolam no rx overnight buy Alprazolam overnight COD online pharmacy Alprazolam cod order Alprazolam insurance Alprazolam cash delivery cod buy Alprazolam cheap cod no rx online pharmacy Alprazolam sale nextday Alprazolam Alprazolam pill Alprazolam online ordering Alprazolam online without prescription Alprazolam no script needed cod overnight how to buy Alprazolam online without a prescription cheap Alprazolam without prescription cheap Alprazolam online no rx saturday delivery order Alprazolam over the counter for sale Alprazolam next day delivery cod order Alprazolam online without prescription no prescription next day delivery Alprazolam overnight Alprazolam C.O.D Alprazolam without prescription Alprazolam discount fedex no prescription buy Alprazolam amex Alprazolam online next day Alprazolam shipped with no prescription Alprazolam online cheap cheap Alprazolam without prescription overnight delivery buy Alprazolam over the counter for sale Alprazolam no prescriptions needed cod Alprazolam fed ex cheap overnight delivery of Alprazolam free prescription Alprazolam free shipping not expensive legal Alprazolam for sale buy Alprazolam cod Alprazolam for saturday Alprazolam price cash for Alprazolam cash on delivery Alprazolam Alprazolam without a prescription and cod delivery buying Alprazolam without a prescription order Alprazolam no rx buy Alprazolam without rx Alprazolam cheapest buy Alprazolam online pharmacy buy cheap Alprazolam overnight delivery Alprazolam and online pharmacy Alprazolam next day Alprazolam drug no prescription where can i buy Alprazolam no prescription Alprazolam with saturday delivery Alprazolam online overnight Alprazolam no prescription worldwide buy cheap Alprazolam cod ordering Alprazolam online Buy Alprazolam overnight shipping Alprazolam overnight US delivery cheap real Alprazolam for sale Alprazolam no prescriptions needed COD buy Alprazolam no prescription needed Alprazolam no prescription overnight cod delivery cheap Alprazolam cash on delivery no prescription required for Alprazolam order Alprazolam c.o.d. not expensive Alprazolam prescriptions Alprazolam online Cash on Delivery buy Alprazolam overnight delivery Alprazolam online without presciption buy Alprazolam prescription online no prescription saturday delivery Alprazolam where to buy cheap Alprazolam no prescription Alprazolam wo get Alprazolam over the counter fedex Alprazolam with no rx and free shipping order Alprazolam over the counter cod overnight Alprazolam Fedex Without Prescription Alprazolam Online With Next Day Shipping Buy Cheap Alprazolam online | purchase Alprazolam without prescription online | Alprazolam Online Prescriptions With No Membership Alprazolam Cheap next day | Buy Cheap Alprazolam fedex overnight | original Alprazolam pill | Purchase Alprazolam pharmacy r x online | Alprazolam cod Orders | Buy Alprazolam online pharmacy | Alprazolam cod ne xt day delivery | order Alprazolam online no membership overnight shipping | B uy Cheap Alprazolam Online No Prescription Order Alprazolam cod next day delivery | Alprazolam Discount cards | Buy genuine Alprazolam online | buying Alprazolam without a prescription | Where To Buy Alprazolam No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Alprazolam fedex without prescription | U ltram consumer information | pills Cheap generic Alprazolam | Buy Alprazolam onlin e no prescription | Alprazolam Buy | Buy Cheap Alprazolam Online No Prescription B uy Alprazolam online | purchase Alprazolam without prescription | Buying Alprazolam On line Without Prescription Alprazolam Overnight COD no prescription | Cheap onli ne Buy Alprazolam | Low Price Alprazolam Saturday Delivery No Prescription Alprazolam w ithout a prescription no generics | Buy Alprazolam Without Prescription Alprazolam overnight | Buy With No Prescription Alprazolam Online Order Alprazolam no rx overn ight delivery | Order Alprazolam Saturday Delivery No Prescription Alprazolam onlin e no prescription | Alprazolam Discount cards | Buy Alprazolam no script | Alprazolam by phone no script | Buy Alprazolam Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Alprazolam online without a prescription and no me mbership | Buy Without Prescription Alprazolam Online buy no prescription Ultra m | Order Alprazolam Cheap no membership fees no prescription | Alprazolam order n o script | Alprazolam lowest cost | online Buy Alprazolam | Overnight Alprazolam With out A Prescription Alprazolam Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Alprazolam Without A Prescription no script Alprazolam | Alprazolam Buy phone | Alprazolam paid with mastercard | Alprazolam With No Prescript ion Alprazolam to purchase | Order Alprazolam online with no prescription | Alprazolam Buying online Alprazolam drugs | Alprazolam free Overnight fedex delivery | Ultra m best online pharmacy | purchase Alprazolam without a prescription overnight d elivery | Buy Alprazolam online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Alprazolam From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Alprazolam next day | Where To Buy Alprazolam No Prescription No Fees Alprazolam ups cod | Order Alprazolam cash on delive ry | Alprazolam overnight shipping no prescription | purchase Alprazolam without p rescription online | Buy Alprazolam online without dr approval | Buy Alprazolam on line without dr approval | Alprazolam ups | Alprazolam Buy | Buy Alprazolam in Idaho | Alprazolam cheapest | Buy Alprazolam pay with mastercard | ordering Buy Alprazolam online | Alprazolam Overnight COD no prescription | Alprazolam order cod | Alprazolam No Prescription Alprazolam overnight delivery Cheap | Alprazolam order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Alprazolam usa online pharmacy | U ltram free consultation | how to Order Alprazolam without doctors | Purchase U ltram online | comprar Alprazolam | No Prescription Required For Alprazolam Alprazolam cod ordering | Cheap Alprazolam without prescription | Buy Cheap Alprazolam fast | Alprazolam Buy | Buy Alprazolam online without a prescription and no membership | Cheap Alprazolam without prescription overnight delivery | cash on delivery online prescriptions Alprazolam | Alprazolam with no prescription | ordering Ultra m online without a prescription | Alprazolam Cheap order | Alprazolam online no pr escription | No Prescription Needed Alprazolam Low Price Alprazolam With No Prescri ption Buy Alprazolam Online Without Prescription buy no prescription Alprazolam | B uy Alprazolam online discount | Alprazolam order cod | Order Cheap Alprazolam very Buy without prescription | Alprazolam cod next day delivery | Order Alprazolam Online Without Prescription Alprazolam free Overnight fedex delivery | Cheap Alprazolam b y money Order | Buy Alprazolam online discount | overnight Alprazolam | 8 Buy Ult ram online | Cheap Alprazolam c.o.d. | Buy Alprazolam Tablets Without Prescription Overnight Alprazolam for sale | Buy Alprazolam online sales | natural Alprazolam | U ltram manufacturer | Alprazolam Online No Prescription Alprazolam adiction | geniu ne Alprazolam no prescription | Alprazolam Pharmacy Cod Saturday Delivery With No P rescription Alprazolam Buy phone | Buy Alprazolam online prescription | Order Ultr am without prescription from us pharmacy | Buy real Alprazolam with mastercard | Alprazolam without a rx | doctor online prescription Alprazolam | Alprazolam Free O vernight Fedex Delivery order Alprazolam online cash on delivery | Cheap Alprazolam next day | Buy Alprazolam Cheap online us pharmacy | Alprazolam delivery to uk fe dex Overnight | Find Cheap Alprazolam no prescription | online pharmacy Alprazolam | Buy Alprazolam Online Without A Prescription And No Membership Alprazolam to pur chase | Alprazolam Same Day Delivery No Prescription Alprazolam by phone no script | Buy Alprazolam without | discount Alprazolam overnight | Buy Cheap Alprazolam, Buy Cheap Alprazolam online | Alprazolam Buy fedex | Alprazolam shipped with no prescripti on | Buy Alprazolam online money order | purchase Alprazolam without a prescriptio n | Alprazolam ups cod | Buy Alprazolam Online No Prescription Buy Alprazolam online | Alprazolam with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Alprazolam cod | how to get Alprazolam prescription | Low Price Alprazolam With No Prescription Buy the Cheapest Alprazolam online index | prescription U ltram | Order Alprazolam No Prescription Order Alprazolam medicine online without p rescription | Low Price Alprazolam Saturday Delivery No Prescription Cheap Ultr am overnight | Alprazolam Online No Prescription Alprazolam online cash on delivery | Fedex Alprazolam Without Prescription Buy Alprazolam online usa | Alprazolam for sa le without a prescription | to Buy Alprazolam without a prescription | Alprazolam Overnight no script mastercard accepted | Buy Cheap Alprazolam No Prescription Cheap Alprazolam free consultant | Buy Alprazolam Cheap online us pharmacy | Buy C heap Alprazolam No Prescription Alprazolam lowest cost | Where To Buy Alprazolam No Pre scription No Fees Cheapest Alprazolam Online Without Prescription cheapest Ultra m | Alprazolam amphetimine | Buy Alprazolam 120 tabs | Buy Alprazolam Without A Presc ription Or Membership Alprazolam Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Alprazolam | Alprazolam conversion | overnight Alprazolam ups cod | Buy Alprazolam online Cheap | Alprazolam No Script Required Express Delivery With No P rescription Alprazolam free consultation u.s. pharmacy | Alprazolam cod no script | Alprazolam ups cod | Alprazolam online no prescription | purchase Alprazolam with co d | Canadian Alprazolam Pills No Prescription Buy Alprazolam in North Carolina | buy Alprazolam in Denmark, buy Alprazolam in Egypt, buy Alprazolam in Israel, buy Alprazolam in Ireland, buy Alprazolam in Spain, buy Alprazolam in Italy, buy Alprazolam in Canada, buy Alprazolam in Cyprus, buy Alprazolam in Mexico, buy Alprazolam in Netherlands, buy Alprazolam in New zealand, buy Alprazolam in Kingston, buy Alprazolam in Australia, buy Alprazolam in AU, buy Alprazolam in New South Wales, buy Alprazolam in NSW, buy Alprazolam i n Sydney, buy Alprazolam in Brisbane, buy Alprazolam in South Australia, buy Alprazolam in Hobart, buy Alprazolam in the United states, buy Alprazolam in Finland, buy Ultra m in France, buy Alprazolam in Chekhiya, buy Alprazolam in Switzerland, buy Alprazolam i n Sweden, buy Alprazolam in Alberta, buy Alprazolam in Labrador, buy Alprazolam in Toron to, buy Alprazolam in Ottawa, buy Alprazolam in Mississauga, buy Alprazolam in Hamilton, buy Alprazolam in Brampton, buy Alprazolam in London, buy Alprazolam in Markham, buy Ul tram in Vaughan, buy Alprazolam in Windsor, buy Alprazolam in Kitchener, buy Alprazolam in Montreal, buy Alprazolam in Mauricie, buy Alprazolam in Vancouver, buy Alprazolam in Victoria, buy Alprazolam in Kelowna, buy Alprazolam in Abbotsford, buy Alprazolam in Kam loops, buy Alprazolam in Nanaimo, buy Alprazolam in Vernon, buy Alprazolam in Lethbridge , buy Alprazolam in United Kingdom, buy Alprazolam in England, buy Alprazolam in Wales, buy Alprazolam in Scotland, buy Alprazolam in Northern Ireland, buy Alprazolam in Belfas t, buy Alprazolam in Cardiff, buy Alprazolam in London, buy Alprazolam in Glasgow, buy U ltram in Liverpool, buy Alprazolam in Leeds, buy Alprazolam in Victoria, buy Alprazolam in Melbourne, buy Alprazolam in Western Australia, buy Alprazolam in Perth, buy Ultr am in Alabama, buy Alprazolam in Arizona, buy Alprazolam in Arkansas, buy Alprazolam in California, buy Alprazolam in Colorado, buy Alprazolam in Connecticut, buy Alprazolam in Delaware, buy Alprazolam in Florida, buy Alprazolam in Georgia, buy Alprazolam in Hawai i, buy Alprazolam in Idaho, buy Alprazolam in Illinois, buy Alprazolam in Indiana, buy U ltram in Iowa, buy Alprazolam in Kansas, buy Alprazolam in Kentucky, buy Alprazolam in L ouisiana, buy Alprazolam in Maine, buy Alprazolam in Montana, buy Alprazolam in Nebraska , buy Alprazolam in Nevada, buy Alprazolam in New Jersey, buy Alprazolam in New Mexico, buy Alprazolam in New York, buy Alprazolam in North Carolina, buy Alprazolam in North Da kota, buy Alprazolam in Ohio, buy Alprazolam in Oklahoma, buy Alprazolam in Texas, buy U ltram in Utah, buy Alprazolam in Vermont, buy Alprazolam in Virginia, buy Alprazolam in Washington, buy Alprazolam in West Virginia, buy Alprazolam in Wisconsin, buy Alprazolam in Wyoming, buy Alprazolam in Montgomery, buy Alprazolam in Juneau, buy Alprazolam in P hoenix, buy Alprazolam in Little Rock, buy Alprazolam in Sacramento, buy Alprazolam in D enver, buy Alprazolam in Hartford, buy Alprazolam in Dover, buy Alprazolam in Tallahasse e, buy Alprazolam in Atlanta, buy Alprazolam in Springfield, buy Alprazolam in Indianapo lis, buy Alprazolam in Des Moines, buy Alprazolam in Annapolis, buy Alprazolam in Boston , buy Alprazolam in Lansing, buy Alprazolam in Helena, buy Alprazolam in Lincoln, buy Ul tram in Santa Fe, buy Alprazolam in Albany, buy Alprazolam in Raleigh, buy Alprazolam in Bismarck, buy Alprazolam in Columbus, buy Alprazolam in Salem, buy Alprazolam in Columb ia, buy Alprazolam in Salt Lake City, buy Alprazolam in Montpelier, buy Alprazolam in Ch arleston, buy Alprazolam in Madison, buy Alprazolam in Cheyenne, buy Alprazolam in Austr alia, buy Alprazolam in Austria, buy Alprazolam in Argentina, buy Alprazolam in Belgium, buy Alprazolam in Bulgaria, buy Alprazolam in Brasilia, buy Alprazolam in Great britain , buy Alprazolam in Hungary, buy Alprazolam in Germany, buy Alprazolam in Greece, buy Ul tram in South Africa, buy Alprazolam in Japan From numansenm at gmail.com Thu Nov 10 13:39:57 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Thu, 10 Nov 2011 10:39:57 -0800 (PST) Subject: Buy Tadalafil Online without script, Tadalafil prescription from doctors Online, Order Tadalafil without prescription from us pharmacy Message-ID: <012233dd-474c-47e5-88bf-0c26a4a9e2bf@f29g2000yqa.googlegroups.com> ?2011. Top Pharmacy List! Best Prices Online! * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Tadalafil/Tadalafil pills with every Order ______________________________________________________________________ BUY Tadalafil ONLINE http://buypharmasite.com/?q=Tadalafil CLICK HERE! ______________________________________________________________________ +Watchful packaging. + Swift worldwide shipping! + 30 days money back guarantee! + Order 3 or more products and get free Regular Airmail shipping! + Many payment options: Visa, MasterCard, American Express, Automated Clearing House (ACH) and etc. ______________________________________________________________________ BUY Tadalafil ONLINE http://buypharmasite.com/?q=Tadalafil CLICK HERE! ______________________________________________________________________ We thank you for visiting!!! cheap online pharmacy Tadalafil Tadalafil online saturday delivery online Tadalafil and fedex cheap order prescription Tadalafil cheap Tadalafil by money order buy Tadalafil from mexico online Tadalafil no prescription usa fedex shipping overnight delivery Tadalafil buy Tadalafil online without a prescription and no membership no prescription needed Tadalafil cod shipped Tadalafil not expensive order prescription Tadalafil Tadalafil money order Tadalafil without a perscription online buy Tadalafil Tadalafil fedex buy no online prescription Tadalafil Tadalafil pharmacies accepting cod delivery Tadalafil online consultant online pharmacy fedex cod Tadalafil buy Tadalafil no scams Tadalafil c.o.d overnight delivery buy Tadalafil no prescription cod overnight Tadalafil order Tadalafil online doctors buy Tadalafil on line no prescription Tadalafil no prescription usa fedex shipping Tadalafil online uk watson brand Tadalafil medicine online Tadalafil order Tadalafil samples sent buy Tadalafil no prescription order Tadalafil without a prescription Tadalafil no prescription drug cheap online order Tadalafil get Tadalafil over the counter online order Tadalafil next day buy Tadalafil no perscription cod real Tadalafil fed ex Tadalafil no prescription cod does cv/ pharmacy carry Tadalafil no prescription cod Tadalafil cheap Tadalafil without rx Tadalafil online health insurance lead buy Tadalafil online with overnight delivery Tadalafil no rx fed ex buy Tadalafil without a perscription lowest prices for Tadalafil online buy Tadalafil paypal online without prescription cheap non prescription Tadalafil Tadalafil ups Tadalafil for cheap buy Tadalafil no visa online without prescription cheapest Tadalafil cash on delivery Tadalafil order a prepaid mastercard buy online Tadalafil purchase Tadalafil mail order Tadalafil without a prescription online with overnight delivery Tadalafil from canada buy Tadalafil with no rx overnight delivery of Tadalafil with no prescription cash on delivery Tadalafil no rx Tadalafil by cod buy Tadalafil over the counter cod overnight overnight Tadalafil order Tadalafil without prescription from us pharmacy cheap Tadalafil free fedex shipping order Tadalafil over the counter where to buy Tadalafil no prescription no fees only Tadalafil free consult cod delivery Tadalafil Tadalafil no prescription Tadalafil online overnight delivery cod order Tadalafil over the counter fedex Tadalafil saturday delivery buy Tadalafil money order Tadalafil without prescription mexico buy cheap Tadalafil without prescription Tadalafil non prescription for next day delivery Tadalafil ups delivery only buy Tadalafil usa cod Tadalafil with next day delivery no prescriptions needed for Tadalafil cheap Tadalafil overnight prescription Tadalafil cheap Tadalafil overnight delivery Tadalafil non prescription fedex overnight free order Tadalafil no creditcard buy cheap Tadalafil no Prescription buy Tadalafil over the counter fedex Tadalafil no doctor presribe needed cheap watson Tadalafil online cheap discount Tadalafil buy Tadalafil without a prescription online cheapest Tadalafil free delivery buy Tadalafil online overseas buy Tadalafil over the counter online not expensive Tadalafil next day shipping order Tadalafil cod next day delivery Tadalafil cheap Tadalafil buy in UK Tadalafil next day cod fedex Tadalafil to buy cheap order Tadalafil next day Tadalafil Tadalafil overnight no consult cheap watson Tadalafil no prescription needed Tadalafil without prescription medications overnight delivery of Tadalafil with no perscription buy Tadalafil.com Tadalafil cod next day delivery buy cheap discount online Tadalafil buy Tadalafil drug Tadalafil overnight delivery cheap overnight delivery of Tadalafil in US no prescription needed purchase Tadalafil free next day airTadalafil on line cheap Tadalafil without a prescription Tadalafil cheap cod Tadalafil buy no prepaid cheap Tadalafil next day buy Tadalafil cod accepted online pharmacies Tadalafil saturday delivery buy Tadalafil pay pal Tadalafil shipped on saturday Tadalafil pharmacy cod saturday delivery buy online Tadalafil prescriptions free fedex delivery Tadalafil Tadalafil without prescription cash on delivery buy discount Tadalafil Tadalafil overnight cheap best Tadalafil online pill images of Tadalafil Tadalafil U.P.S SHIPPING COD Tadalafil cod pharmacy buy Tadalafil online cod Tadalafil cod overnight delivery Tadalafil no rx overnight buy Tadalafil overnight COD online pharmacy Tadalafil cod order Tadalafil insurance Tadalafil cash delivery cod buy Tadalafil cheap cod no rx online pharmacy Tadalafil sale nextday Tadalafil Tadalafil pill Tadalafil online ordering Tadalafil online without prescription Tadalafil no script needed cod overnight how to buy Tadalafil online without a prescription cheap Tadalafil without prescription cheap Tadalafil online no rx saturday delivery order Tadalafil over the counter for sale Tadalafil next day delivery cod order Tadalafil online without prescription no prescription next day delivery Tadalafil overnight Tadalafil C.O.D Tadalafil without prescription Tadalafil discount fedex no prescription buy Tadalafil amex Tadalafil online next day Tadalafil shipped with no prescription Tadalafil online cheap cheap Tadalafil without prescription overnight delivery buy Tadalafil over the counter for sale Tadalafil no prescriptions needed cod Tadalafil fed ex cheap overnight delivery of Tadalafil free prescription Tadalafil free shipping not expensive legal Tadalafil for sale buy Tadalafil cod Tadalafil for saturday Tadalafil price cash for Tadalafil cash on delivery Tadalafil Tadalafil without a prescription and cod delivery buying Tadalafil without a prescription order Tadalafil no rx buy Tadalafil without rx Tadalafil cheapest buy Tadalafil online pharmacy buy cheap Tadalafil overnight delivery Tadalafil and online pharmacy Tadalafil next day Tadalafil drug no prescription where can i buy Tadalafil no prescription Tadalafil with saturday delivery Tadalafil online overnight Tadalafil no prescription worldwide buy cheap Tadalafil cod ordering Tadalafil online Buy Tadalafil overnight shipping Tadalafil overnight US delivery cheap real Tadalafil for sale Tadalafil no prescriptions needed COD buy Tadalafil no prescription needed Tadalafil no prescription overnight cod delivery cheap Tadalafil cash on delivery no prescription required for Tadalafil order Tadalafil c.o.d. not expensive Tadalafil prescriptions Tadalafil online Cash on Delivery buy Tadalafil overnight delivery Tadalafil online without presciption buy Tadalafil prescription online no prescription saturday delivery Tadalafil where to buy cheap Tadalafil no prescription Tadalafil wo get Tadalafil over the counter fedex Tadalafil with no rx and free shipping order Tadalafil over the counter cod overnight Tadalafil Fedex Without Prescription Tadalafil Online With Next Day Shipping Buy Cheap Tadalafil online | purchase Tadalafil without prescription online | Tadalafil Online Prescriptions With No Membership Tadalafil Cheap next day | Buy Cheap Tadalafil fedex overnight | original Tadalafil pill | Purchase Tadalafil pharmacy r x online | Tadalafil cod Orders | Buy Tadalafil online pharmacy | Tadalafil cod ne xt day delivery | order Tadalafil online no membership overnight shipping | B uy Cheap Tadalafil Online No Prescription Order Tadalafil cod next day delivery | Tadalafil Discount cards | Buy genuine Tadalafil online | buying Tadalafil without a prescription | Where To Buy Tadalafil No Prescription No Fees Low Price Ult ram Saturday Delivery No Prescription Tadalafil fedex without prescription | U ltram consumer information | pills Cheap generic Tadalafil | Buy Tadalafil onlin e no prescription | Tadalafil Buy | Buy Cheap Tadalafil Online No Prescription B uy Tadalafil online | purchase Tadalafil without prescription | Buying Tadalafil On line Without Prescription Tadalafil Overnight COD no prescription | Cheap onli ne Buy Tadalafil | Low Price Tadalafil Saturday Delivery No Prescription Tadalafil w ithout a prescription no generics | Buy Tadalafil Without Prescription Tadalafil overnight | Buy With No Prescription Tadalafil Online Order Tadalafil no rx overn ight delivery | Order Tadalafil Saturday Delivery No Prescription Tadalafil onlin e no prescription | Tadalafil Discount cards | Buy Tadalafil no script | Tadalafil by phone no script | Buy Tadalafil Cheap online us pharmacy | Cheapest Ultra m without prescription | Buy Tadalafil online without a prescription and no me mbership | Buy Without Prescription Tadalafil Online buy no prescription Ultra m | Order Tadalafil Cheap no membership fees no prescription | Tadalafil order n o script | Tadalafil lowest cost | online Buy Tadalafil | Overnight Tadalafil With out A Prescription Tadalafil Shipped Overnight No Prescription affects of Ultra m pills | I Want To Order Tadalafil Without A Prescription no script Tadalafil | Tadalafil Buy phone | Tadalafil paid with mastercard | Tadalafil With No Prescript ion Tadalafil to purchase | Order Tadalafil online with no prescription | Tadalafil Buying online Tadalafil drugs | Tadalafil free Overnight fedex delivery | Ultra m best online pharmacy | purchase Tadalafil without a prescription overnight d elivery | Buy Tadalafil online without a prescription and no membership | Ult ram xr Buy online Cheap | Buy Tadalafil From A Usa Without A Prescription Ultr am saturday delivery cod | no prescription Tadalafil next day | Where To Buy Tadalafil No Prescription No Fees Tadalafil ups cod | Order Tadalafil cash on delive ry | Tadalafil overnight shipping no prescription | purchase Tadalafil without p rescription online | Buy Tadalafil online without dr approval | Buy Tadalafil on line without dr approval | Tadalafil ups | Tadalafil Buy | Buy Tadalafil in Idaho | Tadalafil cheapest | Buy Tadalafil pay with mastercard | ordering Buy Tadalafil online | Tadalafil Overnight COD no prescription | Tadalafil order cod | Tadalafil No Prescription Tadalafil overnight delivery Cheap | Tadalafil order cod | Ultr am Overnight delivery Cheap | Buy brand Buy Tadalafil usa online pharmacy | U ltram free consultation | how to Order Tadalafil without doctors | Purchase U ltram online | comprar Tadalafil | No Prescription Required For Tadalafil Tadalafil cod ordering | Cheap Tadalafil without prescription | Buy Cheap Tadalafil fast | Tadalafil Buy | Buy Tadalafil online without a prescription and no membership | Cheap Tadalafil without prescription overnight delivery | cash on delivery online prescriptions Tadalafil | Tadalafil with no prescription | ordering Ultra m online without a prescription | Tadalafil Cheap order | Tadalafil online no pr escription | No Prescription Needed Tadalafil Low Price Tadalafil With No Prescri ption Buy Tadalafil Online Without Prescription buy no prescription Tadalafil | B uy Tadalafil online discount | Tadalafil order cod | Order Cheap Tadalafil very Buy without prescription | Tadalafil cod next day delivery | Order Tadalafil Online Without Prescription Tadalafil free Overnight fedex delivery | Cheap Tadalafil b y money Order | Buy Tadalafil online discount | overnight Tadalafil | 8 Buy Ult ram online | Cheap Tadalafil c.o.d. | Buy Tadalafil Tablets Without Prescription Overnight Tadalafil for sale | Buy Tadalafil online sales | natural Tadalafil | U ltram manufacturer | Tadalafil Online No Prescription Tadalafil adiction | geniu ne Tadalafil no prescription | Tadalafil Pharmacy Cod Saturday Delivery With No P rescription Tadalafil Buy phone | Buy Tadalafil online prescription | Order Ultr am without prescription from us pharmacy | Buy real Tadalafil with mastercard | Tadalafil without a rx | doctor online prescription Tadalafil | Tadalafil Free O vernight Fedex Delivery order Tadalafil online cash on delivery | Cheap Tadalafil next day | Buy Tadalafil Cheap online us pharmacy | Tadalafil delivery to uk fe dex Overnight | Find Cheap Tadalafil no prescription | online pharmacy Tadalafil | Buy Tadalafil Online Without A Prescription And No Membership Tadalafil to pur chase | Tadalafil Same Day Delivery No Prescription Tadalafil by phone no script | Buy Tadalafil without | discount Tadalafil overnight | Buy Cheap Tadalafil, Buy Cheap Tadalafil online | Tadalafil Buy fedex | Tadalafil shipped with no prescripti on | Buy Tadalafil online money order | purchase Tadalafil without a prescriptio n | Tadalafil ups cod | Buy Tadalafil Online No Prescription Buy Tadalafil online | Tadalafil with no prescription and delivered overnight | Buy online Cheap Ul tram | Buy Tadalafil cod | how to get Tadalafil prescription | Low Price Tadalafil With No Prescription Buy the Cheapest Tadalafil online index | prescription U ltram | Order Tadalafil No Prescription Order Tadalafil medicine online without p rescription | Low Price Tadalafil Saturday Delivery No Prescription Cheap Ultr am overnight | Tadalafil Online No Prescription Tadalafil online cash on delivery | Fedex Tadalafil Without Prescription Buy Tadalafil online usa | Tadalafil for sa le without a prescription | to Buy Tadalafil without a prescription | Tadalafil Overnight no script mastercard accepted | Buy Cheap Tadalafil No Prescription Cheap Tadalafil free consultant | Buy Tadalafil Cheap online us pharmacy | Buy C heap Tadalafil No Prescription Tadalafil lowest cost | Where To Buy Tadalafil No Pre scription No Fees Cheapest Tadalafil Online Without Prescription cheapest Ultra m | Tadalafil amphetimine | Buy Tadalafil 120 tabs | Buy Tadalafil Without A Presc ription Or Membership Tadalafil Pharmacy Cod Saturday Delivery Without Prescrip tion arkansas Tadalafil | Tadalafil conversion | overnight Tadalafil ups cod | Buy Tadalafil online Cheap | Tadalafil No Script Required Express Delivery With No P rescription Tadalafil free consultation u.s. pharmacy | Tadalafil cod no script | Tadalafil ups cod | Tadalafil online no prescription | purchase Tadalafil with co d | Canadian Tadalafil Pills No Prescription Buy Tadalafil in North Carolina | buy Tadalafil in Denmark, buy Tadalafil in Egypt, buy Tadalafil in Israel, buy Tadalafil in Ireland, buy Tadalafil in Spain, buy Tadalafil in Italy, buy Tadalafil in Canada, buy Tadalafil in Cyprus, buy Tadalafil in Mexico, buy Tadalafil in Netherlands, buy Tadalafil in New zealand, buy Tadalafil in Kingston, buy Tadalafil in Australia, buy Tadalafil in AU, buy Tadalafil in New South Wales, buy Tadalafil in NSW, buy Tadalafil i n Sydney, buy Tadalafil in Brisbane, buy Tadalafil in South Australia, buy Tadalafil in Hobart, buy Tadalafil in the United states, buy Tadalafil in Finland, buy Ultra m in France, buy Tadalafil in Chekhiya, buy Tadalafil in Switzerland, buy Tadalafil i n Sweden, buy Tadalafil in Alberta, buy Tadalafil in Labrador, buy Tadalafil in Toron to, buy Tadalafil in Ottawa, buy Tadalafil in Mississauga, buy Tadalafil in Hamilton, buy Tadalafil in Brampton, buy Tadalafil in London, buy Tadalafil in Markham, buy Ul tram in Vaughan, buy Tadalafil in Windsor, buy Tadalafil in Kitchener, buy Tadalafil in Montreal, buy Tadalafil in Mauricie, buy Tadalafil in Vancouver, buy Tadalafil in Victoria, buy Tadalafil in Kelowna, buy Tadalafil in Abbotsford, buy Tadalafil in Kam loops, buy Tadalafil in Nanaimo, buy Tadalafil in Vernon, buy Tadalafil in Lethbridge , buy Tadalafil in United Kingdom, buy Tadalafil in England, buy Tadalafil in Wales, buy Tadalafil in Scotland, buy Tadalafil in Northern Ireland, buy Tadalafil in Belfas t, buy Tadalafil in Cardiff, buy Tadalafil in London, buy Tadalafil in Glasgow, buy U ltram in Liverpool, buy Tadalafil in Leeds, buy Tadalafil in Victoria, buy Tadalafil in Melbourne, buy Tadalafil in Western Australia, buy Tadalafil in Perth, buy Ultr am in Alabama, buy Tadalafil in Arizona, buy Tadalafil in Arkansas, buy Tadalafil in California, buy Tadalafil in Colorado, buy Tadalafil in Connecticut, buy Tadalafil in Delaware, buy Tadalafil in Florida, buy Tadalafil in Georgia, buy Tadalafil in Hawai i, buy Tadalafil in Idaho, buy Tadalafil in Illinois, buy Tadalafil in Indiana, buy U ltram in Iowa, buy Tadalafil in Kansas, buy Tadalafil in Kentucky, buy Tadalafil in L ouisiana, buy Tadalafil in Maine, buy Tadalafil in Montana, buy Tadalafil in Nebraska , buy Tadalafil in Nevada, buy Tadalafil in New Jersey, buy Tadalafil in New Mexico, buy Tadalafil in New York, buy Tadalafil in North Carolina, buy Tadalafil in North Da kota, buy Tadalafil in Ohio, buy Tadalafil in Oklahoma, buy Tadalafil in Texas, buy U ltram in Utah, buy Tadalafil in Vermont, buy Tadalafil in Virginia, buy Tadalafil in Washington, buy Tadalafil in West Virginia, buy Tadalafil in Wisconsin, buy Tadalafil in Wyoming, buy Tadalafil in Montgomery, buy Tadalafil in Juneau, buy Tadalafil in P hoenix, buy Tadalafil in Little Rock, buy Tadalafil in Sacramento, buy Tadalafil in D enver, buy Tadalafil in Hartford, buy Tadalafil in Dover, buy Tadalafil in Tallahasse e, buy Tadalafil in Atlanta, buy Tadalafil in Springfield, buy Tadalafil in Indianapo lis, buy Tadalafil in Des Moines, buy Tadalafil in Annapolis, buy Tadalafil in Boston , buy Tadalafil in Lansing, buy Tadalafil in Helena, buy Tadalafil in Lincoln, buy Ul tram in Santa Fe, buy Tadalafil in Albany, buy Tadalafil in Raleigh, buy Tadalafil in Bismarck, buy Tadalafil in Columbus, buy Tadalafil in Salem, buy Tadalafil in Columb ia, buy Tadalafil in Salt Lake City, buy Tadalafil in Montpelier, buy Tadalafil in Ch arleston, buy Tadalafil in Madison, buy Tadalafil in Cheyenne, buy Tadalafil in Austr alia, buy Tadalafil in Austria, buy Tadalafil in Argentina, buy Tadalafil in Belgium, buy Tadalafil in Bulgaria, buy Tadalafil in Brasilia, buy Tadalafil in Great britain , buy Tadalafil in Hungary, buy Tadalafil in Germany, buy Tadalafil in Greece, buy Ul tram in South Africa, buy Tadalafil in Japan From ethan at stoneleaf.us Thu Nov 10 13:43:32 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 10 Nov 2011 10:43:32 -0800 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4EBC1B54.6000308@stoneleaf.us> Devin Jeanpierre wrote: > Well. It reads fine in a certain sense, in that I can figure out > what's going on (although I have some troubles figuring out why the > heck certain things are in the code). The issue is that what's going > on is otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. Certainly it's a Python pattern -- it's what you do to dynamically generate code. > The use of exec also results in (seemingly) arbitrary constraints on > the input. Like, why can't "--" be a name? Because exec? Is there some > other reason? '--' not being allowed for a name has *nothing* to do with exec, and everything to do with `--` not being a valid Python identifier. > '--' is a valid attribute name on virtually any object that supports > attribute setting (e.g. function objects). Of course, you need to use > setattr() and getattr(). Is this really the reason, or is it a > limitation caused primarily by the usage of exec and the need to > prevent code injection? If somebody added this feature later on, would > this create a security vulnerability in certain projects that used > namedtuple in certain ways? So you think somevar = getattr(my_named_tuple, '--') is more readable than somevar = my_named_tuple.spam ? ~Ethan~ From tkpmep at hotmail.com Thu Nov 10 13:56:25 2011 From: tkpmep at hotmail.com (tkpmep at hotmail.com) Date: Thu, 10 Nov 2011 10:56:25 -0800 (PST) Subject: Working with databases (ODBC and ORMs) in Python 3.2 Message-ID: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> We are in the process of trying to decide between Python 2.7 and 3.2 with a view to making a 5-10 year commitment to the right platform, and would appreciate some guidance on how best to connect to SQL databases in 3.2. ceODBC 2.01 provides an ODBC driver for Python 3.2, does anyone have experience using it? Also, are there any ORMs (object relational mapper)s that work well with 3,2? Thanks in advance Thomas Philips From tjreedy at udel.edu Thu Nov 10 14:25:40 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Nov 2011 14:25:40 -0500 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebb81e1$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/10/2011 3:51 AM, Devin Jeanpierre wrote: >> Because Python doesn't allow "--" to be an attribute name, and so >> namedtuple doesn't let you try: >> >> t = namedtuple("T", "foo -- bar")(1, 2, 3) >> print(t.foo) >> print(t.--) >> print(t.bar) > > '--' is a valid attribute name on virtually any object that supports > attribute setting (e.g. function objects). ob.-- is not valid Python because '--' is not a name. > Of course, you need to use setattr() and getattr(). I consider the fact that CPython's setattr accepts non-name strings to be a bit of a bug. Or if you will, leniency for speed. (A unicode name check in Py3 would be much more expensive than an ascii name check in Py2.) I would consider it legitimate for another implementation to only accept names and to use a specialized name_dict for attribute dictionaries. So I consider it quite legitimate for namedtuple to requires real names for the fields. The whole point is to allow ob.name access to tuple members. Someone who plans to use set/getattr with arbitrary strings should just use a dict instead of a tuple. -- Terry Jan Reedy From benjamin.kaplan at case.edu Thu Nov 10 14:32:24 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Thu, 10 Nov 2011 14:32:24 -0500 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <1320941348.7601.57.camel@tim-laptop> Message-ID: On Thu, Nov 10, 2011 at 1:06 PM, Jerry Zhang wrote: > > > I just did an example code to describe what i am looking for. > /*------------------------------------------------------------------------------------------------*/ > # ... > > class Head: > ??? def __init__(self): > ??????? self.size = 5 > > class Hat: > ??? def __init__(self): > ??????? self.color = red > ??? def took_on(self, body): > ??????? self.body = body > ??? def took_off(self, body): > ??????? del self.body > > class Body: > ??? def __init__(self): > ??????? self.head = Head() > ??? def take_on_hat(self, hat): > ??????? self.hat = hat > ??????? hat.take_on(self) > ??? def take_off_hat(self): > ??????? hat.take_off(self) > ??????? del self.hat > ??? def go_to_heaven(self): > ??????? take_off_hat(self) > ??????? del self.head > /*----------------------------------------------------------------------------------------------------------*/ > > In this example, Head and body are COMPOSITION, which means > a. A head only live with one body, it can not live with other body. It can > not even live without body > b. If the body go to die, the head also go to die. > > Body and Hat are aggregation, which means > a. A hat live isolate with body, its life circle is isolate > b. A hat only live with one body at a specific time, it can not live with > two body(association would be more than one) > > So when the body die, the clean dead should include take_off Hat and del > Head, otherwise, the code definition is not prciselly describing the > relationship, which may cause a mess system, for example, a body has dead, > but one hat is still associated with a unreferenced body. > A point on this issue, maybe python is smart that the take_off_hat(self) is > not needed in go_to_heaven() method(i am not sure yet), but the del > self.head is sure needed, otherwise, we will have a no_body_head in our > ZODB, that is extremely horrible, right? > > All of these points one, the four kinds of class relationship in UML > precisely describe the real word, if the implementation is not precisely, > you will have unexpected results. > Of course, python may be smart to achieve such goal with less effort, that > is why i am asking for a code example for all of the four relationships. You're still misunderstanding Python's object model. del does NOT delete an object. It deletes a name. The only way for an object to be deleted is for it to be inaccessible (there are no references to it, or there are no reachable references to it). >>> foo = object() >>> bar = foo >>> foo >>> bar >>> del foo >>> bar >>> foo Traceback (most recent call last): File "", line 1, in foo NameError: name 'foo' is not defined There is no way to force the go_to_heaven method to delete the head unless you can make sure that all other references to the head are weak references. If you need strictly-enforced relationships, Python is probably not the right language for the job- you'll be better off with C++ or Java. From brenNOSPAMbarn at NObrenSPAMbarn.net Thu Nov 10 14:35:29 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Thu, 10 Nov 2011 19:35:29 +0000 (UTC) Subject: all() is slow? References: <4ebafbb7$0$1724$742ec2ed@news.sonic.net> Message-ID: John Nagle wrote: > On 11/7/2011 1:00 PM, OKB (not okblacke) wrote: >> I noticed this (Python 2.6.5 on Windows XP): > > CPython is slow. It's a naive interpreter. There's > almost no optimization during compilation. Try PyPy > or Shed Skin. PyPy is interesting, but I use various libraries that make use of C extension modules. I'm not going to compile them all myself, which is apparently what I would need to do for PyPy. PyPy or other implementations won't work for me unless they're completely drop-in replacements for the interpreter. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From tjreedy at udel.edu Thu Nov 10 14:38:58 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Nov 2011 14:38:58 -0500 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: On 11/10/2011 9:31 AM, Jerry Zhang wrote: > Unfortunately there is a difference between composition and > aggregation in my real word, and my application really care this > since it is trying to simulate this real world model, so my system > should track this difference accurately, otherwise the system may > not work well. > > For example, > a. the Cls_arm and Cls_body may be composition, but not aggregation. > My app must ensure that " one arm instance only live with one body > instance, if the body instance die, the arm instance must die. Create the arm as a private member '_arm' of body and make sure that no method of body passes out a reference to the arm. (In Python, outside code can still grab a reference to the private attribute, but that is a coding bug.) I will point out that in the real world, dead donor transplants are based on the fact the parts of the body do NOT have to die when the composition does. I will not be surprised if we someday see arm transplants. -- Terry Jan Reedy From ethan at stoneleaf.us Thu Nov 10 15:31:23 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 10 Nov 2011 12:31:23 -0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <1320941348.7601.57.camel@tim-laptop> Message-ID: <4EBC349B.5030209@stoneleaf.us> Benjamin Kaplan wrote: > You're still misunderstanding Python's object model. del does NOT > delete an object. It deletes a name. The only way for an object to be > deleted is for it to be inaccessible (there are no references to it, > or there are no reachable references to it). >>>> foo = object() >>>> bar = foo >>>> foo > >>>> bar > >>>> del foo >>>> bar > >>>> foo > > Traceback (most recent call last): > File "", line 1, in > foo > NameError: name 'foo' is not defined > > > There is no way to force the go_to_heaven method to delete the head > unless you can make sure that all other references to the head are > weak references. If you need strictly-enforced relationships, Python > is probably not the right language for the job- you'll be better off > with C++ or Java. Having said all that, you could do something like: class BodyPart(object): _alive = True def __nonzero__(self): return self._alive def die(self): self._alive = False class Head(BodyPart): "will contain things like Brain, Eyes, etc" size = 5 class Body(BodyPart): def __init__(self): self._head = Head() def go_to_heaven(self): self._head.die() self.die() John_Doe = Body() if John_Doe: print "John Doe is alive!" John_Doe.go_to_heaven() if John_Doe: print "uh oh - something wrong" else: print "John Doe is no longer with us" print "and his head is %s" % ('alive' if John_Doe._head else 'dead') From nathan.alexander.rice at gmail.com Thu Nov 10 15:35:22 2011 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 10 Nov 2011 15:35:22 -0500 Subject: Working with databases (ODBC and ORMs) in Python 3.2 In-Reply-To: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> References: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> Message-ID: For now, get started in Python 2.7. Write code with an eye to 3.x portability, and you will be fine. You probably won't see 3.x overtake 2.x for at least 3-4 years, and a decent amount of stuff is still 2.x only. Since it sounds like you are a windows/net shop, go ahead and use Iron Python. SQL Alchemy is your one stop shop. It is basically 3.x compatible, but see my previous statement about 3.x. I haven't used SQL Alchemy with SQL Server but honestly, SQL Alchemy is THE showcase python library -- I doubt you will run into any issues. Just google "sqlalchemy sql server", I'm sure there's a blog post explaining the specifics in detail. Nathan On Thu, Nov 10, 2011 at 1:56 PM, tkpmep at hotmail.com wrote: > We are in the process of trying to decide between Python 2.7 and 3.2 > with a view to making a 5-10 year commitment to the right platform, > and would appreciate some guidance on how best to connect to SQL > databases in 3.2. ceODBC 2.01 provides an ODBC driver for Python 3.2, > does anyone have experience using it? Also, are there any ORMs (object > relational mapper)s that work well with 3,2? > > Thanks in advance > > Thomas Philips > -- > http://mail.python.org/mailman/listinfo/python-list > From jeanpierreda at gmail.com Thu Nov 10 15:37:05 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 10 Nov 2011 15:37:05 -0500 Subject: all() is slow? In-Reply-To: <4EBC1B54.6000308@stoneleaf.us> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: > '--' not being allowed for a name has *nothing* to do with exec, and > everything to do with `--` not being a valid Python identifier. The only reason valid python identifiers come into it at all is because they get pasted into a string where identifiers would go, and that string is passed to exec(). So really, does it have "nothing" to do with exec? Or does your argument eventually boil down to the use of exec? > is more readable than Of course not. I do, however, think that it's conceivable that I'd want to key a namedtuple by an invalid identifier, and to do that, yes, I'd need to use getattr(). Devin On Thu, Nov 10, 2011 at 1:43 PM, Ethan Furman wrote: > Devin Jeanpierre wrote: >> >> Well. It reads fine in a certain sense, in that I can figure out >> what's going on (although I have some troubles figuring out why the >> heck certain things are in the code). The issue is that what's going >> on is otherworldly: this is not a Python pattern, this is not a normal >> approach. To me, that means it does not read fine. > > Certainly it's a Python pattern -- it's what you do to dynamically generate > code. > > >> The use of exec also results in (seemingly) arbitrary constraints on >> the input. Like, why can't "--" be a name? Because exec? Is there some >> other reason? > > '--' not being allowed for a name has *nothing* to do with exec, and > everything to do with `--` not being a valid Python identifier. > > >> '--' is a valid attribute name on virtually any object that supports >> attribute setting (e.g. function objects). Of course, you need to use >> setattr() and getattr(). Is this really the reason, or is it a >> limitation caused primarily by the usage of exec and the need to >> prevent code injection? If somebody added this feature later on, would >> this create a security vulnerability in certain projects that used >> namedtuple in certain ways? > > So you think > > ? ?somevar = getattr(my_named_tuple, '--') > > is more readable than > > ? ?somevar = my_named_tuple.spam > > ? > > ~Ethan~ > -- > http://mail.python.org/mailman/listinfo/python-list > From kwa at kuwata-lab.com Thu Nov 10 15:38:53 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Fri, 11 Nov 2011 05:38:53 +0900 Subject: easy_install doesn't install non-package *.py file In-Reply-To: <5611883.2927.1320916092038.JavaMail.geo-discussion-forums@yqni5> References: <5611883.2927.1320916092038.JavaMail.geo-discussion-forums@yqni5> Message-ID: On Thu, Nov 10, 2011 at 6:08 PM, Jonathan Hartley wrote: > Hey. I don't know the details, but your setup.py needs to use either the 'package_data' or the 'data_files' entry in the dict you pass to setup. These can specify files you want included in the sdist which aren't package files. > > There are many complications with using them though. One of them in particular (I don't remember which one) installs the files you specify in a different place depending on whether the user is installing the sdist from local files (python setup.py install) or using pip, so be sure to test both ways. 'package_data' is the solution for my trouble. Thank you very much, Jonathan. -- regards, makoto kuwata From ian.g.kelly at gmail.com Thu Nov 10 16:19:18 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 10 Nov 2011 14:19:18 -0700 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: On Thu, Nov 10, 2011 at 1:37 PM, Devin Jeanpierre wrote: > Of course not. I do, however, think that it's conceivable that I'd > want to key a namedtuple by an invalid identifier, and to do that, > yes, I'd need to use getattr(). Care to give a real use case? You could even go a step further and use, say, arbitrary ints as names if you're willing to give up getattr() and use "ob.__class__.__dict__[42].__get__(ob, ob.__class__)" everywhere instead. The fact that somebody might conceivably want to do this doesn't make it a good idea, though. I do find it a bit funny that you're criticizing a somewhat smelly implementation detail by complaining that it doesn't support an equally smelly feature. Cheers, Ian From ethan at stoneleaf.us Thu Nov 10 16:47:48 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 10 Nov 2011 13:47:48 -0800 Subject: all() is slow? In-Reply-To: References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: <4EBC4684.8070308@stoneleaf.us> Devin Jeanpierre wrote: > The only reason valid python identifiers come into it at all is > because they get pasted into a string where identifiers would go, and > that string is passed to exec(). > > So really, does it have "nothing" to do with exec? Or does your > argument eventually boil down to the use of exec? As I recall the big reason for namedtuples was things like sys.version_info[1] # behind door number one is... being much more readable as sys.version_info.minor In other words, the tuple offsets are named -- hence, namedtuples. And only valid identifiers will work. So, no, it has nothing to do with 'exec', and everything to do with the problem namedtuple was designed to solve. ~Ethan~ From rowen at uw.edu Thu Nov 10 16:52:17 2011 From: rowen at uw.edu (Russell E. Owen) Date: Thu, 10 Nov 2011 13:52:17 -0800 Subject: Decorator question: prefer class, but only function works Message-ID: I am trying to write a decorator that times an instance method and writes the results to a class member variable. For example: def timeMethod(func): def wrapper(self, *args, **keyArgs): t1 = time.time() res = func(self, *args, **keyArgs) duration = time.time() - t1 self.timings[func.__name__] = duration return res return wrapper This works, but I'm not very happy with the way self.timings is obtained. I first tried to write this as a class (for readability), and this did NOT work: class timeMethod(object): def __init__(self, func): self.func = func def __call__(self, *args, **keyArgs): t1 = time.time() res = self.func(*args, **keyArgs) duration = time.time() - t1 args[0].timings.set(self.func.__name__, duration) return res In the first case the wrapper is called as an unbound function, so it works. But in the second case the wrapper is called as a bound method -- thus args[0] is not func's class instance, and I can't get to the timings attribute. Unfortunately they are both pretty ugly. Is there a cleaner way to access the the instance of which func is a member? I was very disappointed it was not available when timeMethod was called/instantiated. -- Russell From kwa at kuwata-lab.com Thu Nov 10 16:54:02 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Fri, 11 Nov 2011 06:54:02 +0900 Subject: [ANN] pyKook 0.7.1 - task automation tool for Python, similar to Rake or Ant Message-ID: I have released pyKook 0.7.1.http://pypi.python.org/pypi/Kook/http://www.kuwata-lab.com/kook/http://www.kuwata-lab.com/kook/pykook-users-guide.html pyKook is a task automation tool for Python, similar to Rake or Ant. Bugfix in this release---------------------- * Fixed to include 'kook/books/*.py' into .egg file --regads,makoto kuwata On Sat, Nov 5, 2011 at 3:06 PM, Makoto Kuwata wrote: > Hi, > > I have released pyKook 0.7.0. > http://pypi.python.org/pypi/Kook/ > http://www.kuwata-lab.com/kook/ > http://www.kuwata-lab.com/kook/pykook-users-guide.html > > In this release, you can run commands on remote machines using ssh. > This is very useful to deploy your application. > > > pyKook Overview > --------------- > > pyKook is a task automation tool for Python, similar to Rake or Ant. > > (Kookbook.py): > > ? ?kookbook.default = 'build' > > ? ?## task > ? ?@recipe(None, ['hello']) > ? ?def build(c): > ? ? ? ?"""build all""" > ? ? ? ?pass > > ? ?## file > ? ?@recipe('hello', ['hello.o']) > ? ?def file_hello(c): > ? ? ? ?"""build 'hello' from 'hello.o'""" > ? ? ? ?system(c%'gcc -o $(product) $(ingred)') > > ? ?## rule > ? ?@recipe('*.o', ['$(1).c', '$(1).h']) > ? ?def file_o(c): > ? ? ? ?system(c%'gcc -c $(ingred)') > > > Command-line: > > ? ?bash> kk ? ? # or pykook > ? ?$ gcc -c hello.c > ? ?### *** hello.o (recipe=file_o) > ? ?$ gcc -c hello.c > ? ?### ** hello (recipe=file_hello) > ? ?$ gcc -o hello hello.o > ? ?### * build (recipe=build) > > See http://www.kuwata-lab.com/kook/pykook-users-guide.html for details. > > > Enhancements in this release > ---------------------------- > > * (EXPERIMENTAL!!) Remote command execution (ssh and sftp) is available. > ?This is very useful to deploy your application into servers. > > ?Ex (Kookbook.py):: > > ? ? ? ?from kook.remote import Remote > ? ? ? ?remote = Remote( > ? ? ? ? ? ?hosts ? ?= ['www1', 'www2', 'user3 at www3:10022'], > ? ? ? ? ? ?port ? ? = 22, > ? ? ? ? ? ?user ? ? = 'user1', > ? ? ? ? ? ?#password = None, ? ? ?# for login, '~/.ssh/id_rsa' and sudo > ? ? ? ? ? ?passphrase = None, ? ? # only for '~/.ssh/id_rsa' > ? ? ? ? ? ?sudo_password = 'xxx', # only for sudo command > ? ? ? ?) > > ? ? ? ?@recipe > ? ? ? ?@remotes(remote) > ? ? ? ?def hostinfo(c): > ? ? ? ? ? ?"""show hostname""" > ? ? ? ? ? ?ssh = c.ssh > ? ? ? ? ? ?ssh('hostname') ? ? ? ?# run command with ssh > ? ? ? ? ? ?ssh('whomai') ? ? ? ? ?# run command with ssh > ? ? ? ? ? ?ssh.sudo('whoami') ? ? # run command with sudo > > ? ? ? ?@recipe > ? ? ? ?@remotes(remote) > ? ? ? ?def exchange(c): > ? ? ? ? ? ?"""upload and download files""" > ? ? ? ? ? ?ssh = c.ssh > ? ? ? ? ? ?with ssh.pushd('work/apps'): > ? ? ? ? ? ? ? ?ssh.get('file.remote') ? ?# download a file > ? ? ? ? ? ? ? ?ssh.put('file.local') ? ? # upload a file > ? ? ? ? ? ? ? ?ssh.mget('remote.*') ? ? ?# download files > ? ? ? ? ? ? ? ?ssh.mput('local.*') ? ? ? # upload files > > ?Notice that you must configure ssh at first and confirm that > ?you can log into servers without typing password:: > > ? ? ? ?bash> ssh user1 at www1 > ? ? ? ?bash> ssh user1 at www2 > ? ? ? ?bash> ssh -p 10022 user3 at www3 > ? ? ? ?bash> kk hostinfo > ? ? ? ?### * showinfo (recipe=showinfo) > ? ? ? ?[user1 at www1]$ hostame > ? ? ? ?www1 > ? ? ? ?[user1 at www1]$ whoami > ? ? ? ?user1 > ? ? ? ?[user1 at www1]$ sudo whoami > ? ? ? ?root > ? ? ? ?[user2 at www2]$ hostame > ? ? ? ?www2 > ? ? ? ?[user2 at www2]$ whoami > ? ? ? ?user2 > ? ? ? ?[user2 at www2]$ sudo whoami > ? ? ? ?root > ? ? ? ?[user3 at www3]$ hostame > ? ? ? ?www3 > ? ? ? ?[user3 at www3]$ whami > ? ? ? ?user3 > ? ? ? ?[user3 at www3]$ sudo whoami > ? ? ? ?root > > ?Currently commands are executed sequencially (not in parallel). > > * (EXPERIMENTAL!!) Password object supported. > ?Password object asks you to enter password in prompt when necessary. > > ?Ex (Kookbook.py):: > > ? ? ? ?from kook.remote import Remote, Password > ? ? ? ?remote = Remote( > ? ? ? ? ? ?hosts ? ? ? ? = ['user1 at www1:22'], > ? ? ? ? ? ?#password ? ? = Password('login'), > ? ? ? ? ? ?passphrase ? ?= Password('~/.ssh/id_rsa'), > ? ? ? ? ? ?sudo_password = Password('sudo command') > ? ? ? ?) > ? ? ? ?# > ? ? ? ?@recipe > ? ? ? ?@remotes(remote) > ? ? ? ?def remote_test(c): > ? ? ? ? ? ?ssh = c.ssh > ? ? ? ? ? ?ssh.sudo('whoami') > > ?Output example:: > > ? ? ? ?bash> kk remote_test > ? ? ? ?### * remote_test (recipe=remote_test) > ? ? ? ?Password for ~/.ssh/id_rsa: > ? ? ? ?Password for sudo command: > ? ? ? ?[user1 at www1]$ sudo whoami > ? ? ? ?root > > ?It is easy to share password object. > > ?Ex (Kookbook.py):: > > ? ? ? ?from kook.remote import Remote, Password > ? ? ? ?passwd = Password() > ? ? ? ?remote = Remote( > ? ? ? ? ? ?hosts ? ? ? ? = ['user1 at www1:22'], > ? ? ? ? ? ?password ? ? ?= passwd, > ? ? ? ? ? ?passphrase ? ?= passwd, > ? ? ? ? ? ?sudo_password = passwd, > ? ? ? ?) > > > Changes in this release > ----------------------- > > * Category class is changed to convers all instance methods into staticmethods. > > ?Ex (Kookbook.py): > > ? ? ? ?class apache(Category): > ? ? ? ? ? ?@recipe > ? ? ? ? ? ?def start(c): > ? ? ? ? ? ? ? system('apachectl start') > > ? ? ? ?## start() is converted into staticmethod > ? ? ? ?assert type(apache.__dict__['start']) == staticmethod > ? ? ? ?from types import FunctionType > ? ? ? ?assert type(apache.start) == FuntionType > > ?This makes execution of other recipes in category easier:: > > ? ? ? ?class apache(Category): > ? ? ? ? ? ?@recipe > ? ? ? ? ? ?def start(c): > ? ? ? ? ? ? ? ... > ? ? ? ? ? ?@recipe > ? ? ? ? ? ?def stop(c): > ? ? ? ? ? ? ? ... > ? ? ? ? ? ?@recipe > ? ? ? ? ? ?def restart(c): > ? ? ? ? ? ? ? apache.start(c) ? ?# execute other recipe > ? ? ? ? ? ? ? apache.stop(c) ? ? # execute other recipe > > * (internal) kook.config.stdout and kook.config.stderr are removed. > > > > See http://www.kuwata-lab.com/kook/pykook-CHANGES.txt for details. > > > Have fun! > > -- > regards, > makoto kuwata > From ian.g.kelly at gmail.com Thu Nov 10 17:35:14 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 10 Nov 2011 15:35:14 -0700 Subject: Decorator question: prefer class, but only function works In-Reply-To: References: Message-ID: On Thu, Nov 10, 2011 at 2:52 PM, Russell E. Owen wrote: > I am trying to write a decorator that times an instance method and > writes the results to a class member variable. For example: > > def timeMethod(func): > ? ?def wrapper(self, *args, **keyArgs): > ? ? ? ?t1 = time.time() > ? ? ? ?res = func(self, *args, **keyArgs) > ? ? ? ?duration = time.time() - t1 > ? ? ? ?self.timings[func.__name__] = duration > ? ? ? ?return res > ? ?return wrapper > > This works, but I'm not very happy with the way self.timings is obtained. What do you feel is wrong with it? You probably should use sum(os.times()[:2]) instead, which (assuming your script is single-threaded) will more accurately count the actual CPU time spent in the function rather than real time, which could be quite different if the CPU is busy. Also, why do you need this? If you're just trying to evaluate the speed of your code, you should consider using a proper profiler or the timeit module. The former will tell you how much time is spent in each function, while the latter runs the code a large number of times in a loop, which gives you better precision for quick methods. > I first tried to write this as a class (for readability), and this did > NOT work: > > class timeMethod(object): > ? ?def __init__(self, func): > ? ? ? ?self.func = func > ? ?def __call__(self, *args, **keyArgs): > ? ? ? ?t1 = time.time() > ? ? ? ?res = self.func(*args, **keyArgs) > ? ? ? ?duration = time.time() - t1 > ? ? ? ?args[0].timings.set(self.func.__name__, duration) > ? ? ? ?return res > > In the first case the wrapper is called as an unbound function, so it > works. But in the second case the wrapper is called as a bound method -- > thus args[0] is not func's class instance, and I can't get to the > timings attribute. I prefer the function version myself, but to make this work you could add something like this (untested) to make your wrapper class a descriptor that tacks on the self argument: def __get__(self, instance, owner): from functools import partial if instance is None: return self return partial(self, instance) HTH, Ian From cra5370 at g.rit.edu Thu Nov 10 17:40:18 2011 From: cra5370 at g.rit.edu (CAMERON ALLEY) Date: Thu, 10 Nov 2011 14:40:18 -0800 (PST) Subject: No matter what I do, IDLE will not work... Message-ID: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Lemme preface this post by saying the following - I've taken my computer to the local IT office on RIT campus, asked a Computer Science professor specializing in Python, and posted my question on answers.yahoo.com (I don't know why I expected that to work...). I've also googled my problem multiple times and have not come up with anything newer than about 4 years ago. Okay, so the problem. I tried to install Python 2.7 about two months ago on both my laptop and iMac. Both are running up-to-date Mac OS X 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My laptop installed python 2.7 and ran it perfectly, first time. My desktop... not so much. How to recreate the issue on iMac - try to open IDLE, or in terminal, type the following: python import turtle turtle.up() This is what's displayed in terminal: COMPUTERNAME:~ USER$ python Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import turtle >>> turtle.up() CGColor with 1 components Abort trap COMPUTERNAME:~ USER$ It also pops up a Problem Report for Python Python quit unexpectedly. Click Reopen to open the application again. This report will be sent to Apple automatically. Problem Details and System Configuration Process: Python [33535] Path: /Library/Frameworks/Python.framework/Versions/2.7/ Resources/Python.app/Contents/MacOS/Python Identifier: org.python.python Version: 2.7.2 (2.7.2) Code Type: X86-64 (Native) Parent Process: bash [33532] Date/Time: 2011-11-10 17:31:58.424 -0500 OS Version: Mac OS X 10.6.8 (10K549) Report Version: 6 Interval Since Last Report: 1141508 sec Crashes Since Last Report: 2 Per-App Interval Since Last Report: 2 sec Per-App Crashes Since Last Report: 2 Anonymous UUID: C667A2E4-5530-4A3E-B6E3- B38E970458E5 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Application Specific Information: abort() called Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 libSystem.B.dylib 0x00007fff89bd40b6 __kill + 10 1 libSystem.B.dylib 0x00007fff89c749f6 abort + 83 2 Tcl 0x000000010067f9ef Tcl_Panic + 0 3 Tcl 0x000000010067fa91 Tcl_Panic + 162 4 Tk 0x00000001010ac5a7 TkpGetColor + 383 5 Tk 0x00000001010b9a2a TkpMenuInit + 156 6 Tk 0x000000010103c36c TkMenuInit + 88 7 Tk 0x00000001010bc68b - [TKApplication(TKMenus) _setupMenus] + 53 8 Tk 0x00000001010b6d27 - [TKApplication(TKInit) _setup:] + 56 9 Tk 0x00000001010b7260 TkpInit + 545 10 Tk 0x000000010102da26 Initialize + 1678 11 _tkinter.so 0x00000001005fccfb Tcl_AppInit + 75 12 _tkinter.so 0x00000001005fa153 Tkinter_Create + 915 13 org.python.python 0x00000001000c102d PyEval_EvalFrameEx + 22397 14 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 15 org.python.python 0x000000010003da80 function_call + 176 16 org.python.python 0x000000010000c5e2 PyObject_Call + 98 17 org.python.python 0x000000010001ebcb instancemethod_call + 363 18 org.python.python 0x000000010000c5e2 PyObject_Call + 98 19 org.python.python 0x00000001000be5f3 PyEval_EvalFrameEx + 11587 20 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 21 org.python.python 0x000000010003da80 function_call + 176 22 org.python.python 0x000000010000c5e2 PyObject_Call + 98 23 org.python.python 0x000000010001ebcb instancemethod_call + 363 24 org.python.python 0x000000010000c5e2 PyObject_Call + 98 25 org.python.python 0x00000001000ba5f7 PyEval_CallObjectWithKeywords + 87 26 org.python.python 0x0000000100021e5e PyInstance_New + 126 27 org.python.python 0x000000010000c5e2 PyObject_Call + 98 28 org.python.python 0x00000001000be5f3 PyEval_EvalFrameEx + 11587 29 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 30 org.python.python 0x000000010003da80 function_call + 176 31 org.python.python 0x000000010000c5e2 PyObject_Call + 98 32 org.python.python 0x000000010001ebcb instancemethod_call + 363 33 org.python.python 0x000000010000c5e2 PyObject_Call + 98 34 org.python.python 0x0000000100077a68 slot_tp_init + 88 35 org.python.python 0x0000000100074e65 type_call + 245 36 org.python.python 0x000000010000c5e2 PyObject_Call + 98 37 org.python.python 0x00000001000be5f3 PyEval_EvalFrameEx + 11587 38 org.python.python 0x00000001000c1ebe PyEval_EvalFrameEx + 26126 39 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 40 org.python.python 0x000000010003da80 function_call + 176 41 org.python.python 0x000000010000c5e2 PyObject_Call + 98 42 org.python.python 0x000000010001ebcb instancemethod_call + 363 43 org.python.python 0x000000010000c5e2 PyObject_Call + 98 44 org.python.python 0x0000000100077a68 slot_tp_init + 88 45 org.python.python 0x0000000100074e65 type_call + 245 46 org.python.python 0x000000010000c5e2 PyObject_Call + 98 47 org.python.python 0x00000001000be5f3 PyEval_EvalFrameEx + 11587 48 org.python.python 0x00000001000c1ebe PyEval_EvalFrameEx + 26126 49 org.python.python 0x00000001000c1ebe PyEval_EvalFrameEx + 26126 50 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 51 org.python.python 0x00000001000c2e46 PyEval_EvalCode + 54 52 org.python.python 0x00000001000e769c PyRun_InteractiveOneFlags + 380 53 org.python.python 0x00000001000e78fe PyRun_InteractiveLoopFlags + 78 54 org.python.python 0x00000001000e80e1 PyRun_AnyFileExFlags + 161 55 org.python.python 0x00000001000fe77c Py_Main + 2940 56 org.python.python 0x0000000100000f14 0x100000000 + 3860 Thread 1: Dispatch queue: com.apple.libdispatch-manager 0 libSystem.B.dylib 0x00007fff89b9ec0a kevent + 10 1 libSystem.B.dylib 0x00007fff89ba0add _dispatch_mgr_invoke + 154 2 libSystem.B.dylib 0x00007fff89ba07b4 _dispatch_queue_invoke + 185 3 libSystem.B.dylib 0x00007fff89ba02de _dispatch_worker_thread2 + 252 4 libSystem.B.dylib 0x00007fff89b9fc08 _pthread_wqthread + 353 5 libSystem.B.dylib 0x00007fff89b9faa5 start_wqthread + 13 Thread 2: 0 libSystem.B.dylib 0x00007fff89b9fa2a __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff89b9fe3c _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff89b9faa5 start_wqthread + 13 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000000000000 rbx: 0x00007fff7116b2f8 rcx: 0x00007fff5fbfc0e8 rdx: 0x0000000000000000 rdi: 0x00000000000082ff rsi: 0x0000000000000006 rbp: 0x00007fff5fbfc100 rsp: 0x00007fff5fbfc0e8 r8: 0x00007fff7116ea60 r9: 0x0000000000000000 r10: 0x00007fff89bd00fa r11: 0x0000000000000206 r12: 0x00000001006ecb20 r13: 0x0000000000000001 r14: 0x00000001010e1f77 r15: 0x0000000000000000 rip: 0x00007fff89bd40b6 rfl: 0x0000000000000206 cr2: 0x00000001135b54f3 ............... ............... ............... Model: iMac7,1, BootROM IM71.007A.B03, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.20f4 Graphics: ATI Radeon HD 2600 Pro, ATI,RadeonHD2600, PCIe, 256 MB Memory Module: global_name AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x88), Broadcom BCM43xx 1.0 (5.10.131.42.4) Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports Network Service: Built-in Ethernet, Ethernet, en0 Network Service: AirPort, AirPort, en1 Serial ATA Device: WDC WD3200AAJS-40RYA0, 298.09 GB Parallel ATA Device: OPTIARC DVD RW AD-5630A, 406.7 MB USB Device: Built-in iSight, 0x05ac (Apple Inc.), 0x8502, 0xfd400000 / 2 USB Device: Bluetooth USB Host Controller, 0x05ac (Apple Inc.), 0x8206, 0x1a100000 / 2 USB Device: Razer Naga, 0x1532, 0x0015, 0x1d100000 / 2 USB Device: IR Receiver, 0x05ac (Apple Inc.), 0x8242, 0x5d100000 / 2 I have tried copying every framework possible from the laptop to the iMac, done several reinstalls, and pretty much everything else I and the IT people on campus could think of to no avail. I'm pretty close to paying 20-30 bucks for a call to Apple and ask for help, because I'm tired of programming on a 13-inch screen while my 20-inch desktop is sitting right next to me just playing pandora... P.S. To those who might say "just use your imac as another monitor!" I can't. I've already asked Apple about that - the iMac is too old. HELP!!! From steve+comp.lang.python at pearwood.info Thu Nov 10 17:48:51 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 22:48:51 GMT Subject: The python implementation of the "relationships between classes". References: Message-ID: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Nov 2011 14:38:58 -0500, Terry Reedy wrote: > I will point out that in the real world, dead donor transplants are > based on the fact the parts of the body do NOT have to die when the > composition does. I will not be surprised if we someday see arm > transplants. And Guido's Time Machine strikes again... not only have there been arm transplants, but the first DOUBLE arm transplant was three years ago: http://www.dailymail.co.uk/health/article-1039587/Worlds-double-arm-transplant-man-gets-teenagers-limbs.html There have been successful *face* transplants. Nothing will surprise me now until they do a brain or head transplant. -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 10 17:56:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 22:56:41 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: <4ebc56a9$0$29970$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Nov 2011 14:19:18 -0700, Ian Kelly wrote: > On Thu, Nov 10, 2011 at 1:37 PM, Devin Jeanpierre > wrote: >> Of course not. I do, however, think that it's conceivable that I'd want >> to key a namedtuple by an invalid identifier, and to do that, yes, I'd >> need to use getattr(). > > Care to give a real use case? A common use-case is for accessing fields from an external data source, using the same field names. For example, you might have a database with a field called "class", or a CSV file with columns "0-10", "11-20", etc. Personally, I wouldn't bother using attributes to access fields, I'd use a dict, but some people think it's important to use attribute access. > You could even go a step further and use, > say, arbitrary ints as names if you're willing to give up getattr() and > use "ob.__class__.__dict__[42].__get__(ob, ob.__class__)" everywhere > instead. The fact that somebody might conceivably want to do this > doesn't make it a good idea, though. Obviously you would write a helper function rather than repeat that mess in-line everywhere. -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 10 18:07:23 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Nov 2011 23:07:23 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Nov 2011 15:37:05 -0500, Devin Jeanpierre wrote: >> '--' not being allowed for a name has *nothing* to do with exec, and >> everything to do with `--` not being a valid Python identifier. > > The only reason valid python identifiers come into it at all is because > they get pasted into a string where identifiers would go, and that > string is passed to exec(). That is patently untrue. If you were implementing namedtuple without exec, you would still (or at least you *should*) prevent the user from passing invalid identifiers as attribute names. What's the point of allowing attribute names you can't actually *use* as attribute names? You could remove the validation, allowing users to pass invalid field names, but that would be a lousy API. If you want field names that aren't valid identifiers, the right solution is a dict, not attributes. Here's a re-implementation using a metaclass: http://pastebin.com/AkG1gbGC and a diff from the Python bug tracker removing exec from namedtuple: http://bugs.python.org/file11608/new_namedtuples.diff You will notice both of them keep the field name validation. -- Steven From gordon at panix.com Thu Nov 10 18:11:23 2011 From: gordon at panix.com (John Gordon) Date: Thu, 10 Nov 2011 23:11:23 +0000 (UTC) Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: In <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df at e3g2000vbs.googlegroups.com> CAMERON ALLEY writes: > Okay, so the problem. I tried to install Python 2.7 about two months > ago on both my laptop and iMac. Both are running up-to-date Mac OS X > 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My > laptop installed python 2.7 and ran it perfectly, first time. My > desktop... not so much. IDLE is a separate program from Python itself, right? It's a GUI, or an IDE, or a shell or something. (Your session output doesn't seem to involve IDLE at all, so I am wondering why you mentioned it.) By typing "python" on your desktop, are you running plain Python, or are you running IDLE? Did you install Python and IDLE on the desktop machine separately? Did both installations succeed? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From ckaynor at zindagigames.com Thu Nov 10 18:14:23 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 10 Nov 2011 15:14:23 -0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 10, 2011 at 2:48 PM, Steven D'Aprano wrote: > On Thu, 10 Nov 2011 14:38:58 -0500, Terry Reedy wrote: > >> I will point out that in the real world, dead donor transplants are >> based on the fact the parts of the body do NOT have to die when the >> composition does. I will not be surprised if we someday see arm >> transplants. > > And Guido's Time Machine strikes again... not only have there been arm > transplants, but the first DOUBLE arm transplant was three years ago: > > http://www.dailymail.co.uk/health/article-1039587/Worlds-double-arm-transplant-man-gets-teenagers-limbs.html > > > There have been successful *face* transplants. Nothing will surprise me > now until they do a brain or head transplant. > Continuing this OT discussion, would it be a brain transplant, or a full body transplant? > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From cra5370 at g.rit.edu Thu Nov 10 18:27:49 2011 From: cra5370 at g.rit.edu (CAMERON ALLEY) Date: Thu, 10 Nov 2011 15:27:49 -0800 (PST) Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: <10a05a56-bd2a-4036-963a-b003453f58a9@cc2g2000vbb.googlegroups.com> On Nov 10, 6:11?pm, John Gordon wrote: > In <3c2688bd-4f87-4eb1-9b40-3cb536a2d... at e3g2000vbs.googlegroups.com> CAMERON ALLEY writes: > > > Okay, so the problem. I tried to install Python 2.7 about two months > > ago on both my laptop and iMac. Both are running up-to-date Mac OS X > > 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My > > laptop installed python 2.7 and ran it perfectly, first time. My > > desktop... not so much. > > IDLE is a separate program from Python itself, right? ?It's a GUI, or an > IDE, or a shell or something. > > (Your session output doesn't seem to involve IDLE at all, so I am > wondering why you mentioned it.) > > By typing "python" on your desktop, are you running plain Python, or > are you running IDLE? > > Did you install Python and IDLE on the desktop machine separately? > Did both installations succeed? > > -- > John Gordon ? ? ? ? ? ? ? ? ? A is for Amy, who fell down the stairs > gor... at panix.com ? ? ? ? ? ? ?B is for Basil, assaulted by bears > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -- Edward Gorey, "The Gashlycrumb Tinies" Thanks for the prompt response - yes, IDLE is a seperate program from python, however included in the Python 2.7.2 folder when downloaded from python.org. It's an IDE. I mentioned it, because when I try to open it, I also get an error report, so I figured it wouldn't be coincidence. I'm not typing "python" on my desktop, I'm typing it in terminal with no change of default directory. It runs plain python THROUGH terminal, and when I import turtle, and call turtle.up() it should in theory display an image of whatever I asked turtle to draw (in this case nothing, but the window should still pop up.) I installed two things on the desktop - python2.7.2 from python.org and the respective ActiveTK. Both succeeded. From rosuav at gmail.com Thu Nov 10 18:39:12 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Nov 2011 10:39:12 +1100 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor wrote: > Continuing this OT discussion, would it be a brain transplant, or a > full body transplant? It's just a rebinding. You don't move the body, you just bind your name to a new body. It's perfectly legal to have two names bound to one body (cf Dr Jekyll and Mr Hyde); if you murder Mr Hyde, you can still access the body through the other name. ChrisA From tjreedy at udel.edu Thu Nov 10 18:45:06 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Nov 2011 18:45:06 -0500 Subject: No matter what I do, IDLE will not work... In-Reply-To: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: On 11/10/2011 5:40 PM, CAMERON ALLEY wrote: > Okay, so the problem. I tried to install Python 2.7 about two months > ago on both my laptop and iMac. Both are running up-to-date Mac OS X > 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My > laptop installed python 2.7 and ran it perfectly, first time. My > desktop... not so much. You issue has nothing to do with IDLE and perhaps all to do with the buggy tcl/tk that comes with OSX 10.6. The Python module tkinter is the tk interface for Python (hence the name). The turtle module and IDLE both use tkinter. Searching all tracker issues (open and closed) for 'max tcl' turns up (among several others) http://bugs.python.org/issue10907 http://bugs.python.org/issue10969 http://bugs.python.org/issue12269 The latter 2, especially, might tell you what to do. -- Terry Jan Reedy From nad at acm.org Thu Nov 10 19:27:33 2011 From: nad at acm.org (Ned Deily) Date: Thu, 10 Nov 2011 16:27:33 -0800 Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: In article <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df at e3g2000vbs.googlegroups.com>, CAMERON ALLEY wrote: > Lemme preface this post by saying the following - I've taken my > computer to the local IT office on RIT campus, asked a Computer > Science professor specializing in Python, and posted my question on > answers.yahoo.com (I don't know why I expected that to work...). I've > also googled my problem multiple times and have not come up with > anything newer than about 4 years ago. > > Okay, so the problem. I tried to install Python 2.7 about two months > ago on both my laptop and iMac. Both are running up-to-date Mac OS X > 10.6, with 64-bit processors and around 2.4GHz speed and 2G of RAM. My > laptop installed python 2.7 and ran it perfectly, first time. My > desktop... not so much. > > How to recreate the issue on iMac - try to open IDLE, or in terminal, > type the following: > python > import turtle > turtle.up() > > This is what's displayed in terminal: > > COMPUTERNAME:~ USER$ python > Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import turtle > >>> turtle.up() > CGColor with 1 components > Abort trap > COMPUTERNAME:~ USER$ That's an odd one; I've not seen a crash like that before. From the crash dump, it is clear that the crash is happening inside of Tk, not Python, and, judging from the symbol names, it has something to do with menu initialization and colors. Try running the same Turtle test using the Apple-supplied Python 2.6 /usr/bin/python2.6 The Apple-supplied Tcl/Tk that it uses is known to have a number of serious problems and should not be used for serious work but, for me, it will bring up the turtle window in Tk without crashing. If it crashes the same way that 2.7.2 does, then that would be pretty solid corroboration that the problem is not in Python and more likely an issue with Tk. My first question would be do you have some third-party OS X app or extension installed that alters or colors menus? I know there used to be some popular ones out there in the past. If not, try opening System Preferences, select Displays, select Color, and check which display profile is selected. Perhaps try selecting another. And are you using a specific language in System Preferences -> Languages & Text -> Language? If that doesn't help, try running the following commands in a terminal window: source /Library/Frameworks/Tk.framework/Versions/8.5/tkConfig.sh echo $TK_VERSION $TK_PATCH_LEVEL You should see something like: 8.5 .11 If not, double check that you really are using the latest ActiveState Tcl/Tk 8.5 installer from here: http://www.activestate.com/activetcl/downloads Then try the failing turtle commads again and in the crash report, verify that /Library/Frameworks/Tk.framework/Versions/8.5/ appear as framework paths and *not* /System/Library/Frameworks/Tk.framework/Versions/8.5/. Try the following command which may not work if you don't have Xcode tools installed: otool -L $(python2.7 -c 'import _tkinter; print(_tkinter.__file__)') The paths reported again should start with /Library/Frameworks/Tk.framework and not /System/Library/Frameworks/Tk.framework. If none of that works, you could try installing the other python.org 2.7.2 installer, the 32-bit-only one, which is linked to the older Tcl/Tk 8.4, which uses Carbon interfaces rather than Cocoa, and see what happens with it. In any case, please report back what you find and, if necessary, open an issue on the Python bug tracker: http://bugs.python.org/ Thanks! -- Ned Deily, nad at acm.org From gagou7 at gmail.com Thu Nov 10 19:49:05 2011 From: gagou7 at gmail.com (Gagou Final Fantasy) Date: Thu, 10 Nov 2011 16:49:05 -0800 (PST) Subject: Solution Message-ID: A common problem when you generate executable on Windows 7 and deploy on Windows XP. According with the py2exe tutorial, you need include the MVC DLL. But the tutorial is old and the script given search only in one directory. Before, the directory contained all DLL and the manifest, but nowadays it contains only the DLL. You need to specify another directory for the manifest file. If you don't do that, you will have this kind of error: "this application has failed to start because the application configuration is incorrect" If you are on Windows 7 64 bits, you need the Microsoft Visual C runtime DLL. Don't forget the manifest that isn't in the same directory in Windows 7. You need to adapt the script like this: data_files = [("VC90", glob(r'C:\Windows\winsxs \x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\*.*')), ("VC90", glob(r'C:\Windows\winsxs\Manifests \x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest')) ] setup( data_files=data_files, console = [{'script': "C:\test\my_program.py"}], zipfile = None, ) Now you can deploy the "dist" directory that contains all files and dependencies. From jerry.scofield at gmail.com Thu Nov 10 20:30:41 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 09:30:41 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <1320941348.7601.57.camel@tim-laptop> Message-ID: 2011/11/11 Benjamin Kaplan > On Thu, Nov 10, 2011 at 1:06 PM, Jerry Zhang > wrote: > > > > > > I just did an example code to describe what i am looking for. > > > /*------------------------------------------------------------------------------------------------*/ > > # ... > > > > class Head: > > def __init__(self): > > self.size = 5 > > > > class Hat: > > def __init__(self): > > self.color = red > > def took_on(self, body): > > self.body = body > > def took_off(self, body): > > del self.body > > > > class Body: > > def __init__(self): > > self.head = Head() > > def take_on_hat(self, hat): > > self.hat = hat > > hat.take_on(self) > > def take_off_hat(self): > > hat.take_off(self) > > del self.hat > > def go_to_heaven(self): > > take_off_hat(self) > > del self.head > > > /*----------------------------------------------------------------------------------------------------------*/ > > > > In this example, Head and body are COMPOSITION, which means > > a. A head only live with one body, it can not live with other body. It > can > > not even live without body > > b. If the body go to die, the head also go to die. > > > > Body and Hat are aggregation, which means > > a. A hat live isolate with body, its life circle is isolate > > b. A hat only live with one body at a specific time, it can not live with > > two body(association would be more than one) > > > > So when the body die, the clean dead should include take_off Hat and del > > Head, otherwise, the code definition is not prciselly describing the > > relationship, which may cause a mess system, for example, a body has > dead, > > but one hat is still associated with a unreferenced body. > > A point on this issue, maybe python is smart that the take_off_hat(self) > is > > not needed in go_to_heaven() method(i am not sure yet), but the del > > self.head is sure needed, otherwise, we will have a no_body_head in our > > ZODB, that is extremely horrible, right? > > > > All of these points one, the four kinds of class relationship in UML > > precisely describe the real word, if the implementation is not precisely, > > you will have unexpected results. > > Of course, python may be smart to achieve such goal with less effort, > that > > is why i am asking for a code example for all of the four relationships. > > You're still misunderstanding Python's object model. del does NOT > delete an object. It deletes a name. The only way for an object to be > deleted is for it to be inaccessible (there are no references to it, > or there are no reachable references to it). > >>> foo = object() > >>> bar = foo > >>> foo > > >>> bar > > >>> del foo > >>> bar > > >>> foo > > Traceback (most recent call last): > File "", line 1, in > foo > NameError: name 'foo' is not defined > > > There is no way to force the go_to_heaven method to delete the head > unless you can make sure that all other references to the head are > weak references. If you need strictly-enforced relationships, Python > is probably not the right language for the job- you'll be better off > with C++ or Java. > Thanks for your reply, but i know your point on this before post this issue. "doing the the job of python's garbage collecting" system is not i want. What i am trying to do is a python implementation of the real "composition implementation". > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 20:34:30 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 09:34:30 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: Message-ID: 2011/11/11 Terry Reedy > On 11/10/2011 9:31 AM, Jerry Zhang wrote: > > Unfortunately there is a difference between composition and >> aggregation in my real word, and my application really care this >> since it is trying to simulate this real world model, so my system >> should track this difference accurately, otherwise the system may >> not work well. >> >> For example, >> a. the Cls_arm and Cls_body may be composition, but not aggregation. >> My app must ensure that " one arm instance only live with one body >> instance, if the body instance die, the arm instance must die. >> > > Create the arm as a private member '_arm' of body and make sure that no > method of body passes out a reference to the arm. (In Python, outside code > can still grab a reference to the private attribute, but that is a coding > bug.) > > I will point out that in the real world, dead donor transplants are based > on the fact the parts of the body do NOT have to die when the composition > does. I will not be surprised if we someday see arm transplants. Thanks for your comment. Actually you are mixing the concept. That is aggregation implementation, which also points out there is difference between aggregation and composition implementation. You already know that. > > > -- > Terry Jan Reedy > > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 20:43:33 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 09:43:33 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: 2011/11/11 Chris Angelico > On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor > wrote: > > Continuing this OT discussion, would it be a brain transplant, or a > > full body transplant? > > It's just a rebinding. You don't move the body, you just bind your > name to a new body. It's perfectly legal to have two names bound to > one body (cf Dr Jekyll and Mr Hyde); if you murder Mr Hyde, you can > still access the body through the other name. > > This is association, not aggregation or composition. You already realized that there is difference between these relationship(depending on your application requirement). and you are trying to tell me to code a aggregation and the composition with the same code. > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 20:54:22 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 09:54:22 +0800 Subject: Working with databases (ODBC and ORMs) in Python 3.2 In-Reply-To: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> References: <63858437-450a-4c09-979d-e35f335fd12a@cc2g2000vbb.googlegroups.com> Message-ID: 2011/11/11 tkpmep at hotmail.com > We are in the process of trying to decide between Python 2.7 and 3.2 > with a view to making a 5-10 year commitment to the right platform, > and would appreciate some guidance on how best to connect to SQL > databases in 3.2. ceODBC 2.01 provides an ODBC driver for Python 3.2, > does anyone have experience using it? Also, are there any ORMs (object > relational mapper)s that work well with 3,2? > I am in the similar situation as you. I abandon the MySQL + python3.x solution, since translate between fields of tables(SQL table) and objects attributes is destroying my OOP world. I choose the ZODB + python2.x solution, python3.x does not support ZODB yet. > > Thanks in advance > > Thomas Philips > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.scofield at gmail.com Thu Nov 10 21:42:45 2011 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Fri, 11 Nov 2011 10:42:45 +0800 Subject: The python implementation of the "relationships between classes". In-Reply-To: References: <4ebc54d3$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: A general description of my issue. To my understand, python's feature such as "name-reference-object" and "garbage collection" system did some of work for you, it makes your life easier, but you still need to add your explicit application in your code. For example, Composition implementation: you may need to do 5 job with C++, but only 2 job with python, the other 3 job is done by python implicitly. association implementation: You need 3 job with C++, but 1 with python. it seems python's object's lifecycle handling has reached this level, all you should do is just "associating and de-association". Here is exactly of my question, for composition, the best code may be you do 2 job explicitly, 3 job done by python implicitly. Code_Zero. 1 job(by you) + 4(by python) does NOT work. Code_one. 2 job(by you) + 3(by python) works. That is the best one. Code_two. 3 job( by you) + 2 (by python) works too, Code_three. 4 job(by you) + 1(by python) works too. Since i am not familiar with python yet, my code most likely would gets into Code_two or Code_three(Code_Zero is also possible for new guys like me), though they also work, they are bad code. What i am looking for is the Code_one example, i thought many OOP application designer may have met this issue, so a good Code_one reference is the best choice to start this project. 2011/11/11 Jerry Zhang > > > 2011/11/11 Chris Angelico > >> On Fri, Nov 11, 2011 at 10:14 AM, Chris Kaynor >> wrote: >> > Continuing this OT discussion, would it be a brain transplant, or a >> > full body transplant? >> >> It's just a rebinding. You don't move the body, you just bind your >> name to a new body. It's perfectly legal to have two names bound to >> one body (cf Dr Jekyll and Mr Hyde); if you murder Mr Hyde, you can >> still access the body through the other name. >> >> This is association, not aggregation or composition. You already realized > that there is difference between these relationship(depending on your > application requirement). and you are trying to tell me to code a > aggregation and the composition with the same code. > > > >> ChrisA >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From laurent.payot at gmail.com Thu Nov 10 23:03:05 2011 From: laurent.payot at gmail.com (Laurent) Date: Thu, 10 Nov 2011 20:03:05 -0800 (PST) Subject: property decorator and inheritance Message-ID: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> Hi. I couldn't find a way to overwrite a property declared using a decorator in a parent class. I can only do this if I use the "classic" property() method along with a getter function. Here's an example: #!/usr/bin/python3 class Polite: def __init__(self): self._greeting = "Hello" def get_greeting(self, suffix=", my dear."): return self._greeting + suffix greeting1 = property(get_greeting) @property def greeting2(self, suffix=", my dear."): return self._greeting + suffix class Rude(Polite): @property def greeting1(self): return self.get_greeting(suffix=", stupid.") @property def greeting2(self): return super().greeting2(suffix=", stupid.") p = Polite() r = Rude() print("p.greeting1 =", p.greeting1) print("p.greeting2 =", p.greeting2) print("r.greeting1 =", r.greeting1) print("r.greeting2 =", r.greeting2) # TypeError: 'str' object is not callable In this example I can easily overwrite the greeting1 property. But the inherited greeting2 doesn't seem to be a property but a mere string. I use a lot of properties decorators for simple properties in a project and I hate mixing them with a couple of "undecorated" properties that have to be overwritten in child classes. I tried using @greeting2.getter decorator and tricks like this but inheritance overwriting failed every time I used decorators. Can someone tell me a way to use decorator-declared properties that can be overwritten in child classes?? That would be nice. From cra5370 at g.rit.edu Thu Nov 10 23:25:55 2011 From: cra5370 at g.rit.edu (CAMERON ALLEY) Date: Thu, 10 Nov 2011 20:25:55 -0800 (PST) Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> Message-ID: <960bb3e9-a1b4-4495-9334-e1a35f9b40f5@e3g2000vbs.googlegroups.com> On Nov 10, 7:27?pm, Ned Deily wrote: > That's an odd one; I've not seen a crash like that before. ?From the > crash dump, it is clear that the crash is happening inside of Tk, not > Python, and, judging from the symbol names, it has something to do with > menu initialization and colors. > > Try running the same Turtle test using the Apple-supplied Python 2.6 > > ? /usr/bin/python2.6 > > The Apple-supplied Tcl/Tk that it uses is known to have a number of > serious problems and should not be used for serious work but, for me, it > will bring up the turtle window in Tk without crashing. ?If it crashes > the same way that 2.7.2 does, then that would be pretty solid > corroboration that the problem is not in Python and more likely an issue > with Tk. > > My first question would be do you have some third-party OS X app or > extension installed that alters or colors menus? ?I know there used to > be some popular ones out there in the past. ?If not, try opening System > Preferences, select Displays, select Color, and check which display > profile is selected. ?Perhaps try selecting another. ?And are you using > a specific language in System Preferences -> Languages & Text -> > Language? > > If that doesn't help, try running the following commands in a terminal > window: > > ? source /Library/Frameworks/Tk.framework/Versions/8.5/tkConfig.sh > ? echo $TK_VERSION $TK_PATCH_LEVEL > > You should see something like: > > ? 8.5 .11 > > If not, double check that you really are using the latest ActiveState > Tcl/Tk 8.5 installer from here: > > ?http://www.activestate.com/activetcl/downloads > > Then try the failing turtle commads again and in the crash report, > verify that ?/Library/Frameworks/Tk.framework/Versions/8.5/ appear as > framework paths and *not* > /System/Library/Frameworks/Tk.framework/Versions/8.5/. > > Try the following command which may not work if you don't have Xcode > tools installed: > > ? otool -L $(python2.7 -c 'import _tkinter; print(_tkinter.__file__)') > > The paths reported again should start with > /Library/Frameworks/Tk.framework and not > /System/Library/Frameworks/Tk.framework. > > If none of that works, you could try installing the other python.org > 2.7.2 installer, the 32-bit-only one, which is linked to the older > Tcl/Tk 8.4, which uses Carbon interfaces rather than Cocoa, and see what > happens with it. > > In any case, please report back what you find and, if necessary, open an > issue on the Python bug tracker: > ?http://bugs.python.org/ > > Thanks! > > -- > ?Ned Deily, > ?n... at acm.org Thanks so much for your incredibly in-depth response Ned! I've tried everything you've suggested and here's what I've found: The error occurs with the old python as well, but this MIGHT be because at some point during my many attempts at fixing this issue I could have deleted an old tk framework. It's funny you mention the theming - before snow leapord, I had leapord installed and used magnifique to theme my computer. I then upgraded to snow leapord and (like a novice) tried to use magnifique again only to find it crashed my system because it's not compatible with snow leapord. I did a reinstall of the OS though, and everything was fine. (this was about 2 years ago). I also recently installed Crystal Black on here, however I've been having this issue since before that. Other than that, no specific theming or color changing schemes come to mind... Oh actually there is something called Nocturne I used to use... Not sure if any of these could be affecting this. There's only one color profile, and no bizarre language being used. When I typed that in terminal, I saw 8.5.11 - this was the recommended activestate by python.org. Should I get 8.5.11? I tried the failing turtle commands, and in the crash report /Library/ Frameworks/Tk.framework/Versions/8.5/ only appears once (when doing a cmd+f search) and does not have /System/ in front of it. I'm going to try installing the 32 bit 2.7.2 installer next, and I'll be back to let you know how it goes. Thanks a lot! Cameron From jeanpierreda at gmail.com Thu Nov 10 23:35:32 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 10 Nov 2011 23:35:32 -0500 Subject: all() is slow? In-Reply-To: <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: > You will notice both of them keep the field name validation. There are lots of reasons for that to be the case. To me, the most likely one just seems to be that you don't want to remove more than necessary when changing the way something works under the hood -- both for compatibility reasons, and because you want the patch to get accepted and want the least number of objectionable changes. I guess you disagree. > That is patently untrue. If you were implementing namedtuple without > exec, you would still (or at least you *should*) prevent the user from > passing invalid identifiers as attribute names. What's the point of > allowing attribute names you can't actually *use* as attribute names? Then why doesn't Python do this anywhere else? e.g. why can I setattr(obj, 'a#b') when obj is any other mutable type? I just don't believe this reasoning is what happened, I suppose. And there's no way for you to convince me, or me to convince you, without R. Hettinger stepping in here and verifying one side of the story. This is subjective supposition, and that was supposed to be my most objective opposition. To go off on another tangent, though, I don't really understand how you guys can think this is reasonable, though. I don't get this philosophy of restricting inputs that would otherwise be perfectly valid, just for concerns that you have that users might not share -- especially when it's valid everywhere else that the concept shows up. It seems totally inconsistent with the attitude expressed above (by you!) towards exec, which is that it's ok to be cautious of something, but something else to forbid it outright. Of course, as I said before, I don't agree with core python developers on lots of things. I guess this is just another thing I just don't understand. Devin On Thu, Nov 10, 2011 at 6:07 PM, Steven D'Aprano wrote: > On Thu, 10 Nov 2011 15:37:05 -0500, Devin Jeanpierre wrote: > >>> '--' not being allowed for a name has *nothing* to do with exec, and >>> everything to do with `--` not being a valid Python identifier. >> >> The only reason valid python identifiers come into it at all is because >> they get pasted into a string where identifiers would go, and that >> string is passed to exec(). > > That is patently untrue. If you were implementing namedtuple without > exec, you would still (or at least you *should*) prevent the user from > passing invalid identifiers as attribute names. What's the point of > allowing attribute names you can't actually *use* as attribute names? > > You could remove the validation, allowing users to pass invalid field > names, but that would be a lousy API. If you want field names that aren't > valid identifiers, the right solution is a dict, not attributes. > > Here's a re-implementation using a metaclass: > > http://pastebin.com/AkG1gbGC > > and a diff from the Python bug tracker removing exec from namedtuple: > > http://bugs.python.org/file11608/new_namedtuples.diff > > > You will notice both of them keep the field name validation. > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From cra5370 at g.rit.edu Thu Nov 10 23:38:28 2011 From: cra5370 at g.rit.edu (CAMERON ALLEY) Date: Thu, 10 Nov 2011 20:38:28 -0800 (PST) Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> <960bb3e9-a1b4-4495-9334-e1a35f9b40f5@e3g2000vbs.googlegroups.com> Message-ID: <415ed0ec-65a5-41df-b81e-d74786c74073@s5g2000vbe.googlegroups.com> IT WORKS!!!! I didn't change my activestate, but I downloaded python 3.2.2 with the 32 bit installer and it works! Perfectally!! Sir you're my savior, thank you so much. I don't know how you did it but you just made my day :) Thanks again From wuwei23 at gmail.com Thu Nov 10 23:43:30 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 10 Nov 2011 20:43:30 -0800 (PST) Subject: property decorator and inheritance References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> Message-ID: On Nov 11, 2:03?pm, Laurent wrote: > Hi. I couldn't find a way to overwrite a property declared using a decorator in a parent class. > class Polite: > ? ? @property > ? ? def greeting2(self, suffix=", my dear."): > ? ? ? ? return self._greeting + suffix Here you set up greeting2 as a property. > class Rude(Polite): > ? ? @property > ? ? def greeting2(self): > ? ? ? ? return super().greeting2(suffix=", stupid.") Here you call Polite.greeting2 as a function. > print("r.greeting2 =", r.greeting2) # TypeError: 'str' object is not callable And here it's telling you that you're trying to treat a string - the output of Polite.greeting2 - as a function. The problem isn't that you cannot override greeting2 on Rude, it's that you can't treat properties as functions, so you can't pass in a new suffix. Instead, break the suffix out as a class attribute, then each descendent just needs to override that attribute: class Polite(object): suffix = ', my dear' @property def greeting(self): return 'Hello' + self.suffix class Rude(Polite): suffix = ', stupid' From laurent.payot at gmail.com Fri Nov 11 00:17:11 2011 From: laurent.payot at gmail.com (Laurent) Date: Thu, 10 Nov 2011 21:17:11 -0800 (PST) Subject: property decorator and inheritance In-Reply-To: References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> Message-ID: <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Yes using a separate class variable would transfer the problem to the class level. But adding 10 class variables if I have 10 properties would be ugly. Maybe I should reformulate the subject of this thread to "is there some python magic to pass parameters to decorator-declared properties ?" From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Nov 11 00:40:09 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Fri, 11 Nov 2011 05:40:09 +0000 (UTC) Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> Message-ID: Devin Jeanpierre wrote: >> '--' not being allowed for a name has *nothing* to do with exec, and >> everything to do with `--` not being a valid Python identifier. > > The only reason valid python identifiers come into it at all is > because they get pasted into a string where identifiers would go, and > that string is passed to exec(). The whole point of named tuples is to be able to access the members via attribute access as in "obj.attr". Things like "obj.--" are not valid Python syntax, so you can't use "--" as the name of a namedtuple field. Yes, you can do "getattr(obj, '--')" if you want, but it's quite reasonable for namedtuple to refrain from catering to that sort of perverse usage. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Nov 11 00:54:50 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Fri, 11 Nov 2011 05:54:50 +0000 (UTC) Subject: property decorator and inheritance References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Message-ID: Laurent wrote: > Yes using a separate class variable would transfer the problem to > the class level. But adding 10 class variables if I have 10 > properties would be ugly. Maybe I should reformulate the subject of > this thread to "is there some python magic to pass parameters to > decorator-declared properties ?" You can't have it both ways. If you want myObj.greeting2 # No parentheses To evaluate to a string (which it will if it's a property as you set it up), then it is necessarily true that myObj.greeting2(somearg) is going to try to call that string, which isn't going to work. If you need to be able to pass in parameters, then you need greeting2 to be a real method, not a property, and you need to get the greeting string with myObj.greeting2() # Parentheses All this is as it should be. The whole point of properties is that outside functions accessing them don't "know" that a getter function is called behind the scenes. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From clp2 at rebertia.com Fri Nov 11 00:58:21 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 10 Nov 2011 21:58:21 -0800 Subject: property decorator and inheritance In-Reply-To: <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Message-ID: On Thu, Nov 10, 2011 at 9:17 PM, Laurent wrote: > Yes using a separate class variable would transfer the problem to the class level. But adding 10 class variables if I have 10 properties would be ugly. Maybe I should reformulate the subject of this thread to "is there some python magic to pass parameters to decorator-declared properties ?" Apparently, yes: >>> class Foo(object): ... @property ... def bar(self, arg1='baz', arg2='qux'): ... return arg1, arg2 ... >>> Foo.bar.fget(Foo(), 'spam', 'eggs') ('spam', 'eggs') >>> Though I do not like this trick at all. Cheers, Chris -- http://rebertia.com From nad at acm.org Fri Nov 11 01:51:29 2011 From: nad at acm.org (Ned Deily) Date: Thu, 10 Nov 2011 22:51:29 -0800 Subject: No matter what I do, IDLE will not work... References: <3c2688bd-4f87-4eb1-9b40-3cb536a2d8df@e3g2000vbs.googlegroups.com> <960bb3e9-a1b4-4495-9334-e1a35f9b40f5@e3g2000vbs.googlegroups.com> <415ed0ec-65a5-41df-b81e-d74786c74073@s5g2000vbe.googlegroups.com> Message-ID: In article <415ed0ec-65a5-41df-b81e-d74786c74073 at s5g2000vbe.googlegroups.com>, CAMERON ALLEY wrote: > IT WORKS!!!! I didn't change my activestate, but I downloaded python > 3.2.2 with the 32 bit installer and it works! Perfectally!! > > Sir you're my savior, thank you so much. > > I don't know how you did it but you just made my day :) The 32-bit-installer links to the older Carbon-based Tcl/Tk 8.4 which is very different under the covers from the Tcl/Tk 8.5 used by the Apple-supplied Pythons and the python.org 64-bit installer. So there's *something* on your system that interferes with the Cocoa Tcl/Tk 8.5. If you want to pursue it, you might ask on the OS X Tcl mailing list. Good luck! http://dir.gmane.org/gmane.comp.lang.tcl.mac -- Ned Deily, nad at acm.org From laurent.payot at gmail.com Fri Nov 11 04:41:39 2011 From: laurent.payot at gmail.com (Laurent) Date: Fri, 11 Nov 2011 01:41:39 -0800 (PST) Subject: property decorator and inheritance In-Reply-To: References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <1571989.1239.1321004499667.JavaMail.geo-discussion-forums@yqpp12> Hey yes it's working that way. But I don't like it very much either. If as OKB said the whole point is that outside functions can't detect a property then I'm going to stick with the non-decorator way. Thanks anyway. From laurent.payot at gmail.com Fri Nov 11 04:41:39 2011 From: laurent.payot at gmail.com (Laurent) Date: Fri, 11 Nov 2011 01:41:39 -0800 (PST) Subject: property decorator and inheritance In-Reply-To: References: <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <1571989.1239.1321004499667.JavaMail.geo-discussion-forums@yqpp12> Hey yes it's working that way. But I don't like it very much either. If as OKB said the whole point is that outside functions can't detect a property then I'm going to stick with the non-decorator way. Thanks anyway. From ss27051980 at gmail.com Fri Nov 11 06:23:08 2011 From: ss27051980 at gmail.com (Suresh Sharma) Date: Fri, 11 Nov 2011 16:53:08 +0530 Subject: No matter what I do, IDLE will not work... Message-ID: <14bljwe7ffx67yysd6rfhxr9.1321010588320@email.android.com> Hello all, I need to know how to connect python 3.2 with mysql db i am newbie and appreciate your help to enhance my skills. I googled a lot but nothing came up Ned Deily wrote: >In article ><415ed0ec-65a5-41df-b81e-d74786c74073 at s5g2000vbe.googlegroups.com>, > CAMERON ALLEY wrote: >> IT WORKS!!!! I didn't change my activestate, but I downloaded python >> 3.2.2 with the 32 bit installer and it works! Perfectally!! >> >> Sir you're my savior, thank you so much. >> >> I don't know how you did it but you just made my day :) > >The 32-bit-installer links to the older Carbon-based Tcl/Tk 8.4 which is >very different under the covers from the Tcl/Tk 8.5 used by the >Apple-supplied Pythons and the python.org 64-bit installer. So there's >*something* on your system that interferes with the Cocoa Tcl/Tk 8.5. >If you want to pursue it, you might ask on the OS X Tcl mailing list. >Good luck! > >http://dir.gmane.org/gmane.comp.lang.tcl.mac > >-- > Ned Deily, > nad at acm.org > >-- >http://mail.python.org/mailman/listinfo/python-list From moura.mario at gmail.com Fri Nov 11 08:31:35 2011 From: moura.mario at gmail.com (macm) Date: Fri, 11 Nov 2011 05:31:35 -0800 (PST) Subject: Get keys from a dicionary Message-ID: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Hi Folks I pass a nested dictionary to a function. def Dicty( dict[k1][k2] ): print k1 print k2 There is a fast way (trick) to get k1 and k2 as string. Whithout loop all dict. Just it! Regards macm From joncle at googlemail.com Fri Nov 11 11:09:30 2011 From: joncle at googlemail.com (Jon Clements) Date: Fri, 11 Nov 2011 08:09:30 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> On Nov 11, 1:31?pm, macm wrote: > Hi Folks > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > ? ? ? ? print k1 > ? ? ? ? print k2 > > There is a fast way (trick) to get k1 and k2 as string. > > Whithout loop all dict. Just it! > > Regards > > macm I've tried to understand this, but can't tell if it's a question or statement, and even then can't tell what the question or statement is... Care to eloborate? From gordon at panix.com Fri Nov 11 11:25:19 2011 From: gordon at panix.com (John Gordon) Date: Fri, 11 Nov 2011 16:25:19 +0000 (UTC) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: In <8f5215a8-d08f-4355-a5a2-77fcaa32c92d at j10g2000vbe.googlegroups.com> macm writes: > I pass a nested dictionary to a function. > def Dicty( dict[k1][k2] ): That's not valid syntax. > print k1 > print k2 > There is a fast way (trick) to get k1 and k2 as string. Are you stating this can be done, or are you asking if it can be done? Questions usually end with a question mark. (Are you a native English speaker?) > Whithout loop all dict. Just it! print "%s" % x -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From moura.mario at gmail.com Fri Nov 11 11:33:27 2011 From: moura.mario at gmail.com (macm) Date: Fri, 11 Nov 2011 08:33:27 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> Message-ID: Hi Sorry ! My mistake. >>> myDict = {} >>> myDict['foo'] = {} >>> myDict['foo']['bar'] = 'works' ----- >>> def myFunction( MyObj ): ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] ['bar']) ... # I want inspect this MyObj ... # what keys was pass ... print MyObj.keys() ## WRONG ... # So What I want is : ... # return foo bar ---------------- >>> result = myFunction( myDict['foo']['bar'] ) >>> result Should print : ... foo bar Best Regards macm On Nov 11, 2:09?pm, Jon Clements wrote: > On Nov 11, 1:31?pm, macm wrote: > > > Hi Folks > > > I pass a nested dictionary to a function. > > > def Dicty( dict[k1][k2] ): > > ? ? ? ? print k1 > > ? ? ? ? print k2 > > > There is a fast way (trick) to get k1 and k2 as string. > > > Whithout loop all dict. Just it! > > > Regards > > > macm > > I've tried to understand this, but can't tell if it's a question or > statement, and even then can't tell what the question or statement > is... > > Care to eloborate? From moura.mario at gmail.com Fri Nov 11 11:36:55 2011 From: moura.mario at gmail.com (macm) Date: Fri, 11 Nov 2011 08:36:55 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: <09bf2935-00e6-4ecb-a5fe-71566155f995@q16g2000yqn.googlegroups.com> On Nov 11, 2:25?pm, John Gordon wrote: > In <8f5215a8-d08f-4355-a5a2-77fcaa32c... at j10g2000vbe.googlegroups.com> macm writes: > > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > > That's not valid syntax. > > > ? ?print k1 > > ? ?print k2 > > There is a fast way (trick) to get k1 and k2 as string. > > Are you stating this can be done, or are you asking if it can be done? > Questions usually end with a question mark. ?(Are you a native English > speaker?) > > > Whithout loop all dict. Just it! > > print "%s" % x > > -- > John Gordon ? ? ? ? ? ? ? ? ? A is for Amy, who fell down the stairs > gor... at panix.com ? ? ? ? ? ? ?B is for Basil, assaulted by bears > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -- Edward Gorey, "The Gashlycrumb Tinies" Hi John I am not a native English speaker. Sorry bad english. Regards macm From moura.mario at gmail.com Fri Nov 11 11:38:41 2011 From: moura.mario at gmail.com (macm) Date: Fri, 11 Nov 2011 08:38:41 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> Message-ID: Ok Sorry!! Sorry the noise!! def func(object): print "%s" % object Regards On Nov 11, 2:33?pm, macm wrote: > Hi > > Sorry ! My mistake. > > >>> myDict = {} > >>> myDict['foo'] = {} > >>> myDict['foo']['bar'] = 'works' > > ----- > > >>> def myFunction( MyObj ): > > ... ? ? # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] > ['bar']) > ... ? ? # I want inspect this MyObj > ... ? ? # what keys was pass > ... ? ? print MyObj.keys() ## WRONG > ... ? ? # So What I want is : > ... ? ? # return foo bar > > ---------------- > > >>> result = myFunction( myDict['foo']['bar'] ) > >>> result > > Should print : > > ... foo bar > > Best Regards > > macm > > On Nov 11, 2:09?pm, Jon Clements wrote: > > > > > > > > > On Nov 11, 1:31?pm, macm wrote: > > > > Hi Folks > > > > I pass a nested dictionary to a function. > > > > def Dicty( dict[k1][k2] ): > > > ? ? ? ? print k1 > > > ? ? ? ? print k2 > > > > There is a fast way (trick) to get k1 and k2 as string. > > > > Whithout loop all dict. Just it! > > > > Regards > > > > macm > > > I've tried to understand this, but can't tell if it's a question or > > statement, and even then can't tell what the question or statement > > is... > > > Care to eloborate? From d at davea.name Fri Nov 11 11:47:21 2011 From: d at davea.name (Dave Angel) Date: Fri, 11 Nov 2011 11:47:21 -0500 Subject: Get keys from a dicionary In-Reply-To: References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> Message-ID: <4EBD5199.3010507@davea.name> On 11/11/2011 11:33 AM, macm wrote: > Hi > > Sorry ! My mistake. > >>>> myDict = {} >>>> myDict['foo'] = {} >>>> myDict['foo']['bar'] = 'works' > ----- > >>>> def myFunction( MyObj ): > ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] > ['bar']) No, it's not. It's a string "works". There's no dictionary passed to myFunction(), so it cannot do what you ask, slow or fast. There are games you can play with introspection, but they are neither portable nor reliable. > ... # I want inspect this MyObj > ... # what keys was pass > ... print MyObj.keys() ## WRONG > ... # So What I want is : > ... # return foo bar > > ---------------- > >>>> result = myFunction( myDict['foo']['bar'] ) >>>> result > Should print : > > ... foo bar > > Best Regards > > macm Can you tell us the exact assignment, to see whether this is supposed to be a practical question, or a way to try to learn more about Python internals. -- DaveA From robin at reportlab.com Fri Nov 11 11:52:25 2011 From: robin at reportlab.com (Robin Becker) Date: Fri, 11 Nov 2011 16:52:25 +0000 Subject: bug python2.3+zipimport+ubuntu 10.04 amd_64 Message-ID: <4EBD52C9.7000408@chamonix.reportlab.co.uk> I'm trying to run some aged software on a new machine which runs Linux app2.reportlab.com 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC 2011 x86_64 GNU/Linux Ubuntu 10.04.2 LTS The software is required to use python 2.3 so first I've had some problems building python itself. Apparently to get rid of segfaults during the build we need the configure args to include BASECFLAGS=-U_FORTIFY_SOURCE that certainly fixes the python build errors. Now when we come to run the aged application we get this $ ./xxx.cgi Traceback (most recent call last): File "/home/rptlab/website/develop.reportlab.com/cgi-bin/xxx.cgi", line 7, in ? from fastwebapp import FastWebApp OverflowError: signed integer is greater than maximum this appears to be related to the use of a zip import. > sys.path.insert(0,os.path.join(os.getcwd(),"fastapp.zip")) > from fastwebapp import FastWebApp if we unpack the zip and remove the path insert the application appears to run fine. Googling appears to indicate that others have seen this error but on a different hardware and trying to remove optimizations from the python build has had variable success. Anyone had any real success with this problem? The last version of the test machinery ran 32bit freebsd and we had no problems on that hardware. -- Robin Becker From gordon at panix.com Fri Nov 11 12:28:52 2011 From: gordon at panix.com (John Gordon) Date: Fri, 11 Nov 2011 17:28:52 +0000 (UTC) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> <1e00ab59-8fc5-4bd7-b52c-f98f3b0b4473@x8g2000yql.googlegroups.com> Message-ID: In macm writes: > >>> myDict = {} > >>> myDict['foo'] = {} > >>> myDict['foo']['bar'] = 'works' > ----- > >>> def myFunction( MyObj ): > ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] > ['bar']) > ... # I want inspect this MyObj > ... # what keys was pass > ... print MyObj.keys() ## WRONG > ... # So What I want is : > ... # return foo bar > ---------------- > >>> result = myFunction( myDict['foo']['bar'] ) > >>> result > Should print : > ... foo bar I don't think there's a simple way to do what you want. You could inspect the whole dictionary to find the keys that map to a given value, like so: def MyFunction(mydict, x): for k1 in mydict: for k2 in mydict[k1]: if mydict[k1][k2] == x: return "%s %s" % (k1, k2) >>> print MyFunction(myDict, 'works') >>> foo bar -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From gelonida at gmail.com Fri Nov 11 12:29:59 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 18:29:59 +0100 Subject: Get keys from a dicionary In-Reply-To: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: On 11/11/2011 02:31 PM, macm wrote: > Hi Folks > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > print k1 > print k2 > > There is a fast way (trick) to get k1 and k2 as string. > > Whithout loop all dict. Just it! > > Regards > > macm I think the answer to the question, that I don't really understand is: No. This cannot be done. However we might help you if you copy a COMPLETE standalone example of your problem and if you try to re-explain once more what exactly you want to do. Ideally tell us even why you want to do it. Perhaps the solution is something completely different. Below I'm doing some guess work: nesteddict = { 'a': { 'A' : 'value1 a_A' , 'B' : 'value2 a_B' }, 'b': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, 'c': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, } def mymagic_function(value): print 'the value is <%s>', value print('There is really no way knowing from where this value came\n' 'except if you tell me in which dictionary you are supposed\n' 'and if I just try to find all matches\n' ) value = nesteddict['a']['B'] mymagic_function(value) From robin at reportlab.com Fri Nov 11 12:44:22 2011 From: robin at reportlab.com (Robin Becker) Date: Fri, 11 Nov 2011 17:44:22 +0000 Subject: bug python2.3+zipimport+ubuntu 10.04 amd_64 In-Reply-To: <4EBD52C9.7000408@chamonix.reportlab.co.uk> References: <4EBD52C9.7000408@chamonix.reportlab.co.uk> Message-ID: <4EBD5EF6.3040203@chamonix.reportlab.co.uk> OK it seems there's a bug in zipimport.c that was fixed in 2.4. I copied across the 2.4 version and after removing a single new error check the rebuilt python 2.3 works fine. There was supposed to be a patch here http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/zipimport.c?r1=1.16&r2=1.17 but it's a dead link. -- Robin Becker On 11/11/2011 16:52, Robin Becker wrote: > I'm trying to run some aged software on a new machine which runs > > Linux app2.reportlab.com 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC > 2011 x86_64 GNU/Linux Ubuntu 10.04.2 LTS > > The software is required to use python 2.3 so first I've had some problems > building python itself. Apparently to get rid of segfaults during the build we > need the configure args to include > > BASECFLAGS=-U_FORTIFY_SOURCE > > that certainly fixes the python build errors. > > Now when we come to run the aged application we get this > > $ ./xxx.cgi > Traceback (most recent call last): > File "/home/rptlab/website/develop.reportlab.com/cgi-bin/xxx.cgi", line 7, in ? > from fastwebapp import FastWebApp > OverflowError: signed integer is greater than maximum > > > this appears to be related to the use of a zip import. > > > sys.path.insert(0,os.path.join(os.getcwd(),"fastapp.zip")) > > from fastwebapp import FastWebApp > > if we unpack the zip and remove the path insert the application appears to run > fine. > > Googling appears to indicate that others have seen this error but on a different > hardware and trying to remove optimizations from the python build has had > variable success. > > Anyone had any real success with this problem? The last version of the test > machinery ran 32bit freebsd and we had no problems on that hardware. From robin at reportlab.com Fri Nov 11 12:44:22 2011 From: robin at reportlab.com (Robin Becker) Date: Fri, 11 Nov 2011 17:44:22 +0000 Subject: bug python2.3+zipimport+ubuntu 10.04 amd_64 In-Reply-To: <4EBD52C9.7000408@chamonix.reportlab.co.uk> References: <4EBD52C9.7000408@chamonix.reportlab.co.uk> Message-ID: <4EBD5EF6.3040203@chamonix.reportlab.co.uk> OK it seems there's a bug in zipimport.c that was fixed in 2.4. I copied across the 2.4 version and after removing a single new error check the rebuilt python 2.3 works fine. There was supposed to be a patch here http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/zipimport.c?r1=1.16&r2=1.17 but it's a dead link. -- Robin Becker On 11/11/2011 16:52, Robin Becker wrote: > I'm trying to run some aged software on a new machine which runs > > Linux app2.reportlab.com 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC > 2011 x86_64 GNU/Linux Ubuntu 10.04.2 LTS > > The software is required to use python 2.3 so first I've had some problems > building python itself. Apparently to get rid of segfaults during the build we > need the configure args to include > > BASECFLAGS=-U_FORTIFY_SOURCE > > that certainly fixes the python build errors. > > Now when we come to run the aged application we get this > > $ ./xxx.cgi > Traceback (most recent call last): > File "/home/rptlab/website/develop.reportlab.com/cgi-bin/xxx.cgi", line 7, in ? > from fastwebapp import FastWebApp > OverflowError: signed integer is greater than maximum > > > this appears to be related to the use of a zip import. > > > sys.path.insert(0,os.path.join(os.getcwd(),"fastapp.zip")) > > from fastwebapp import FastWebApp > > if we unpack the zip and remove the path insert the application appears to run > fine. > > Googling appears to indicate that others have seen this error but on a different > hardware and trying to remove optimizations from the python build has had > variable success. > > Anyone had any real success with this problem? The last version of the test > machinery ran 32bit freebsd and we had no problems on that hardware. From gelonida at gmail.com Fri Nov 11 12:45:00 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 18:45:00 +0100 Subject: Get keys from a dicionary In-Reply-To: References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: On 11/11/2011 02:31 PM, macm wrote: > > Hi Folks > > > > I pass a nested dictionary to a function. > > > > def Dicty( dict[k1][k2] ): > > print k1 > > print k2 > > > > There is a fast way (trick) to get k1 and k2 as string. > > > > Whithout loop all dict. Just it! > > > > Regards > > > > macm If my guessing was correct is this what you are looking for? nesteddict = { 'a': { 'A' : 'value1 a_A' , 'B' : 'value2 a_B' }, 'b': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, 'c': { 'A' : 'value3 b_A' , 'B' : 'value4 b_B' }, } def find_in_nested_dict(adict, avalue): results = [] for key1, sub_dict in adict.items(): for key2, value in sub_dict.items(): if avalue == value: results.append( (key1, key2) ) return results def mk_lookup(adict): lookup = {} for key1, sub_dict in adict.items(): for key2, value in sub_dict.items(): entry = lookup.get(value, []) entry.append( (key1, key2) ) lookup[value] = entry return lookup # good if you just want so search one value value = nesteddict['c']['B'] keys = find_in_nested_dict(nesteddict, value) print "found %r in %r" % (value, keys) # if you need many lookups perhaps better to 'precalculate a # 'reversed' dict lookup = mk_lookup(nesteddict) keys = lookup[value] print "found %r in %r" % (value, keys) From gordon at panix.com Fri Nov 11 12:51:57 2011 From: gordon at panix.com (John Gordon) Date: Fri, 11 Nov 2011 17:51:57 +0000 (UTC) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: In Gelonida N writes: > > > There is a fast way (trick) to get k1 and k2 as string. > > > > > > Whithout loop all dict. Just it! > If my guessing was correct is this what you are looking for? He said he didn't want to loop over the dict contents. Without that, I don't think there's an answer for him. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From sky378 at gmail.com Fri Nov 11 13:44:27 2011 From: sky378 at gmail.com (Arjuna Software) Date: Fri, 11 Nov 2011 10:44:27 -0800 (PST) Subject: SMS api for python References: <07a0a94e-2b96-4149-a18c-2cf2836351d8@f3g2000pri.googlegroups.com> Message-ID: <23f5c569-a131-4ffc-9ded-b07bcaffc83b@n38g2000yqm.googlegroups.com> On Oct 21, 3:10?am, Pankaj wrote: > I want to make an api that would recieve the SMS text from the user > and process it then send the result back to the use. Is there any api > that I can use to do this?? Send SMS Text messages using SMS API: http://www.txtimpact.com/sms-gateway-api.asp TxtImpact SMS API, you have access to powerful text messaging functionality for integration into your existing and new web and enterprise applications. Text Messaging API or SMS API can enable application to receive and send SMS text messages utilising txtimpact advanced SMS gateway API or Text Messaging API. TxtImpact provides simple HTTP interface for clients to send and receive messages from mobile phone users. HTTP POST can be used in all modern programming languages including ASP, ASP.NET, C++, C#, PHP, VB, VB.NET, command lines, SSH & cURL. From sky378 at gmail.com Fri Nov 11 13:44:41 2011 From: sky378 at gmail.com (Arjuna Software) Date: Fri, 11 Nov 2011 10:44:41 -0800 (PST) Subject: SMS api for python References: <07a0a94e-2b96-4149-a18c-2cf2836351d8@f3g2000pri.googlegroups.com> Message-ID: <5f098d1d-adf3-4c4c-83eb-31a7621a8e21@o13g2000vbo.googlegroups.com> On Oct 21, 4:41?am, Chris Rebert wrote: > On Fri, Oct 21, 2011 at 12:10 AM, Pankaj wrote: > > I want to make an api that would recieve the SMS text from the user > > and process it then send the result back to the use. Is there any api > > that I can use to do this?? > > There would seem to be several options:http://pypi.python.org/pypi?%3Aaction=search&term=sms&submit=search > > Cheers, > Chris Send SMS Text messages using SMS API: http://www.txtimpact.com/sms-gateway-api.asp TxtImpact SMS API, you have access to powerful text messaging functionality for integration into your existing and new web and enterprise applications. Text Messaging API or SMS API can enable application to receive and send SMS text messages utilising txtimpact advanced SMS gateway API or Text Messaging API. TxtImpact provides simple HTTP interface for clients to send and receive messages from mobile phone users. HTTP POST can be used in all modern programming languages including ASP, ASP.NET, C++, C#, PHP, VB, VB.NET, command lines, SSH & cURL. From ethan at stoneleaf.us Fri Nov 11 13:47:13 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 11 Nov 2011 10:47:13 -0800 Subject: How to dynamically create a derived type in the Python C-API Message-ID: <4EBD6DB1.2070600@stoneleaf.us> Asking on behalf of Sven Marnach: --------------------------------------------------------------------- Assume we have the type Noddy as defined in the tutorial on writing C extension modules for Python. Now we want to create a derived type, overwriting only the __new__() method of Noddy. Currently I use the following approach (error checking stripped for readability): PyTypeObject *BrownNoddyType = (PyTypeObject *)PyType_Type.tp_alloc(&PyType_Type, 0); BrownNoddyType->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; BrownNoddyType->tp_name = "noddy.BrownNoddy"; BrownNoddyType->tp_doc = "BrownNoddy objects"; BrownNoddyType->tp_base = &NoddyType; BrownNoddyType->tp_new = BrownNoddy_new; PyType_Ready(BrownNoddyType); This works, but I'm not sure if it is The Right Way To Do It. I would have expected that I have to set the Py_TPFLAGS_HEAPTYPE flag, too, because I dynamically allocate the type object on the heap, but doing so leads to a segfault in the interpreter. I also thought about explicitly calling type() using PyObject_Call() or similar, but I discarded the idea. I would need to wrap the function BrownNoddy_new() in a Python function object and create a dictionary mapping __new__ to this function object, which seems silly. What is the best way to go about this? Is my approach correct? Is there an interface function I missed? --------------------------------------------------------------------- ~Ethan~ From cv33cv33cv33 at gmail.com Fri Nov 11 14:04:06 2011 From: cv33cv33cv33 at gmail.com (BV) Date: Fri, 11 Nov 2011 11:04:06 -0800 (PST) Subject: DISCOVER ISLAM - THE FASTEST GROWING RELIGION IN THE WORLD !!!!!!!!!!!! Message-ID: DISCOVER ISLAM - THE FASTEST GROWING RELIGION IN THE WORLD Did you read about Islam from it,s original sources? Is the information about Islam that published at International Media is correct ? Excuse me!! Would you stop for a moment?! O...man...Haven't you thought-one day- about yourself ? Who has made it? Have you seen a design which hasn't a designer ?! Have you seen a wonderful,delicate work without a worker ?! It's you and the whole universe!.. Who has made them all ?!! You know who ?.. It's "ALLAH",prise be to him. Just think for a moment. How are you going to be after death ?! Can you believe that this exact system of the universe and all of these great creation will end in in nothing...just after death! Have you thought, for a second, How to save your soul from Allah's punishment?! Haven't you thought about what is the right religion?! Read ... and think deeply before you answer.. It is religion of Islam. It is the religion that Mohammad-peace upon him- the last prophet, had been sent by. It is the religion that the right Bible- which is not distorted-has preached. Just have a look at The Bible of (Bernaba). Don't be emstional. Be rational and judge.. Just look..listen...compare..and then judge and say your word. We advise you visiting : http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://www.chatislamonline.org/ar http://www.dar-us-salam.com http://youtubeislam.com From ethan at stoneleaf.us Fri Nov 11 15:08:13 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 11 Nov 2011 12:08:13 -0800 Subject: How to dynamically create a derived type in the Python C-API In-Reply-To: <4EBD6DB1.2070600@stoneleaf.us> References: <4EBD6DB1.2070600@stoneleaf.us> Message-ID: <4EBD80AD.5020201@stoneleaf.us> The question is on StackOverflow if you want to answer it directly: http://stackoverflow.com/questions/8066438 ~Ethan~ From gelonida at gmail.com Fri Nov 11 15:27:49 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 21:27:49 +0100 Subject: resolving module name conflicts. Message-ID: Hi, I got some code. - This code contains a package named tests - there are at least 100 references in different python files importing from above mentioned tests package. - the code also imports pytz at one place I get following warning message: /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: Module tests was already imported from /home/user/myproject/tests/__init__.pyc, but /usr/lib/python2.6/dist-packages is being added to sys.path from pkg_resources import resource_stream Is there any way to tell pytz to import it's own tests package and tell the rest of the code to import the other? Python version is 2.6.5 Thanks in advance for any suggestion. From emile at fenx.com Fri Nov 11 16:31:03 2011 From: emile at fenx.com (Emile van Sebille) Date: Fri, 11 Nov 2011 13:31:03 -0800 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On 11/11/2011 12:27 PM Gelonida N said... > > > Hi, > > I got some code. > - This code contains a package named tests > - there are at least 100 references in different python files > importing from above mentioned tests package. > - the code also imports pytz at one place > > I get following warning message: > > /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: > Module tests was already imported from > /home/user/myproject/tests/__init__.pyc, but > /usr/lib/python2.6/dist-packages is being added to sys.path > from pkg_resources import resource_stream > > > Is there any way to tell pytz to import it's own tests package and tell > the rest of the code to import the other? > > Python version is 2.6.5 > > > Thanks in advance for any suggestion. Start with http://docs.python.org/whatsnew/2.5.html#pep-328-absolute-and-relative-imports Emile From ericsnowcurrently at gmail.com Fri Nov 11 16:34:07 2011 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Fri, 11 Nov 2011 14:34:07 -0700 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 1:27 PM, Gelonida N wrote: > > > Hi, > > I got some code. > - This code contains a package named tests > - there are at least 100 references in different python files > ? ? ? ?importing from above mentioned tests package. > - the code also imports pytz at one place > > I get following warning message: > > /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: > Module tests was already imported from > /home/user/myproject/tests/__init__.pyc, but > /usr/lib/python2.6/dist-packages is being added to sys.path > ?from pkg_resources import resource_stream > > > Is there any way to tell pytz to import it's own tests package and tell > the rest of the code to import the other? This sounds like a problem caused by using relative imports. Each import statement is made relative to some top-level module. The import mechanism looks for it in the directories in sys.path (first match wins). The interpreter adds the empty string to the beginning of sys.path, by default. The empty string represents the current working directory. An import referencing a module found there is called a relative import. Solution: If possible, make sure each of your import statements is absolute (the top-level module is in one of the [legit] sys.path directories). Then do one of the following: * sys.path.remove(''); * call your script from a directory without any python modules in it; * call os.chdir(...) in your script to change CWD before making any imports. This also means you shouldn't "test" your modules by just running them as scripts. Instead, write a separate test script that imports each of your modules absolutely (and maybe actually test them too ). As of 2.5, Python's from...import syntax supports explicit relative imports, with absolute imports as the default (sort of). In 2.5 and 2.6 the feature is optional, so you must add "from __future__ import absolute_import" to enable it. See PEP 328[1]. The relative import syntax means that you don't have to hard-code the name of the packages in your imports, which helps with brevity and portability. The problem is that the empty string is still added to the from of sys.path. I'm going to have to find out more about that one. Hope that helps. -eric [1] http://www.python.org/dev/peps/pep-0328/ > > Python version is 2.6.5 > > > Thanks in advance for any suggestion. > > > > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From ericsnowcurrently at gmail.com Fri Nov 11 16:51:12 2011 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Fri, 11 Nov 2011 14:51:12 -0700 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 2:34 PM, Eric Snow wrote: > The problem is that the empty string is still added to the from of > sys.path. ?I'm going to have to find out more about that one. Okay, don't know how I missed it but the docs for sys.path[1] spell it out: "As initialized upon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to search modules in the current directory first." So if you run a module as a script, that empty string will be added to sys.path and all imports will first check the directory you were in when you ran Python... -eric [1] http://docs.python.org/library/sys.html#sys.path From miki.tebeka at gmail.com Fri Nov 11 17:07:16 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Fri, 11 Nov 2011 14:07:16 -0800 (PST) Subject: SMS api for python In-Reply-To: <07a0a94e-2b96-4149-a18c-2cf2836351d8@f3g2000pri.googlegroups.com> References: <07a0a94e-2b96-4149-a18c-2cf2836351d8@f3g2000pri.googlegroups.com> Message-ID: <5179557.1489.1321049236343.JavaMail.geo-discussion-forums@prgt40> You can use services like https://www.tropo.com/home.jsp or http://www.twilio.com/ From gelonida at gmail.com Fri Nov 11 17:11:38 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 23:11:38 +0100 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On 11/11/2011 10:31 PM, Emile van Sebille wrote: > On 11/11/2011 12:27 PM Gelonida N said... >> Is there any way to tell pytz to import it's own tests package and tell >> the rest of the code to import the other? >> >> Python version is 2.6.5 >> >> >> Thanks in advance for any suggestion. > > Start with > http://docs.python.org/whatsnew/2.5.html#pep-328-absolute-and-relative-imports > Thanks Emile / Thanks Eric The from __future__ import absolute_import is already used in most files of this project but only used for importing some other modules. All the 'tests' modules are still imported with absolute imports. 'tests' is also a top level module of the existing project and being imported from top level scripts (scripts in the python path directory) Relative imports don't work on top level scripts as it would raise > ValueError: Attempted relative import in non-pack This is a legacy project where many tools assume a certain directory structure and where I'm kind of hesitant to move files into differnt directories. What's probably the most painless fix would be - force only certain (older?) versions of pytz (which don't expose this issue) to be installed. - rename tests into something else. However this will affect loads of files. and I had to check whether there are no shell scripts or custom executables, which depend on 'tests' being called 'tests' Pytz is only imported by one module, so I wondered if there were any tricks to 'change sys.path' prior to importing pytz and to make sure, that the projects 'tests' package and pytz's 'tests' package could co-exist. What I wondered is whether there was a way to fix the issue without having to 'touch' all the 100+ import statements spread over the project. In the long term I suggest, that the project's code will be changed such that it will no more conflict with pytz's tests package. (either rename the package, transform it to a sub package, ... ???), From gelonida at gmail.com Fri Nov 11 17:47:14 2011 From: gelonida at gmail.com (Gelonida N) Date: Fri, 11 Nov 2011 23:47:14 +0100 Subject: resolving module name conflicts. In-Reply-To: References: Message-ID: On 11/11/2011 10:51 PM, Eric Snow wrote: > On Fri, Nov 11, 2011 at 2:34 PM, Eric Snow wrote: > > So if you run a module as a script, that empty string will be added to > sys.path and all imports will first check the directory you were in > when you ran Python... > Yes that's normal (and for the rest of the code required behaviour :-( ) The top level directory is no module, but just contains scripts requiring, that '.' is in the python path. In fact theissue can be reproduced rather easily. Everything seems to work, but I don't like having this warning. Especially as the project contains a hook, which raises an alert as soon as any module tries to send data to stderr. (reporting this as potential failure of the application) $ mkdir newdir $ cd newdir $ python -c 'import pytz ; print pytz.VERSION' 2010b $ mkdir tests $ echo print 1234 > tests/__init__.py $ python -c 'import pytz ; print pytz.VERSION' 2010b $ python -c 'import tests ; import pytz ; print pytz.VERSION ; reload(tests)' 1234 /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: Module tests was already imported from tests/__init__.pyc, but /usr/lib/python2.6/dist-packages is being added to sys.path from pkg_resources import resource_stream 2010b 1234 $ What does pytz want to tell me ????? From jehugaleahsa at gmail.com Fri Nov 11 19:20:09 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Fri, 11 Nov 2011 16:20:09 -0800 (PST) Subject: xmlrpclib date times and a trailing Z Message-ID: <7d3e9e96-687f-4081-990e-46b7bb386925@d5g2000yqg.googlegroups.com> I am trying to connect to Marchex's a call tracking software using xmlrpclib. I was able to get some code working, but I ran into a problem dealing with transfering datetimes. When I construct a xmlrpclib.ServerProxy, I am setting the use_datetime flag to indicate that I want to automatically convert back and forth between date times in the datetime library. I have a working version that doesn't use this flag, and I have to convert from the xmlrpclib.DateTime type to the datetime.datetime type manually, via string parsing. The thing is, Marchex's API returns date's with a trailing Z, after the time component. I did some research and this is supposed to be an indicator that UTC was used. However, it doesn't seem like the xmlrpclib likes it very much. It looks like it is using this code internally: time.strptime(data, "%Y %m%dT%H:%M:%S") This code doesn't look like it handles time zones at all. I guess, is there a way to tell xmlrpclib to include time zones when parsing date times? Thanks, Travis Parks From steve+comp.lang.python at pearwood.info Fri Nov 11 19:42:46 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Nov 2011 00:42:46 GMT Subject: resolving module name conflicts. References: Message-ID: <4ebdc106$0$29970$c3e8da3$5496439d@news.astraweb.com> On Fri, 11 Nov 2011 23:11:38 +0100, Gelonida N wrote: > Pytz is only imported by one module, so I wondered if there were any > tricks to 'change sys.path' prior to importing pytz sys.path is just a list of paths. You can import the sys module and manipulate it any way you like. -- Steven From steve+comp.lang.python at pearwood.info Fri Nov 11 20:18:26 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Nov 2011 01:18:26 GMT Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Nov 2011 23:35:32 -0500, Devin Jeanpierre wrote: >> That is patently untrue. If you were implementing namedtuple without >> exec, you would still (or at least you *should*) prevent the user from >> passing invalid identifiers as attribute names. What's the point of >> allowing attribute names you can't actually *use* as attribute names? > > Then why doesn't Python do this anywhere else? e.g. why can I > setattr(obj, 'a#b') when obj is any other mutable type? That is implementation-specific behaviour and not documented behaviour for Python. If you try it in (say) IronPython or Jython, you may or may not see the same behaviour. The docs for getattr state: getattr(x, 'foobar') is equivalent to x.foobar which implies that getattr(x, 'a!b') should be equivalent to x.a!b which will give a syntax error. The fact that CPython does less validation is arguably a bug and not something that you should rely on: it is *not* a promise of the language. As Terry Reedy already mentioned, the namespace used in classes and instances are ordinary generic dicts, which don't perform any name validation. That's done for speed. Other implementations may use namespaces that enforce legal names for attributes, and __slots__ already does: >>> class X(object): ... __slots__ = ['a', 'b!'] ... Traceback (most recent call last): File "", line 1, in TypeError: Error when calling the metaclass bases __slots__ must be identifiers [...] > To go off on another tangent, though, I don't really understand how you > guys can think this is reasonable, though. I don't get this philosophy > of restricting inputs that would otherwise be perfectly valid But they aren't perfectly valid. They are invalid inputs. Just because getattr and setattr in CPython allow you to create attributes with invalid names doesn't mean that everything else should be equally as slack. -- Steven From gelonida at gmail.com Fri Nov 11 20:46:49 2011 From: gelonida at gmail.com (Gelonida N) Date: Sat, 12 Nov 2011 02:46:49 +0100 Subject: resolving module name conflicts. (pytz version 2010b) In-Reply-To: <4ebdc106$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <4ebdc106$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/12/2011 01:42 AM, Steven D'Aprano wrote: > On Fri, 11 Nov 2011 23:11:38 +0100, Gelonida N wrote: > >> Pytz is only imported by one module, so I wondered if there were any >> tricks to 'change sys.path' prior to importing pytz > > sys.path is just a list of paths. You can import the sys module and > manipulate it any way you like. > Hmmm, I think I didn't express myself really well. What I meant is: Is there any successful trick, which can get rid of my warning. I don't feel comfortable with warnings, that I don't understand. Please see below example (which can easily be reproduced, if you have the right (wrong) version of pytz. $ mkdir newdir $ cd newdir $ python -c 'import pytz ; print pytz.VERSION' 2010b $ mkdir tests $ echo print 1234 > tests/__init__.py $ python -c 'import pytz ; print pytz.VERSION' 2010b $ python -c 'import tests ; import pytz ; print pytz.VERSION ; reload(tests)' 1234 /usr/lib/python2.6/dist-packages/pytz/__init__.py:32: UserWarning: Module tests was already imported from tests/__init__.pyc, but /usr/lib/python2.6/dist-packages is being added to sys.path from pkg_resources import resource_stream 2010b 1234 $ What does pytz want to tell me ????? From candide at free.invalid Sat Nov 12 06:56:17 2011 From: candide at free.invalid (candide) Date: Sat, 12 Nov 2011 12:56:17 +0100 Subject: Use and usefulness of the as syntax Message-ID: <4ebe5ee6$0$25872$426a74cc@news.free.fr> First, could you confirm the following syntax import foo as f equivalent to import foo f = foo Now, I was wondering about the usefulness in everyday programming of the as syntax within an import statement. Here are some instances retrieved from real code of such a syntax import numpy as np import math as _math import pickle as pickle -- In the first case, the syntax is motivated by brevity need, isn't it ? -- The second case seems to be rather widespread and causes math attribute to be private but I don't figure out why this matters. -- In the last case, I can see no point So what is the pragmatics of the as syntax ? Thanks for clarification. From rosuav at gmail.com Sat Nov 12 07:27:56 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Nov 2011 23:27:56 +1100 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: On Sat, Nov 12, 2011 at 10:56 PM, candide wrote: > import foo as f > > equivalent to > > import foo > f = foo > Not quite, it's closer to: import foo f = foo del foo without the fiddling around. What the 'import... as' syntax gives is a way to separate the thing loaded from the name bound to. Suppose importing were done thus: foo = import("foo.py") Then you'd have a standard convention of always importing into a variable of the same name (loose terminology, but you know what I mean), with the option of importing as something completely different. The "import... as" syntax gives the same power, without forcing you to repeat yourself in the common situation. ChrisA From arnodel at gmail.com Sat Nov 12 07:29:26 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Sat, 12 Nov 2011 12:29:26 +0000 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: On 12 November 2011 11:56, candide wrote: > First, could you confirm the following syntax > > import foo as f > > equivalent to > > import foo > f = foo > > > > Now, I was wondering about the usefulness in everyday programming of the as > syntax within an import statement. Here are some instances retrieved from > real code of such a syntax > > import numpy as np > > import math as _math > > import pickle as pickle > > > -- In the first case, the syntax is motivated by brevity need, isn't it ? Correct! > -- The second case seems to be rather widespread and causes math attribute > to be private but I don't figure out why this matters. This way math doesn't get bound in the global namespace when doing "from module import *" > -- In the last case, I can see no point Neither can I > So what is the pragmatics of the as syntax ? It can also help when you want to import two different modules with the same name. -- Arnaud From python.list at tim.thechases.com Sat Nov 12 07:43:06 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 12 Nov 2011 06:43:06 -0600 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: <4EBE69DA.2060501@tim.thechases.com> On 11/12/11 05:56, candide wrote: > First, could you confirm the following syntax > > import foo as f > > equivalent to > > import foo > f = foo and the issuing "del foo" > Now, I was wondering about the usefulness in everyday programming of the > as syntax within an import statement. Here are some instances retrieved > from real code of such a syntax > > import numpy as np > import math as _math > import pickle as pickle > > -- In the last case, I can see no point Without context, I'm guessing the last one is merely keeping parity in a block that reads: try: import cPickle as pickle except ImportError: import pickle as pickle > So what is the pragmatics of the as syntax ? The most common use-case I see is your first: to shorten a frequently-used namespace. I do this frequently with import Tkinter as tk which makes it obvious where things are coming from. I hate trying to track down variable-names if one did something like from Tkinter import * The second big use case I see regularly is the full example (above): try to import a faster/native module that shares an interface with a pure-python implementation. However in the above, the "import pickle as pickle" is a uselessly redundant. -tkc From rafadurancastaneda at gmail.com Sat Nov 12 07:48:04 2011 From: rafadurancastaneda at gmail.com (=?ISO-8859-1?Q?Rafael_Dur=E1n_Casta=F1eda?=) Date: Sat, 12 Nov 2011 13:48:04 +0100 Subject: Use and usefulness of the as syntax In-Reply-To: <4EBE69DA.2060501@tim.thechases.com> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> <4EBE69DA.2060501@tim.thechases.com> Message-ID: <4EBE6B04.6040900@gmail.com> El 12/11/11 13:43, Tim Chase escribi?: > I hate trying to track down variable-names if one did something like > > from Tkinter import * > +1 From tim.wintle at teamrubber.com Sat Nov 12 08:03:29 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Sat, 12 Nov 2011 13:03:29 +0000 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: <1321103009.23677.32.camel@tim-laptop> On Sat, 2011-11-12 at 12:56 +0100, candide wrote: > So what is the pragmatics of the as syntax ? Another case: try: import json except: import simplejson as json (same goes for several modules where the C implementation may or may not be available) Tim From mwilson at the-wire.com Sat Nov 12 08:59:40 2011 From: mwilson at the-wire.com (Mel Wilson) Date: Sat, 12 Nov 2011 08:59:40 -0500 Subject: Use and usefulness of the as syntax References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: candide wrote: > First, could you confirm the following syntax > > import foo as f > > equivalent to > > import foo > f = foo > > > > Now, I was wondering about the usefulness in everyday programming of the > as syntax within an import statement. [ ... ] It gives you an out in a case like Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> os = 5 # number of 'o's >>> import os as opsys >>> os 5 >>> opsys (This is an instance of what arnaud mentioned.) Mel. From numansenm at gmail.com Sat Nov 12 09:31:27 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Sat, 12 Nov 2011 06:31:27 -0800 (PST) Subject: soma cheapest. Lowest prices for soma online. Buy soma online without no prescription. Buy cheap soma next day no prescription! Message-ID: soma cheapest. Lowest prices for soma online. Buy soma online without no prescription. Buy cheap soma next day no prescription! soma BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=soma <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=soma http://buypharmasite.com/?q=Buy+online+soma http://buypharmasite.com/?q=Buy+order+soma http://buypharmasite.com/?q=Buy+soma http://buypharmasite.com/?q=Buy+cheap+soma http://buypharmasite.com/?q=Order+soma http://buypharmasite.com/?q=Online+soma cheap online pharmacy soma soma online saturday delivery online soma and fedex cheap order prescription soma cheap soma by money order buy soma from mexico online soma no prescription usa fedex shipping overnight delivery soma buy soma online without a prescription and no membership no prescription needed soma cod shipped soma not expensive order prescription soma soma money order soma without a perscription online buy soma soma fedex buy no online prescription soma soma pharmacies accepting cod delivery soma online consultant online pharmacy fedex cod soma buy soma no scams soma c.o.d overnight delivery buy soma no prescription cod overnight soma order soma online doctors buy soma on line no prescription soma no prescription usa fedex shipping soma online uk watson brand soma medicine online soma order soma samples sent buy soma no prescription order soma without a prescription soma no prescription drug cheap online order soma get soma over the counter online order soma next day buy soma no perscription cod real soma fed ex soma no prescription cod does cv/ pharmacy carry soma no prescription cod soma cheap soma without rx soma online health insurance lead buy soma online with overnight delivery soma no rx fed ex buy soma without a perscription lowest prices for soma online buy soma paypal online without prescription cheap non prescription soma soma ups soma for cheap buy soma no visa online without prescription cheapest soma cash on delivery soma order a prepaid mastercard buy online soma purchase soma mail order soma without a prescription online with overnight delivery soma from canada buy soma with no rx overnight delivery of soma with no prescription cash on delivery soma no rx soma by cod buy soma over the counter cod overnight overnight soma order soma without prescription from us pharmacy cheap soma free fedex shipping order soma over the counter where to buy soma no prescription no fees only soma free consult cod delivery soma soma no prescription soma online overnight delivery cod order soma over the counter fedex soma saturday delivery buy soma money order soma without prescription mexico buy cheap soma without prescription soma non prescription for next day delivery soma ups delivery only buy soma usa cod soma with next day delivery no prescriptions needed for soma cheap soma overnight prescription soma cheap soma overnight delivery soma non prescription fedex overnight free order soma no creditcard buy cheap soma no Prescription buy soma over the counter fedex soma no doctor presribe needed cheap watson soma online cheap discount soma buy soma without a prescription online cheapest soma free delivery buy soma online overseas buy soma over the counter online not expensive soma next day shipping order soma cod next day delivery soma cheap soma buy in UK soma next day cod fedex soma to buy cheap order soma next day soma soma overnight no consult cheap watson soma no prescription needed soma without prescription medications overnight delivery of soma with no perscription buy soma.com soma cod next day delivery buy cheap discount online soma buy soma drug soma overnight delivery cheap overnight delivery of soma in US no prescription needed purchase soma free next day airsoma on line cheap soma without a prescription soma cheap cod soma buy no prepaid cheap soma next day buy soma cod accepted online pharmacies soma saturday delivery buy soma pay pal soma shipped on saturday soma pharmacy cod saturday delivery buy online soma prescriptions free fedex delivery soma soma without prescription cash on delivery buy discount soma soma overnight cheap best soma online pill images of soma soma U.P.S SHIPPING COD soma cod pharmacy buy soma online cod soma cod overnight delivery soma no rx overnight buy soma overnight COD online pharmacy soma cod order soma insurance soma cash delivery cod buy soma cheap cod no rx online pharmacy soma sale nextday soma soma pill soma online ordering soma online without prescription soma no script needed cod overnight how to buy soma online without a prescription cheap soma without prescription cheap soma online no rx saturday delivery order soma over the counter for sale soma next day delivery cod order soma online without prescription no prescription next day delivery soma overnight soma C.O.D soma without prescription soma discount fedex no prescription buy soma amex soma online next day soma shipped with no prescription soma online cheap cheap soma without prescription overnight delivery buy soma over the counter for sale soma no prescriptions needed cod soma fed ex cheap overnight delivery of soma free prescription soma free shipping not expensive legal soma for sale buy soma cod soma for saturday soma price cash for soma cash on delivery soma soma without a prescription and cod delivery buying soma without a prescription order soma no rx buy soma without rx soma cheapest buy soma online pharmacy buy cheap soma overnight delivery soma and online pharmacy soma next day soma drug no prescription where can i buy soma no prescription soma with saturday delivery soma online overnight soma no prescription worldwide buy cheap soma cod ordering soma online Buy soma overnight shipping soma overnight US delivery cheap real soma for sale soma no prescriptions needed COD buy soma no prescription needed soma no prescription overnight cod delivery cheap soma cash on delivery no prescription required for soma order soma c.o.d. not expensive soma prescriptions soma online Cash on Delivery buy soma overnight delivery soma online without presciption buy soma prescription online no prescription saturday delivery soma where to buy cheap soma no prescription soma wo get soma over the counter fedex soma with no rx and free shipping order soma over the counter cod overnight From numansenm at gmail.com Sat Nov 12 09:33:31 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Sat, 12 Nov 2011 06:33:31 -0800 (PST) Subject: Alprazolam Without Prescription Shipped Overnight Express | Buy Alprazolam Without A Prescription Or Membership Message-ID: <3f5a13c5-6149-4006-a6e0-5a7fb3c4e894@p16g2000yqd.googlegroups.com> Alprazolam cheapest. Lowest prices for Alprazolam online. Buy Alprazolam online without no prescription. Buy cheap Alprazolam next day no prescription! Alprazolam BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=Alprazolam <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=Alprazolam http://buypharmasite.com/?q=Buy+online+Alprazolam http://buypharmasite.com/?q=Buy+order+Alprazolam http://buypharmasite.com/?q=Buy+Alprazolam http://buypharmasite.com/?q=Buy+cheap+Alprazolam http://buypharmasite.com/?q=Order+Alprazolam http://buypharmasite.com/?q=Online+Alprazolam cheap online pharmacy Alprazolam Alprazolam online saturday delivery online Alprazolam and fedex cheap order prescription Alprazolam cheap Alprazolam by money order buy Alprazolam from mexico online Alprazolam no prescription usa fedex shipping overnight delivery Alprazolam buy Alprazolam online without a prescription and no membership no prescription needed Alprazolam cod shipped Alprazolam not expensive order prescription Alprazolam Alprazolam money order Alprazolam without a perscription online buy Alprazolam Alprazolam fedex buy no online prescription Alprazolam Alprazolam pharmacies accepting cod delivery Alprazolam online consultant online pharmacy fedex cod Alprazolam buy Alprazolam no scams Alprazolam c.o.d overnight delivery buy Alprazolam no prescription cod overnight Alprazolam order Alprazolam online doctors buy Alprazolam on line no prescription Alprazolam no prescription usa fedex shipping Alprazolam online uk watson brand Alprazolam medicine online Alprazolam order Alprazolam samples sent buy Alprazolam no prescription order Alprazolam without a prescription Alprazolam no prescription drug cheap online order Alprazolam get Alprazolam over the counter online order Alprazolam next day buy Alprazolam no perscription cod real Alprazolam fed ex Alprazolam no prescription cod does cv/ pharmacy carry Alprazolam no prescription cod Alprazolam cheap Alprazolam without rx Alprazolam online health insurance lead buy Alprazolam online with overnight delivery Alprazolam no rx fed ex buy Alprazolam without a perscription lowest prices for Alprazolam online buy Alprazolam paypal online without prescription cheap non prescription Alprazolam Alprazolam ups Alprazolam for cheap buy Alprazolam no visa online without prescription cheapest Alprazolam cash on delivery Alprazolam order a prepaid mastercard buy online Alprazolam purchase Alprazolam mail order Alprazolam without a prescription online with overnight delivery Alprazolam from canada buy Alprazolam with no rx overnight delivery of Alprazolam with no prescription cash on delivery Alprazolam no rx Alprazolam by cod buy Alprazolam over the counter cod overnight overnight Alprazolam order Alprazolam without prescription from us pharmacy cheap Alprazolam free fedex shipping order Alprazolam over the counter where to buy Alprazolam no prescription no fees only Alprazolam free consult cod delivery Alprazolam Alprazolam no prescription Alprazolam online overnight delivery cod order Alprazolam over the counter fedex Alprazolam saturday delivery buy Alprazolam money order Alprazolam without prescription mexico buy cheap Alprazolam without prescription Alprazolam non prescription for next day delivery Alprazolam ups delivery only buy Alprazolam usa cod Alprazolam with next day delivery no prescriptions needed for Alprazolam cheap Alprazolam overnight prescription Alprazolam cheap Alprazolam overnight delivery Alprazolam non prescription fedex overnight free order Alprazolam no creditcard buy cheap Alprazolam no Prescription buy Alprazolam over the counter fedex Alprazolam no doctor presribe needed cheap watson Alprazolam online cheap discount Alprazolam buy Alprazolam without a prescription online cheapest Alprazolam free delivery buy Alprazolam online overseas buy Alprazolam over the counter online not expensive Alprazolam next day shipping order Alprazolam cod next day delivery Alprazolam cheap Alprazolam buy in UK Alprazolam next day cod fedex Alprazolam to buy cheap order Alprazolam next day Alprazolam Alprazolam overnight no consult cheap watson Alprazolam no prescription needed Alprazolam without prescription medications overnight delivery of Alprazolam with no perscription buy Alprazolam.com Alprazolam cod next day delivery buy cheap discount online Alprazolam buy Alprazolam drug Alprazolam overnight delivery cheap overnight delivery of Alprazolam in US no prescription needed purchase Alprazolam free next day airAlprazolam on line cheap Alprazolam without a prescription Alprazolam cheap cod Alprazolam buy no prepaid cheap Alprazolam next day buy Alprazolam cod accepted online pharmacies Alprazolam saturday delivery buy Alprazolam pay pal Alprazolam shipped on saturday Alprazolam pharmacy cod saturday delivery buy online Alprazolam prescriptions free fedex delivery Alprazolam Alprazolam without prescription cash on delivery buy discount Alprazolam Alprazolam overnight cheap best Alprazolam online pill images of Alprazolam Alprazolam U.P.S SHIPPING COD Alprazolam cod pharmacy buy Alprazolam online cod Alprazolam cod overnight delivery Alprazolam no rx overnight buy Alprazolam overnight COD online pharmacy Alprazolam cod order Alprazolam insurance Alprazolam cash delivery cod buy Alprazolam cheap cod no rx online pharmacy Alprazolam sale nextday Alprazolam Alprazolam pill Alprazolam online ordering Alprazolam online without prescription Alprazolam no script needed cod overnight how to buy Alprazolam online without a prescription cheap Alprazolam without prescription cheap Alprazolam online no rx saturday delivery order Alprazolam over the counter for sale Alprazolam next day delivery cod order Alprazolam online without prescription no prescription next day delivery Alprazolam overnight Alprazolam C.O.D Alprazolam without prescription Alprazolam discount fedex no prescription buy Alprazolam amex Alprazolam online next day Alprazolam shipped with no prescription Alprazolam online cheap cheap Alprazolam without prescription overnight delivery buy Alprazolam over the counter for sale Alprazolam no prescriptions needed cod Alprazolam fed ex cheap overnight delivery of Alprazolam free prescription Alprazolam free shipping not expensive legal Alprazolam for sale buy Alprazolam cod Alprazolam for saturday Alprazolam price cash for Alprazolam cash on delivery Alprazolam Alprazolam without a prescription and cod delivery buying Alprazolam without a prescription order Alprazolam no rx buy Alprazolam without rx Alprazolam cheapest buy Alprazolam online pharmacy buy cheap Alprazolam overnight delivery Alprazolam and online pharmacy Alprazolam next day Alprazolam drug no prescription where can i buy Alprazolam no prescription Alprazolam with saturday delivery Alprazolam online overnight Alprazolam no prescription worldwide buy cheap Alprazolam cod ordering Alprazolam online Buy Alprazolam overnight shipping Alprazolam overnight US delivery cheap real Alprazolam for sale Alprazolam no prescriptions needed COD buy Alprazolam no prescription needed Alprazolam no prescription overnight cod delivery cheap Alprazolam cash on delivery no prescription required for Alprazolam order Alprazolam c.o.d. not expensive Alprazolam prescriptions Alprazolam online Cash on Delivery buy Alprazolam overnight delivery Alprazolam online without presciption buy Alprazolam prescription online no prescription saturday delivery Alprazolam where to buy cheap Alprazolam no prescription Alprazolam wo get Alprazolam over the counter fedex Alprazolam with no rx and free shipping order Alprazolam over the counter cod overnight From numansenm at gmail.com Sat Nov 12 09:35:49 2011 From: numansenm at gmail.com (Sedab Bunay) Date: Sat, 12 Nov 2011 06:35:49 -0800 (PST) Subject: Buying CODEINE Without A Prescription | CODEINE Without Prescription Or Membership Message-ID: <3137318f-99d0-4008-8aa7-9bce00344e0b@n6g2000vbg.googlegroups.com> CODEINE cheapest. Lowest prices for CODEINE online. Buy CODEINE online without no prescription. Buy cheap CODEINE next day no prescription! CODEINE BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://buypharmasite.com/?q=CODEINE <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://buypharmasite.com/?q=CODEINE http://buypharmasite.com/?q=Buy+online+CODEINE http://buypharmasite.com/?q=Buy+order+CODEINE http://buypharmasite.com/?q=Buy+CODEINE http://buypharmasite.com/?q=Buy+cheap+CODEINE http://buypharmasite.com/?q=Order+CODEINE http://buypharmasite.com/?q=Online+CODEINE cheap online pharmacy CODEINE CODEINE online saturday delivery online CODEINE and fedex cheap order prescription CODEINE cheap CODEINE by money order buy CODEINE from mexico online CODEINE no prescription usa fedex shipping overnight delivery CODEINE buy CODEINE online without a prescription and no membership no prescription needed CODEINE cod shipped CODEINE not expensive order prescription CODEINE CODEINE money order CODEINE without a perscription online buy CODEINE CODEINE fedex buy no online prescription CODEINE CODEINE pharmacies accepting cod delivery CODEINE online consultant online pharmacy fedex cod CODEINE buy CODEINE no scams CODEINE c.o.d overnight delivery buy CODEINE no prescription cod overnight CODEINE order CODEINE online doctors buy CODEINE on line no prescription CODEINE no prescription usa fedex shipping CODEINE online uk watson brand CODEINE medicine online CODEINE order CODEINE samples sent buy CODEINE no prescription order CODEINE without a prescription CODEINE no prescription drug cheap online order CODEINE get CODEINE over the counter online order CODEINE next day buy CODEINE no perscription cod real CODEINE fed ex CODEINE no prescription cod does cv/ pharmacy carry CODEINE no prescription cod CODEINE cheap CODEINE without rx CODEINE online health insurance lead buy CODEINE online with overnight delivery CODEINE no rx fed ex buy CODEINE without a perscription lowest prices for CODEINE online buy CODEINE paypal online without prescription cheap non prescription CODEINE CODEINE ups CODEINE for cheap buy CODEINE no visa online without prescription cheapest CODEINE cash on delivery CODEINE order a prepaid mastercard buy online CODEINE purchase CODEINE mail order CODEINE without a prescription online with overnight delivery CODEINE from canada buy CODEINE with no rx overnight delivery of CODEINE with no prescription cash on delivery CODEINE no rx CODEINE by cod buy CODEINE over the counter cod overnight overnight CODEINE order CODEINE without prescription from us pharmacy cheap CODEINE free fedex shipping order CODEINE over the counter where to buy CODEINE no prescription no fees only CODEINE free consult cod delivery CODEINE CODEINE no prescription CODEINE online overnight delivery cod order CODEINE over the counter fedex CODEINE saturday delivery buy CODEINE money order CODEINE without prescription mexico buy cheap CODEINE without prescription CODEINE non prescription for next day delivery CODEINE ups delivery only buy CODEINE usa cod CODEINE with next day delivery no prescriptions needed for CODEINE cheap CODEINE overnight prescription CODEINE cheap CODEINE overnight delivery CODEINE non prescription fedex overnight free order CODEINE no creditcard buy cheap CODEINE no Prescription buy CODEINE over the counter fedex CODEINE no doctor presribe needed cheap watson CODEINE online cheap discount CODEINE buy CODEINE without a prescription online cheapest CODEINE free delivery buy CODEINE online overseas buy CODEINE over the counter online not expensive CODEINE next day shipping order CODEINE cod next day delivery CODEINE cheap CODEINE buy in UK CODEINE next day cod fedex CODEINE to buy cheap order CODEINE next day CODEINE CODEINE overnight no consult cheap watson CODEINE no prescription needed CODEINE without prescription medications overnight delivery of CODEINE with no perscription buy CODEINE.com CODEINE cod next day delivery buy cheap discount online CODEINE buy CODEINE drug CODEINE overnight delivery cheap overnight delivery of CODEINE in US no prescription needed purchase CODEINE free next day airCODEINE on line cheap CODEINE without a prescription CODEINE cheap cod CODEINE buy no prepaid cheap CODEINE next day buy CODEINE cod accepted online pharmacies CODEINE saturday delivery buy CODEINE pay pal CODEINE shipped on saturday CODEINE pharmacy cod saturday delivery buy online CODEINE prescriptions free fedex delivery CODEINE CODEINE without prescription cash on delivery buy discount CODEINE CODEINE overnight cheap best CODEINE online pill images of CODEINE CODEINE U.P.S SHIPPING COD CODEINE cod pharmacy buy CODEINE online cod CODEINE cod overnight delivery CODEINE no rx overnight buy CODEINE overnight COD online pharmacy CODEINE cod order CODEINE insurance CODEINE cash delivery cod buy CODEINE cheap cod no rx online pharmacy CODEINE sale nextday CODEINE CODEINE pill CODEINE online ordering CODEINE online without prescription CODEINE no script needed cod overnight how to buy CODEINE online without a prescription cheap CODEINE without prescription cheap CODEINE online no rx saturday delivery order CODEINE over the counter for sale CODEINE next day delivery cod order CODEINE online without prescription no prescription next day delivery CODEINE overnight CODEINE C.O.D CODEINE without prescription CODEINE discount fedex no prescription buy CODEINE amex CODEINE online next day CODEINE shipped with no prescription CODEINE online cheap cheap CODEINE without prescription overnight delivery buy CODEINE over the counter for sale CODEINE no prescriptions needed cod CODEINE fed ex cheap overnight delivery of CODEINE free prescription CODEINE free shipping not expensive legal CODEINE for sale buy CODEINE cod CODEINE for saturday CODEINE price cash for CODEINE cash on delivery CODEINE CODEINE without a prescription and cod delivery buying CODEINE without a prescription order CODEINE no rx buy CODEINE without rx CODEINE cheapest buy CODEINE online pharmacy buy cheap CODEINE overnight delivery CODEINE and online pharmacy CODEINE next day CODEINE drug no prescription where can i buy CODEINE no prescription CODEINE with saturday delivery CODEINE online overnight CODEINE no prescription worldwide buy cheap CODEINE cod ordering CODEINE online Buy CODEINE overnight shipping CODEINE overnight US delivery cheap real CODEINE for sale CODEINE no prescriptions needed COD buy CODEINE no prescription needed CODEINE no prescription overnight cod delivery cheap CODEINE cash on delivery no prescription required for CODEINE order CODEINE c.o.d. not expensive CODEINE prescriptions CODEINE online Cash on Delivery buy CODEINE overnight delivery CODEINE online without presciption buy CODEINE prescription online no prescription saturday delivery CODEINE where to buy cheap CODEINE no prescription CODEINE wo get CODEINE over the counter fedex CODEINE with no rx and free shipping order CODEINE over the counter cod overnight From tavares at fe.up.pt Sat Nov 12 10:05:05 2011 From: tavares at fe.up.pt (tavares at fe.up.pt) Date: Sat, 12 Nov 2011 07:05:05 -0800 (PST) Subject: =?windows-1252?Q?CMBBE2012_=96_Special_Session_on_=93Computational_Me?= =?windows-1252?Q?thods_for_Bio=2D_Imaging_and_Visualization=94?= Message-ID: Dear Colleague, Within the 10th International Symposium on Biomechanics and Biomedical Engineering - CMBBE2012 (http://www.cmbbe2012.cf.ac.uk), to be held in Berlin, Germany, on April 11-14, 2012, we are organizing the Special Session on ?Computational Methods for Bio- Imaging and Visualization?. Due to your research activities in the related fields, we would like to invite you to submit an abstract to our special session. Your contribution is mostly welcomed, and we would be honoured if you could accept this invitation. TOPICS OF INTEREST (not restricted to): - Applications of Bio- Imaging and Visualization; - Computational Vision; - Computer Aided Diagnosis, Surgery, Therapy, and Treatment; - Image Acquisition; - Image Processing and Analysis; - Image Segmentation, Matching and Registration; - Medical Imaging; - Motion and Deformation Analysis; - Physics of Bio-Imaging; - Scientific Visualization; - Shape Reconstruction; - Simulation and Animation; - Software Development; - Telemedicine Systems and their Applications. IMPORTANT DATES: - Abstract submission cut off: December 16, 2011; - Meeting: April 11-14, 2012. ABSTRACT SUBMISSION: Please, go to the abstract submission page (http:// www.cmbbe2012.cf.ac.uk/abstract%20-%20author.asp) and select the Special Session ?SS5 - Computational Methods for Bio- Imaging and Visualization?. With kind regards, Jo?o Manuel R. S. Tavares, University of Porto, Portugal, tavares at fe.up.pt (Organizer of the Special Session on ?Computational Methods for Bio- Imaging and Visualization?) From jehugaleahsa at gmail.com Sat Nov 12 11:11:21 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sat, 12 Nov 2011 08:11:21 -0800 (PST) Subject: Python ORMs Supporting POPOs and Substituting Layers in Django References: <1f9f9361-8278-4ae6-8d4d-5fd09b0fd800@hc5g2000vbb.googlegroups.com> <415d875d-bc6d-4e69-bcf8-39754b45030a@n18g2000vbv.googlegroups.com> Message-ID: On Nov 8, 12:09?am, Lie Ryan wrote: > On 11/08/2011 01:21 PM, Travis Parks wrote: > > > > > > > On Nov 7, 12:44 pm, John Gordon ?wrote: > >> In ?John Gordon ?writes: > > >>> In<415d875d-bc6d-4e69-bcf8-39754b450... at n18g2000vbv.googlegroups.com> ?Travis Parks ?writes: > >>>> Which web frameworks have people here used and which have they found > >>>> to be: scalable, RAD compatible, performant, stable and/or providing > >>>> good community support? I am really trying to get as much feedback as > >>> I've used Django and it seems to be a very nice framework. ?However I've > >>> only done one project so I haven't delved too deeply. > > >> You are probably looking for more detail than "It's a nice framework" :-) > > >> The database model in Django is powerful; it allows you to do queries in > >> native Python code without delving into backend SQL stuff. > > >> I don't know how scalable/performant the database model is, as the one > >> project I worked on didn't deal with a ton of data. ?(But I'd be surprised > >> if it had poor performance.) > > >> The URL dispatcher provides a very nice and logical way to associate a > >> given URL with a given method call. > > >> Community support is excellent. > > >> -- > >> John Gordon ? ? ? ? ? ? ? ? ? A is for Amy, who fell down the stairs > >> gor... at panix.com ? ? ? ? ? ? ?B is for Basil, assaulted by bears > >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- Edward Gorey, "The Gashlycrumb Tinies" > > > I started the battle today. The "new guy" was trying to sell me on > > CodeIgnitor. I haven't looked at it, but it is PHP, so I really want > > to avoid it. The good thing is that all of his "friends" have been > > telling him to get into Python. I have been trying to convince him > > that PHP isn't cut out for background services and is mostly a front- > > end language. Python is much more geared towards hardcore data > > processing. Why write the system in two languages? > > > I have been spending a lot of time looking at the Pyramid project: the > > next generation of the Pylons project. It looks powerful, but it seems > > to be a lot more complex than Django. > > CodeIgniter is a very fine framework, however it builds on top of a > shitty excuse of a language called PHP. > > I've found that Django has a much better debugging tools; when a Django > page produces an exception, it would always produce a useful error page. > I haven't been able to do the same in CodeIgniter (nor in any PHP > framework I've used, I'm starting to think it's a language limitation); > often when you have errors, PHP would just silently return empty or > partial pages even with all the debugging flags on. > > IMO, Python has a much nicer choice of built-in data structure for data > processing. Python has a much more mature object-orientation, e.g. I > prefer writing l.append(x) rather than array_push(l, x). I think these > qualities are what makes you think Python is much, much more suitable > for data processing than PHP; and I wholesomely agree. > > Database abstraction-wise, Django's ORM wins hands down against > CodeIgniter's ActiveRecord. CodeIgniter's ActiveRecord is basically just > a thin wrapper that abstracts the perks of various database engine. > Django's ORM is a full blown ORM, it handles foreign key relationships > in OO way. The only disadvantage of Django's ORM is that since it's > written in Python, if you need to write a program working on the same > database that doesn't use Django nor Python, then you'll have a problem > since you'll have to duplicate the foreign key relationships. > > With all the bashing of PHP, PHP do have a few advantages. PHP and > CodeIgniter is much easier to set up and running than Django; and the > ability to create a .php file and have it running without having to > write the routing file is sometimes a bliss. And PHP are often used as > their own templating language; in contrast with Django which uses a > separate templating language. Having a full blown language as your > templating language can be a double-edged sword, but it is useful > nevertheless for experimental work. > > IMO, while it is easier to get up and running in PHP, in the long run > Python is much better in almost any other aspects.- Hide quoted text - > > - Show quoted text - The good thing is that I got the new guy to convert his thinking towards Python. He did a little research of his own and realized what he was missing. He and I have been writing some tools in Python, accessing social networking sites, and have been pleasantly surprised by Python's rich support for web protocols. Even yesterday, I wrote some code using xmlrpclib and it blew the equivalent C# code out of the water. urllib2 and urlparse make it really easy to work against RESTful services. It seems like most of Google's APIs have a Python variant. We are thinking we will go along with Pyramid, rather than Django. It was a really hard decision to make. Django has a lot of community support and is integrated with PyDev in eclipse. Nonetheless, we are anticipating the need for massive through-put on our web servers, so we want to make sure we don't have to change gears 2 years down the road when we have 100,000+ users. Furthermore, it seems like Django doesn't allow for customization - we might want to switch between ORMs and the template engine. It is going to be an interesting process of moving from an ASP.NET MVC application to 100% Python. We'll see how well we can scaffold them together. From krzysztof.berniak at gmail.com Sat Nov 12 13:54:12 2011 From: krzysztof.berniak at gmail.com (Krzysztof Berniak) Date: Sat, 12 Nov 2011 19:54:12 +0100 Subject: export output from gnuplot to python Message-ID: Hi all, I'm writing script in python, which fitting exponencial curve to data ( f(x) = a*exp(x*b). To this problem, I use gnuplot in my script. Gnuplot display parameters ( a +/- delta a; b +/- delta b) How Can I use/save this parameters in python variables in next steps of my script, def main(): ... plot = Gnuplot.Gnuplot() plot('f1(x) = a1*exp(b1*x)') plot('a1 = 300; b1 = 0.005;') plot('fit f1(x) "data.txt" using 1:2 via a1, b1') print "first parameter", a1 print "second parameter", b1 # is it feasible ? Or there is another way to see the results ( parameter a1 and b1) of gnuplot by python ... #plot('set terminal postscript') #plot('set output "output.p s"') regards and please help, Cristopher -------------- next part -------------- An HTML attachment was scrubbed... URL: From lbrt Sat Nov 12 14:06:32 2011 From: lbrt (lbrt) Date: 12 Nov 2011 19:06:32 GMT Subject: youtube-dl: way to deal with the size cap issue + new errors + issues ... Message-ID: <1321124792.454176@nntp.aceinnovative.com> ~ I did find my way (through a silly hack) to get all files within a size range without waiting for youtube-dl to be "enhanced". You could simply run youtube-dl in simulate mode and then parse that data to get the info ~ $ youtube-dl --help | grep simulate -s, --simulate do not download the video and do not write anything to disk -g, --get-url simulate, quiet but print URL -e, --get-title simulate, quiet but print title --get-thumbnail simulate, quiet but print thumbnail URL --get-description simulate, quiet but print video description --get-filename simulate, quiet but print output filename --get-format simulate, quiet but print output format ~ it turns out I needed the data anyway and %(uploader)s %(stitle)s and %(ext)s are helpful as well, for example, in case you decide to skip a certain uploader ~ I have also been getting errors reporting: ~ RTMP download detected but "rtmpdump" could not be run ~ What does it mean? Is it a youtube thing or a python/youtube-dl one (or both)? Could you fix that with some flag? ~ It would be very helpful if you could redirect youtube-dl errors to a separate file you would indicate via a flag ~ lbrtchx comp.lang.python: youtube-dl: way to deal with the size cap issue + new errors + issues ... ~ // __ ERROR: RTMP download detected but "rtmpdump" could not be run ~ downloading: http://www.youtube.com/watch?v=TD-66LHJF9E [youtube] Setting language [youtube] TD-66LHJF9E: Downloading video webpage [youtube] TD-66LHJF9E: Downloading video info webpage [youtube] TD-66LHJF9E: Extracting video information [youtube] RTMP download detected [download] Destination: ./LionsgateMovies-TD-66LHJF9E_Trading_Mom.flv ERROR: RTMP download detected but "rtmpdump" could not be run ~ downloading: http://www.youtube.com/watch?v=Ft5fFOktUno [youtube] Setting language [youtube] Ft5fFOktUno: Downloading video webpage [youtube] Ft5fFOktUno: Downloading video info webpage [youtube] Ft5fFOktUno: Extracting video information [youtube] RTMP download detected [download] Destination: ./LionsgateMovies-Ft5fFOktUno_Speed_Racer_The_Movie.flv ERROR: RTMP download detected but "rtmpdump" could not be run ~ downloading: http://www.youtube.com/watch?v=wRbAGrIjCr4 [youtube] Setting language [youtube] wRbAGrIjCr4: Downloading video webpage [youtube] wRbAGrIjCr4: Downloading video info webpage [youtube] wRbAGrIjCr4: Extracting video information [youtube] RTMP download detected [download] Destination: ./LionsgateMovies-wRbAGrIjCr4_Jonah_A_VeggieTales_Movie.flv ERROR: RTMP download detected but "rtmpdump" could not be run ~ downloading: http://www.youtube.com/watch?v=yU0KpRBkeMY [youtube] Setting language [youtube] yU0KpRBkeMY: Downloading video webpage [youtube] yU0KpRBkeMY: Downloading video info webpage [youtube] yU0KpRBkeMY: Extracting video information [youtube] RTMP download detected [download] Destination: ./LionsgateMovies-yU0KpRBkeMY_Hercules_In_New_York.flv ERROR: RTMP download detected but "rtmpdump" could not be run ~ From haraldarminmassa at gmail.com Sat Nov 12 18:53:06 2011 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Sun, 13 Nov 2011 00:53:06 +0100 Subject: occupywallst.org is looking for Python programmers Message-ID: just got this from Richard: Justine told me they are looking for Python programmers. (It involves Django also.) so, if anyone is interested to help them out, please contact Justine. Best wishes Harald -- Harald Armin Massa no fx, no carrier pigeon - From steve+comp.lang.python at pearwood.info Sat Nov 12 18:54:00 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Nov 2011 23:54:00 GMT Subject: youtube-dl: way to deal with the size cap issue + new errors + issues ... References: <1321124792.454176@nntp.aceinnovative.com> Message-ID: <4ebf0718$0$29970$c3e8da3$5496439d@news.astraweb.com> On Sat, 12 Nov 2011 19:06:32 +0000, lbrt chx _ gemale wrote: > I have also been getting errors reporting: > ~ > RTMP download detected but "rtmpdump" could not be run > ~ > What does it mean? Is it a youtube thing or a python/youtube-dl one (or > both)? Could you fix that with some flag? Try installing rtmpdump. BTW, your first call before asking here about random problems should be to use the search engine of your choice to google for more information: https://duckduckgo.com/html/?q=rtmpdump -- Steven From ramapraba2653 at gmail.com Sun Nov 13 00:56:56 2011 From: ramapraba2653 at gmail.com (SUPREME) Date: Sat, 12 Nov 2011 21:56:56 -0800 (PST) Subject: SOUTH INDIAN HOT ACTRESS Message-ID: FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From jeanpierreda at gmail.com Sun Nov 13 01:28:31 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 13 Nov 2011 01:28:31 -0500 Subject: all() is slow? In-Reply-To: <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: > which implies that getattr(x, 'a!b') should be equivalent to x.a!b No, it does not. The documentation states equivalence for two particular values, and there is no way to deduce truth for all cases from that. In fact, if it _was_ trying to say it was true for any attribute value, then your example would be proof that the documentation is incorrect, since CPython breaks that equivalence. Devin On Fri, Nov 11, 2011 at 8:18 PM, Steven D'Aprano wrote: > On Thu, 10 Nov 2011 23:35:32 -0500, Devin Jeanpierre wrote: > >>> That is patently untrue. If you were implementing namedtuple without >>> exec, you would still (or at least you *should*) prevent the user from >>> passing invalid identifiers as attribute names. What's the point of >>> allowing attribute names you can't actually *use* as attribute names? >> >> Then why doesn't Python do this anywhere else? e.g. why can I >> setattr(obj, 'a#b') when obj is any other mutable type? > > That is implementation-specific behaviour and not documented behaviour > for Python. If you try it in (say) IronPython or Jython, you may or may > not see the same behaviour. > > The docs for getattr state: > > ? ?getattr(x, 'foobar') is equivalent to x.foobar > > > which implies that getattr(x, 'a!b') should be equivalent to x.a!b which > will give a syntax error. The fact that CPython does less validation is > arguably a bug and not something that you should rely on: it is *not* a > promise of the language. > > As Terry Reedy already mentioned, the namespace used in classes and > instances are ordinary generic dicts, which don't perform any name > validation. That's done for speed. Other implementations may use > namespaces that enforce legal names for attributes, and __slots__ already > does: > >>>> class X(object): > ... ? ? __slots__ = ['a', 'b!'] > ... > Traceback (most recent call last): > ?File "", line 1, in > TypeError: Error when calling the metaclass bases > ? ?__slots__ must be identifiers > > > [...] >> To go off on another tangent, though, I don't really understand how you >> guys can think this is reasonable, though. I don't get this philosophy >> of restricting inputs that would otherwise be perfectly valid > > But they aren't perfectly valid. They are invalid inputs. Just because > getattr and setattr in CPython allow you to create attributes with > invalid names doesn't mean that everything else should be equally as > slack. > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From oleg.rimko at gmail.com Sun Nov 13 03:55:16 2011 From: oleg.rimko at gmail.com (0xfn) Date: Sun, 13 Nov 2011 00:55:16 -0800 (PST) Subject: Use and usefulness of the as syntax References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> <4EBE69DA.2060501@tim.thechases.com> Message-ID: <54b0617a-3456-4878-819c-f79b388232ea@u6g2000vbg.googlegroups.com> On Nov 12, 7:48?am, Rafael Dur?n Casta?eda wrote: > El 12/11/11 13:43, Tim Chase escribi?:> ? I hate trying to track down variable-names if one did something like > > > ? from Tkinter import * > > +1 Really, this questionable code is always mentioned as example in Tkinter tuts. IMHO much better is >>> import Tkinter as tk In common case `as` is useful when: 1. You `import ThirdPartyModuleWithTerriblyLongName as tpm` 2. Whant to free some common variable name, which is engaged by module name by default (right what Mel Wilson has pictured) From anssi.kaariainen at thl.fi Sun Nov 13 07:28:16 2011 From: anssi.kaariainen at thl.fi (=?iso-8859-1?Q?K=E4=E4ri=E4inen_Anssi?=) Date: Sun, 13 Nov 2011 14:28:16 +0200 Subject: Dynamically altering __init__ In-Reply-To: References: , , Message-ID: I wrote: """ I will post a link to a complete example once I have done the AST transformations etc. I hope this will be useful to readers of this list. I didn't find such an example, so maybe the next asker will find it... """ Finally got time to do this. The example can be found at: https://github.com/akaariai/ast_model In the example I rewrote a small part of Django's model __init__ to use: self.field1, self.field2, ... = args instead of: for f_name, val in izip(field_names, args): setattr(self, f_name, val) The speedup of that rewrote is about 50% for a model having 10 fields. The example implementation might not be optimal, but it seems to work. I hope it will be useful to the readers of this list. It was a nice learning experience for me. Thanks for your help, - Anssi K??ri?inen From steve+comp.lang.python at pearwood.info Sun Nov 13 08:30:37 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Nov 2011 13:30:37 GMT Subject: How to indent blocks when readline completion is on? Message-ID: <4ebfc67c$0$29970$c3e8da3$5496439d@news.astraweb.com> I have set up readline completion as described here: http://docs.python.org/library/rlcompleter.html Now how do I indent blocks in the interactive interpreter? If I press the TAB key, the completer prompts me instead of indenting: >>> readline.parse_and_bind("tab: complete") >>> while True: ... Display all 182 possibilities? (y or n) ... Surely I'm not stuck with indenting by manually typing spaces? I thought I could add a wrapper around the rlcompleter method, like this: >>> import readline >>> import rlcompleter >>> readline.parse_and_bind("tab: complete") >>> completer = readline.get_completer() >>> def wrapped_completer(text, state): ... if not text or text.isspace(): ... return "\t" ... else: ... return completer(text, state) ... >>> readline.set_completer(wrapped_completer) Completion appears to work if I have something in the line to start with, e.g. if I type "whi" TAB "Tr" TAB I get "while True", but if I press TAB on an empty line (intending to get an actual tab character for indentation), it plays merry havoc with my session. All keyboard input appears to be dead, eventually I used Ctrl-Z to interrupt the process and killed it from the shell. -- Steven From anacrolix at gmail.com Sun Nov 13 08:32:39 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Mon, 14 Nov 2011 00:32:39 +1100 Subject: socket.socket.makefile Message-ID: I'm writing an alternative socket module, and have come across the code for the makefile call, which mentions the following: (XXX refactor to share code?) http://hg.python.org/cpython/file/27adb952813b/Lib/socket.py#l149 Has this been refactored elsewhere? Is there something I can use to wrap the SocketIO inheriting from RawIOBase in all the variants the io.open/socket.makefile functions return for me? From rosuav at gmail.com Sun Nov 13 09:40:28 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Nov 2011 01:40:28 +1100 Subject: How to indent blocks when readline completion is on? In-Reply-To: <4ebfc67c$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <4ebfc67c$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Nov 14, 2011 at 12:30 AM, Steven D'Aprano wrote: > I thought I could add a wrapper around the rlcompleter method, like this: > >>>> import readline >>>> import rlcompleter >>>> readline.parse_and_bind("tab: complete") >>>> completer = readline.get_completer() >>>> def wrapped_completer(text, state): > ... ? ? if not text or text.isspace(): > ... ? ? ? ? return "\t" > ... ? ? else: > ... ? ? ? ? return completer(text, state) > ... >>>> readline.set_completer(wrapped_completer) Attempting to duplicate this failed in my Py3 (no readline module - probably I didn't have the dev version when I built that Python), but in Py2, I can see the same issue. The wrapped_completer function is called repeatedly with successive values for 'state', and it needs to return None at some point to indicate that there are no more possibilities. (Why isn't it specced to simply return an iterable?) >>> def wrapped_completer(text, state): ... if not text or text.isspace(): ... if state: return None ... return "\t" ... else: ... return completer(text, state) ... This function appears (to me!) to do what you're looking for; it allows me to enter tabs while still using tab completion. However, I seem to have some slightly different tab-completion settings somewhere (for instance, typing "whi" produces "while" with no space after it, so I need to type " Tr" not "Tr"), so this may not work on your setup. ChrisA From jehugaleahsa at gmail.com Sun Nov 13 12:37:25 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sun, 13 Nov 2011 09:37:25 -0800 (PST) Subject: xmlrpclib date times and a trailing Z References: <7d3e9e96-687f-4081-990e-46b7bb386925@d5g2000yqg.googlegroups.com> Message-ID: <8009b627-be86-495f-85d7-8fac6522fe8d@y12g2000vba.googlegroups.com> On Nov 11, 7:20?pm, Travis Parks wrote: > I am trying to connect to Marchex's a call tracking software using > xmlrpclib. I was able to get some code working, but I ran into a > problem dealing with transfering datetimes. > > When I construct a xmlrpclib.ServerProxy, I am setting the > use_datetime flag to indicate that I want to automatically convert > back and forth between date times in the datetime library. > > I have a working version that doesn't use this flag, and I have to > convert from the xmlrpclib.DateTime type to the datetime.datetime type > manually, via string parsing. > > The thing is, Marchex's API returns date's with a trailing Z, after > the time component. I did some research and this is supposed to be an > indicator that UTC was used. However, it doesn't seem like the > xmlrpclib likes it very much. > > It looks like it is using this code internally: time.strptime(data, "%Y > %m%dT%H:%M:%S") > > This code doesn't look like it handles time zones at all. I guess, is > there a way to tell xmlrpclib to include time zones when parsing date > times? > > Thanks, > Travis Parks I did some chatting on IRC and it seems that the date/time format is not very well defined in XML RPC specs. So, basically, Marchex is using a format that the XML RPC library doesn't support. Strangely, Marchex supports incoming dates with the format yyyyMMddThhmmss. It just spits dates back out with yyyy-MM-ddThh:mm:ssZ. The ISO8601 standard seems to be used a lot, so it is surprising the library doesn't try multiple formats, at least. I find it strange that the library, in light of the fact that date formats aren't standardized, doesn't provide the ability to configure this. I also find it strange that the library doesn't incorporate Basic Authentication using urllib2, but instead rolls its own method of putting username:password@ before the netloc. I wish Python's libraries acted more like an integrated framework than just unrelated libraries. I suppose I am spoiled from years of working with all-in-one frameworks managed by a single group. That is not the way C/C++ works or how Linux works. The power generated by using a conglomeration of unrelated libraries is indisputable, even if it can be a productivity killer and just plain confusing. From wolftracks at invalid.com Sun Nov 13 12:46:18 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sun, 13 Nov 2011 09:46:18 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 Message-ID: For many months I had sporadically used 2.5.2 under Win 7, then something went awry. I tried an uninstall/install and it didn't get any better. I thought I'd take another shot at it today. The uninstall went OK, but c:\python25 remained with several py files and a folder, Lib. I went ahead with the install and got a msg that asked if I wanted to write over the python25 folder. I figured maybe I should ask about this. It's probably OK. Yes, I know I have an old version of Python, but I need it occasionally. Comments? From steve at sprangle.com Sun Nov 13 13:17:59 2011 From: steve at sprangle.com (Steve Edlefsen) Date: Sun, 13 Nov 2011 11:17:59 -0700 Subject: can't decompress data; zlib not available Message-ID: <4EC009D7.90100@sprangle.com> Hi, I'm trying to install a tool for Plone called ZopeSkel, but when I run the setup file ez_setup.py, I get dr_shred at merle:~$ ez_setup.py Downloading http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg Traceback (most recent call last): File "/home/dr_shred/python/ez_setup.py", line 279, in ? main(sys.argv[1:]) File "/home/dr_shred/python/ez_setup.py", line 213, in main from setuptools.command.easy_install import main zipimport.ZipImportError: can't decompress data; zlib not available I believe this means the python installation didn't include zlib. Python was installed with Plone and has the following config directory: dr_shred at merle:/usr/local/Plone/Python-2.6/lib/python2.6/config$ ls -l total 10208 -rw-r--r-- 1 root root 2139 2011-10-24 17:53 config.c -rw-r--r-- 1 root root 1507 2011-10-24 17:53 config.c.in -rwxr-xr-x 1 root root 7122 2011-10-24 17:53 install-sh -rw-r--r-- 1 root root 10342706 2011-10-24 17:53 libpython2.6.a -rw-r--r-- 1 root root 42568 2011-10-24 17:53 Makefile -rwxr-xr-x 1 root root 7431 2011-10-24 17:53 makesetup -rw-r--r-- 1 root root 6528 2011-10-24 17:53 python.o -rw-r--r-- 1 root root 18265 2011-10-24 17:53 Setup -rw-r--r-- 1 root root 368 2011-10-24 17:53 Setup.config -rw-r--r-- 1 root root 41 2011-10-24 17:53 Setup.local There's no readme file, or anything to describe how it all works. The Setup file has an entry zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz which appears to install zlib when python is reinstalled. Except I can't run make without errors and there is no configuration file. How do I reinstall python to include zlib? Many Thanks, Steve Edlefsen From jason.swails at gmail.com Sun Nov 13 13:27:05 2011 From: jason.swails at gmail.com (Jason Swails) Date: Sun, 13 Nov 2011 13:27:05 -0500 Subject: (n00b) Tkinter trouble Message-ID: Hello, I'm trying my hand at creating a Tkinter application, but not having much luck. I'm trying to have my top level window be a series of buttons with different options on them. Every time a button is pressed, it opens up a new window with options. While that new window is open, all of the buttons on the original window are disabled. However, I want all of those buttons to become active again once I quit my new window. I can't seem to reactivate those buttons no matter what I do. This is the approach I'm trying: #!/usr/bin/env python from Tkinter import * class ActionButton(Button): def __init__(self, frame, text): self.frame = frame Button.__init__(self, master=self.frame, text=text, command=self.execute) def execute(self): window = Toplevel() new_button = ActionButton(window, '2nd level button') quit_button = Button(window, text='Quit!', command=window.destroy) window.buttons = [new_button, quit_button] for button in window.buttons: button.pack() # Deactivate buttons from containing shell for button in self.frame.buttons: button.config(state=DISABLED) window.mainloop() for button in self.frame.buttons: button.config(state=ACTIVE) top = Tk() top_button = ActionButton(top, 'Button on top!') top_button.pack() quit_button = Button(top, text='Quit', command=top.destroy) quit_button.pack() top.buttons = [top_button, quit_button] top.mainloop() I'm really kind of running around in the dark here, so any advice or explanation is appreciated. Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From irmen at -NOSPAM-xs4all.nl Sun Nov 13 14:08:32 2011 From: irmen at -NOSPAM-xs4all.nl (Irmen de Jong) Date: Sun, 13 Nov 2011 20:08:32 +0100 Subject: Uninstalling Py 2.5.2 from Windows 7 In-Reply-To: References: Message-ID: <4ec015b0$0$6927$e4fe514c@news2.news.xs4all.nl> On 13-11-11 18:46, W. eWatson wrote: > For many months I had sporadically used 2.5.2 under Win 7, then > something went awry. I tried an uninstall/install and it didn't get any > better. I thought I'd take another shot at it today. The uninstall went > OK, but c:\python25 remained with several py files and a folder, Lib. I > went ahead with the install and got a msg that asked if I wanted to > write over the python25 folder. > > I figured maybe I should ask about this. It's probably OK. Yes, I know I > have an old version of Python, but I need it occasionally. > > Comments? Just go ahead and manually delete c:\python25 and everything in it. But make sure that the leftover stuff in there is something you won't need again, or that you can get back by re-installing the third party library that it was part of. Then re-install from the 2.5.2 msi. (Or perhaps 2.5.4). Irmen From tim.wintle at teamrubber.com Sun Nov 13 16:55:05 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Sun, 13 Nov 2011 21:55:05 +0000 Subject: can't decompress data; zlib not available In-Reply-To: <4EC009D7.90100@sprangle.com> References: <4EC009D7.90100@sprangle.com> Message-ID: <1321221305.12661.6.camel@tim-laptop> On Sun, 2011-11-13 at 11:17 -0700, Steve Edlefsen wrote: > > which appears to install zlib when python is reinstalled. Except I > can't run make without errors and there is no configuration file. > > How do I reinstall python to include zlib? Which OS are you on? Linux? BSD? How did you install Plone? First I'd check if there's a module shadowing the builtin zlib module - i.e. if you've got a local file called "zlib.py" which is getting imported by mistake. Fairly much all *nix systems will have a python installation out of the box - it looks like you need python2.6 I've never had a missing zlib module - but it's possible that it might be missing if you don't have the zlib/deflate headers installed - if they're not available then I'd try installing them and then reinstalling the package you started with. Tim Wintle From tjreedy at udel.edu Sun Nov 13 17:08:53 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Nov 2011 17:08:53 -0500 Subject: Uninstalling Py 2.5.2 from Windows 7 In-Reply-To: References: Message-ID: On 11/13/2011 12:46 PM, W. eWatson wrote: > For many months I had sporadically used 2.5.2 under Win 7, then > something went awry. I tried an uninstall/install and it didn't get any > better. I thought I'd take another shot at it today. The uninstall went > OK, but c:\python25 remained with several py files and a folder, Lib. I > went ahead with the install and got a msg that asked if I wanted to > write over the python25 folder. Uninstall (should) only uninstall files that it installed and directories that are empty. The 'several py files' should be files that you or some third-party software installed. I personally put everything I write under /pythonxy in a subdirectory thereof that install and uninstall pay no attention to. The Lib directory contains all the python-coded stdlib modules. Unless you know there is something that you wrote that you want, I would delete it before re-installing. I suspect that current installers work a bit better than 2.5. I would definitely use the latest 2.5.z that comes with an installer and not 2.5.2. They are all the same version of the language. The only difference is bug fixes. -- Terry Jan Reedy From tjreedy at udel.edu Sun Nov 13 17:16:38 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Nov 2011 17:16:38 -0500 Subject: Use and usefulness of the as syntax In-Reply-To: <54b0617a-3456-4878-819c-f79b388232ea@u6g2000vbg.googlegroups.com> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> <4EBE69DA.2060501@tim.thechases.com> <54b0617a-3456-4878-819c-f79b388232ea@u6g2000vbg.googlegroups.com> Message-ID: On 11/13/2011 3:55 AM, 0xfn wrote: > On Nov 12, 7:48 am, Rafael Dur?n Casta?eda > wrote: >> El 12/11/11 13:43, Tim Chase escribi?:> I hate trying to track down variable-names if one did something like >> >>> from Tkinter import * >> >> +1 > > Really, this questionable code is always mentioned as example in > Tkinter tuts. I see it is still in the 3.2 tkinter doc, near the top. > IMHO much better is >>>> import Tkinter as tk My opinion also. I will think about changing it someday, but then all the examples will need to be changed ;-). So it will not be trivial. -- Terry Jan Reedy From goldtech at worldpost.com Sun Nov 13 17:37:01 2011 From: goldtech at worldpost.com (goldtech) Date: Sun, 13 Nov 2011 14:37:01 -0800 (PST) Subject: Trying to write beautifulsoup result to a file and get error message Message-ID: If I try: ... soup = BeautifulSoup(ft3) f = open(r'c:\NewFolder\clean4.html', "w") f.write(soup) f.close() I get error message: Traceback (most recent call last): File "C:\Documents and Settings\user01\Desktop\py\tb1a.py", line 203, in f.write(soup) TypeError: expected a character buffer object I want to write beautiful soup's result to a file, I am doing something wrong. Help appreciated. Thanks From python at mrabarnett.plus.com Sun Nov 13 18:31:52 2011 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 13 Nov 2011 23:31:52 +0000 Subject: Trying to write beautifulsoup result to a file and get error message In-Reply-To: References: Message-ID: <4EC05368.1060408@mrabarnett.plus.com> On 13/11/2011 22:37, goldtech wrote: > If I try: > ... > soup = BeautifulSoup(ft3) > f = open(r'c:\NewFolder\clean4.html', "w") > f.write(soup) > f.close() > > I get error message: > > Traceback (most recent call last): > File "C:\Documents and Settings\user01\Desktop\py\tb1a.py", line > 203, in > f.write(soup) > TypeError: expected a character buffer object > > I want to write beautiful soup's result to a file, I am doing > something wrong. Help appreciated. > What do you mean by "beautiful soup's result"? The original HTML is text, and you want it to write some text to the file, but what exactly are you expecting it to write? From wolftracks at invalid.com Sun Nov 13 19:06:50 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sun, 13 Nov 2011 16:06:50 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 In-Reply-To: References: Message-ID: On 11/13/2011 2:08 PM, Terry Reedy wrote: > On 11/13/2011 12:46 PM, W. eWatson wrote: >> For many months I had sporadically used 2.5.2 under Win 7, then >> something went awry. I tried an uninstall/install and it didn't get any >> better. I thought I'd take another shot at it today. The uninstall went >> OK, but c:\python25 remained with several py files and a folder, Lib. I >> went ahead with the install and got a msg that asked if I wanted to >> write over the python25 folder. > > Uninstall (should) only uninstall files that it installed and > directories that are empty. The 'several py files' should be files that > you or some third-party software installed. I personally put everything > I write under /pythonxy in a subdirectory thereof that install and > uninstall pay no attention to. The Lib directory contains all the > python-coded stdlib modules. Unless you know there is something that you > wrote that you want, I would delete it before re-installing. > > I suspect that current installers work a bit better than 2.5. I would > definitely use the latest 2.5.z that comes with an installer and not > 2.5.2. They are all the same version of the language. The only > difference is bug fixes. > Thanks to both of you. Deleting python25 folder. Nothing of personal use in it. From wolftracks at invalid.com Sun Nov 13 19:17:11 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sun, 13 Nov 2011 16:17:11 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 In-Reply-To: References: Message-ID: Well, let be a careful a little more. I have PIL, numpy, scipy, pymatplotlib and pyephem installed, I think. There are Remove....exe files in the python25 folder for them. There's also a Removepy2exe.exe. Probably that was somehow used to get out py2.5. From kwa at kuwata-lab.com Sun Nov 13 19:27:35 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Mon, 14 Nov 2011 09:27:35 +0900 Subject: [ANN] PikoTest.py - a small testing library Message-ID: I released PikoTest.py 0.1.0. http://pypi.python.org/pypi/PicoTest PikoTest.py is a samll testing library for Python. Features: * Structured Test * Setup/Teardown * Fixture Injection * Skip Test * TODO Example:: from __future__ import with_statement import picotest test = picotest.new() with test("type 'str'"): with test("operator '*'"): @test("repeats string N times.") def _(self): self.assertEqual("AAA", "A" * 3) @test("returns empty string when N is negative.") def _(self): self.assertEqual("", "A" * -1) if __name__ == '__main__': picotest.main() Output example:: $ python -m picotest -h # show help $ python example_test.py # or python -m picotest example_test.py #### example_test.py * type 'str' * operator '*' - [passed] repeats string N times. - [passed] returns empty string when N is negative. ## total:2, passed:2, failed:0, error:0, skipped:0, todo:0 See http://pypi.python.org/pypi/PicoTest for details. -- regards, makoto kuwata From vugluskr at vugluskr.org.ua Sun Nov 13 19:58:44 2011 From: vugluskr at vugluskr.org.ua (=?UTF-8?B?0JHQvtCz0YPQvSDQlNC80LjRgtGA0LjQuQ==?=) Date: Mon, 14 Nov 2011 02:58:44 +0200 Subject: Slave to master auto linking. Message-ID: <4EC067C4.7040009@vugluskr.org.ua> Hello. I try make some weird thing. I want to get from code like this: class master: ... class slave: ... m = master() s = m.slave() s.master is m Last expression must be true. I want link "master" to be set automatically by master object while creating slave object. Additional requirement - "master" link must be available for constructor of slave object. Best what I can get is: import functools from weakref import WeakKeyDictionary from threading import RLock class meth_wrap(object): def __init__(self, func): object.__init__(self) self.func = func functools.update_wrapper(self, func, updated=()) class lazy_attr(meth_wrap): def __get__(self, obj, type=None): if obj is None: return self val = self.func(obj) setattr(obj, self.__name__, val) return val class slave_mixin(object): @lazy_attr def master(self): m = slave_gen._unbound_master assert m is not None, '"Slave" object can\'t find master link. Is it was correctly created? obj:%s' % repr(self) return m class slave_gen(meth_wrap): _storage = WeakKeyDictionary() # ???????????? ????????? _unbound_master = None _lock = RLock() def __get__(self, mobj, type=None): if mobj is None: return self.func d = { 'm': mobj, 'w': self} obj = self.delay_init() self._storage[obj] = d functools.update_wrapper(obj, self.func, updated=()) return obj class delay_init(object): def __call__(self, *args, **kw_args): d = slave_gen._storage[self] slave_gen._lock.acquire() try: slave_gen._unbound_master = d['m'] obj = d['w'].func(*args, **kw_args) obj.master = d['m'] slave_gen._unbound_master = None finally: slave_gen._lock.release() return obj def __getattr__(self, attr): d = slave_gen._storage[self] return getattr(d['m'], attr) def __setattr__(self, attr, val): d = slave_gen._storage[self] return setattr(d['m'], attr, val) class Master(object): @slave_gen class Slave(slave_mixin): def __init__(self): slave_mixin.__init__(self) print 'Slave.__init__: self.master: ', self.master if __name__ == '__main__': m = Master() s = m.Slave() print 's.master: ', s.master It works, by looking little weird... and I can't find way to escape from using lock at object creation phase. It can be done by adding mandatory attribute to slave class constructor, but this is even worse(for me) than using lock. Please show me more clear way to make this slave to master link. PS Sorry for my English. -- ????? ??????? aka vugluskr From rosuav at gmail.com Sun Nov 13 21:15:05 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Nov 2011 13:15:05 +1100 Subject: Slave to master auto linking. In-Reply-To: <4EC067C4.7040009@vugluskr.org.ua> References: <4EC067C4.7040009@vugluskr.org.ua> Message-ID: 2011/11/14 ????? ??????? : > m = master() > s = m.slave() > s.master is m > Can you simply have m.slave() pass a parameter to the slave's constructor? class Master(object): class Slave(object): def __init__(self,master): self.master=master print 'Slave.__init__: self.master: ', self.master def slave(self): return self.Slave(self) Alternatively, you don't have to nest the classes at all: class Slave(object): def __init__(self,master): self.master=master print 'Slave.__init__: self.master: ', self.master class Master(object): def slave(self): return Slave(self) By passing 'self' to the Slave() constructor, I give the slave a chance to keep a reference to its own master. Chris Angelico From wuwei23 at gmail.com Sun Nov 13 21:50:33 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 13 Nov 2011 18:50:33 -0800 (PST) Subject: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2b46d46c-f66d-4a13-8c0b-af9b6c638863@h30g2000pro.googlegroups.com> On Nov 13, 4:28?pm, Devin Jeanpierre wrote: > > which implies that getattr(x, 'a!b') should be equivalent to x.a!b > > No, it does not. The documentation states equivalence for two > particular values It states equivalence for two values _based on the name_. "If the string is the name of one of the object?s attributes, the result is the value of that attribute. For example, getattr(x, 'foobar') is equivalent to x.foobar." The string 'a!b' is the name of the attribute, ergo getattr(x, 'a!b') _is_ x.a!b. If x.a!b isn't valid CPython, then etc. > CPython breaks that equivalence So you're outright ignoring the comments that this behaviour is to make CPython more performant? From jeanpierreda at gmail.com Sun Nov 13 23:48:45 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 13 Nov 2011 23:48:45 -0500 Subject: all() is slow? In-Reply-To: <2b46d46c-f66d-4a13-8c0b-af9b6c638863@h30g2000pro.googlegroups.com> References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> <4EBC1B54.6000308@stoneleaf.us> <4ebc592b$0$29970$c3e8da3$5496439d@news.astraweb.com> <4ebdc961$0$29970$c3e8da3$5496439d@news.astraweb.com> <2b46d46c-f66d-4a13-8c0b-af9b6c638863@h30g2000pro.googlegroups.com> Message-ID: > It states equivalence for two values _based on the name_. I don't know what you mean. "Based on the name" doesn't mean anything in particular to me in this context. > So you're outright ignoring the comments that this behaviour is to > make CPython more performant? I don't see how I'm ignoring the comment. Yes, breaking the spec improves performance. Is that a reason to not fix the spec, or something? Devin On Sun, Nov 13, 2011 at 9:50 PM, alex23 wrote: > On Nov 13, 4:28?pm, Devin Jeanpierre wrote: >> > which implies that getattr(x, 'a!b') should be equivalent to x.a!b >> >> No, it does not. The documentation states equivalence for two >> particular values > > It states equivalence for two values _based on the name_. > > "If the string is the name of one of the object?s attributes, the > result is the value of that attribute. For example, getattr(x, > 'foobar') is equivalent to x.foobar." > > The string 'a!b' is the name of the attribute, ergo getattr(x, 'a!b') > _is_ x.a!b. If x.a!b isn't valid CPython, then etc. > >> CPython breaks that equivalence > > So you're outright ignoring the comments that this behaviour is to > make CPython more performant? > -- > http://mail.python.org/mailman/listinfo/python-list > From wolftracks at invalid.com Mon Nov 14 00:19:22 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sun, 13 Nov 2011 21:19:22 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) In-Reply-To: References: Message-ID: I just pushed aside the python25 folder by renaming it, and installed py 2.5.2. However, when I try to open the simplest of py programs with IDLE, I get an error from Win7. c:\Users\blah\...\junk.py is not a valid Win 32 app. Here's one: def abc(one): print "abc: ", one, " is one" def duh(two): print "duh: ",abc(2) abc(1) duh(2) duh("so what") abc(36.333) From wuwei23 at gmail.com Mon Nov 14 00:42:59 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 13 Nov 2011 21:42:59 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: On Nov 11, 11:31 pm, macm wrote: > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > print k1 > print k2 > > There is a fast way (trick) to get k1 and k2 as string. It might be possible to do something using a reverse dictionary and getting rid of the nested dictionary. This is a quick and simple 'two-way' dictionary class that works by maintaining two dictionaries: the original key/value, and the reversed value/key. It returns a list of keys, allowing for a value to be assigned against more than from collections import defaultdict class TwoWayDict(dict): def __init__(self, *args, **kwargs): self._reversed = defaultdict(list) for key, val in kwargs.iteritems(): self[key] = val def __setitem__(self, key, value): super(TwoWayDict, self).__setitem__(key, value) self._reversed[value].append(key) def getkeys(self, match): return self._reversed[match] >>> original = TwoWayDict(a=100,b='foo',c=int,d='foo') >>> original.getkeys(100) ['a'] >>> original.getkeys('foo') ['b', 'd'] As for the nested dictionary, you could replace it with a _single_ dictionary that uses a composite key: >>> original = TwoWayDict(a=100,b=100) >>> original.getkeys(100) ['a', 'b'] >>> original = TwoWayDict() >>> original['record1','user1'] = 'martin' >>> original['record1','user2'] = 'robert' >>> original['record2','user1'] = 'robert' >>> original.getkeys('robert') [('record1', 'user2'), ('record2', 'user1')] > Whithout loop all dict. Just it! The TwoWayDict class removes the need to loop across the dict looking for keys that match a value by replacing it with another dict lookup. Reducing the nested dict to a single dict with composite keys removes the need to traverse the outer dict to compare against its children. From wuwei23 at gmail.com Mon Nov 14 00:44:25 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 13 Nov 2011 21:44:25 -0800 (PST) Subject: Get keys from a dicionary References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: On Nov 11, 11:31 pm, macm wrote: > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > print k1 > print k2 > > There is a fast way (trick) to get k1 and k2 as string. It might be possible to do something using a reverse dictionary and getting rid of the nested dictionary. This is a quick and simple 'two-way' dictionary class that works by maintaining two dictionaries: the original key/value, and the reversed value/key. It returns a list of keys, allowing for a value to be assigned against more than from collections import defaultdict class TwoWayDict(dict): def __init__(self, *args, **kwargs): self._reversed = defaultdict(list) for key, val in kwargs.iteritems(): self[key] = val def __setitem__(self, key, value): super(TwoWayDict, self).__setitem__(key, value) self._reversed[value].append(key) def getkeys(self, match): return self._reversed[match] >>> original = TwoWayDict(a=100,b='foo',c=int,d='foo') >>> original.getkeys(100) ['a'] >>> original.getkeys('foo') ['b', 'd'] As for the nested dictionary, you could replace it with a _single_ dictionary that uses a composite key: >>> original = TwoWayDict(a=100,b=100) >>> original.getkeys(100) ['a', 'b'] >>> original = TwoWayDict() >>> original['record1','user1'] = 'martin' >>> original['record1','user2'] = 'robert' >>> original['record2','user1'] = 'robert' >>> original.getkeys('robert') [('record1', 'user2'), ('record2', 'user1')] > Whithout loop all dict. Just it! The TwoWayDict class removes the need to loop across the dict looking for keys that match a value by replacing it with another dict lookup. Reducing the nested dict to a single dict with composite keys removes the need to traverse the outer dict to compare against its children. From jason.swails at gmail.com Mon Nov 14 02:11:45 2011 From: jason.swails at gmail.com (Jason Swails) Date: Mon, 14 Nov 2011 02:11:45 -0500 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Sun, Nov 13, 2011 at 1:27 PM, Jason Swails wrote: > Hello, > > I'm trying my hand at creating a Tkinter application, but not having much > luck. I'm trying to have my top level window be a series of buttons with > different options on them. Every time a button is pressed, it opens up a > new window with options. While that new window is open, all of the buttons > on the original window are disabled. However, I want all of those buttons > to become active again once I quit my new window. I can't seem to > reactivate those buttons no matter what I do. > > This is the approach I'm trying: > > #!/usr/bin/env python > > from Tkinter import * > > class ActionButton(Button): > def __init__(self, frame, text): > self.frame = frame > Button.__init__(self, master=self.frame, text=text, > command=self.execute) > def execute(self): > window = Toplevel() > new_button = ActionButton(window, '2nd level button') > quit_button = Button(window, text='Quit!', command=window.destroy) > window.buttons = [new_button, quit_button] > for button in window.buttons: button.pack() > # Deactivate buttons from containing shell > for button in self.frame.buttons: button.config(state=DISABLED) > window.mainloop() > for button in self.frame.buttons: button.config(state=ACTIVE) > > > top = Tk() > top_button = ActionButton(top, 'Button on top!') > top_button.pack() > quit_button = Button(top, text='Quit', command=top.destroy) > quit_button.pack() > > top.buttons = [top_button, quit_button] > > top.mainloop() > > I'm really kind of running around in the dark here, so any advice or > explanation is appreciated. > Another approach I think will work, and that I'm going to try, is to subclass Toplevel and simply assign the higher-level frame/window as an instance attribute. Then, I can reactivate all of the buttons in the destroy() method before calling the destroy() method of Toplevel on self. Something like this: [untested] class MyToplevel(Toplevel): def __init__(self, root, **options): self.root = root Toplevel.__init__(self, options) for button in self.root.buttons: button.config(state=DISABLED) def destroy(self): for button in self.root.buttons: button.config(state=ACTIVE) Toplevel.destroy(self) This allows me to avoid running "mainloop()" on a non-root Toplevel instance, but links the re-activation of the buttons with the destruction of the child window (which was the effect I was going for). I must not understand what mainloop() does, fully (does it only make sense to run it on Tkinter.Tk()?) Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Nov 14 03:49:03 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Nov 2011 19:49:03 +1100 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Mon, Nov 14, 2011 at 6:11 PM, Jason Swails wrote: > Then, I can reactivate all of the buttons in the destroy() method before > calling the destroy() method of Toplevel on self. Small side point that might save you some work: Instead of disabling and enabling all the buttons, disable the whole window. I don't know Tkinter well enough to know if there's an easy way to create a modal window, but the thing to do is to disable the entire window rather than just its command buttons - that's the least astonishing[1] user interface technique. ChrisA [1] http://en.wikipedia.org/wiki/Principle_of_least_astonishment From mcepl at redhat.com Mon Nov 14 05:05:40 2011 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 14 Nov 2011 11:05:40 +0100 Subject: Multilevel dicts/arrays v. tuples as keys? [Was: Re: Get keys from a dicionary] In-Reply-To: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: Dne 11.11.2011 14:31, macm napsal(a): > def Dicty( dict[k1][k2] ): When looking at this I returned to the question which currently rolls in my mind: What's difference/advantage-disadvantage betweeng doing multi-level dicts/arrays like this and using tuple as a key? I.e., is it more Pythonic to have dict[k1,k2] instead? Best, Mat?j From affdfsdfdsfsd at b.com Mon Nov 14 05:41:52 2011 From: affdfsdfdsfsd at b.com (Tracubik) Date: 14 Nov 2011 10:41:52 GMT Subject: my new project, is this the right way? Message-ID: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Hi all, i'm developing a new program. Mission: learn a bit of database management Idea: create a simple, 1 window program that show me a db of movies i've seen with few (<10) fields (actors, name, year etc) technologies i'll use: python + gtk db: that's the question since i'm mostly a new-bye for as regard databases, my idea is to use sqlite at the beginning. Is that ok? any other db to start with? (pls don't say mysql or similar, they are too complex and i'll use this in a second step) is there any general tutorial of how to start developing a database? i mean a general guide to databases you can suggest to me? Thank you all MedeoTL P.s. since i have a ods sheet files (libreoffice calc), is there a way to easily convert it in a sqlite db? (maybe via csv) From mail at timgolden.me.uk Mon Nov 14 05:42:50 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 14 Nov 2011 10:42:50 +0000 Subject: Multilevel dicts/arrays v. tuples as keys? [Was: Re: Get keys from a dicionary] In-Reply-To: References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: <4EC0F0AA.4060003@timgolden.me.uk> On 14/11/2011 10:05, Matej Cepl wrote: > Dne 11.11.2011 14:31, macm napsal(a): >> def Dicty( dict[k1][k2] ): > > When looking at this I returned to the question which currently rolls in > my mind: > > What's difference/advantage-disadvantage betweeng doing multi-level > dicts/arrays like this and using tuple as a key? I.e., is it more > Pythonic to have > > dict[k1,k2] > > instead? For me, it would depend on what the data meant. To give an obvious example: if you were storing things which were based on coords, then clearly map[x, y] is more meaningful than map[x][y]. Conversely, if your dictionary structure was, say, a set of preferences for users, then prefs[username][prefname] is probably a more useful model. Sometimes it's not so clear, in which case one person might opt for one approach while another opted for another while modelling the same data concepts. If, for example, you were modelling a set of book reviews where each review might have one or more genres (which you could display as a tag-cloud, say) then you could consider the model to be a sort of book-genre tag cloud: book_genres[title, genre] or a list of books in each genre: genres[genre][title] or a list of genres for each book: books[title][genre] or even multiple ways if that made it easier to use in one situation or another. Stating-the-obvious-ly yours, TJG From __peter__ at web.de Mon Nov 14 05:47:58 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 14 Nov 2011 11:47:58 +0100 Subject: Multilevel dicts/arrays v. tuples as keys? References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: Matej Cepl wrote: > Dne 11.11.2011 14:31, macm napsal(a): >> def Dicty( dict[k1][k2] ): > > When looking at this I returned to the question which currently rolls in > my mind: > > What's difference/advantage-disadvantage betweeng doing multi-level > dicts/arrays like this and using tuple as a key? I.e., is it more > Pythonic to have > > dict[k1,k2] > > instead? If you need lookup only I'd prefer tuples, but sometimes you may want to retrieve all values with a certain k1 and d[k1] is certainly more efficient than [(k2, v) for (k1, k2), v in d.items() if k1 == wanted] From rosuav at gmail.com Mon Nov 14 05:55:43 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Nov 2011 21:55:43 +1100 Subject: my new project, is this the right way? In-Reply-To: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: On Mon, Nov 14, 2011 at 9:41 PM, Tracubik wrote: > Hi all, > i'm developing a new program. > Mission: learn a bit of database management If your goal is to learn about databasing, then I strongly recommend a real database engine. > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) The complexity, in most cases, is a direct consequence of the job at hand. I recommend PostgreSQL generally, although I've never used it with Python and can't speak for the quality of the APIs. The most important thing to consider is a separation of the back end (the "guts") from the front end (the "interface"). Since your goal is to explore databases, the guts of your code will basically just be working with the database (no heavy computation or anything). Make sure you can work with that, separately from your GUI. You may find it easier to dispense with GTK and just work through the console; you can always change later to make a pretty window. If you've never worked with databases before, it may be best to skip Python altogether and explore the fundamentals of relational database engines. There's plenty of excellent tutorials on the web. Get to know how things are done generally, and you'll be able to figure out how things are done in Python. All the best! ChrisA From andreas.perstinger at gmx.net Mon Nov 14 07:06:00 2011 From: andreas.perstinger at gmx.net (Andreas Perstinger) Date: Mon, 14 Nov 2011 13:06:00 +0100 Subject: Trying to write beautifulsoup result to a file and get error message In-Reply-To: References: Message-ID: <4EC10428.10603@gmx.net> On 2011-11-13 23:37, goldtech wrote: > If I try: > ... > soup = BeautifulSoup(ft3) > f = open(r'c:\NewFolder\clean4.html', "w") > f.write(soup) > f.close() > > I get error message: > > Traceback (most recent call last): > File "C:\Documents and Settings\user01\Desktop\py\tb1a.py", line > 203, in > f.write(soup) > TypeError: expected a character buffer object > > I want to write beautiful soup's result to a file, I am doing > something wrong. Help appreciated. BeautifulSoup takes a html document in the form of a string or file-like oject and creates an internal data-structure after parsing it: Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from BeautifulSoup import BeautifulSoup >>> html = "Demo" >>> soup = BeautifulSoup(html) >>> type(soup) To write the modified document into a file, you have to convert this structur back into a string: >>> new_html = str(soup) >>> type(new_html) >>> new_html '\n \n Demo\n \n' HTH, Andreas From love_ram2040 at yahoo.com Mon Nov 14 08:48:18 2011 From: love_ram2040 at yahoo.com (porxy) Date: Mon, 14 Nov 2011 05:48:18 -0800 (PST) Subject: new cars2011,2012,2013 Message-ID: <3976750c-d558-4c41-a492-4e4d70a6af64@p2g2000vbj.googlegroups.com> Honda Insight (2012) http://newscarsblogspotcom.blogspot.com/#!/2011/11/honda-insight-2012... Audi A2 concept (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/audi-a2-concept-20... Infiniti FX designed by Sebastian Vettel (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/infiniti-fx-design... Smart Forvision concept (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/smart-forvision-co... Honda Civic (2012) http://newscarsblogspotcom.blogspot.com/#!/2011/11/honda-civic-2012.html Ford Evos concept car (2011) news and pictures http://newscarsblogspotcom.blogspot.com/#!/2011/11/ford-evos-concept-... Fiat Panda (2012) http://newscarsblogspotcom.blogspot.com/#!/2011/11/fiat-panda-2012.html Peugeot HX1 concept car (2011) first news more picsere http://newscarsblogspotcom.blogspot.com/#!/2011/11/peugeot-hx1-concep... Citroen Tubik concept car (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/citroen-tubik-conc... Skoda MissionL concept car (2011) unveiled http://newscarsblogspotcom.blogspot.com/#!/2011/11/skoda-missionl-con... Audi A5 DTM (2012) http://newscarsblogspotcom.blogspot.com/#!/2011/11/audi-a5-dtm-2012.html Lambo Super Trofeo Stradale (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/lambo-super-trofeo... Mercedes SLK55 AMG (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/mercedes-slk55-amg... Lotus Exige S (2011) http://newscarsblogspotcom.blogspot.com/#!/2011/11/lotus-exige-s-2011... Ford Fiesta ST concept (2011) at the Frankfurt motor show http://newscarsblogspotcom.blogspot.com/#!/2011/11/ford-fiesta-st-con... From gordon at panix.com Mon Nov 14 10:24:04 2011 From: gordon at panix.com (John Gordon) Date: Mon, 14 Nov 2011 15:24:04 +0000 (UTC) Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) References: Message-ID: In "W. eWatson" writes: > I just pushed aside the python25 folder by renaming it, and installed py > 2.5.2. However, when I try to open the simplest of py programs with > IDLE, I get an error from Win7. > c:\Users\blah\...\junk.py is not a valid Win 32 app. Are you double-clicking on the .py file? What application is associated with .py files? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From wolftracks at invalid.com Mon Nov 14 10:42:27 2011 From: wolftracks at invalid.com (W. eWatson) Date: Mon, 14 Nov 2011 07:42:27 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) In-Reply-To: References: Message-ID: On 11/14/2011 7:24 AM, John Gordon wrote: > In "W. eWatson" writes: > >> I just pushed aside the python25 folder by renaming it, and installed py >> 2.5.2. However, when I try to open the simplest of py programs with >> IDLE, I get an error from Win7. > >> c:\Users\blah\...\junk.py is not a valid Win 32 app. > > Are you double-clicking on the .py file? Yes. > > What application is associated with .py files? Application? Simple ones, including the one i put here that you removed to answer my question. From redcat at catfolks.net Mon Nov 14 10:47:17 2011 From: redcat at catfolks.net (Redcat) Date: 14 Nov 2011 15:47:17 GMT Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: <9icrg5F5lhU1@mid.individual.net> > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) I know it's a lot of work to learn initially, but I would recommend taking the time to install and become familiar with a database engine such as MySQL or PostgresQL. While SQLite is easy to install and easy to use, it also cuts a lot of corners and allows you to do things that would die in a real database. For example, in SQLite column types are merely suggestions; there is nothing in SQLite to keep you from storing a string in an integer field or vice versa. For example: dan at dan:~/work$ sqlite3 SQLite version 3.7.3 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table test ( ...> id int, ...> name varchar(64), ...> comment varchar(256) ...> ); sqlite> .schema test CREATE TABLE test ( id int, name varchar(64), comment varchar(256) ); sqlite> insert into test values (1, 'Dan', 'Normal insert with valid types'); sqlite> insert into test values ('Bogosity', 2, 'Record with invalid types'); sqlite> insert into test values ('This field should be an int but is really a long string instead', 12.45, 'A really screwy record'); sqlite> select * from test; 1|Dan|Normal insert with valid types Bogosity|2|Record with invalid types This field should be an int but is really a long string instead|12.45|A really screwy record sqlite> This is not to say that SQLite is useless. Far from it - I use it frequently myself. But I've been working with SQL databases for a bunch of years, and I am familiar with the tradeoffs involved in working with SQLite. A decent tutorial on working with SQL in general can be found at http:// www.w3schools.com/sql/sql_intro.asp Installing MySQL or Postgres can be fairly simple, if you use the tools provided with your Linux distro (assuming you're running on Linux). "sudo apt-get install mysql mysql-server" or "yum install mysql mysql-server" should get you what you need to start using MySQL, "sudo apt-get install postgresql" or "yum install postgresql" should get you started with PostgresQL. From tobias.oberstein at tavendo.de Mon Nov 14 10:57:28 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 07:57:28 -0800 Subject: Py2.7/FreeBSD: maximum number of open files Message-ID: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> I am trying to convince Python to open more than 32k files .. this is on FreeBSD. Now I know I have to set appropriate limits .. I did: $ sysctl kern.maxfiles kern.maxfiles: 204800 $ sysctl kern.maxfilesperproc kern.maxfilesperproc: 200000 $ sysctl kern.maxvnodes kern.maxvnodes: 200000 $ ulimit unlimited Here is what happens with a Python freshly built from sources .. it'll tell me I can open 200k files .. but will bail out at 32k: $ ./local/bin/python -V Python 2.7.2 $ ./local/bin/python Python 2.7.2 (default, Nov 14 2011, 16:41:56) [GCC 4.2.1 20070719 [FreeBSD]] on freebsd8 Type "help", "copyright", "credits" or "license" for more information. >>> import resource >>> resource.getrlimit(resource.RLIMIT_NOFILE) (200000L, 200000L) >>> resource.getrlimit(resource.RLIMIT_OFILE) Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'RLIMIT_OFILE' >>> import resource >>> >>> max = resource.getrlimit(resource.RLIMIT_NOFILE) >>> cnt = 0 >>> print "maximum FDs", max maximum FDs (200000L, 200000L) fds = [] while cnt < max: f = open("/tmp/test1/test_%d" % cnt, "w") f.write("test") fds.append(f) cnt += 1 if cnt % 1000 == 0: print "opened %d files" % cnt print "ok, created %d files" % cnt >>> >>> fds = [] >>> >>> while cnt < max: ... f = open("/tmp/test1/test_%d" % cnt, "w") ... f.write("test") ... fds.append(f) ... cnt += 1 ... if cnt % 1000 == 0: ... print "opened %d files" % cnt ... opened 1000 files opened 2000 files opened 3000 files opened 4000 files opened 5000 files opened 6000 files opened 7000 files opened 8000 files opened 9000 files opened 10000 files opened 11000 files opened 12000 files opened 13000 files opened 14000 files opened 15000 files opened 16000 files opened 17000 files opened 18000 files opened 19000 files opened 20000 files opened 21000 files opened 22000 files opened 23000 files opened 24000 files opened 25000 files opened 26000 files opened 27000 files opened 28000 files opened 29000 files opened 30000 files opened 31000 files opened 32000 files Traceback (most recent call last): File "", line 2, in IOError: [Errno 24] Too many open files: '/tmp/test1/test_32765' >>> print "ok, created %d files" % cnt ok, created 32765 files >>> From gordon at panix.com Mon Nov 14 11:15:45 2011 From: gordon at panix.com (John Gordon) Date: Mon, 14 Nov 2011 16:15:45 +0000 (UTC) Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) References: Message-ID: In "W. eWatson" writes: > > What application is associated with .py files? > Application? Simple ones, including the one i put here that you > removed to answer my question. Eh? I can't see anywhere that you mentioned your Windows settings as to what application is associated with .py files. (You mentioned running IDLE, but I don't see that it was given as the default application for opening .py files.) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From lists at cheimes.de Mon Nov 14 11:25:13 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 17:25:13 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> Message-ID: Am 14.11.2011 16:57, schrieb Tobias Oberstein: > I am trying to convince Python to open more than 32k files .. this is on FreeBSD. > > Now I know I have to set appropriate limits .. I did: > > $ sysctl kern.maxfiles > kern.maxfiles: 204800 > $ sysctl kern.maxfilesperproc > kern.maxfilesperproc: 200000 > $ sysctl kern.maxvnodes > kern.maxvnodes: 200000 > $ ulimit > unlimited > > Here is what happens with a Python freshly built from sources .. it'll tell me I can open 200k files .. but will bail out at 32k: I'm not familiar with BSD but Linux has similar Kernel options. The kernel options might be *global* flags to set the total upper limit of open file descriptors for the entire system, not for a single process. Also on Linux "ulimit" doesn't display the fd limit. You have to use "ulimit -n". Why do you need more than 32k file descriptors anyway? It's an insanely high amount of FDs. Most programs need less than 100 and the default value of 1024 on my Linux servers is usually high enough. I've never increased the fd limit over 8192 and our biggest installation servers more than 80 TB data in about 20 to 25 million files. Christian From tobias.oberstein at tavendo.de Mon Nov 14 11:36:37 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 08:36:37 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files In-Reply-To: References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> Message-ID: <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> > I'm not familiar with BSD but Linux has similar Kernel options. The kernel > options might be *global* flags to set the total upper limit of open file > descriptors for the entire system, not for a single process. > Also on Linux "ulimit" doesn't display the fd limit. You have to use "ulimit -n". This is a dedicated machine doing nothing else .. I'm monitoring global FD usage sysctl kern.openfiles and it's way beyond the configured limit $ ulimit -n 200000 > > Why do you need more than 32k file descriptors anyway? It's an insanely high It's not for files: This is a network service .. I tested it with up to 50k TCP connections .. however at this point, when the service tries to open a file, it'll bail out. Sockets+Files both contribute to open FDs. I need 50k sockets + 100 files. Thus, this is even more strange: the Python (a Twisted service) will happily accept 50k sockets, but as soon as you do open() a file, it'll bail out. From joncle at googlemail.com Mon Nov 14 11:37:01 2011 From: joncle at googlemail.com (Jon Clements) Date: Mon, 14 Nov 2011 08:37:01 -0800 (PST) Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: <7ce7af27-0f4d-4b17-ab44-36a192028f41@e15g2000vba.googlegroups.com> On Nov 14, 10:41?am, Tracubik wrote: > Hi all, > i'm developing a new program. > Mission: learn a bit of database management > Idea: create a simple, 1 window program that show me a db of movies i've > seen with few (<10) fields (actors, name, year etc) > technologies i'll use: python + gtk > db: that's the question > > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) > > is there any general tutorial of how to start developing a database? i > mean a general guide to databases you can suggest to me? > Thank you all > > MedeoTL > > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > easily convert it in a sqlite db? (maybe via csv) I would recommend working through the book "SQL for Dummies". I found it very clear, and slowly leads you into how to think about design, not just how to manipulate databases. Instead of using Python to start with consider using OOo Base or MS Access (retching noise), so you can use RAD to play with structure and manipulation of your data and create data-entry forms -- this'll allow you to enter data, and play with queries and the structure -- as you won't get it right the first time! You will be able to get either of these programs to give you the SQL that constructs tables, or makes queries etc... That'd be enough to keep you going for a couple of weeks I guess. Also, some things make more sense in a NoSQL database, so have a look at something like MongoDB or CouchDB and how their design works differently. That's probably another couple of weeks. Also worth checking out would be http://dabodev.com hth Jon. From lists at cheimes.de Mon Nov 14 11:51:23 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 17:51:23 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> Message-ID: <4EC1470B.90403@cheimes.de> Am 14.11.2011 17:36, schrieb Tobias Oberstein: > This is a dedicated machine doing nothing else .. I'm monitoring global FD usage > > sysctl kern.openfiles > > and it's way beyond the configured limit > > $ ulimit -n > 200000 Apparently you did everything right here. Well, it was worth the try. ;) > It's not for files: > > This is a network service .. I tested it with up to 50k TCP connections .. however > at this point, when the service tries to open a file, it'll bail out. > > Sockets+Files both contribute to open FDs. > > I need 50k sockets + 100 files. > > Thus, this is even more strange: the Python (a Twisted service) will happily > accept 50k sockets, but as soon as you do open() a file, it'll bail out. A limit of 32k smells like a overflow in a signed int. Perhaps your system is able and configured to handle more than 32k FDs but you hit an artificial limit because some C code or API has a overflow. This seems to be a known bug in FreeBSD http://lists.freebsd.org/pipermail/freebsd-bugs/2010-July/040689.html Christian From tobias.oberstein at tavendo.de Mon Nov 14 12:03:46 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 09:03:46 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <4EC1470B.90403@cheimes.de> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> Message-ID: <634914A010D0B943A035D226786325D42D0C2647EB@EXVMBX020-12.exch020.serverdata.net> > > I need 50k sockets + 100 files. > > > > Thus, this is even more strange: the Python (a Twisted service) will > > happily accept 50k sockets, but as soon as you do open() a file, it'll bail out. > > A limit of 32k smells like a overflow in a signed int. Perhaps your system is > able and configured to handle more than 32k FDs but you hit an artificial limit > because some C code or API has a overflow. This seems to be a known bug in > FreeBSD http://lists.freebsd.org/pipermail/freebsd-bugs/2010- > July/040689.html This is unbelievable. I've just tested: the bug (in libc) is still there on FreeBSD 8.2 p3 ... both on i386 _and_ amd64. Now I'm f***d;( A last chance: is it possible to compile Python for not using libc fopen(), but the Posix open()? Thanks anyway for this hint! From lists at cheimes.de Mon Nov 14 12:13:12 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 18:13:12 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C2647EB@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C2647EB@EXVMBX020-12.exch020.serverdata.net> Message-ID: <4EC14C28.2020106@cheimes.de> Am 14.11.2011 18:03, schrieb Tobias Oberstein: > This is unbelievable. > > I've just tested: the bug (in libc) is still there on FreeBSD 8.2 p3 ... both on i386 > _and_ amd64. > > Now I'm f***d;( > > A last chance: is it possible to compile Python for not using libc fopen(), > but the Posix open()? > > Thanks anyway for this hint! A fix would break the ABI compatibility. I guess that you won't see a fix for the issue until FreeBSD 9.0 is released. And no, you can't re-compile Python to use the open() API instead of fopen(). The built-in file type is developed around the file pointer API, not the file descriptor API. Luckily Python 2.7 has a backport of Python 3.x new IO library. The new IO API doesn't use file pointers at all and implements its own layer around file descriptors. Good luck! Christian From wolftracks at invalid.com Mon Nov 14 12:31:47 2011 From: wolftracks at invalid.com (W. eWatson) Date: Mon, 14 Nov 2011 09:31:47 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) In-Reply-To: References: Message-ID: On 11/14/2011 8:15 AM, John Gordon wrote: > In "W. eWatson" writes: > >>> What application is associated with .py files? > >> Application? Simple ones, including the one i put here that you >> removed to answer my question. > > Eh? I can't see anywhere that you mentioned your Windows settings as > to what application is associated with .py files. > > (You mentioned running IDLE, but I don't see that it was given as the > default application for opening .py files.) > I would think the install would make the association of py to Python, either IDLE or the interpreter. If I right-click on a py file, it asks me for "Open with". If I select idle.pyw, it gives me the message I posted earlier. From joncle at googlemail.com Mon Nov 14 12:33:48 2011 From: joncle at googlemail.com (Jon Clements) Date: Mon, 14 Nov 2011 09:33:48 -0800 (PST) Subject: Py2.7/FreeBSD: maximum number of open files References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> Message-ID: On Nov 14, 5:03?pm, Tobias Oberstein wrote: > > > I need 50k sockets + 100 files. > > > > Thus, this is even more strange: the Python (a Twisted service) will > > > happily accept 50k sockets, but as soon as you do open() a file, it'll bail out. > > > A limit of 32k smells like a overflow in a signed int. Perhaps your system is > > able and configured to handle more than 32k FDs but you hit an artificial limit > > because some C code or API has a overflow. This seems to be a known bug in > > FreeBSDhttp://lists.freebsd.org/pipermail/freebsd-bugs/2010- > > July/040689.html > > This is unbelievable. > > I've just tested: the bug (in libc) is still there on FreeBSD 8.2 p3 ... both on i386 > _and_ amd64. > > Now I'm f***d;( > > A last chance: is it possible to compile Python for not using libc fopen(), > but the Posix open()? > > Thanks anyway for this hint! Have you tried/or is it possible to get your 100 or whatever files first, before your sockets? hth Jon From tobias.oberstein at tavendo.de Mon Nov 14 12:46:00 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 09:46:00 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files In-Reply-To: References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> Message-ID: <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> > > > > I need 50k sockets + 100 files. > > > > > > Thus, this is even more strange: the Python (a Twisted service) > > > > will happily accept 50k sockets, but as soon as you do open() a file, it'll > bail out. > > > > > A limit of 32k smells like a overflow in a signed int. Perhaps your > > > system is able and configured to handle more than 32k FDs but you > > > hit an artificial limit because some C code or API has a overflow. > > > This seems to be a known bug in > > > FreeBSDhttp://lists.freebsd.org/pipermail/freebsd-bugs/2010- > > > July/040689.html > > > > This is unbelievable. > > > > I've just tested: the bug (in libc) is still there on FreeBSD 8.2 p3 > > ... both on i386 _and_ amd64. > > > > Now I'm f***d;( > > > > A last chance: is it possible to compile Python for not using libc > > fopen(), but the Posix open()? > > > > Thanks anyway for this hint! > > Have you tried/or is it possible to get your 100 or whatever files first, before > your sockets? If I only needed to open a fixed set of files, that might be a workaround. However, this is not the case. I.e. Twisted will do log switching and create/open a new file when the 50k sockets are already there. I just confirmed that the bug is even there for FreeBSD 9 RC1 ! This is most unfortunate. Seriously. I am running out of options, since I am willing to make my stuff Python 3 compatible, but Twisted is not yet there. Using the backported new IO on Python 2.7 will not make open() automatically use the new IO, will it? From miki.tebeka at gmail.com Mon Nov 14 12:48:27 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 14 Nov 2011 09:48:27 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: <28344033.1206.1321292907659.JavaMail.geo-discussion-forums@prms22> > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? I think sqlite3 makes sense since it's already there and has SQL interface. > is there any general tutorial of how to start developing a database? i > mean a general guide to databases you can suggest to me? The docs (http://docs.python.org/library/sqlite3.html) have some basic instructions. > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > easily convert it in a sqlite db? (maybe via csv) This can be your first exercise :) But it should be easy to import with the csv module. From gordon at panix.com Mon Nov 14 13:00:44 2011 From: gordon at panix.com (John Gordon) Date: Mon, 14 Nov 2011 18:00:44 +0000 (UTC) Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) References: Message-ID: In "W. eWatson" writes: > I would think the install would make the association of py to Python, > either IDLE or the interpreter. I would hope so too, however you did mention that you moved the python executable to a different directory and installed a newer version, so verifying that the .py file association points to the correct application might be worthwhile. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From lists at cheimes.de Mon Nov 14 13:03:31 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 19:03:31 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> Message-ID: Am 14.11.2011 18:46, schrieb Tobias Oberstein: > I just confirmed that the bug is even there for FreeBSD 9 RC1 ! > > This is most unfortunate. Seriously. W00t, that sucks! You could migrate to another BSD (NetBSD) or Linux ... :) > I am running out of options, since I am willing to make my stuff Python 3 compatible, > but Twisted is not yet there. > > Using the backported new IO on Python 2.7 will not make open() automatically use the new IO, will it? No, the open() function of Python 2.7 will still use the file class which in return uses fopen(). You could try to monkey patch the built-in open() function. It's mostly API compatible with the current open() function: >>> import io, __builtin__ >>> __builtin__.open = io.open It works as long as no codes checks for isinstance(obj, file). If your app only has to worry about log files, you might want to overwrite the _open() method of logging.FileHandler and its subclasses. Christian From wolftracks at invalid.com Mon Nov 14 13:08:17 2011 From: wolftracks at invalid.com (W. eWatson) Date: Mon, 14 Nov 2011 10:08:17 -0800 Subject: Uninstalling Py 2.5.2 from Windows 7 (Invalid on Win 32 app) In-Reply-To: References: Message-ID: On 11/14/2011 10:00 AM, John Gordon wrote: > In "W. eWatson" writes: > >> I would think the install would make the association of py to Python, >> either IDLE or the interpreter. > > I would hope so too, however you did mention that you moved the python > executable to a different directory and installed a newer version, so > verifying that the .py file association points to the correct application > might be worthwhile. > Note though I had uninstalled Python. The folder remained, so I renamed it, then installed. I see no way that under that arrangement that py would be associated with the renamed contents. The renamed folder has no exe file for the interpreter. There is, of course, a new Python25 that shows python.exe and pythonw.exe. python.exe will bring up a command window. From tobias.oberstein at tavendo.de Mon Nov 14 13:28:21 2011 From: tobias.oberstein at tavendo.de (Tobias Oberstein) Date: Mon, 14 Nov 2011 10:28:21 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files In-Reply-To: References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> Message-ID: <634914A010D0B943A035D226786325D42D0C26485F@EXVMBX020-12.exch020.serverdata.net> > > I just confirmed that the bug is even there for FreeBSD 9 RC1 ! > > > > This is most unfortunate. Seriously. > > W00t, that sucks! You could migrate to another BSD (NetBSD) or Linux ... :) No, thanks;) > > I am running out of options, since I am willing to make my stuff > > Python 3 compatible, but Twisted is not yet there. > > > > Using the backported new IO on Python 2.7 will not make open() > automatically use the new IO, will it? > > No, the open() function of Python 2.7 will still use the file class which in > return uses fopen(). You could try to monkey patch the built-in > open() function. It's mostly API compatible with the current open() > function: > > >>> import io, __builtin__ > >>> __builtin__.open = io.open > > It works as long as no codes checks for isinstance(obj, file). If your app only > has to worry about log files, you might want to overwrite the > _open() method of logging.FileHandler and its subclasses. > Thanks! This is probably the most practical option I can go. I've just tested: the backported new IO on Python 2.7 will indeed open >32k files on FreeBSD. It also creates the files much faster. The old, non-monkey-patched version was getting slower and slower as more files were opened/created .. There seem to be slight differences though: Non-monkey patched: I can write to the file a non-Unicode string, even when the file was opened non-Binary. With monkey patch: either open the file Binary-mode, or write Unicode strings .. I need to see if / what breaks in Twisted. I can handle my own code .. no problem. Thanks alot!! import io, __builtin__ __builtin__.open = io.open import resource max = resource.getrlimit(resource.RLIMIT_NOFILE) cnt = 0 print "maximum FDs", max max = 33000 fds = [] while cnt < max: f = open("/tmp/test1/test_%d" % cnt, "wb") f.write("test") fds.append(f) cnt += 1 if cnt % 1000 == 0: print "opened %d files" % cnt print "ok, created %d files" % cnt From steve at sprangle.com Mon Nov 14 14:30:15 2011 From: steve at sprangle.com (Steve Edlefsen) Date: Mon, 14 Nov 2011 12:30:15 -0700 Subject: can't decompress data; zlib not available In-Reply-To: <1321221305.12661.6.camel@tim-laptop> References: <4EC009D7.90100@sprangle.com> <1321221305.12661.6.camel@tim-laptop> Message-ID: <4EC16C47.9000604@sprangle.com> Sorry about that. Ubuntu 11.10. I used Plone-4.1.2-UnifiedInstaller.tar which installed o.k. I'm serving a webpage on my LAN. I did a search on files named "python" on my machine. There are 23 not including the ones in the Plone buildout-cache in my account. Seems like a lot of applications install their own copy of python. There are also ./usr/lib/x86_64-linux-gnu/libz.so ./usr/lib/libz.so which, I believe, are the zlib libraries. I've read that you can reinstall python with configure using the "--with-zlib" option, but configure isn't in /usr/local/Plone/Python-2.6/lib/python2.6/config I think the python interpreter for the command line is the one in /usr/bin/python. Would this be the one I reconfigure for zlib? Should I simply install python from Python-3.2.2.tgz? On 11/13/2011 02:55 PM, Tim Wintle wrote: > On Sun, 2011-11-13 at 11:17 -0700, Steve Edlefsen wrote: >> which appears to install zlib when python is reinstalled. Except I >> can't run make without errors and there is no configuration file. >> >> How do I reinstall python to include zlib? > Which OS are you on? Linux? BSD? > > How did you install Plone? > > First I'd check if there's a module shadowing the builtin zlib module - > i.e. if you've got a local file called "zlib.py" which is getting > imported by mistake. > > > Fairly much all *nix systems will have a python installation out of the > box - it looks like you need python2.6 > > I've never had a missing zlib module - but it's possible that it might > be missing if you don't have the zlib/deflate headers installed - if > they're not available then I'd try installing them and then reinstalling > the package you started with. > > Tim Wintle > From lists at cheimes.de Mon Nov 14 14:34:31 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 20:34:31 +0100 Subject: Py2.7/FreeBSD: maximum number of open files In-Reply-To: <634914A010D0B943A035D226786325D42D0C26485F@EXVMBX020-12.exch020.serverdata.net> References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C26485F@EXVMBX020-12.exch020.serverdata.net> Message-ID: <4EC16D47.3000607@cheimes.de> Am 14.11.2011 19:28, schrieb Tobias Oberstein: > Thanks! This is probably the most practical option I can go. > > I've just tested: the backported new IO on Python 2.7 will indeed > open >32k files on FreeBSD. It also creates the files much faster. > The old, non-monkey-patched version was getting slower and > slower as more files were opened/created .. I wonder what's causing the O(n^2) behavior. Is it the old file type or BSD's fopen() fault? > There seem to be slight differences though: > > Non-monkey patched: I can write to the file a non-Unicode string, > even when the file was opened non-Binary. > > With monkey patch: either open the file Binary-mode, or > write Unicode strings .. Python 3.x doesn't collate data and text but distinguishes between bytes (str type in Python 2.x) and unicode. You can't write unicode to a binary file and str to a text file. See it as an opportunity! You are taking the first step towards Python 3 compatibility. :) Christian From lists at cheimes.de Mon Nov 14 14:50:39 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Nov 2011 20:50:39 +0100 Subject: can't decompress data; zlib not available In-Reply-To: <4EC16C47.9000604@sprangle.com> References: <4EC009D7.90100@sprangle.com> <1321221305.12661.6.camel@tim-laptop> <4EC16C47.9000604@sprangle.com> Message-ID: Am 14.11.2011 20:30, schrieb Steve Edlefsen: > Sorry about that. Ubuntu 11.10. > > I used > > Plone-4.1.2-UnifiedInstaller.tar > > which installed o.k. I'm serving a webpage on my LAN. > > I did a search on files named "python" on my machine. > There are 23 not including the ones in the Plone > buildout-cache in my account. Seems like a lot of > applications install their own copy of python. > > There are also > > ../usr/lib/x86_64-linux-gnu/libz.so > ../usr/lib/libz.so > > which, I believe, are the zlib libraries. > > I've read that you can reinstall python with configure > using the "--with-zlib" option, but configure isn't in > > /usr/local/Plone/Python-2.6/lib/python2.6/config > > I think the python interpreter for the command line is > the one in /usr/bin/python. Would this be the one I > reconfigure for zlib? You might have run into this [1] issue with Ubuntu 11.04+ and Python before 2.7.2. Christian [1] http://lipyrary.blogspot.com/2011/05/how-to-compile-python-on-ubuntu-1104.html From chris.martel at gmail.com Mon Nov 14 15:57:37 2011 From: chris.martel at gmail.com (Chris Martel) Date: Mon, 14 Nov 2011 12:57:37 -0800 (PST) Subject: Python Developer needed for Catalina Marketing - St. Petersburg Message-ID: <7430fa93-e8a0-41e5-8fd5-3a4b5fe40cc4@l19g2000yqc.googlegroups.com> We, at Catalina Marketing, are in need of a Python Developer for 3 - 6 months. You'd be writing highly sophisticated scripting in OO classes (cron) for our coupon campaigns. Also using SQLite, Oracle, and Netezza. Prefer someone who has at least 3-5 years of Python and database experience. The other skills are secondary. You would be a direct Catalina temporary employee, or we can do a C2C arrangement. Also if you know of someone who might be interested, I would muchly appreciate the referral. Please contact Chris Martel if interested: chris.martel at catalinamarketing.com, 727-579-5434. Catalina Marketing Corp. provides behavior-based marketing solutions for brand manufacturers, retailers, and healthcare providers. It offers campaign management services; Catalina Category Marketing, a behavior-based merchandising event; Catalina Interactive, which allows the user to communicate with consumers online; Catalina Product Alert, which tracks down actual recalled product buyers; Checkout Coupon, which targets consumers at the transaction level; Checkout Direct, which allows brands and retailers to target households based on past purchase behavior; Checkout Prizes, which builds product volume and generates in-store/brand excitement by pre-announcing sweepstakes events; and Checkout Rx, a household and transactional database. The company also provides competitive benchmarks; Connection Builder, a Web-based business intelligence application designed to support analytical needs; data mining services; Loyalty Quotient, a strategic application; new product launch programs; PatientLink, which delivers healthcare messages; PatientLinkMC, which delivers PatientLink messages in the patient's language of choice; Pay for Performance, which allows brand manufacturers to influence consumers before they reach the point of sale; PharmAware, which delivers educational messages about pharmaceutical products for pharmacists and their staff; Rebate Max, a program that simplifies customer participation in various manufacturer-funded rebate offers; and RxConx, an integrated wellness marketing solution. In addition, it offers retail consulting services. The company serves various brands, retailers, and healthcare markets. Catalina Marketing Corp. was founded in 1983 and is based in St. Petersburg, Florida with locations in the United States, the United Kingdom, the Netherlands, Japan, Italy, Germany, France, and Belgium. From tim.wintle at teamrubber.com Mon Nov 14 16:01:06 2011 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Mon, 14 Nov 2011 21:01:06 +0000 Subject: can't decompress data; zlib not available In-Reply-To: <4EC16C47.9000604@sprangle.com> References: <4EC009D7.90100@sprangle.com> <1321221305.12661.6.camel@tim-laptop> <4EC16C47.9000604@sprangle.com> Message-ID: <1321304466.32356.14.camel@tim-laptop> On Mon, 2011-11-14 at 12:30 -0700, Steve Edlefsen wrote: > I did a search on files named "python" on my machine. > There are 23 not including the ones in the Plone > buildout-cache in my account. Seems like a lot of > applications install their own copy of python. > > There are also > > ./usr/lib/x86_64-linux-gnu/libz.so > ./usr/lib/libz.so > > which, I believe, are the zlib libraries. but do you have the headers? On my ubuntu it's /usr/include/zlib.h As Christian pointed out, Ubuntu 11.04 introduced some changes which may have broken the installation - there is a patch on the python bug tracker which will provide a work-around, but it is not going to be applied to 2.6 or lower as they are not actively maintained branches any more. You'll need to run through the steps that the plone installer makes and patch the extracted python directory before it makes it's local python. > I've read that you can reinstall python with configure > using the "--with-zlib" option, but configure isn't in > > /usr/local/Plone/Python-2.6/lib/python2.6/config > > I think the python interpreter for the command line is > the one in /usr/bin/python. Would this be the one I > reconfigure for zlib? Should I simply install python from > > Python-3.2.2.tgz? no - you need to use python2.6 - python3 is effectively a different language. python is a core part of *nix these days, so playing around recompiling the system python can cause a lot of pain. Tim From ethan at stoneleaf.us Mon Nov 14 16:53:29 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 14 Nov 2011 13:53:29 -0800 Subject: else in try/except Message-ID: <4EC18DD9.1070301@stoneleaf.us> The code in 'else' in a 'try/except/else[/finally]' block seems pointless to me, as I am not seeing any difference between having the code in the 'else' suite vs having the code in the 'try' suite. Can anybody shed some light on this for me? ~Ethan~ From python at mrabarnett.plus.com Mon Nov 14 17:59:35 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 14 Nov 2011 22:59:35 +0000 Subject: else in try/except In-Reply-To: <4EC18DD9.1070301@stoneleaf.us> References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: <4EC19D57.8000907@mrabarnett.plus.com> On 14/11/2011 21:53, Ethan Furman wrote: > The code in 'else' in a 'try/except/else[/finally]' block seems > pointless to me, as I am not seeing any difference between having the > code in the 'else' suite vs having the code in the 'try' suite. > > Can anybody shed some light on this for me? > The difference is that if an exception occurs in the else block it won't be caught by the exception handlers of the try statement. From arnodel at gmail.com Mon Nov 14 18:03:55 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Mon, 14 Nov 2011 23:03:55 +0000 Subject: else in try/except In-Reply-To: <4EC18DD9.1070301@stoneleaf.us> References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: On 14 November 2011 21:53, Ethan Furman wrote: > The code in 'else' in a 'try/except/else[/finally]' block seems pointless to > me, as I am not seeing any difference between having the code in the 'else' > suite vs having the code in the 'try' suite. > > Can anybody shed some light on this for me? Exceptions in the else clause will not be caught. Look at the difference between the two try clauses below: >>> def f(): raise TypeError ... >>> try: ... print("try") ... f() ... except TypeError: ... print("except") ... try except >>> try: ... print("try") ... except TypeError: ... print("except") ... else: ... f() ... try Traceback (most recent call last): File "", line 6, in File "", line 1, in f TypeError >>> HTH -- Arnaud From ckaynor at zindagigames.com Mon Nov 14 18:12:13 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Mon, 14 Nov 2011 15:12:13 -0800 Subject: else in try/except In-Reply-To: <4EC19D57.8000907@mrabarnett.plus.com> References: <4EC18DD9.1070301@stoneleaf.us> <4EC19D57.8000907@mrabarnett.plus.com> Message-ID: On Mon, Nov 14, 2011 at 2:59 PM, MRAB wrote: > On 14/11/2011 21:53, Ethan Furman wrote: >> >> The code in 'else' in a 'try/except/else[/finally]' block seems >> pointless to me, as I am not seeing any difference between having the >> code in the 'else' suite vs having the code in the 'try' suite. >> >> Can anybody shed some light on this for me? >> > The difference is that if an exception occurs in the else block it > won't be caught by the exception handlers of the try statement. Consider the examples: try: a raise RuntimeError() except RuntimeError: pass vs try: a except RuntimeError: pass else: raise RuntimeError() The first example will not raise an exception, while the second will result in a RuntimeError. Effectively, the first block will either: 1) If the "a" block raises a RuntimeError, continue, 2) If the "a" block raised any other error, propergate it, 3) If the "a" block does not raise an exception, continue. while the second block will either: 1) If the "a" block raises a RuntimeError, continue, 2) If the "a" block raised any other error, propergate it, 3) If the "a" block does not raise an exception, raise a RuntimeError. Note the difference in the 3rd case. > -- > http://mail.python.org/mailman/listinfo/python-list > From devplayer at gmail.com Mon Nov 14 18:59:39 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 14 Nov 2011 15:59:39 -0800 (PST) Subject: Opportunity missed by Python ? References: <4e96b324$0$1007$426a34cc@news.free.fr> <1dd5aa8c-7a41-4108-8940-ef666cd2ddb9@t38g2000prg.googlegroups.com> Message-ID: What I don't get is, having seen Python's syntax with indentation instead of open and closing puncuation and other -readability- structures in Python's syntax, is if someone is going to invent any new language, how could they NOT take Python's visual structures (read as readability) and copy it, whether it be a compiled language, explicidly typed checked or whatever underlying mechanism they want to make that code executable. From ethan at stoneleaf.us Mon Nov 14 19:15:16 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 14 Nov 2011 16:15:16 -0800 Subject: else in try/except In-Reply-To: <4EC18DD9.1070301@stoneleaf.us> References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: <4EC1AF14.3010401@stoneleaf.us> Thanks, all! ~Ethan~ From rosuav at gmail.com Mon Nov 14 19:28:10 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Nov 2011 11:28:10 +1100 Subject: Opportunity missed by Python ? In-Reply-To: References: <4e96b324$0$1007$426a34cc@news.free.fr> <1dd5aa8c-7a41-4108-8940-ef666cd2ddb9@t38g2000prg.googlegroups.com> Message-ID: On Tue, Nov 15, 2011 at 10:59 AM, DevPlayer wrote: > What I don't get is, having seen Python's syntax with indentation > instead of open and closing puncuation and other -readability- > structures in Python's syntax, is if someone is going to invent any > new language, how could they NOT take Python's visual structures (read > as readability) and copy it, whether it be a compiled language, > explicidly typed checked or whatever underlying mechanism they want to > make that code executable. What I would say is: How could they NOT be aware of Python's visual structures. There are tradeoffs, and just because something works for one language doesn't mean it's right for every other. I doubt the Dart developers were unaware of Python's structural style, so the choice to not use such was most likely conscious. (It may have been as simple as "let's keep the syntax mostly JS-like, to make it easier for JS developers to grok" though, rather than a major language-design choice.) ChrisA From rowen at uw.edu Mon Nov 14 20:00:38 2011 From: rowen at uw.edu (Russell E. Owen) Date: Mon, 14 Nov 2011 17:00:38 -0800 Subject: Decorator question: prefer class, but only function works References: Message-ID: In article , Ian Kelly wrote: > On Thu, Nov 10, 2011 at 2:52 PM, Russell E. Owen wrote: > > I am trying to write a decorator that times an instance method and > > writes the results to a class member variable. For example: > > > > def timeMethod(func): > > ? ?def wrapper(self, *args, **keyArgs): > > ? ? ? ?t1 = time.time() > > ? ? ? ?res = func(self, *args, **keyArgs) > > ? ? ? ?duration = time.time() - t1 > > ? ? ? ?self.timings[func.__name__] = duration > > ? ? ? ?return res > > ? ?return wrapper > > > > This works, but I'm not very happy with the way self.timings is obtained. > > What do you feel is wrong with it? Oops, I stripped so much out of my example that I stripped the ugly bit. This is closer to the original and demonstrated the issue: def timeMethod(func): name = func.__name__ + "Duration" def wrapper(self, *args, **keyArgs): ? ? t1 = time.time() ? ? ? ?res = func(self, *args, **keyArgs) ? ? ? ?duration = time.time() - t1 ? ? ? ?self.timings[name] = duration ? ? ? ?return res ? ?return wrapper I don't like the way name is passed into wrapper. It works, but it looks like magic. A class offers an obvious place to save the information. Or I could just generate the name each time. I realize I'm showing the limits of my understanding of python binding of variable names, but I also think that if I find it confusing then others will, as well. > sum(os.times()[:2]) instead, which (assuming your script is > single-threaded) will more accurately count the actual CPU time spent > in the function rather than real time, which could be quite different > if the CPU is busy. Thanks for the suggestion. I decided to use time.clock(), which I understand gives basically the same information (at a resolution that is sufficient for my needs). > Also, why do you need this? If you're just trying to evaluate the > speed of your code, you should consider using a proper profiler or the > timeit module. The former will tell you how much time is spent in > each function, while the latter runs the code a large number of times > in a loop, which gives you better precision for quick methods. It is for timing stages of a data processing pipeline. Only long-running tasks will be timed. Repeatedly running to get better times is neither practical nor necessary to get a good feeling of where the time is being spent. > > I first tried to write this as a class (for readability), and this did > > NOT work: > > > > class timeMethod(object): > > ? ?def __init__(self, func): > > ? ? ? ?self.func = func > > ? ?def __call__(self, *args, **keyArgs): > > ? ? ? ?t1 = time.time() > > ? ? ? ?res = self.func(*args, **keyArgs) > > ? ? ? ?duration = time.time() - t1 > > ? ? ? ?args[0].timings.set(self.func.__name__, duration) > > ? ? ? ?return res > > > > In the first case the wrapper is called as an unbound function, so it > > works. But in the second case the wrapper is called as a bound method -- > > thus args[0] is not func's class instance, and I can't get to the > > timings attribute. > > I prefer the function version myself, but to make this work you could > add something like this (untested) to make your wrapper class a > descriptor that tacks on the self argument: > > def __get__(self, instance, owner): > from functools import partial > if instance is None: > return self > return partial(self, instance) Thank you very much. I'll stick to the function, since it works, but it's nice to know how to work around the problem. From dbinks at codeaurora.org Mon Nov 14 20:09:39 2011 From: dbinks at codeaurora.org (Dominic Binks) Date: Mon, 14 Nov 2011 17:09:39 -0800 Subject: Opportunity missed by Python ? In-Reply-To: References: <4e96b324$0$1007$426a34cc@news.free.fr> <1dd5aa8c-7a41-4108-8940-ef666cd2ddb9@t38g2000prg.googlegroups.com> Message-ID: <4EC1BBD3.2020006@codeaurora.org> I believe Occam had a visual structure and was compiled. In fact it was even more picky than Python in this respect IIRC. On 11/14/2011 4:28 PM, Chris Angelico wrote: > On Tue, Nov 15, 2011 at 10:59 AM, DevPlayer wrote: >> What I don't get is, having seen Python's syntax with indentation >> instead of open and closing puncuation and other -readability- >> structures in Python's syntax, is if someone is going to invent any >> new language, how could they NOT take Python's visual structures (read >> as readability) and copy it, whether it be a compiled language, >> explicidly typed checked or whatever underlying mechanism they want to >> make that code executable. > > What I would say is: How could they NOT be aware of Python's visual > structures. There are tradeoffs, and just because something works for > one language doesn't mean it's right for every other. I doubt the Dart > developers were unaware of Python's structural style, so the choice to > not use such was most likely conscious. (It may have been as simple as > "let's keep the syntax mostly JS-like, to make it easier for JS > developers to grok" though, rather than a major language-design > choice.) > > ChrisA -- Dominic Binks: dbinks at codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum From wuwei23 at gmail.com Mon Nov 14 22:07:34 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 14 Nov 2011 19:07:34 -0800 (PST) Subject: Multilevel dicts/arrays v. tuples as keys? References: <8f5215a8-d08f-4355-a5a2-77fcaa32c92d@j10g2000vbe.googlegroups.com> Message-ID: <74d33315-beb0-4b4e-90bb-0cac8c91c5e6@j19g2000pro.googlegroups.com> Peter Otten <__pete... at web.de> wrote: > If you need lookup only I'd prefer tuples, but sometimes you may want to > retrieve all values with a certain k1 and > > d[k1] > > is certainly more efficient than > > [(k2, v) for (k1, k2), v in d.items() if k1 == wanted] This was the hidden cost of the tuple/reverse-dictionary solution I offered. The solution will of course depend on what the OP requires to be more efficient: looking up keys from values, or working with subsets of the data. From steve+comp.lang.python at pearwood.info Mon Nov 14 22:10:34 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 03:10:34 GMT Subject: Opportunity missed by Python ? References: <4e96b324$0$1007$426a34cc@news.free.fr> <1dd5aa8c-7a41-4108-8940-ef666cd2ddb9@t38g2000prg.googlegroups.com> Message-ID: <4ec1d829$0$29989$c3e8da3$5496439d@news.astraweb.com> On Mon, 14 Nov 2011 15:59:39 -0800, DevPlayer wrote: > What I don't get is, having seen Python's syntax with indentation > instead of open and closing puncuation and other -readability- > structures in Python's syntax, is if someone is going to invent any new > language, how could they NOT take Python's visual structures (read as > readability) and copy it, whether it be a compiled language, explicidly > typed checked or whatever underlying mechanism they want to make that > code executable. Because sometimes people have priorities other than readability. Or they actually *like* braces. (I know, crazy!) In fairness, the significant indentation is not all peaches and cream, it has a dark side too. For example, the difference between visually indistinguishable spaces and tabs can be meaningful (in Python 2, your code may be broken if you mix spaces and tabs; in Python 3, the compiler will give you an error). If you work in a noisy environment that eats whitespace, such as crappy web forums, people using HTML email, editors with unfriendly word-wrapping rules, and the like, you might miss having braces. I occasionally see emails with code looking something like this: print(something) while x < 100: print(something_else) x -= 1 if x % 2 == 1: some_function() else: another_function() third_function() print(x) So the "off-side rule", as it is called, is not uncontroversial. Languages developed by old-school language developers or academics, like Google's Go language, tend to be very conservative and hence require braces or even semicolons. http://en.wikipedia.org/wiki/Off-side_rule So many people keep asking for braces in Python that one of the developers (Guido?) gave in and added it to the language. Just run from __future__ import braces at the top of your file, or at the interactive interpreter, and you're done. My own opinion is that the time I save with significant indentation is a hundred times greater than the time I lose due to mangled code without braces. So I consider Python's design a big win, but other people may make other value judgments. -- Steven From steve+comp.lang.python at pearwood.info Mon Nov 14 22:22:03 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 03:22:03 GMT Subject: Decorator question: prefer class, but only function works References: Message-ID: <4ec1dada$0$29989$c3e8da3$5496439d@news.astraweb.com> On Mon, 14 Nov 2011 17:00:38 -0800, Russell E. Owen wrote: > Oops, I stripped so much out of my example that I stripped the ugly bit. > This is closer to the original and demonstrated the issue: > > def timeMethod(func): > name = func.__name__ + "Duration" > def wrapper(self, *args, **keyArgs): > ? ? t1 = time.time() > ? ? ? ?res = func(self, *args, **keyArgs) > ? ? ? ?duration = time.time() - t1 > ? ? ? ?self.timings[name] = duration > ? ? ? ?return res > ? ?return wrapper > > I don't like the way name is passed into wrapper. It works, but it looks > like magic. A class offers an obvious place to save the information. Or > I could just generate the name each time. The pattern you are seeing is called a closure, and it is a very important, if advanced, part of Python programming. Of course, you don't *have* to use closures, but it isn't scarily-advanced (like metaclass programming) but only moderately advanced, and there will be a lot of code out there using closures. http://en.wikipedia.org/wiki/Closure_(computer_science) Basically a closure is a function which remembers just enough of its current environment (the value of non-local variables) so that it can continue to work in the future, even if those non-locals change or disappear. I take it you are aware that timing code as shown is only suitable for long-running code, and not small snippets? For small snippets, you should use the timeit module. You might also find this recipe useful: http://code.activestate.com/recipes/577896/ -- Steven From brownbar at gmail.com Mon Nov 14 23:53:06 2011 From: brownbar at gmail.com (Barry W Brown) Date: Mon, 14 Nov 2011 20:53:06 -0800 (PST) Subject: else in try/except In-Reply-To: References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: <33343034.1390.1321332786394.JavaMail.geo-discussion-forums@yqbl36> I thought that the point of the else clause is that it is reached only if there is no exception in the try clause. From brownbar at gmail.com Mon Nov 14 23:53:06 2011 From: brownbar at gmail.com (Barry W Brown) Date: Mon, 14 Nov 2011 20:53:06 -0800 (PST) Subject: else in try/except In-Reply-To: References: <4EC18DD9.1070301@stoneleaf.us> Message-ID: <33343034.1390.1321332786394.JavaMail.geo-discussion-forums@yqbl36> I thought that the point of the else clause is that it is reached only if there is no exception in the try clause. From jason.swails at gmail.com Tue Nov 15 00:18:28 2011 From: jason.swails at gmail.com (Jason Swails) Date: Tue, 15 Nov 2011 00:18:28 -0500 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Mon, Nov 14, 2011 at 3:49 AM, Chris Angelico wrote: > On Mon, Nov 14, 2011 at 6:11 PM, Jason Swails > wrote: > > Then, I can reactivate all of the buttons in the destroy() method before > > calling the destroy() method of Toplevel on self. > > Small side point that might save you some work: Instead of disabling > and enabling all the buttons, disable the whole window. I don't know > Tkinter well enough to know if there's an easy way to create a modal > window, but the thing to do is to disable the entire window rather > than just its command buttons - that's the least astonishing[1] user > interface technique. > Of course! Windows are widgets just like everything else is, and so can be configured to be in the DISABLED state just like a button can. I'm not used to this hierarchy in which the root window presides over all, yet is still a widget just like everything else. But there's a lot of GUI programming that I haven't wrapped my head around yet (which is why I'm running with this pet project -- but it's bound to be ugly :)). Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Nov 15 00:32:06 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Nov 2011 16:32:06 +1100 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 4:18 PM, Jason Swails wrote: > Of course!? Windows are widgets just like everything else is, and so can be > configured to be in the DISABLED state just like a button can.? I'm not used > to this hierarchy in which the root window presides over all, yet is still a > widget just like everything else. > > But there's a lot of GUI programming that I haven't wrapped my head around > yet (which is why I'm running with this pet project -- but it's bound to be > ugly :)). Heh, I grew up on OS/2 and everything was an object. (With a few exceptions; the minimize/maximize/close buttons are all a single object, rather than being three.) It's not normal to disable the title bar while leaving the window enabled, but if you want to, you can! As a general rule, if any parent is invisible, you won't see the child, and if any parent is disabled, you can't access the child. You may find that there's even a one-line command that will disable the window, open a new window, wait for the new window to close, and automatically reenable the window - an "open modal dialog" function or something. ChrisA From devplayer at gmail.com Tue Nov 15 02:39:51 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 14 Nov 2011 23:39:51 -0800 (PST) Subject: simple import hook References: <4EBBF15D.9090401@gmail.com> Message-ID: <09619112-407e-49ba-87df-ceed03e7789e@v5g2000yqn.googlegroups.com> An alternative approach: http://pastebin.com/z6pNqFYE or: # devplayer at gmail.com # 2011-Nov-15 # recordimports.py # my Import Hook Hack in response to: # http://groups.google.com/group/comp.lang.python/browse_thread/thread/5a5d5c724f142eb5?hl=en # as an initial learning exercise # This code needs to come before any imports you want recorded # usually just once in the initial (main) module # Of course you can excluding the if __name__ == '__main__': demo code # barely tested: # only tested with modules that had no errors on import # did not need/use/expect/try reload() # ran with Python 2.7 on Win32 # create two fake modules moda.py and modb.py and stick some imports in them ''' Exerpt from PEP 302 -- New Import Hooks ... Motivation: - __import__ gets called even for modules that are already in sys.modules, which is almost never what you want, unless you're writing some sort of monitoring tool. Note the last two words.''' # ======================================================================= # place to save Collected imports imported = [] # save old __builtins__.__import__() __builtins__.__dict__['__old_import__'] = __builtins__.__dict__['__import__'] # match __builtins__.__import__() function signature def __myimport(name, globals={}, locals={}, fromlist=[], level=-1): global imported # I don't know why this works. __name__ = locals['__name__'] __file__ = locals['__file__'] __package__ = locals['__package__'] __doc__ = locals['__doc__'] # call original __import__ module = __builtins__.__old_import__(name, globals, locals, fromlist, level) # save import module name into namespace __builtins__.__dict__[name] = module tag = (name, __name__, __file__, __package__, module) # do not append duplicates if tag not in imported: imported.append( tag ) return module # store the new __import__ into __builtins__ __builtins__.__dict__['__import__'] = __myimport # erase unneed func name del __myimport # ======================================================================= # demo if __name__ == '__main__': # import some random packages/modules import sys import moda # a test module that does some other imports import modb # a test module that does some imports from pprint import pprint # imported has name, __name__, __file__, __package__ # show each import for n, __n, __f, __p, m in imported: print n print ' ', __n print ' ', __f print ' ', __p print del n, __n, __f, __p, m print 'recordimports.py' pprint(dir(), None, 4, 1) print print 'moda.py' pprint(dir(moda), None, 4, 1) print print 'modb.py' pprint(dir(modb), None, 4, 1) # print imported print From whatsjacksemail at gmail.com Tue Nov 15 06:14:17 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Tue, 15 Nov 2011 11:14:17 +0000 Subject: Opportunity missed by Python ? In-Reply-To: References: <4e96b324$0$1007$426a34cc@news.free.fr> Message-ID: On Thu, Oct 13, 2011 at 11:07 AM, Chris Angelico wrote: > On Thu, Oct 13, 2011 at 8:45 PM, candide wrote: > > Dart is the very new language created by Google to replace Javascript. > > So Python was not able to do the job? Or may be they don't know about > Python > > at Google ;) ? > > > > Also, Dart is looking to support (optional) strict typing, which > Python doesn't do. That's a fairly major performance enhancement. > > Traits from Enthought has defined types. I'm no expert mind so might not be suitable. Cheers, Jack -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From suhasrm at gmail.com Tue Nov 15 07:04:51 2011 From: suhasrm at gmail.com (Roark) Date: Tue, 15 Nov 2011 04:04:51 -0800 (PST) Subject: Execute a command on remote machine in python Message-ID: Hi, I am first time trying my hands on python scripting and would need some guidance from the experts on my problem. I want to execute a windows command within python script from a client machine on a remote target server, and would want the output of the command written in a file on client machine. What is the way it could be achieved. Thanks in advance, Roark. From martin.hellwig at gmail.com Tue Nov 15 08:29:23 2011 From: martin.hellwig at gmail.com (Martin P. Hellwig) Date: Tue, 15 Nov 2011 13:29:23 +0000 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: On 11/15/11 12:04, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. > If your doing windows to windows then you could wrap PsExec (sysinternals) or the open source but more or less abandoned RemCom (http://sourceforge.net/projects/rce). Disadvantage is that both of them are a royal PITA to wrap nicely. There are multiple problems with re-redirected STDOUT/STDERR Advantage is that you don't need to configure anything on the target machine. hth -- mph From kwa at kuwata-lab.com Tue Nov 15 08:34:30 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Tue, 15 Nov 2011 22:34:30 +0900 Subject: PREFIX directory for pip command Message-ID: Is it possible to specify PREFIX directory for pip command by environment variable? I found that 'pip install --install-option=--prefix=PREFIX' works well, but I don't want to specify '--install-option=--prefix=PREFIX' every time. I prefer to specify it by environment variable such as:: export PIP_INSTALL_DIR=$PWD/local Is it possible? Or any idea? -- regards, makoto From nawijn at gmail.com Tue Nov 15 08:54:14 2011 From: nawijn at gmail.com (Marco Nawijn) Date: Tue, 15 Nov 2011 05:54:14 -0800 (PST) Subject: Execute a command on remote machine in python References: Message-ID: On Nov 15, 1:04?pm, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. > > Thanks in advance, > Roark. Hello Roark, If the command does not change over time, an option could be to encapsulate the command and the output behind an XML-RPC interface. I used it several times now and for me this works perfectly. XML-RPC is part of the Python standard library, so it should work out of the box on windows and linux. It also supports mixed programming languages (maybe C# on windows to get the info you want and python on linux on the client). Kind regards, Marco From jeanmichel at sequans.com Tue Nov 15 09:03:49 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 15 Nov 2011 15:03:49 +0100 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: <4EC27145.6070203@sequans.com> Martin P. Hellwig wrote: > On 11/15/11 12:04, Roark wrote: >> Hi, >> >> I am first time trying my hands on python scripting and would need >> some guidance from the experts on my problem. >> >> I want to execute a windows command within python script from a client >> machine on a remote target server, and would want the output of the >> command written in a file on client machine. What is the way it could >> be achieved. >> > > If your doing windows to windows then you could wrap PsExec > (sysinternals) or the open source but more or less abandoned RemCom > (http://sourceforge.net/projects/rce). > > Disadvantage is that both of them are a royal PITA to wrap nicely. > There are multiple problems with re-redirected STDOUT/STDERR > > Advantage is that you don't need to configure anything on the target > machine. > > hth have a look at execnet http://codespeak.net/execnet/ It allows you to execute python code on a remote machine, assuming the distant machine has python installed. Work fine with either nix or windows systems. Regarding the file transfert, it sounds like pywin32 provides the netcopy service, but I'm not sure, I'm not working with windows. JM From rosuav at gmail.com Tue Nov 15 09:10:51 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 01:10:51 +1100 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 11:04 PM, Roark wrote: > Hi, > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. This looks like a job for SSH. ChrisA From contact at xavierho.com Tue Nov 15 09:16:23 2011 From: contact at xavierho.com (Xavier Ho) Date: Wed, 16 Nov 2011 00:16:23 +1000 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: It sounds like Fabric is what you're after. We use it at work and it's the best thing since ssh. ;] http://docs.fabfile.org/en/1.3.2/index.html (Actually, it uses ssh internally and allows you to do remote shell-like programming in a pythonic fashion.) Cheers, Xav On 15 November 2011 22:04, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. > > > Thanks in advance, > Roark. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roy at panix.com Tue Nov 15 09:20:50 2011 From: roy at panix.com (Roy Smith) Date: Tue, 15 Nov 2011 09:20:50 -0500 Subject: Execute a command on remote machine in python References: Message-ID: In article , Chris Angelico wrote: > On Tue, Nov 15, 2011 at 11:04 PM, Roark wrote: > > Hi, > > > > I want to execute a windows command within python script from a client > > machine on a remote target server, and would want the output of the > > command written in a file on client machine. What is the way it could > > be achieved. > > This looks like a job for SSH. You might also want to look at fabric (http://fabfile.org). It's a nice python library for remote command execution built on top of SSH. A more general answer is that, yes, SSH is the right thing to be looking at for your basic connectivity, data transport and remote command execution. But trying to deal with raw SSH will drive you batty. Something like fabric, layered on top of SSH, will make things a lot easier. From invalid at invalid.invalid Tue Nov 15 09:31:56 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 15 Nov 2011 14:31:56 +0000 (UTC) Subject: else in try/except References: <4EC18DD9.1070301@stoneleaf.us> <33343034.1390.1321332786394.JavaMail.geo-discussion-forums@yqbl36> Message-ID: On 2011-11-15, Barry W Brown wrote: > I thought that the point of the else clause is that it is reached > only if there is no exception in the try clause. Not really. If that's all you wanted, then you just put the code at the end of the try block. -- Grant Edwards grant.b.edwards Yow! ... I see TOILET at SEATS ... gmail.com From usenet at solar-empire.de Tue Nov 15 09:33:42 2011 From: usenet at solar-empire.de (Marc Christiansen) Date: Tue, 15 Nov 2011 15:33:42 +0100 Subject: PREFIX directory for pip command References: Message-ID: <6r9ap8-2to.ln1@pluto.solar-empire.de> Makoto Kuwata wrote: > Is it possible to specify PREFIX directory for pip command by > environment variable? > > I found that 'pip install --install-option=--prefix=PREFIX' works well, > but I don't want to specify '--install-option=--prefix=PREFIX' every time. > I prefer to specify it by environment variable such as:: > > export PIP_INSTALL_DIR=$PWD/local > > Is it possible? Or any idea? I'd try export PIP_INSTALL_OPTION=--prefix=$PWD/local using a config file is also possible. See http://www.pip-installer.org/en/latest/configuration.html Ciao Marc From robert.kern at gmail.com Tue Nov 15 10:06:15 2011 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 15 Nov 2011 15:06:15 +0000 Subject: else in try/except In-Reply-To: References: <4EC18DD9.1070301@stoneleaf.us> <33343034.1390.1321332786394.JavaMail.geo-discussion-forums@yqbl36> Message-ID: On 11/15/11 2:31 PM, Grant Edwards wrote: > On 2011-11-15, Barry W Brown wrote: > >> I thought that the point of the else clause is that it is reached >> only if there is no exception in the try clause. > > Not really. If that's all you wanted, then you just put the code at > the end of the try block. No, he's right. You should only put code in the try: block where you want exceptions to be caught. Everything else should be outside of the block. You really do want to minimize the amount of code inside the try: block. try: # minimal code that might raise exceptions that you want to catch except ThisError: # handle ThisError exceptions, and probably continue execution except ThatError: # handle ThatError exceptions, and probably continue execution else: # Code that only runs if ThisError or ThatError were not # raised in the try: block. This code may raise ThisError or ThatError # exceptions that should not be caught by the above except: blocks. # Other code that runs regardless if a caught-and-continued exception # was raised or not -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From kwa at kuwata-lab.com Tue Nov 15 10:40:34 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Wed, 16 Nov 2011 00:40:34 +0900 Subject: PREFIX directory for pip command In-Reply-To: <6r9ap8-2to.ln1@pluto.solar-empire.de> References: <6r9ap8-2to.ln1@pluto.solar-empire.de> Message-ID: On Tue, Nov 15, 2011 at 11:33 PM, Marc Christiansen wrote: > > I'd try > ?export PIP_INSTALL_OPTION=--prefix=$PWD/local It works very well. Thank you. -- regards, makoto > > using a config file is also possible. See > http://www.pip-installer.org/en/latest/configuration.html > > Ciao > Marc > -- > http://mail.python.org/mailman/listinfo/python-list > From rodrick.brown at gmail.com Tue Nov 15 10:57:16 2011 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Tue, 15 Nov 2011 10:57:16 -0500 Subject: Execute a command on remote machine in python In-Reply-To: References: Message-ID: You could easily script this with popen calling secure shell to execute a command and capture the output. Sent from my iPhone On Nov 15, 2011, at 7:04 AM, Roark wrote: > Hi, > > I am first time trying my hands on python scripting and would need > some guidance from the experts on my problem. > > I want to execute a windows command within python script from a client > machine on a remote target server, and would want the output of the > command written in a file on client machine. What is the way it could > be achieved. > > > Thanks in advance, > Roark. > -- > http://mail.python.org/mailman/listinfo/python-list From amalguseynov at gmail.com Tue Nov 15 11:02:13 2011 From: amalguseynov at gmail.com (BOOK-AZ) Date: Tue, 15 Nov 2011 08:02:13 -0800 (PST) Subject: all() is slow? References: Message-ID: <98bccd44-92b0-4a98-92c0-fb56a2ce847d@hh9g2000vbb.googlegroups.com> On Nov 7, 1:00?pm, "OKB (not okblacke)" wrote: > ? ? ? ? I noticed this (Python 2.6.5 on Windows XP): > http://book-az.com > >>> import random, timeit > >>> def myAll(x): > > ... ? ? for a in x: > ... ? ? ? ? if a not in (True, False): > ... ? ? ? ? ? ? return False > ... ? ? return True>>> x = [random.choice([True, False]) for a in xrange(0, 5000000)] > >>> timeit.timeit('myAll(x)', 'from __main__ import myAll, x', > > number=10) > 0: 9.7685158309226452>>> timeit.timeit('all(a in (True, False) for a in x)', 'from __main__ > > import x', number=10) > 1: 12.348196768024984>>> x = [random.randint(0,100) for a in xrange(0, 5000000)] > >>> def myAll(x): > > ... ? ? for a in x: > ... ? ? ? ? if not a <= 100: > ... ? ? ? ? ? ? return False > ... ? ? return True>>> timeit.timeit('myAll(x)', 'from __main__ import myAll, x', > > number=10) > 4: 2.8248207523582209>>> timeit.timeit('all(a <= 100 for a in x)', 'gc.enable(); from > > __main__ import x', number=10) > 5: 4.6433557896324942 > > ? ? ? ? What is the point of the all() function being a builtin if it's > slower than writing a function to do the check myself? > > -- > --OKB (not okblacke) > Brendan Barnwell > "Do not follow where the path may lead. ?Go, instead, where there is > no path, and leave a trail." > ? ? ? ? --author unknown From ramit.prasad at jpmorgan.com Tue Nov 15 12:01:23 2011 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 15 Nov 2011 17:01:23 +0000 Subject: Extracting elements over multiple lists? In-Reply-To: <4EB828B3.1020509@sequans.com> References: <4EB828B3.1020509@sequans.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> >>for x in a, b, c: >> del x[0] >for arr in [a,b,c]: > arr.pop(0) >(Peter's "del" solution is quite close, but I find the 'del' statement >tricky in python and will mislead many python newcomers) Can you expand on why 'del' is "tricky"/misleading? Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From babiucandreea at gmail.com Tue Nov 15 12:11:10 2011 From: babiucandreea at gmail.com (Andreea Babiuc) Date: Tue, 15 Nov 2011 17:11:10 +0000 Subject: suppressing import errors Message-ID: Hi, Is there a way to suppress all the errors when importing a module in python? By that I mean.. If I have other imports in the module I'm trying to import that fail, I still want my module to be imported that way.. Many thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckaynor at zindagigames.com Tue Nov 15 12:24:03 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 15 Nov 2011 09:24:03 -0800 Subject: suppressing import errors In-Reply-To: References: Message-ID: As with any Python code, you can wrap the import into a try: except block. try: import badModule except: pass # Or otherwise handle the exception - possibly importing an alternative module. As with any except statement, specific exceptions may be caught (rather than the blank, catch everything). Chris On Tue, Nov 15, 2011 at 9:11 AM, Andreea Babiuc wrote: > Hi, > > Is there a way to suppress all the errors when importing a module in python? > > By that I mean.. If I have other imports in the module I'm trying to import > that fail, I still want my module to be imported that way.. > > Many thanks. > > -- > http://mail.python.org/mailman/listinfo/python-list > > From ramit.prasad at jpmorgan.com Tue Nov 15 12:26:51 2011 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 15 Nov 2011 17:26:51 +0000 Subject: overview on dao In-Reply-To: <96a0fc78-aa96-4830-bc26-b3efbb75e65b@f3g2000pri.googlegroups.com> References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> <96a0fc78-aa96-4830-bc26-b3efbb75e65b@f3g2000pri.googlegroups.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474018427@SCACMX008.exchad.jpmchase.net> >> Perhaps you should call it "LaoZiDao". >I just prefer shorter name. DAO as Data Access Objects is a common acronym in several languages (i.e. Java), so you will continually have this naming conflict. Just be aware that this conflict will happen frequently in the minds of many programmers. Ramit P.S. I vote for PyLaoziDao :P Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From babiucandreea at gmail.com Tue Nov 15 12:35:09 2011 From: babiucandreea at gmail.com (Andreea Babiuc) Date: Tue, 15 Nov 2011 17:35:09 +0000 Subject: suppressing import errors In-Reply-To: References: Message-ID: On 15 November 2011 17:24, Chris Kaynor wrote: > As with any Python code, you can wrap the import into a try: except block. > > try: > import badModule > except: > > pass # Or otherwise handle the exception - possibly importing an > alternative module. > > Hmm, I know this might sound silly, but if it fails I still want to import the module and disable those lines of code that are related to the reason while the module failed to be imported in the first place. Even if that makes the code not 100% correct. Does that make sense ? > As with any except statement, specific exceptions may be caught > (rather than the blank, catch everything). > > Chris > > On Tue, Nov 15, 2011 at 9:11 AM, Andreea Babiuc > wrote: > > Hi, > > > > Is there a way to suppress all the errors when importing a module in > python? > > > > By that I mean.. If I have other imports in the module I'm trying to > import > > that fail, I still want my module to be imported that way.. > > > > Many thanks. > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Blog: Http://andreeababiuc.ro Photo Portfolio: http://royaa.daportfolio.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From devplayer at gmail.com Tue Nov 15 12:56:03 2011 From: devplayer at gmail.com (DevPlayer) Date: Tue, 15 Nov 2011 09:56:03 -0800 (PST) Subject: simple import hook References: <4EBBF15D.9090401@gmail.com> <09619112-407e-49ba-87df-ceed03e7789e@v5g2000yqn.googlegroups.com> Message-ID: And for an insane amount of what REALLY gets imported: python.exe -B -s -S -v -v -v -v your_module_here.py %1 %2 %3 %4 %5 %6 %7 %8 %9 or more appropiately: python -v -v -v -v your_module_here.py And for completeness, if you feel those options aren't telling the whole truth, you can turn on your operating system's file auditing for opens and reads; I forget if there are other places that can be imported from besides *.py, *.pyo, *.pyc, *.pyd files too (maybe zips?) From fraveydank at gmail.com Tue Nov 15 12:57:11 2011 From: fraveydank at gmail.com (David Riley) Date: Tue, 15 Nov 2011 12:57:11 -0500 Subject: suppressing import errors In-Reply-To: References: Message-ID: On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote: > > > On 15 November 2011 17:24, Chris Kaynor wrote: > As with any Python code, you can wrap the import into a try: except block. > > try: > import badModule > except: > > > pass # Or otherwise handle the exception - possibly importing an > alternative module. > > > Hmm, I know this might sound silly, but if it fails I still want to import the module and disable those lines of code that are related to the reason while the module failed to be imported in the first place. Even if that makes the code not 100% correct. > > Does that make sense ? It makes sense. It probably also makes sense to only do an "except ImportError", since if there are other errors (say, syntax errors in a module you're trying to import, rather than its absence, you probably want to know about it. To disable code that won't work without the module you're trying to import, you can always set flags in your module. For example, I've got a project at work that can use a variety of communications interfaces, including using PySerial for serial port comms. But if someone doesn't have PySerial installed, I want it to fail gracefully and just not support serial. So I can do the following: try: import serial _serial_enabled = True except ImportError: print("PySerial not installed - serial ports not supported!") _serial_enabled = False And then elsewhere in my module, I can check the value of _serial_enabled to see if I should e.g. list the serial ports in available communications interfaces. Of course, if there's some other error in PySerial (maybe I installed a broken version with a syntax error?), that error will get propagated up, which is a good thing, because I'd rather know that PySerial is broken than just have it tell me it's not installed (which is what would happen if I simply caught all exceptions). Your mileage may vary. - Dave From d at davea.name Tue Nov 15 13:17:48 2011 From: d at davea.name (Dave Angel) Date: Tue, 15 Nov 2011 13:17:48 -0500 Subject: Extracting elements over multiple lists? In-Reply-To: <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> References: <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> Message-ID: <4EC2ACCC.2000100@davea.name> On 11/15/2011 12:01 PM, Prasad, Ramit wrote: > >> (Peter's "del" solution is quite close, but I find the 'del' statement >> tricky in python and will mislead many python newcomers) > Can you expand on why 'del' is "tricky"/misleading? > > Ramit > a = someexpression... b = a .... del a Does not (necessarily) delete the object that a refers to. It merely deletes the symbol a. -- DaveA From python at mrabarnett.plus.com Tue Nov 15 13:44:44 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 15 Nov 2011 18:44:44 +0000 Subject: overview on dao In-Reply-To: <5B80DD153D7D744689F57F4FB69AF474018427@SCACMX008.exchad.jpmchase.net> References: <4bd0b85e-a426-444b-be7e-9793d1ba3ec1@h23g2000pra.googlegroups.com> <79f616cb-8fc7-42f7-a455-3c2adbb01fa7@u24g2000pru.googlegroups.com> <96a0fc78-aa96-4830-bc26-b3efbb75e65b@f3g2000pri.googlegroups.com> <5B80DD153D7D744689F57F4FB69AF474018427@SCACMX008.exchad.jpmchase.net> Message-ID: <4EC2B31C.4060502@mrabarnett.plus.com> On 15/11/2011 17:26, Prasad, Ramit wrote: >>> Perhaps you should call it "LaoZiDao". >> I just prefer shorter name. > > DAO as Data Access Objects is a common acronym in several languages (i.e. Java), > so you will continually have this naming conflict. Just be aware that this > conflict will happen frequently in the minds of many programmers. > > Ramit > > P.S. I vote for PyLaoziDao :P > Just don't confuse it with PyDao, which is already taken. :-) From jeanmichel at sequans.com Tue Nov 15 13:58:30 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 15 Nov 2011 19:58:30 +0100 Subject: suppressing import errors In-Reply-To: References: Message-ID: <4EC2B656.7050902@sequans.com> David Riley wrote: > On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote: > > >> On 15 November 2011 17:24, Chris Kaynor wrote: >> As with any Python code, you can wrap the import into a try: except block. >> >> try: >> import badModule >> except: >> >> >> pass # Or otherwise handle the exception - possibly importing an >> alternative module. >> >> >> Hmm, I know this might sound silly, but if it fails I still want to import the module and disable those lines of code that are related to the reason while the module failed to be imported in the first place. Even if that makes the code not 100% correct. >> >> Does that make sense ? >> > > It makes sense. It probably also makes sense to only do an "except ImportError", since if there are other errors (say, syntax errors in a module you're trying to import, rather than its absence, you probably want to know about it. > > To disable code that won't work without the module you're trying to import, you can always set flags in your module. For example, I've got a project at work that can use a variety of communications interfaces, including using PySerial for serial port comms. But if someone doesn't have PySerial installed, I want it to fail gracefully and just not support serial. So I can do the following: > > > try: > import serial > _serial_enabled = True > except ImportError: > print("PySerial not installed - serial ports not supported!") > _serial_enabled = False > > > And then elsewhere in my module, I can check the value of _serial_enabled to see if I should e.g. list the serial ports in available communications interfaces. > > Of course, if there's some other error in PySerial (maybe I installed a broken version with a syntax error?), that error will get propagated up, which is a good thing, because I'd rather know that PySerial is broken than just have it tell me it's not installed (which is what would happen if I simply caught all exceptions). Your mileage may vary. > > - Dave > > If I'm not wrong the OP wants to disable the line *in the module being imported*, which is kindof silly and doesn't make sense to answer his question. Anreea, tell us why the module you are importing is failing and if this module is yours, we may provide you a proper way to handle this situation (though I'm pretty sure everything is in Dave's proposal). JM PS : @Dave there is a way to avoiding adding symbols to your global namespace, assign None to the module's name on import errors. Then before using it, just test the module bool value : if serial: serial.whateverMethod() From alisha1551 at gmail.com Tue Nov 15 14:06:45 2011 From: alisha1551 at gmail.com (alisha alisha) Date: Tue, 15 Nov 2011 11:06:45 -0800 (PST) Subject: Gossip Protocol in Python Message-ID: Hi All, I am new to Python. I have to implement a overlay network of around 500 nodes which are arranged as a random graph. To generate theoverlay network I will be using networkx. My query is, is there a way to implement Gossip protocol in my overlay network using Python. Like one node initiated the Gossip of a message, then in how many epoch time it reaches all the nodes in the network. Thanks. Regards, Alisha From info at wingware.com Tue Nov 15 14:18:51 2011 From: info at wingware.com (Wingware) Date: Tue, 15 Nov 2011 14:18:51 -0500 Subject: Wing IDE 4.1.1 released Message-ID: <4EC2BB1B.8080506@wingware.com> Hi, Wingware has released version 4.1.1 of Wing IDE, an integrated development environment designed specifically for the Python programming language. Wing IDE is a cross-platform Python IDE that provides a professional code editor with vi, emacs, and other key bindings, auto-completion, call tips, refactoring, context-aware auto-editing, a powerful graphical debugger, version control, unit testing, search, and many other features. **Changes in Version 4.1.1** Highlights of this release include: * Goto-definition on symbols in the shells * Expanded and improved auto-editing support (enable this in the Edit > Keyboard Personality menu): * Auto-closing * Auto-enter invocation args * Apply quote/comment/paren/etc to selection * Auto-enter spaces * Insert EOL and indent for new block * Continue comment on new line * Auto-indent when pasting multi-line text in Python code (undo once restores original indentation) * Improved Smart Tab key option for Python * Indent to Match menu and tool bar items toggle indentation to one indent position lower if already at matching indent level * Improved auto-indent of else, elif, except, and finally * Experimental Turbo auto-completer mode for Python that treats any non-word key as a completion key and Ctrl, Alt, and Command as a cancel keys * Link to docs.python.org in Source Assistant * Include argument names in auto-completer during invocation * About 30 other bug fixes and minor improvements Complete change log: http://wingware.com/pub/wingide/4.1.1/CHANGELOG.txt **New Features in Version 4** Version 4 adds the following new major features: * Refactoring -- Rename/move symbols, extract to function/method, and introduce variable * Find Uses -- Find all points of use of a symbol * Auto-Editing -- Reduce typing burden by auto-entering expected code * Diff/Merge -- Graphical file and repository comparison and merge * Django Support -- Debug Django templates, run Django unit tests, and more * matplotlib Support -- Maintains live-updating plots in shell and debugger * Simplified Licensing -- Includes all OSes and adds Support+Upgrades subscriptions Details on licensing changes: http://wingware.com/news/2011-02-16 **About Wing IDE** Wing IDE is an integrated development environment designed specifically for the Python programming language. It provides powerful editing, testing, and debugging features that help reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. Wing IDE can be used to develop Python code for web, GUI, and embedded scripting applications. Wing IDE is available in three product levels: Wing IDE Professional is the full-featured Python IDE, Wing IDE Personal offers a reduced feature set at a low price, and Wing IDE 101 is a free simplified version designed for teaching beginning programming courses with Python. Version 4.0 of Wing IDE Professional includes the following major features: * Professional quality code editor with vi, emacs, and other keyboard personalities * Code intelligence for Python: Auto-completion, call tips, find uses, goto-definition, error indicators, refactoring, context-aware auto-editing, smart indent and rewrapping, and source navigation * Advanced multi-threaded debugger with graphical UI, command line interaction, conditional breakpoints, data value tooltips over code, watch tool, and externally launched and remote debugging * Powerful search and replace options including keyboard driven and graphical UIs, multi-file, wild card, and regular expression search and replace * Version control integration for Subversion, CVS, Bazaar, git, Mercurial, and Perforce * Integrated unit testing with unittest, nose, and doctest frameworks * Django support: Debugs Django templates, provides project setup tools, and runs Django unit tests * Many other features including project manager, bookmarks, code snippets, diff/merge tool, OS command integration, indentation manager, PyLint integration, and perspectives * Extremely configurable and may be extended with Python scripts * Extensive product documentation and How-Tos for Django, matplotlib, Plone, wxPython, PyQt, mod_wsgi, Autodesk Maya, and many other frameworks Please refer to http://wingware.com/wingide/features for a detailed listing of features by product level. System requirements are Windows 2000 or later, OS X 10.3.9 or later (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Wing IDE supports Python versions 2.0.x through 3.2.x and Stackless Python. For more information, see the http://wingware.com/ **Downloads** Wing IDE Professional and Wing IDE Personal are commercial software and require a license to run. A free trial can be obtained directly from the product when launched. Wing IDE Pro -- Full-featured product: http://wingware.com/downloads/wingide/4.1 Wing IDE Personal -- A simplified IDE: http://wingware.com/downloads/wingide-personal/4.1 Wing IDE 101 -- For teaching with Python: http://wingware.com/downloads/wingide-101/4.1 **Purchasing and Upgrading** Wing 4.x requires an upgrade for Wing IDE 2.x and 3.x users at a cost of 1/2 the full product pricing. Upgrade a license: https://wingware.com/store/upgrade Purchase a new license: https://wingware.com/store/purchase Optional Support+Upgrades subscriptions are available for expanded support coverage and free upgrades to new major releases: http://wingware.com/support/agreement Thanks! -- The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com From fraveydank at gmail.com Tue Nov 15 14:39:01 2011 From: fraveydank at gmail.com (David Riley) Date: Tue, 15 Nov 2011 14:39:01 -0500 Subject: suppressing import errors In-Reply-To: <4EC2B656.7050902@sequans.com> References: <4EC2B656.7050902@sequans.com> Message-ID: <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> On Nov 15, 2011, at 1:58 PM, Jean-Michel Pichavant wrote: > PS : @Dave there is a way to avoiding adding symbols to your global namespace, assign None to the module's name on import errors. Then before using it, just test the module bool value : if serial: serial.whateverMethod() True, and that does avoid polluting namespace. However, you shouldn't be testing for None as a bool; you should instead do an "if is None:" (or, of course, "is not None"). - Dave From rosuav at gmail.com Tue Nov 15 14:53:26 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 06:53:26 +1100 Subject: Extracting elements over multiple lists? In-Reply-To: <4EC2ACCC.2000100@davea.name> References: <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> <4EC2ACCC.2000100@davea.name> Message-ID: On Wed, Nov 16, 2011 at 5:17 AM, Dave Angel wrote: > a = someexpression... > b = a > .... > del a > > Does not (necessarily) delete the object that a refers to. ?It merely > deletes the symbol a. I'd have to classify that as part of the change of thinking necessary for a refcounted language, and not specific to del at all. The del statement is identical to "a = None" in terms of deleting objects; someone who's come from C++ might want to explicitly del every variable before returning, but that's the only way that it's tied to 'del'. ChrisA From rosuav at gmail.com Tue Nov 15 15:01:40 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 07:01:40 +1100 Subject: suppressing import errors In-Reply-To: <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Wed, Nov 16, 2011 at 6:39 AM, David Riley wrote: > True, and that does avoid polluting namespace. ?However, you shouldn't be testing for None as a bool; you should instead do an "if is None:" (or, of course, "is not None"). Why not? Is there some other way for the module object to evaluate as false? ChrisA From passiday at gmail.com Tue Nov 15 15:37:03 2011 From: passiday at gmail.com (Passiday) Date: Tue, 15 Nov 2011 12:37:03 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript Message-ID: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Hello, I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? From rosuav at gmail.com Tue Nov 15 15:45:52 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 07:45:52 +1100 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: On Wed, Nov 16, 2011 at 7:37 AM, Passiday wrote: > The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. Hmm. If it's to be an educational platform, I would recommend doing something like the W3Schools "tryit" page [1] and just go back to the server each time. You have potential security issues to watch out for (so it may be worth chrooting your interpreter), but it's sure to be easier than rewriting the entire interpreter in another language. You would have to maintain your implementation as the language evolves, keep it bug-free, etc, etc. ChrisA [1] eg http://www.w3schools.com/html/tryit.asp?filename=tryhtml_basic From ian.g.kelly at gmail.com Tue Nov 15 15:52:49 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 15 Nov 2011 13:52:49 -0700 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: On Tue, Nov 15, 2011 at 1:37 PM, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. You could take a look at pyjamas, but it's precompiled. I don't know whether they have support for runtime compilation at all. From stef.mientki at gmail.com Tue Nov 15 16:08:28 2011 From: stef.mientki at gmail.com (Stef Mientki) Date: Tue, 15 Nov 2011 22:08:28 +0100 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: <4EC2D4CC.2090601@gmail.com> On 15-11-2011 21:37, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? skulpt ? cheers, Stef From fraveydank at gmail.com Tue Nov 15 16:20:33 2011 From: fraveydank at gmail.com (David Riley) Date: Tue, 15 Nov 2011 16:20:33 -0500 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Nov 15, 2011, at 3:01 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 6:39 AM, David Riley wrote: >> True, and that does avoid polluting namespace. However, you shouldn't be testing for None as a bool; you should instead do an "if is None:" (or, of course, "is not None"). > > Why not? Is there some other way for the module object to evaluate as false? Well, probably not. It was my understanding that "None" evaluating to a Boolean false was not necessarily guaranteed; I've even gotten some warnings from Python to that effect, though I can't recall the context in which that happened. In any case, PEP 8 states: Comparisons to singletons like None should always be done with 'is' or 'is not', never the equality operators. Also, beware of writing "if x" when you really mean "if x is not None" -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context! Obviously, that last bit doesn't apply to modules; they're not going to evaluate as False in general. I just bristle when I see people writing "if x" when they really mean "if x is not None", perhaps because it's not The Right Way(tm)? It mostly comes down to aesthetics, I guess. Write what you really mean. - Dave From rosuav at gmail.com Tue Nov 15 16:34:02 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 08:34:02 +1100 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Wed, Nov 16, 2011 at 8:20 AM, David Riley wrote: > ? ?Comparisons to singletons like None should always be done with > ? ? ?'is' or 'is not', never the equality operators. > > ? ? ?Also, beware of writing "if x" when you really mean "if x is not None" > ? ? ?-- e.g. when testing whether a variable or argument that defaults to > ? ? ?None was set to some other value. ?The other value might have a type > ? ? ?(such as a container) that could be false in a boolean context! It's probably quicker to execute "if x is None" than "if x" (presumably the former just compares the two pointers). On the other hand, it's more compact to leave off the "is None". And on the gripping hand, neither "quicker to execute" nor "more compact" equates to "more Pythonic". ChrisA From arnodel at gmail.com Tue Nov 15 16:42:22 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 15 Nov 2011 21:42:22 +0000 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On 15 November 2011 21:34, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 8:20 AM, David Riley wrote: >> ? ? ?Comparisons to singletons like None should always be done with >> ? ? ?'is' or 'is not', never the equality operators. >> >> ? ? ?Also, beware of writing "if x" when you really mean "if x is not None" >> ? ? ?-- e.g. when testing whether a variable or argument that defaults to >> ? ? ?None was set to some other value. ?The other value might have a type >> ? ? ?(such as a container) that could be false in a boolean context! > > It's probably quicker to execute "if x is None" than "if x" > (presumably the former just compares the two pointers). On the other > hand, it's more compact to leave off the "is None". And on the > gripping hand, neither "quicker to execute" nor "more compact" equates > to "more Pythonic". It's idiomatic to write "x is None" when you want to know whether x is None. -- Arnaud From ian.g.kelly at gmail.com Tue Nov 15 17:09:31 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 15 Nov 2011 15:09:31 -0700 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Tue, Nov 15, 2011 at 2:42 PM, Arnaud Delobelle wrote: > It's idiomatic to write "x is None" when you want to know whether x is None. It's also idiomatic to just write "if x:" when you want to know whether x is something or nothing, and that's what I would probably do here. Either is correct. From tjreedy at udel.edu Tue Nov 15 17:15:18 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 15 Nov 2011 17:15:18 -0500 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: On 11/15/2011 3:52 PM, Ian Kelly wrote: > On Tue, Nov 15, 2011 at 1:37 PM, Passiday wrote: >> Hello, >> >> I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. >> >> I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > You could take a look at pyjamas, but it's precompiled. I don't know > whether they have support for runtime compilation at all. Perhaps one could use pyjamas to compile pypy to javascript ;-). -- Terry Jan Reedy From steve+comp.lang.python at pearwood.info Tue Nov 15 17:21:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 22:21:41 GMT Subject: Extracting elements over multiple lists? References: <4EB828B3.1020509@sequans.com> Message-ID: <4ec2e5f4$0$29970$c3e8da3$5496439d@news.astraweb.com> On Tue, 15 Nov 2011 17:01:23 +0000, Prasad, Ramit wrote: > Can you expand on why 'del' is "tricky"/misleading? People often imagine that the del statement sends a message to the object "please delete yourself", which then calls the __del__ method. That is incorrect. "del x" is an unbinding operation, it removes the *name* "x" from the current namespace. As a side-effect, if the object which was bound to x no longer has any other references to it, then the garbage collector will delete it and __del__ may be called. (I say "may be called" rather than "will" because there are circumstances where __del__ methods won't get called, such as during interpreter shutdown.) On the other hand, "del x[i]" does work like the way people expect. It deletes items from collections (lists, dicts, etc.) and does so by calling the method x.__delitem__(i). This also may cause the garbage collector to delete the object which was at x[i] if that was the last reference to that object. CPython's implementation keeps a count of references for each object, and the garbage collector deletes the object immediately that reference count reaches zero. This is fast, simple, deterministic (objects will be predictably deleted as soon as they can be), but simple-minded, and so it is aided by a second garbage collector which runs periodically, looking for reference cycles. You can set how often this second garbage collector runs using the gc module. Jython uses the Java garbage collector, and IronPython the .Net garbage collector. Neither are reference counters, and (as far as I know) neither guarantees that objects will be deleted as soon as they are free to be deleted. They will be deleted whenever the garbage collector gets around to it. -- Steven From ckaynor at zindagigames.com Tue Nov 15 17:22:21 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 15 Nov 2011 14:22:21 -0800 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: On Tue, Nov 15, 2011 at 1:34 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 8:20 AM, David Riley wrote: >> ? ? ?Comparisons to singletons like None should always be done with >> ? ? ?'is' or 'is not', never the equality operators. >> >> ? ? ?Also, beware of writing "if x" when you really mean "if x is not None" >> ? ? ?-- e.g. when testing whether a variable or argument that defaults to >> ? ? ?None was set to some other value. ?The other value might have a type >> ? ? ?(such as a container) that could be false in a boolean context! > > It's probably quicker to execute "if x is None" than "if x" > (presumably the former just compares the two pointers). On the other > hand, it's more compact to leave off the "is None". And on the > gripping hand, neither "quicker to execute" nor "more compact" equates > to "more Pythonic". I decided to run some tests to see which is faster. As is turns out, in simple cases (eg, True), "if x: pass" is faster than "if x is None: pass" if x is True, and otherwise its the same. If x is a custom type (I only tested a simple custom class written in Python), "if x is None: pass" is significantly faster. Overall, performance-wise, it is irrelevant - use the code that is the most clear in the situation. Only if there is a custom type involved, and then only if that type defines Python code to be executed, does it matter. The tests (the code is shown later - its about 53 lines, with lots of copy+paste...): 1a: 0.04 usec/pass -- if None: pass 1b: 0.03 usec/pass -- if True: pass 1c: 0.27 usec/pass -- if customObjectWithNonZero: pass 1d: 0.04 usec/pass -- if customObjectNoNonZero: pass 2a: 0.04 usec/pass -- if None is None: pass 2b: 0.04 usec/pass -- if True is None: pass 2c: 0.04 usec/pass -- if customObjectWithNonZero is None: pass 2d: 0.04 usec/pass -- if customObjectNoNonZero is None: pass The tests were run on Python 2.6x64 on Windows: 2.6.4 (r264:75706, Aug 4 2010, 17:00:56) [MSC v.1500 64 bit (AMD64)] The code: import timeit def test(): numRuns = 10000000 statement1 = 'if x: pass' statement2 = 'if x is None: pass' setup1 = 'x = None' setup2 = 'x = True' setup3 = ''' class Test(object): def __nonzero__(self): return True x = Test()''' setup4 = ''' class Test(object): pass x = Test()''' t1a = timeit.Timer(stmt=statement1, setup=setup1) t1b = timeit.Timer(stmt=statement1, setup=setup2) t1c = timeit.Timer(stmt=statement1, setup=setup3) t1d = timeit.Timer(stmt=statement1, setup=setup4) t2a = timeit.Timer(stmt=statement2, setup=setup1) t2b = timeit.Timer(stmt=statement2, setup=setup2) t2c = timeit.Timer(stmt=statement2, setup=setup3) t2d = timeit.Timer(stmt=statement2, setup=setup4) a1 = [] b1 = [] c1 = [] d1 = [] a2 = [] b2 = [] c2 = [] d2 = [] for i in xrange(10): a1.append(1000000 * t1a.timeit(number=numRuns)/numRuns) b1.append(1000000 * t1b.timeit(number=numRuns)/numRuns) c1.append(1000000 * t1c.timeit(number=numRuns)/numRuns) d1.append(1000000 * t1d.timeit(number=numRuns)/numRuns) a2.append(1000000 * t2a.timeit(number=numRuns)/numRuns) b2.append(1000000 * t2b.timeit(number=numRuns)/numRuns) c2.append(1000000 * t2c.timeit(number=numRuns)/numRuns) d2.append(1000000 * t2d.timeit(number=numRuns)/numRuns) print "1a: %.2f usec/pass" % (sum(a1) / len(a1),) print "1b: %.2f usec/pass" % (sum(b1) / len(b1),) print "1c: %.2f usec/pass" % (sum(c1) / len(c1),) print "1d: %.2f usec/pass" % (sum(d1) / len(d1),) print "2a: %.2f usec/pass" % (sum(a2) / len(a2),) print "2b: %.2f usec/pass" % (sum(b2) / len(b2),) print "2c: %.2f usec/pass" % (sum(c2) / len(c2),) print "2d: %.2f usec/pass" % (sum(d2) / len(d2),) > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > From steve+comp.lang.python at pearwood.info Tue Nov 15 17:25:16 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 22:25:16 GMT Subject: Extracting elements over multiple lists? References: <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> <4EC2ACCC.2000100@davea.name> Message-ID: <4ec2e6cb$0$29970$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Nov 2011 06:53:26 +1100, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 5:17 AM, Dave Angel wrote: >> a = someexpression... >> b = a >> .... >> del a >> >> Does not (necessarily) delete the object that a refers to. ?It merely >> deletes the symbol a. > > I'd have to classify that as part of the change of thinking necessary > for a refcounted language, and not specific to del at all. Languages aren't refcounted. Or at least, *Python* isn't a refcounted language. CPython is a refcounted implementation. IronPython and Jython are not. del behaves exactly the same in IronPython and Jython as it does in CPython: it removes the name, which may have a side-effect of deleting the object. > The del > statement is identical to "a = None" in terms of deleting objects; I'm not entirely sure what you arr trying to say here. I *think* you are trying to say is this: Given that `a` is bound to my_object initially, `del a` from the point of view of my_object is no different from re-binding a to some other object such as None (or any other object). which is true as far as it goes, but it fails to note that the name "a" no longer exists after `del a` while it does exist after `a = None`. -- Steven From steve+comp.lang.python at pearwood.info Tue Nov 15 17:34:34 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Nov 2011 22:34:34 GMT Subject: suppressing import errors References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: <4ec2e8fa$0$29970$c3e8da3$5496439d@news.astraweb.com> On Tue, 15 Nov 2011 14:22:21 -0800, Chris Kaynor wrote: > The tests (the code is shown later - its about 53 lines, with lots of > copy+paste...): Holy unnecessarily complicated code Batman! This is much simpler: [steve at ando ~]$ python -m timeit -s "x = None" "if x is None: pass" 10000000 loops, best of 3: 0.0738 usec per loop [steve at ando ~]$ python -m timeit -s "x = True" "if x is None: pass" 10000000 loops, best of 3: 0.0799 usec per loop The difference is too small to be significant. If I run the same tests multiple times, the winner could easily change. -- Steven From rosuav at gmail.com Tue Nov 15 17:54:15 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 09:54:15 +1100 Subject: Extracting elements over multiple lists? In-Reply-To: <4ec2e6cb$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> <4EC2ACCC.2000100@davea.name> <4ec2e6cb$0$29970$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Nov 16, 2011 at 9:25 AM, Steven D'Aprano wrote: > Languages aren't refcounted. Or at least, *Python* isn't a refcounted > language. CPython is a refcounted implementation. IronPython and Jython > are not. del behaves exactly the same in IronPython and Jython as it does > in CPython: it removes the name, which may have a side-effect of deleting > the object. Yes, I was sloppy there. A non-manually-memory-managed language, if you will; it's part of Python's spec that you do NOT have to explicitly release objects you're no longer using. >> The del >> statement is identical to "a = None" in terms of deleting objects; > > I'm not entirely sure what you arr trying to say here. I *think* you are > trying to say is this: > > ? ?Given that `a` is bound to my_object initially, `del a` > ? ?from the point of view of my_object is no different > ? ?from re-binding a to some other object such as None > ? ?(or any other object). > > which is true as far as it goes, but it fails to note that the name "a" > no longer exists after `del a` while it does exist after `a = None`. Right. Both actions have the same effect wrt deleting my_object; the only connection between Python's "del" and C++'s "delete" is that, which del shares with "a = None". The fact is that, regardless of the Python implementation, deleting *objects* is not the programmer's responsibility. The only thing he can or must do is delete *names*. del a del globals()['a'] globals().__delitem__('a') are all roughly equivalent (assuming that a is global). Maybe this is the best way to explain it - that you're deleting from a "dictionary" (which may or may not actually be implemented as a dict) of local names. ChrisA From ameyer2 at yahoo.com Tue Nov 15 17:59:12 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 15 Nov 2011 17:59:12 -0500 Subject: suppressing import errors In-Reply-To: References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> Message-ID: <4EC2EEC0.2090806@yahoo.com> On 11/15/2011 4:20 PM, David Riley wrote: ... > None was set to some other value. The other value might have a type > (such as a container) that could be false in a boolean context! > > Obviously, that last bit doesn't apply to modules; they're not going to evaluate as False in general. I just bristle when I see people writing "if x" when they really mean "if x is not None", perhaps because it's not The Right Way(tm)? It mostly comes down to aesthetics, I guess. Write what you really mean. Actually Dave, as your quote from PEP 8 says, the difference is real. It's not just aesthetics. Consider this: x = None if x: print('if x == true') else: print('if x == false') if x is None: print('x is None == true') else: print('x is none == false') y = '' if y: print('if y == true') else: print('if y == false') if y is None: print('y is None == true') else: print('y is none == false') The result is: if x == false x is None == true if y == false y is none == false Alan From ameyer2 at yahoo.com Tue Nov 15 18:05:49 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 15 Nov 2011 18:05:49 -0500 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: <4EC2F04D.5030801@yahoo.com> On 11/15/2011 3:37 PM, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? I don't have any good ideas for how to do this, but I do have a warning. The JavaScript security model prohibits a lot of things that Python does not prohibit. So if you need to do anything like access a file on the user's machine or talk to some computer other than the one you came from, it won't work. Alan From fraveydank at gmail.com Tue Nov 15 18:15:45 2011 From: fraveydank at gmail.com (David Riley) Date: Tue, 15 Nov 2011 18:15:45 -0500 Subject: suppressing import errors In-Reply-To: <4EC2EEC0.2090806@yahoo.com> References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> <4EC2EEC0.2090806@yahoo.com> Message-ID: <0D538417-B0EC-4C2E-B810-53038AB86D3C@gmail.com> On Nov 15, 2011, at 5:59 PM, Alan Meyer wrote: > On 11/15/2011 4:20 PM, David Riley wrote: > ... >> None was set to some other value. The other value might have a type >> (such as a container) that could be false in a boolean context! >> >> Obviously, that last bit doesn't apply to modules; they're not going to evaluate as False in general. I just bristle when I see people writing "if x" when they really mean "if x is not None", perhaps because it's not The Right Way(tm)? It mostly comes down to aesthetics, I guess. Write what you really mean. > > Actually Dave, as your quote from PEP 8 says, the difference is real. It's not just aesthetics. I guess I meant it's aesthetics when it comes down to determining whether a module is None or not; a module is never going to evaluate to False under any feasible circumstances. It's not an aesthetic difference when you consider that the global (or local) namespace may be polluted with other variables that have the same name as your module, but then your evaluation would be entirely invalid anyway. But yes, in the general case, it's much more than an aesthetic difference, which is why I always write "if x is None" when I want to know if it's None (rather than False, 0, [], "", etc). I have been bitten way too many times by doing the lazy thing to keep doing it. - Dave From jabba.laci at gmail.com Tue Nov 15 21:22:11 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Wed, 16 Nov 2011 03:22:11 +0100 Subject: redis beginner question Message-ID: Hi, I'm reading the redis documentation and there is one thing that bothers me. For redis, you need to start a server on localhost. Is there an easy way that my Python script starts this server automatically? Before using my script, I don't want to start redis-server each time. When my program terminates, the server could be shut down automatically. Thanks, Laszlo From pavlovevidence at gmail.com Tue Nov 15 21:51:19 2011 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 15 Nov 2011 18:51:19 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> On Tuesday, November 15, 2011 12:37:03 PM UTC-8, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? Some people have already made an LLVM-to-Javascript compiler, and have managed to build Python 2.7 with it. The LLVM-to-Javascript project is called emscripten. https://github.com/kripken/emscripten/wiki Demo of Python (and a bunch of other languages) here: http://repl.it/ Carl Banks From jason.swails at gmail.com Tue Nov 15 22:02:25 2011 From: jason.swails at gmail.com (Jason Swails) Date: Tue, 15 Nov 2011 22:02:25 -0500 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 12:32 AM, Chris Angelico wrote: > > As a general rule, if any parent is invisible, you won't see the > child, and if any parent is disabled, you can't access the child. Yea, I'm becoming more familiar and comfortable with the GUI hierarchy as I play around. I do like how simple it is to test a concept in Tkinter (just a couple lines builds you a window with any kind of widget you want). > You > may find that there's even a one-line command that will disable the > window, open a new window, wait for the new window to close, and > automatically reenable the window - an "open modal dialog" function or > something. > Apparently I could not do what I was wanting to (state=DISABLED is not a valid option to Toplevel). What I wanted to do was something similar to what the dialogs were doing from tkMessageBox. The window didn't appear changed, but no buttons could be clicked. After looking through the tkMessageBox.py source code, I found the method I was looking for: grab_set. Essentially, I just have to have my new window call its grab_set() method to hog all events. Not really "disabling" the root window (which is why I had a hard time finding it on Google), but it's the exact behavior I was looking for. http://www.python-forum.org/pythonforum/viewtopic.php?f=15&t=4930 was helpful here. The only other approach I (successfully) tried was to use the .withdraw() method on the window during the constructor of the *new* window and execute .deiconify() on it during the new window's destroy() method (before calling Toplevel's destroy on self). I still like the first way better. Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From roy at panix.com Tue Nov 15 22:11:48 2011 From: roy at panix.com (Roy Smith) Date: Tue, 15 Nov 2011 22:11:48 -0500 Subject: redis beginner question References: Message-ID: In article , Jabba Laci wrote: > Hi, > > I'm reading the redis documentation and there is one thing that > bothers me. For redis, you need to start a server on localhost. Is > there an easy way that my Python script starts this server > automatically? Before using my script, I don't want to start > redis-server each time. When my program terminates, the server could > be shut down automatically. > > Thanks, > > Laszlo Why do you want to stop redis after your program terminates? Generally, you just start redis up when the system boots and leave it running. From john.37 at gmail.com Tue Nov 15 22:28:46 2011 From: john.37 at gmail.com (sword) Date: Tue, 15 Nov 2011 19:28:46 -0800 (PST) Subject: Stucked with python logging module Message-ID: <3ce63c21-1880-4cb2-979a-1c806ace4d8f@u37g2000prh.googlegroups.com> I just scaned through the beginer's guide of logging module, but I can't get anything from console. The demo just like this: import logging logging.debug("This is a demo") Maybe I should do sth to put the log to stdout in basicConfig first? Thanks in advance From goldtech at worldpost.com Tue Nov 15 22:38:48 2011 From: goldtech at worldpost.com (goldtech) Date: Tue, 15 Nov 2011 19:38:48 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots Message-ID: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Hi, Using Windows. Is there a python shell that has a history of typed in commands? I don't need output of commands just what I typed it. I need it to save between sessions - something that no shell seems to do. If I reboot there will still be a command history somewhere. Like bash history in Linux. Thanks From john.37 at gmail.com Tue Nov 15 22:45:06 2011 From: john.37 at gmail.com (sword) Date: Tue, 15 Nov 2011 19:45:06 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: <905c6590-84e0-4eab-80bd-3daf12d0a326@y15g2000prl.googlegroups.com> Maybe you're looking for ipython? History, tab-complete, sort of things in it. goldtech wrote: > Hi, > > Using Windows. Is there a python shell that has a history of typed in > commands? > > I don't need output of commands just what I typed it. I need it to > save between sessions - something that no shell seems to do. If I > reboot there will still be a command history somewhere. > > Like bash history in Linux. > > Thanks From rosuav at gmail.com Tue Nov 15 22:49:37 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Nov 2011 14:49:37 +1100 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Wed, Nov 16, 2011 at 2:02 PM, Jason Swails wrote: > Apparently I could not do what I was wanting to (state=DISABLED is not a > valid option to Toplevel).? What I wanted to do was something similar to > what the dialogs were doing from tkMessageBox. Yes, that would be what you'd want. I wonder, though: Is Toplevel the right window class? There may be a better class for a subwindow. Again, I'm not familiar with Tkinter, but a quick google suggests that Frame or Window might be worth looking into. Ideally, you want the window to disable its parent and claim all events. ChrisA From kushal.kumaran+python at gmail.com Wed Nov 16 00:13:10 2011 From: kushal.kumaran+python at gmail.com (Kushal Kumaran) Date: Wed, 16 Nov 2011 10:43:10 +0530 Subject: Stucked with python logging module In-Reply-To: <3ce63c21-1880-4cb2-979a-1c806ace4d8f@u37g2000prh.googlegroups.com> References: <3ce63c21-1880-4cb2-979a-1c806ace4d8f@u37g2000prh.googlegroups.com> Message-ID: On Wed, Nov 16, 2011 at 8:58 AM, sword wrote: > I just scaned through the beginer's guide of logging module, but I > can't get anything from console. The demo just like this: > > import logging > logging.debug("This is a demo") > > Maybe I should do sth to put the log to stdout in basicConfig first? Actually, the problem is not of the output location, but of the logging level. In the default configuration, logs at DEBUG level are suppressed. logging.basicConfig will be a simple way to change this. Are you following the logging documentation at http://docs.python.org/py3k/howto/logging.html#logging-basic-tutorial? This page is part of the documentation of the logging module, and is suitable for first-time logging module users. In your case, you can do this: import logging logging.basicConfig(level=logging.DEBUG) logging.debug("This is a demo") -- regards, kushal From john.37 at gmail.com Wed Nov 16 01:09:53 2011 From: john.37 at gmail.com (sword) Date: Tue, 15 Nov 2011 22:09:53 -0800 (PST) Subject: Got some problems when using logging Filter Message-ID: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> The logging cookbook gives an Filter example, explainning how to add contextural info to log. I can't figure out how to filter log from it. Suppose I have 3 file, a.py, b.py and main.py #file: a.py import logging logger=logging.getLogger(__name__) def print_log(): logger.debug("I'm module a") #file: b.py just like a.py import logging logger=logging.getLogger(__name__) def print_log(): logger.debug("I'm module b") #file: main.py import logging from logging import Filter logging.basicConfig(level=logging.DEBUG) logger=logging.getLogger("main") logger.debug("This is main process") logger.addFilter(Filter("a")) And I expected that the console output would contain main and b module log only. But it turned out that all logs there. Is it the problem of root logger? From passiday at gmail.com Wed Nov 16 02:05:21 2011 From: passiday at gmail.com (Passiday) Date: Tue, 15 Nov 2011 23:05:21 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <27707069.794.1321427121532.JavaMail.geo-discussion-forums@yqff21> Thanks Carl, this looks like a good base to start from. From passiday at gmail.com Wed Nov 16 02:07:15 2011 From: passiday at gmail.com (Passiday) Date: Tue, 15 Nov 2011 23:07:15 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <4EC2F04D.5030801@yahoo.com> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <4EC2F04D.5030801@yahoo.com> Message-ID: <11268744.795.1321427235257.JavaMail.geo-discussion-forums@yqff21> Of course, I am aware of this. But the file system can be emulated, and certain networking can be mediated via the server, too. But for starts, I don't plan to go beyond the basic file operations, if at all. From mail at timgolden.me.uk Wed Nov 16 03:37:47 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 16 Nov 2011 08:37:47 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: <4EC3765B.2020204@timgolden.me.uk> On 16/11/2011 03:38, goldtech wrote: > Hi, > > Using Windows. Is there a python shell that has a history of typed in > commands? Have a look at DreamPie: http://dreampie.sourceforge.net/ TJG From ulrich.eckhardt at dominolaser.com Wed Nov 16 04:08:24 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Wed, 16 Nov 2011 10:08:24 +0100 Subject: unit-profiling, similar to unit-testing Message-ID: <95bcp8-bft.ln1@satorlaser.homedns.org> Hi! I'm currently trying to establish a few tests here that evaluate certain performance characteristics of our systems. As part of this, I found that these tests are rather similar to unit-tests, only that they are much more fuzzy and obviously dependent on the systems involved, CPU load, network load, day of the week (Tuesday is virus scan day) etc. What I'd just like to ask is how you do such things. Are there tools available that help? I was considering using the unit testing framework, but the problem with that is that the results are too hard to interpret programmatically and too easy to misinterpret manually. Any suggestions? Cheers! Uli From amirouche.boubekki at gmail.com Wed Nov 16 05:39:09 2011 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Wed, 16 Nov 2011 11:39:09 +0100 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: H?llo I am looking for a way how to bring Python interpreter to JavaScript, in > order to provide a web-based application with python scripting > capabilities. The app would have basic IDE for writing and debugging the > python code, but the interpretation, of course, would be done in > JavaScript. I'd like to avoid any client-server transactions, so all the > interpretation should take place on the client side. The purpose of all > this would be to create educational platform for learning the programming > in python. > You might be looking for http://www.skulpt.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From babiucandreea at gmail.com Wed Nov 16 06:05:10 2011 From: babiucandreea at gmail.com (Andreea Babiuc) Date: Wed, 16 Nov 2011 11:05:10 +0000 Subject: suppressing import errors In-Reply-To: <4EC2B656.7050902@sequans.com> References: <4EC2B656.7050902@sequans.com> Message-ID: Loving the offtopic guys, sorry I have to go back to my problem now.. In the module I want to import I have a few import statements for Maya commands that don't work outside Maya unless I use the Maya standalone interpreter. So before I import this module I need to make sure I import maya and maya.standalone. I make sure I place the correct paths in sys.path, but I get the following error: import maya.standalone ImportError: /apps/Linux64/aw/maya2012/lib/python2.6/site-packages/maya/../../../../lib/libOGSDeviceOGL-2_7.so: undefined symbol: cgGetParameterBufferIndex Now, I've googled this error and couldn't find anything on it and I'd have no idea why it wouldn't work. It's not a python related error so I understand if you couldn't help me with this, but since you've asked :D I am thinking of using eval for each line in the module i want to import (instead of importing it ) and just ignoring the maya related commands. I can't and shouldn't edit any of these modules, I instead have to parse them and interpret the parameters types without actually executing the functions.. Thanks a lot, Andreea On 15 November 2011 18:58, Jean-Michel Pichavant wrote: > David Riley wrote: > >> On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote: >> >> >> >>> On 15 November 2011 17:24, Chris Kaynor >>> wrote: >>> As with any Python code, you can wrap the import into a try: except >>> block. >>> >>> try: >>> import badModule >>> except: >>> >>> pass # Or otherwise handle the exception - possibly importing an >>> alternative module. >>> >>> >>> Hmm, I know this might sound silly, but if it fails I still want to >>> import the module and disable those lines of code that are related to the >>> reason while the module failed to be imported in the first place. Even if >>> that makes the code not 100% correct. >>> >>> Does that make sense ? >>> >>> >> >> It makes sense. It probably also makes sense to only do an "except >> ImportError", since if there are other errors (say, syntax errors in a >> module you're trying to import, rather than its absence, you probably want >> to know about it. >> >> To disable code that won't work without the module you're trying to >> import, you can always set flags in your module. For example, I've got a >> project at work that can use a variety of communications interfaces, >> including using PySerial for serial port comms. But if someone doesn't >> have PySerial installed, I want it to fail gracefully and just not support >> serial. So I can do the following: >> >> >> try: >> import serial >> _serial_enabled = True >> except ImportError: >> print("PySerial not installed - serial ports not supported!") >> _serial_enabled = False >> >> >> And then elsewhere in my module, I can check the value of _serial_enabled >> to see if I should e.g. list the serial ports in available communications >> interfaces. >> >> Of course, if there's some other error in PySerial (maybe I installed a >> broken version with a syntax error?), that error will get propagated up, >> which is a good thing, because I'd rather know that PySerial is broken than >> just have it tell me it's not installed (which is what would happen if I >> simply caught all exceptions). Your mileage may vary. >> >> - Dave >> >> >> > If I'm not wrong the OP wants to disable the line *in the module being > imported*, which is kindof silly and doesn't make sense to answer his > question. > > Anreea, tell us why the module you are importing is failing and if this > module is yours, we may provide you a proper way to handle this situation > (though I'm pretty sure everything is in Dave's proposal). > > JM > PS : @Dave there is a way to avoiding adding symbols to your global > namespace, assign None to the module's name on import errors. Then before > using it, just test the module bool value : if serial: > serial.whateverMethod() > -- Blog: Http://andreeababiuc.ro Photo Portfolio: http://royaa.daportfolio.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanmichel at sequans.com Wed Nov 16 06:40:02 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 16 Nov 2011 12:40:02 +0100 Subject: Got some problems when using logging Filter In-Reply-To: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: <4EC3A112.70400@sequans.com> sword wrote: > The logging cookbook gives an Filter example, explainning how to add > contextural info to log. I can't figure out how to filter log from it. > > Suppose I have 3 file, a.py, b.py and main.py > #file: a.py > import logging > > logger=logging.getLogger(__name__) > def print_log(): > logger.debug("I'm module a") > > #file: b.py just like a.py > import logging > logger=logging.getLogger(__name__) > def print_log(): > logger.debug("I'm module b") > > #file: main.py > import logging > from logging import Filter > logging.basicConfig(level=logging.DEBUG) > logger=logging.getLogger("main") > logger.debug("This is main process") > logger.addFilter(Filter("a")) > > And I expected that the console output would contain main and b module > log only. But it turned out that all logs there. Is it the problem of > root logger? > > > Hi, First of all, in the code you provided we can't see where you import a & b, and when you call their respective print_log method. Secondly,Filter("a") would allow only the "a" log events, not forbid them. quoting the docs: "if name is specified, it names a logger which, together with its children, will have its events allowed through the filter." As for your problem it may come from the fact that you applied the filter to the 'main' logger, while you probably want to add the filter to the *root* logger. Your current hierarchy is root - main - a - b events fired from 'a' will be handled by the root logger, not the main. root = logging.getLogger() root.addFilter('main') root.addFilter('a') root.addFilter('b') JM From john.37 at gmail.com Wed Nov 16 07:31:08 2011 From: john.37 at gmail.com (sword) Date: Wed, 16 Nov 2011 04:31:08 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: On Nov 16, 7:40?pm, Jean-Michel Pichavant wrote: > sword wrote: > > The logging cookbook gives an Filter example, explainning how to add > > contextural info to log. I can't figure out how to filter log from it. > > > Suppose I have 3 file, a.py, b.py and main.py > > #file: a.py > > import logging > > > logger=logging.getLogger(__name__) > > def print_log(): > > ? ? logger.debug("I'm module a") > > > #file: b.py just like a.py > > import logging > > logger=logging.getLogger(__name__) > > def print_log(): > > ? ? logger.debug("I'm module b") > > > #file: main.py > > import logging > > from logging import Filter > > logging.basicConfig(level=logging.DEBUG) > > logger=logging.getLogger("main") > > logger.debug("This is main process") > > logger.addFilter(Filter("a")) > > > And I expected that the console output would contain main and b module > > log only. But it turned out that all logs there. ?Is it the problem of > > root logger? > > Hi, > > First of all, in the code you provided we can't see where you import a & > b, and when you call their respective print_log method. > Secondly,Filter("a") would allow only the "a" log events, not forbid > them. quoting the docs: "if name is specified, it names a logger which, > together with its children, will have its events allowed through the > filter." > > As for your problem it may come from the fact that you applied the > filter to the 'main' logger, while you probably want to add the filter > to the *root* logger. Your current hierarchy is > > root > ? - main > ? - a > ? - b > > events fired from 'a' will be handled by the root logger, not the main. > root = logging.getLogger() > root.addFilter('main') > root.addFilter('a') > root.addFilter('b') > > JM Thanks for your reply. I tried to edit the source a bit, now the main.py looks like this: #main.py import logging from logging import Filter import a import b logging.basicConfig(level=logging.DEBUG) root = logging.getLogger() root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg would pass this filter logger = logging.getLogger("main") logger.debug("main process") a.print_log() b.print_log() #### And It still prints out all the log msg. :( From jabba.laci at gmail.com Wed Nov 16 08:09:43 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Wed, 16 Nov 2011 14:09:43 +0100 Subject: redis beginner question In-Reply-To: References: Message-ID: > Why do you want to stop redis after your program terminates? ?Generally, > you just start redis up when the system boots and leave it running. Hi, OK, so it's more like MySQL or PostgeSQL, i.e. leave the server running in the background. I wanted to use it like SQLite, i.e. let it run only when I need it. Laszlo From dutche at gmail.com Wed Nov 16 08:48:16 2011 From: dutche at gmail.com (Eduardo Oliva) Date: Wed, 16 Nov 2011 05:48:16 -0800 (PST) Subject: Multiple threads Message-ID: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. What I want to do is: I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. I know that Semaphores would help with that. But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. Any help would be great. Thank you in advance From rosuav at gmail.com Wed Nov 16 08:55:40 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Nov 2011 00:55:40 +1100 Subject: Multiple threads In-Reply-To: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: On Thu, Nov 17, 2011 at 12:48 AM, Eduardo Oliva wrote: > Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. > > What I want to do is: > > ?I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. > ?I know that Semaphores would help with that. > ?But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. First off, it's better in CPython (the most popular Python) to use multiple processes than multiple threads. That aside, what you're looking at is a pretty common model - a large number of tasks being served by a pool of workers. Have a look at the multiprocessing module, specifically Pool: Version 2: http://docs.python.org/library/multiprocessing.html Version 3: http://docs.python.org/py3k/library/multiprocessing.html Should be fairly straightforward. ChrisA From hfaber at invalid.net Wed Nov 16 09:07:48 2011 From: hfaber at invalid.net (Henrik Faber) Date: Wed, 16 Nov 2011 15:07:48 +0100 Subject: Multiple threads References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: On 16.11.2011 14:48, Eduardo Oliva wrote: > I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. > I know that Semaphores would help with that. > But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. Absolute standard request, has nothing to do with Python. The way to go (in Cish pseudocode) is: thread() { /* do work */ [...] /* finished! */ semaphore++; } semaphore = 2 while (jobs) { semaphore--; // will block if pool exhausted thread(); } // in the end, collect remaining two workers semaphore -= 2 // will block until all are finished Best regards, Henrik From roy at panix.com Wed Nov 16 09:36:40 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 09:36:40 -0500 Subject: unit-profiling, similar to unit-testing References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: In article <95bcp8-bft.ln1 at satorlaser.homedns.org>, Ulrich Eckhardt wrote: > Hi! > > I'm currently trying to establish a few tests here that evaluate certain > performance characteristics of our systems. As part of this, I found > that these tests are rather similar to unit-tests, only that they are > much more fuzzy and obviously dependent on the systems involved, CPU > load, network load, day of the week (Tuesday is virus scan day) etc. > > What I'd just like to ask is how you do such things. Are there tools > available that help? I was considering using the unit testing framework, > but the problem with that is that the results are too hard to interpret > programmatically and too easy to misinterpret manually. Any suggestions? It's really, really, really hard to either control for, or accurately measure, things like CPU or network load. There's so much stuff you can't even begin to see. The state of your main memory cache. Disk fragmentation. What I/O is happening directly out of kernel buffers vs having to do a physical disk read. How slow your DNS server is today. What I suggest is instrumenting your unit test suite to record not just the pas/fail status of every test, but also the test duration. Stick these into a database as the tests run. Over time, you will accumulate a whole lot of performance data, which you can then start to mine. While you're running the tests, gather as much system performance data as you can (output of top, vmstat, etc) and stick that into your database too. You never know when you'll want to refer to the data, so just collect it all and save it forever. From roy at panix.com Wed Nov 16 09:37:09 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 09:37:09 -0500 Subject: redis beginner question References: Message-ID: In article , Jabba Laci wrote: > > Why do you want to stop redis after your program terminates? ?Generally, > > you just start redis up when the system boots and leave it running. > > Hi, > > OK, so it's more like MySQL or PostgeSQL, i.e. leave the server > running in the background. That's how I would treat it. From __peter__ at web.de Wed Nov 16 09:50:51 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 16 Nov 2011 15:50:51 +0100 Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: sword wrote: > Thanks for your reply. I tried to edit the source a bit, now the > main.py looks like this: > #main.py > import logging > from logging import Filter > import a > import b > > logging.basicConfig(level=logging.DEBUG) > root = logging.getLogger() > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > would pass this filter > > logger = logging.getLogger("main") > logger.debug("main process") > a.print_log() > b.print_log() > > #### > And It still prints out all the log msg. :( Here's a little demo to explore how filtering works: $ cat demo.py import logging class Filter(logging.Filter): def filter(self, record): print "applying filter", self.name return True logging.basicConfig() loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]] for logger in loggers: logger.addFilter(Filter("filter@" + logger.name)) [handler] = logging.getLogger().handlers handler.addFilter(Filter("filter at handler")) for logger in loggers: logger.critical("whatever") $ python demo.py applying filter filter at root applying filter filter at handler CRITICAL:root:whatever applying filter filter at a applying filter filter at handler CRITICAL:a:whatever applying filter filter at a.b applying filter filter at handler CRITICAL:a.b:whatever $ As you can infer from the output only the filter(s) of the original logger and of the handler(s) are applied. From lists at cheimes.de Wed Nov 16 10:01:15 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 16 Nov 2011 16:01:15 +0100 Subject: Multiple threads In-Reply-To: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: Am 16.11.2011 14:48, schrieb Eduardo Oliva: > Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. > > What I want to do is: > > I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. > I know that Semaphores would help with that. > But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. I suggest a slight different approach: use a queue [1] and create two worker threads that consume the queue. You don't need multiprocessing because you are already using multiple processes here (one Python and two ffmpeg processes). Christian [1] http://docs.python.org/library/queue.html From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Wed Nov 16 11:45:29 2011 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Wed, 16 Nov 2011 17:45:29 +0100 Subject: Multiple threads In-Reply-To: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: Am 16.11.2011 14:48 schrieb Eduardo Oliva: > Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line. > > What I want to do is: > > I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads. > I know that Semaphores would help with that. > But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread. > > Any help would be great. I'm not sure if you need threads at all: if you launch a process with subprocess, it runs and you only would have to wait() for it. The same can be done with two processes. Pseudocode: LIMIT = 2 processes = [] def do_waiting(limit): while len(processes) >= limit: % take the first one... sp = processes.pop(0) % wait for it... st = sp.wait(100) if is None: % timeout, not finished yet, push back. processes.append(sp) else: % finished - don't push back, let outer for loop continue. print sp, "has finished with", st for fname in list: % launch process ... sp = subprocess.Popen(...) % ... and register it. processes.append(sp) % If we are on the limit, wait for process to finish. do_waiting(LIMIT) do_waiting(1) Thomas From anthra.norell at bluewin.ch Wed Nov 16 11:57:27 2011 From: anthra.norell at bluewin.ch (Frederic Rentsch) Date: Wed, 16 Nov 2011 17:57:27 +0100 Subject: try - except. How to identify errors unknown in advance? Message-ID: <1321462647.2315.31.camel@hatchbox-one> Hi all, I'd like to log MySQL errors. If I do: try: (command) except MySQLdb.OperationalError, e: print e I may get something like: (1136, "Column count doesn't match value count at row 1") If I don't know in advance which error to expect, but on the contrary want to find out which error occurred, I can catch any error by omitting the name: except: (handle) But now I don't have access to the error message 'e'. I'm sure there's a way and it's probably ridiculously simple. Frederic From whatsjacksemail at gmail.com Wed Nov 16 12:00:57 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Wed, 16 Nov 2011 17:00:57 +0000 Subject: Multiple threads In-Reply-To: References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: Hi Chris, On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelico wrote: > First off, it's better in CPython (the most popular Python) to use > multiple processes than multiple threads. I had been looking into treads and process/subprocess myself a while ago and couldn't decide which would suit what I needed to do best. I'm still very confused about the whole thing. Can you elaborate on the above a bit please? Cheers, Jack -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckaynor at zindagigames.com Wed Nov 16 12:09:39 2011 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 16 Nov 2011 09:09:39 -0800 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: <1321462647.2315.31.camel@hatchbox-one> References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch wrote: > Hi all, > > > I'd like to log MySQL errors. If I do: > > ? ? ? ?try: (command) > ? ? ? ?except MySQLdb.OperationalError, e: print e > > I may get something like: > > ? ? ? ?(1136, "Column count doesn't match value count at row 1") > > If I don't know in advance which error to expect, but on the contrary > want to find out which error occurred, I can catch any error by omitting > the name: > > ? ? ? ?except: (handle) > > But now I don't have access to the error message 'e'. I'm sure there's a > way and it's probably ridiculously simple. except Exception, e: (or, in Py3, except Exception as e is prefereed). Note that you should generally avoid bare except statements "except:" as that will catch everything, including KeyboardInterrupt and SystemExit which may not be desirable. Even without saving the exception in the except statement, you can get the type, value, and traceback with the sys.exc_info command. See http://docs.python.org/library/sys.html#sys.exc_info For example: py>import sys py>try: py> raise RuntimeError py> except: py> print sys.exc_info() py> (, RuntimeError(), ) > > Frederic > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From d at davea.name Wed Nov 16 12:27:52 2011 From: d at davea.name (Dave Angel) Date: Wed, 16 Nov 2011 12:27:52 -0500 Subject: Multiple threads In-Reply-To: References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <4EC3F298.1030604@davea.name> On 11/16/2011 12:00 PM, Jack Keegan wrote: > Hi Chris, > > On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelico wrote: > >> First off, it's better in CPython (the most popular Python) to use >> multiple processes than multiple threads. > > I had been looking into treads and process/subprocess myself a while ago > and couldn't decide which would suit what I needed to do best. I'm still > very confused about the whole thing. Can you elaborate on the above a bit > please? > > Cheers, > > Jack Threads and processes are a concept that exists in your operating system, and Python can use either of them to advantage, depending on the problem. Note that different OS also handle them differently, so code that's optimal on one system might not be as optimal on another. Still, some generalities can be made. Each process is a separate program, with its own address space and its own file handles, etc. You can examine them separately with task manager, for example. If you launch multiple processes, they might not even all have to be python, so if one problem can be handled by an existing program, just run it as a separate process. Processes are generally very protected from each other, and the OS is generally better at scheduling them than it is at scheduling threads within a single process. If you have multiple cores, the processes can really run simultaneously, frequently with very small overhead. The downside is that you cannot share variables between processes without extra work, so if the two tasks are very interdependent, it's more of a pain to use separate processes. Within one process, you can have multiple threads. On some OS, and in some languages, this can be extremely efficient. Some programs launch hundreds of threads, and use them to advantage. By default, it's easy to share data between threads, since they're in the same address space. But the downsides are 1) it's very easy to trash another thread by walking on its variables. 2) Python does a lousy job of letting threads work independently. For CPU-bound tasks, using separate threads is likely to be slower than just doing it all in one thread. -- DaveA From tahoemph at gmail.com Wed Nov 16 12:55:24 2011 From: tahoemph at gmail.com (Michael Hunter) Date: Wed, 16 Nov 2011 09:55:24 -0800 Subject: Multiple threads In-Reply-To: <4EC3F298.1030604@davea.name> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <4EC3F298.1030604@davea.name> Message-ID: On Wed, Nov 16, 2011 at 9:27 AM, Dave Angel wrote: > On 11/16/2011 12:00 PM, Jack Keegan wrote: >[...] Processes [...] and the OS is generally better at scheduling them than it is at > scheduling threads within a single process. ?If you have multiple cores, the > processes can really run simultaneously, frequently with very small > overhead. ?[...] Maybe you are trying to simplify things but in a lot of cases this is just false. In at least some operating systems these days a thread is the basic unit that is scheduled. Processes are thread containers that provide other things (fds, separate address space, etc.). The comment about multiple cores can be extended to multiple threads on a core (CMT) but applies to threads as well as processes. Switching between processes tends to be heavier weight then switching between threads in a process because of the needs to change the address space. Just because Python sucks at threads doesn't make them heavier for the OS. That doesn't mean you shouldn't use multiprocessing. The problem asked about seems a good fit to me to a single python process starting and managing a set of external converter processes. Michael From furoscame at 7fun.de Wed Nov 16 13:00:38 2011 From: furoscame at 7fun.de (furoscame) Date: Wed, 16 Nov 2011 19:00:38 +0100 Subject: How to use pySerial under Windows 7 without administrator rights Message-ID: Hello together, currently I try to use pySerial under Windows 7. But it is not possible to open a serial port without running the script under adminstrator rights. Other programs like Terraterm are able to so without adminstrator rights. What is the reason for that and is it possible open a port without administrator rights in Python? regards furoscame From d at davea.name Wed Nov 16 13:06:40 2011 From: d at davea.name (Dave Angel) Date: Wed, 16 Nov 2011 13:06:40 -0500 Subject: Multiple threads In-Reply-To: References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <4EC3F298.1030604@davea.name> Message-ID: <4EC3FBB0.80601@davea.name> On 11/16/2011 12:55 PM, Michael Hunter wrote: > On Wed, Nov 16, 2011 at 9:27 AM, Dave Angel wrote: >> On 11/16/2011 12:00 PM, Jack Keegan wrote: >> [...] Processes [...] and the OS is generally better at scheduling them than it is at >> scheduling threads within a single process. If you have multiple cores, the >> processes can really run simultaneously, frequently with very small >> overhead. [...] > > Maybe you are trying to simplify things but in a lot of cases this is > just false. In at least some operating systems these days a thread is > the basic unit that is scheduled. Processes are thread containers > that provide other things (fds, separate address space, etc.). The > comment about multiple cores can be extended to multiple threads on a > core (CMT) but applies to threads as well as processes. Switching > between processes tends to be heavier weight then switching between > threads in a process because of the needs to change the address space. > > Just because Python sucks at threads doesn't make them heavier for the OS. > > That doesn't mean you shouldn't use multiprocessing. The problem > asked about seems a good fit to me to a single python process starting > and managing a set of external converter processes. > > Michael > No response is deserved. -- DaveA From d at davea.name Wed Nov 16 13:30:39 2011 From: d at davea.name (Dave Angel) Date: Wed, 16 Nov 2011 13:30:39 -0500 Subject: Multiple threads In-Reply-To: <4EC3FF56.7030101@davea.name> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <4EC3F298.1030604@davea.name> <4EC3FF56.7030101@davea.name> Message-ID: <4EC4014F.8080105@davea.name> On 11/16/2011 01:22 PM, Dave Angel wrote: > (You're top-posting. Put your remarks AFTER what you're quoting) > > On 11/16/2011 12:52 PM, Jack Keegan wrote: >> Ok, I thought that processes would do the same job as threads. So >> would the >> general rule be some thing like so: >> >> If I want another piece of work to run (theoretically) along side my >> main >> script, and I want to share data between them, I should use a thread and >> share data with the thread-safe queue. >> If the work I want done can function and complete on its own, go for a >> process. >> >> Would that be about right? >> > > Yes, with all the caveats I mentioned before. With some language > implementations, and with some operating systems, and on some > CPU-systems, the guidelines could be different. They all trade off in > ways too complex to describe here. > > For example, if a thread is mostly doing I/O, it may be just as > efficient as a separate process, even if sharing data isn't an issue. > > And in some languages, sharing data between processes isn't all that > tough, either. > > Well, you sent me a mail without including the list (just use Reply-All), and I tried to add the list in. Unfortunately, I picked the wrong one, so i sent this to Tutor by mistake. I'll try to fix that now, sorry. -- DaveA From anthra.norell at bluewin.ch Wed Nov 16 13:39:32 2011 From: anthra.norell at bluewin.ch (Frederic Rentsch) Date: Wed, 16 Nov 2011 19:39:32 +0100 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: <1321468772.2315.35.camel@hatchbox-one> On Wed, 2011-11-16 at 09:09 -0800, Chris Kaynor wrote: > On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch > wrote: > > Hi all, > > > > > > I'd like to log MySQL errors. If I do: > > > > try: (command) > > except MySQLdb.OperationalError, e: print e > > > > I may get something like: > > > > (1136, "Column count doesn't match value count at row 1") > > > > If I don't know in advance which error to expect, but on the contrary > > want to find out which error occurred, I can catch any error by omitting > > the name: > > > > except: (handle) > > > > But now I don't have access to the error message 'e'. I'm sure there's a > > way and it's probably ridiculously simple. > > except Exception, e: (or, in Py3, except Exception as e is prefereed). > > Note that you should generally avoid bare except statements "except:" > as that will catch everything, including KeyboardInterrupt and > SystemExit which may not be desirable. > > Even without saving the exception in the except statement, you can get > the type, value, and traceback with the sys.exc_info command. See > http://docs.python.org/library/sys.html#sys.exc_info > > For example: > > py>import sys > py>try: > py> raise RuntimeError > py> except: > py> print sys.exc_info() > py> > (, RuntimeError(), at 0x0000000002371588>) Chris, Thanks very much! Great help! Frederic From lists at cheimes.de Wed Nov 16 13:47:45 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 16 Nov 2011 19:47:45 +0100 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: <1321468772.2315.35.camel@hatchbox-one> References: <1321462647.2315.31.camel@hatchbox-one> <1321468772.2315.35.camel@hatchbox-one> Message-ID: Am 16.11.2011 19:39, schrieb Frederic Rentsch: >> py>import sys >> py>try: >> py> raise RuntimeError >> py> except: >> py> print sys.exc_info() >> py> >> (, RuntimeError(), > at 0x0000000002371588>) > > Chris, Thanks very much! Great help! How about using the excellent logging framework instead of rolling your own stuff? It can print the traceback, too. >>> import logging >>> logging.basicConfig() >>> log = logging.getLogger("mymodule") >>> try: ... raise ValueError("test") ... except Exception: ... log.exception("some message") ... ERROR:mymodule:some message Traceback (most recent call last): File "", line 2, in ValueError: test Christian From python at mrabarnett.plus.com Wed Nov 16 15:21:16 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 16 Nov 2011 20:21:16 +0000 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: <4EC41B3C.6040606@mrabarnett.plus.com> On 16/11/2011 17:09, Chris Kaynor wrote: > On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch > wrote: >> Hi all, >> >> >> I'd like to log MySQL errors. If I do: >> >> try: (command) >> except MySQLdb.OperationalError, e: print e >> >> I may get something like: >> >> (1136, "Column count doesn't match value count at row 1") >> >> If I don't know in advance which error to expect, but on the contrary >> want to find out which error occurred, I can catch any error by omitting >> the name: >> >> except: (handle) >> >> But now I don't have access to the error message 'e'. I'm sure there's a >> way and it's probably ridiculously simple. > > except Exception, e: (or, in Py3, except Exception as e is prefereed). > In Python 3, "except Exception as e" is not just preferred: it's the only form. > Note that you should generally avoid bare except statements "except:" > as that will catch everything, including KeyboardInterrupt and > SystemExit which may not be desirable. > [snip] Very true. From jason.swails at gmail.com Wed Nov 16 15:42:52 2011 From: jason.swails at gmail.com (Jason Swails) Date: Wed, 16 Nov 2011 15:42:52 -0500 Subject: (n00b) Tkinter trouble In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 10:49 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 2:02 PM, Jason Swails > wrote: > > Apparently I could not do what I was wanting to (state=DISABLED is not a > > valid option to Toplevel). What I wanted to do was something similar to > > what the dialogs were doing from tkMessageBox. > > Yes, that would be what you'd want. I wonder, though: Is Toplevel the > right window class? There may be a better class for a subwindow. > Again, I'm not familiar with Tkinter, but a quick google suggests that > Frame or Window might be worth looking into. Ideally, you want the > window to disable its parent and claim all events. > I think Toplevel is right. Frame isn't actually a window (a window has to be its parent), and I've never seen any documentation regarding a Window class (perhaps it's just meant to be a base class that Toplevel inherits from?). I think a separate window needs to be a Toplevel instance (or instance of a Toplevel-derived class). Pulling on the tkMessageBox example again, their base Dialog class inherits from Toplevel. In any case, I've actually found that Tkinter is relatively straightforward to learn, despite some of the bashing it's received here (admittedly I've never tried PyGTK or wxpython or any of the other toolkits because I want to keep dependencies within the stdlib as much as possible). Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From rafadurancastaneda at gmail.com Wed Nov 16 15:48:37 2011 From: rafadurancastaneda at gmail.com (=?ISO-8859-1?Q?Rafael_Dur=E1n_Casta=F1eda?=) Date: Wed, 16 Nov 2011 21:48:37 +0100 Subject: redis beginner question In-Reply-To: References: Message-ID: <4EC421A5.4010601@gmail.com> El 16/11/11 03:22, Jabba Laci escribi?: > Hi, > > I'm reading the redis documentation and there is one thing that > bothers me. For redis, you need to start a server on localhost. Is > there an easy way that my Python script starts this server > automatically? Before using my script, I don't want to start > redis-server each time. When my program terminates, the server could > be shut down automatically. > > Thanks, > > Laszlo I think you are misunderstanding the docs, on ubuntu (or whatever you use) you can do apt-get install redis-server and you'll get what you want. HTH From miki.tebeka at gmail.com Wed Nov 16 15:50:25 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 16 Nov 2011 12:50:25 -0800 (PST) Subject: Multiple threads In-Reply-To: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <17096391.271.1321476625430.JavaMail.geo-discussion-forums@yqhd1> You can see an example on how to use multiprocessing.Pool at http://pythonwise.blogspot.com/2011/03/convert-oggs-to-mp3-fast-way.html This is ogg -> mp3 but the same idea. From ben+python at benfinney.id.au Wed Nov 16 16:09:18 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 17 Nov 2011 08:09:18 +1100 Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: <8762ijlqpt.fsf@benfinney.id.au> goldtech writes: > Using Windows. Is there a python shell that has a history of typed in > commands? I don't know about MS Windows, but the Python interactive shell can be linked with the GNU Readline library for managing its command line including editing features, tab completion, history management, and a persistent history file. You can then use that functionality in your Python interactive startup file. Here's mine: ===== # $HOME/.pythonrc # User configuration for interactive Python shell. import sys import os import os.path import atexit # Tab completion with readline. # Cribbed from . try: import readline except ImportError: sys.stderr.write("Module readline not available.\n") else: import rlcompleter # Enable tab completion. readline.parse_and_bind("tab: complete") # Persistent command history. histfile = os.path.join(os.environ["HOME"], ".python_history") try: readline.read_history_file(histfile) except IOError: # Existing history file can't be read. pass atexit.register(readline.write_history_file, histfile) del histfile del sys, os, atexit ===== Reading the documentation, I see that the ?readline? library is only linked with Python on Unix-alike operating systems. Yet another reason why MS Windows is not a good choice for developing software I guess. -- \ ?The difference between religions and cults is determined by | `\ how much real estate is owned.? ?Frank Zappa | _o__) | Ben Finney From tjreedy at udel.edu Wed Nov 16 16:18:14 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Nov 2011 16:18:14 -0500 Subject: try - except. How to identify errors unknown in advance? In-Reply-To: <1321462647.2315.31.camel@hatchbox-one> References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: On 11/16/2011 11:57 AM, Frederic Rentsch wrote: > If I don't know in advance which error to expect, but on the contrary > want to find out which error occurred, I can catch any error by omitting > the name: > > except: (handle) > > But now I don't have access to the error message 'e'. I'm sure there's a > way and it's probably ridiculously simple. Bare except is a holdover from when exceptions could be strings rather than an instance of a subclass of BaseException. A Python 3 interpreter in effect runs code within a try-except block something like this: try: except BaseException as __exception__: However, use Exception instead of BaseException in your code unless you REALLY know what you are doing and why. -- Terry Jan Reedy From andrea.crotti.0 at gmail.com Wed Nov 16 18:42:02 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 16 Nov 2011 23:42:02 +0000 Subject: pymacs? Message-ID: <4EC44A4A.70201@gmail.com> After a long time, and since it was included iin python-mode, I wanted to try if I can get ropemacs working finally. I have tried many possible things, also in Emacs -Q, and I actually got it working only once, apparently by pure luck with Emacs -Q: (setq py-load-python-mode-pymacs-p nil) (setq ca-pymacs-path (expand-file-name "~/Emacs-configuration/python-mode/pymacs")) (add-to-list 'load-path ca-pymacs-path) (setenv "PYMACS_PYTHON" "python2.7") (require 'pymacs) (pymacs-load "ropemacs" "rope-") (setq ropemacs-confirm-saving 'nil) The problem is that this configuration doesn't use python-mode.el but the standard python.el, all my attempts to make this work on my normal configuration failed. Did anyone got both correctly working? Thanks.. From drobinow at gmail.com Wed Nov 16 18:46:30 2011 From: drobinow at gmail.com (David Robinow) Date: Wed, 16 Nov 2011 18:46:30 -0500 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <8762ijlqpt.fsf@benfinney.id.au> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> Message-ID: On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney wrote: > goldtech writes: > >> Using Windows. Is there a python shell that has a history of typed in >> commands? > > I don't know about MS Windows, but the Python interactive shell can be > linked with the GNU Readline library for managing its command line > including editing > features, tab completion, history management, and a persistent history > file. > > You can then use that functionality in your Python interactive startup > file. Here's mine: > > ===== > # $HOME/.pythonrc > # User configuration for interactive Python shell. > > import sys > import os > import os.path > import atexit > > # Tab completion with readline. > # Cribbed from . > try: > ? ?import readline > except ImportError: > ? ?sys.stderr.write("Module readline not available.\n") > else: > ? ?import rlcompleter > > ? ?# Enable tab completion. > ? ?readline.parse_and_bind("tab: complete") > > ? ?# Persistent command history. > ? ?histfile = os.path.join(os.environ["HOME"], ".python_history") > ? ?try: > ? ? ? ?readline.read_history_file(histfile) > ? ?except IOError: > ? ? ? ?# Existing history file can't be read. > ? ? ? ?pass > ? ?atexit.register(readline.write_history_file, histfile) > > ? ?del histfile > > del sys, os, atexit > > ===== > > Reading the documentation, I see that the ?readline? library is only > linked with Python on Unix-alike operating systems. Yet another reason > why MS Windows is not a good choice for developing software I guess. I'm not sure what documentation you're reading, but your code works fine on Windows. Thanks. [It is necessary to properly set PYTHONSTARTUP] From ben+python at benfinney.id.au Wed Nov 16 18:59:27 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 17 Nov 2011 10:59:27 +1100 Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> Message-ID: <87hb23ei00.fsf@benfinney.id.au> David Robinow writes: > On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney wrote: > > I don't know about MS Windows, but the Python interactive shell can be > > linked with the GNU Readline library for managing its command line > > [?] > > Reading the documentation, I see that the ?readline? library is only > > linked with Python on Unix-alike operating systems. > I'm not sure what documentation you're reading The same documentation I linked to above. Immediately below the title, it specifies a limited set of platforms: ?Platforms: Unix? limiting the availability of the described module. > but your code works fine on Windows. Thanks. I'm glad to know that. Perhaps you could investigate why, and suggest an update to the above documentation if it's wrong? The bug tracker at would be the appropriate place for such a suggestion. -- \ ?Intellectual property is to the 21st century what the slave | `\ trade was to the 16th.? ?David Mertz | _o__) | Ben Finney From drobinow at gmail.com Wed Nov 16 19:49:31 2011 From: drobinow at gmail.com (David Robinow) Date: Wed, 16 Nov 2011 19:49:31 -0500 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <87hb23ei00.fsf@benfinney.id.au> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> <87hb23ei00.fsf@benfinney.id.au> Message-ID: On Wed, Nov 16, 2011 at 6:59 PM, Ben Finney wrote: > David Robinow writes: > >> On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney wrote: >> > I don't know about MS Windows, but the Python interactive shell can be >> > linked with the GNU Readline library for managing its command line >> > > [?] > >> > Reading the documentation, I see that the ?readline? library is only >> > linked with Python on Unix-alike operating systems. > >> ?I'm not sure what documentation you're reading > > The same documentation I linked to above. Immediately below the title, > it specifies a limited set of platforms: ?Platforms: Unix? limiting the > availability of the described module. > >> but your code works fine on Windows. Thanks. > > I'm glad to know that. Perhaps you could investigate why, and suggest an > update to the above documentation if it's wrong? The bug tracker at > would be the appropriate place for such a > suggestion. Upon further investigation, it turns out that I'm using pyreadline from http://pypi.python.org/pypi/pyreadline. I'd forgotten I'd installed it. No documentation fixes appear to be necessary. "The pyreadline package is a python implementation of GNU readline functionality it is based on the ctypes based UNC readline package by Gary Bishop. It is not complete. It has been tested for use with windows 2000 and windows xp." It appears to work in Vista also, at least for the purposes discussed in this thread. From dan at tombstonezero.net Wed Nov 16 20:07:37 2011 From: dan at tombstonezero.net (Dan Sommers) Date: Thu, 17 Nov 2011 01:07:37 +0000 (UTC) Subject: try - except. How to identify errors unknown in advance? References: <1321462647.2315.31.camel@hatchbox-one> Message-ID: On Wed, 16 Nov 2011 17:57:27 +0100, Frederic Rentsch wrote: > I'd like to log MySQL errors. If I do: > > try: (command) > except MySQLdb.OperationalError, e: print e > > I may get something like: > > (1136, "Column count doesn't match value count at row 1") > > If I don't know in advance which error to expect, but on the contrary > want to find out which error occurred, I can catch any error by omitting > the name: > > except: (handle) > > But now I don't have access to the error message 'e'. I'm sure there's a > way and it's probably ridiculously simple. "except" catches any exception that inherits from its argument, and all MySQL exceptions inherit from MySQLError, so something like this will catch only MySQL exceptions and nothing else: try: (command) except MySQLdb.MySQLError as e: print(e) Dan From roy at panix.com Wed Nov 16 20:57:42 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 20:57:42 -0500 Subject: How to insert my own module in front of site eggs? Message-ID: I'm trying to use a custom version of mongoengine. I cloned the git repo and put the directory on my PYTHONPATH, but python is still importing the system's installed version. Looking at sys.path, it's obvious why: $ echo $PYTHONPATH /home/roy/songza:/home/roy/lib/mongoengine >>> pprint.pprint(sys.path) ['', '/usr/local/lib/python2.6/dist-packages/selenium-2.0a5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/unittest2-0.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.eg g', '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/mongoengine-0.5.2-py2.6.egg', '/home/roy/songza', '/home/roy/lib/mongoengine', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages'] The system eggs come before my path. I found http://mail.python.org/pipermail/distutils-sig/2006-July/006520.html in the archives; it explains that eggs come before PYTHONPATH, but doesn't explain how to get around this problem. I emphatically agree with Michael Bayer who said: > I cant think of a possible scenario where a path would explicitly > exist in PYTHONPATH, non-egg or egg, where the user would still like the > system-wide installation to take precedence So, is there any way to get my local copy of mongoengine loaded instead of the system egg? I could probably import sys, and do an egg-ectomy on sys.path before importing mongoengine, but that's too gross to contemplate. From roy at panix.com Wed Nov 16 21:30:57 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 21:30:57 -0500 Subject: staticmethod makes my brain hurt Message-ID: When I run this (python 2.6.1): class C: @staticmethod def foo(): pass print "inside", foo, callable(foo) print "outside", C.foo, callable(C.foo) I get: inside False outside True I don't understand. Why is foo not callable inside of the class definition? Where this comes up is that I'm trying to use a callable default in mongoengine: class User(Document): @staticmethod def _get_next_id(): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) The way mongoengine works is if callable(default) is true, it calls default() to get the real value to use. At the point where the IntField() call is made, _get_next_id is not callable, and eventually I end up with: ValidationError: could not be converted to int From wuwei23 at gmail.com Wed Nov 16 21:44:00 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 16 Nov 2011 18:44:00 -0800 (PST) Subject: staticmethod makes my brain hurt References: Message-ID: On Nov 17, 12:30?pm, Roy Smith wrote: > class C: > ? ? @staticmethod > ? ? def foo(): > ? ? ? ? pass > > ? ? print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I don't understand. ?Why is foo not callable inside of the class > definition? Consider this: >>> def foo(): pass ... >>> foo = staticmethod(foo) >>> callable(foo) False A staticmethod by itself does not appear to be callable. Your internal 'foo' is referring to the staticmethod wrapper. Your external 'C.foo' refers to the result returned by the class mechanism's __getattr__, which I'm guessing is munged into a callable at that point. Where this comes up is that I'm trying to use a callable > default in mongoengine: > > class User(Document): > ? ? @staticmethod > ? ? def _get_next_id(): > ? ? ? [blah, blah, blah] > ? ? ? return id > > ? ? user_id = IntField(required=True, default=_get_next_id) What you're effectively trying to do is use a class before it has been constructed to help construct itself. Just define it as a helper function before the class declaration. From roy at panix.com Wed Nov 16 21:52:57 2011 From: roy at panix.com (Roy Smith) Date: Wed, 16 Nov 2011 21:52:57 -0500 Subject: staticmethod makes my brain hurt References: Message-ID: In article , alex23 wrote: > What you're effectively trying to do is use a class before it has been > constructed to help construct itself. > > Just define it as a helper function before the class declaration. Yes, this is the workaround I ended up with. From wuwei23 at gmail.com Wed Nov 16 22:04:23 2011 From: wuwei23 at gmail.com (alex23) Date: Wed, 16 Nov 2011 19:04:23 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> Message-ID: <3ed98382-5d03-4491-a24a-032f47f5ed5c@u24g2000pru.googlegroups.com> On Nov 17, 7:09?am, Ben Finney wrote: > You can then use that functionality in your Python interactive startup > file. Here's mine: Awesome, thank you for this. I use iPython where ever possible but there are times where I just can't avoid the default shell and this will help immensely. Cheers! From ethan at stoneleaf.us Wed Nov 16 22:24:02 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 16 Nov 2011 19:24:02 -0800 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: <4EC47E52.9080708@stoneleaf.us> Roy Smith wrote: > class User(Document): > @staticmethod > def _get_next_id(): > [blah, blah, blah] > return id > > user_id = IntField(required=True, default=_get_next_id) If you don't call '_get_next_id()' from any class methods (in other words, if you don't need to ever say 'self._gen_next_id()') then you can remove the '@staticmethod': def _get_next_id(): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) If you do need to sometimes call it from a method then still leave off the '@staticmethod', and give 'self' a default of 'None': def _get_next_id(self=None): [blah, blah, blah] return id user_id = IntField(required=True, default=_get_next_id) ~Ethan~ From snorble at hotmail.com Wed Nov 16 23:17:21 2011 From: snorble at hotmail.com (snorble) Date: Wed, 16 Nov 2011 20:17:21 -0800 (PST) Subject: Monitoring/inventory client-server app Message-ID: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> I'm writing a tool for monitoring the workstations and servers in our office. I plan to have a server and a client service that runs on each workstation and reports back to the server (heartbeat, disk free space, etc). So far I am considering XMLRPC, or a client service that just downloads a Python file and runs it. With XMLRPC I don't know how to easily add features without having to update every client. Also while playing with XMLRPC I learned that when you run a registered function, it runs it on the server. I was hoping it would run on the client, so that when I get the machine's computer name (or disk space, etc) it will return the client's info. It seems with XMLRPC I would have to hard code the functionality into the client (i.e. client gets it's computer name, then calls the XMLRPC function to pass it to the server)? I was hoping it would work more like, "pass some code to the client to be run on the client, and report it to the server". Almost XMLRPC in the reverse direction. With the download-and-run approach, it seems trivially easy to add new functionality to the clients. Just save the updated Python file to the server, and clients download it and run it. Are there any standard approaches to problems like this that can be recommended? Thank you. From steve+comp.lang.python at pearwood.info Wed Nov 16 23:43:24 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Nov 2011 04:43:24 GMT Subject: staticmethod makes my brain hurt References: Message-ID: <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote: > When I run this (python 2.6.1): > > class C: > @staticmethod > def foo(): > pass > print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I get: > > inside False > outside True > > I don't understand. Why is foo not callable inside of the class > definition? This has come up before. http://bytes.com/topic/python/answers/34396-static-method-object-not-callable http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callable However, the fix is not as simple as merely making staticmethod objects callable. This was discussed at the 2011 language summit: http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html See also this thread: http://mail.python.org/pipermail/python-dev/2011-March/109090.html -- Steven From roy at panix.com Thu Nov 17 00:26:20 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 00:26:20 -0500 Subject: staticmethod makes my brain hurt References: <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4ec490ec$0$30003$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > This has come up before. > > http://bytes.com/topic/python/answers/34396-static-method-object-not-callable > > http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callabl > e > > > However, the fix is not as simple as merely making staticmethod objects > callable. This was discussed at the 2011 language summit: > > http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.h > tml > > See also this thread: > > http://mail.python.org/pipermail/python-dev/2011-March/109090.html Thanks for the links. It always makes me feel good when I get tripped up by something complex and subtle. It almost makes up for all the times when I feel like a dolt because I got tripped up by something obvious and elementary... From jeanpierreda at gmail.com Thu Nov 17 01:20:43 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 17 Nov 2011 01:20:43 -0500 Subject: staticmethod makes my brain hurt In-Reply-To: <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ec490ec$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: > However, the fix is not as simple as merely making staticmethod objects > callable. This was discussed at the 2011 language summit: > > http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html > > See also this thread: > > http://mail.python.org/pipermail/python-dev/2011-March/109090.html The notes didn't actually mention what was discussed, but re the second thread, the issue was not changing staticmethod to be callable. Making staticmethod callable is fine, but __get__ still has to return the original function, not self. The context of the second thread was that staticmethod was imagined as one way to eliminate the difference between C and Python functions, when added to a class. But this doesn't quite work, unless staticmethod.__get__ returned self (which broke for related reasons). If it returns the original function (as it does now) then the issue is unresolved: C functions still behave differently from Python functions, so you can't quite just hide them behind a staticmethod and let everything remain the same. It doesn't eliminate the difference in behavior in certain circumstances, e.g.: class MyClass: foo = staticmethod(foo) class MyOtherClass: foo = MyClass.foo MyOtherClass().foo() # what happens if foo is builtin vs pure-Python? In the context of this thread, though, just making it callable without modifying __get__ is fine. Or at least, I don't see the issue. Devin On Wed, Nov 16, 2011 at 11:43 PM, Steven D'Aprano wrote: > On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote: > >> When I run this (python 2.6.1): >> >> class C: >> ? ? @staticmethod >> ? ? def foo(): >> ? ? ? ? pass >> ? ? print "inside", foo, callable(foo) >> >> print "outside", C.foo, callable(C.foo) >> >> I get: >> >> inside False >> outside True >> >> I don't understand. ?Why is foo not callable inside of the class >> definition? > > > This has come up before. > > http://bytes.com/topic/python/answers/34396-static-method-object-not-callable > > http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callable > > > However, the fix is not as simple as merely making staticmethod objects > callable. This was discussed at the 2011 language summit: > > http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html > > See also this thread: > > http://mail.python.org/pipermail/python-dev/2011-March/109090.html > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From dotancohen at gmail.com Thu Nov 17 01:44:23 2011 From: dotancohen at gmail.com (Dotan Cohen) Date: Thu, 17 Nov 2011 08:44:23 +0200 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 04:30, Roy Smith wrote: > When I run this (python 2.6.1): > > class C: > ? ?@staticmethod > ? ?def foo(): > ? ? ? ?pass > > ? ?print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I get: > > inside False > outside True > > I don't understand. ?Why is foo not callable inside of the class > definition? ?Where this comes up is that I'm trying to use a callable > default in mongoengine: > > class User(Document): > ? ?@staticmethod > ? ?def _get_next_id(): > ? ? ?[blah, blah, blah] > ? ? ?return id > > ? ?user_id = IntField(required=True, default=_get_next_id) > > The way mongoengine works is if callable(default) is true, it calls > default() to get the real value to use. ?At the point where the > IntField() call is made, _get_next_id is not callable, and eventually I > end up with: > > ValidationError: could not be > converted to int Try this (untested): class C: @staticmethod def foo(): pass print "inside", C.foo, callable(C.foo) -- Dotan Cohen http://gibberish.co.il http://what-is-what.com From anushritripathi at gmail.com Thu Nov 17 02:05:30 2011 From: anushritripathi at gmail.com (Anushree Tripathi) Date: Thu, 17 Nov 2011 12:35:30 +0530 Subject: problem in running script file of modeller Message-ID: When I run mod9.10 model-default.py command on command window.It is showing that 'import site' failed;use -v for traceback and also error in opening alignment.ali file.Now what do i have to change.Please reply me as soon as possible. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Nov 17 02:37:57 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 17 Nov 2011 00:37:57 -0700 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen wrote: > Try this (untested): > > class C: > ? @staticmethod > ? def foo(): > ? ? ? pass > > ? print "inside", C.foo, callable(C.foo) If you had tested this, you would have found that you get a NameError, since C is not yet bound inside the class block where you define it. From whatsjacksemail at gmail.com Thu Nov 17 02:38:04 2011 From: whatsjacksemail at gmail.com (Jack Keegan) Date: Thu, 17 Nov 2011 07:38:04 +0000 Subject: Multiple threads In-Reply-To: <4EC4014F.8080105@davea.name> References: <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <4EC3F298.1030604@davea.name> <4EC3FF56.7030101@davea.name> <4EC4014F.8080105@davea.name> Message-ID: On Wed, Nov 16, 2011 at 6:30 PM, Dave Angel wrote: > On 11/16/2011 01:22 PM, Dave Angel wrote: > >> (You're top-posting. Put your remarks AFTER what you're quoting) >> >> On 11/16/2011 12:52 PM, Jack Keegan wrote: >> >>> Ok, I thought that processes would do the same job as threads. So would >>> the >>> general rule be some thing like so: >>> >>> If I want another piece of work to run (theoretically) along side my main >>> script, and I want to share data between them, I should use a thread and >>> share data with the thread-safe queue. >>> If the work I want done can function and complete on its own, go for a >>> process. >>> >>> Would that be about right? >>> >>> >> Yes, with all the caveats I mentioned before. With some language >> implementations, and with some operating systems, and on some CPU-systems, >> the guidelines could be different. They all trade off in ways too complex >> to describe here. >> >> For example, if a thread is mostly doing I/O, it may be just as efficient >> as a separate process, even if sharing data isn't an issue. >> >> And in some languages, sharing data between processes isn't all that >> tough, either. >> >> >> Well, you sent me a mail without including the list (just use > Reply-All), and I tried to add the list in. Unfortunately, I picked the > wrong one, so i sent this to Tutor by mistake. I'll try to fix that now, > sorry. Apologies, I usually reply-all and don't usually top-post. Was just rushing out the door when I responded last time. Cheers, Jack -- The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and in triumph they could become the momentary masters of a fraction of a dot. - Carl Sagan [Pale Blue Dot] -------------- next part -------------- An HTML attachment was scrubbed... URL: From bastian.ballmann at notch-interactive.com Thu Nov 17 03:36:59 2011 From: bastian.ballmann at notch-interactive.com (Bastian Ballmann) Date: Thu, 17 Nov 2011 09:36:59 +0100 Subject: pymacs? In-Reply-To: <4EC44A4A.70201@gmail.com> References: <4EC44A4A.70201@gmail.com> Message-ID: <4EC4C7AB.9050807@notch-interactive.com> Hi, why not try out emacs-for-python https://github.com/gabrielelanaro/emacs-for-python It's has everything included one needs as a python programmer on emacs and even if it's not your choice you can lookup pymacs configuration there. HTH && have a nice day Basti Am 17.11.2011 00:42, schrieb Andrea Crotti: > After a long time, and since it was included iin python-mode, I wanted > to try if I can > get ropemacs working finally. > I have tried many possible things, also in Emacs -Q, and I actually > got it working > only once, apparently by pure luck with Emacs -Q: > > (setq py-load-python-mode-pymacs-p nil) > > (setq ca-pymacs-path (expand-file-name > "~/Emacs-configuration/python-mode/pymacs")) > (add-to-list 'load-path ca-pymacs-path) > (setenv "PYMACS_PYTHON" "python2.7") > (require 'pymacs) > > (pymacs-load "ropemacs" "rope-") > (setq ropemacs-confirm-saving 'nil) > > The problem is that this configuration doesn't use python-mode.el but > the standard python.el, > all my attempts to make this work on my normal configuration failed. > Did anyone got both correctly working? > > Thanks.. -- Bastian Ballmann / Web Developer Notch Interactive GmbH / Badenerstrasse 571 / 8048 Z?rich Phone +41 43 818 20 91 / www.notch-interactive.com From ulrich.eckhardt at dominolaser.com Thu Nov 17 03:53:07 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 17 Nov 2011 09:53:07 +0100 Subject: unit-profiling, similar to unit-testing In-Reply-To: References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: Am 16.11.2011 15:36, schrieb Roy Smith: > It's really, really, really hard to either control for, or accurately > measure, things like CPU or network load. There's so much stuff you > can't even begin to see. The state of your main memory cache. Disk > fragmentation. What I/O is happening directly out of kernel buffers vs > having to do a physical disk read. How slow your DNS server is today. Fortunately, I am in a position where I'm running tests on one system (generic desktop PC) while the system to test is another one, and there both hardware and software is under my control. Since this is rather smallish and embedded, the power and load of the desktop don't play a significant role, the other side is usually the bottleneck. ;) > What I suggest is instrumenting your unit test suite to record not just > the pas/fail status of every test, but also the test duration. Stick > these into a database as the tests run. Over time, you will accumulate > a whole lot of performance data, which you can then start to mine. I'm not sure. I see unit tests as something that makes sure things run correctly. For performance testing, I have functions to set up and tear down the environment. Then, I found it useful to have separate code to prime a cache, which is something done before each test run, but which is not part of the test run itself. I'm repeating each test run N times, recording the times and calculating maximum, minimum, average and standard deviation. Some of this is similar to unit testing (code to set up/tear down), but other things are too different. Also, sometimes I can vary tests with a factor F, then I would also want to capture the influence of this factor. I would even wonder if you can't verify the behaviour agains an expected Big-O complexity somehow. All of this is rather general, not specific to my use case, hence my question if there are existing frameworks to facilitate this task. Maybe it's time to create one... > While you're running the tests, gather as much system performance data > as you can (output of top, vmstat, etc) and stick that into your > database too. You never know when you'll want to refer to the data, so > just collect it all and save it forever. Yes, this is surely something that is necessary, in particular since there are no clear success/failure outputs like for unit tests and they require a human to interpret them. Cheers! Uli From john.37 at gmail.com Thu Nov 17 04:06:03 2011 From: john.37 at gmail.com (sword) Date: Thu, 17 Nov 2011 01:06:03 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: <4f5fd473-4717-4f41-8017-d7407adc4571@u10g2000prl.googlegroups.com> On Nov 16, 10:50?pm, Peter Otten <__pete... at web.de> wrote: > sword wrote: > > Thanks for your reply. I tried to edit the source a bit, now the > > main.py looks like this: > > #main.py > > import logging > > from logging import Filter > > import a > > import b > > > logging.basicConfig(level=logging.DEBUG) > > root = logging.getLogger() > > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > > would pass this filter > > > logger = logging.getLogger("main") > > logger.debug("main process") > > a.print_log() > > b.print_log() > > > #### > > And It still prints out all the log msg. :( > > Here's a little demo to explore how filtering works: > > $ cat demo.py > import logging > class Filter(logging.Filter): > ? ? def filter(self, record): > ? ? ? ? print "applying filter", self.name > ? ? ? ? return True > > logging.basicConfig() > > loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]] > for logger in loggers: > ? ? logger.addFilter(Filter("filter@" + logger.name)) > > [handler] = logging.getLogger().handlers > handler.addFilter(Filter("filter at handler")) > > for logger in loggers: > ? ? logger.critical("whatever") > $ python demo.py > applying filter filter at root > applying filter filter at handler > CRITICAL:root:whatever > applying filter filter at a > applying filter filter at handler > CRITICAL:a:whatever > applying filter fil... at a.b > applying filter filter at handler > CRITICAL:a.b:whatever > $ > > As you can infer from the output only the filter(s) of the original logger > and of the handler(s) are applied. Thanks, so if I want to see my own log out of all logs produced by different module in the project, I should addFilter to each corresponding logger. I thought I could add Filter in root and filter out only the interested info from it before. From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Thu Nov 17 04:17:21 2011 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Thu, 17 Nov 2011 10:17:21 +0100 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: Am 17.11.2011 03:30 schrieb Roy Smith: > When I run this (python 2.6.1): > > class C: > @staticmethod > def foo(): > pass > > print "inside", foo, callable(foo) > > print "outside", C.foo, callable(C.foo) > > I get: > > inside False > outside True Right. The reason is that on an attribute access, you get a __get__ call of the "real" attribute. That is, if your class has a "regular" method, it is stored there as a formal function. But if you access it (C.f), you get C.__dict__["f"].__get__(None, C) (not sure about the arguments, but you should get the idea). A functions __get__ returns a unbound or bound method, depending on its own arguments. With a static method, you don't want this to happen. So you wrap your "regular" function into a staticmethod object, which has a __get__() method itself just returning the wrapped function object. Look at this: >>> class C(object): pass ... >>> f=lambda *a:a >>> C.f=f >>> s=staticmethod(f) >>> C.s=s >>> # Now we test the access ... >>> f at 0x00B43E30> >>> s >>> C.f > >>> C().f of <__main__.C object at 0x00B48810>> >>> C.s at 0x00B43E30> >>> C().s at 0x00B43E30> >>> f.__get__(None, C) > >>> f.__get__(C(), C) of <__main__.C object at 0x00B48AD0>> >>> s.__get__(None, C) at 0x00B43E30> >>> s.__get__(C(), C) at 0x00B43E30> That's how things work. If you want to get back the "real" function from a staticmethod, you either call its __get__ with an arbitrary argument, or you do it the clean way and do a def deref(s): class C(object): s=s return s.s and so do a class User(Document): @staticmethod def _get_next_id(): [blah, blah, blah] return id user_id = IntField(required=True, default=deref(_get_next_id)) HTH, Thomas From usenet at solar-empire.de Thu Nov 17 04:48:17 2011 From: usenet at solar-empire.de (Marc Christiansen) Date: Thu, 17 Nov 2011 10:48:17 +0100 Subject: How to insert my own module in front of site eggs? References: Message-ID: <1s1fp8-6la.ln1@pluto.solar-empire.de> Roy Smith wrote: > I'm trying to use a custom version of mongoengine. I cloned the git > repo and put the directory on my PYTHONPATH, but python is still > importing the system's installed version. Looking at sys.path, it's > obvious why: > > $ echo $PYTHONPATH > /home/roy/songza:/home/roy/lib/mongoengine > >>>> pprint.pprint(sys.path) > ['', > '/usr/local/lib/python2.6/dist-packages/selenium-2.0a5-py2.6.egg', > '/usr/local/lib/python2.6/dist-packages/unittest2-0.5.1-py2.6.egg', > > '/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.eg > g', > '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.2-py2.6.egg', > '/usr/local/lib/python2.6/dist-packages/mongoengine-0.5.2-py2.6.egg', > '/home/roy/songza', > '/home/roy/lib/mongoengine', [...] > The system eggs come before my path. I found > http://mail.python.org/pipermail/distutils-sig/2006-July/006520.html in > the archives; it explains that eggs come before PYTHONPATH, but doesn't > explain how to get around this problem. I emphatically agree with > Michael Bayer who said: > >> I cant think of a possible scenario where a path would explicitly >> exist in PYTHONPATH, non-egg or egg, where the user would still like the >> system-wide installation to take precedence > > So, is there any way to get my local copy of mongoengine loaded instead > of the system egg? I could probably import sys, and do an egg-ectomy on > sys.path before importing mongoengine, but that's too gross to > contemplate. The only way I found is to edit the easy_install.pth file and comment the two lines starting with "import sys". You'll have to do that every time you install/upgrade an egg via easy_install (and maybe setuptools). In your case the right file should be /usr/local/lib/python2.6/dist-packages/easy_install.pth BTW: You could try pip (http://www.pip-installer.org/) instead of easy_install, it doesn't mess with sys.path. Ciao Marc From anushritripathi at gmail.com Thu Nov 17 04:51:33 2011 From: anushritripathi at gmail.com (Anushree Tripathi) Date: Thu, 17 Nov 2011 15:21:33 +0530 Subject: problem in running script file (model-default.py) Message-ID: When I run script file(i.e.,model-default.py) on IDLE interface,I m getting this error: read_al_373E> Protein specified in ALIGN_CODES(i) was not found in the alignment file; ALIGN_CODES( 1) = 2hyd -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Thu Nov 17 05:12:09 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 17 Nov 2011 02:12:09 -0800 Subject: problem in running script file (model-default.py) In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 1:51 AM, Anushree Tripathi wrote: > When I run script file(i.e.,model-default.py) on IDLE interface,I m > getting?this error: > read_al_373E> Protein specified in ALIGN_CODES(i) was not found in the > alignment file; ALIGN_CODES(?????? 1) =? 2hyd Such an error is entirely specific to the particular script you are running (and/or possibly due to a lack of command-line arguments since you're running it via IDLE). Either consult the script's documentation or author, or post the script here. We can't debug/troubleshoot code we don't have access to. Regards, Chris From Nikunj.Badjatya at emc.com Thu Nov 17 05:39:33 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Thu, 17 Nov 2011 05:39:33 -0500 Subject: ProgressBar - Python and Powershell Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> Hi All, I am using Python 2.7, windows Env. I have an Installer written in Python(45%) and Powershell(55%) which is used to install Virtual Machines at specific locations. It is single threaded. I am trying to implement a ProgressBar for this installer. So that the user will come to know the progress of the installation. I am using pypi progressbar module. The top script is in python which inturns calls powershell scripts using subprocess.call() and proceeds with the installation. I am taking a shared file between python and powershell, so that diff functions can update their %age completion level in to the file. Ex. Func1() updates it to 5%, func2() will add its own 5% to it.. and so on. At the start of the (main.py) script I am creating a thread whose sole purpose would be to keep "READ" a temp file for a new entry in it. Based on this entry I can have my thread update the progressbar on the console. My questions are: 1. Can I have a better shared mechanism between python and powershell.? As I am using a file here. Reading + writing in python and writing only in powershell. ! 2. Does this thread mechanism work.? I am yet to implement and test it.! :P What can be the possible shortfalls.? Thanks Nikunj Bangalore - India -------------- next part -------------- An HTML attachment was scrubbed... URL: From dotancohen at gmail.com Thu Nov 17 06:13:38 2011 From: dotancohen at gmail.com (Dotan Cohen) Date: Thu, 17 Nov 2011 13:13:38 +0200 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 09:37, Ian Kelly wrote: > On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen wrote: >> Try this (untested): >> >> class C: >> ? @staticmethod >> ? def foo(): >> ? ? ? pass >> >> ? print "inside", C.foo, callable(C.foo) > > If you had tested this, you would have found that you get a NameError, > since C is not yet bound inside the class block where you define it. > I hadn't tested, I'm at work far from Idle. Just shooting from the hip. For that matter, though, this does work in Java (I'm pretty sure but again, untested right now). -- Dotan Cohen http://gibberish.co.il http://what-is-what.com From rosuav at gmail.com Thu Nov 17 06:38:19 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Nov 2011 22:38:19 +1100 Subject: staticmethod makes my brain hurt In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 10:13 PM, Dotan Cohen wrote: > I'm at work far from Idle. Taken out of context, I'm sure your boss is pleased. :) ChrisA From roy at panix.com Thu Nov 17 09:03:15 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 09:03:15 -0500 Subject: unit-profiling, similar to unit-testing References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: In article , Ulrich Eckhardt wrote: > Yes, this is surely something that is necessary, in particular since > there are no clear success/failure outputs like for unit tests and they > require a human to interpret them. As much as possible, you want to automate things so no human intervention is required. For example, let's say you have a test which calls foo() and times how long it takes. You've already mentioned that you run it N times and compute some basic (min, max, avg, sd) stats. So far, so good. The next step is to do some kind of regression against past results. Once you've got a bunch of historical data, it should be possible to look at today's numbers and detect any significant change in performance. Much as I loathe the bureaucracy and religious fervor which has grown up around Six Sigma, it does have some good tools. You might want to look into control charts (http://en.wikipedia.org/wiki/Control_chart). You think you've got the test environment under control, do you? Try plotting a month's worth of run times for a particular test on a control chart and see what it shows. Assuming your process really is under control, I would write scripts that did the following kinds of analysis: 1) For a given test, do a linear regression of run time vs date. If the line has any significant positive slope, you want to investigate why. 2) You already mentioned, "I would even wonder if you can't verify the behaviour agains an expected Big-O complexity somehow". Of course you can. Run your test a bunch of times with different input sizes. I would try something like a 1-2-5 progression over several decades (i.e. input sizes of 10, 20, 50, 100, 200, 500, 1000, etc) You will have to figure out what an appropriate range is, and how to generate useful input sets. Now, curve fit your performance numbers to various shape curves and see what correlation coefficient you get. All that being said, in my experience, nothing beats plotting your data and looking at it. From roy at panix.com Thu Nov 17 09:09:34 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 09:09:34 -0500 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> Message-ID: In article <1s1fp8-6la.ln1 at pluto.solar-empire.de>, Marc Christiansen wrote: > > So, is there any way to get my local copy of mongoengine loaded instead > > of the system egg? I could probably import sys, and do an egg-ectomy on > > sys.path before importing mongoengine, but that's too gross to > > contemplate. > > The only way I found is to edit the easy_install.pth file and comment > the two lines starting with "import sys". You'll have to do that every > time you install/upgrade an egg via easy_install (and maybe setuptools). > In your case the right file should be > /usr/local/lib/python2.6/dist-packages/easy_install.pth > > BTW: You could try pip (http://www.pip-installer.org/) instead of > easy_install, it doesn't mess with sys.path. But, you're talking about installers. I'm talking about if I've already got something installed, how do I force one particular python process to pull in a local copy of a module in preference to the installed one? In some cases, I own the machine and can make changes to /usr/local/lib if I want to. But what about on a shared machine? I don't want to (or perhaps can't) play with what's in /usr/local/lib just to make my stuff load first. From duncan.booth at invalid.invalid Thu Nov 17 10:04:49 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 17 Nov 2011 15:04:49 GMT Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> Message-ID: Roy Smith wrote: > In some cases, I own the machine and can make changes to /usr/local/lib > if I want to. But what about on a shared machine? I don't want to (or > perhaps can't) play with what's in /usr/local/lib just to make my stuff > load first. > Have you considered running your code in a virtualenv? http://pypi.python.org/pypi/virtualenv -- Duncan Booth http://kupuguy.blogspot.com From candide at free.invalid Thu Nov 17 10:48:04 2011 From: candide at free.invalid (candide) Date: Thu, 17 Nov 2011 16:48:04 +0100 Subject: Use and usefulness of the as syntax In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: <4ec52cb7$0$16583$426a74cc@news.free.fr> Thanks to all Le 12/11/2011 13:27, Chris Angelico a ?crit : > On Sat, Nov 12, 2011 at 10:56 PM, candide wrote: >> import foo as f >> >> equivalent to >> >> import foo >> f = foo >> > > Not quite, it's closer to: > > import foo > f = foo > del foo > Le 12/11/2011 13:43, Tim Chase a ?crit : > On 11/12/11 05:56, candide wrote: >> First, could you confirm the following syntax >> >> import foo as f >> >> equivalent to >> >> import foo >> f = foo > > and the issuing "del foo" > Correct, I missed this point : I didn't realize that importing is also binding. From candide at free.invalid Thu Nov 17 10:48:32 2011 From: candide at free.invalid (candide) Date: Thu, 17 Nov 2011 16:48:32 +0100 Subject: Use and usefulness of the as syntax In-Reply-To: References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Message-ID: <4ec52cd3$0$16583$426a74cc@news.free.fr> Le 12/11/2011 13:29, Arnaud Delobelle a ?crit : >> -- The second case seems to be rather widespread and causes math attribute >> to be private but I don't figure out why this matters. > > This way math doesn't get bound in the global namespace when doing > "from module import *" > To contextualize more, I guess you are referring to the following situation : # a.py import math as _math # b.py from a import * print _math.sin(0) # raise a NameError print math.sin(0) # raise a NameError so the as syntax is also seful for hiding name, isn'it ? From wolftracks at invalid.com Thu Nov 17 11:55:36 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 08:55:36 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 Message-ID: Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I uninstalled and installed. Same problem. If one right-clicks on a py file, IDLE is not shown in the menu as Edit with IDLE. After playing with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same results. If I look at a 2.4 install on my laptop, I get the desired reference to Edit with IDLE. My guess is that Win 7 is behind this. If so, it's good-bye Python. Comments? From paul.nospam at rudin.co.uk Thu Nov 17 12:05:17 2011 From: paul.nospam at rudin.co.uk (Paul Rudin) Date: Thu, 17 Nov 2011 17:05:17 +0000 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> Message-ID: <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Roy Smith writes: > But, you're talking about installers. I'm talking about if I've already > got something installed, how do I force one particular python process to > pull in a local copy of a module in preference to the installed one? > > In some cases, I own the machine and can make changes to /usr/local/lib > if I want to. But what about on a shared machine? I don't want to (or > perhaps can't) play with what's in /usr/local/lib just to make my stuff > load first. Maybe I'm missing something - but if I want to do this I just mess about with sys.path at the top of my python script/program. Always seems to work... is there a situation in which it doesn't? From spartan.the at gmail.com Thu Nov 17 12:37:30 2011 From: spartan.the at gmail.com (spartan.the) Date: Thu, 17 Nov 2011 09:37:30 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: On 17 Nov, 18:55, "W. eWatson" wrote: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > results. > > If I look at a 2.4 install on my laptop, I get the desired reference to > Edit with IDLE. > > My guess is that Win 7 is behind this. If so, it's good-bye Python. > > Comments? I prefer "fail fast" approach too. If right-click not working on Win7 is your reason to say good bye to Python then better you do so. From ray040123 at gmail.com Thu Nov 17 12:37:49 2011 From: ray040123 at gmail.com (ray) Date: Fri, 18 Nov 2011 01:37:49 +0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4EC5466D.8000000@gmail.com> On Friday, November 18, 2011 12:55 AM, W. eWatson wrote: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago > I uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. > Same results. > > If I look at a 2.4 install on my laptop, I get the desired reference > to Edit with IDLE. > > My guess is that Win 7 is behind this. If so, it's good-bye Python. > > Comments? Why not good-bye Windows ? Actually you may want to try Vim, or gVim in Windows. I think the people who use IDLE is with really good patient. From gordon at panix.com Thu Nov 17 12:39:56 2011 From: gordon at panix.com (John Gordon) Date: Thu, 17 Nov 2011 17:39:56 +0000 (UTC) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: In "W. eWatson" writes: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > results. I'm not sure I'd describe the lack of IDLE in a context menu as "python not functioning". > If I look at a 2.4 install on my laptop, I get the desired reference to > Edit with IDLE. > My guess is that Win 7 is behind this. If so, it's good-bye Python. It was working originally, right? So the problem can't really just be Win 7. Can you add IDLE manually to the associated applications list? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From therve at free.fr Thu Nov 17 13:02:17 2011 From: therve at free.fr (=?UTF-8?B?VGhvbWFzIEhlcnbDqQ==?=) Date: Thu, 17 Nov 2011 19:02:17 +0100 Subject: Twisted 11.1.0 Released Message-ID: <4EC54C29.80300@free.fr> On behalf of Twisted Matrix Laboratories, I am pleased to announce the release of Twisted 11.1. Highlights of the 185 tickets closed include: * The poll reactor as default where applicable, instead of select everywhere. * A new SSL implementation only relying on OpenSSL for cryptography, (not I/O) making it more robust. * Several improvements to the fresh HTTP/1.1 client implementation, including proxy and cookie support. * My personal favorite: a new howto has been published on test-driven development with Twisted. * A special mention to the new abortConnection support on TCP and SSL connections, heroically pushed by Itamar and Jean-Paul, and the oldest ticket closed by this release. This is the last release supporting Python 2.4 (the support on Windows stopped with 11.0). For more information, see the NEWS file here: http://twistedmatrix.com/Releases/Twisted/11.1/NEWS.txt Download it now from: http://pypi.python.org/packages/source/T/Twisted/Twisted-11.1.0.tar.bz2 or http://pypi.python.org/packages/2.5/T/Twisted/Twisted-11.1.0.win32-py2.5.msi or http://pypi.python.org/packages/2.6/T/Twisted/Twisted-11.1.0.win32-py2.6.msi or http://pypi.python.org/packages/2.7/T/Twisted/Twisted-11.1.0.win32-py2.7.msi Thanks to the supporters of the Twisted Software Foundation and to the many contributors for this release. -- Thomas From steve+comp.lang.python at pearwood.info Thu Nov 17 13:42:36 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 17 Nov 2011 18:42:36 GMT Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <4ec5559c$0$29967$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Nov 2011 08:55:36 -0800, W. eWatson wrote: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > results. I find I get better results when I stop "playing with matters" and start treating them seriously :) If you need help fixing the file associations on your Windows 7 machine, you'll probably get better advice on a dedicated Windows forum. Or even by googling for instructions: https://duckduckgo.com/html/?q=how%20to%20fix%20windows%207%20file%20associations > If I look at a 2.4 install on my laptop, I get the desired reference to > Edit with IDLE. So you're saying that Python is working on one laptop, but not on another machine? Okay. Great. What's your point? You have a messed up installation on your Windows 7 box, and a working installation on your laptop. What would you like us to do? Commiserate? Laugh? Look into a crystal ball and tell you what you did wrong? Can you run Python from the command line? If so, that tells you that Python is installed and working correctly. If Python is installed, then it sounds like a matter of getting the file associates fixed in the registry. Good luck. > My guess is that Win 7 is behind this. If so, it's good-bye Python. > > Comments? Why not good-bye Windows 7? This being Windows, have you run a virus scan with up to date definitions? Then run a *second* scan, using a completely different scanner, because no scanner can catch all viruses? And then run a good anti-spyware program. All of which will be irrelevant 99 times out of 100, but you could be the 1% ... -- Steven From wolftracks at invalid.com Thu Nov 17 15:22:03 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 12:22:03 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 9:39 AM, John Gordon wrote: > In "W. eWatson" writes: > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. > > I'm not sure I'd describe the lack of IDLE in a context menu as > "python not functioning". > >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. > > It was working originally, right? So the problem can't really just be > Win 7. > > Can you add IDLE manually to the associated applications list? > Not successfully. I tried it and pointed to idle.pyw. It gave a Invalid Win32 app. From wolftracks at invalid.com Thu Nov 17 15:31:28 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 12:31:28 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 9:39 AM, John Gordon wrote: > In "W. eWatson" writes: > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. > > I'm not sure I'd describe the lack of IDLE in a context menu as > "python not functioning". Well, yes, and I can run it from the command line. > >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. This has been a nagging problem for far too long. I see no reason why a simple install should make such a difference with the way I get to IDLE. Maybe few people here like IDLE, but for my minimal needs, it's just fine. > > It was working originally, right? So the problem can't really just be > Win 7. I installed it about April 2010, and it worked for months. I then stopped using it until around July 2011. It no longer worked in the IDLE sense. Who really knows? > > Can you add IDLE manually to the associated applications list? > Tried that by sending it directly to idle.pyw, but then trying to get there through the Edit with menu caused a "invalid Win32 app." From rosuav at gmail.com Thu Nov 17 15:43:05 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Nov 2011 07:43:05 +1100 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On Fri, Nov 18, 2011 at 7:31 AM, W. eWatson wrote: > I installed it [Windows 7] about April 2010, and it worked for months. I then stopped > using it until around July 2011. It no longer worked in the IDLE sense. > Microsoft have broken things in many Windowses, and it's often hard to figure out whether the fault is with the Windows version or with the application. MS several times went to ridiculous effort to try to ensure that broken programs that ran under version X would still run under version Y, to the extent of being bug-for-bug compatible. If you're having issues, grab a spare computer, throw Linux on it (I recommend Ubuntu or Debian, others will have other preferred distros), and see if the issues remain. Or if you're having trouble with the GUI, try things from the command line (Windows's command interpreter is pretty weak compared to bash, but it's plenty powerful enough). ChrisA From tycho at tycho.ws Thu Nov 17 15:45:56 2011 From: tycho at tycho.ws (Tycho Andersen) Date: Thu, 17 Nov 2011 14:45:56 -0600 Subject: unit-profiling, similar to unit-testing In-Reply-To: References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: <20111117204556.GD16669@velveeta.cs.wisc.edu> On Wed, Nov 16, 2011 at 09:36:40AM -0500, Roy Smith wrote: > In article <95bcp8-bft.ln1 at satorlaser.homedns.org>, > Ulrich Eckhardt wrote: > > > Hi! > > > > I'm currently trying to establish a few tests here that evaluate certain > > performance characteristics of our systems. As part of this, I found > > that these tests are rather similar to unit-tests, only that they are > > much more fuzzy and obviously dependent on the systems involved, CPU > > load, network load, day of the week (Tuesday is virus scan day) etc. > > > > What I'd just like to ask is how you do such things. Are there tools > > available that help? I was considering using the unit testing framework, > > but the problem with that is that the results are too hard to interpret > > programmatically and too easy to misinterpret manually. Any suggestions? > > It's really, really, really hard to either control for, or accurately > measure, things like CPU or network load. There's so much stuff you > can't even begin to see. The state of your main memory cache. Disk > fragmentation. What I/O is happening directly out of kernel buffers vs > having to do a physical disk read. How slow your DNS server is today. While I agree there's a lot of things you can't control for, you can get a more accurate picture by using CPU time instead of wall time (e.g. the clock() system call). If what you care about is mostly CPU time, you can control for the "your disk is fragmented", "your DNS server died", or "my cow-orker was banging on the test machine" this way. \t From spartan.the at gmail.com Thu Nov 17 15:46:38 2011 From: spartan.the at gmail.com (spartan.the) Date: Thu, 17 Nov 2011 12:46:38 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <6b26958f-291e-4c0f-8dce-36343781a63e@t16g2000vba.googlegroups.com> On Nov 17, 10:31?pm, "W. eWatson" wrote: > On 11/17/2011 9:39 AM, John Gordon wrote:> In ?"W. eWatson" ?writes: > > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > >> uninstalled and installed. Same problem. If one right-clicks on a py > >> file, IDLE is not shown in the menu as Edit with IDLE. After playing > >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > >> results. > > > I'm not sure I'd describe the lack of IDLE in a context menu as > > "python not functioning". > > Well, yes, and I can run it from the command line. > > >> If I look at a 2.4 install on my laptop, I get the desired reference to > >> Edit with IDLE. > > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. > > This has been a nagging problem for far too long. I see no reason why a > simple install should make such a difference with the way I get to IDLE. > Maybe few people here like IDLE, but for my minimal needs, it's just fine. > > > > > It was working originally, right? ?So the problem can't really just be > > Win 7. > > I installed it about April 2010, and it worked for months. I then > stopped using it until around July 2011. It no longer worked in the IDLE > sense. > > Who really knows? > > > > > Can you add IDLE manually to the associated applications list? > > Tried that by sending it directly to idle.pyw, but then trying to get > there through the Edit with menu caused a "invalid Win32 app." idle.pyw is not executable in Windows, but you can right-click it, open, browse to pythonw.exe. Then it should work. From python at mrabarnett.plus.com Thu Nov 17 15:59:33 2011 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 17 Nov 2011 20:59:33 +0000 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4EC575B5.2070504@mrabarnett.plus.com> On 17/11/2011 20:31, W. eWatson wrote: > On 11/17/2011 9:39 AM, John Gordon wrote: >> In "W. eWatson" >> writes: >> >>> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >>> uninstalled and installed. Same problem. If one right-clicks on a py >>> file, IDLE is not shown in the menu as Edit with IDLE. After playing >>> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >>> results. >> >> I'm not sure I'd describe the lack of IDLE in a context menu as >> "python not functioning". > Well, yes, and I can run it from the command line. >> >>> If I look at a 2.4 install on my laptop, I get the desired reference to >>> Edit with IDLE. >> >>> My guess is that Win 7 is behind this. If so, it's good-bye Python. > This has been a nagging problem for far too long. I see no reason why a > simple install should make such a difference with the way I get to IDLE. > Maybe few people here like IDLE, but for my minimal needs, it's just fine. > >> >> It was working originally, right? So the problem can't really just be >> Win 7. > I installed it about April 2010, and it worked for months. I then > stopped using it until around July 2011. It no longer worked in the IDLE > sense. > > Who really knows? > >> >> Can you add IDLE manually to the associated applications list? >> > Tried that by sending it directly to idle.pyw, but then trying to get > there through the Edit with menu caused a "invalid Win32 app." Are you trying to associate .pyw with idle.pyw instead of with pythonw.exe? From spartan.the at gmail.com Thu Nov 17 16:28:56 2011 From: spartan.the at gmail.com (spartan.the) Date: Thu, 17 Nov 2011 13:28:56 -0800 (PST) Subject: unit-profiling, similar to unit-testing References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: On Nov 17, 4:03?pm, Roy Smith wrote: > In article , > ?Ulrich Eckhardt wrote: > > > Yes, this is surely something that is necessary, in particular since > > there are no clear success/failure outputs like for unit tests and they > > require a human to interpret them. > > As much as possible, you want to automate things so no human > intervention is required. > > For example, let's say you have a test which calls foo() and times how > long it takes. ?You've already mentioned that you run it N times and > compute some basic (min, max, avg, sd) stats. ?So far, so good. > > The next step is to do some kind of regression against past results. > Once you've got a bunch of historical data, it should be possible to > look at today's numbers and detect any significant change in performance. > > Much as I loathe the bureaucracy and religious fervor which has grown up > around Six Sigma, it does have some good tools. ?You might want to look > into control charts (http://en.wikipedia.org/wiki/Control_chart). ?You > think you've got the test environment under control, do you? ?Try > plotting a month's worth of run times for a particular test on a control > chart and see what it shows. > > Assuming your process really is under control, I would write scripts > that did the following kinds of analysis: > > 1) For a given test, do a linear regression of run time vs date. ?If the > line has any significant positive slope, you want to investigate why. > > 2) You already mentioned, "I would even wonder if you can't verify the > behaviour agains an expected Big-O complexity somehow". ?Of course you > can. ?Run your test a bunch of times with different input sizes. ?I > would try something like a 1-2-5 progression over several decades (i.e. > input sizes of 10, 20, 50, 100, 200, 500, 1000, etc) ?You will have to > figure out what an appropriate range is, and how to generate useful > input sets. ?Now, curve fit your performance numbers to various shape > curves and see what correlation coefficient you get. > > All that being said, in my experience, nothing beats plotting your data > and looking at it. I strongly agree with Roy, here. Ulrich, I recommend you to explore how google measures appengine's health here: http://code.google.com/status/appengine. Unit tests are inappropriate here; any single unit test can answer PASS or FAIL, YES or NO. It can't answer the question "how much". Unless you just want to use unit tests. Then any arguments here just don't make sense. I suggest: 1. Decide what you want to measure. Measure result must be a number in range (0..100, -5..5), so you can plot them. 2. Write no-UI programs to get each number (measure) and write it to CSV. Run each of them several times take away 1 worst and 1 best result, and take and average number. 3. Collect the data for some period of time. 4. Plot those average number over time axis (it's easy with CSV format). 5. Make sure you automate this process (batch files or so) so the plot is generated automatically each hour or each day. And then after a month you can decide if you want to divide your number ranges into green-yellow-red zones. More often than not you may find that your measures are so inaccurate and random that you can't trust them. Then you'll either forget that or dive into math (statistics). You have about 5% chances to succeed ;) From tjreedy at udel.edu Thu Nov 17 17:12:44 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 17 Nov 2011 17:12:44 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 11:55 AM, W. eWatson wrote: > Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I > uninstalled and installed. Same problem. If one right-clicks on a py > file, IDLE is not shown in the menu as Edit with IDLE. After playing > with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same > results. > > If I look at a 2.4 install on my laptop, I get the desired reference to > Edit with IDLE. > > My guess is that Win 7 is behind this. If so, it's good-bye Python. I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine. However, I almost never use that with Explorer to open files. I have IDLE pinned to the task bar so it is one click to start. If I edit a file, I want to run it, so I want a shell window open anyway. I usually open files to edit with the first three entries under the File menu: New File, Open, or Recent Files. Once I open a file in a particular directory (usually with Recent Files), Open initially looks for files in the same directory, which is usually what I want. So say hello again to Python, especially Python 3. -- Terry Jan Reedy From irmen at -NOSPAM-razorvine.net Thu Nov 17 17:31:50 2011 From: irmen at -NOSPAM-razorvine.net (Irmen de Jong) Date: Thu, 17 Nov 2011 23:31:50 +0100 Subject: Monitoring/inventory client-server app In-Reply-To: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> References: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> Message-ID: <4ec58b51$0$6842$e4fe514c@news2.news.xs4all.nl> On 17-11-2011 5:17, snorble wrote: > I'm writing a tool for monitoring the workstations and servers in our > office. I plan to have a server and a client service that runs on each > workstation and reports back to the server (heartbeat, disk free > space, etc). > > So far I am considering XMLRPC, or a client service that just > downloads a Python file and runs it. > > With XMLRPC I don't know how to easily add features without having to > update every client. Also while playing with XMLRPC I learned that > when you run a registered function, it runs it on the server. I was > hoping it would run on the client, so that when I get the machine's > computer name (or disk space, etc) it will return the client's info. > It seems with XMLRPC I would have to hard code the functionality into > the client (i.e. client gets it's computer name, then calls the XMLRPC > function to pass it to the server)? I was hoping it would work more > like, "pass some code to the client to be run on the client, and > report it to the server". Almost XMLRPC in the reverse direction. > > With the download-and-run approach, it seems trivially easy to add new > functionality to the clients. Just save the updated Python file to the > server, and clients download it and run it. > > Are there any standard approaches to problems like this that can be > recommended? Thank you. The security implications are HUGE when you are thinking about transferring and executing arbitrary code over the network. Avoid this if at all possible. But if you can be 100% sure it's only trusted stuff, things are not so grim. Have a look at Pyro, or even Pyro Flame: http://packages.python.org/Pyro4/ http://packages.python.org/Pyro4/flame.html Flame allows for very easy remote module execution and a limited way of transferring code to the 'other side'. Also what is wrong with running an XMLrpc server, or Pyro daemon, on your client machines? This way your central computer can call registered methods (or remote objects in case of Pyro) on the client and execute code there (that reports all sorts of stuff you want to know). Or have each client call into a central server, where it reports that stuff itself. Many ways to skin a cat. Regards, Irmen de Jong From wolftracks at invalid.com Thu Nov 17 18:54:39 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 15:54:39 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: <6b26958f-291e-4c0f-8dce-36343781a63e@t16g2000vba.googlegroups.com> References: <6b26958f-291e-4c0f-8dce-36343781a63e@t16g2000vba.googlegroups.com> Message-ID: On 11/17/2011 12:46 PM, spartan.the wrote: > On Nov 17, 10:31 pm, "W. eWatson" wrote: >> On 11/17/2011 9:39 AM, John Gordon wrote:> In "W. eWatson" writes: >> >>>> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >>>> uninstalled and installed. Same problem. If one right-clicks on a py >>>> file, IDLE is not shown in the menu as Edit with IDLE. After playing >>>> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >>>> results. >> >>> I'm not sure I'd describe the lack of IDLE in a context menu as >>> "python not functioning". >> >> Well, yes, and I can run it from the command line. >> >>>> If I look at a 2.4 install on my laptop, I get the desired reference to >>>> Edit with IDLE. >> >>>> My guess is that Win 7 is behind this. If so, it's good-bye Python. >> >> This has been a nagging problem for far too long. I see no reason why a >> simple install should make such a difference with the way I get to IDLE. >> Maybe few people here like IDLE, but for my minimal needs, it's just fine. >> >> >> >>> It was working originally, right? So the problem can't really just be >>> Win 7. >> >> I installed it about April 2010, and it worked for months. I then >> stopped using it until around July 2011. It no longer worked in the IDLE >> sense. >> >> Who really knows? >> >> >> >>> Can you add IDLE manually to the associated applications list? >> >> Tried that by sending it directly to idle.pyw, but then trying to get >> there through the Edit with menu caused a "invalid Win32 app." > > idle.pyw is not executable in Windows, but you can right-click it, > open, browse to pythonw.exe. Then it should work. right-click on junk.py gives me a menu. I select Open with, and ... hmmm, whoops, in the latest install, 2.7.2, I did not give it access to idle.pyw. My mistake above. I was talking about the previous 2.5.2 of install in Win7. Where I'm at is 2.7.2 now. However, I still find in very odd there is no Edit with IDLE when I right-click on junk.py. That's the way it worked on 2.5.2 on my XP and earlier, 2010, on Win7. Downright frustrating. From wolftracks at invalid.com Thu Nov 17 19:00:31 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 16:00:31 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 12:59 PM, MRAB wrote: > On 17/11/2011 20:31, W. eWatson wrote: >> On 11/17/2011 9:39 AM, John Gordon wrote: >>> In "W. eWatson" >>> writes: >>> >>>> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >>>> uninstalled and installed. Same problem. If one right-clicks on a py >>>> file, IDLE is not shown in the menu as Edit with IDLE. After playing >>>> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >>>> results. >>> >>> I'm not sure I'd describe the lack of IDLE in a context menu as >>> "python not functioning". >> Well, yes, and I can run it from the command line. >>> >>>> If I look at a 2.4 install on my laptop, I get the desired reference to >>>> Edit with IDLE. >>> >>>> My guess is that Win 7 is behind this. If so, it's good-bye Python. >> This has been a nagging problem for far too long. I see no reason why a >> simple install should make such a difference with the way I get to IDLE. >> Maybe few people here like IDLE, but for my minimal needs, it's just >> fine. >> >>> >>> It was working originally, right? So the problem can't really just be >>> Win 7. >> I installed it about April 2010, and it worked for months. I then >> stopped using it until around July 2011. It no longer worked in the IDLE >> sense. >> >> Who really knows? >> >>> >>> Can you add IDLE manually to the associated applications list? >>> >> Tried that by sending it directly to idle.pyw, but then trying to get >> there through the Edit with menu caused a "invalid Win32 app." > > Are you trying to associate .pyw with idle.pyw instead of with > pythonw.exe? What does pythonw.exe do for me? I would think all associations would be correct after an install. The single thing I do not understand is why in my latest install of 2.5.2 and 2.7.2 (2.5.2 was uninstalled before going to 2.7.2) on Win7 that why a right-click on a py file does not show as a choice is "Edit with IDLE", as it does on my XP PC and my 2010 install of 2.5.2 on this Win 7 PC. To me that signals that something is wrong. From wolftracks at invalid.com Thu Nov 17 19:03:14 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 16:03:14 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 2:12 PM, Terry Reedy wrote: > On 11/17/2011 11:55 AM, W. eWatson wrote: >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. >> >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. >> >> My guess is that Win 7 is behind this. If so, it's good-bye Python. > > I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine. > However, I almost never use that with Explorer to open files. I have > IDLE pinned to the task bar so it is one click to start. If I edit a > file, I want to run it, so I want a shell window open anyway. I usually > open files to edit with the first three entries under the File menu: New > File, Open, or Recent Files. Once I open a file in a particular > directory (usually with Recent Files), Open initially looks for files in > the same directory, which is usually what I want. So say hello again to > Python, especially Python 3. > I have not found any successful way to get to IDLE. It's on on the right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails with a "invalid Win32 app" msg. From steve+comp.lang.python at pearwood.info Thu Nov 17 19:24:47 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Nov 2011 00:24:47 GMT Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: > I have not found any successful way to get to IDLE. It's on on the > right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails > with a "invalid Win32 app" msg. If you associate .pyw files with pythonw.exe, and then open idle.pyw, does it work? Failing that, go to your laptop where the associations are right, and see what they are, then duplicate the settings on your Windows 7 machine. -- Steven From roy at panix.com Thu Nov 17 20:36:38 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 20:36:38 -0500 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: In article <874ny2fzn6.fsf at no-fixed-abode.cable.virginmedia.net>, Paul Rudin wrote: > Roy Smith writes: > > > > But, you're talking about installers. I'm talking about if I've already > > got something installed, how do I force one particular python process to > > pull in a local copy of a module in preference to the installed one? > > > > In some cases, I own the machine and can make changes to /usr/local/lib > > if I want to. But what about on a shared machine? I don't want to (or > > perhaps can't) play with what's in /usr/local/lib just to make my stuff > > load first. > > Maybe I'm missing something - but if I want to do this I just mess about > with sys.path at the top of my python script/program. Always seems to > work... is there a situation in which it doesn't? What if the first import of a module is happening inside some code you don't have access to? It just seems mind-boggling to me that PYTHONPATH doesn't preempt everything else. From roy at panix.com Thu Nov 17 20:38:30 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 20:38:30 -0500 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> Message-ID: In article , Duncan Booth wrote: > Roy Smith wrote: > > > In some cases, I own the machine and can make changes to /usr/local/lib > > if I want to. But what about on a shared machine? I don't want to (or > > perhaps can't) play with what's in /usr/local/lib just to make my stuff > > load first. > > > > Have you considered running your code in a virtualenv? > http://pypi.python.org/pypi/virtualenv I do that for some projects. In fact, I suspect I will do that for all furture projects that I start from scratch. For this particular one, there's a lot of stuff already installed in the system that I need. From martin.hellwig at gmail.com Thu Nov 17 20:55:56 2011 From: martin.hellwig at gmail.com (Martin P. Hellwig) Date: Fri, 18 Nov 2011 01:55:56 +0000 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: <6b26958f-291e-4c0f-8dce-36343781a63e@t16g2000vba.googlegroups.com> Message-ID: On 17/11/2011 23:54, W. eWatson wrote: > My mistake above. I was talking about the previous 2.5.2 of install in > Win7. Where I'm at is 2.7.2 now. However, I still find in very odd there > is no Edit with IDLE when I right-click on junk.py. That's the way it > worked on 2.5.2 on my XP and earlier, 2010, on Win7. Downright frustrating. > Well if I was still a windows administrator and you would be one of my users, I would first make sure that your profile or windows installation is not pooped as it definitively smells like that. After being reassured that this is not the case I would then search the interwebs for something like "extending right click context menu". Probably hitting something like this: http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-can-i-customize-right-click-mouse-context-menu/5ea7104f-2213-41b9-9933-83f25da086d1 And after that searching where this 'idle' you speak of is actually located, probably finding something like this: http://stackoverflow.com/questions/118260/how-to-start-idle-python-editor-without-using-the-shortcut-on-windows-vista Then it rest me to combine them both, after promising myself not to install one version of a particular program 'for all users' and then 'updating' for 'only me' as this can screw up the default settings quite badly. But hey I haven't been a win admin since I switched over to FreeBSD years and years ago. I find it immensely reassuring that the problems I encounter on my systems are all my fault, well actually that is just the same as with windows, just less obvious there. Luckily I am no longer an administrator either as I couldn't stand it anymore when users spill their frustrations, although perfectly understandable, unto those who are actually willing to help. Something to do with attitude or so, speaking if which, I do apologize for my own attitude, but given the choice of just ignoring you or lacing my post with patronization I though that the latter one was the least bad of them two. -- mph From roy at panix.com Thu Nov 17 21:00:00 2011 From: roy at panix.com (Roy Smith) Date: Thu, 17 Nov 2011 21:00:00 -0500 Subject: unit-profiling, similar to unit-testing References: <95bcp8-bft.ln1@satorlaser.homedns.org> Message-ID: In article , Tycho Andersen wrote: > While I agree there's a lot of things you can't control for, you can > get a more accurate picture by using CPU time instead of wall time > (e.g. the clock() system call). If what you care about is mostly CPU > time [...] That's a big if. In some cases, CPU time is important, but more often, wall-clock time is more critical. Let's say I've got two versions of a program. Here's some results for my test run: Version CPU Time Wall-Clock Time 1 2 hours 2.5 hours 2 1.5 hours 5.0 hours Between versions, I reduced the CPU time to complete the given task, but increased the wall clock time. Perhaps I doubled the size of some hash table. Now I get a lot fewer hash collisions (so I spend less CPU time re-hashing), but my memory usage went up so I'm paging a lot and my locality of reference went down so my main memory cache hit rate is worse. Which is better? I think most people would say version 1 is better. CPU time is only important in a situation where the system is CPU bound. In many real-life cases, that's not at all true. Things can be memory bound. Or I/O bound (which, when you consider paging, is often the same thing as memory bound). Or lock-contention bound. Before you starting measuring things, it's usually a good idea to know what you want to measure, and why :-) From ladasky at my-deja.com Thu Nov 17 21:18:11 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 18:18:11 -0800 (PST) Subject: What exactly is "pass"? What should it be? Message-ID: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Hi folks, I'm trying to write tidy, modular code which includes a long-running process. From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. Other times, I'll just want to let it run. So I have a section of code which, generally, looks like this: def _pass(*args): pass def long_running_process(arg1, arg2, arg_etc, report = _pass): result1 = do_stuff() report(result1) result2 = do_some_different_stuff() report(result2) result3 = do_even_more_stuff() report(result3) return result3 This does what I want. When I do not specify a report function, the process simply runs. Typically, when I do supply a report function, it would print something to stdout, or draw an update through a GUI. But this approach seems a tad cumbersome and unPythonic to me, particularly the part where I define the function _pass() which accepts an arbitrary argument list, and does nothing but... pass. This has led me to ask the question, what exactly IS pass? I played with the interpreter a bit. IDLE 2.6.6 ==== No Subprocess ==== >>> pass >>> pass() SyntaxError: invalid syntax >>> type(pass) SyntaxError: invalid syntax So, pass does not appear to be a function, nor even an object. Is it nothing more than a key word? And would there be any merit to having some syntactic sugar which allows pass to behave like the _pass() function I wrote, if it were called? As you can see, I'm programming in Python 2.6. I don't know whether pass is handled differently in Python 3. From wuwei23 at gmail.com Thu Nov 17 21:31:04 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 18:31:04 -0800 (PST) Subject: staticmethod makes my brain hurt References: Message-ID: On Nov 17, 1:24?pm, Ethan Furman wrote: > If you do need to sometimes call it from a method then still leave off > the '@staticmethod', and give 'self' a default of 'None': > > ? ? ?def _get_next_id(self=None): > ? ? ? ?[blah, blah, blah] > ? ? ? ?return id > > ? ? ?user_id = IntField(required=True, default=_get_next_id) And if the OP needs it to be a staticmethod as well, he can just wrap the nested function: gen_next_id = staticmethod(_gen_next_id) I think I like this approach best. I'm annoyed that I forgot functions declared in a class scope were callable within the definition :) From wuwei23 at gmail.com Thu Nov 17 21:38:47 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 18:38:47 -0800 (PST) Subject: Use and usefulness of the as syntax References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> <4ec52cd3$0$16583$426a74cc@news.free.fr> Message-ID: <1772de52-5ce0-4cb0-ac3c-e43aa2d17cf6@a5g2000vbb.googlegroups.com> On Nov 18, 1:48?am, candide wrote: > # a.py > import math as _math > > # b.py > from a import * > > print _math.sin(0) ? ? ? # raise a NameError > print math.sin(0) ? ? ? ?# raise a NameError > > so the as syntax is also seful for hiding name, isn'it ? Not exactly. It's the * import mechanism here that's ignoring any bindings that begin with an underscore. If you had: _dummy = 1 ...inside of a.py, it wouldn't be pulled in either. As you state later, 'as' is purely a binding convenience. Incidentally, you can still allow * import to bring in underscore- prefixed bindings by adding them to an __all__: __all__ = ['_dummy'] From clp2 at rebertia.com Thu Nov 17 21:45:58 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 17 Nov 2011 18:45:58 -0800 Subject: What exactly is "pass"? What should it be? In-Reply-To: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: On Thu, Nov 17, 2011 at 6:18 PM, John Ladasky wrote: > Hi folks, > > I'm trying to write tidy, modular code which includes a long-running process. ?From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. ?Other times, I'll just want to let it run. ?So I have a section of code which, generally, looks like this: > > def _pass(*args): > ? ?pass > > def long_running_process(arg1, arg2, arg_etc, report = _pass): > ? ?result1 = do_stuff() > ? ?report(result1) > ? ?result2 = do_some_different_stuff() > ? ?report(result2) > ? ?result3 = do_even_more_stuff() > ? ?report(result3) > ? ?return result3 > > This does what I want. ?When I do not specify a report function, the process simply runs. ?Typically, when I do supply a report function, it would print something to stdout, or draw an update through a GUI. > > But this approach seems a tad cumbersome and unPythonic to me, particularly the part where I define the function _pass() which accepts an arbitrary argument list, and does nothing but... pass. Seems fine to me (good use of the null object pattern), although I might define _pass() to instead take exactly 1 argument, since that's all you ever call report() with in your example. > This has led me to ask the question, what exactly IS pass? ?I played with the interpreter a bit. > > IDLE 2.6.6 ? ? ?==== No Subprocess ==== >>>> pass >>>> pass() > SyntaxError: invalid syntax >>>> type(pass) > SyntaxError: invalid syntax > > So, pass does not appear to be a function, nor even an object. ?Is it nothing more than a key word? Correct: http://docs.python.org/reference/simple_stmts.html#pass http://docs.python.org/reference/lexical_analysis.html#keywords Cheers, Chris From wuwei23 at gmail.com Thu Nov 17 21:58:46 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 18:58:46 -0800 (PST) Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: On Nov 18, 11:36?am, Roy Smith wrote: > What if the first import of a module is happening inside some code you > don't have access to? No import will happen until you import something. As long as you change sys.path before you do, all subsequent imports will use that path. From rosuav at gmail.com Thu Nov 17 21:59:13 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Nov 2011 13:59:13 +1100 Subject: What exactly is "pass"? What should it be? In-Reply-To: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: On Fri, Nov 18, 2011 at 1:18 PM, John Ladasky wrote: > def _pass(*args): > ? ?pass > > def long_running_process(arg1, arg2, arg_etc, report = _pass): > For some compactness at the expense of brevity, you could use a lambda: def long_running_process(arg1, arg2, arg_etc, report = lambda msg: None): Other than that, I think it's fine. (Actually, the lambda has a slight advantage in self-documentation; in the main function's definition it specifies that the 'report' argument is a function that takes one argument, the message. (Or whatever that argument is. Name it appropriately.) If you call your dummy function something else, it may help readability/self-documentation too. On the other hand, it may not. YMMV. ChrisA From dbinks at codeaurora.org Thu Nov 17 22:01:01 2011 From: dbinks at codeaurora.org (Dominic Binks) Date: Thu, 17 Nov 2011 19:01:01 -0800 Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <4EC5CA6D.3060100@codeaurora.org> On 11/17/2011 6:45 PM, Chris Rebert wrote: > On Thu, Nov 17, 2011 at 6:18 PM, John Ladasky wrote: >> Hi folks, >> >> I'm trying to write tidy, modular code which includes a long-running process. From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. Other times, I'll just want to let it run. So I have a section of code which, generally, looks like this: >> >> def _pass(*args): >> pass >> >> def long_running_process(arg1, arg2, arg_etc, report = _pass): >> result1 = do_stuff() >> report(result1) >> result2 = do_some_different_stuff() >> report(result2) >> result3 = do_even_more_stuff() >> report(result3) >> return result3 >> >> This does what I want. When I do not specify a report function, the process simply runs. Typically, when I do supply a report function, it would print something to stdout, or draw an update through a GUI. >> >> But this approach seems a tad cumbersome and unPythonic to me, particularly the part where I define the function _pass() which accepts an arbitrary argument list, and does nothing but... pass. > > Seems fine to me (good use of the null object pattern), although I > might define _pass() to instead take exactly 1 argument, since that's > all you ever call report() with in your example. > >> This has led me to ask the question, what exactly IS pass? I played with the interpreter a bit. >> >> IDLE 2.6.6 ==== No Subprocess ==== >>>>> pass >>>>> pass() >> SyntaxError: invalid syntax >>>>> type(pass) >> SyntaxError: invalid syntax >> >> So, pass does not appear to be a function, nor even an object. Is it nothing more than a key word? > It is a keyword that can appear in a position where a statement is required by the grammar but there is nothing to do. For example if .. then .. else .. where nothing happens in the else condition is effectively: if : else: pass Bourne shell has a similar construct with the colon statement : Another python example is where you need to catch an exception (or all exceptions but don't actually care about what they are) try: except: pass > Correct: > http://docs.python.org/reference/simple_stmts.html#pass > http://docs.python.org/reference/lexical_analysis.html#keywords > > Cheers, > Chris -- Dominic Binks: dbinks at codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum From wuwei23 at gmail.com Thu Nov 17 22:04:18 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 19:04:18 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: On Nov 18, 2:55?am, "W. eWatson" wrote: > Comments? Are you using the vanilla installer or ActiveState's ActivePython? I find the latter integrates better with Windows. Also, out of curiousity, 32 or 64 bit Windows? From ben+python at benfinney.id.au Thu Nov 17 22:45:35 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 18 Nov 2011 14:45:35 +1100 Subject: What exactly is "pass"? What should it be? References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <87pqgq6qlc.fsf@benfinney.id.au> John Ladasky writes: > So, pass does not appear to be a function, nor even an object. Is it > nothing more than a key word? Yes. Unlike some languages where the program is a collection of expressions, a Python program is a series of statements which themselves may or may not be expressions. -- \ ?I tell you the truth: some standing here will not taste death | `\ before they see the Son of Man coming in his kingdom.? ?Jesus, | _o__) c. 30 CE, as quoted in Matthew 16:28 | Ben Finney From d at davea.name Thu Nov 17 22:59:17 2011 From: d at davea.name (Dave Angel) Date: Thu, 17 Nov 2011 22:59:17 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4EC5D815.3090800@davea.name> On 11/17/2011 03:31 PM, W. eWatson wrote: > On 11/17/2011 9:39 AM, John Gordon wrote: > >> >> Can you add IDLE manually to the associated applications list? >> > Tried that by sending it directly to idle.pyw, but then trying to get > there through the Edit with menu caused a "invalid Win32 app." You've been told repeatedly that building an association to idle.pyw is useless. It must be to something Windows understands, such as .exe, or .bat (or several other extensions, as I said in an earlier message) So why waste our time telling us yet again that it doesn't work? -- DaveA From wolftracks at invalid.com Thu Nov 17 23:21:18 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 20:21:18 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 7:59 PM, Dave Angel wrote: > On 11/17/2011 03:31 PM, W. eWatson wrote: >> On 11/17/2011 9:39 AM, John Gordon wrote: >> >>> >>> Can you add IDLE manually to the associated applications list? >>> >> Tried that by sending it directly to idle.pyw, but then trying to get >> there through the Edit with menu caused a "invalid Win32 app." > > You've been told repeatedly that building an association to idle.pyw is > useless. It must be to something Windows understands, such as .exe, or > .bat (or several other extensions, as I said in an earlier message) So > why waste our time telling us yet again that it doesn't work? > > > Because some people think that's a solution, and ask. It's not. It leads to an error message. From wolftracks at invalid.com Thu Nov 17 23:33:40 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 20:33:40 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/17/2011 4:24 PM, Steven D'Aprano wrote: > On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: > >> I have not found any successful way to get to IDLE. It's on on the >> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >> with a "invalid Win32 app" msg. > > If you associate .pyw files with pythonw.exe, and then open idle.pyw, > does it work? > > Failing that, go to your laptop where the associations are right, and see > what they are, then duplicate the settings on your Windows 7 machine. > Sounds like a good idea except I've not used associations in so long under XP, I have no idea where to start. Control Panel. My Computer Tools? From wolftracks at invalid.com Thu Nov 17 23:34:31 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 17 Nov 2011 20:34:31 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 7:04 PM, alex23 wrote: > On Nov 18, 2:55 am, "W. eWatson" wrote: >> Comments? > > Are you using the vanilla installer or ActiveState's ActivePython? I > find the latter integrates better with Windows. > > Also, out of curiousity, 32 or 64 bit Windows? 64-bit and plain old python msi installer. From snorble at hotmail.com Thu Nov 17 23:49:16 2011 From: snorble at hotmail.com (snorble) Date: Thu, 17 Nov 2011 20:49:16 -0800 (PST) Subject: Monitoring/inventory client-server app References: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> <4ec58b51$0$6842$e4fe514c@news2.news.xs4all.nl> Message-ID: <1ba9dc95-9347-4a5a-a705-774d31166a08@o17g2000yqa.googlegroups.com> On Nov 17, 4:31?pm, Irmen de Jong wrote: > On 17-11-2011 5:17, snorble wrote: > > > > > > > > > > > I'm writing a tool for monitoring the workstations and servers in our > > office. I plan to have a server and a client service that runs on each > > workstation and reports back to the server (heartbeat, disk free > > space, etc). > > > So far I am considering XMLRPC, or a client service that just > > downloads a Python file and runs it. > > > With XMLRPC I don't know how to easily add features without having to > > update every client. Also while playing with XMLRPC I learned that > > when you run a registered function, it runs it on the server. I was > > hoping it would run on the client, so that when I get the machine's > > computer name (or disk space, etc) it will return the client's info. > > It seems with XMLRPC I would have to hard code the functionality into > > the client (i.e. client gets it's computer name, then calls the XMLRPC > > function to pass it to the server)? I was hoping it would work more > > like, "pass some code to the client to be run on the client, and > > report it to the server". Almost XMLRPC in the reverse direction. > > > With the download-and-run approach, it seems trivially easy to add new > > functionality to the clients. Just save the updated Python file to the > > server, and clients download it and run it. > > > Are there any standard approaches to problems like this that can be > > recommended? Thank you. > > The security implications are HUGE when you are thinking about > transferring and executing arbitrary code over the network. Avoid this > if at all possible. But if you can be 100% sure it's only trusted stuff, > things are not so grim. > > Have a look at Pyro, or even Pyro Flame: > > http://packages.python.org/Pyro4/http://packages.python.org/Pyro4/flame.html > > Flame allows for very easy remote module execution and a limited way of > transferring code to the 'other side'. > > Also what is wrong with running an XMLrpc server, or Pyro daemon, on > your client machines? This way your central computer can call registered > methods (or remote objects in case of Pyro) on the client and execute > code there (that reports all sorts of stuff you want to know). Or have > each client call into a central server, where it reports that stuff > itself. Many ways to skin a cat. > > Regards, > Irmen de Jong I'm thinking maybe the client service will have a small number of generic features, such as reading WMI and SNMP values. That way the server still dictates the work to be done (i.e. XMLRPC returns which WMI/SNMP values to query), and the client remains relatively focused and straightforward. From alec.taylor6 at gmail.com Thu Nov 17 23:53:07 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Fri, 18 Nov 2011 15:53:07 +1100 Subject: Monitoring/inventory client-server app In-Reply-To: <1ba9dc95-9347-4a5a-a705-774d31166a08@o17g2000yqa.googlegroups.com> References: <557bfa42-0ba1-45b6-9eee-5bf23a278baf@h5g2000yqk.googlegroups.com> <4ec58b51$0$6842$e4fe514c@news2.news.xs4all.nl> <1ba9dc95-9347-4a5a-a705-774d31166a08@o17g2000yqa.googlegroups.com> Message-ID: Maybe take a look outside python: - Puppet On Fri, Nov 18, 2011 at 3:49 PM, snorble wrote: > On Nov 17, 4:31?pm, Irmen de Jong wrote: >> On 17-11-2011 5:17, snorble wrote: >> >> >> >> >> >> >> >> >> >> > I'm writing a tool for monitoring the workstations and servers in our >> > office. I plan to have a server and a client service that runs on each >> > workstation and reports back to the server (heartbeat, disk free >> > space, etc). >> >> > So far I am considering XMLRPC, or a client service that just >> > downloads a Python file and runs it. >> >> > With XMLRPC I don't know how to easily add features without having to >> > update every client. Also while playing with XMLRPC I learned that >> > when you run a registered function, it runs it on the server. I was >> > hoping it would run on the client, so that when I get the machine's >> > computer name (or disk space, etc) it will return the client's info. >> > It seems with XMLRPC I would have to hard code the functionality into >> > the client (i.e. client gets it's computer name, then calls the XMLRPC >> > function to pass it to the server)? I was hoping it would work more >> > like, "pass some code to the client to be run on the client, and >> > report it to the server". Almost XMLRPC in the reverse direction. >> >> > With the download-and-run approach, it seems trivially easy to add new >> > functionality to the clients. Just save the updated Python file to the >> > server, and clients download it and run it. >> >> > Are there any standard approaches to problems like this that can be >> > recommended? Thank you. >> >> The security implications are HUGE when you are thinking about >> transferring and executing arbitrary code over the network. Avoid this >> if at all possible. But if you can be 100% sure it's only trusted stuff, >> things are not so grim. >> >> Have a look at Pyro, or even Pyro Flame: >> >> http://packages.python.org/Pyro4/http://packages.python.org/Pyro4/flame.html >> >> Flame allows for very easy remote module execution and a limited way of >> transferring code to the 'other side'. >> >> Also what is wrong with running an XMLrpc server, or Pyro daemon, on >> your client machines? This way your central computer can call registered >> methods (or remote objects in case of Pyro) on the client and execute >> code there (that reports all sorts of stuff you want to know). Or have >> each client call into a central server, where it reports that stuff >> itself. Many ways to skin a cat. >> >> Regards, >> Irmen de Jong > > I'm thinking maybe the client service will have a small number of > generic features, such as reading WMI and SNMP values. That way the > server still dictates the work to be done (i.e. XMLRPC returns which > WMI/SNMP values to query), and the client remains relatively focused > and straightforward. > -- > http://mail.python.org/mailman/listinfo/python-list > From ladasky at my-deja.com Fri Nov 18 00:03:23 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 21:03:23 -0800 (PST) Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <19287522.9.1321592603810.JavaMail.geo-discussion-forums@prfb5> On Thursday, November 17, 2011 6:45:58 PM UTC-8, Chris Rebert wrote: > Seems fine to me (good use of the null object pattern), although I > might define _pass() to instead take exactly 1 argument, since that's > all you ever call report() with in your example. Oops, I over-simplified the calls to my report() function. The truth is that report() can accept a variable argument list too. From ladasky at my-deja.com Fri Nov 18 00:03:23 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 21:03:23 -0800 (PST) Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <19287522.9.1321592603810.JavaMail.geo-discussion-forums@prfb5> On Thursday, November 17, 2011 6:45:58 PM UTC-8, Chris Rebert wrote: > Seems fine to me (good use of the null object pattern), although I > might define _pass() to instead take exactly 1 argument, since that's > all you ever call report() with in your example. Oops, I over-simplified the calls to my report() function. The truth is that report() can accept a variable argument list too. From ladasky at my-deja.com Fri Nov 18 00:07:23 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 21:07:23 -0800 (PST) Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> On Thursday, November 17, 2011 8:34:22 PM UTC-8, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky > declaimed the following in > gmane.comp.python.general: > > def _pass(*args): > > pass > > > This is the equivalent of > > def _pass(*args): > return None > > (functions with no explicit return statement implicitly return None) OK, that works for me, and now I understand. One of my questions was: would there be any merit to having the Python "pass" token itself defined exactly as _pass() is defined above? From ladasky at my-deja.com Fri Nov 18 00:07:23 2011 From: ladasky at my-deja.com (John Ladasky) Date: Thu, 17 Nov 2011 21:07:23 -0800 (PST) Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> On Thursday, November 17, 2011 8:34:22 PM UTC-8, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky > declaimed the following in > gmane.comp.python.general: > > def _pass(*args): > > pass > > > This is the equivalent of > > def _pass(*args): > return None > > (functions with no explicit return statement implicitly return None) OK, that works for me, and now I understand. One of my questions was: would there be any merit to having the Python "pass" token itself defined exactly as _pass() is defined above? From benjamin.kaplan at case.edu Fri Nov 18 00:25:29 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Fri, 18 Nov 2011 00:25:29 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 11:21 PM, W. eWatson wrote: > > On 11/17/2011 7:59 PM, Dave Angel wrote: >> >> On 11/17/2011 03:31 PM, W. eWatson wrote: >>> >>> On 11/17/2011 9:39 AM, John Gordon wrote: >>> >>>> >>>> Can you add IDLE manually to the associated applications list? >>>> >>> Tried that by sending it directly to idle.pyw, but then trying to get >>> there through the Edit with menu caused a "invalid Win32 app." >> >> You've been told repeatedly that building an association to idle.pyw is >> useless. It must be to something Windows understands, such as .exe, or >> .bat (or several other extensions, as I said in an earlier message) So >> why waste our time telling us yet again that it doesn't work? >> >> >> > Because some ?people think that's a solution, and ask. It's not. It leads to an error message. Checking my Python install, there should be an idle.bat file in there too. Have you tried that? From rosuav at gmail.com Fri Nov 18 00:34:10 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Nov 2011 16:34:10 +1100 Subject: What exactly is "pass"? What should it be? In-Reply-To: <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> Message-ID: On Fri, Nov 18, 2011 at 4:07 PM, John Ladasky wrote: > One of my questions was: would there be any merit to having the Python "pass" token itself defined exactly as _pass() is defined above? No, there wouldn't. The Python 'pass' statement is a special statement that indicates a lack of anything to execute; a dummy function call isn't this. What I would kinda like to see, though, is function versions of many things. Your basic operators exist in the 'operator' module, but the syntax is rather clunky; for comparison, Pike has beautifully simple (if a little cryptic) syntax: back-tick followed by the operator itself, very similar to the way C++ does operator overloading. In Python 2, back-tick has a special meaning. In Python 3, that meaning is removed. Is the character now available for this "function-version" syntax? ChrisA From clp2 at rebertia.com Fri Nov 18 00:49:47 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 17 Nov 2011 21:49:47 -0800 Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> Message-ID: On Thu, Nov 17, 2011 at 9:34 PM, Chris Angelico wrote: > On Fri, Nov 18, 2011 at 4:07 PM, John Ladasky wrote: >> One of my questions was: would there be any merit to having the Python "pass" token itself defined exactly as _pass() is defined above? > > No, there wouldn't. The Python 'pass' statement is a special statement > that indicates a lack of anything to execute; a dummy function call > isn't this. What I would kinda like to see, though, is function > versions of many things. Your basic operators exist in the 'operator' > module, but the syntax is rather clunky; for comparison, Pike has > beautifully simple (if a little cryptic) syntax: back-tick followed by > the operator itself, very similar to the way C++ does operator > overloading. > > In Python 2, back-tick has a special meaning. In Python 3, that > meaning is removed. Is the character now available for this > "function-version" syntax? Negative. I know this from personal experience. Things that will Not Change in Python 3000 (http://www.python.org/dev/peps/pep-3099/ ): "No more backticks." Cheers, Chris R. From paul.nospam at rudin.co.uk Fri Nov 18 00:54:15 2011 From: paul.nospam at rudin.co.uk (Paul Rudin) Date: Fri, 18 Nov 2011 05:54:15 +0000 Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: <87wraydlh4.fsf@no-fixed-abode.cable.virginmedia.net> Roy Smith writes: > In article <874ny2fzn6.fsf at no-fixed-abode.cable.virginmedia.net>, > Paul Rudin wrote: > >> >> Maybe I'm missing something - but if I want to do this I just mess about >> with sys.path at the top of my python script/program. Always seems to >> work... is there a situation in which it doesn't? > > What if the first import of a module is happening inside some code you > don't have access to? If you change sys.path first - before you do any imports - then any other imports will surely come from the first thing on sys.path (unless something else you import also changes sys.path)? From wuwei23 at gmail.com Fri Nov 18 01:04:12 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 22:04:12 -0800 (PST) Subject: What exactly is "pass"? What should it be? References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: On Nov 18, 12:59?pm, Chris Angelico wrote: > If you call your dummy function something else, it may help > readability/self-documentation too. Or replace the pass with a docstring for the same effect: def silent(*args): """Null Object to repress reporting""" From wuwei23 at gmail.com Fri Nov 18 01:06:51 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Nov 2011 22:06:51 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: On Nov 18, 2:21?pm, "W. eWatson" wrote: > Because some ?people think that's a solution, and ask. It's not. It > leads to an error message. No, people are saying "manually add IDLE _the correct way that Windows can recognise_", not recommending you stuff random .pyw files into the context menu and hope they work. From steve+comp.lang.python at pearwood.info Fri Nov 18 01:07:21 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Nov 2011 06:07:21 GMT Subject: What exactly is "pass"? What should it be? References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> <3758934.65.1321592843731.JavaMail.geo-discussion-forums@prms22> Message-ID: <4ec5f619$0$29967$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Nov 2011 21:07:23 -0800, John Ladasky wrote: > One of my questions was: would there be any merit to having the Python > "pass" token itself defined exactly as _pass() is defined above? No. The pass statement compiles to nothing at all. Your _pass() function compiles to a function object, which needs to be looked up at run time, then called, all of which takes time and memory. To satisfy the compiler, but do nothing, the pass statement should stay a statement. When you need a "do nothing" function, either define one (two lines) in your application, or use a lambda in place (lambda *args: None). Either way, it is too trivial to be a built-in. By the way, to answer your earlier question "what is pass?", you could do this in the interactive interpreter: help("pass") -- Steven From namenobodywants at gmail.com Fri Nov 18 02:27:47 2011 From: namenobodywants at gmail.com (Sean McIlroy) Date: Thu, 17 Nov 2011 23:27:47 -0800 (PST) Subject: useless python - term rewriter Message-ID: <429ffce6-8912-4851-bb4f-bb894241038f@v31g2000prg.googlegroups.com> ## term rewriter (python 3.1.1) def gettokens(string): spaced = string.replace('(',' ( ').replace(')',' ) ') return spaced.split() def getterm(tokens): if tokens[0] in '()': term = [] assert tokens[0] == '(' tokens.pop(0) while not tokens[0] == ')': term.append(getterm(tokens)) tokens.pop(0) return term return tokens.pop(0) def parse(strg): tokens = gettokens(strg) term = getterm(tokens) assert not tokens return term def unparse(term): if type(term) == str: return term subterms = [unparse(subterm) for subterm in term] return '({})'.format(' '.join(subterms)) def atom(term): return type(term) == str def compound(term): return type(term) == list def variable(term): return atom(term) and term[0].isupper() def constant(term): return atom(term) and not term[0].isupper() def conformable(term1,term2): return compound(term1) and compound(term2) and len(term1) == len(term2) def getrule(string): left, right = string.split('=') return [parse(left), parse(right)] def getrules(string): nonblank = lambda substring: substring and not substring.isspace() return [getrule(substring) for substring in string.splitlines() if nonblank(substring)] def substitute(bindings,term): if constant(term): return term if variable(term): return bindings.get(term,term) return [substitute(bindings,subterm) for subterm in term] def match(term,pattern): from operator import concat from functools import reduce if variable(pattern): return [[pattern, term]] if constant(pattern) and pattern == term: return [] if conformable(pattern,term): matches = [match(subterm,subpattern) for subterm, subpattern in zip(term,pattern)] return reduce(concat,matches) raise Exception def rewrite(term,rule): if type(rule) == dict: function = rule[term[0]] arguments = [int(subterm) for subterm in term[1:]] return str(function(*arguments)) left, right = rule bindings = dict(match(term,left)) return substitute(bindings,right) def apply(rule,term): try: return [rewrite(term,rule), True] except: if atom(term): return [term, False] applications = [apply(rule,subterm) for subterm in term] subterms = [subterm for subterm, change in applications] changes = [change for subterm, change in applications] return [subterms, any(changes)] def normalize(term,rules): while True: changes = [] for rule in rules: term, change = apply(rule,term) changes.append(change) if not any(changes): break return term def translate(rules): string = input('>>> ') if string and not string.isspace(): try: term = parse(string) normal = normalize(term,rules) string = unparse(normal) print(string) except: print('parse error') def interpret(equations): import operator rules = [vars(operator)] + getrules(equations) while True: try: translate(rules) except KeyboardInterrupt: print('end session') break example = """ (factorial 0) = 1 (factorial N) = (mul N (factorial (sub N 1))) (fibonacci 0) = 0 (fibonacci 1) = 1 (fibonacci N) = (add (fibonacci (sub N 1)) (fibonacci (sub N 2))) """ interpret(example) From tjreedy at udel.edu Fri Nov 18 02:35:51 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 18 Nov 2011 02:35:51 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 7:03 PM, W. eWatson wrote: > I have not found any successful way to get to IDLE. Use the start menu to start IDLE once. Then pin it to your taskbar. If you do not have STart/ all programs / Python / IDLE, then your installation is bad. As for the right click problem, you probably have something screwy in the registry. The python installer (or uninstaller) will not fix it (my experience on my old xp machine). You will have to do so manually. -- Terry Jan Reedy From abecedarian314159 at yahoo.com Fri Nov 18 02:38:06 2011 From: abecedarian314159 at yahoo.com (William) Date: Thu, 17 Nov 2011 23:38:06 -0800 (PST) Subject: python chat Message-ID: <1321601886.45737.YahooMailNeo@web161806.mail.bf1.yahoo.com> Hi, I've started a new site called StudyBrunch, where we offer a chance for online studygroups with video conferencing, screen sharing etc. ? I'd like to keep the groups small to be maneageble. ? I will offer a basic session on python for people who are interested, on Saturday or Sunday evening. ? If you are interested, you can look at: http://www.studybrunch.com/studysession/intro-to-python/ For this month, general membership is free and I hope to move on to more advanced topics later. ? If you have questions, or suggestion for topics (for example, classes, wxpython, urllib2, etc.), then contact us through?http://www.studybrunch.com/contact/ so we don't spam the list. I have listed some preliminary times on the site in EST, but let me know on the site if you can't make those and I can try to schedule another session later in the week. ?? Best, William -------------- next part -------------- An HTML attachment was scrubbed... URL: From peksikytola at gmail.com Fri Nov 18 02:51:12 2011 From: peksikytola at gmail.com (=?ISO-8859-1?B?UGVra2EgS3l09mzk?=) Date: Thu, 17 Nov 2011 23:51:12 -0800 (PST) Subject: Passing DLL handle as an argument (in Windows) Message-ID: Is it possible to pass my own dll's (already loaded) handle as an argument to load/attach to the very same instance of dll? Thing is that I've done plugin (dll) to a host app and the SDK's function pointers are assigned once the dll is loaded in the host process. I'd like to fire up python code with ShellExecuteEx from my plugin dll and expose (wrap) these SDK funcs to that script. If I just load the dll in python it will be different instance and the SDK function pointers are all NULL. I tried passing the dll handle as lpParameter but in vain. Is this ShellExecute + dll handle passing even possible or do I need to take a totally different route? What route that would be? Doesn't have to be portable, just so it works in Windows environment. From ulrich.eckhardt at dominolaser.com Fri Nov 18 03:27:39 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 18 Nov 2011 09:27:39 +0100 Subject: Passing DLL handle as an argument (in Windows) In-Reply-To: References: Message-ID: Am 18.11.2011 08:51, schrieb Pekka Kyt?l?: > Is it possible to pass my own dll's (already loaded) handle as an > argument to load/attach to the very same instance of dll? Thing is > that I've done plugin (dll) to a host app and the SDK's function > pointers are assigned once the dll is loaded in the host process. DLL handles are valid anywhere in a process, but... > I'd like to fire up python code with ShellExecuteEx from my plugin > dll and expose (wrap) these SDK funcs to that script. If I just load > the dll in python it will be different instance and the SDK function > pointers are all NULL. I tried passing the dll handle as lpParameter > but in vain. ...ShellExecuteEx will create a new process, where the DLL handle is not valid. A new process has a separate memory space, so the function pointers are different etc. This is so by design, it shouldn't matter to one process when a DLL it uses is loaded into another process, too. > Is this ShellExecute + dll handle passing even possible or do I need > to take a totally different route? What route that would be? Doesn't > have to be portable, just so it works in Windows environment. If all you want is to run Python code inside your application, you can link in a Python interpreter and run it from there. This is called embedding Python (docs.python.org/extending/embedding.html), as opposed to writing Python modules, don't confuse those two Python C APIs. Another way to get both into the same process is to convert your host application into a Python module, which you then import into Python. This would use the other Python C API (docs.python.org/extending/extending.html). It depends a bit on what you want to achieve, so you might want to elaborate on that. This is often better than asking for a way to achieve a solution that is impossible. Good luck! Uli From peksikytola at gmail.com Fri Nov 18 04:31:42 2011 From: peksikytola at gmail.com (=?ISO-8859-1?B?UGVra2EgS3l09mzk?=) Date: Fri, 18 Nov 2011 01:31:42 -0800 (PST) Subject: Passing DLL handle as an argument (in Windows) References: Message-ID: <59ccd4dd-3e39-44f5-8234-4afc64c32701@p16g2000yqd.googlegroups.com> On Nov 18, 10:27?am, Ulrich Eckhardt wrote: > Am 18.11.2011 08:51, schrieb Pekka Kyt?l?: > > > Is it possible to pass my own dll's (already loaded) handle as an > > argument to load/attach to the very same instance of dll? Thing is > > that I've done plugin (dll) to a host app and the SDK's function > > pointers are assigned once the dll is loaded in the host process. > > DLL handles are valid anywhere in a process, but... > > > I'd like to fire up python code with ShellExecuteEx from my plugin > > dll and expose (wrap) these SDK funcs to that script. If I just load > > the dll in python it will be different instance and the SDK function > > pointers are all NULL. I tried passing the dll handle as lpParameter > > but in vain. > > ...ShellExecuteEx will create a new process, where the DLL handle is not > valid. A new process has a separate memory space, so the function > pointers are different etc. This is so by design, it shouldn't matter to > one process when a DLL it uses is loaded into another process, too. > > > Is this ShellExecute + dll handle passing even possible or do I need > > to take a totally different route? What route that would be? Doesn't > > have to be portable, just so it works in Windows environment. > > If all you want is to run Python code inside your application, you can > link in a Python interpreter and run it from there. This is called > embedding Python (docs.python.org/extending/embedding.html), as opposed > to writing Python modules, don't confuse those two Python C APIs. > > Another way to get both into the same process is to convert your host > application into a Python module, which you then import into Python. > This would use the other Python C API > (docs.python.org/extending/extending.html). > > It depends a bit on what you want to achieve, so you might want to > elaborate on that. This is often better than asking for a way to achieve > a solution that is impossible. > > Good luck! > > Uli Thanks for reply, I'll try to elaborate a bit :) I should have included this bit from: http://docs.python.org/library/ctypes.html#loading-shared-libraries "All these classes can be instantiated by calling them with at least one argument, the pathname of the shared library. If you have an existing handle to an already loaded shared library, it can be passed as the handle named parameter, otherwise the underlying platforms dlopen or LoadLibrary function is used to load the library into the process, and to get a handle to it." So, I've got this handle to my .dll and would want to get that passed as an argument when firing up .py via ShellExecute and use one of the dll load functions that take in handle. What I don't know if these windows/python dll handles are interchangable at all. Think it would be quite nice if they were. But if they aren't I need to forget about it and just #include From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Fri Nov 18 04:57:42 2011 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Fri, 18 Nov 2011 10:57:42 +0100 Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: Am 18.11.2011 05:34 schrieb Dennis Lee Bieber: >> def _pass(*args): >> pass >> >> def long_running_process(arg1, arg2, arg_etc, report = _pass): >> result1 = do_stuff() >> report(result1) > > So this is a call to a function that just returns a None, which is > dropped by the interpreter... I'm not sure about this. I think, the call will be executed, but the callee will return immediately. It is different from call being dropped. Another optimized alternative could be to do def long_running_process(arg1, arg2, arg_etc, report=None): result1 = do_stuff() if report: report(result1) but I think that is too low benefit at the cost of too much readability. Such a function call is 2 0 LOAD_FAST 0 (a) 3 POP_JUMP_IF_FALSE 16 6 LOAD_FAST 0 (a) 9 CALL_FUNCTION 0 12 POP_TOP 13 JUMP_FORWARD 0 (to 16) 3 >> 16 ... as opposed to just 2 0 LOAD_FAST 0 (a) 3 CALL_FUNCTION 0 6 POP_TOP with a call target of 1 0 LOAD_CONST 0 (None) 3 RETURN_VALUE I don't think that a call is sooo expensive that it would make any noticeable difference. Thomas BTW: Sorry, Dennis, for the private mail - I am incapable to use Thunderbird correctly :-( From hujunfeng at gmail.com Fri Nov 18 05:23:29 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 02:23:29 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing Message-ID: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Hi All, I'm trying to leverage my core i5 to send more UDP packets with multiprocssing, but I found a interesting thing is that the socket.bind is always reporting 10048 error even the process didn't do anything about the socket. Here is the script import threading,socket,random,pp,os import time from multiprocessing import Process import multiprocessing.reduction localIP='10.80.2.24' localPort=2924 remoteIP='10.80.5.143' remotePort=2924 sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) #sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((localIP,localPort)) sock.connect((remoteIP,remotePort)) addRequest="MEGACO/1 ["+localIP+"]:"+str(localPort)+"\r\nTRANSACTION = 100 {\r\n" \ "\tCONTEXT = $ {\r\n" \ "\t\tADD = TDMs15c1f1/11{ \r\n" \ " Media { LocalControl { Mode=SendReceive,tdmc/ec=on }} " \ "\t}\r\n}}\r\n" def sendAddRequest(sock,addRequst): #for i in range(2500): #sock.send(addRequest) print "hello" if __name__ == '__main__': reader = Process(target=sendAddRequest,args=(sock,addRequest)) reader.start() Here is the output D:\Python test>mythread2.py Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\multiprocessing\forking.py", line 346, in main prepare(preparation_data) File "C:\Python27\lib\multiprocessing\forking.py", line 461, in prepare '__parents_main__', file, path_name, etc File "D:\Python test\mythread2.py", line 12, in sock.bind((localIP,localPort)) File "C:\Python27\lib\socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 10048] Only one usage of each socket address (protocol/netw ork address/port) is normally permitted From hansmu at xs4all.nl Fri Nov 18 05:52:54 2011 From: hansmu at xs4all.nl (Hans Mulder) Date: Fri, 18 Nov 2011 11:52:54 +0100 Subject: How to insert my own module in front of site eggs? In-Reply-To: References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: <4ec63907$0$6850$e4fe514c@news2.news.xs4all.nl> On 18/11/11 03:58:46, alex23 wrote: > On Nov 18, 11:36 am, Roy Smith wrote: >> What if the first import of a module is happening inside some code you >> don't have access to? > No import will happen until you import something. That would be the case if you use the '-S' command line option. Otherwise, site.py is imported before you get a chance to alter sys.path, and by default site.py imports other modules. -- HansM From michels at mps.mpg.de Fri Nov 18 05:56:36 2011 From: michels at mps.mpg.de (Helmut Michels) Date: Fri, 18 Nov 2011 11:56:36 +0100 Subject: [ANN] Data Plotting Library Dislin 10.2 Message-ID: Dear Python programmers, I am pleased to announce version 10.2 of the data plotting software Dislin. Dislin is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, OpenGL, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG, BMP and SVG. The software is available for the most C, Fortran 77 and Fortran 90/95 compilers. Plotting extensions for the interpreting languages Perl, Python and Java are also supported. Dislin is available from the site http://www.dislin.de and via FTP from the server ftp://ftp.gwdg.de/pub/grafik/dislin All Dislin distributions are free for non-commercial use. Licenses for commercial use are available from http://www.dislin.de. ------------------- Helmut Michels Max Planck Institute for Solar System Research Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : michels at mps.mpg.de From peksikytola at gmail.com Fri Nov 18 06:49:14 2011 From: peksikytola at gmail.com (=?ISO-8859-1?B?UGVra2EgS3l09mzk?=) Date: Fri, 18 Nov 2011 03:49:14 -0800 (PST) Subject: Passing DLL handle as an argument (in Windows) References: <59ccd4dd-3e39-44f5-8234-4afc64c32701@p16g2000yqd.googlegroups.com> Message-ID: <6bc18373-3213-4153-ad87-ba998ca2e597@p16g2000yqd.googlegroups.com> Hmm. Let me describe what is going a bit more carefully: What I build is a dll file that has exported function that gets called when the host application/dll loads my dll. In this function the function pointers to the actual SDK functions are fetched. After this my dll's registers some plugins that have callbacks. After that it's all about reacting to an event/callback. What I'd like to do is that after fetching those SDK function pointers I'd like to fire up .py/.pyc that snoops for possible plugins written in python and registers those plugins and callbacks and let them react to events. Obviously this python code needs access to those SDK functions. Essentially it would show for the host app as one .dll but registers multiple plugins from different python files. I don't mind if it's not ShellExecute route, but I'd prefer approaching this so that I don't need to compile different dll's to different versions of python but let the python code take care of that stuff. From python at mrabarnett.plus.com Fri Nov 18 08:03:28 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 18 Nov 2011 13:03:28 +0000 Subject: What exactly is "pass"? What should it be? In-Reply-To: References: <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> Message-ID: <4EC657A0.7000103@mrabarnett.plus.com> On 18/11/2011 04:34, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky > declaimed the following in > gmane.comp.python.general: > >> I'm trying to write tidy, modular code which includes a long-running process. From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. Other times, I'll just want to let it run. So I have a section of code which, generally, looks like this: >> >> def _pass(*args): >> pass >> > This is the equivalent of > > def _pass(*args): > return None > Wouldn't "pass_" be a more Pythonic name? > (functions with no explicit return statement implicitly return None) > >> def long_running_process(arg1, arg2, arg_etc, report = _pass): >> result1 = do_stuff() >> report(result1) > > So this is a call to a function that just returns a None, which is > dropped by the interpreter... > From neilc at norwich.edu Fri Nov 18 08:11:05 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 18 Nov 2011 13:11:05 GMT Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9in3r9F5j3U2@mid.individual.net> On 2011-11-18, W. eWatson wrote: > On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >> >>> I have not found any successful way to get to IDLE. It's on on the >>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>> with a "invalid Win32 app" msg. >> >> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >> does it work? >> >> Failing that, go to your laptop where the associations are right, and see >> what they are, then duplicate the settings on your Windows 7 machine. > > Sounds like a good idea except I've not used associations in so > long under XP, I have no idea where to start. Control Panel. My > Computer Tools? Open Windows Explorer. With the menu, to to Tools->Folder Options Click the File Types tab in the Folder Options menu. There will be an upper view with registered filed types, and some buttons below far making changes to them. -- Neil Cerutti From ulrich.eckhardt at dominolaser.com Fri Nov 18 09:14:56 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 18 Nov 2011 15:14:56 +0100 Subject: Passing DLL handle as an argument (in Windows) In-Reply-To: <6bc18373-3213-4153-ad87-ba998ca2e597@p16g2000yqd.googlegroups.com> References: <59ccd4dd-3e39-44f5-8234-4afc64c32701@p16g2000yqd.googlegroups.com> <6bc18373-3213-4153-ad87-ba998ca2e597@p16g2000yqd.googlegroups.com> Message-ID: <0s5ip8-oq1.ln1@satorlaser.homedns.org> Am 18.11.2011 12:49, schrieb Pekka Kyt?l?: > What I'd like to do is that after fetching those SDK function > pointers I'd like to fire up .py/.pyc that snoops for possible > plugins written in python and registers those plugins and callbacks > and let them react to events. Obviously this python code needs access > to those SDK functions. Essentially it would show for the host app as > one .dll but registers multiple plugins from different python files. Okay, so you want to export functions from your host application (it doesn't matter if that is inside a DLL or not) to a bunch of Python plugins. This is actually the embedding that I hinted at and documented, but here's some example code (stripped of any error handling and reference counting, so beware!): // append line to debug log static PyObject* log_string(PyObject *self, PyObject *args) { char const* arg = 0; if(!PyArg_ParseTuple(args, "s", &arg)) return NULL; fprintf(debug_output, "%s", arg); Py_RETURN_NONE; } // exported API static PyMethodDef host_api[] = { {"log_string", log_string, METH_VARARGS, "log_string(string) -> None\n" "Write text to debug output."}, {NULL, NULL, 0, NULL} }; Py_Initialize(); PyObject* host_api_module = Py_InitModule("host", host_api); PyObject* test_module = PyImport_ImportModule("./test.py"); PyObject* main_function = PyObject_GetAttrString(test_module, "main"); PyObject* res = PyObject_CallObject(main_function, NULL); Py_Finalize(); This has the disadvantage that it blocks, for multiple Python threads, you need to program a dispatcher. Also, you can only have a single interpreter loaded, so other parts of your program may not call Py_Initialize(). It does the job for my uses, so I hope it helps! Uli From zyzhu2000 at gmail.com Fri Nov 18 09:51:12 2011 From: zyzhu2000 at gmail.com (GZ) Date: Fri, 18 Nov 2011 06:51:12 -0800 (PST) Subject: Dynamically Generate Methods Message-ID: Hi, I have a class Record and a list key_attrs that specifies the names of all attributes that correspond to a primary key. I can write a function like this to get the primary key: def get_key(instance_of_record): return tuple(instance_of_record.__dict__[k] for k in key_attrs) However, since key_attrs are determined at the beginning of the program while get_key() will be called over and over again, I am wondering if there is a way to dynamically generate a get_ley method with the key attributes expanded to avoid the list comprehension/ generator. For example, if key_attrs=['A','B'], I want the generated function to be equivalent to the following: def get_key(instance_of_record): return (instance_of_record['A'],instance_of_record['B'] ) I realize I can use eval or exec to do this. But is there any other way to do this? Thanks, gz From hujunfeng at gmail.com Fri Nov 18 10:20:20 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:20:20 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <15167697.1495.1321629620458.JavaMail.geo-discussion-forums@yqoo7> I did a test on linux, it works well, so the issue is related to os. From wolftracks at invalid.com Fri Nov 18 10:29:56 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 07:29:56 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: <9in3r9F5j3U2@mid.individual.net> References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> Message-ID: On 11/18/2011 5:11 AM, Neil Cerutti wrote: > On 2011-11-18, W. eWatson wrote: >> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >>> >>>> I have not found any successful way to get to IDLE. It's on on the >>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>>> with a "invalid Win32 app" msg. >>> >>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >>> does it work? >>> >>> Failing that, go to your laptop where the associations are right, and see >>> what they are, then duplicate the settings on your Windows 7 machine. >> >> Sounds like a good idea except I've not used associations in so >> long under XP, I have no idea where to start. Control Panel. My >> Computer Tools? > > Open Windows Explorer. > With the menu, to to Tools->Folder Options > Click the File Types tab in the Folder Options menu. > > There will be an upper view with registered filed types, and some > buttons below far making changes to them. > OK, I've found that. I see Py Pyc Pyo Pyw If I click on each, it basically it gives a short description of each. If I click advanced, there's more info. For example for py, Actions are IDLE and Open. What does this tell me that's relevant to Win7? If on Win7, I go to Default Programs I see under associations various python items. Py shows Unknown application. Since installing 2.7.2 I have not messed with these associations. If I right-click on Unknown, I see Notepad and python.exe for choices to open the file. I want neither. Why isn't IDLE listed there? If I right-click on junk.py, I see "Open with". Notepad and python.exe are choices. However, that menu allows me to choose something else. For example, Adobe Reader, or Internet Explorer. I suppose the next question is should I use the browse there and try to connect to IDLE in ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid Win32 app", when I try to use it. From rosuav at gmail.com Fri Nov 18 10:33:11 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Nov 2011 02:33:11 +1100 Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Message-ID: On Fri, Nov 18, 2011 at 9:23 PM, Junfeng Hu wrote: > Hi All, I'm trying to leverage my core i5 to send more UDP packets with multiprocssing, but I found a interesting thing is that the socket.bind is always reporting 10048 error even the process didn't do anything about the socket. > sock.bind((localIP,localPort)) > socket.error: [Errno 10048] Only one usage of each socket address (protocol/netw > ork address/port) is normally permitted Try setting the socket to SO_REUSEADDR. ChrisA From hujunfeng at gmail.com Fri Nov 18 10:48:36 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:48:36 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Thanks Yes, I had tried this before, so you could find that I comment the line sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) Here is the results. D:\Python test>mythread2.py Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main self = load(from_parent) File "C:\Python27\lib\pickle.py", line 1378, in load return Unpickler(file).load() File "C:\Python27\lib\pickle.py", line 858, in load dispatch[key](self) File "C:\Python27\lib\pickle.py", line 1133, in load_reduce value = func(*args) File "C:\Python27\lib\multiprocessing\reduction.py", line 167, in rebuild_sock et _sock = fromfd(fd, family, type_, proto) File "C:\Python27\lib\multiprocessing\reduction.py", line 156, in fromfd s = socket.fromfd(fd, family, type_, proto) AttributeError: 'module' object has no attribute 'fromfd' From hujunfeng at gmail.com Fri Nov 18 10:48:36 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:48:36 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Thanks Yes, I had tried this before, so you could find that I comment the line sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) Here is the results. D:\Python test>mythread2.py Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main self = load(from_parent) File "C:\Python27\lib\pickle.py", line 1378, in load return Unpickler(file).load() File "C:\Python27\lib\pickle.py", line 858, in load dispatch[key](self) File "C:\Python27\lib\pickle.py", line 1133, in load_reduce value = func(*args) File "C:\Python27\lib\multiprocessing\reduction.py", line 167, in rebuild_sock et _sock = fromfd(fd, family, type_, proto) File "C:\Python27\lib\multiprocessing\reduction.py", line 156, in fromfd s = socket.fromfd(fd, family, type_, proto) AttributeError: 'module' object has no attribute 'fromfd' From hujunfeng at gmail.com Fri Nov 18 10:51:49 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:51:49 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> And actually ,the socket hadn't been used in this script. From hujunfeng at gmail.com Fri Nov 18 10:51:49 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 07:51:49 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> And actually ,the socket hadn't been used in this script. From wolftracks at invalid.com Fri Nov 18 10:54:56 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 07:54:56 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 8:34 PM, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 08:55:36 -0800, "W. eWatson" > declaimed the following in > gmane.comp.python.general: > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. >> >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. >> > Fine... so open a directory window, follow > > Tools/Folder Options/File Types > > Scroll down to PYW, click [Advanced] > > You should get an "Edit File Type" dialog. Mine shows just one > action "open", yours probably has "open" and "edit". Select "edit" and > then click [Edit] button. See what it says for the application to be > used. > > Do the same on the Win7 machine -- it probably doesn't have "edit" > as an action, so you'll be picking the [New] button. Define the new > action to look like the action on the laptop (use the correct path to > the python executable, and maybe to IDLE). > > Heck, check what those actions show for PY files too... The only > difference between PY and PYW should be the application used in the > "open" action. > PY => .../python.exe > PYW => .../pythonw.exe > > Also make sure that the "open" action is the defined default (select > the action, and click the default button); when there are more than one > action, the default will be in bold. > > > > > > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. >> >> Comments? See my response to Neil Cerutii a few msgs above this one. From wolftracks at invalid.com Fri Nov 18 10:57:02 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 07:57:02 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 8:34 PM, Dennis Lee Bieber wrote: > On Thu, 17 Nov 2011 08:55:36 -0800, "W. eWatson" > declaimed the following in > gmane.comp.python.general: > >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I >> uninstalled and installed. Same problem. If one right-clicks on a py >> file, IDLE is not shown in the menu as Edit with IDLE. After playing >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same >> results. >> >> If I look at a 2.4 install on my laptop, I get the desired reference to >> Edit with IDLE. >> > Fine... so open a directory window, follow > > Tools/Folder Options/File Types > > Scroll down to PYW, click [Advanced] > > You should get an "Edit File Type" dialog. Mine shows just one > action "open", yours probably has "open" and "edit". Select "edit" and > then click [Edit] button. See what it says for the application to be > used. > > Do the same on the Win7 machine -- it probably doesn't have "edit" > as an action, so you'll be picking the [New] button. Define the new > action to look like the action on the laptop (use the correct path to > the python executable, and maybe to IDLE). > > Heck, check what those actions show for PY files too... The only > difference between PY and PYW should be the application used in the > "open" action. > PY => .../python.exe > PYW => .../pythonw.exe > > Also make sure that the "open" action is the defined default (select > the action, and click the default button); when there are more than one > action, the default will be in bold. > > > > > > >> My guess is that Win 7 is behind this. If so, it's good-bye Python. >> >> Comments? See my response to Neil Cerutti a few msgs above this one. From rosuav at gmail.com Fri Nov 18 11:04:11 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Nov 2011 03:04:11 +1100 Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On Sat, Nov 19, 2011 at 2:51 AM, Junfeng Hu wrote: > And actually ,the socket hadn't been used in this script. Doesn't matter that you haven't used it; you're binding to the port, that's what causes the 10048. I think the main problem is that you're trying to share sockets across processes, but I haven't used the Python multiprocessing module with sockets before. I would recommend, if you can, creating separate sockets in each subprocess; that might make things a bit easier. ChrisA From hujunfeng at gmail.com Fri Nov 18 11:11:40 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 08:11:40 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <15809319.188.1321632700957.JavaMail.geo-discussion-forums@yqdr22> Hi Chris. The socket only binded once. That's the problem I'm puzzleing, I think it may a bug of multiprocessing in windows, or something I missed. From hujunfeng at gmail.com Fri Nov 18 11:11:40 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 08:11:40 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <15809319.188.1321632700957.JavaMail.geo-discussion-forums@yqdr22> Hi Chris. The socket only binded once. That's the problem I'm puzzleing, I think it may a bug of multiprocessing in windows, or something I missed. From rosuav at gmail.com Fri Nov 18 11:16:47 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Nov 2011 03:16:47 +1100 Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <15809319.188.1321632700957.JavaMail.geo-discussion-forums@yqdr22> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> <674531.1586.1321631509432.JavaMail.geo-discussion-forums@yqhd1> <15809319.188.1321632700957.JavaMail.geo-discussion-forums@yqdr22> Message-ID: On Sat, Nov 19, 2011 at 3:11 AM, Junfeng Hu wrote: > Hi Chris. > The socket only binded once. That's the problem I'm puzzleing, I think it may a bug of multiprocessing in windows, or something I missed. I don't know how multiprocessing goes about initializing those subprocesses; I suspect that's where it creates the additional sockets. ChrisA From ramapraba2653 at gmail.com Fri Nov 18 11:20:05 2011 From: ramapraba2653 at gmail.com (SUPREME) Date: Fri, 18 Nov 2011 08:20:05 -0800 (PST) Subject: FOR FAST UPDATES IN FILM INDUSTRY Message-ID: FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From python at mrabarnett.plus.com Fri Nov 18 11:55:33 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 18 Nov 2011 16:55:33 +0000 Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing In-Reply-To: <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <4EC68E05.6030209@mrabarnett.plus.com> On 18/11/2011 15:48, Junfeng Hu wrote: > Thanks > Yes, I had tried this before, so you could find that I comment the line > sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > Here is the results. > D:\Python test>mythread2.py > Traceback (most recent call last): > File "", line 1, in > File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main > self = load(from_parent) > File "C:\Python27\lib\pickle.py", line 1378, in load > return Unpickler(file).load() > File "C:\Python27\lib\pickle.py", line 858, in load > dispatch[key](self) > File "C:\Python27\lib\pickle.py", line 1133, in load_reduce > value = func(*args) > File "C:\Python27\lib\multiprocessing\reduction.py", line 167, in rebuild_sock > et > _sock = fromfd(fd, family, type_, proto) > File "C:\Python27\lib\multiprocessing\reduction.py", line 156, in fromfd > s = socket.fromfd(fd, family, type_, proto) > AttributeError: 'module' object has no attribute 'fromfd' The documentation for socket.fromfd says: Availability: Unix. You're using Microsoft Windows. From jeanmichel at sequans.com Fri Nov 18 11:56:29 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 18 Nov 2011 17:56:29 +0100 Subject: Dynamically Generate Methods In-Reply-To: References: Message-ID: <4EC68E3D.4050402@sequans.com> GZ wrote: > Hi, > > I have a class Record and a list key_attrs that specifies the names of > all attributes that correspond to a primary key. > > I can write a function like this to get the primary key: > > def get_key(instance_of_record): > return tuple(instance_of_record.__dict__[k] for k in key_attrs) > > However, since key_attrs are determined at the beginning of the > program while get_key() will be called over and over again, I am > wondering if there is a way to dynamically generate a get_ley method > with the key attributes expanded to avoid the list comprehension/ > generator. > > For example, if key_attrs=['A','B'], I want the generated function to > be equivalent to the following: > > def get_key(instance_of_record): > return (instance_of_record['A'],instance_of_record['B'] ) > > I realize I can use eval or exec to do this. But is there any other > way to do this? > > Thanks, > gz > > > > Hi, you may want to do something like class Record(object): PRIMARY_KEY = [] def __init__(self): for key in self.PRIMARY_KEY: setattr(self, key, None) def getPrimaryKeyValues(self): return [ getattr(self, key) for key in self.PRIMARY_KEY] class FruitRecord(Record): PRIMARY_KEY = ['fruit_id', 'fruit_name'] JM PS : there's a high chance that a python module already exists to access your database with python objects. From python at mrabarnett.plus.com Fri Nov 18 12:12:40 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 18 Nov 2011 17:12:40 +0000 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> Message-ID: <4EC69208.6040104@mrabarnett.plus.com> On 18/11/2011 15:29, W. eWatson wrote: > On 11/18/2011 5:11 AM, Neil Cerutti wrote: >> On 2011-11-18, W. eWatson wrote: >>> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >>>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >>>> >>>>> I have not found any successful way to get to IDLE. It's on on the >>>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>>>> with a "invalid Win32 app" msg. >>>> >>>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >>>> does it work? >>>> >>>> Failing that, go to your laptop where the associations are right, >>>> and see >>>> what they are, then duplicate the settings on your Windows 7 machine. >>> >>> Sounds like a good idea except I've not used associations in so >>> long under XP, I have no idea where to start. Control Panel. My >>> Computer Tools? >> >> Open Windows Explorer. >> With the menu, to to Tools->Folder Options >> Click the File Types tab in the Folder Options menu. >> >> There will be an upper view with registered filed types, and some >> buttons below far making changes to them. >> > OK, I've found that. I see > Py > Pyc > Pyo > Pyw > If I click on each, it basically it gives a short description of each. > If I click advanced, there's more info. For example for py, Actions are > IDLE and Open. > > What does this tell me that's relevant to Win7? > > If on Win7, I go to Default Programs I see under associations various > python items. Py shows Unknown application. Since installing 2.7.2 I > have not messed with these associations. If I right-click on Unknown, I > see Notepad and python.exe for choices to open the file. I want neither. > Why isn't IDLE listed there? > > If I right-click on junk.py, I see "Open with". Notepad and python.exe > are choices. However, that menu allows me to choose something else. For > example, Adobe Reader, or Internet Explorer. I suppose the next question > is should I use the browse there and try to connect to IDLE in > ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid > Win32 app", when I try to use it. > You can't associate .py with Idle because Idle is a Python script, not an executable (an .exe). Have a look here: http://superuser.com/questions/68852/change-windows-7-explorer-edit-context-menu-action-for-jpg-and-other-image-fil In my PC's registry (Windows XP, but Windows 7 should be similar or the same) it has the entry: Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command Value: "C:\Python31\pythonw.exe" "C:\Python31\Lib\idlelib\idle.pyw" -n -e "%1" Note how it actually associates the Edit action of Python files with an .exe file. From rustompmody at gmail.com Fri Nov 18 12:19:53 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 18 Nov 2011 09:19:53 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> Message-ID: <18f7cac6-1c38-4506-b8b9-f30d2b9ae5a9@x10g2000prk.googlegroups.com> On Nov 18, 10:12?pm, MRAB wrote: > On 18/11/2011 15:29, W. eWatson wrote: > > > > > > > > > On 11/18/2011 5:11 AM, Neil Cerutti wrote: > >> On 2011-11-18, W. eWatson wrote: > >>> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: > >>>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: > > >>>>> I have not found any successful way to get to IDLE. It's on on the > >>>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails > >>>>> with a "invalid Win32 app" msg. > > >>>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, > >>>> does it work? > > >>>> Failing that, go to your laptop where the associations are right, > >>>> and see > >>>> what they are, then duplicate the settings on your Windows 7 machine. > > >>> Sounds like a good idea except I've not used associations in so > >>> long under XP, I have no idea where to start. Control Panel. My > >>> Computer Tools? > > >> Open Windows Explorer. > >> With the menu, to to Tools->Folder Options > >> Click the File Types tab in the Folder Options menu. > > >> There will be an upper view with registered filed types, and some > >> buttons below far making changes to them. > > > OK, I've found that. I see > > Py > > Pyc > > Pyo > > Pyw > > If I click on each, it basically it gives a short description of each. > > If I click advanced, there's more info. For example for py, Actions are > > IDLE and Open. > > > What does this tell me that's relevant to Win7? > > > If on Win7, I go to Default Programs I see under associations various > > python items. Py shows Unknown application. Since installing 2.7.2 I > > have not messed with these associations. If I right-click on Unknown, I > > see Notepad and python.exe for choices to open the file. I want neither. > > Why isn't IDLE listed there? > > > If I right-click on junk.py, I see "Open with". Notepad and python.exe > > are choices. However, that menu allows me to choose something else. For > > example, Adobe Reader, or Internet Explorer. I suppose the next question > > is should I use the browse there and try to connect to IDLE in > > ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid > > Win32 app", when I try to use it. > > You can't associate .py with Idle because Idle is a Python script, not > an executable (an .exe). > > Have a look here:http://superuser.com/questions/68852/change-windows-7-explorer-edit-c... > > In my PC's registry (Windows XP, but Windows 7 should be similar or the > same) it has the entry: > > Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command > Value: "C:\Python31\pythonw.exe" "C:\Python31\Lib\idlelib\idle.pyw" -n > -e "%1" > > Note how it actually associates the Edit action of Python files with an > .exe file. The tools -> folder options approach is the user-friendly approach -- when it works. The 'Correct the registry' is the muscular approach -- it will set right everything iff you are a wizard. In between the two is assoc and ftype see http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ftype.mspx?mfr=true http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/assoc.mspx?mfr=true From wolftracks at invalid.com Fri Nov 18 12:45:26 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 09:45:26 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> Message-ID: On 11/18/2011 9:12 AM, MRAB wrote: > On 18/11/2011 15:29, W. eWatson wrote: >> On 11/18/2011 5:11 AM, Neil Cerutti wrote: >>> On 2011-11-18, W. eWatson wrote: >>>> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >>>>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >>>>> >>>>>> I have not found any successful way to get to IDLE. It's on on the >>>>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>>>>> with a "invalid Win32 app" msg. >>>>> >>>>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >>>>> does it work? >>>>> >>>>> Failing that, go to your laptop where the associations are right, >>>>> and see >>>>> what they are, then duplicate the settings on your Windows 7 machine. >>>> >>>> Sounds like a good idea except I've not used associations in so >>>> long under XP, I have no idea where to start. Control Panel. My >>>> Computer Tools? >>> >>> Open Windows Explorer. >>> With the menu, to to Tools->Folder Options >>> Click the File Types tab in the Folder Options menu. >>> >>> There will be an upper view with registered filed types, and some >>> buttons below far making changes to them. >>> >> OK, I've found that. I see >> Py >> Pyc >> Pyo >> Pyw >> If I click on each, it basically it gives a short description of each. >> If I click advanced, there's more info. For example for py, Actions are >> IDLE and Open. >> >> What does this tell me that's relevant to Win7? >> >> If on Win7, I go to Default Programs I see under associations various >> python items. Py shows Unknown application. Since installing 2.7.2 I >> have not messed with these associations. If I right-click on Unknown, I >> see Notepad and python.exe for choices to open the file. I want neither. >> Why isn't IDLE listed there? >> >> If I right-click on junk.py, I see "Open with". Notepad and python.exe >> are choices. However, that menu allows me to choose something else. For >> example, Adobe Reader, or Internet Explorer. I suppose the next question >> is should I use the browse there and try to connect to IDLE in >> ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid >> Win32 app", when I try to use it. >> > You can't associate .py with Idle because Idle is a Python script, not > an executable (an .exe). Odd, but OK. > > Have a look here: > http://superuser.com/questions/68852/change-windows-7-explorer-edit-context-menu-action-for-jpg-and-other-image-fil Are you suggesting that I use the "default" program mentioned there? > > > In my PC's registry (Windows XP, but Windows 7 should be similar or the > same) it has the entry: > > Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command > Value: "C:\Python31\pythonw.exe" "C:\Python31\Lib\idlelib\idle.pyw" -n > -e "%1" > > Note how it actually associates the Edit action of Python files with an > .exe file. So pythonw.exe and idle.pyw are not scripts but somehow can fire up idle? Are you suggesting I modify my registry? I still find it bizarre the install did not put it IDLE choice on the menu for py. It's there on XP. From wolftracks at invalid.com Fri Nov 18 12:48:54 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 09:48:54 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: <18f7cac6-1c38-4506-b8b9-f30d2b9ae5a9@x10g2000prk.googlegroups.com> References: <4ec5a5cf$0$29967$c3e8da3$5496439d@news.astraweb.com> <9in3r9F5j3U2@mid.individual.net> <18f7cac6-1c38-4506-b8b9-f30d2b9ae5a9@x10g2000prk.googlegroups.com> Message-ID: On 11/18/2011 9:19 AM, rusi wrote: > On Nov 18, 10:12 pm, MRAB wrote: >> On 18/11/2011 15:29, W. eWatson wrote: >> >> >> >> >> >> >> >>> On 11/18/2011 5:11 AM, Neil Cerutti wrote: >>>> On 2011-11-18, W. eWatson wrote: >>>>> On 11/17/2011 4:24 PM, Steven D'Aprano wrote: >>>>>> On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote: >> >>>>>>> I have not found any successful way to get to IDLE. It's on on the >>>>>>> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails >>>>>>> with a "invalid Win32 app" msg. >> >>>>>> If you associate .pyw files with pythonw.exe, and then open idle.pyw, >>>>>> does it work? >> >>>>>> Failing that, go to your laptop where the associations are right, >>>>>> and see >>>>>> what they are, then duplicate the settings on your Windows 7 machine. >> >>>>> Sounds like a good idea except I've not used associations in so >>>>> long under XP, I have no idea where to start. Control Panel. My >>>>> Computer Tools? >> >>>> Open Windows Explorer. >>>> With the menu, to to Tools->Folder Options >>>> Click the File Types tab in the Folder Options menu. >> >>>> There will be an upper view with registered filed types, and some >>>> buttons below far making changes to them. >> >>> OK, I've found that. I see >>> Py >>> Pyc >>> Pyo >>> Pyw >>> If I click on each, it basically it gives a short description of each. >>> If I click advanced, there's more info. For example for py, Actions are >>> IDLE and Open. >> >>> What does this tell me that's relevant to Win7? >> >>> If on Win7, I go to Default Programs I see under associations various >>> python items. Py shows Unknown application. Since installing 2.7.2 I >>> have not messed with these associations. If I right-click on Unknown, I >>> see Notepad and python.exe for choices to open the file. I want neither. >>> Why isn't IDLE listed there? >> >>> If I right-click on junk.py, I see "Open with". Notepad and python.exe >>> are choices. However, that menu allows me to choose something else. For >>> example, Adobe Reader, or Internet Explorer. I suppose the next question >>> is should I use the browse there and try to connect to IDLE in >>> ...\Lib\idlelib? My guess is that if I do, I will run into the "invalid >>> Win32 app", when I try to use it. >> >> You can't associate .py with Idle because Idle is a Python script, not >> an executable (an .exe). >> >> Have a look here:http://superuser.com/questions/68852/change-windows-7-explorer-edit-c... >> >> In my PC's registry (Windows XP, but Windows 7 should be similar or the >> same) it has the entry: >> >> Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command >> Value: "C:\Python31\pythonw.exe" "C:\Python31\Lib\idlelib\idle.pyw" -n >> -e "%1" >> >> Note how it actually associates the Edit action of Python files with an >> .exe file. > > The tools -> folder options approach is the user-friendly approach -- > when it works. > The 'Correct the registry' is the muscular approach -- it will set > right everything iff you are a wizard. > > In between the two is assoc and ftype see > http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ftype.mspx?mfr=true > http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/assoc.mspx?mfr=true These two seem equally muscular. I shudder to think where these choices might lead me. From duncan.booth at invalid.invalid Fri Nov 18 12:52:49 2011 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 18 Nov 2011 17:52:49 GMT Subject: Dynamically Generate Methods References: Message-ID: GZ wrote: > For example, if key_attrs=['A','B'], I want the generated function to > be equivalent to the following: > > def get_key(instance_of_record): > return (instance_of_record['A'],instance_of_record['B'] ) > > I realize I can use eval or exec to do this. But is there any other > way to do this? > Use operator.itemgetter: >>> key_attrs = ['A', 'B'] >>> import operator >>> get_key = operator.itemgetter(*key_attrs) >>> d = {'A': 42, 'B': 63, 'C': 99} >>> get_key(d) (42, 63) -- Duncan Booth http://kupuguy.blogspot.com From wolftracks at invalid.com Fri Nov 18 12:57:53 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 09:57:53 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 11:35 PM, Terry Reedy wrote: > On 11/17/2011 7:03 PM, W. eWatson wrote: > >> I have not found any successful way to get to IDLE. > > Use the start menu to start IDLE once. Then pin it to your taskbar. > If you do not have STart/ all programs / Python / IDLE, then your > installation is bad. > > As for the right click problem, you probably have something screwy in > the registry. The python installer (or uninstaller) will not fix it (my > experience on my old xp machine). You will have to do so manually. > IDLE is a choice on the Start menu (All Programs). Pressing it does nothing. I see nothing that suggests it's open. The IDLE entry is pointing at c:\Python27\ (shortcut) A post above yours suggests IDLE is a script, and somehow needs a "boost" to use it. An exe file, apparently. Beats the heck out of me. From wolftracks at invalid.com Fri Nov 18 12:59:00 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 09:59:00 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: On 11/17/2011 9:25 PM, Benjamin Kaplan wrote: > On Thu, Nov 17, 2011 at 11:21 PM, W. eWatson wrote: >> >> On 11/17/2011 7:59 PM, Dave Angel wrote: >>> >>> On 11/17/2011 03:31 PM, W. eWatson wrote: >>>> >>>> On 11/17/2011 9:39 AM, John Gordon wrote: >>>> >>>>> >>>>> Can you add IDLE manually to the associated applications list? >>>>> >>>> Tried that by sending it directly to idle.pyw, but then trying to get >>>> there through the Edit with menu caused a "invalid Win32 app." >>> >>> You've been told repeatedly that building an association to idle.pyw is >>> useless. It must be to something Windows understands, such as .exe, or >>> .bat (or several other extensions, as I said in an earlier message) So >>> why waste our time telling us yet again that it doesn't work? >>> >>> >>> >> Because some people think that's a solution, and ask. It's not. It leads to an error message. > > > Checking my Python install, there should be an idle.bat file in there > too. Have you tried that? Yes. I tried running it. Got nowhere. From ian.g.kelly at gmail.com Fri Nov 18 13:04:19 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 18 Nov 2011 11:04:19 -0700 Subject: Dynamically Generate Methods In-Reply-To: References: Message-ID: On Fri, Nov 18, 2011 at 7:51 AM, GZ wrote: > Hi, > > I have a class Record and a list key_attrs that specifies the names of > all attributes that correspond to a primary key. > > I can write a function like this to get the primary key: > > def get_key(instance_of_record): > return tuple(instance_of_record.__dict__[k] for k in key_attrs) > > However, since key_attrs are determined at the beginning of the > program while get_key() will be called over and over again, I am > wondering if there is a way to dynamically generate a get_ley method > with the key attributes expanded to avoid the list comprehension/ > generator. (Accidentally sent this to the OP only) This is exactly what the attrgetter factory function produces. from operator import attrgetter get_key = attrgetter(*key_attrs) But if your attribute names are variable and arbitrary, I strongly recommend you store them in a dict instead. Setting them as instance attributes risks that they might conflict with the regular attributes and methods on your objects. Cheers, Ian From wolftracks at invalid.com Fri Nov 18 13:06:47 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 10:06:47 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) Message-ID: Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 flop the same way under Win 7. One thing I think no one has offered is whether their installation of 2.7.2 has the same IDLE oddity that I've described. That is, if you right-click on a py file, do you see a choice for the IDLE editor? From wolftracks at invalid.com Fri Nov 18 13:10:32 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 10:10:32 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: Message-ID: On 11/18/2011 10:06 AM, W. eWatson wrote: > Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 > flop the same way under Win 7. > > One thing I think no one has offered is whether their installation of > 2.7.2 has the same IDLE oddity that I've described. That is, if you > right-click on a py file, do you see a choice for the IDLE editor? Try it on Win 7. From mbadoiu at gmail.com Fri Nov 18 16:10:24 2011 From: mbadoiu at gmail.com (Mihai Badoiu) Date: Fri, 18 Nov 2011 16:10:24 -0500 Subject: Resources consumed by parent Message-ID: How do I get the resources consumed by the parent process? getrusage() in the resource module seems to work only for self or the children processes. thanks, --mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From me+list/python at ixokai.io Fri Nov 18 17:31:54 2011 From: me+list/python at ixokai.io (Stephen Hansen) Date: Fri, 18 Nov 2011 14:31:54 -0800 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4EC6DCDA.8040802@ixokai.io> On 11/17/11 8:34 PM, W. eWatson wrote: > On 11/17/2011 7:04 PM, alex23 wrote: >> On Nov 18, 2:55 am, "W. eWatson" wrote: >>> Comments? >> >> Are you using the vanilla installer or ActiveState's ActivePython? I >> find the latter integrates better with Windows. >> >> Also, out of curiousity, 32 or 64 bit Windows? > 64-bit and plain old python msi installer. That'd be it, I expect. Windows has two parallel registry trees; if you launch a 32-bit program, it sees one.. if you launch a 64-bit program, it sees the other. What looks like the exact same keys can be different as a result. The MSI is probably writing the keys into the 32-bit registry, and Explorer is now a 64-bit application. You can add the associations for Edit manually. Though not to "idle.pyw", which you keep -- repeatedly -- saying you try and errors. Of course it errors. That's a python script, not an executable. Associate to pythonw.exe, and pass it the path to idle.pyw, and then -n -e "%1" -- which will be replaced with the actual filename. But you were told that already and seem to have just dismissed it out of hand. Like: PATH\pythonw.exe PATH\idle.pyw -n -e "%1" ... where PATH is whatever the location of those files are in your environment. Yes, its moderately annoying that you have to do this yourself; maybe you wouldn't if you installed 64-bit python, but I can't be sure. Maybe it has nothing to do with 32 or 64-bitness at all and my guess is wrong. Maybe your profile has gone wonky. But it doesn't matter. You can add the Edit association yourself. Its a one-time fix. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: OpenPGP digital signature URL: From steve+comp.lang.python at pearwood.info Fri Nov 18 18:44:08 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Nov 2011 23:44:08 GMT Subject: Python 2.7.2 on Win7 and IDLE (Try it) References: Message-ID: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: > Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 > flop the same way under Win 7. > > One thing I think no one has offered is whether their installation of > 2.7.2 has the same IDLE oddity that I've described. That is, if you > right-click on a py file, do you see a choice for the IDLE editor? Terry Reedy has already said that his installation works fine. "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." If you have installed the regular, 32-bit version of Python on a 64-bit version of Windows, chances are good that there will be registry problems stopping things from working correctly. See Stephen Hansen's post. -- Steven From wolftracks at invalid.com Fri Nov 18 19:31:03 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 16:31:03 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/18/2011 3:44 PM, Steven D'Aprano wrote: > On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: > >> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >> flop the same way under Win 7. >> >> One thing I think no one has offered is whether their installation of >> 2.7.2 has the same IDLE oddity that I've described. That is, if you >> right-click on a py file, do you see a choice for the IDLE editor? > > Terry Reedy has already said that his installation works fine. > > "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." > > > If you have installed the regular, 32-bit version of Python on a 64-bit > version of Windows, chances are good that there will be registry problems > stopping things from working correctly. See Stephen Hansen's post. > > > Somehow 3.3.2 doesn't look like 2.7.2. Ah, I installed a 32-bit. Missed his post. So what should I do? Try 3.3.2 64-bit? I'm game. By the time you read this, I will either have done it or gotten into it. From wolftracks at invalid.com Fri Nov 18 19:50:24 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 16:50:24 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/18/2011 4:31 PM, W. eWatson wrote: > On 11/18/2011 3:44 PM, Steven D'Aprano wrote: >> On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: >> >>> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >>> flop the same way under Win 7. >>> >>> One thing I think no one has offered is whether their installation of >>> 2.7.2 has the same IDLE oddity that I've described. That is, if you >>> right-click on a py file, do you see a choice for the IDLE editor? >> >> Terry Reedy has already said that his installation works fine. >> >> "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." >> >> >> If you have installed the regular, 32-bit version of Python on a 64-bit >> version of Windows, chances are good that there will be registry problems >> stopping things from working correctly. See Stephen Hansen's post. >> >> >> > Somehow 3.3.2 doesn't look like 2.7.2. > > Ah, I installed a 32-bit. Missed his post. So what should I do? Try > 3.3.2 64-bit? I'm game. By the time you read this, I will either have > done it or gotten into it. 3.3.2? I do not see that in his single message I found. I see a 3.2.2 release on . Google shows me nothing for 3.3.2. I see: * Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug information files (sig) * Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug information files (sig) Visual Studio???? I hope I don't need VS! From python at mrabarnett.plus.com Fri Nov 18 20:22:04 2011 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 19 Nov 2011 01:22:04 +0000 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4EC704BC.6050703@mrabarnett.plus.com> On 19/11/2011 00:50, W. eWatson wrote: > On 11/18/2011 4:31 PM, W. eWatson wrote: >> On 11/18/2011 3:44 PM, Steven D'Aprano wrote: >>> On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: >>> >>>> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >>>> flop the same way under Win 7. >>>> >>>> One thing I think no one has offered is whether their installation of >>>> 2.7.2 has the same IDLE oddity that I've described. That is, if you >>>> right-click on a py file, do you see a choice for the IDLE editor? >>> >>> Terry Reedy has already said that his installation works fine. >>> >>> "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works >>> fine." >>> >>> >>> If you have installed the regular, 32-bit version of Python on a 64-bit >>> version of Windows, chances are good that there will be registry >>> problems >>> stopping things from working correctly. See Stephen Hansen's post. >>> >>> >>> >> Somehow 3.3.2 doesn't look like 2.7.2. >> >> Ah, I installed a 32-bit. Missed his post. So what should I do? Try >> 3.3.2 64-bit? I'm game. By the time you read this, I will either have >> done it or gotten into it. > > 3.3.2? I do not see that in his single message I found. I see a 3.2.2 > release on . Google > shows me nothing for 3.3.2. > > I see: > * Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug > information files (sig) > * Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug > information files (sig) > > Visual Studio???? I hope I don't need VS! If you look more closely you'll see that there are 5 links on each line: Windows X86-64 MSI Installer (3.2.2) [1] (sig) Visual Studio debug information files (sig) Unless you intending to work on the sources, you need just the first one: Windows X86-64 MSI Installer (3.2.2) for a 64-bit build of Python 3.2.2. From hujunfeng at gmail.com Fri Nov 18 21:45:42 2011 From: hujunfeng at gmail.com (Junfeng Hu) Date: Fri, 18 Nov 2011 18:45:42 -0800 (PST) Subject: Why sock.bind is always report 10048 error when in a script with multiprocessing References: <12715937.830.1321611809592.JavaMail.geo-discussion-forums@yqoo7> <14330307.286.1321631316567.JavaMail.geo-discussion-forums@yqcm23> Message-ID: <5e4635df-936f-4f5d-b3c9-ad4370a3be64@j10g2000vbe.googlegroups.com> On Nov 18, 10:55?am, MRAB wrote: > On 18/11/2011 15:48, Junfeng Hu wrote: > > > > > > > Thanks > > Yes, I had tried this before, so you could find that I comment the line > > sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > > Here is the results. > > D:\Python test>mythread2.py > > Traceback (most recent call last): > > ? ?File "", line 1, in > > ? ?File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main > > ? ? ?self = load(from_parent) > > ? ?File "C:\Python27\lib\pickle.py", line 1378, in load > > ? ? ?return Unpickler(file).load() > > ? ?File "C:\Python27\lib\pickle.py", line 858, in load > > ? ? ?dispatch[key](self) > > ? ?File "C:\Python27\lib\pickle.py", line 1133, in load_reduce > > ? ? ?value = func(*args) > > ? ?File "C:\Python27\lib\multiprocessing\reduction.py", line 167, in rebuild_sock > > et > > ? ? ?_sock = fromfd(fd, family, type_, proto) > > ? ?File "C:\Python27\lib\multiprocessing\reduction.py", line 156, in fromfd > > ? ? ?s = socket.fromfd(fd, family, type_, proto) > > AttributeError: 'module' object has no attribute 'fromfd' > > The documentation for socket.fromfd says: > > ? ? ?Availability: Unix. > > You're using Microsoft Windows.- Hide quoted text - > > - Show quoted text - Yes, but my question is , how to make such script work in windows. From sturlamolden at yahoo.no Fri Nov 18 23:26:17 2011 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 18 Nov 2011 20:26:17 -0800 (PST) Subject: Data Plotting Library Dislin 10.2 References: Message-ID: <9599229d-28aa-4730-b29a-b7c32e1e3d2e@e15g2000vba.googlegroups.com> On 18 Nov, 22:16, Tony the Tiger wrote: > Ya, but apparently no source unless you dig deep into your pockets. > Really, why would we need this when we already have gnuplot? > Just wondering... Dislin is a very nice plotting library for scientific data, particularly for scientists and engineers using Fortran (which, incidentally, is quite a few). For Python, we have Matplotlib as well (at least for 2D plots). Sturla From steve+comp.lang.python at pearwood.info Fri Nov 18 23:36:08 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Nov 2011 04:36:08 GMT Subject: Python 2.7.2 on Win7 and IDLE (Try it) References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ec73237$0$29967$c3e8da3$5496439d@news.astraweb.com> On Fri, 18 Nov 2011 16:31:03 -0800, W. eWatson wrote: > Somehow 3.3.2 doesn't look like 2.7.2. Oops, so you're right. Sorry for the noise. -- Steven From wolftracks at invalid.com Sat Nov 19 00:03:58 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 21:03:58 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: ... >> >> 3.3.2? I do not see that in his single message I found. I see a 3.2.2 >> release on . Google >> shows me nothing for 3.3.2. >> >> I see: >> * Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug >> information files (sig) >> * Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug >> information files (sig) >> >> Visual Studio???? I hope I don't need VS! > > If you look more closely you'll see that there are 5 links on each line: > > Windows X86-64 MSI Installer (3.2.2) > [1] > (sig) > Visual Studio debug information files > (sig) > > Unless you intending to work on the sources, you need just the first > one: > > Windows X86-64 MSI Installer (3.2.2) > > for a 64-bit build of Python 3.2.2. An oddity occurs here. Yes, x86-64 is the right installer, maybe. While noting your msg, my PC got very slow, and I ended up going to a related site for the downloads of 3.2.2 while trying for the one above. . It shows: Also look at the detailed Python 3.2.2 page: * Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not include source) * Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 / X86-64 binary [1] -- does not include source) The first of the two choices does not say x-bit anything. The second looks off course for my HP 64-bit PC. I'm going to just use Windows X86-64 MSI Installer (3.2.2). Wait a minute Windows X86-64 MSI Installer (3.2.2). Windows X86-64 MSI Installer (3.2.2) shows it's associated with Visual Studio. Why would I want that? Ah, I get it The single first line has Windows X86-64 MSI Installer (3.2.2) and Visual Studio. That's a really weird way to arrange them. OK, now off to Windows X86-64 MSI Installer (3.2.2) I'll be back shortly after I've made the install. From wolftracks at invalid.com Sat Nov 19 00:28:39 2011 From: wolftracks at invalid.com (W. eWatson) Date: Fri, 18 Nov 2011 21:28:39 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/18/2011 9:03 PM, W. eWatson wrote: > ... >>> >>> 3.3.2? I do not see that in his single message I found. I see a 3.2.2 >>> release on . Google >>> shows me nothing for 3.3.2. >>> >>> I see: >>> * Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug >>> information files (sig) >>> * Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug >>> information files (sig) >>> >>> Visual Studio???? I hope I don't need VS! >> >> If you look more closely you'll see that there are 5 links on each line: >> >> Windows X86-64 MSI Installer (3.2.2) >> [1] >> (sig) >> Visual Studio debug information files >> (sig) >> >> Unless you intending to work on the sources, you need just the first >> one: >> >> Windows X86-64 MSI Installer (3.2.2) >> >> for a 64-bit build of Python 3.2.2. > > An oddity occurs here. Yes, x86-64 is the right installer, maybe. While > noting your msg, my PC got very slow, and I ended up going to a related > site for the downloads of 3.2.2 while trying for the one above. > . > > It shows: > Also look at the detailed Python 3.2.2 page: > > * Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not > include source) > * Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 / > X86-64 binary [1] -- does not include source) > > The first of the two choices does not say x-bit anything. The second > looks off course for my HP 64-bit PC. > > I'm going to just use Windows X86-64 MSI Installer (3.2.2). > > Wait a minute Windows X86-64 MSI Installer (3.2.2). Windows X86-64 MSI > Installer (3.2.2) shows it's associated with Visual Studio. Why would I > want that? Ah, I get it The single first line has Windows X86-64 MSI > Installer (3.2.2) and Visual Studio. That's a really weird way to > arrange them. OK, now off to Windows X86-64 MSI Installer (3.2.2) > > I'll be back shortly after I've made the install. I surrender. IDLE does not appear as a choice when I right-click on a py file. IDLE is on the All Programs list, and if I click on it, something more or less seems to happen, but it does not reveal anything. There is a comparability choice there that asks what OS did it last run on. Unfortunately the choices were VISTA (service packs) and Win7. I selected Win7 but it didn't help. Off to bed soon. From tjreedy at udel.edu Sat Nov 19 05:34:25 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 19 Nov 2011 05:34:25 -0500 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/18/2011 6:44 PM, Steven D'Aprano wrote: > On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: > >> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >> flop the same way under Win 7. >> >> One thing I think no one has offered is whether their installation of >> 2.7.2 has the same IDLE oddity that I've described. That is, if you >> right-click on a py file, do you see a choice for the IDLE editor? > > Terry Reedy has already said that his installation works fine. > > "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." 64 bit python and 64 bit win 7 > > If you have installed the regular, 32-bit version of Python on a 64-bit > version of Windows, chances are good that there will be registry problems > stopping things from working correctly. See Stephen Hansen's post. > > > -- Terry Jan Reedy From tjreedy at udel.edu Sat Nov 19 05:39:19 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 19 Nov 2011 05:39:19 -0500 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/19/2011 12:03 AM, W. eWatson wrote: I meant 3.2.2, not 3.3.2, sorry for typo. > * Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not > include source) this is 32 bit. Note that your c: has /program files for 64 bit programs and /program files(x86) for 32 bit programs. I know, a bit confusing. > * Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 / > X86-64 binary [1] -- does not include source) this is 64 bit. -- Terry Jan Reedy From alec.taylor6 at gmail.com Sat Nov 19 08:51:57 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sun, 20 Nov 2011 00:51:57 +1100 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: Message-ID: Works fine for me from msi install on Windows 8 x64 Dev Preview On Sat, Nov 19, 2011 at 5:06 AM, W. eWatson wrote: > Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 flop > the same way under Win 7. > > One thing I think no one has offered is whether their installation of 2.7.2 > has the same IDLE oddity that I've described. ?That is, if you right-click > on a py file, do you see a choice for the IDLE editor? > -- > http://mail.python.org/mailman/listinfo/python-list From safeerheart at gmail.com Sat Nov 19 09:54:47 2011 From: safeerheart at gmail.com (safeer) Date: Sat, 19 Nov 2011 06:54:47 -0800 (PST) Subject: dj Message-ID: <275a84ea-7a85-42fe-82ce-eab8e63326f0@q39g2000prg.googlegroups.com> http://123maza.com/48/gold028/ From wolftracks at invalid.com Sat Nov 19 10:35:52 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sat, 19 Nov 2011 07:35:52 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/19/2011 2:39 AM, Terry Reedy wrote: > On 11/19/2011 12:03 AM, W. eWatson wrote: > > I meant 3.2.2, not 3.3.2, sorry for typo. > >> * Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not >> include source) > > this is 32 bit. Note that your c: has /program files for 64 bit programs > and /program files(x86) for 32 bit programs. I know, a bit confusing. > >> * Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 / >> X86-64 binary [1] -- does not include source) > > this is 64 bit. > Yes. Did I miss something? From wolftracks at invalid.com Sat Nov 19 10:39:34 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sat, 19 Nov 2011 07:39:34 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: <4ec6edc7$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/19/2011 2:34 AM, Terry Reedy wrote: > On 11/18/2011 6:44 PM, Steven D'Aprano wrote: >> On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote: >> >>> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 >>> flop the same way under Win 7. >>> >>> One thing I think no one has offered is whether their installation of >>> 2.7.2 has the same IDLE oddity that I've described. That is, if you >>> right-click on a py file, do you see a choice for the IDLE editor? >> >> Terry Reedy has already said that his installation works fine. >> >> "I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine." > > 64 bit python and 64 bit win 7 >> >> If you have installed the regular, 32-bit version of Python on a 64-bit >> version of Windows, chances are good that there will be registry problems >> stopping things from working correctly. See Stephen Hansen's post. >> >> >> > > Yes, see the other fork started by MRAB I tried it. Same old problem. From wolftracks at invalid.com Sat Nov 19 11:14:57 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sat, 19 Nov 2011 08:14:57 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: Message-ID: On 11/19/2011 5:51 AM, Alec Taylor wrote: > Works fine for me from msi install on Windows 8 x64 Dev Preview > > On Sat, Nov 19, 2011 at 5:06 AM, W. eWatson wrote: >> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 flop >> the same way under Win 7. >> >> One thing I think no one has offered is whether their installation of 2.7.2 >> has the same IDLE oddity that I've described. That is, if you right-click >> on a py file, do you see a choice for the IDLE editor? >> -- >> http://mail.python.org/mailman/listinfo/python-list 3.2.2, and not 2.7.2. The course of the thread was changed at the MRAB post. What do you mean by it works fine? My criterion is that it puts IDLE as a choice for editor on the menu produced with a right-click on a py file. From wolftracks at invalid.com Sat Nov 19 11:18:54 2011 From: wolftracks at invalid.com (W. eWatson) Date: Sat, 19 Nov 2011 08:18:54 -0800 Subject: Python 2.7.2 on Win7 and IDLE (Try it) In-Reply-To: References: Message-ID: On 11/19/2011 5:51 AM, Alec Taylor wrote: > Works fine for me from msi install on Windows 8 x64 Dev Preview > > On Sat, Nov 19, 2011 at 5:06 AM, W. eWatson wrote: >> Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 flop >> the same way under Win 7. >> >> One thing I think no one has offered is whether their installation of 2.7.2 >> has the same IDLE oddity that I've described. That is, if you right-click >> on a py file, do you see a choice for the IDLE editor? >> -- >> http://mail.python.org/mailman/listinfo/python-list Are you suggesting the mail list might be a better place to pursue this? Or is it from some one else? From no.email at nospam.invalid Sat Nov 19 18:21:52 2011 From: no.email at nospam.invalid (Paul Rubin) Date: Sat, 19 Nov 2011 15:21:52 -0800 Subject: xml.dom.minidom question References: Message-ID: <7xwravu29b.fsf@ruckus.brouhaha.com> nivashno writes: > I always thought that xml was very precisely split up into nodes, > childnodes, etc, no matter what the whitespace between them was. But > apparently not, or am I missing something? The whitespace in your example becomes part of a data element. From vinay_sajip at yahoo.co.uk Sat Nov 19 19:42:19 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sat, 19 Nov 2011 16:42:19 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> <4f5fd473-4717-4f41-8017-d7407adc4571@u10g2000prl.googlegroups.com> Message-ID: <5dfa9add-582f-4219-8d78-01239f80525e@p5g2000vbm.googlegroups.com> On Nov 17, 9:06?am, sword wrote: > On Nov 16, 10:50?pm, Peter Otten <__pete... at web.de> wrote: > > > > > > > > > > > sword wrote: > > > Thanks for your reply. I tried to edit the source a bit, now the > > > main.py looks like this: > > > #main.py > > > importlogging > > > fromloggingimport Filter > > > import a > > > import b > > > >logging.basicConfig(level=logging.DEBUG) > > > root =logging.getLogger() > > > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > > > would pass this filter > > > > logger =logging.getLogger("main") > > > logger.debug("main process") > > > a.print_log() > > > b.print_log() > > > > #### > > > And It still prints out all the log msg. :( > > > Here's a little demo to explore how filtering works: > > > $ cat demo.py > > importlogging > > class Filter(logging.Filter): > > ? ? def filter(self, record): > > ? ? ? ? print "applying filter", self.name > > ? ? ? ? return True > > >logging.basicConfig() > > > loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]] > > for logger in loggers: > > ? ? logger.addFilter(Filter("filter@" + logger.name)) > > > [handler] =logging.getLogger().handlers > > handler.addFilter(Filter("filter at handler")) > > > for logger in loggers: > > ? ? logger.critical("whatever") > > $ python demo.py > > applying filter filter at root > > applying filter filter at handler > > CRITICAL:root:whatever > > applying filter filter at a > > applying filter filter at handler > > CRITICAL:a:whatever > > applying filter fil... at a.b > > applying filter filter at handler > > CRITICAL:a.b:whatever > > $ > > > As you can infer from the output only the filter(s) of the original logger > > and of the handler(s) are applied. > > Thanks, so if I want to see my own log out of all logs produced by > different module in the project, I should addFilter to each > corresponding logger. I thought I could add Filter in root and filter > out only the interested info from it before. Or you can add a filter to the handler (but then you can't use basicConfig() to configure it - you need to do it explicitly). Regards, Vinay Sajip From kwa at kuwata-lab.com Sat Nov 19 23:30:22 2011 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Sun, 20 Nov 2011 13:30:22 +0900 Subject: [ANN] Oktest.py 0.11.0 released - a new-style testing library Message-ID: I released Oktest.py 0.11.0. http://pypi.python.org/pypi/Oktest/ http://packages.python.org/Oktest/ Oktest.py is a new-style testing library for Python. :: from oktest import ok, NG ok (x) > 0 # same as assertTrue(x > 0) ok (s) == 'foo' # same as assertEqual(s, 'foo') ok (s) != 'foo' # same as assertNotEqual(s, 'foo') ok (f).raises(ValueError) # same as assertRaises(ValueError, f) ok (u'foo').is_a(unicode) # same as assertTrue(isinstance(u'foo', unicode)) NG (u'foo').is_a(int) # same as assertTrue(not isinstance(u'foo', int)) ok ('A.txt').is_file() # same as assertTrue(os.path.isfile('A.txt')) NG ('A.txt').is_dir() # same as assertTrue(not os.path.isdir('A.txt')) See http://packages.python.org/Oktest/ for details. Changes and Enhancements ------------------------ * [change] 'spec()' is now NOT obsoleted. * [change] 'spec()' is now available as function decorator. ex:: class FooTest(unittest.TestCase): def test_method1(self) @spec("1+1 should be 2") def _(): ok (1+1) == 2 @spec("1-1 should be 0") def _(): ok (1-1) == 0 * [enhance] New assertions: not_file(), not_dir() and not_exist(). ex:: ok (".").not_file() # same as NG (".").is_file() ok (__file__).not_dir() # same as NG (__file__).is_dir() ok ("foobar").not_exist() # same as NG ("foobar").exists() * [enhance] New assertion: not_match(). ex:: ok ("SOS").not_match(r"\d+") # same as NG ("SOS").matches(r"\d+") * [enhance] Global provider/releaser functions can take 'self' argument. ex:: def provide_logname(self): self._LOGNAME = os.getenv('LOGNAME') os.environ['LOGNAME'] = "Haruhi" return os.environ['LOGNAME'] def release_logname(self, value): os.environ['LOGNAME'] = self._LOGNAME * [change] Change not to ignore test classes which name starts with '_'. * [change] (internal) Move some utility functions to 'util' module. * [change] (internal) Move '_Context' and '_RunnableContext' classes into 'util' module. * [change] (internal) Move 'Color' class into 'util' module * [change] (internal) Remove 'OUT' variable in 'Reporter' class * [change] (internal) Move 'TARGET_PATTERN' variable to 'config' * [bugfix] Fix to clear ImportError after trying to import unittest2 -- regards, makoto From andrew.rustytub at gmail.com Sun Nov 20 00:04:11 2011 From: andrew.rustytub at gmail.com (Andrew Evans) Date: Sat, 19 Nov 2011 21:04:11 -0800 Subject: Announcing Mii (My) Chat Message-ID: Hello I wish to inform the list of a Python Application I am writing entitled Mii Chat. What is Mii Chat you ask? It is an IP to IP or IP to Multiple IP text/voice/video chat client written in Python Currently the GUI is written in PyQT and could use a complete overhaul (in progress) There are a few bugs: Like I couldn't figure out the Threading for the Video so I am using QTimer. and the Audio could be improved. But overall it works as expected! I am happy about it cause I am not the best programmer. I have never been to school for Comp Science Programming or any university/college for that matter. I am self taught and consider myself a hobbyist programmer. It would be great if some one could suggest a library for TCP Nat Traversal. As well I am open to any and all suggestions! I appreciate any feedback *cheers Andrew Evans Here is the link http://code.google.com/p/mii-chat/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From nobody at nowhere.com Sun Nov 20 02:22:02 2011 From: nobody at nowhere.com (Nobody) Date: Sun, 20 Nov 2011 07:22:02 +0000 Subject: xml.dom.minidom question References: Message-ID: On Sat, 19 Nov 2011 15:32:18 -0600, nivashno wrote: > I always thought that xml was very precisely split up into nodes, > childnodes, etc, no matter what the whitespace between them was. But > apparently not, or am I missing something? XML allows mixed content (an element's children can be a mixture of text and elements). Formats such as XHTML wouldn't be possible otherwise. A validating parser will know from the schema whether an element can contain mixed content, and can use this knowledge to elide whitespace-only text nodes within elements which don't have mixed content (however, that doesn't meant that it will, or even that it should; some applications may prefer to retain the whitespace in order to preserve formatting). A non-validating parser (which doesn't use a schema) doesn't know whether an element contains mixed content, so it has to retain all text nodes in case they're significant. The Python standard library doesn't include a validating XML parser. xmlproc seems to be the preferred validating parser. That has a separate handle_ignorable_data() method for reporting whitespace-only text nodes within non-mixed-content elements; the handle_data() method is only called for "significant" text. From zyzhu2000 at gmail.com Sun Nov 20 06:23:18 2011 From: zyzhu2000 at gmail.com (GZ) Date: Sun, 20 Nov 2011 03:23:18 -0800 (PST) Subject: Dynamically Generate Methods References: Message-ID: <6c05cd6f-9adb-4f65-9da7-cd938616da41@j10g2000vbe.googlegroups.com> Hi All, I see. It works. Thanks, GZ On Nov 18, 12:04?pm, Ian Kelly wrote: > On Fri, Nov 18, 2011 at 7:51 AM, GZ wrote: > > Hi, > > > I have a class Record and a list key_attrs that specifies the names of > > all attributes that correspond to a primary key. > > > I can write a function like this to get the primary key: > > > def get_key(instance_of_record): > > ? return tuple(instance_of_record.__dict__[k] for k in key_attrs) > > > However, since key_attrs are determined at the beginning of the > > program while get_key() will be called over and over again, I am > > wondering if there is a way to dynamically generate a get_ley method > > with the key attributes expanded to avoid the list comprehension/ > > generator. > > (Accidentally sent this to the OP only) > > This is exactly what the attrgetter factory function produces. > > from operator import attrgetter > get_key = attrgetter(*key_attrs) > > But if your attribute names are variable and arbitrary, I strongly > recommend you store them in a dict instead. ?Setting them as instance > attributes risks that they might conflict with the regular attributes > and methods on your objects. > > Cheers, > Ian > > From phd at phdru.name Sun Nov 20 07:19:40 2011 From: phd at phdru.name (Oleg Broytman) Date: Sun, 20 Nov 2011 16:19:40 +0400 Subject: SQLObject 1.2.0 Message-ID: <20111120121940.GC24874@iskra.aviel.ru> Hello! I'm pleased to announce version 1.2.0, the first stable release of branch 1.2 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://pypi.python.org/pypi/SQLObject/1.2.0 News and changes: http://sqlobject.org/News.html What's New ========== Features & Interface -------------------- * Strings are treated specially in Select to allow Select(['id, 'name'], where='value = 42'). Update allows a string in WHERE. * ForeignKey('Table', refColumn='refcol_id') to allow ForeignKey to point to a non-id column; the referred column must be a unique integer column. * delColumn now accepts a ForeignKey's name without 'ID'. * Support for PostgreSQL 7.* is dropped. The minimal supported version of PostgreSQL is 8.1 now. * Quoting rules changed for PostgreSQL: SQLObject uses E'' escape string if the string contains characters escaped with backslash. * A bug caused by psycopg2 recently added a new boolean not callable autocommit attribute was fixed. * sqlobject.__doc__ and main.__doc__ no longer contain version number. Use sqlobject.version or version_info. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ phd at phdru.name Programmers don't die, they just GOSUB without RETURN. From Nikunj.Badjatya at emc.com Sun Nov 20 08:01:15 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Sun, 20 Nov 2011 08:01:15 -0500 Subject: ProgressBar - Python and Powershell In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> Can anyone throw some light on this please ! ? From: python-list-bounces+nikunj.badjatya=emc.com at python.org [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of Nikunj.Badjatya at emc.com Sent: Thursday, November 17, 2011 4:10 PM To: python-list at python.org Subject: ProgressBar - Python and Powershell Hi All, I am using Python 2.7, windows Env. I have an Installer written in Python(45%) and Powershell(55%) which is used to install Virtual Machines at specific locations. It is single threaded. I am trying to implement a ProgressBar for this installer. So that the user will come to know the progress of the installation. I am using pypi progressbar module. The top script is in python which inturns calls powershell scripts using subprocess.call() and proceeds with the installation. I am taking a shared file between python and powershell, so that diff functions can update their %age completion level in to the file. Ex. Func1() updates it to 5%, func2() will add its own 5% to it.. and so on. At the start of the (main.py) script I am creating a thread whose sole purpose would be to keep "READ" a temp file for a new entry in it. Based on this entry I can have my thread update the progressbar on the console. My questions are: 1. Can I have a better shared mechanism between python and powershell.? As I am using a file here. Reading + writing in python and writing only in powershell. ! 2. Does this thread mechanism work.? I am yet to implement and test it.! :P What can be the possible shortfalls.? Thanks Nikunj Bangalore - India -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Sun Nov 20 08:52:03 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 21 Nov 2011 00:52:03 +1100 Subject: ProgressBar - Python and Powershell In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> Message-ID: Why are you writing an installer in Python and Powershell? Just write an installer in WiX, NSIS or Inno like the rest of the sane world. Alternatively take a look at MakeMSI or the script python uses to generate there .MSI. Anything else is WAY too non-standard to consider. On Mon, Nov 21, 2011 at 12:01 AM, wrote: > Can anyone throw some light on this please ! ? > > > > > > From: python-list-bounces+nikunj.badjatya=emc.com at python.org > [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of > Nikunj.Badjatya at emc.com > Sent: Thursday, November 17, 2011 4:10 PM > To: python-list at python.org > Subject: ProgressBar - Python and Powershell > > > > Hi All, > > > > I am using Python 2.7, windows Env. > > I have an Installer written in Python(45%) and Powershell(55%) which is used > to install Virtual Machines at specific locations. It is single threaded. > > I am trying to implement a ProgressBar ?for this installer. So that the user > will come to know the progress of the installation. > > I am using pypi progressbar module. > > The top script is in python which inturns calls powershell scripts using > subprocess.call() and proceeds with the installation. > > > > I am taking a shared file between python and powershell, so that diff > functions can update their %age completion level in to the file. Ex. Func1() > updates it to 5%,? func2() will add its own 5% to it.. and so on. > > At the start of the (main.py) script I am creating a thread whose sole > purpose would be to keep ?READ? a temp file for a new entry in it. > > Based on this entry I can have my thread update the progressbar on the > console. > > > > My questions are: > > 1.?????? Can I have a better shared mechanism between python and > powershell.? ?As I am using a file here. Reading + writing in python and > writing only in powershell. ?! > > 2.?????? Does this thread mechanism work.? I am yet to implement and test > it.! :P What can be the possible shortfalls.? > > > > > Thanks > > > > Nikunj > > Bangalore - India > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From lists at cheimes.de Sun Nov 20 09:17:34 2011 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Nov 2011 15:17:34 +0100 Subject: Announcing Mii (My) Chat In-Reply-To: References: Message-ID: Am 20.11.2011 06:04, schrieb Andrew Evans: > Hello I wish to inform the list of a Python Application I am writing > entitled Mii Chat. Your choice of name is most likely to cause trouble. Nintendo has a trademark on "Mii" as part of the Wii console trademark. In Nintendo's glossary a Mii is a player's avatar. Christian From milleja46 at gmail.com Sun Nov 20 09:32:22 2011 From: milleja46 at gmail.com (Joshua Miller) Date: Sun, 20 Nov 2011 09:32:22 -0500 Subject: Announcing Mii (My) Chat In-Reply-To: References: Message-ID: I have to agree with christian.... Mii is those avatars in the nintendo wii system....I highly recommend you change the name it might be a good idea for software but the name will most likely get you in trouble On Sun, Nov 20, 2011 at 9:17 AM, Christian Heimes wrote: > Am 20.11.2011 06:04, schrieb Andrew Evans: >> Hello I wish to inform the list of a Python Application I am writing >> entitled Mii Chat. > > Your choice of name is most likely to cause trouble. Nintendo has a > trademark on "Mii" as part of the Wii console trademark. In Nintendo's > glossary a Mii is a player's avatar. > > Christian > > -- > http://mail.python.org/mailman/listinfo/python-list > From stefan_ml at behnel.de Sun Nov 20 10:03:24 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 20 Nov 2011 16:03:24 +0100 Subject: xml.dom.minidom question In-Reply-To: References: Message-ID: nivashno, 19.11.2011 22:32: > I've got this code: > > >>> dom = xml.dom.minidom.parse('myfile.xml') > >>> for testnode in dom.getElementsByTagName('tests')[0].childNodes: > ... print testnode > > When it's working on this xml: > > > something > > > I get the following: > > > > > > But when it's working on this xml: > > something > > I get this: > > > > > I always thought that xml was very precisely split up into nodes, > childnodes, etc, no matter what the whitespace between them was. But > apparently not, or am I missing something? You already got some answers to this question. I'd just like to point you to the xml.etree.(c)ElementTree packages, which are substantially faster and easier to use than minidom. Stefan From gelonida at gmail.com Sun Nov 20 10:15:05 2011 From: gelonida at gmail.com (Gelonida N) Date: Sun, 20 Nov 2011 16:15:05 +0100 Subject: Is there any way to unimport a library Message-ID: I wondered whether there is any way to un-import a library, such, that it's occupied memory and the related shared libraries are released. My usecase is following: success = False try: import lib1_version1 as lib1 import lib2_version1 as lib2 success = True except ImportError: pass if not success: try: import lib1_version2 as lib1 import lib2_version2 as lib2 success = True except importError: pass if not success: . . . Basically if I am not amble to import lib1_version1 AND lib2_version1, then I wanted to make sure, that lib1_version1 does not waste any memory At this moment this is more a thought excercise than a real issue, but I thought that perhaps somebody encountered this kind of issue and had an idea how to deal with such situations. One solution, that I could imagine is running the program a first time, detect all existing libraries and write out a config file being use the next time it is run, such, that immediately the right libs are imported. From renesd at gmail.com Sun Nov 20 10:25:07 2011 From: renesd at gmail.com (illume) Date: Sun, 20 Nov 2011 07:25:07 -0800 (PST) Subject: PyGameZine launched. See http://pygame.org for details. Message-ID: <16451527.473.1321802707273.JavaMail.geo-discussion-forums@yqan20> Hey ya, today we launched the first issue of PyGameZine. For more info, please see the pygame website: http://www.pygame.org/ cheers! From miki.tebeka at gmail.com Sun Nov 20 10:39:36 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Sun, 20 Nov 2011 07:39:36 -0800 (PST) Subject: Is there any way to unimport a library In-Reply-To: References: Message-ID: <31034729.395.1321803576950.JavaMail.geo-discussion-forums@prlm15> del sys.modules['my-module'] However if your module imported other modules, they'll still be there. If there are references to objects your module created, they'll still be there. A better option IMO is to use imp.find_module and then import. From miki.tebeka at gmail.com Sun Nov 20 10:39:36 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Sun, 20 Nov 2011 07:39:36 -0800 (PST) Subject: Is there any way to unimport a library In-Reply-To: References: Message-ID: <31034729.395.1321803576950.JavaMail.geo-discussion-forums@prlm15> del sys.modules['my-module'] However if your module imported other modules, they'll still be there. If there are references to objects your module created, they'll still be there. A better option IMO is to use imp.find_module and then import. From steve+comp.lang.python at pearwood.info Sun Nov 20 10:46:44 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 20 Nov 2011 15:46:44 GMT Subject: Is there any way to unimport a library References: Message-ID: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> On Sun, 20 Nov 2011 16:15:05 +0100, Gelonida N wrote: > I wondered whether there is any way to un-import a library, such, that > it's occupied memory and the related shared libraries are released. Not really. Python modules are objects, like everything else in Python, and can only be deleted when the garbage collector is certain that nothing else is keeping a reference to it. So long as any object, anywhere, no matter how deep in your code or in third-party code, has a reference to the module, you can't force it to be deleted. You can remove it from your application's namespace: import math result = math.sin(1.2345) del math This, however, is not sufficient to free the module, as it is cached. You can (but shouldn't!) do this as well: import sys del sys.modules['math'] But please don't delete modules from the cache unless (1) you really need to, and (2) you are prepared for the consequences. "Just in case the library uses too much memory" is not a good reason for deleting the module. The problem is, if you delete the module from the cache, but some other part of your application still holds onto a reference to the module (directly, or indirectly), the next time you import the library, Python will not use the cached version but will create a second, independent copy of the module in memory. Instead of saving memory, you have just DOUBLED the amount of memory used by the library. You may also run into bizarre, hard to debug problems due to breaking the "modules are singletons" promise. Trust me, this opens the door to a world of pain. > success = False > try: > import lib1_version1 as lib1 > import lib2_version1 as lib2 > success = True > except ImportError: > pass > if not success: > try: > import lib1_version2 as lib1 > import lib2_version2 as lib2 > success = True > except importError: > pass Can you mix lib1_version1 and lib2_version2? If so, the best way of doing this would be: try: import lib1_version1 as lib1 except ImportError: try: import lib1_version2 as lib1 except ImportError: # Last chance. If this fails, it is a fatal error. import lib1_version3 as lib1 And then do the same for lib2. > One solution, that I could imagine is running the program a first time, > detect all existing libraries and write out a config file being use the > next time it is run, such, that immediately the right libs are imported. What if the libs change between one run of your program and the next? -- Steven From gelonida at gmail.com Sun Nov 20 11:39:28 2011 From: gelonida at gmail.com (Gelonida N) Date: Sun, 20 Nov 2011 17:39:28 +0100 Subject: Is there any way to unimport a library In-Reply-To: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> References: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven, Mika, Thanks for your answers. It's always good to know which options exist. It makes it easier to choose the right one depending on the situation. On 11/20/2011 04:46 PM, Steven D'Aprano wrote: > On Sun, 20 Nov 2011 16:15:05 +0100, Gelonida N wrote: > >> I wondered whether there is any way to un-import a library, such, that >> it's occupied memory and the related shared libraries are released. > > > You can remove it from your application's namespace: > > import math > result = math.sin(1.2345) > del math > > > This, however, is not sufficient to free the module, as it is cached. You > can (but shouldn't!) do this as well: > > import sys > del sys.modules['math'] > > > The problem is, if you delete the module from the cache, but some other > part of your application still holds onto a reference to the module > (directly, or indirectly), the next time you import the library, Python > will not use the cached version but will create a second, independent > copy of the module in memory. Instead of saving memory, you have just > DOUBLED the amount of memory used by the library. You may also run into > bizarre, hard to debug problems due to breaking the "modules are > singletons" promise. > in my case only one module (the one with the try import statements) would import these libraries. >> success = False >> try: >> import lib1_version1 as lib1 >> import lib2_version1 as lib2 >> success = True >> except ImportError: >> pass >> if not success: >> try: >> import lib1_version2 as lib1 >> import lib2_version2 as lib2 >> success = True >> except importError: >> pass > > > Can you mix lib1_version1 and lib2_version2? If so, the best way of doing > this would be: > > try: > import lib1_version1 as lib1 > except ImportError: > try: > import lib1_version2 as lib1 > except ImportError: > # Last chance. If this fails, it is a fatal error. > import lib1_version3 as lib1 > No mixing would not be possible. So either I need the first two libs or the second two. > >> One solution, that I could imagine is running the program a first time, >> detect all existing libraries and write out a config file being use the >> next time it is run, such, that immediately the right libs are imported. > > What if the libs change between one run of your program and the next? > Well that's why wondered whether there is a dynamic solution. However if I'd like to force a rescan I could always just delete the config file. I think I'll look at imp.find_module as Miki suggested. In my case it should probably be enough to know whether a group of modules exist. Theoretically a module could exist, but fail to import but if in this rare situations one of the libraries stays in memory it wouldn't be the biggest issue. I'd just like to avoid that (this is not my use case, but just a (crazy) example) TKInter, wxWidgets, and pyQt were all loaded even if due I'd use only one of them due to the lack of other packages From shilparani9030 at gmail.com Sun Nov 20 11:40:47 2011 From: shilparani9030 at gmail.com (SHILPA) Date: Sun, 20 Nov 2011 08:40:47 -0800 (PST) Subject: XXX HOT PHOTOS&VIDEOS Message-ID: <53016838-1333-45fd-a347-a37220fba937@s35g2000pra.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From shilparani9030 at gmail.com Sun Nov 20 11:40:50 2011 From: shilparani9030 at gmail.com (SHILPA) Date: Sun, 20 Nov 2011 08:40:50 -0800 (PST) Subject: XXX HOT PHOTOS&VIDEOS Message-ID: <6449927a-d143-463d-b34e-5796b419879e@c16g2000pre.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From Nikunj.Badjatya at emc.com Sun Nov 20 11:40:58 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Sun, 20 Nov 2011 11:40:58 -0500 Subject: ProgressBar - Python and Powershell In-Reply-To: References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> Thanks for reply. Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am using Python. I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? The current look of the installer is completely command line based. -----Original Message----- From: Alec Taylor [mailto:alec.taylor6 at gmail.com] Sent: Sunday, November 20, 2011 7:22 PM To: Badjatya, Nikunj Cc: python-list at python.org Subject: Re: ProgressBar - Python and Powershell Why are you writing an installer in Python and Powershell? Just write an installer in WiX, NSIS or Inno like the rest of the sane world. Alternatively take a look at MakeMSI or the script python uses to generate there .MSI. Anything else is WAY too non-standard to consider. On Mon, Nov 21, 2011 at 12:01 AM, wrote: > Can anyone throw some light on this please ! ? > > > > > > From: python-list-bounces+nikunj.badjatya=emc.com at python.org > [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of > Nikunj.Badjatya at emc.com > Sent: Thursday, November 17, 2011 4:10 PM > To: python-list at python.org > Subject: ProgressBar - Python and Powershell > > > > Hi All, > > > > I am using Python 2.7, windows Env. > > I have an Installer written in Python(45%) and Powershell(55%) which is used > to install Virtual Machines at specific locations. It is single threaded. > > I am trying to implement a ProgressBar ?for this installer. So that the user > will come to know the progress of the installation. > > I am using pypi progressbar module. > > The top script is in python which inturns calls powershell scripts using > subprocess.call() and proceeds with the installation. > > > > I am taking a shared file between python and powershell, so that diff > functions can update their %age completion level in to the file. Ex. Func1() > updates it to 5%,? func2() will add its own 5% to it.. and so on. > > At the start of the (main.py) script I am creating a thread whose sole > purpose would be to keep "READ" a temp file for a new entry in it. > > Based on this entry I can have my thread update the progressbar on the > console. > > > > My questions are: > > 1.?????? Can I have a better shared mechanism between python and > powershell.? ?As I am using a file here. Reading + writing in python and > writing only in powershell. ?! > > 2.?????? Does this thread mechanism work.? I am yet to implement and test > it.! :P What can be the possible shortfalls.? > > > > > Thanks > > > > Nikunj > > Bangalore - India > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Sun Nov 20 11:53:06 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Nov 2011 03:53:06 +1100 Subject: Is there any way to unimport a library In-Reply-To: References: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Nov 21, 2011 at 3:39 AM, Gelonida N wrote: > No mixing would not be possible. > > So either I need the first two libs or the second two. > I wonder, can you make the first one import the second one? That automatically defines your dependency right there, and may make things clearer - you import lib1_version1, and if that fails, you import lib1_version2; if either succeeds, you know the matching lib2 is available. ChrisA From gelonida at gmail.com Sun Nov 20 12:21:00 2011 From: gelonida at gmail.com (Gelonida N) Date: Sun, 20 Nov 2011 18:21:00 +0100 Subject: Is there any way to unimport a library In-Reply-To: References: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: I forgot to mention, that this is at the moment more a thought experiment, than a real need. On 11/20/2011 05:53 PM, Chris Angelico wrote: > On Mon, Nov 21, 2011 at 3:39 AM, Gelonida N wrote: >> No mixing would not be possible. >> >> So either I need the first two libs or the second two. >> > > I wonder, can you make the first one import the second one? That > automatically defines your dependency right there, and may make things > clearer - you import lib1_version1, and if that fails, you import > lib1_version2; if either succeeds, you know the matching lib2 is > available. > At the moment I will do exactly what you suggested. I will make sure, that always the first import fails. But I wanted to learn more what is possible and which potential can of worms I would open if I wanted to unimport a library of which I'm sure that nobody is currently referencing (or refering? Not sure about my English here) to. From jabba.laci at gmail.com Sun Nov 20 13:06:44 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Sun, 20 Nov 2011 19:06:44 +0100 Subject: scraping a tumblr.com archive page Message-ID: Hi, I want to extract the URLs of all the posts on a tumblr blog. Let's take for instance this blog: http://loveyourchaos.tumblr.com/archive . If I download this page with a script, there are only 50 posts in the HTML. If you scroll down in your browser to the end of the archive, the browser will dynamically load newer and newer posts. How to scrape such a dynamic page? Thanks, Laszlo From benjamin.kaplan at case.edu Sun Nov 20 13:18:21 2011 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Sun, 20 Nov 2011 13:18:21 -0500 Subject: scraping a tumblr.com archive page In-Reply-To: References: Message-ID: On Sun, Nov 20, 2011 at 1:06 PM, Jabba Laci wrote: > Hi, > > I want to extract the URLs of all the posts on a tumblr blog. Let's > take for instance this blog: http://loveyourchaos.tumblr.com/archive . > If I download this page with a script, there are only 50 posts in the > HTML. If you scroll down in your browser to the end of the archive, > the browser will dynamically load newer and newer posts. > > How to scrape such a dynamic page? > > Thanks, > > Laszlo > -- The page isn't really that dynamic- HTTP doesn't allow for that. Scrolling down the page triggers some Javascript. That Javascript sends some HTTP requests to the server, which returns more HTML, which gets stuck into the middle of the page. If you take the time to monitor your network traffic using a tool like Firebug, you should be able to figure out the pattern in the requests for more content. Just send those same requests yourself and parse the results. From andrew.chapkowski at gmail.com Sun Nov 20 15:02:11 2011 From: andrew.chapkowski at gmail.com (Andrew) Date: Sun, 20 Nov 2011 12:02:11 -0800 (PST) Subject: Server Questions (2 of them) Message-ID: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Hello List, How to do you create a server that accepts a set of user code? For example, I would like to send this function: def addition(x,y): return x+y and have the socket server perform the operation and send is back to the end user. Question 2: On that same server, I want a user to be able to pass a file to the server along with code. What is the best way to pass file to the server? Thank you for any suggestions or resources you can provide. Andrew From spartan.the at gmail.com Sun Nov 20 15:44:26 2011 From: spartan.the at gmail.com (spartan.the) Date: Sun, 20 Nov 2011 12:44:26 -0800 (PST) Subject: How to insert my own module in front of site eggs? References: <1s1fp8-6la.ln1@pluto.solar-empire.de> <874ny2fzn6.fsf@no-fixed-abode.cable.virginmedia.net> Message-ID: On Nov 18, 3:36?am, Roy Smith wrote: ... > It just seems mind-boggling to me that PYTHONPATH doesn't preempt > everything else. I was surprised too, but this issue is widespread. Best explained here: https://bugs.launchpad.net/tahoe-lafs/+bug/821000/comments/0 Quote: " The crux of the problem is that the Python documentation says: "The PYTHONPATH variable can be set to a list of paths that will be added to the beginning of sys.path." http://docs.python.org/install/index.html#modifying-python-s-search-path This is true with standard distutils, false with setuptools, false with distribute... " Phillip J. Eby (setuptools guy) was religious about "easy installed" packages over anything else to comment on this issue 3 years ago: " This behavior change is unacceptable, as it makes it impossible to ensure that an easy_install-ed package takes precedence over an existing, distutils-installed version of the same package in the same PYTHONPATH directory. Please note that that is the intended default behavior of easy_install: if you wish to override it, you should use --multi-version, and explicitly select the egg(s) to be added to sys.path instead. " (http://bugs.python.org/setuptools/issue53) From sorsorday at gmail.com Sun Nov 20 16:16:26 2011 From: sorsorday at gmail.com (Herman) Date: Sun, 20 Nov 2011 13:16:26 -0800 Subject: What is the difference between "new Class()" and "Class()"? Message-ID: What is so special about the "new" operator? From rosuav at gmail.com Sun Nov 20 16:34:28 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Nov 2011 08:34:28 +1100 Subject: Server Questions (2 of them) In-Reply-To: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Message-ID: On Mon, Nov 21, 2011 at 7:02 AM, Andrew wrote: > Hello List, > > How to do you create a server that accepts a set of user code? > > For example, > > I would like to send this function: > def addition(x,y): > ? return x+y > and have the socket server perform the operation and send is back to > the end user. > > Question 2: > On that same server, I want a user to be able to pass a file to the > server along with code. ?What is the best way to pass file to the > server? The easiest way is to write an HTTP server (Python has some tools that will make this easy) and use an HTML form, which can do file uploads as well as accept keyed-in code. However, you will run into some fairly major security issues. You're accepting code across the internet and running it. Python does not protect you against malicious users reading files from your hard disk or, worse, modifying those files. This sort of thing can ONLY be used in a trusted environment - a local network on which you know everything that's happening. ChrisA From tjreedy at udel.edu Sun Nov 20 16:41:02 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Nov 2011 16:41:02 -0500 Subject: What is the difference between "new Class()" and "Class()"? In-Reply-To: References: Message-ID: On 11/20/2011 4:16 PM, Herman wrote: > What is so special about the "new" operator? There is no 'new' operator in Python. Perhaps you are thinking of javascript or maybe jave or ...? -- Terry Jan Reedy From hniksic at xemacs.org Sun Nov 20 16:44:25 2011 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Sun, 20 Nov 2011 22:44:25 +0100 Subject: Server Questions (2 of them) References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Message-ID: <8762iesc3q.fsf@xemacs.org> Andrew writes: > How to do you create a server that accepts a set of user code? [...] Look up the "exec" statement, the server can use it to execute any code received from the client as a string. Note "any code", though; exec runs in no sandbox and if a malicious client defines addition(1, 2) to execute os.system('sudo rm -rf /'), the server will happily do just that. From ben+python at benfinney.id.au Sun Nov 20 18:40:33 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 21 Nov 2011 10:40:33 +1100 Subject: What is the difference between "new Class()" and "Class()"? References: Message-ID: <87lira747i.fsf@benfinney.id.au> Herman writes: > What is so special about the "new" operator? It's special because Python doesn't have it. Can you refer us with a URL to the place where you've seen Python code containing a ?new? operator? -- \ ?Fear him, which after he hath killed hath power to cast into | `\ hell; yea, I say unto you, Fear him.? ?Jesus, as quoted in Luke | _o__) 12:5 | Ben Finney From ralf at systemexit.de Sun Nov 20 19:16:05 2011 From: ralf at systemexit.de (Ralf Schmitt) Date: Mon, 21 Nov 2011 01:16:05 +0100 Subject: [ANNOUNCE] pypiserver 0.4.0 - minimal pypi server Message-ID: <87ehx2ba9m.fsf@myhost.localnet> Hi, I've just uploaded pypiserver 0.4.0 to the python package index. pypiserver is a minimal PyPI compatible server. It can be used to serve a set of packages and eggs to easy_install or pip. pypiserver is easy to install (i.e. just easy_install pypiserver). It doesn't have any external dependencies. http://pypi.python.org/pypi/pypiserver/ should contain enough information to easily get you started running your own PyPI server in a few minutes. The code is available on github: https://github.com/schmir/pypiserver Changes in version 0.4.0 ------------------------- - add functionality to manage package updates - updated documentation - python 3 support has been added -- Cheers, Ralf From lists at cheimes.de Sun Nov 20 19:27:59 2011 From: lists at cheimes.de (Christian Heimes) Date: Mon, 21 Nov 2011 01:27:59 +0100 Subject: Server Questions (2 of them) In-Reply-To: <8762iesc3q.fsf@xemacs.org> References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> <8762iesc3q.fsf@xemacs.org> Message-ID: Am 20.11.2011 22:44, schrieb Hrvoje Niksic: > Andrew writes: > >> How to do you create a server that accepts a set of user code? > [...] > > Look up the "exec" statement, the server can use it to execute any code > received from the client as a string. > > Note "any code", though; exec runs in no sandbox and if a malicious > client defines addition(1, 2) to execute os.system('sudo rm -rf /'), the > server will happily do just that. It's possible to sandbox Python code, see http://docs.python.org/library/rexec.html, http://code.activestate.com/recipes/496746-restricted-safe-eval/ or TTW code (through the web) in Zope. However the sandboxing is limited and you really need to know what you are doing. From jehugaleahsa at gmail.com Sun Nov 20 19:46:14 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sun, 20 Nov 2011 16:46:14 -0800 (PST) Subject: Using the Python Interpreter as a Reference Message-ID: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Hello: I am currently working on designing a new programming language. It is a compiled language, but I still want to use Python as a reference. Python has a lot of similarities to my language, such as indentation for code blocks, lambdas, non-locals and my language will partially support dynamic programming. Can anyone list a good introduction to the files found in the source code? I have been poking around the source code for a little bit and there is a lot there. So, I was hoping someone could point me to the "good parts". I am also wondering whether some of the code was generated because I see state transition tables, which I doubt someone built by hand. Any help would be greatly appreciated. It will be cool to see how the interpreter works internally. I am still wonder whether designing the language (going on 4 months now) will be harder than implementing it. Thanks, Travis Parks From alan.gauld at btinternet.com Sun Nov 20 20:28:14 2011 From: alan.gauld at btinternet.com (Alan Gauld) Date: Mon, 21 Nov 2011 01:28:14 +0000 Subject: What is the difference between "new Class()" and "Class()"? In-Reply-To: References: Message-ID: On 20/11/11 21:16, Herman wrote: > What is so special about the "new" operator? Assuming you mean the __new__() method? __new__() gets called when the class is being constructed, it returns the new instance. It is the real Pyhon constructor. As opposed to __init__() which is called after the instance has been created. It is not really a constructor but an initializer. (Even though most of us treat it as a constructor!) But you should never see code like meat = new Spam(). it should be meat = Spam() Which calls __new__() followed by __init__(). HTH -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ From jabba.laci at gmail.com Sun Nov 20 21:09:46 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Mon, 21 Nov 2011 03:09:46 +0100 Subject: scraping a tumblr.com archive page In-Reply-To: References: Message-ID: Hi, Thanks for the answer. Finally I found an API for this task: http://www.tumblr.com/docs/en/api/v2#posts . It returns the required data in JSON format. Laszlo > The page isn't really that dynamic- HTTP doesn't allow for that. > Scrolling down the page triggers some Javascript. That Javascript > sends some HTTP requests to the server, which returns more HTML, which > gets stuck into the middle of the page. If you take the time to > monitor your network traffic using a tool like Firebug, you should be > able to figure out the pattern in the requests for more content. Just > send those same requests yourself and parse the results. From loluengo at gmail.com Sun Nov 20 21:16:58 2011 From: loluengo at gmail.com (Lorenzo) Date: Sun, 20 Nov 2011 18:16:58 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <90f6dc69-1b8a-49d7-aa00-662c6baefda5@n14g2000vbn.googlegroups.com> On Nov 15, 11:51?pm, Carl Banks wrote: > Some people have already made an LLVM-to-Javascript compiler, and have managed to build Python 2.7 with it. > > The LLVM-to-Javascript project is called emscripten. > > https://github.com/kripken/emscripten/wiki > > Demo of Python (and a bunch of other languages) here: > > http://repl.it/ > > Carl Banks It definitely looks great!! From rosuav at gmail.com Sun Nov 20 21:33:21 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Nov 2011 13:33:21 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: On Mon, Nov 21, 2011 at 11:46 AM, Travis Parks wrote: > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. If you want to use Python as a reference for designing your language, look at the documentation. It's pretty decent on the subject of language specs (you may find yourself reading a lot of PEPs as well as the "normal" docs). But for actual code - you may want to look at Cython. I've never used it, but it compiles Python code to C (IIRC); that's more likely to be what you're after. What's your language's "special feature"? I like to keep track of languages using a "slug" - a simple one-sentence (or less) statement of when it's right to use this language above others. For example, Python is optimized for 'rapid deployment'. ChrisA From drsalists at gmail.com Sun Nov 20 21:55:21 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 20 Nov 2011 18:55:21 -0800 Subject: Using the Python Interpreter as a Reference In-Reply-To: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: On Sun, Nov 20, 2011 at 4:46 PM, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. > FWIW, comprehensions are often nicer than lambdas. You might want to check out PyPy. It's written in a more flexible implementation language than CPython, and facilitates writing languages - IOW, PyPy is more than just Python written in Python. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wuwei23 at gmail.com Sun Nov 20 23:26:30 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 20 Nov 2011 20:26:30 -0800 (PST) Subject: Server Questions (2 of them) References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> <8762iesc3q.fsf@xemacs.org> Message-ID: <4e7f81b4-f394-40fa-91ff-fcc6a27d9a1c@k5g2000pre.googlegroups.com> On Nov 21, 10:27?am, Christian Heimes wrote: > It's possible to sandbox Python code, see > http://docs.python.org/library/rexec.html Although this has been deprecated since 2.6 & removed from 3.x (and cautioned against for as long as I've used Python). PyPy provides some sandboxing functionality that might be useful here: http://codespeak.net/pypy/dist/pypy/doc/sandbox.html From wuwei23 at gmail.com Sun Nov 20 23:58:33 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 20 Nov 2011 20:58:33 -0800 (PST) Subject: Is there any way to unimport a library References: Message-ID: <81b06056-9928-4871-8452-feb681bbc0d0@a3g2000prd.googlegroups.com> On Nov 21, 1:15?am, Gelonida N wrote: > I wondered whether there is any way to un-import a library, such, that > it's occupied ?memory and the related shared libraries are released. > > My usecase is following: > > success = False > try: > ? ? import lib1_version1 as lib1 > ? ? import lib2_version1 as lib2 > ? ? success = True > except ImportError: > ? ? pass > if not success: > ? ? try: > ? ? ? ? import lib1_version2 as lib1 > ? ? ? ? import lib2_version2 as lib2 > ? ? ? ? success = True > ? ? except importError: > ? ? ? ? pass > if not success: > ? ? . . . > > Basically if I am not amble to import lib1_version1 AND lib2_version1, > then I wanted to make sure, that lib1_version1 does not waste any memory A simple way would be to create packages for each version that import the two dependencies: /version1/__init__.py: import lib1_version1 as lib1 import lib2_version2 as lib2 /version2/__init__.py: import lib1_version2 as lib1 import lib2_version2 as lib2 Then create a single module to handle the importing: /libraries.py: __all__ = ['lib1', 'lib2', 'version'] version = None _import_errs = [] try: from version1 import lib1, lib2 version = 1 except ImportError as (err,): _import_errs.append(err) if version is None: try: from version2 import lib1, lib2 version = 2 except ImportError as (err,): _import_errs.append(err) if version is None: _format_errs = (('v%d: %s' % (ver, err)) for ver, err in enumerate(_import_errs, 1)) raise ImportError('Unable to import libraries: %s' % list(_format_errs)) From wuwei23 at gmail.com Mon Nov 21 00:04:50 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 20 Nov 2011 21:04:50 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <0296a730-c952-4f14-99ca-a63a9fe96096@k5g2000pre.googlegroups.com> On Nov 19, 3:59?am, "W. eWatson" wrote: > Yes. I tried running it. Got nowhere. Did you run it from the shell? Did it spit out any errors? From wuwei23 at gmail.com Mon Nov 21 00:09:24 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 20 Nov 2011 21:09:24 -0800 (PST) Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 References: Message-ID: <70f026ae-9a6d-42de-880d-c1e430275e7c@13g2000prw.googlegroups.com> On Nov 19, 8:31?am, Stephen Hansen wrote: > Yes, its moderately annoying that you have to do this yourself; maybe > you wouldn't if you installed 64-bit python, but I can't be sure. Maybe > it has nothing to do with 32 or 64-bitness at all and my guess is wrong. I've got the 32 bit version of 2.7 & the 64 bit of 3.2 installed under Windows 7. I'm not seeing 'Edit with IDLE' options, instead I get 'Edit with Pythonwin' from the 32bit installation. I'm also using ActivePython, though. I can honestly say I've never had an issue under Windows with it. From steve+comp.lang.python at pearwood.info Mon Nov 21 00:44:56 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Nov 2011 05:44:56 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <4ec9e558$0$29997$c3e8da3$5496439d@news.astraweb.com> On Mon, 21 Nov 2011 13:33:21 +1100, Chris Angelico wrote: > What's your language's "special feature"? I like to keep track of > languages using a "slug" - a simple one-sentence (or less) statement of > when it's right to use this language above others. For example, Python > is optimized for 'rapid deployment'. "Python will save the world" http://proyectojuanchacon.blogspot.com/2010/07/saving-world-with-python.html -- Steven From zyzhu2000 at gmail.com Mon Nov 21 00:46:35 2011 From: zyzhu2000 at gmail.com (GZ) Date: Sun, 20 Nov 2011 21:46:35 -0800 (PST) Subject: Close as Many Files/External resourcs as possible in the face of exceptions Message-ID: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> Hi, Here is my situation. A parent object owns a list of files (or other objects with a close() method). The close() method can sometimes fail and raise an exception. When the parent object's close() method is called, it needs to close down as many files it owns as possible, even if the close() function of some files fail. I also want to re-raise at least one of the original exceptions so that the outer program can handle it. What I come up is something like this, suppose L is a list that holds all the file objects. is_closed = set() try: for f in L: f.close() is_closed.add(f) except: try: raise #re-raise immediately, keeping context intact finally: for f in L: # close the rest of the file objects if f not in is_closed: try: f.close() except: pass It will re-raise the first exception and preserve the context and close as many other files as possible while ignoring any further exceptions. But this looks really awkward. And in the case that two files fail to close, I am not sure the best strategy is to ignore the second failure. What is a better way of handling such situation? Thanks, gz From nizamov.shawkat at gmail.com Mon Nov 21 01:28:03 2011 From: nizamov.shawkat at gmail.com (Nizamov Shawkat) Date: Mon, 21 Nov 2011 07:28:03 +0100 Subject: Server Questions (2 of them) In-Reply-To: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> References: <4c5cedc5-65e4-4bca-a7fe-7afffde79c88@s6g2000vbc.googlegroups.com> Message-ID: 2011/11/20 Andrew : > Hello List, > > How to do you create a server that accepts a set of user code? > > For example, > > I would like to send this function: > def addition(x,y): > ? return x+y > and have the socket server perform the operation and send is back to > the end user. > > Question 2: > On that same server, I want a user to be able to pass a file to the > server along with code. ?What is the best way to pass file to the > server? > > > Thank you for any suggestions or resources you can provide. > > Andrew > -- > http://mail.python.org/mailman/listinfo/python-list > Check for Pyro - it allows creation of objects on client side while running them on server side. Pyro makes this process almost transparent using proxy objects. Hope it helps, S.Nizamov From alec.taylor6 at gmail.com Mon Nov 21 01:28:55 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 21 Nov 2011 17:28:55 +1100 Subject: ProgressBar - Python and Powershell In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> Message-ID: So you're executing Powershell commands into Virtual Machines? Add this into the installer (probably WiX is your best bet) On Mon, Nov 21, 2011 at 3:40 AM, wrote: > Thanks for reply. > Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). > Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am ?using Python. > > I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? > > The current look of the installer is completely command line based. > > > -----Original Message----- > From: Alec Taylor [mailto:alec.taylor6 at gmail.com] > Sent: Sunday, November 20, 2011 7:22 PM > To: Badjatya, Nikunj > Cc: python-list at python.org > Subject: Re: ProgressBar - Python and Powershell > > Why are you writing an installer in Python and Powershell? > > Just write an installer in WiX, NSIS or Inno like the rest of the sane world. > > Alternatively take a look at MakeMSI or the script python uses to > generate there .MSI. > > Anything else is WAY too non-standard to consider. > > On Mon, Nov 21, 2011 at 12:01 AM, ? wrote: >> Can anyone throw some light on this please ! ? >> >> >> >> >> >> From: python-list-bounces+nikunj.badjatya=emc.com at python.org >> [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of >> Nikunj.Badjatya at emc.com >> Sent: Thursday, November 17, 2011 4:10 PM >> To: python-list at python.org >> Subject: ProgressBar - Python and Powershell >> >> >> >> Hi All, >> >> >> >> I am using Python 2.7, windows Env. >> >> I have an Installer written in Python(45%) and Powershell(55%) which is used >> to install Virtual Machines at specific locations. It is single threaded. >> >> I am trying to implement a ProgressBar ?for this installer. So that the user >> will come to know the progress of the installation. >> >> I am using pypi progressbar module. >> >> The top script is in python which inturns calls powershell scripts using >> subprocess.call() and proceeds with the installation. >> >> >> >> I am taking a shared file between python and powershell, so that diff >> functions can update their %age completion level in to the file. Ex. Func1() >> updates it to 5%,? func2() will add its own 5% to it.. and so on. >> >> At the start of the (main.py) script I am creating a thread whose sole >> purpose would be to keep "READ" a temp file for a new entry in it. >> >> Based on this entry I can have my thread update the progressbar on the >> console. >> >> >> >> My questions are: >> >> 1.?????? Can I have a better shared mechanism between python and >> powershell.? ?As I am using a file here. Reading + writing in python and >> writing only in powershell. ?! >> >> 2.?????? Does this thread mechanism work.? I am yet to implement and test >> it.! :P What can be the possible shortfalls.? >> >> >> >> >> Thanks >> >> >> >> Nikunj >> >> Bangalore - India >> >> >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > From rosuav at gmail.com Mon Nov 21 01:48:45 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Nov 2011 17:48:45 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ec9e558$0$29997$c3e8da3$5496439d@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4ec9e558$0$29997$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Nov 21, 2011 at 4:44 PM, Steven D'Aprano wrote: > On Mon, 21 Nov 2011 13:33:21 +1100, Chris Angelico wrote: > >> What's your language's "special feature"? I like to keep track of >> languages using a "slug" - a simple one-sentence (or less) statement of >> when it's right to use this language above others. For example, Python >> is optimized for 'rapid deployment'. > > "Python will save the world" > > http://proyectojuanchacon.blogspot.com/2010/07/saving-world-with-python.html I don't think Python has a hard disk big enough to save all of it... ChrisA From john.37 at gmail.com Mon Nov 21 02:15:21 2011 From: john.37 at gmail.com (sword) Date: Sun, 20 Nov 2011 23:15:21 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> <4f5fd473-4717-4f41-8017-d7407adc4571@u10g2000prl.googlegroups.com> <5dfa9add-582f-4219-8d78-01239f80525e@p5g2000vbm.googlegroups.com> Message-ID: <066c8586-dd11-4982-ab3a-5ff77db46b90@a3g2000prd.googlegroups.com> On Nov 20, 8:42?am, Vinay Sajip wrote: > On Nov 17, 9:06?am, sword wrote: > > > > > > > > > > > On Nov 16, 10:50?pm, Peter Otten <__pete... at web.de> wrote: > > > > sword wrote: > > > > Thanks for your reply. I tried to edit the source a bit, now the > > > > main.py looks like this: > > > > #main.py > > > > importlogging > > > > fromloggingimport Filter > > > > import a > > > > import b > > > > >logging.basicConfig(level=logging.DEBUG) > > > > root =logging.getLogger() > > > > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > > > > would pass this filter > > > > > logger =logging.getLogger("main") > > > > logger.debug("main process") > > > > a.print_log() > > > > b.print_log() > > > > > #### > > > > And It still prints out all the log msg. :( > > > > Here's a little demo to explore how filtering works: > > > > $ cat demo.py > > > importlogging > > > class Filter(logging.Filter): > > > ? ? def filter(self, record): > > > ? ? ? ? print "applying filter", self.name > > > ? ? ? ? return True > > > >logging.basicConfig() > > > > loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]] > > > for logger in loggers: > > > ? ? logger.addFilter(Filter("filter@" + logger.name)) > > > > [handler] =logging.getLogger().handlers > > > handler.addFilter(Filter("filter at handler")) > > > > for logger in loggers: > > > ? ? logger.critical("whatever") > > > $ python demo.py > > > applying filter filter at root > > > applying filter filter at handler > > > CRITICAL:root:whatever > > > applying filter filter at a > > > applying filter filter at handler > > > CRITICAL:a:whatever > > > applying filter fil... at a.b > > > applying filter filter at handler > > > CRITICAL:a.b:whatever > > > $ > > > > As you can infer from the output only the filter(s) of the original logger > > > and of the handler(s) are applied. > > > Thanks, so if I want to see my own log out of all logs produced by > > different module in the project, I should addFilter to each > > corresponding logger. I thought I could add Filter in root and filter > > out only the interested info from it before. > > Or you can add a filter to the handler (but then you can't use > basicConfig() to configure it - you need to do it explicitly). > > Regards, > > Vinay Sajip Thank you! Maybe I should find out another way to manipulate the log, like wrap the getLogger function and add the filter at the first time :) From ysh1989 at gmail.com Mon Nov 21 02:32:29 2011 From: ysh1989 at gmail.com (=?UTF-8?B?6aG66IiqIOa4uA==?=) Date: Sun, 20 Nov 2011 23:32:29 -0800 (PST) Subject: request of "real timeout" in socket.read Message-ID: Hi, few days ago I was confused with the behavior of socket.read when timeout is used -- that the lifespan of the operation often is longer than the time I've specified. So I go to python.org and get the source code of python. Yet I had read some lines of code from the Python-2.7.2/Modules/ socketmodule.c, and I found that the function was implemented in internal_select by poll or select, this function will block at most a span of timeout, so whenever it is called, another timeout time has to be wasted if there's nothing coming. So what if to change the code like this: now = time(NULL); //may be other function if( s->sock_timeout >= now + .5 ) return 1; timeout = s->sock_timeout + .5 - now; /* ... poll or select */ here s->sock_timeout is a particular moment rather than a time span, or: s->sock_timeout = time(NULL) + timeout; when init. From john.37 at gmail.com Mon Nov 21 02:33:47 2011 From: john.37 at gmail.com (sword) Date: Sun, 20 Nov 2011 23:33:47 -0800 (PST) Subject: Interesting problem about uuid1 Message-ID: My colleague asks me an interesting problem about uuid library in python. In multicore system with multiprocessing, is it possible to get the duplicated uuid with uuid1? I just check the RFC 4122, and I can't find anything about multicore environment. Python's uuid1 method generates the uuid with time stamp, mac address, and algorithm to gen random numbers. So, I think it's possible to get the duplicate uuid1 at the same time. What about you? Hope for your reply From brenNOSPAMbarn at NObrenSPAMbarn.net Mon Nov 21 02:41:02 2011 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Mon, 21 Nov 2011 07:41:02 +0000 (UTC) Subject: (don't bash me too hard) Python interpreter in JavaScript References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: Carl Banks wrote: > Some people have already made an LLVM-to-Javascript compiler, and > have managed to build Python 2.7 with it. > > The LLVM-to-Javascript project is called emscripten. > > https://github.com/kripken/emscripten/wiki > > Demo of Python (and a bunch of other languages) here: > > http://repl.it/ Very interesting. Is there a simple way to add third-party libraries to these? I assume that for pure-Python modules you could just put a python file in the appropriate place and import it, but what about if you wanted a web app that used numpy or something? Is that feasible? -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From kai.diefenbach at iqpp.de Mon Nov 21 03:11:35 2011 From: kai.diefenbach at iqpp.de (Kai) Date: Mon, 21 Nov 2011 09:11:35 +0100 Subject: LFS 0.6 beta 1 released Message-ID: Hi, I'm happy to announce the release of LFS 0.6 beta 1. LFS is an online shop based on Django and jQuery. If you want to read more information please refer to: http://www.getlfs.com/released-06-beta-1 Thanks Kai From vincent.vandevyvre at swing.be Mon Nov 21 03:56:39 2011 From: vincent.vandevyvre at swing.be (Vincent Vande Vyvre) Date: Mon, 21 Nov 2011 09:56:39 +0100 Subject: Close as Many Files/External resourcs as possible in the face of exceptions In-Reply-To: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> References: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> Message-ID: <4ECA1247.8060500@swing.be> An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Mon Nov 21 04:07:53 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 21 Nov 2011 20:07:53 +1100 Subject: (don't bash me too hard) Python interpreter in JavaScript In-Reply-To: References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: Just compile your python to C :] On Mon, Nov 21, 2011 at 6:41 PM, OKB (not okblacke) wrote: > Carl Banks wrote: > >> Some people have already made an LLVM-to-Javascript compiler, and >> have managed to build Python 2.7 with it. >> >> The LLVM-to-Javascript project is called emscripten. >> >> https://github.com/kripken/emscripten/wiki >> >> Demo of Python (and a bunch of other languages) here: >> >> http://repl.it/ > > ? ? ? ?Very interesting. ?Is there a simple way to add third-party > libraries to these? ?I assume that for pure-Python modules you could > just put a python file in the appropriate place and import it, but what > about if you wanted a web app that used numpy or something? ?Is that > feasible? > > -- > --OKB (not okblacke) > Brendan Barnwell > "Do not follow where the path may lead. ?Go, instead, where there is > no path, and leave a trail." > ? ? ? ?--author unknown > -- > http://mail.python.org/mailman/listinfo/python-list From vinay_sajip at yahoo.co.uk Mon Nov 21 05:11:17 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 21 Nov 2011 02:11:17 -0800 (PST) Subject: Got some problems when using logging Filter References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> <4f5fd473-4717-4f41-8017-d7407adc4571@u10g2000prl.googlegroups.com> <5dfa9add-582f-4219-8d78-01239f80525e@p5g2000vbm.googlegroups.com> <066c8586-dd11-4982-ab3a-5ff77db46b90@a3g2000prd.googlegroups.com> Message-ID: <2169ee84-a59a-4d52-977b-00200deffc1a@m19g2000yqh.googlegroups.com> On Nov 21, 7:15?am, sword wrote: > > Thank you! Maybe I should find out another way to manipulate the log, > like wrap the getLogger function and add the filter at the first > time :) If you are using Python 2.7, 3.2 or later, you can use dictionary- based configuration - it's fairly painless. http://docs.python.org/library/logging.config.html#logging.config.dictConfig If you are using an earlier version of Python, the logutils project includes the same dictionary-based configuration logic. http://code.google.com/p/logutils/ Regards, Vinay Sajip From Nikunj.Badjatya at emc.com Mon Nov 21 05:44:17 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Mon, 21 Nov 2011 05:44:17 -0500 Subject: ProgressBar - Python and Powershell In-Reply-To: References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D3E9@MX34A.corp.emc.com> Yes I am executing powershell commands into virtual machines. Will have a look at WiX. But please, Answer my questions: >> My questions are: >> >> 1. Can I have a better shared mechanism between python and >> powershell.? As I am using a file here. Reading + writing in python and >> writing only in powershell. ! >> >> 2. Does this thread mechanism work.? I am yet to implement and test >> it.! :P What can be the possible shortfalls.? Thanks Nikunj -----Original Message----- From: Alec Taylor [mailto:alec.taylor6 at gmail.com] Sent: Monday, November 21, 2011 11:59 AM To: Badjatya, Nikunj Cc: python-list at python.org Subject: Re: ProgressBar - Python and Powershell So you're executing Powershell commands into Virtual Machines? Add this into the installer (probably WiX is your best bet) On Mon, Nov 21, 2011 at 3:40 AM, wrote: > Thanks for reply. > Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). > Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am ?using Python. > > I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? > > The current look of the installer is completely command line based. > > > -----Original Message----- > From: Alec Taylor [mailto:alec.taylor6 at gmail.com] > Sent: Sunday, November 20, 2011 7:22 PM > To: Badjatya, Nikunj > Cc: python-list at python.org > Subject: Re: ProgressBar - Python and Powershell > > Why are you writing an installer in Python and Powershell? > > Just write an installer in WiX, NSIS or Inno like the rest of the sane world. > > Alternatively take a look at MakeMSI or the script python uses to > generate there .MSI. > > Anything else is WAY too non-standard to consider. > > On Mon, Nov 21, 2011 at 12:01 AM, ? wrote: >> Can anyone throw some light on this please ! ? >> >> >> >> >> >> From: python-list-bounces+nikunj.badjatya=emc.com at python.org >> [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of >> Nikunj.Badjatya at emc.com >> Sent: Thursday, November 17, 2011 4:10 PM >> To: python-list at python.org >> Subject: ProgressBar - Python and Powershell >> >> >> >> Hi All, >> >> >> >> I am using Python 2.7, windows Env. >> >> I have an Installer written in Python(45%) and Powershell(55%) which is used >> to install Virtual Machines at specific locations. It is single threaded. >> >> I am trying to implement a ProgressBar ?for this installer. So that the user >> will come to know the progress of the installation. >> >> I am using pypi progressbar module. >> >> The top script is in python which inturns calls powershell scripts using >> subprocess.call() and proceeds with the installation. >> >> >> >> I am taking a shared file between python and powershell, so that diff >> functions can update their %age completion level in to the file. Ex. Func1() >> updates it to 5%,? func2() will add its own 5% to it.. and so on. >> >> At the start of the (main.py) script I am creating a thread whose sole >> purpose would be to keep "READ" a temp file for a new entry in it. >> >> Based on this entry I can have my thread update the progressbar on the >> console. >> >> >> >> My questions are: >> >> 1.?????? Can I have a better shared mechanism between python and >> powershell.? ?As I am using a file here. Reading + writing in python and >> writing only in powershell. ?! >> >> 2.?????? Does this thread mechanism work.? I am yet to implement and test >> it.! :P What can be the possible shortfalls.? >> >> >> >> >> Thanks >> >> >> >> Nikunj >> >> Bangalore - India >> >> >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > From jeanmichel at sequans.com Mon Nov 21 06:39:20 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 21 Nov 2011 12:39:20 +0100 Subject: Got some problems when using logging Filter In-Reply-To: References: <5b246f46-ca59-43a4-b9a6-29fdfc86822e@j19g2000pro.googlegroups.com> Message-ID: <4ECA3868.8010905@sequans.com> sword wrote: > On Nov 16, 7:40 pm, Jean-Michel Pichavant > wrote: > >> sword wrote: >> >>> The logging cookbook gives an Filter example, explainning how to add >>> contextural info to log. I can't figure out how to filter log from it. >>> >>> Suppose I have 3 file, a.py, b.py and main.py >>> #file: a.py >>> import logging >>> >>> logger=logging.getLogger(__name__) >>> def print_log(): >>> logger.debug("I'm module a") >>> >>> #file: b.py just like a.py >>> import logging >>> logger=logging.getLogger(__name__) >>> def print_log(): >>> logger.debug("I'm module b") >>> >>> #file: main.py >>> import logging >>> from logging import Filter >>> logging.basicConfig(level=logging.DEBUG) >>> logger=logging.getLogger("main") >>> logger.debug("This is main process") >>> logger.addFilter(Filter("a")) >>> >>> And I expected that the console output would contain main and b module >>> log only. But it turned out that all logs there. Is it the problem of >>> root logger? >>> >> Hi, >> >> First of all, in the code you provided we can't see where you import a & >> b, and when you call their respective print_log method. >> Secondly,Filter("a") would allow only the "a" log events, not forbid >> them. quoting the docs: "if name is specified, it names a logger which, >> together with its children, will have its events allowed through the >> filter." >> >> As for your problem it may come from the fact that you applied the >> filter to the 'main' logger, while you probably want to add the filter >> to the *root* logger. Your current hierarchy is >> >> root >> - main >> - a >> - b >> >> events fired from 'a' will be handled by the root logger, not the main. >> root = logging.getLogger() >> root.addFilter('main') >> root.addFilter('a') >> root.addFilter('b') >> >> JM >> > > Thanks for your reply. I tried to edit the source a bit, now the > main.py looks like this: > #main.py > import logging > from logging import Filter > import a > import b > > logging.basicConfig(level=logging.DEBUG) > root = logging.getLogger() > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg > would pass this filter > > logger = logging.getLogger("main") > logger.debug("main process") > a.print_log() > b.print_log() > > #### > And It still prints out all the log msg. :( > You need to add you filter to the handler(s) of the root logger, not the root logger itself. Filters to loggger object are applied only when the log event is raised, i.e. when one of the logging method error, info, warning, debug is called. In your case, log events are raised by other loggers than the root logger, so its filter will not apply. However any filter applied to the root *handlers* will be applied to any log processed by the handler, including log event raised by sub-logger. root.handlers[-1].addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg JM Quoting http://docs.python.org/library/logging.html#filter-objects "Note that filters attached to handlers are consulted whenever an event is emitted by the handler, whereas filters attached to loggers are consulted whenever an event is logged to the handler (using debug(), info(), etc.) This means that events which have been generated by descendant loggers will not be filtered by a logger?s filter setting, unless the filter has also been applied to those descendant loggers." From mwilson at the-wire.com Mon Nov 21 07:09:11 2011 From: mwilson at the-wire.com (Mel Wilson) Date: Mon, 21 Nov 2011 07:09:11 -0500 Subject: Close as Many Files/External resourcs as possible in the face of exceptions References: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> Message-ID: GZ wrote: > Here is my situation. A parent object owns a list of files (or other > objects with a close() method). The close() method can sometimes fail > and raise an exception. When the parent object's close() method is > called, it needs to close down as many files it owns as possible, even > if the close() function of some files fail. I also want to re-raise at > least one of the original exceptions so that the outer program can > handle it. [ ... ] > > It will re-raise the first exception and preserve the context and > close as many other files as possible while ignoring any further > exceptions. > > But this looks really awkward. And in the case that two files fail to > close, I am not sure the best strategy is to ignore the second > failure. I imagine you could save any caught exception instances in a list and study them later. Mel. From ahsanbagwan at gmail.com Mon Nov 21 07:13:29 2011 From: ahsanbagwan at gmail.com (sl33k) Date: Mon, 21 Nov 2011 04:13:29 -0800 (PST) Subject: Format the ouput in my python code Message-ID: <3f23c6ac-0554-4cb7-bf7c-b98c29721796@z22g2000prd.googlegroups.com> I am printing the numbers from 1 to 100. In that, I want to display multiples of 3,5 and of both as mulof3, mul0f5 and mulof3and5 respectively. I am getting the output I want but I would like to format the output to print only 10 number per line. How do I go about doing this? for i in range(1, 101): if i % 3 == 0: if i % 5 == 0: print 'mulof3and5', else: print 'mulof3', elif i % 5 == 0: print 'mulof5', else: print i From Nikunj.Badjatya at emc.com Mon Nov 21 07:27:47 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Mon, 21 Nov 2011 07:27:47 -0500 Subject: ProgressBar - Python and Powershell In-Reply-To: References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D3E9@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D401@MX34A.corp.emc.com> Hey Thanks. Will do that. Just a question in general. Is it possible that we have opened one file in r+ mode ( file1.txt ). We have 2 threads, thread1 will continuously only read the file in a loop. Thread2 will only update the data in the file. Now thread2 has called other script ( written in say Perl/Powershell ) and those scripts are inturn updating ( only writing ) into that file by their own file i/o mechanism. Is it possible by any chance? One file being shared between different processes one is updating and other is reading ..? Will this work in practical and what can be the complications ? -----Original Message----- From: Alec Taylor [mailto:alec.taylor6 at gmail.com] Sent: Monday, November 21, 2011 5:23 PM To: Badjatya, Nikunj Subject: Re: ProgressBar - Python and Powershell WiX will manage all the progress bar stuff for you. Just wrap it all in On Mon, Nov 21, 2011 at 9:44 PM, wrote: > Yes I am executing powershell commands into virtual machines. > > Will have a look at WiX. > > But please, Answer my questions: > >>> My questions are: >>> >>> 1. ? ? ? Can I have a better shared mechanism between python and >>> powershell.? ?As I am using a file here. Reading + writing in python and >>> writing only in powershell. ?! >>> >>> 2. ? ? ? Does this thread mechanism work.? I am yet to implement and test >>> it.! :P What can be the possible shortfalls.? > > Thanks > Nikunj > > -----Original Message----- > From: Alec Taylor [mailto:alec.taylor6 at gmail.com] > Sent: Monday, November 21, 2011 11:59 AM > To: Badjatya, Nikunj > Cc: python-list at python.org > Subject: Re: ProgressBar - Python and Powershell > > So you're executing Powershell commands into Virtual Machines? > > Add this into the installer (probably WiX is your best bet) > > On Mon, Nov 21, 2011 at 3:40 AM, ? wrote: >> Thanks for reply. >> Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). >> Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am ?using Python. >> >> I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? >> >> The current look of the installer is completely command line based. >> >> >> -----Original Message----- >> From: Alec Taylor [mailto:alec.taylor6 at gmail.com] >> Sent: Sunday, November 20, 2011 7:22 PM >> To: Badjatya, Nikunj >> Cc: python-list at python.org >> Subject: Re: ProgressBar - Python and Powershell >> >> Why are you writing an installer in Python and Powershell? >> >> Just write an installer in WiX, NSIS or Inno like the rest of the sane world. >> >> Alternatively take a look at MakeMSI or the script python uses to >> generate there .MSI. >> >> Anything else is WAY too non-standard to consider. >> >> On Mon, Nov 21, 2011 at 12:01 AM, ? wrote: >>> Can anyone throw some light on this please ! ? >>> >>> >>> >>> >>> >>> From: python-list-bounces+nikunj.badjatya=emc.com at python.org >>> [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of >>> Nikunj.Badjatya at emc.com >>> Sent: Thursday, November 17, 2011 4:10 PM >>> To: python-list at python.org >>> Subject: ProgressBar - Python and Powershell >>> >>> >>> >>> Hi All, >>> >>> >>> >>> I am using Python 2.7, windows Env. >>> >>> I have an Installer written in Python(45%) and Powershell(55%) which is used >>> to install Virtual Machines at specific locations. It is single threaded. >>> >>> I am trying to implement a ProgressBar ?for this installer. So that the user >>> will come to know the progress of the installation. >>> >>> I am using pypi progressbar module. >>> >>> The top script is in python which inturns calls powershell scripts using >>> subprocess.call() and proceeds with the installation. >>> >>> >>> >>> I am taking a shared file between python and powershell, so that diff >>> functions can update their %age completion level in to the file. Ex. Func1() >>> updates it to 5%,? func2() will add its own 5% to it.. and so on. >>> >>> At the start of the (main.py) script I am creating a thread whose sole >>> purpose would be to keep "READ" a temp file for a new entry in it. >>> >>> Based on this entry I can have my thread update the progressbar on the >>> console. >>> >>> >>> >>> My questions are: >>> >>> 1.?????? Can I have a better shared mechanism between python and >>> powershell.? ?As I am using a file here. Reading + writing in python and >>> writing only in powershell. ?! >>> >>> 2.?????? Does this thread mechanism work.? I am yet to implement and test >>> it.! :P What can be the possible shortfalls.? >>> >>> >>> >>> >>> Thanks >>> >>> >>> >>> Nikunj >>> >>> Bangalore - India >>> >>> >>> >>> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >>> >> > From santosdosreis at gmail.com Mon Nov 21 08:05:30 2011 From: santosdosreis at gmail.com (Jayson Santos) Date: Mon, 21 Nov 2011 05:05:30 -0800 (PST) Subject: New memcached module Message-ID: <9f3e0c68-3057-4a65-90f8-5e05f82c5aae@y7g2000vbe.googlegroups.com> Hi guys, I have created a pure python module [1] to work with memcached in binary protocol with SASL authentication. I need some contributors or people to discuss some idead about it, anyone is free to contact me, any help will be appreciated. Thank You Jayson Reis [1] https://github.com/jaysonsantos/python-binary-memcached From jeanmichel at sequans.com Mon Nov 21 08:06:18 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 21 Nov 2011 14:06:18 +0100 Subject: Is there any way to unimport a library In-Reply-To: References: Message-ID: <4ECA4CCA.5050308@sequans.com> Gelonida N wrote: > I wondered whether there is any way to un-import a library, such, that > it's occupied memory and the related shared libraries are released. > > > My usecase is following: > > > success = False > try: > import lib1_version1 as lib1 > import lib2_version1 as lib2 > success = True > except ImportError: > pass > if not success: > try: > import lib1_version2 as lib1 > import lib2_version2 as lib2 > success = True > except importError: > pass > if not success: > . . . > > > > Basically if I am not amble to import lib1_version1 AND lib2_version1, > then I wanted to make sure, that lib1_version1 does not waste any memory > > > At this moment this is more a thought excercise than a real issue, but I > thought that perhaps somebody encountered this kind of issue and had an > idea how to deal with such situations. > > One solution, that I could imagine is running the program a first time, > detect all existing libraries and write out a config file being use > the next time it is run, such, that immediately the right libs are imported. > > Short answer for unimporting modules : Not possible (yes there is a long one :o) ). One approach to your problem is to test for module existence before importing any module. import imp def impVersion(version) try: imp.find_module('lib1_version%s' % version) imp.find_module('lib2_version%s' % version) except ImportError: raise else: lib1 = __import__('lib1_version%s' % version) lib2 = __import__('lib2_version%s' % version) # using a for loop to avoid to many nested try statement for version in [1,2,3,4]: try: impVersion(version) except ImportError: continue break if not lib1 or not lib2: # no lib imported pass Using this code allows you to import your library only if all conditions are met, preventing you from rolling back in case of error. Jean-Michel From alec.taylor6 at gmail.com Mon Nov 21 08:08:29 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Tue, 22 Nov 2011 00:08:29 +1100 Subject: ProgressBar - Python and Powershell In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D401@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D184@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D352@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D355@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D3E9@MX34A.corp.emc.com> <599CEBACD49B4144A61212D837EE3C0F144604D401@MX34A.corp.emc.com> Message-ID: New thread! On Mon, Nov 21, 2011 at 11:27 PM, wrote: > Hey Thanks. Will do that. > > Just a question in general. ?Is it possible that we have opened one file in r+ mode ( file1.txt ). We have 2 threads, thread1 will continuously only read the file in a loop. Thread2 will only update the data in the file. Now thread2 has called other script ( written in say Perl/Powershell ) and those scripts are inturn updating ( only writing ) into that file by their own file i/o mechanism. > Is it possible by any chance? One file being shared between different processes one is updating and other is reading ..? Will this work in practical and what can be the complications ? > > > > -----Original Message----- > From: Alec Taylor [mailto:alec.taylor6 at gmail.com] > Sent: Monday, November 21, 2011 5:23 PM > To: Badjatya, Nikunj > Subject: Re: ProgressBar - Python and Powershell > > WiX will manage all the progress bar stuff for you. > > Just wrap it all in > > On Mon, Nov 21, 2011 at 9:44 PM, ? wrote: >> Yes I am executing powershell commands into virtual machines. >> >> Will have a look at WiX. >> >> But please, Answer my questions: >> >>>> My questions are: >>>> >>>> 1. ? ? ? Can I have a better shared mechanism between python and >>>> powershell.? ?As I am using a file here. Reading + writing in python and >>>> writing only in powershell. ?! >>>> >>>> 2. ? ? ? Does this thread mechanism work.? I am yet to implement and test >>>> it.! :P What can be the possible shortfalls.? >> >> Thanks >> Nikunj >> >> -----Original Message----- >> From: Alec Taylor [mailto:alec.taylor6 at gmail.com] >> Sent: Monday, November 21, 2011 11:59 AM >> To: Badjatya, Nikunj >> Cc: python-list at python.org >> Subject: Re: ProgressBar - Python and Powershell >> >> So you're executing Powershell commands into Virtual Machines? >> >> Add this into the installer (probably WiX is your best bet) >> >> On Mon, Nov 21, 2011 at 3:40 AM, ? wrote: >>> Thanks for reply. >>> Python and Powershell are required because the installer would deal in virtual machines ( VMware environment ). >>> Some prechecks and postconfig are required in both VMware and Windows environment. For dealing with VMware environment powershell has the best bonding. For windows I am ?using Python. >>> >>> I am new to this field and do not know if there is an alternative available.! Can you please suggest an alternative to Powershell in VM environment. ? >>> >>> The current look of the installer is completely command line based. >>> >>> >>> -----Original Message----- >>> From: Alec Taylor [mailto:alec.taylor6 at gmail.com] >>> Sent: Sunday, November 20, 2011 7:22 PM >>> To: Badjatya, Nikunj >>> Cc: python-list at python.org >>> Subject: Re: ProgressBar - Python and Powershell >>> >>> Why are you writing an installer in Python and Powershell? >>> >>> Just write an installer in WiX, NSIS or Inno like the rest of the sane world. >>> >>> Alternatively take a look at MakeMSI or the script python uses to >>> generate there .MSI. >>> >>> Anything else is WAY too non-standard to consider. >>> >>> On Mon, Nov 21, 2011 at 12:01 AM, ? wrote: >>>> Can anyone throw some light on this please ! ? >>>> >>>> >>>> >>>> >>>> >>>> From: python-list-bounces+nikunj.badjatya=emc.com at python.org >>>> [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of >>>> Nikunj.Badjatya at emc.com >>>> Sent: Thursday, November 17, 2011 4:10 PM >>>> To: python-list at python.org >>>> Subject: ProgressBar - Python and Powershell >>>> >>>> >>>> >>>> Hi All, >>>> >>>> >>>> >>>> I am using Python 2.7, windows Env. >>>> >>>> I have an Installer written in Python(45%) and Powershell(55%) which is used >>>> to install Virtual Machines at specific locations. It is single threaded. >>>> >>>> I am trying to implement a ProgressBar ?for this installer. So that the user >>>> will come to know the progress of the installation. >>>> >>>> I am using pypi progressbar module. >>>> >>>> The top script is in python which inturns calls powershell scripts using >>>> subprocess.call() and proceeds with the installation. >>>> >>>> >>>> >>>> I am taking a shared file between python and powershell, so that diff >>>> functions can update their %age completion level in to the file. Ex. Func1() >>>> updates it to 5%,? func2() will add its own 5% to it.. and so on. >>>> >>>> At the start of the (main.py) script I am creating a thread whose sole >>>> purpose would be to keep "READ" a temp file for a new entry in it. >>>> >>>> Based on this entry I can have my thread update the progressbar on the >>>> console. >>>> >>>> >>>> >>>> My questions are: >>>> >>>> 1.?????? Can I have a better shared mechanism between python and >>>> powershell.? ?As I am using a file here. Reading + writing in python and >>>> writing only in powershell. ?! >>>> >>>> 2.?????? Does this thread mechanism work.? I am yet to implement and test >>>> it.! :P What can be the possible shortfalls.? >>>> >>>> >>>> >>>> >>>> Thanks >>>> >>>> >>>> >>>> Nikunj >>>> >>>> Bangalore - India >>>> >>>> >>>> >>>> >>>> -- >>>> http://mail.python.org/mailman/listinfo/python-list >>>> >>> >> > From jeanmichel at sequans.com Mon Nov 21 08:08:34 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 21 Nov 2011 14:08:34 +0100 Subject: Is there any way to unimport a library In-Reply-To: <4ECA4CCA.5050308@sequans.com> References: <4ECA4CCA.5050308@sequans.com> Message-ID: <4ECA4D52.5090504@sequans.com> Jean-Michel Pichavant wrote: > Gelonida N wrote: >> I wondered whether there is any way to un-import a library, such, that >> it's occupied memory and the related shared libraries are released. >> >> >> My usecase is following: >> >> >> success = False >> try: >> import lib1_version1 as lib1 >> import lib2_version1 as lib2 >> success = True >> except ImportError: >> pass >> if not success: >> try: >> import lib1_version2 as lib1 >> import lib2_version2 as lib2 >> success = True >> except importError: >> pass >> if not success: >> . . . >> >> >> >> Basically if I am not amble to import lib1_version1 AND lib2_version1, >> then I wanted to make sure, that lib1_version1 does not waste any memory >> >> >> At this moment this is more a thought excercise than a real issue, but I >> thought that perhaps somebody encountered this kind of issue and had an >> idea how to deal with such situations. >> >> One solution, that I could imagine is running the program a first time, >> detect all existing libraries and write out a config file being use >> the next time it is run, such, that immediately the right libs are >> imported. >> >> > Short answer for unimporting modules : Not possible (yes there is a > long one :o) ). > > One approach to your problem is to test for module existence before > importing any module. > > import imp > > def impVersion(version) > try: > imp.find_module('lib1_version%s' % version) > imp.find_module('lib2_version%s' % version) > except ImportError: > raise > else: > lib1 = __import__('lib1_version%s' % version) > lib2 = __import__('lib2_version%s' % version) > > # using a for loop to avoid to many nested try statement > for version in [1,2,3,4]: > try: > impVersion(version) > except ImportError: > continue > break > > if not lib1 or not lib2: > # no lib imported > pass > > Using this code allows you to import your library only if all > conditions are met, preventing you from rolling back in case of error. > > Jean-Michel there are missing global lib1 global lib2 statements right before assigning lib1 and lib2. JM From Nikunj.Badjatya at emc.com Mon Nov 21 08:15:28 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Mon, 21 Nov 2011 08:15:28 -0500 Subject: Multiple Threads - I/O in Same File Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D407@MX34A.corp.emc.com> Hi All, Just a question in general. Is it possible that we have opened one file in r+ mode ( file1.txt ). We have 2 threads, * Thread1 will continuously 'only read' the file in a loop. * Thread2 will only update the data in the file ( say a number < 100 ). Now thread2 has called other script ( written in say Perl/Powershell using subprocess.call() ) and those scripts are inturn updating ( only writing ) into that file by their own file i/o mechanism. Is it possible by any chance? One file being shared between different processes one is only updating and other is only reading ..? Will this work in practical and what can be the complications ? Thanks Nikunj -------------- next part -------------- An HTML attachment was scrubbed... URL: From ray at aarden.us Mon Nov 21 08:18:00 2011 From: ray at aarden.us (ray) Date: Mon, 21 Nov 2011 05:18:00 -0800 (PST) Subject: How to: Coordinate DictReader and Reader for CSV Message-ID: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> I am trying to get the data from a CSV file into variables. I have used DictReader to get the field names and I can report them. When I attempt to look at the data, every row shows the combination of fieldname:data. How do I get the data out? linelist=open( "C:/Users/rjoseph/Documents/Projects/Bootstrap Plan Design Tool/Sandbox/line_list_r0a.csv", "rb" ) csvDictReader=csv.DictReader( linelist, dialect='excel' ) for data in csvReader: print data[0] print data[1] print data[2] print data[3] linelist.close() Thanks, ray From alec.taylor6 at gmail.com Mon Nov 21 08:39:18 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Tue, 22 Nov 2011 00:39:18 +1100 Subject: JSON passing protocol Message-ID: Good morning, I'm planning on assembling my django templates onto mobile apps using a JSON passing protocol, probably tunnels through HTTP. What's available? Thanks for all information, Alec Taylor From ray at aarden.us Mon Nov 21 08:42:59 2011 From: ray at aarden.us (ray) Date: Mon, 21 Nov 2011 05:42:59 -0800 (PST) Subject: How to Get Data from DictReader for CSV Files Message-ID: I don't see how to get my data from the output. I can see the data in the rows but it is mixed in with the field names. That is, the data I get comes out as: fieldname1 : data1 , fieldname2 : data2 , etc. import csv linelist=open( "C:/Users/me/line_list_r0.csv", "rb" ) csvReader= csv.DictReader( linelist, dialect='excel' ) for data in csvReader: print data linelist.close() I want to pass this data as arrays or lists to another module such as: myfunction(data1, data2, data3) How do I get the data I want out of the pair fieldname1 : data1? Thanks, ray From neilc at norwich.edu Mon Nov 21 08:59:35 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 21 Nov 2011 13:59:35 GMT Subject: How to: Coordinate DictReader and Reader for CSV References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> Message-ID: <9iv3q7F1t5U1@mid.individual.net> On 2011-11-21, ray wrote: > I am trying to get the data from a CSV file into variables. I have > used DictReader to get the field names and I can report them. When I > attempt to look at the data, every row shows the combination of > fieldname:data. How do I get the data out? > linelist=open( "C:/Users/rjoseph/Documents/Projects/Bootstrap Plan > Design Tool/Sandbox/line_list_r0a.csv", "rb" ) > csvDictReader=csv.DictReader( linelist, dialect='excel' ) > for data in csvReader: > print data[0] > print data[1] > print data[2] > print data[3] > linelist.close() The elements yielded by a DictReader iterator are dictionaries, and the keys are the headings of the csv file. So replace those integers with strings representing the headings of your file. If the headings are actually those numbers, you want: [...] print data['0'] print data['1'] print data['2'] print data['3'] print data['4'] [...] -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins From mlenz at nocturnal.org Mon Nov 21 09:00:55 2011 From: mlenz at nocturnal.org (mlenz at nocturnal.org) Date: Mon, 21 Nov 2011 06:00:55 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. Message-ID: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> I'm working on a project where I need to communicate with some devices via modem which have the possibility of using MARK and SPACE parity. These are not defined by POSIX and therefore are not directly supported under Linux. I've found the following discussion on the topic: http://www.lothosoft.ch/thomas/libmip/markspaceparity.php and I have been trying to use this information (since the TERMIOS module is available) to proceed with the communication. I was able to use minicom to determine that the first device I started testing with uses 7M1 but cannot figure out how to implement the solution described by the author above. Any pointers would be greatly appreciated. From matthew at nocturnal.org Mon Nov 21 09:16:44 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 06:16:44 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> Message-ID: <16480720.736.1321885004083.JavaMail.geo-discussion-forums@yqni5> I should also note that I am aware of the following discussion on the newsgroup: https://groups.google.com/d/msg/comp.lang.python/1HyCqPSOf50/eQINFrrFKwoJ However, I believe this refers to implementing the solution for 8M1 and 8S1. From nizamov.shawkat at gmail.com Mon Nov 21 09:26:48 2011 From: nizamov.shawkat at gmail.com (Nizamov Shawkat) Date: Mon, 21 Nov 2011 15:26:48 +0100 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> Message-ID: 2011/11/21 : > I'm working on a project where I need to communicate with some devices via modem which have the possibility of using MARK and SPACE parity. ?These are not defined by POSIX and therefore are not directly supported under Linux. > > I've found the following discussion on the topic: > > http://www.lothosoft.ch/thomas/libmip/markspaceparity.php > > and I have been trying to use this information (since the TERMIOS module is available) to proceed with the communication. > > I was able to use minicom to determine that the first device I started testing with uses 7M1 but cannot figure out how to implement the solution described by the author above. > "The modes 7M1 (7 data bits, MARK parity, 1 stop bit) and 7S1 (7 data bits, SPACE parity, 1 stop bit) can easily be emulated using 8N1 (0 data bits, NO parity, 1 stop bit) and setting the 8th data bit to 1 resp. 0. This is relatively simple to implement and cannot be distinguished by the receiver." It means that 7M1 === 8N1. Set 8N1 mode on your side and 7M1 on the other side. I really do not understand what is the reason to have dedicated 7M1 or 7S1 mode - it is no different from regular 8 bit mode from the hardware point of view. From the software point of view it is just the matter of the definition of the highest bit. In other words, 7M1/7S1 are two complementary subsets of a single 8N1 set. HTH From d at davea.name Mon Nov 21 09:27:29 2011 From: d at davea.name (Dave Angel) Date: Mon, 21 Nov 2011 09:27:29 -0500 Subject: Format the ouput in my python code In-Reply-To: <3f23c6ac-0554-4cb7-bf7c-b98c29721796@z22g2000prd.googlegroups.com> References: <3f23c6ac-0554-4cb7-bf7c-b98c29721796@z22g2000prd.googlegroups.com> Message-ID: <4ECA5FD1.5090308@davea.name> On 11/21/2011 07:13 AM, sl33k wrote: > I am printing the numbers from 1 to 100. In that, I want to display > multiples of 3,5 and of both as mulof3, mul0f5 and mulof3and5 > respectively. > > I am getting the output I want but I would like to format the output > to print only 10 number per line. How do I go about doing this? > > for i in range(1, 101): > if i % 3 == 0: > if i % 5 == 0: > print 'mulof3and5', > else: > print 'mulof3', > elif i % 5 == 0: > print 'mulof5', > else: > print i > Change that loop into a generator, having it return values rather than printing them. Then call that generator in a for-loop, something like: for index, val in enumerate(mygen): print val, if not index%10: print -- DaveA From d at davea.name Mon Nov 21 09:34:14 2011 From: d at davea.name (Dave Angel) Date: Mon, 21 Nov 2011 09:34:14 -0500 Subject: Format the ouput in my python code In-Reply-To: <4ECA5FD1.5090308@davea.name> References: <3f23c6ac-0554-4cb7-bf7c-b98c29721796@z22g2000prd.googlegroups.com> <4ECA5FD1.5090308@davea.name> Message-ID: <4ECA6166.3050401@davea.name> On 11/21/2011 09:27 AM, Dave Angel wrote: > On 11/21/2011 07:13 AM, sl33k wrote: >> I am printing the numbers from 1 to 100. In that, I want to display >> multiples of 3,5 and of both as mulof3, mul0f5 and mulof3and5 >> respectively. >> >> I am getting the output I want but I would like to format the output >> to print only 10 number per line. How do I go about doing this? >> >> for i in range(1, 101): >> if i % 3 == 0: >> if i % 5 == 0: >> print 'mulof3and5', >> else: >> print 'mulof3', >> elif i % 5 == 0: >> print 'mulof5', >> else: >> print i >> > Change that loop into a generator, having it return values rather than > printing them. Then call that generator in a for-loop, something like: > > for index, val in enumerate(mygen): > print val, > if not index%10: print > > Oops. That was untested, and it probably wasn't quite what you wanted. More likely something like (untested): for index, val in enumerate(mygen): print val, if not ((index+1)%10): print -- DaveA From andrea.crotti.0 at gmail.com Mon Nov 21 09:44:34 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 21 Nov 2011 14:44:34 +0000 Subject: decorators and closures Message-ID: <4ECA63D2.7080603@gmail.com> With one colleague I discovered that the decorator code is always executed, every time I call a nested function: def dec(fn): print("In decorator") def _dec(): fn() return _dec def nested(): @dec def fun(): print("here") nested() nested() Will give: In decorator In decorator So we were wondering, would the interpreter be able to optimize this somehow? I was betting it's not possible, but I'm I would like to be wrong :) From d at davea.name Mon Nov 21 10:06:00 2011 From: d at davea.name (Dave Angel) Date: Mon, 21 Nov 2011 10:06:00 -0500 Subject: decorators and closures In-Reply-To: <4ECA63D2.7080603@gmail.com> References: <4ECA63D2.7080603@gmail.com> Message-ID: <4ECA68D8.2060608@davea.name> On 11/21/2011 09:44 AM, Andrea Crotti wrote: > With one colleague I discovered that the decorator code is always > executed, every time I call > a nested function: > > def dec(fn): > print("In decorator") > def _dec(): > fn() > > return _dec > > def nested(): > @dec > def fun(): > print("here") > > nested() > nested() > > Will give: > In decorator > In decorator > > So we were wondering, would the interpreter be able to optimize this > somehow? > I was betting it's not possible, but I'm I would like to be wrong :) Your function 'nested' isn't nested, 'fun' is. What you discovered is that a decorator is always executed, every time a nested decorated function is defined. You've also ust proved that it would be an incompatible change. Doesn't that answer the question? An optimizer that changes the behavior isn't usually desirable. -- DaveA From ray at aarden.us Mon Nov 21 10:16:15 2011 From: ray at aarden.us (ray) Date: Mon, 21 Nov 2011 07:16:15 -0800 (PST) Subject: How to: Coordinate DictReader and Reader for CSV References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> <9iv3q7F1t5U1@mid.individual.net> Message-ID: <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> On Nov 21, 7:59?am, Neil Cerutti wrote: > On 2011-11-21, ray wrote: > > > I am trying to get the data from a CSV file into variables. ?I have > > used DictReader to get the field names and I can report them. ?When I > > attempt to look at the data, every row shows the combination of > > fieldname:data. ?How do I get the data out? > > linelist=open( "C:/Users/thisuser/Documents/Projects/Bootstrap Plan > > Design Tool/Sandbox/line_list_r0a.csv", "rb" ) > > csvDictReader=csv.DictReader( linelist, dialect='excel' ) > > for data in csvReader: > > ? ? ? ? print data[0] > > ? ? ? ? print data[1] > > ? ? ? ? print data[2] > > ? ? ? ? print data[3] > > linelist.close() > > The elements yielded by a DictReader iterator are dictionaries, > and the keys are the headings of the csv file. So replace those > integers with strings representing the headings of your file. > > If the headings are actually those numbers, you want: > > [...] > ? ? print data['0'] > ? ? print data['1'] > ? ? print data['2'] > ? ? print data['3'] > ? ? print data['4'] > [...] > > -- > Neil Cerutti > ? "This room is an illusion and is a trap devisut by Satan. ?Go > ahead and dauntlessly! ?Make rapid progres!" > ? --Ghosts 'n Goblins Neil, Thank you for your efforts. When I use the 0, 1, etc. in the data[x] slot, I get some data. When I put a string in, I get an error stating: TypeError: list indices must be integers, not str But your suggestion has helped my better understand my problem. The output is first a list of the keys and then the associated data. The difficulty is that I want to pass the data to another function will I am in the 'for' loop. But the first data out is keys and that is not the data I want to send to the other function. Is there a way to capture the keys outside of the for loop so when the for loop is entered, only data is extracted? Thanks, ray From andrea.crotti.0 at gmail.com Mon Nov 21 10:35:13 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 21 Nov 2011 15:35:13 +0000 Subject: decorators and closures In-Reply-To: <4ECA68D8.2060608@davea.name> References: <4ECA63D2.7080603@gmail.com> <4ECA68D8.2060608@davea.name> Message-ID: <4ECA6FB1.6000701@gmail.com> On 11/21/2011 03:06 PM, Dave Angel wrote: > Your function 'nested' isn't nested, 'fun' is. What you discovered is > that a decorator is always executed, every time a nested decorated > function is defined. > > You've also ust proved that it would be an incompatible change. > Doesn't that answer the question? An optimizer that changes the > behavior isn't usually desirable. > Yes sure I think it makes perfectly sense, because you actually redefine a local variable every time.. Another thing (which was also the reason of the subject), I tried to disassemble the following: def dec(fn): def _dec(): fn() return _dec @dec def fun(): print("here") fun() And I get this: In [29]: dis.dis(test_decorate) Disassembly of dec: 2 0 LOAD_CLOSURE 0 (fn) 3 BUILD_TUPLE 1 6 LOAD_CONST 1 () 9 MAKE_CLOSURE 0 12 STORE_FAST 1 (_dec) 5 15 LOAD_FAST 1 (_dec) 18 RETURN_VALUE Disassembly of fun: 3 0 LOAD_DEREF 0 (fn) 3 CALL_FUNCTION 0 6 POP_TOP 7 LOAD_CONST 0 (None) 10 RETURN_VALUE Looking up the definition of the single calls didn't help much, so why do we need for example MAKE_CLOSURE? Is MAKE_CLOSURE just more generic maybe? From neilc at norwich.edu Mon Nov 21 10:41:31 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 21 Nov 2011 15:41:31 GMT Subject: How to: Coordinate DictReader and Reader for CSV References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> <9iv3q7F1t5U1@mid.individual.net> <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> Message-ID: <9iv9pbFdboU1@mid.individual.net> On 2011-11-21, ray wrote: > Is there a way to capture the keys outside of the for loop so > when the for loop is entered, only data is extracted? I have sometimes done the following type of thing, since DictReader doesn't offer an attribute providing the field names. This is Python 3.3.2 code, so revise boilerplate if necessary. # Open once as a csv.reader instance to get the field names, in # order. with open(in_file_name, newline='') as in_file: reader = csv.reader(in_file) fields = next(reader) # Open it again as a csv.DictReader instance to do actual work, # writing revised lines to the output file as I go. with open(in_file_name, newline=') as in_file: with open(out_file_name, "w", newline='') as out_file: reader = csv.DictReader(in_file) writer = csv.DictWriter(out_file, fieldnames=fields) # Write header line writer.writerow({f: f for n in fields}) for record in reader: # Change a few fields # [...] writer.writerow(record) -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins From neilc at norwich.edu Mon Nov 21 10:43:25 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 21 Nov 2011 15:43:25 GMT Subject: How to: Coordinate DictReader and Reader for CSV References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> <9iv3q7F1t5U1@mid.individual.net> <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> <9iv9pbFdboU1@mid.individual.net> Message-ID: <9iv9stFdboU2@mid.individual.net> On 2011-11-21, Neil Cerutti wrote: > On 2011-11-21, ray wrote: >> Is there a way to capture the keys outside of the for loop so >> when the for loop is entered, only data is extracted? > > I have sometimes done the following type of thing, since > DictReader doesn't offer an attribute providing the field names. > This is Python 3.3.2 code, so revise boilerplate if necessary. > > # Open once as a csv.reader instance to get the field names, in > # order. > with open(in_file_name, newline='') as in_file: > reader = csv.reader(in_file) > fields = next(reader) Equal to reader.next() in 2.x Python, I believe. > # Open it again as a csv.DictReader instance to do actual work, > # writing revised lines to the output file as I go. > with open(in_file_name, newline=') as in_file: > with open(out_file_name, "w", newline='') as out_file: > reader = csv.DictReader(in_file) > writer = csv.DictWriter(out_file, fieldnames=fields) > # Write header line > writer.writerow({f: f for n in fields}) Oops! {f: f for f in fields}. Sorry about that. > for record in reader: > # Change a few fields > # [...] > writer.writerow(record) -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins From jabba.laci at gmail.com Mon Nov 21 10:56:59 2011 From: jabba.laci at gmail.com (Jabba Laci) Date: Mon, 21 Nov 2011 16:56:59 +0100 Subject: sqlalchemy beginner Message-ID: Hi, I'm reading the Essential SQLAlchemy book from O'Reilly. It explains SqlAlch 0.4 but my current version is 0.7 and there are some differences. Here is an example from the book: user_table = Table('tf_user', metadata, Column('id', Integer, primary_key=True), Column('user_name', Unicode(16), unique=True, nullable=False), Column('password', Unicode(40), nullable=False), Column('display_name', Unicode(255), default=''), Column('created', DateTime, default=datetime.now) ) Here I get the following warning: SAWarning: Unicode column received non-unicode default value. Column('display_name', Unicode(255), default=''), Changing Unicode(255) to String(255) makes the warning disappear but I'm not sure if it's the correct solution. For table names, the book uses the prefix convention 'tf_' but what does it mean? 't' is table, but what is 'f'? Thanks, Laszlo From matthew at nocturnal.org Mon Nov 21 11:28:19 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 08:28:19 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> Message-ID: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Using 8N1 under minicom with this device resulted in garbled text when once connected. Connection using 7M1 resulted in the correct text. So there must be something else that needs to be done in my python program correct? From matthew at nocturnal.org Mon Nov 21 11:28:19 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 08:28:19 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> Message-ID: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Using 8N1 under minicom with this device resulted in garbled text when once connected. Connection using 7M1 resulted in the correct text. So there must be something else that needs to be done in my python program correct? From zyzhu2000 at gmail.com Mon Nov 21 11:29:53 2011 From: zyzhu2000 at gmail.com (GZ) Date: Mon, 21 Nov 2011 08:29:53 -0800 (PST) Subject: How to Get Data from DictReader for CSV Files References: Message-ID: <7c77f2c4-09a5-4b5d-b162-b282688c0409@n35g2000yqf.googlegroups.com> Hi, On Nov 21, 7:42?am, ray wrote: > I don't see how to get my data from the output. ?I can see the data in > the rows but it is mixed in with the field names. ?That is, the data I > get comes out as: > fieldname1 : data1 , fieldname2 : data2 , etc. > > import csv > linelist=open( "C:/Users/me/line_list_r0.csv", "rb" ) > csvReader= csv.DictReader( linelist, dialect='excel' ) > for data in csvReader: > ? ? ? ? print data > linelist.close() > > I want to pass this data as arrays or lists to another module such as: > myfunction(data1, data2, data3) > > How do I get the data I want out of the pair fieldname1 : data1? > > Thanks, > ray > > It returns a dict(). You can reference the fields with data['fieldname1'], etc. From wolftracks at invalid.com Mon Nov 21 11:39:37 2011 From: wolftracks at invalid.com (W. eWatson) Date: Mon, 21 Nov 2011 08:39:37 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. Message-ID: My criterion for success is that it puts IDLE as a choice for editor on the menu produced with a right-click on a py file. So far no response on this has solved the problem. I know it sets up that way on a 2.5 and 2.4 on other PCs I have. I know at one time it worked on my 64-bit Win 7 PC, which likely had a 32-bit version installed on it. After something like six months of modest use it stopped working as above. No IDLE choice. I know by installing a 64-bit version, 3.2.2 failed the IDLE criterions as described. No IDLE. I do know that IDLE appears on the Win 7 Start menu, but, when used, nothing happens. Well, OK, for about 3 seconds the Win 7 "working" icon spins around then zip, nothing. Further, right-clicking on Properties of IDLE (GUI) produces a tabbed dialog. It shows Start in: c:\Python32\, and None for shortcut. There is a compatibility tab, which I've set to Win7. I think there's a troubleshooter there too, but I haven't used it. Under the Details tab, it shows Name: IDLE(Python Gui).lnk. Folder Path as: c:\ProgramData\Microsoft\Windows\Start... Nothing after the "...". Attributes: A Going directly to ...\Lib\idlelib\idle.pyw produces the spinning icon. At least, that's what happens in 3.2.2, but in the 32-bit versions I tried, I would get "invalid Win 32 app". When I rebooted my system a few hours after installing 3.2.2, because the PC was running really slowly--not because of Python, I was greeted by a couple of interesting messages as the desktop was populated. I can execute Python from the command line. 1. Specified module could not be found: Load Lib, python.dll. 2. \ProgramFiles(x86)\uniblueDrivers\Scanner (x86) Python26.dll. I'm sure this is related to Winamp, which I had installed a month ago. It had some "crazy" choice to scan for new drivers. Of course, if it found one-connected with Python, and if you wanted it, $$$. I think this message is a red herring. I may re-install Winamp to get rid of that uniblue tool that seems like nothing more than an ad. Some have suggested a registry problem, but I don't have a clue how to play with that, or somehow clean it up, if there is a problem. My PC behaves normally I'm using Win 7 Premium. So unless some brilliant idea appears, that leaves me with the choice of not using Python or this suggestion... (Let's not get off into other variations of other "Pythons" like Active..."): Someone suggested using the mail list at . What's different about that list than this NG? Does the "org" suggest that the inhabitants of that list are more likely associated with the people who are responsible for constructing Python? Comments? From rosuav at gmail.com Mon Nov 21 11:41:01 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Nov 2011 03:41:01 +1100 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Message-ID: On Tue, Nov 22, 2011 at 3:28 AM, Matthew Lenz wrote: > Using 8N1 under minicom with this device resulted in garbled text when once connected. ?Connection using 7M1 resulted in the correct text. ?So there must be something else that needs to be done in my python program correct? Using 8N1 when it's really 7M1 means you have the high bit set on every byte. I don't know if there's an easy way to do this fast in Python, but what you need to do is mask them all off... I'm not sure if there's a better way, but this ought to work: string = "".join(chr(ord(x)&0x7f) for x in string) In Python 3, iterating over a 'bytes' string produces integers, so omit the ord() call. Other than that, code is not tested. ChrisA From fraveydank at gmail.com Mon Nov 21 11:47:53 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 11:47:53 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Message-ID: <5074B814-C5A1-4B42-8F89-3B7406C91F49@gmail.com> On Nov 21, 2011, at 11:28 AM, Matthew Lenz wrote: > Using 8N1 under minicom with this device resulted in garbled text when once connected. Connection using 7M1 resulted in the correct text. So there must be something else that needs to be done in my python program correct? Under minicom in 8N1, it's going to look garbled because the high bit will always be set. Minicom will try to spit out those characters anyway, which will print out whatever extended ASCII garbage your terminal supports in the 0x80-0xFF range. Programmatically, though, you can strip off the high bit when you're receiving it in Python. "Space" parity, on the other hand, should look normal under Minicom because the high bit will always be low, giving you standard 7-bit ASCII. - Dave From matthew at nocturnal.org Mon Nov 21 11:52:17 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 08:52:17 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Message-ID: <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Ahh. Ok. So how would I go about doing that with python? I think in perl (sorry for the naughty word) I could use the tr// (translate) but is there a quick way to do so with python? Is it going to be necessary to convert commands I SEND to the device or only convert what I receive? From matthew at nocturnal.org Mon Nov 21 11:52:17 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 08:52:17 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> Message-ID: <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Ahh. Ok. So how would I go about doing that with python? I think in perl (sorry for the naughty word) I could use the tr// (translate) but is there a quick way to do so with python? Is it going to be necessary to convert commands I SEND to the device or only convert what I receive? From gordon at panix.com Mon Nov 21 12:08:06 2011 From: gordon at panix.com (John Gordon) Date: Mon, 21 Nov 2011 17:08:06 +0000 (UTC) Subject: sqlalchemy beginner References: Message-ID: In Jabba Laci writes: > SAWarning: Unicode column received non-unicode default value. > Column('display_name', Unicode(255), default=''), Perhaps it would help to supply the default value as a Unicode string instead of a plain string? Column('display_name', Unicode(255), default=u''), -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From d at davea.name Mon Nov 21 12:11:30 2011 From: d at davea.name (Dave Angel) Date: Mon, 21 Nov 2011 12:11:30 -0500 Subject: decorators and closures In-Reply-To: <4ECA6FB1.6000701@gmail.com> References: <4ECA63D2.7080603@gmail.com> <4ECA68D8.2060608@davea.name> <4ECA6FB1.6000701@gmail.com> Message-ID: <4ECA8642.7060908@davea.name> On 11/21/2011 10:35 AM, Andrea Crotti wrote: > On 11/21/2011 03:06 PM, Dave Angel wrote: >> Your function 'nested' isn't nested, 'fun' is. What you discovered is >> that a decorator is always executed, every time a nested decorated >> function is defined. >> >> You've also ust proved that it would be an incompatible change. >> Doesn't that answer the question? An optimizer that changes the >> behavior isn't usually desirable. >> > Yes sure I think it makes perfectly sense, because you actually redefine > a local variable every time.. > > Another thing (which was also the reason of the subject), I tried to > disassemble the following: > def dec(fn): > def _dec(): > fn() > > return _dec > > @dec > def fun(): > print("here") > > fun() > > And I get this: > In [29]: dis.dis(test_decorate) > Disassembly of dec: > 2 0 LOAD_CLOSURE 0 (fn) > 3 BUILD_TUPLE 1 > 6 LOAD_CONST 1 ( line 2>) > 9 MAKE_CLOSURE 0 > 12 STORE_FAST 1 (_dec) > > 5 15 LOAD_FAST 1 (_dec) > 18 RETURN_VALUE > > Disassembly of fun: > 3 0 LOAD_DEREF 0 (fn) > 3 CALL_FUNCTION 0 > 6 POP_TOP > 7 LOAD_CONST 0 (None) > 10 RETURN_VALUE > > > Looking up the definition of the single calls didn't help much, so why > do we need > for example MAKE_CLOSURE? > Is MAKE_CLOSURE just more generic maybe? > You didn't mention what version of Python you're running. With Python 2, I got very different results. So I switched to Python 3.2, and I still don't get exactly what you have. A closure is needed if there's some non-global data outside the function definition (code object) that's needed by the function object. As you supply the code I don't need a closure. But if I add a local variable in test_decorate(), and refer to it in dec(), then I get one. Not the same as yours. You left out the import and the definition line for test_decorate. Did you leave anything else? And what version of Python are you using? Are you perhaps running in a shell, as opposed to running code directly from a source file? -- DaveA From andrea.crotti.0 at gmail.com Mon Nov 21 12:12:03 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 21 Nov 2011 17:12:03 +0000 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: <4ECA8663.2070706@gmail.com> On 11/21/2011 04:39 PM, W. eWatson wrote: > ... > I'm using Win 7 Premium. > > So unless some brilliant idea appears, that leaves me with the choice > of not using Python or this suggestion... (Let's not get off into > other variations of other "Pythons" like Active..."): > > Someone suggested using the mail list at > . What's > different about that list than this NG? Does the "org" suggest that > the inhabitants of that list are more likely associated with the > people who are responsible for constructing Python? > > Comments? I only see windows and users-related problems, not much having to do with Python actually. Moreover, nothing forces you to use it, and with this attitude is not bad that you stay way from it, no offense of course. From andrea.crotti.0 at gmail.com Mon Nov 21 12:17:12 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 21 Nov 2011 17:17:12 +0000 Subject: decorators and closures In-Reply-To: <4ECA8642.7060908@davea.name> References: <4ECA63D2.7080603@gmail.com> <4ECA68D8.2060608@davea.name> <4ECA6FB1.6000701@gmail.com> <4ECA8642.7060908@davea.name> Message-ID: <4ECA8798.6060906@gmail.com> On 11/21/2011 05:11 PM, Dave Angel wrote: > > You didn't mention what version of Python you're running. With Python > 2, I got very different results. So I switched to Python 3.2, and I > still don't get exactly what you have. > > A closure is needed if there's some non-global data outside the > function definition (code object) that's needed by the function > object. As you supply the code I don't need a closure. But if I add > a local variable in test_decorate(), and refer to it in dec(), then I > get one. Not the same as yours. > > You left out the import and the definition line for test_decorate. > Did you leave anything else? And what version of Python are you > using? Are you perhaps running in a shell, as opposed to running code > directly from a source file? I use python 2.7, and actually the whole source is this (test_decorate.py): def dec(fn): def _dec(): fn() return _dec @dec def fun(): print("here") fun() Using ipython: import test_decorate dis.dis(test_decorate) From fraveydank at gmail.com Mon Nov 21 12:22:28 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 12:22:28 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Message-ID: <0BC69704-0205-4D1E-B2BA-06DB2783F31D@gmail.com> On Nov 21, 2011, at 11:52 AM, Matthew Lenz wrote: > Ahh. Ok. So how would I go about doing that with python? I think in perl (sorry for the naughty word) I could use the tr// (translate) but is there a quick way to do so with python? Is it going to be necessary to convert commands I SEND to the device or only convert what I receive? The high-level overview is that you'll want to OR in 0x80 on transmit, and AND 0x7F on receive (thus inserting the high bit when you send it out and removing it when you receive). If you wanted to be extra-sure you're receiving things correctly, you should also check to see if your value ANDed with 0x80 is not zero. In Python 2.x, as mentioned, when you iterate over a string, you get a bunch of tiny one-character strings, which you then need to convert into numbers with ord() and back into strings with chr() when you re-concatenate it. ord() and chr() may be familiar to you from Perl. For example, you could do this on reception: ---- # However you get your data out of serial received_str = receive_my_string() ord_str = [ord(x) for x in received_str] # An exception may be extreme in this case, but hey. Note that # the filter() function actually returns a list of all the # characters that don't have the high bit set, so you could # actually use that if you wanted to. if filter((lambda x: x < 0x80), ord_str): raise IOError("Received character without mark parity") return "".join([chr(x & 0x7F) for x in received_str]) ---- In Python 3.x, iterating over a bytes array (which is, hopefully, what your serial interface returns) will give you a bunch of ints, so you shouldn't need to do the conversions: ---- # However you get your data out of serial received_bytes = receive_my_string() # In Python 3.x, filter() returns an iterator, which is generally a # better thing to return, but doesn't test as nicely for a bool. for b in received_bytes: if b < 0x80: raise IOError("Received character without mark parity") # None of this "".join() nonsense with byte arrays! return bytes([(x & 0x7F) for x in received_bytes]) ---- There are surely more efficient ways to do what I've typed up there, but those should work pretty well for whatever you're looking to do. For sending, you pretty much want to swap (x & 0x7F) with (x | 0x80) to insert that high bit. - Dave From gheskett at wdtv.com Mon Nov 21 12:25:54 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 21 Nov 2011 12:25:54 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <5074B814-C5A1-4B42-8F89-3B7406C91F49@gmail.com> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <5074B814-C5A1-4B42-8F89-3B7406C91F49@gmail.com> Message-ID: <201111211225.54775.gheskett@wdtv.com> On Monday, November 21, 2011 11:58:53 AM David Riley did opine: > On Nov 21, 2011, at 11:28 AM, Matthew Lenz wrote: > > Using 8N1 under minicom with this device resulted in garbled text when > > once connected. Connection using 7M1 resulted in the correct text. > > So there must be something else that needs to be done in my python > > program correct? > > Under minicom in 8N1, it's going to look garbled because the high bit > will always be set. Minicom will try to spit out those characters > anyway, which will print out whatever extended ASCII garbage your > terminal supports in the 0x80-0xFF range. Programmatically, though, you > can strip off the high bit when you're receiving it in Python. I have been using 8n1 in minicom for years, never ever had such a problem. In fact, I don't even know if I can set the path to mark parity as it is so rarely used. E or O as error detectors are much more commonly used. Example copy/paste from minicom, talking to a trs-80 Color Computer 3 running a shell under nitros9, which is a bit like unix. I am asking it for the settings of its own output path, .1=stdout: {t2|07}/DD/NITROS9/dw3install/6309L2/SCRIPTS:tmode .1 /t2 upc=00 bso=01 dlo=00 eko=01 alf=01 nul=00 pau=01 pag=18 bsp=08 del=18 eor=0D eof=1B rpr=09 dup=01 psc=17 int=03 qut=05 bse=08 ovf=07 par=01 bau=06 xon=00 xof=00 {t2|07}/DD/NITROS9/dw3install/6309L2/SCRIPTS: And that is 9600 baud 8n1 on both ends. Ascii is normally 7 bit and will have a low 8th bit if fed normal ascii data, so how is the 8th bit getting set other than purposely setting 7M1 on the other end of the cable? > "Space" parity, on the other hand, should look normal under Minicom > because the high bit will always be low, giving you standard 7-bit > ASCII. > Yes. > - Dave Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Everything is controlled by a small evil group to which, unfortunately, no one we know belongs. From fraveydank at gmail.com Mon Nov 21 12:50:17 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 12:50:17 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <201111211225.54775.gheskett@wdtv.com> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <5074B814-C5A1-4B42-8F89-3B7406C91F49@gmail.com> <201111211225.54775.gheskett@wdtv.com> Message-ID: <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> On Nov 21, 2011, at 12:25 PM, gene heskett wrote: > And that is 9600 baud 8n1 on both ends. Ascii is normally 7 bit and will > have a low 8th bit if fed normal ascii data, so how is the 8th bit getting > set other than purposely setting 7M1 on the other end of the cable? That's what I thought the OP was doing; it sounds like he's trying to receive 7M1 in Minicom using 8N1 on the terminal and getting garbled data because the high bit is set (because the other end is sending 7M1). I never meant to imply that 8N1 would give garbled data if both ends were set to it; indeed, that's pretty much standard communications settings for short cables in low to moderate noise environments. If anyone else read it that way, that's not what I meant. :-) - Dave From cousinstanley at gmail.com Mon Nov 21 12:52:52 2011 From: cousinstanley at gmail.com (Cousin Stanley) Date: Mon, 21 Nov 2011 17:52:52 +0000 (UTC) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: Message-ID: W. eWatson wrote: > My criterion for success is that it puts IDLE as a choice for editor > on the menu produced with a right-click on a py file. > > So far no response on this has solved the problem. > .... As an alternative you might consider adding a short-cut to IDLE to the Send To directory if that option is still available under windows 7 .... That would seem almost as handy only moving the mouse one more time to roll out the Send To target menu before the final click to launch .... -- Stanley C. Kitching Human Being Phoenix, Arizona From mcepl at redhat.com Mon Nov 21 12:55:30 2011 From: mcepl at redhat.com (=?UTF-8?B?TWF0xJtqIENlcGw=?=) Date: Mon, 21 Nov 2011 18:55:30 +0100 Subject: [ANN] json_diff 0.9.2 released - JSON files comparator In-Reply-To: References: Message-ID: <4ECA9092.90906@redhat.com> I released json_diff 0.9.2. http://pypi.python.org/pypi/json_diff json_diff is an utility comparing two JSON files and generating diff in form of another JSON file with differences for each level of the object in a dict { "_append": {}, "_remove": {}, "_update": {} } This is the first public release, working my way towards 1.0 release. Development repository is at https://gitorious.org/json_diff, patches and pull requests welcome! -- http://www.ceplovi.cz/matej/, Jabber: mceplceplovi.cz GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC Basically, the only ?intuitive? interface is the nipple. After that, it's all learned. -- Bruce Ediger when discussing intuivity of Mac OS http://groups.google.com/group/comp.sys.next.advocacy\ /msg/7fa8c580900353d0 From ian.g.kelly at gmail.com Mon Nov 21 12:58:58 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 21 Nov 2011 10:58:58 -0700 Subject: How to Get Data from DictReader for CSV Files In-Reply-To: References: Message-ID: The point of DictReader is that it produces dicts. If you actually want a sequence, then use an ordinary csv.reader instead. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew at nocturnal.org Mon Nov 21 12:59:47 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 09:59:47 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Message-ID: <5536811.2361.1321898387975.JavaMail.geo-discussion-forums@yqcm23> Thanks, this will be a great help. Just wanted to confirm that you meant to use [ .. for x in ord_str] in the example conversion? Got a TypeError using the received_str. From matthew at nocturnal.org Mon Nov 21 12:59:47 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 09:59:47 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Message-ID: <5536811.2361.1321898387975.JavaMail.geo-discussion-forums@yqcm23> Thanks, this will be a great help. Just wanted to confirm that you meant to use [ .. for x in ord_str] in the example conversion? Got a TypeError using the received_str. From fraveydank at gmail.com Mon Nov 21 13:12:50 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 13:12:50 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <5536811.2361.1321898387975.JavaMail.geo-discussion-forums@yqcm23> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> <5536811.2361.1321898387975.JavaMail.geo-discussion-forums@yqcm23> Message-ID: On Nov 21, 2011, at 12:59 PM, Matthew Lenz wrote: > Thanks, this will be a great help. > > Just wanted to confirm that you meant to use [ .. for x in ord_str] in the example conversion? Got a TypeError using the received_str. Yes, I probably should have double-checked that. ord_str is indeed what I meant. :-) - Dave From python at mrabarnett.plus.com Mon Nov 21 13:20:01 2011 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 21 Nov 2011 18:20:01 +0000 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <2723247.1219.1321892899941.JavaMail.geo-discussion-forums@yqzz20> <22753805.1034.1321894337412.JavaMail.geo-discussion-forums@yqdr22> Message-ID: <4ECA9651.8020809@mrabarnett.plus.com> On 21/11/2011 16:52, Matthew Lenz wrote: > Ahh. Ok. So how would I go about doing that with python? I think in > perl (sorry for the naughty word) I could use the tr// (translate) > but is there a quick way to do so with python? Is it going to be > necessary to convert commands I SEND to the device or only convert > what I receive? Python strings have a .translate method: # Example in Python 2 import string # From top bit set... from_chars = "".join(chr(c | 0x80) for c in range(0x7F)) # ...to top bit clear. to_chars = "".join(chr(c) for c in range(0x7F)) # Build the translation table. force_clear = string.maketrans(from_chars, to_chars) s = "\x41\xC1" print s print s.translate(force_clear) From gheskett at wdtv.com Mon Nov 21 13:33:17 2011 From: gheskett at wdtv.com (gene heskett) Date: Mon, 21 Nov 2011 13:33:17 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> Message-ID: <201111211333.17806.gheskett@wdtv.com> On Monday, November 21, 2011 01:28:16 PM David Riley did opine: > On Nov 21, 2011, at 12:25 PM, gene heskett wrote: > > And that is 9600 baud 8n1 on both ends. Ascii is normally 7 bit and > > will have a low 8th bit if fed normal ascii data, so how is the 8th > > bit getting set other than purposely setting 7M1 on the other end of > > the cable? > > That's what I thought the OP was doing; it sounds like he's trying to > receive 7M1 in Minicom using 8N1 on the terminal and getting garbled > data because the high bit is set (because the other end is sending > 7M1). I never meant to imply that 8N1 would give garbled data if both > ends were set to it; indeed, that's pretty much standard communications > settings for short cables in low to moderate noise environments. If > anyone else read it that way, that's not what I meant. :-) > > - Dave I think that getting the other end off 7M1 was what I was saying. Trying to attack the bad data after capture by writing code always seems extremely masochistic to me. The amount of miss-understanding that seems to pervade rs-232 communications is mind boggling at times. The tech itself is so old it is being forgotten! Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Whatever occurs from love is always beyond good and evil. -- Friedrich Nietzsche From fetchinson at googlemail.com Mon Nov 21 13:33:44 2011 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 21 Nov 2011 19:33:44 +0100 Subject: SQLObject 1.2.0 In-Reply-To: <20111120121940.GC24874@iskra.aviel.ru> References: <20111120121940.GC24874@iskra.aviel.ru> Message-ID: Thanks a million Oleg! Cheers, Daniel On 11/20/11, Oleg Broytman wrote: > Hello! > > I'm pleased to announce version 1.2.0, the first stable release of branch > 1.2 of SQLObject. > > > What is SQLObject > ================= > > SQLObject is an object-relational mapper. Your database tables are > described > as classes, and rows are instances of those classes. SQLObject is meant to > be > easy to use and quick to get started with. > > SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, > Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). > > > Where is SQLObject > ================== > > Site: > http://sqlobject.org > > Development: > http://sqlobject.org/devel/ > > Mailing list: > https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss > > Archives: > http://news.gmane.org/gmane.comp.python.sqlobject > > Download: > http://pypi.python.org/pypi/SQLObject/1.2.0 > > News and changes: > http://sqlobject.org/News.html > > > What's New > ========== > > Features & Interface > -------------------- > > * Strings are treated specially in Select to allow > Select(['id, 'name'], where='value = 42'). Update allows a string in > WHERE. > > * ForeignKey('Table', refColumn='refcol_id') to allow ForeignKey to > point to a non-id column; the referred column must be a unique integer > column. > > * delColumn now accepts a ForeignKey's name without 'ID'. > > * Support for PostgreSQL 7.* is dropped. The minimal supported version of > PostgreSQL is 8.1 now. > > * Quoting rules changed for PostgreSQL: SQLObject uses E'' escape string > if the string contains characters escaped with backslash. > > * A bug caused by psycopg2 recently added a new boolean not callable > autocommit attribute was fixed. > > * sqlobject.__doc__ and main.__doc__ no longer contain version number. > Use sqlobject.version or version_info. > > For a more complete list, please see the news: > http://sqlobject.org/News.html > > Oleg. > -- > Oleg Broytman http://phdru.name/ phd at phdru.name > Programmers don't die, they just GOSUB without RETURN. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From python.list at tim.thechases.com Mon Nov 21 13:36:14 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 21 Nov 2011 12:36:14 -0600 Subject: How to: Coordinate DictReader and Reader for CSV In-Reply-To: <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> References: <2012e1cb-5913-4f39-b102-038a1c95a483@gi1g2000vbb.googlegroups.com> <9iv3q7F1t5U1@mid.individual.net> <04bc73a1-1408-4626-991f-fad94933cb5f@p2g2000vbj.googlegroups.com> Message-ID: <4ECA9A1E.1060100@tim.thechases.com> On 11/21/11 09:16, ray wrote: > Is there a way to capture the keys outside of the for loop so > when the for loop is entered, only data is extracted? I frequently do this for things like tweaking headers (stripping space, normalizing case, etc because clients love to send us messy data): def norm_header(h): return h.strip().upper() def norm_item(i): return i.strip() f = file("example.csv", "rb") try: r = csv.reader(f) headers = r.next() header_map = dict( (norm_header(h), i) for i, h in enumerate(headers) ) for row in r: item = lambda h: norm_item(row[header_map[norm_header(h)]]) value1 = item("Item1") value2 = item("ITEM3") ... finally: f.close() Should work in 2.x, possibly in 3.x (though you might need to change from "headers = r.next()" to "headers = next(r)") -tkc From illy at otekno.biz Mon Nov 21 14:21:16 2011 From: illy at otekno.biz (Illy) Date: Tue, 22 Nov 2011 02:21:16 +0700 Subject: SetStatusText of MDIParentFrame from MDIChildFrame Message-ID: <4ECAA4AC.6040803@otekno.biz> Dear my friends.... I am stucked on a problem: I can't call a function of MDIParentFrame from MDIChildFrame: myturnonmenu and mystatusbar.SetStatusText() Anybody would be so nice for telling me my mistakes? Please do me a favor. Thank you very much in advance. I created 3 files contain this sourcecode: ceo at mefi:~/sementara/tes$ ls jendelapos.py jendelapos.pyc myMDIChildFrameforLogin.py myMDIChildFrameforLogin.pyc myMDIFrame.py ceo at mefi:~/sementara/tes$ =========================================== ceo at mefi:~/sementara/tes$ cat myMDIFrame.py #!/usr/bin/env python import wx import os import jendelapos import myMDIChildFrameforLogin class myMDIParentFrame (wx.MDIParentFrame): def __init__(self): global mystatusbar, menuakuntan wx.MDIParentFrame.__init__(self, None, -1, "This is myMDIParentFrame", size=(1020,800)) mystatusbar = self.CreateStatusBar() mystatusbar.SetStatusText("This is the StatusBar I want to put my message for the users in it") menuakuntan = wx.Menu() menuakuntan.Append(1000, "Accounting - POS (&Point of Sale)") menuaplikasi = wx.Menu() menuaplikasi.Append(20000, "&Login") menuaplikasi.Append(20001, "E&xit") menubar = wx.MenuBar() menubar.Append(menuakuntan, "&Accounting") menubar.Append(menuaplikasi, "A&pplication") myturnoffmenu(self) self.SetMenuBar(menubar) self.Bind (wx.EVT_MENU, self.jendelapos, id=1000) self.Bind (wx.EVT_MENU, self.myMDIChildFrameforLogin, id=20000) self.Bind (wx.EVT_MENU, self.OnExit, id=20001) def OnExit(self, evt): self.Close(True) jendelapos = jendelapos.Show myMDIChildFrameforLogin = myMDIChildFrameforLogin.Show def myturnoffmenu(self): menuakuntan.Enable(1000, False) def myturnonmenu(self): menuakuntan.Enable(1000, True) if __name__ == '__main__': app = wx.PySimpleApp() myMDIFrame = myMDIParentFrame() myMDIFrame.Show() app.MainLoop() ceo at mefi:~/sementara/tes$ ================================================= ceo at mefi:~/sementara/tes$ cat ./myMDIChildFrameforLogin.py import wx def Show(self, evt): global pengguna, katakunci, jendela jendela = wx.MDIChildFrame(self, -1, "Login Form", style= wx.DEFAULT_FRAME_STYLE | wx.HSCROLL | wx.VSCROLL) mystatusbar.SetStatusText("Login succeeded") myturnonmenu() jendela.Show(True) ceo at mefi:~/sementara/tes$ ================================================= ceo at mefi:~/sementara/tes$ cat jendelapos.py import wx def Show (self, evt): win = wx.MDIChildFrame(self, -1, "Accounting - POS") win.Show(True) ceo at mefi:~/sementara/tes$ ================================================= From matthew at nocturnal.org Mon Nov 21 14:29:24 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 11:29:24 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> Message-ID: <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Another thing I noticed is that the & and | appear to give the same result as adding or subtracting 128 from the ordinal value. I'm assuming that isn't coincidence. :) From matthew at nocturnal.org Mon Nov 21 14:29:24 2011 From: matthew at nocturnal.org (Matthew Lenz) Date: Mon, 21 Nov 2011 11:29:24 -0800 (PST) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> Message-ID: <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Another thing I noticed is that the & and | appear to give the same result as adding or subtracting 128 from the ordinal value. I'm assuming that isn't coincidence. :) From invalid at invalid.invalid Mon Nov 21 14:42:35 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Nov 2011 19:42:35 +0000 (UTC) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> Message-ID: On 2011-11-21, Matthew Lenz wrote: > Another thing I noticed is that the & and | appear to give the same > result as adding or subtracting 128 from the ordinal value. Nope, that's only true for some values. If we're limiting ourselves to byte values, then we're talking modulo-256 arithmetic, so: 128 + 128 = 0 128 | 128 = 128 0 - 128 = 128 0 & 0x7f = 0 What's is true is that adding 128 is actullay the same as subtracting 128, and both are the same as exclusive-or 128 (v ^ 128): >>> x = 128 >>> (x + 128) & 0xff 0 >>> (x - 128) & 0xff 0 >>> (x ^ 128) & 0xff 0 >>> x = 0 >>> (x + 128) & 0xff 128 >>> (x - 128) & 0xff 128 >>> (x ^ 128) & 0xff 128 > I'm assuming that isn't coincidence. :) Well, the weighting of the high-order bit in an 8-bit wide binary number is 128, if that's what you're getting at... -- Grant Edwards grant.b.edwards Yow! How's it going in at those MODULAR LOVE UNITS?? gmail.com From fraveydank at gmail.com Mon Nov 21 15:42:23 2011 From: fraveydank at gmail.com (David Riley) Date: Mon, 21 Nov 2011 15:42:23 -0500 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Message-ID: <38BF659E-38D4-4516-9F22-3C0F7F992828@gmail.com> On Nov 21, 2011, at 2:29 PM, Matthew Lenz wrote: > Another thing I noticed is that the & and | appear to give the same result as adding or subtracting 128 from the ordinal value. I'm assuming that isn't coincidence. :) It's not, though the difference is important. They're binary ANDs (&) and ORs (|), so (0x0F | 0x80) = 0x8F, but (0x8F | 0x80) = 0x8F as well, whereas (0x8F + 0x80) = 0x10F. For manipulating bit values (which is what you're doing, you should almost never be adding or subtracting, but rather ANDing and ORing (or XORing, but not nearly as often). Just in case you're not familiar, 0x is the prefix for a hexadecimal number. 0x80 = 128, which is binary 10000000 (i.e. the high bit in a byte). - Dave From phihag at phihag.de Mon Nov 21 16:14:17 2011 From: phihag at phihag.de (Philipp Hagemeister) Date: Mon, 21 Nov 2011 22:14:17 +0100 Subject: youtube-dl: way to deal with the size cap issue + new errors + issues ... In-Reply-To: <1321124792.454176@nntp.aceinnovative.com> References: <1321124792.454176@nntp.aceinnovative.com> Message-ID: <4ECABF29.1030805@phihag.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 As a general rule, feel free to contact youtube-dl developers and users at https://github.com/rg3/youtube-dl/issues/ . youtube-dl is just one application, which happens to be written in Python. lbrt at mail.python.org wrote: > I did find my way (through a silly hack) to get all files within a size range without waiting for youtube-dl to be "enhanced". You may be able to send a HEAD request to the URL, but there's no guarantee the response will contain a Content-Length header. In fact, there will never be a Content-Lenght header for infinite HTTP streams. Also, RTMP URLs are way more complicated. > I have also been getting errors reporting: > RTMP download detected but "rtmpdump" could not be run You need rtmpdump. See http://rtmpdump.mplayerhq.hu/ for instructions on how to install it. > It would be very helpful if you could redirect youtube-dl errors to a separate file you would indicate via a flag If you think so, please open an issue. Do not forget to consider the usefulness not only for your specific application, but also of other applications. I think the command-line API (https://github.com/rg3/youtube-dl/issues/152) will be your best shot. Note that you can already redirect youtube-dl's output to a file, just like any other shell program: $ youtube-dl uHlDtZ6Oc3s > log will write a file log that contains all of youtube-dl's output. If the return code is not 0, an error has occured. Cheers, Philipp youtube-dl developer -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEAREKAAYFAk7KvygACgkQ9eq1gvr7CFw6GwCfeaF0TPNonTCaXVBDnmDBPio2 qVQAn2/JQzTbBYs+pe50t4qVCjxY+BLy =o6uC -----END PGP SIGNATURE----- From questions.anon at gmail.com Mon Nov 21 16:42:25 2011 From: questions.anon at gmail.com (questions anon) Date: Tue, 22 Nov 2011 08:42:25 +1100 Subject: mask one array using another array Message-ID: I am trying to mask one array using another array. I have created a masked array using mask=MA.masked_equal(myarray,0), that looks something like: [1 - - 1, 1 1 - 1, 1 1 1 1, - 1 - 1] I have an array of values that I want to mask whereever my mask has a a '-'. how do I do this? I have looked at http://www.cawcr.gov.au/bmrc/climdyn/staff/lih/pubs/docs/masks.pdf but the command: d = array(a, mask=c.mask() results in this error: TypeError: 'numpy.ndarray' object is not callable I basically want to do exactly what that article does in that equation. Any feedback will be greatly appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Mon Nov 21 16:48:37 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Nov 2011 16:48:37 -0500 Subject: Close as Many Files/External resourcs as possible in the face of exceptions In-Reply-To: References: <2e8d4372-393d-4c55-aa6e-6c9afd6c8ef2@n35g2000yqf.googlegroups.com> Message-ID: On 11/21/2011 7:09 AM, Mel Wilson wrote: > GZ wrote: >> Here is my situation. A parent object owns a list of files (or other >> objects with a close() method). The close() method can sometimes fail >> and raise an exception. When the parent object's close() method is >> called, it needs to close down as many files it owns as possible, even >> if the close() function of some files fail. I also want to re-raise at >> least one of the original exceptions so that the outer program can >> handle it. > [ ... ] >> >> It will re-raise the first exception and preserve the context and >> close as many other files as possible while ignoring any further >> exceptions. >> >> But this looks really awkward. And in the case that two files fail to >> close, I am not sure the best strategy is to ignore the second failure. > > I imagine you could save any caught exception instances in a list and > study them later. Yes, I would raise a custom exception instance that takes such a list of failures in its constructor. Give it a custom __str__ method to display them all. -- Terry Jan Reedy From ameyer2 at yahoo.com Mon Nov 21 17:43:38 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 21 Nov 2011 17:43:38 -0500 Subject: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7 In-Reply-To: References: Message-ID: <4ECAD41A.9070405@yahoo.com> On 11/17/2011 3:43 PM, Chris Angelico wrote: > ... > If you're having issues, grab a spare computer, throw Linux on it (I > recommend Ubuntu or Debian, others will have other preferred distros), > and see if the issues remain. Or if you're having trouble with the > GUI, try things from the command line (Windows's command interpreter > is pretty weak compared to bash, but it's plenty powerful enough). > > ChrisA If the OP is having trouble with this issue, and if he can't make Windows work here, I suspect that he'll get into trouble trying to install and test with Linux. However if he did want to try it, and assuming he's got 8GB or so of extra space, one easy way to test with Linux is to install VirtualBox, then install Linux under that. I've done that a half dozen times without hiccups. That way he doesn't need a second machine and doesn't need to repartition or toss his old OS. Alan From tjreedy at udel.edu Mon Nov 21 18:07:47 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Nov 2011 18:07:47 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: On 11/21/2011 11:39 AM, W. eWatson wrote: > > My criterion for success is that it puts IDLE as a choice for editor on > the menu produced with a right-click on a py file. Your first criterion for success should be that IDLE runs at all, which is apparently does not. How you run it is secondary. Right-click responses are controlled by Windows using data in the registry. Windows modifies the registry in response to installers *and users*. The ActiveState installers request 'Edit with PythonWin'. They do not request 'Edit with IDLE' and it is foolish to complain to us when you use ActiveState and get their choice of context choices. The PSF .msi installers (.msi = MicroSoftInstall format) from python.org request 'Edit with IDLE' but cannot make Windows put it in. If your registry is messed up enough, it does not happen. But no error message. I have explained to you another way to work with IDLE once it runs. It you refuse to use it, that is your problem, not ours. > I know it sets up that way on a 2.5 and 2.4 on other PCs I have. You installed with the PSF installer with an ok registry. > I know at one time it worked on my 64-bit Win 7 PC, which likely had a > 32-bit version installed on it. After something like six months of > modest use it stopped working as above. No IDLE choice. So some *other* program messed things up. Stop blaming us. Heavy or modest use in the meantime is irrelevant. > I know by installing a 64-bit version, 3.2.2 failed the IDLE criterions > as described. No IDLE. Did you uninstall the 32 bit version, and best, all Python versions? > I do know that IDLE appears on the Win 7 Start menu, but, when used, > nothing happens. Well, OK, for about 3 seconds the Win 7 "working" icon > spins around then zip, nothing. This is your real problem. Stop worrying about the context menu. > Further, right-clicking on Properties of > IDLE (GUI) produces a tabbed dialog. It shows Start in: c:\Python32\, This is the Shortcut tab. A shortcut is like a bound method. The function is the target: 'python 3.2.2 (64 bit)' on my machine. The starting directory is like a bound argument, although it is passed to the launcher that launches the function. What the Properties dialog does not show are the actual 'bound arguments' that are passed to the target as options. So one cannot know what the shortcut is actually trying to do. This is one of the Really Stupid things about Windows that should have been fixed long ago but has not. > and None for shortcut. None for Shortcut key, such as alt-I to invoke the shortcut. > There is a compatibility tab, which I've set to > Win7. I think there's a troubleshooter there too, but I haven't used it. > Under the Details tab, it shows Name: IDLE(Python Gui).lnk. Folder Path > as: c:\ProgramData\Microsoft\Windows\Start... Nothing after the "...". Details: Folder Path is the same as General: Location. Mouse over the latter the the full path appears. That Properties windows are still fixed at 480 pixel wide, regardless of screen size, is another Really Stupid thing. > Going directly to ...\Lib\idlelib\idle.pyw produces the spinning icon. > At least, that's what happens in 3.2.2, but in the 32-bit versions I > tried, I would get "invalid Win 32 app". If the registry entry for .pyw is messed up, trying to run the file by clicking on it is not likely to work. Try running from Command Prompt, as I believe others suggested. > When I rebooted my system a few hours after installing 3.2.2, because > the PC was running really slowly--not because of Python, I was greeted > by a couple of interesting messages as the desktop was populated. > > I can execute Python from the command line. > > 1. Specified module could not be found: Load Lib, python.dll. > > 2. \ProgramFiles(x86)\uniblueDrivers\Scanner (x86) Python26.dll. The uniblue drivers program will match your drivers against a database of up-to-date drivers and offer to upgrade them. I have used uniblue's registry scanner program. Treating pythonxy.dll as a driver, if they are, is an error. These are paid programs. The free demos only scan to tell you what they would do if you bought them. > I'm sure this is related to Winamp, which I had installed a month ago. I do not believe they are the same companies, but they may have a cross-promotion deal. > had some "crazy" choice to scan for new drivers. Of course, if it found > one-connected with Python, and if you wanted it, $$$. I think this > message is a red herring. I may re-install Winamp to get rid of that > uniblue tool that seems like nothing more than an ad. > > Some have suggested a registry problem, but I don't have a clue how to > play with that, or somehow clean it up, if there is a problem. My PC > behaves normally If you ran the psf 3.2.2 installer and idle does not run when you click the start menu shortcut, something is wrong. > Someone suggested using the mail list at > . What's different > about that list than this NG? Does the "org" suggest that the > inhabitants of that list are more likely associated with the people who > are responsible for constructing Python? Python list is mirror to comp.lang.python which is mirrored to a google group. It is also mirrored to gmane.comp.python, which is how I read and post. There is some spam filtering if you use the python.org list or gmane group. -- Terry Jan Reedy From invalid at invalid.invalid Mon Nov 21 18:08:12 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Nov 2011 23:08:12 +0000 (UTC) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On 2011-11-21, David Riley wrote: > On Nov 21, 2011, at 2:29 PM, Matthew Lenz wrote: > >> Another thing I noticed is that the & and | appear to give the same result as adding or subtracting 128 from the ordinal value. I'm assuming that isn't coincidence. :) > > It's not, though the difference is important. They're binary ANDs (&) and ORs (|), so (0x0F | 0x80) = 0x8F, but (0x8F | 0x80) = 0x8F as well, whereas (0x8F + 0x80) = 0x10F. For manipulating bit values (which is what you're doing, you should almost never be adding or subtracting, but rather ANDing and ORing (or XORing, but not nearly as often). > > Just in case you're not familiar, 0x is the prefix for a hexadecimal number. 0x80 = 128, which is binary 10000000 (i.e. the high bit in a byte). Like the old joke: There are 10 kinds of people in the world: those who understand binary numbers, and those who don't. -- Grant Edwards grant.b.edwards Yow! ... I don't like FRANK at SINATRA or his CHILDREN. gmail.com From invalid at invalid.invalid Mon Nov 21 18:09:44 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Nov 2011 23:09:44 +0000 (UTC) Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On 2011-11-21, Grant Edwards wrote: > Like the old joke: > > There are 10 kinds of people in the world: those who understand > binary numbers, and those who don't. OK, it's not _much_ of a joke, but I don't get to use it very often, so I couldn't let it go (for one thing, it only works in "print"). -- Grant Edwards grant.b.edwards Yow! I feel like I am at sharing a ``CORN-DOG'' gmail.com with NIKITA KHRUSCHEV ... From chasrmartin at gmail.com Mon Nov 21 18:17:05 2011 From: chasrmartin at gmail.com (Charlie Martin) Date: Mon, 21 Nov 2011 15:17:05 -0800 (PST) Subject: Peculiarity of '@' in logging.Formatter Message-ID: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> This is what seems like an odd bug, but in code I'd thing often-enough used it must be the expected behavior and I just don't understand. Please, sirs/mesdames, is this a bug? Example code: ---------------- begin code ------------------- #!/usr/bin/env python """ @-character WTF? """ import sys import os import logging, logging.handlers import socket log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) fmtColon = logging.Formatter('[%(module)s:%(lineno)03d]:%(message)s') strC = logging.handlers.SysLogHandler(address='/dev/log') strC.setFormatter(fmtColon) strC.setLevel(logging.DEBUG) log.addHandler(strC) fmtAt = logging.Formatter('[%(module)s@%(lineno)03d]:%(message)s') strA = logging.handlers.SysLogHandler(address='/dev/log') strA.setFormatter(fmtAt) strA.setLevel(logging.DEBUG) log.addHandler(strA) log.info("My log message:isn't it special?") ---------------- end code ---------------- produces these entries in the syslog messages: ---------------- begin results ---------------------- Nov 21 16:09:56 crmartin [atSign: 026]:My log message:isn't it special? Nov 21 16:09:56 crmartin [atSign at 026]: My log message:isn't it special? ---------------- end results ------------------------ Observe: * in the first entry, "[atSign: 026]:My" with space after the first ":"; that space isn't in the format string. * in the second entry "[atSign at 026]: My" again has an additional space after the first ":" the colons following are unchanged. This **seems** like it must be some obscure bug, but perhaps it's some undocumented feature? From chasrmartin at gmail.com Mon Nov 21 18:19:28 2011 From: chasrmartin at gmail.com (Charlie Martin) Date: Mon, 21 Nov 2011 15:19:28 -0800 (PST) Subject: Peculiarity of '@' in logging.Formatter In-Reply-To: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> References: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <10658976.1704.1321917568761.JavaMail.geo-discussion-forums@yqni5> Oops, forgot the python version etc: bash $ /usr/bin/env python -V Python 2.7 On SuSE 11.4 bash $ uname -a Linux crmartin 2.6.37.6-0.9-desktop #1 SMP PREEMPT 2011-10-19 22:33:27 +0200 x86_64 x86_64 x86_64 GNU/Linux From jehugaleahsa at gmail.com Mon Nov 21 19:07:45 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 21 Nov 2011 16:07:45 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4ec9e558$0$29997$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3c8fa8-c792-4afc-8e69-ef65538e5121@w1g2000vba.googlegroups.com> On Nov 21, 12:44?am, Steven D'Aprano wrote: > On Mon, 21 Nov 2011 13:33:21 +1100, Chris Angelico wrote: > > What's your language's "special feature"? I like to keep track of > > languages using a "slug" - a simple one-sentence (or less) statement of > > when it's right to use this language above others. For example, Python > > is optimized for 'rapid deployment'. > > "Python will save the world" > > http://proyectojuanchacon.blogspot.com/2010/07/saving-world-with-pyth... > > -- > Steven The language, psuedo name Unit, will be a low-level language capable of replacing C in most contexts. However, it will have integrated functional programming features (tail-end recursion optimization, tuples, currying, closures, function objects, etc.) and dynamic features (prototypical inheritance and late binding). It is a hybrid between C#, C++, F#, Python and JavaScript. The hope is that you won't pay for features you don't use, so it will run well on embedded devices as well as on desktops - that's to be seen. I'm no master compiler builder, here. The functional code is pretty basic: let multiply = function x y: return x * y # automatic generic arguments (integer here) let double = multiply _ 2 # short-hand currying - inlined if possible let doubled = [|0..10|].Apply(double) # double zero through 10 The dynamic code is pretty simple too: dynamic Prototype = function value: self.Value = value # simulated ctor Prototype.Double = function: self.Value * 2 # self refers to instance new Prototype(5).Double() # 10 new Prototype(6).Double() # 12 dynamic x = 5 # five wrapped with a bag x.Double = function: self * 2 x.Double() # 10 dynamic y = 6 y.Double = x.Double # member sharing y.Double() #12 The language also sports OOP features like are found in Java or C#: single inheritance; multiple interface inheritance; sealed, virtual and abstract types and members; explicit inheritance; extension methods and namespaces. The coolest feature will be its generics-oriented function signatures. By default everything is generic. You apply constraints to parameters, rather than specific types. For instance: let Average = function values: where values is ICountable IIterable assert values.Count > 0 "The values list cannot be empty." throws ArgumentException returns Float64 let sum = 0 for value in values: sum += value return sum / values.Count # floating point division As you can see, the function headers can be larger than the bodies themselves. They support type constraints, assertions (argument checking), exceptions enumeration, default parameters and return type information. All of them can be left out if the type of arguments can be inferred. This will not be an overnight project. :-) From roy at panix.com Mon Nov 21 19:25:03 2011 From: roy at panix.com (Roy Smith) Date: Mon, 21 Nov 2011 19:25:03 -0500 Subject: sqlalchemy beginner References: Message-ID: In article , Jabba Laci wrote: > Hi, > > I'm reading the Essential SQLAlchemy book from O'Reilly. Everytime I've worked with SQLAlchemy, I've run away screaming in the other direction. Sure, portability is a good thing, but at what cost? From rosuav at gmail.com Mon Nov 21 19:32:30 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Nov 2011 11:32:30 +1100 Subject: Non-POSIX parity (mark/space) with Python-Serial on Linux. In-Reply-To: References: <27511132.925.1321884055247.JavaMail.geo-discussion-forums@yqnf38> <201111211225.54775.gheskett@wdtv.com> <2A18CB23-4EDC-46E9-A49D-DEDE28C7FBEF@gmail.com> <6568831.884.1321903764225.JavaMail.geo-discussion-forums@yqhd1> Message-ID: On Tue, Nov 22, 2011 at 10:09 AM, Grant Edwards wrote: > On 2011-11-21, Grant Edwards wrote: > >> Like the old joke: >> >> ? There are 10 kinds of people in the world: those who understand >> ? binary numbers, and those who don't. > > OK, it's not _much_ of a joke, but I don't get to use it very often, > so I couldn't let it go (for one thing, it only works in "print"). On a scale of 1 to 10, what is the probability that this is in binary? There's plenty of great binary jokes going around. ChrisA From python at mrabarnett.plus.com Mon Nov 21 19:48:42 2011 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 22 Nov 2011 00:48:42 +0000 Subject: mask one array using another array In-Reply-To: References: Message-ID: <4ECAF16A.7080707@mrabarnett.plus.com> On 21/11/2011 21:42, questions anon wrote: > I am trying to mask one array using another array. > > I have created a masked array using > mask=MA.masked_equal(myarray,0), > that looks something like: > [1 - - 1, > 1 1 - 1, > 1 1 1 1, > - 1 - 1] > > I have an array of values that I want to mask whereever my mask has a a '-'. > how do I do this? > I have looked at > http://www.cawcr.gov.au/bmrc/climdyn/staff/lih/pubs/docs/masks.pdf but > the command: > > d = array(a, mask=c.mask() > > results in this error: > TypeError: 'numpy.ndarray' object is not callable > > I basically want to do exactly what that article does in that equation. > > Any feedback will be greatly appreciated. > The article is using the Numeric module, but your error says that you're using the numpy module. They're not the same. From questions.anon at gmail.com Mon Nov 21 20:37:57 2011 From: questions.anon at gmail.com (questions anon) Date: Tue, 22 Nov 2011 12:37:57 +1100 Subject: mask one array using another array In-Reply-To: <4ECAF16A.7080707@mrabarnett.plus.com> References: <4ECAF16A.7080707@mrabarnett.plus.com> Message-ID: thank you, that makes sense. I should have posted this on another list (which I have now). and the change required is: If your new array is x, you can use: numpy.ma.masked_array(x, mask=mask.mask) On Tue, Nov 22, 2011 at 11:48 AM, MRAB wrote: > On 21/11/2011 21:42, questions anon wrote: > >> I am trying to mask one array using another array. >> >> I have created a masked array using >> mask=MA.masked_equal(myarray,**0), >> that looks something like: >> [1 - - 1, >> 1 1 - 1, >> 1 1 1 1, >> - 1 - 1] >> >> I have an array of values that I want to mask whereever my mask has a a >> '-'. >> how do I do this? >> I have looked at >> http://www.cawcr.gov.au/bmrc/**climdyn/staff/lih/pubs/docs/**masks.pdfbut >> the command: >> >> d = array(a, mask=c.mask() >> >> results in this error: >> TypeError: 'numpy.ndarray' object is not callable >> >> I basically want to do exactly what that article does in that equation. >> >> Any feedback will be greatly appreciated. >> >> The article is using the Numeric module, but your error says that you're > using > the numpy module. They're not the same. > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bthate at gmail.com Mon Nov 21 21:49:28 2011 From: bthate at gmail.com (Bart Thate) Date: Mon, 21 Nov 2011 18:49:28 -0800 (PST) Subject: JSONBOT 0.80.3 RELEASED Message-ID: <29575735.33.1321930168912.JavaMail.geo-discussion-forums@yqni5> Hello world !! I released JSONBOT 0.80.3 .. the first in the 0.80 series ;] about ~~~~~ JSONBOT is a chatbot that can take commands and react to events on the network it is connected to (IRC, XMPP, WEB mostely). Push functionality is also provided (think RSS feeds to your IRC channel or XMPP conference). It is possible to program your own plugins to create custom functionality. source/docs ~~~~~~~~~~~ see http://jsonbot.org and http://jsonbot.googlecode.com make backup first ~~~~~~~~~~~~~~~~~ I added the jsb-backup program, please run this before starting the 0.80 bot. It will make a backup of your datadir into ~/jsb-backups changes ~~~~~~~ * GAE is no longer part of the standard distribution, as that is aimed at shell users as of 0.80 - use the mercurial repo if you want to use the GAE part of the bot * web console is now supported on shell - use the jsb-tornado program to launch a tornado web server bot on port 10102 * jsb-xmpp now supports OpenFire - use --openfire option to enable this * todo now uses per user databases instead of per channel - use the -c option to the todo command to show the channel todo * learn items are not global per default - use !learn-toglobal to copy local learn data to the global learndb * relay plugins has been rewritten to use bot.cfg.name as well - means that relays need to be created again * jsb-udpstripped program has been added that can be used to send udp data to the bot without the need of making config files (copy and edit it) * add fulljids = 1 to your xmpp bot config (most of the times in ~/.jsb/config/fleet/default-sxmpp/config) to enable full JID discovery in xmpp conference rooms (non anonymous) and: * lots of new plugins .. see !list ;] * lots of bug fixes - thnx everybody for reporting them * still lots of things to fix at 03:35 < jsonbot> tracker is http://code.google.com/p/jsonbot/issues/list If you find any problems or have feature request please post that on the tracker url above. Or try @botfather on #dunkbots on irc.freenode.net ;] From wuwei23 at gmail.com Mon Nov 21 21:51:00 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 21 Nov 2011 18:51:00 -0800 (PST) Subject: sqlalchemy beginner References: Message-ID: <8832ab6d-8def-45d1-92df-baac40e1c498@t36g2000prt.googlegroups.com> On Nov 22, 10:25?am, Roy Smith wrote: > Everytime I've worked with SQLAlchemy, I've run away screaming in the > other direction. ?Sure, portability is a good thing, but at what cost? I've never found SQLAlchemy to be anything but sane and approachable. It's really worth understanding _how_ it works so you can see there's no magic happening there. What cost do you see inherit in the use of SQLAlchemy? From ray at aarden.us Mon Nov 21 21:58:53 2011 From: ray at aarden.us (ray) Date: Mon, 21 Nov 2011 18:58:53 -0800 (PST) Subject: How to Get Data from DictReader for CSV Files References: <7c77f2c4-09a5-4b5d-b162-b282688c0409@n35g2000yqf.googlegroups.com> Message-ID: On Nov 21, 10:29?am, GZ wrote: > Hi, > > On Nov 21, 7:42?am, ray wrote: > > > > > > > I don't see how to get my data from the output. ?I can see the data in > > the rows but it is mixed in with the field names. ?That is, the data I > > get comes out as: > > fieldname1 : data1 , fieldname2 : data2 , etc. > > > import csv > > linelist=open( "C:/Users/me/line_list_r0.csv", "rb" ) > > csvReader= csv.DictReader( linelist, dialect='excel' ) > > for data in csvReader: > > ? ? ? ? print data > > linelist.close() > > > I want to pass this data as arrays or lists to another module such as: > > myfunction(data1, data2, data3) > > > How do I get the data I want out of the pair fieldname1 : data1? > > > Thanks, > > ray > > It returns a dict(). You can reference the fields with > data['fieldname1'], etc.- Hide quoted text - > > - Show quoted text - GZ, That works great. Thanks, ray From wuwei23 at gmail.com Mon Nov 21 22:00:46 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 21 Nov 2011 19:00:46 -0800 (PST) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: Message-ID: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> "W. eWatson" wrote: > Comments? Please don't start multiple threads on the same issue. From nytrokiss at gmail.com Mon Nov 21 22:03:06 2011 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 21 Nov 2011 22:03:06 -0500 Subject: JSONBOT 0.80.3 RELEASED In-Reply-To: <29575735.33.1321930168912.JavaMail.geo-discussion-forums@yqni5> References: <29575735.33.1321930168912.JavaMail.geo-discussion-forums@yqni5> Message-ID: Looks good I am going to plug twisted into this. On Mon, Nov 21, 2011 at 9:49 PM, Bart Thate wrote: > Hello world !! I released JSONBOT 0.80.3 .. the first in the 0.80 series ;] > > about > ~~~~~ > > JSONBOT is a chatbot that can take commands and react to events on the > network it is connected to (IRC, XMPP, WEB > mostely). Push functionality is also provided (think RSS feeds to your IRC > channel or XMPP conference). It is possible to program your own plugins to > create custom > functionality. > > source/docs > ~~~~~~~~~~~ > > see http://jsonbot.org and http://jsonbot.googlecode.com > > > make backup first > ~~~~~~~~~~~~~~~~~ > > I added the jsb-backup program, please run this before starting the 0.80 > bot. It will make a backup of your datadir into ~/jsb-backups > > changes > ~~~~~~~ > > * GAE is no longer part of the standard distribution, as that is aimed at > shell users as of 0.80 - use the mercurial repo if you want to use the GAE > part of the bot > * web console is now supported on shell - use the jsb-tornado program to > launch a tornado web server bot on port 10102 > * jsb-xmpp now supports OpenFire - use --openfire option to enable this > * todo now uses per user databases instead of per channel - use the -c > option to the todo command to show the channel todo > * learn items are not global per default - use !learn-toglobal to copy > local learn data to the global learndb > * relay plugins has been rewritten to use bot.cfg.name as well - means > that relays need to be created again > * jsb-udpstripped program has been added that can be used to send udp data > to the bot without the need of making config files (copy and edit it) > * add fulljids = 1 to your xmpp bot config (most of the times in > ~/.jsb/config/fleet/default-sxmpp/config) to enable full JID discovery in > xmpp conference rooms > (non anonymous) > > and: > > * lots of new plugins .. see !list ;] > * lots of bug fixes - thnx everybody for reporting them > * still lots of things to fix at > > 03:35 < jsonbot> tracker is http://code.google.com/p/jsonbot/issues/list > > If you find any problems or have feature request please post that on the > tracker url above. > > Or try @botfather on #dunkbots on irc.freenode.net ;] > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://www.goldwatches.com -- -------------- next part -------------- An HTML attachment was scrubbed... URL: From nytrokiss at gmail.com Mon Nov 21 22:13:57 2011 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 21 Nov 2011 22:13:57 -0500 Subject: Multiple Threads - I/O in Same File In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D407@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D407@MX34A.corp.emc.com> Message-ID: You may have some issues with disk reading as the drive heads move in different ways On Mon, Nov 21, 2011 at 8:15 AM, wrote: > Hi All,**** > > ** ** > > Just a question in general. Is it possible that we have opened one file > in r+ mode ( file1.txt ). **** > > We have 2 threads, **** > > **? **Thread1 will continuously ?only read? the file in a loop. ** > ** > > **? **Thread2 will only update the data in the file ( say a > number < 100 ). **** > > Now thread2 has called other script ( written in say Perl/Powershell using > subprocess.call() ) and those scripts are inturn updating ( only writing ) > into that file by their own file i/o mechanism.**** > > ** ** > > Is it possible by any chance? One file being shared between different > processes one is only updating and other is only reading ..? Will this work > in practical and what can be the complications ?**** > > ** ** > > ** ** > > Thanks**** > > Nikunj**** > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://www.goldwatches.com -- -------------- next part -------------- An HTML attachment was scrubbed... URL: From devplayer at gmail.com Mon Nov 21 22:16:14 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 21 Nov 2011 19:16:14 -0800 (PST) Subject: Is there any way to unimport a library References: <4ec920e3$0$29967$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 20, 12:21?pm, Gelonida N wrote: > I forgot to mention, that this is at the moment more a thought > experiment, than a real need. > > At the moment I will do exactly what you suggested. I will make sure, > that always the first import fails. > > But I wanted to learn more what is possible and which potential can of > worms I would open if I wanted to unimport a library of which I'm sure > that nobody is currently referencing (or refering? Not sure about my > English here) to. Get how many references to an object: sys.getrefcount(sys) From roy at panix.com Mon Nov 21 22:18:05 2011 From: roy at panix.com (Roy Smith) Date: Mon, 21 Nov 2011 22:18:05 -0500 Subject: sqlalchemy beginner References: <8832ab6d-8def-45d1-92df-baac40e1c498@t36g2000prt.googlegroups.com> Message-ID: In article <8832ab6d-8def-45d1-92df-baac40e1c498 at t36g2000prt.googlegroups.com>, alex23 wrote: > On Nov 22, 10:25?am, Roy Smith wrote: > > Everytime I've worked with SQLAlchemy, I've run away screaming in the > > other direction. ?Sure, portability is a good thing, but at what cost? > > I've never found SQLAlchemy to be anything but sane and approachable. > It's really worth understanding _how_ it works so you can see there's > no magic happening there. > > What cost do you see inherit in the use of SQLAlchemy? The cost of understanding how it works :-) Seriously. I understand SQL. Well, I'm not a SQL wizard, but I understand enough to do what I need to do. Whenever I have to use SQLAlchemy, I always find myself knowing exactly what SQL I want to write and scratching my head to figure out how to translate that into SQLAlchemy calls. From wuwei23 at gmail.com Mon Nov 21 22:22:43 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 21 Nov 2011 19:22:43 -0800 (PST) Subject: Interesting problem about uuid1 References: Message-ID: <43572d62-7afc-4554-a212-4271ee5355e5@o37g2000prn.googlegroups.com> On Nov 21, 5:33?pm, sword wrote: > My colleague asks me an interesting problem about uuid library in > python. In multicore system with multiprocessing, is it possible to > get the duplicated uuid with uuid1? > > I just check the RFC 4122, and I can't find anything about multicore > environment. Python's uuid1 method generates the uuid with time stamp, > mac address, and algorithm to gen random numbers. So, I think it's > possible to get the duplicate uuid1 at the same time. > > What about you? Hope for your reply Check the library documentation: http://docs.python.org/library/uuid.html uuid.uuid1([node[, clock_seq]]) Generate a UUID from a host ID, sequence number, and the current time. If node is not given, getnode() is used to obtain the hardware address. If clock_seq is given, it is used as the sequence number; otherwise a random 14-bit sequence number is chosen. Each process would have to not only execute at the exact same time, it would have to generate the same 14-bit random sequence. And if you're really concerned, try specifying a different clock_seq for each core. From steve+comp.lang.python at pearwood.info Mon Nov 21 22:54:43 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Nov 2011 03:54:43 GMT Subject: decorators and closures References: Message-ID: <4ecb1d03$0$30003$c3e8da3$5496439d@news.astraweb.com> On Mon, 21 Nov 2011 14:44:34 +0000, Andrea Crotti wrote: > With one colleague I discovered that the decorator code is always > executed, every time I call a nested function: "def" is a statement which is executed at runtime. Often people will talk about "definition time" instead of "compile time". Python compiles your source into byte code (compile time), then executes the byte code. The function doesn't actually get created until the byte code is executed, i.e. at run time. This is not as slow as it sounds, because the function is created from pre-compiled parts. In effect, if you have a module: x = 23 def spam(a): print x print x+1 return x**3 then the body of the function is compiled into a "code object" at compile time, and at runtime the function object itself is assembled from the code object, name, and whatever other bits and pieces are needed. In pseudo-code, the byte code looks like this: bind name "x" to object 23 build a function object "spam" from code object bind name "spam" to function object The hard part is creating the code object, as that requires parsing the source code of the body and generating byte code. That's done once, ahead of time, so the actual "build a function" part is fast. Now, if you have an ordinary nested function: def spam(a): def ham(b): return a+b return ham(a+42) # returns a numeric value or a closure: def spam(a): def ham(b): return a+b return ham # returns a closure (function object) the process is no different: the inner function doesn't get created until runtime, that is, when spam gets *called*. But it gets created from parts that were prepared earlier at compile time, and so is fast. Add a decorator, and the basic process remains. Remember that decorator syntax is just syntactic sugar. This: @decorator def spam(): pass is exactly the same as this: def spam(): pass spam = decorator(spam) which clearly has to be done at runtime, not compile time. That applies regardless of whether the function is nested or top-level. -- Steven From cs at zip.com.au Tue Nov 22 01:06:16 2011 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 22 Nov 2011 17:06:16 +1100 Subject: sqlalchemy beginner In-Reply-To: References: Message-ID: <20111122060616.GA17562@cskk.homeip.net> On 21Nov2011 22:18, Roy Smith wrote: | In article | <8832ab6d-8def-45d1-92df-baac40e1c498 at t36g2000prt.googlegroups.com>, | alex23 wrote: | > On Nov 22, 10:25?am, Roy Smith wrote: | > > Everytime I've worked with SQLAlchemy, I've run away screaming in the | > > other direction. ?Sure, portability is a good thing, but at what cost? | > | > I've never found SQLAlchemy to be anything but sane and approachable. | > It's really worth understanding _how_ it works so you can see there's | > no magic happening there. | > | > What cost do you see inherit in the use of SQLAlchemy? | | The cost of understanding how it works :-) | | Seriously. I understand SQL. Well, I'm not a SQL wizard, but I | understand enough to do what I need to do. Whenever I have to use | SQLAlchemy, I always find myself knowing exactly what SQL I want to | write and scratching my head to figure out how to translate that into | SQLAlchemy calls. Are you trying to go the ORM route (make classes etc mapping to SQL entities etc)? I ask because I avoid ORM and mostly use the SQL syntax notation, eg: for node_id, attr, value in select( [ attrs.c.NODE_ID, attrs.c.ATTR, attrs.c.VALUE, ] ) \ .order_by(asc(attrs.c.NODE_ID)) \ .execute(): or: self.attrs.delete(self.attrs.c.NODE_ID == node_id).execute() which I find very easy to read (self.attrs is an SQLAchemy table). ORMs seem very cool and all, but I personally prefer to work with simple SQL level schemae and python-level objects and classes i.e. not ORM classes but ordinary classes that cll SQLAlchemy select/update/delete/etc methods to manipulate the db. For me the great strengths of SQLA are that it (1) talks to many different backend DBs and (2) removes the need to write tediously quotes SQL because I can write python expressions like the above that map directly to SQL statements, and SQLA does all the quoting, conversion etc. Reliably! Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ I sometimes wish that people would put a little more emphasis upon the observance of the law than they do upon its enforcement. - Calvin Coolidge From davidlujun at gmail.com Tue Nov 22 05:18:25 2011 From: davidlujun at gmail.com (David Lu) Date: Tue, 22 Nov 2011 18:18:25 +0800 Subject: a qustion about import that really confuses me Message-ID: Hi, there. I have two files: a.py: > # -*- coding: utf-8 -*- > print('in a') > import b > > print('var') > VAR = 1 > > def p(): > print('{}, {}'.format(VAR, id(VAR))) > > if __name__ == '__main__': > VAR = -1 > p() > b.p() # Where does this VAR come from? > b.py: > # -*- coding: utf-8 -*- > print('in b') > import a > > def p(): > a.p() > I don't understand why there're two different VARs, which is supposed to the same. Is it a bug? If I move the 'main' block to another file, everything works well. c.py: > # coding=UTF-8 > import a > import b > > if __name__ == '__main__': > a.VAR = -1 > a.p() > b.p() > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Tue Nov 22 08:16:26 2011 From: d at davea.name (Dave Angel) Date: Tue, 22 Nov 2011 08:16:26 -0500 Subject: a qustion about import that really confuses me In-Reply-To: References: Message-ID: <4ECBA0AA.9000800@davea.name> On 11/22/2011 05:18 AM, David Lu wrote: > Hi, there. > > I have two files: > > a.py: > >> # -*- coding: utf-8 -*- >> print('in a') >> import b >> >> print('var') >> VAR = 1 >> >> def p(): >> print('{}, {}'.format(VAR, id(VAR))) >> >> if __name__ == '__main__': >> VAR = -1 >> p() >> b.p() # Where does this VAR come from? >> > b.py: > >> # -*- coding: utf-8 -*- >> print('in b') >> import a >> Right there is your problem. You try to import a module that you've earlier used as the top-level script. The top-level script gets a module name of "__main__" and this import is defining a module of "a". So you have two distinct modules from the same source file, as you've discovered. >> def p(): >> a.p() >> > I don't understand why there're two different VARs, which is supposed to > the same. > Is it a bug? > If I move the 'main' block to another file, everything works well. > > c.py: > >> # coding=UTF-8 >> import a >> import b >> >> if __name__ == '__main__': >> a.VAR = -1 >> a.p() >> b.p() >> More generally, you should avoid circular imports. Other problems can occur, this is just the most blatant. When you discover that two modules are using (importing) each other's resources. you should move as much code as necessary from one of them to a 3rd module, and both should import that one. Similar problems appear in other languages, and the cure is generally the same. Avoid circular dependencies. Incidentally, using all uppercase for a name is a convention for constants. Further, you explicitly request that VAR have different values when it's the top-level script than when it's an imported module, so the language is doing exactly what you request, even if not what you wanted. You're lucky that the problem was so obvious. Many mutual import problems are much more subtle. -- DaveA From loluengo at gmail.com Tue Nov 22 09:15:37 2011 From: loluengo at gmail.com (Lorenzo) Date: Tue, 22 Nov 2011 06:15:37 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> <27174986.458.1321411879812.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <70a4b790-b51b-4eb9-b487-07771895056c@w7g2000yqc.googlegroups.com> > ? ? ? ? Very interesting. ?Is there a simple way to add third-party > libraries to these? ?I assume that for pure-Python modules you could > just put a python file in the appropriate place and import it, but what > about if you wanted a web app that used numpy or something? ?Is that > feasible? > I cannot imagine how slow can be a python interpreter in javascript crunching numbers using numpy, and converting those numeric libraries (ATLAS, LAPACK,MKL,ACML) to javascript. From aleksandrs.zdancuks at gmail.com Tue Nov 22 09:54:05 2011 From: aleksandrs.zdancuks at gmail.com (Tiaburn Stedd) Date: Tue, 22 Nov 2011 06:54:05 -0800 (PST) Subject: Peculiarity of '@' in logging.Formatter References: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> <10658976.1704.1321917568761.JavaMail.geo-discussion-forums@yqni5> Message-ID: <4d86a69d-e737-41ea-8e23-a67351a67994@cu3g2000vbb.googlegroups.com> Upvote this. Looks like a bug for me. ---------------- begin results ---------------------- Nov 22 16:47:45 lvaltp0521 [minitest: 021]:My log message:isn't it special? Nov 22 16:47:45 lvaltp0521 [minitest at 021]: My log message:isn't it special? ---------------- end results ------------------------ ~$ python --version Python 2.6.6 From aleksandrs.zdancuks at gmail.com Tue Nov 22 10:19:59 2011 From: aleksandrs.zdancuks at gmail.com (Tiaburn Stedd) Date: Tue, 22 Nov 2011 07:19:59 -0800 (PST) Subject: Strange logging.Formatter behaviour Message-ID: Hello, all! I'm working on specific project and have a curious task where I need to use specific formatter and custom handlers, which are switchable to default handlers. Problem is that default handlers behaviour is to consume errors, so errors raised from code have printed tracebacks, but not passed outside logger, because of it silent behaviour. Unit test for this is below: import logging import unittest class SpecificFormatException(Exception): pass class MyClass(object): def __init__(self, record): raise TypeError class MyFormatter(logging.Formatter, object): def format(self, record): try: specific_format_record = MyClass(record) except TypeError: raise SpecificFormatException("Error raised") class TestLogger(unittest.TestCase): def test_my_logger(self): self.logger = logging.getLogger(self.__class__.__name__) handler = logging.FileHandler('test_logger.log') handler.setFormatter(fmt=MyFormatter()) self.logger.addHandler(handler) self.assertRaises(SpecificFormatException, self.logger.warn,"Log something") if __name__ == '__main__': unittest.main() I don't believe this behavior is normal. I expect error raised in a Formatter.format function, should be passed all the way up, but not consumed. I found a workaround: class CustomFileHandler(logging.FileHandler, object): def handleError(self, record): super(CustomFileHandler, self).handleError(record) raise But it looks ugly to add Custom*Handler for any default Handler (like, StreamHandler, etc) to make them possible to fall out on any error. There are raiseException switch in source of logging/__init__.py 92 #raiseExceptions is used to see if exceptions during handling should be 93 #propagated 94 # 95 raiseExceptions = 1 But all it switch is only is traceback printed or not. I think this behaviour is against Zen of Python: "Errors should never pass silently." May be logging library should be updated to contain 2 flags: printTracebacks and raiseExceptions ? From bex.lewis at gmail.com Tue Nov 22 10:46:43 2011 From: bex.lewis at gmail.com (becky_lewis) Date: Tue, 22 Nov 2011 07:46:43 -0800 (PST) Subject: (don't bash me too hard) Python interpreter in JavaScript References: <11816254.67.1321389423944.JavaMail.geo-discussion-forums@vbay19> Message-ID: <39d7d689-6953-4ae5-84f5-83d44eb9fd39@w7g2000yqc.googlegroups.com> On Nov 15, 8:37?pm, Passiday wrote: > Hello, > > I am looking for a way how to bring Python interpreter to JavaScript, in order to provide a web-based application with python scripting capabilities. The app would have basic IDE for writing and debugging the python code, but the interpretation, of course, would be done in JavaScript. I'd like to avoid any client-server transactions, so all the interpretation should take place on the client side. The purpose of all this would be to create educational platform for learning the programming in python. > > I hoped somebody already had done something like this, but I couldn't google up anything. I've found some crazy project emulating PC in JavaScript (and even running Linux on top of it), but not a python interpreter. > > Of course, I could take the python source and brutally recode it in JavaScript, but that seems like awful lot of work to do. Any ideas how I should proceed with this project? I think you may find it a little time consuming to reimpliment python in javascript. I'm inclined to say "go for it" though since you may create something awesome in the process ;) If you want to take an easier route, may I point out pythonanywhere.com? It doesn't run in the browser but does give safe access to multiple python interpreters and from my own use I can say that it works pretty well. You can even set up web apps using it. For educational purposes it might be helpful to you. From wolftracks at invalid.com Tue Nov 22 10:57:30 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 07:57:30 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: On 11/21/2011 11:21 AM, Dennis Lee Bieber wrote: > On Mon, 21 Nov 2011 08:39:37 -0800, "W. eWatson" > declaimed the following in > gmane.comp.python.general: > >> >> My criterion for success is that it puts IDLE as a choice for editor on >> the menu produced with a right-click on a py file. So far no response on >> this has solved the problem. >> >> I know it sets up that way on a 2.5 and 2.4 on other PCs I have. >> > I have three computers here: > > -=-=-=-=-=- Desktop > WinXP Pro 32-bit, 3.4GHz hyper-threaded P4 > ActiveState ActivePython 2.5.2.2 (Python 2.5.2) All of the above use ActiveState. I use whatever the Python organization provides on their download site. I would not expect the two to compare. > > -=-=-=-=-=- > > So, out of two generations of 32-bit Python 2.5, and 64 and 32 bit > versions of Python 2.7, on three computers, NONE of mine have a > right-click option for IDLE. > >> I do know that IDLE appears on the Win 7 Start menu, but, when used, >> nothing happens. Well, OK, for about 3 seconds the Win 7 "working" icon >> spins around then zip, nothing. Further, right-clicking on Properties >> of IDLE (GUI) produces a tabbed dialog. It shows Start in: >> c:\Python32\, and None for shortcut. There is a compatibility tab, > > But what does it show for TARGET! c:\Python32 Start in, and for Target: Python 3.2.2 (64-bit) For the shortcut C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python3.2 > >> Going directly to ...\Lib\idlelib\idle.pyw produces the spinning icon. >> At least, that's what happens in 3.2.2, but in the 32-bit versions I >> tried, I would get "invalid Win 32 app". >> > Possibly because you are trying to start a 32-bit version with a > default "open" for .pyw files that runs the 64-bit Python.exe; so the > DLLs are mixed architecture. 3.2.2 is 64-bit. > > >> Some have suggested a registry problem, but I don't have a clue how to >> play with that, or somehow clean it up, if there is a problem. My PC >> behaves normally >> > Since none of your problems appear to be related to Python itself, > but rather to the Windows configuration of the Python system, I'd have > to disagree. > >> I'm using Win 7 Premium. > > Home, Pro, Ultimate (or whatever the top level is? From wolftracks at invalid.com Tue Nov 22 11:12:13 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 08:12:13 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: On 11/21/2011 3:07 PM, Terry Reedy wrote: > On 11/21/2011 11:39 AM, W. eWatson wrote: >> >> My criterion for success is that it puts IDLE as a choice for editor on >> the menu produced with a right-click on a py file. > > Your first criterion for success should be that IDLE runs at all, which > is apparently does not. How you run it is secondary. > > Right-click responses are controlled by Windows using data in the > registry. Windows modifies the registry in response to installers *and > users*. The ActiveState installers request 'Edit with PythonWin'. They > do not request 'Edit with IDLE' and it is foolish to complain to us when > you use ActiveState and get their choice of context choices. ActiveState. Am I missing something? I'm running 64-bit Python downloaded from the Python organization's web site.l > > The PSF .msi installers (.msi = MicroSoftInstall format) from python.org > request 'Edit with IDLE' but cannot make Windows put it in. If your > registry is messed up enough, it does not happen. But no error message. > > I have explained to you another way to work with IDLE once it runs. It > you refuse to use it, that is your problem, not ours. > >> I know it sets up that way on a 2.5 and 2.4 on other PCs I have. > > You installed with the PSF installer with an ok registry. PSF? What does "ok registry" mean? > >> I know at one time it worked on my 64-bit Win 7 PC, which likely had a >> 32-bit version installed on it. After something like six months of >> modest use it stopped working as above. No IDLE choice. > > So some *other* program messed things up. Stop blaming us. > Heavy or modest use in the meantime is irrelevant. I'm blaming you??? I was just providing data for whatever it might be worth. I'm also suggesting that I do not have years of experience with Python. > >> I know by installing a 64-bit version, 3.2.2 failed the IDLE criterions >> as described. No IDLE. > > Did you uninstall the 32 bit version, and best, all Python versions? > >> I do know that IDLE appears on the Win 7 Start menu, but, when used, >> nothing happens. Well, OK, for about 3 seconds the Win 7 "working" icon >> spins around then zip, nothing. > > This is your real problem. Stop worrying about the context menu. I would expect consistency through all Python org releases. Should I put consistency in really bold letters with a 30 point font? :-) > > > Further, right-clicking on Properties of >> IDLE (GUI) produces a tabbed dialog. It shows Start in: c:\Python32\, > > This is the Shortcut tab. A shortcut is like a bound method. The > function is the target: 'python 3.2.2 (64 bit)' on my machine. The > starting directory is like a bound argument, although it is passed to > the launcher that launches the function. What the Properties dialog does > not show are the actual 'bound arguments' that are passed to the target > as options. So one cannot know what the shortcut is actually trying to > do. This is one of the Really Stupid things about Windows that should > have been fixed long ago but has not. I never use the shortcut on the Start menu. I mentioned the Start menu, since it might have some relevance. > >> and None for shortcut. > > None for Shortcut key, such as alt-I to invoke the shortcut. > >> There is a compatibility tab, which I've set to >> Win7. I think there's a troubleshooter there too, but I haven't used it. >> Under the Details tab, it shows Name: IDLE(Python Gui).lnk. Folder Path >> as: c:\ProgramData\Microsoft\Windows\Start... Nothing after the "...". > > Details: Folder Path is the same as General: Location. Mouse over the > latter the the full path appears. That Properties windows are still > fixed at 480 pixel wide, regardless of screen size, is another Really > Stupid thing. Yes, I finally realized I could mouse over it. > >> Going directly to ...\Lib\idlelib\idle.pyw produces the spinning icon. >> At least, that's what happens in 3.2.2, but in the 32-bit versions I >> tried, I would get "invalid Win 32 app". > > If the registry entry for .pyw is messed up, trying to run the file by > clicking on it is not likely to work. Try running from Command Prompt, > as I believe others suggested. I'm not trying to run the program, I'm trying to edit. Several times in these threads I've mentioned I can execute python from the command line. > >> When I rebooted my system a few hours after installing 3.2.2, because >> the PC was running really slowly--not because of Python, I was greeted >> by a couple of interesting messages as the desktop was populated. >> >> I can execute Python from the command line. >> >> 1. Specified module could not be found: Load Lib, python.dll. >> >> 2. \ProgramFiles(x86)\uniblueDrivers\Scanner (x86) Python26.dll. > > The uniblue drivers program will match your drivers against a database > of up-to-date drivers and offer to upgrade them. I have used uniblue's > registry scanner program. Treating pythonxy.dll as a driver, if they > are, is an error. These are paid programs. The free demos only scan to > tell you what they would do if you bought them. Yes. Just Winamp looking for $$$. > > > I'm sure this is related to Winamp, which I had installed a month ago. > > I do not believe they are the same companies, but they may have a > cross-promotion deal. Evidently. > >> had some "crazy" choice to scan for new drivers. Of course, if it found >> one-connected with Python, and if you wanted it, $$$. I think this >> message is a red herring. I may re-install Winamp to get rid of that >> uniblue tool that seems like nothing more than an ad. >> >> Some have suggested a registry problem, but I don't have a clue how to >> play with that, or somehow clean it up, if there is a problem. My PC >> behaves normally > > If you ran the psf 3.2.2 installer and idle does not run when you click > the start menu shortcut, something is wrong. Of course. Assuming psf means something like python software foundation. > >> Someone suggested using the mail list at >> . What's different >> about that list than this NG? Does the "org" suggest that the >> inhabitants of that list are more likely associated with the people who >> are responsible for constructing Python? > > Python list is mirror to comp.lang.python which is mirrored to a google > group. It is also mirrored to gmane.comp.python, which is how I read and > post. There is some spam filtering if you use the python.org list or > gmane group. > Good. Then I don't need it. From wolftracks at invalid.com Tue Nov 22 11:14:16 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 08:14:16 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> References: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> Message-ID: On 11/21/2011 7:00 PM, alex23 wrote: > "W. eWatson" wrote: >> Comments? > > Please don't start multiple threads on the same issue. Your joking, right, or do you just prefer 500 line threads wandering all over the place? From vinay_sajip at yahoo.co.uk Tue Nov 22 11:21:10 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 22 Nov 2011 08:21:10 -0800 (PST) Subject: Strange logging.Formatter behaviour References: Message-ID: On Nov 22, 3:19?pm, Tiaburn Stedd wrote: > I don't believe this behavior is normal. I expect error raised in a > Formatter.format function, should be passed all the way up, but not > consumed. > > I found a workaround: > > class CustomFileHandler(logging.FileHandler, object): > ? ? def handleError(self, record): > ? ? ? ? ?super(CustomFileHandler, self).handleError(record) > ? ? ? ? ?raise > > But it looks ugly to add Custom*Handler for any default Handler (like, > StreamHandler, etc) to make them possible to fall out on any error. > > There are raiseException switch in source of logging/__init__.py > > ? 92 #raiseExceptions is used to see if exceptions during handling > should be > ? 93 #propagated > ? 94 # > ? 95 raiseExceptions = 1 > > But all it switch is only is traceback printed or not. I think this > behaviour is against Zen of Python: "Errors should never pass > silently." They don't pass silently - raiseExceptions defaults to 1, so tracebacks are printed by default. In production, it's not a good idea for a potentially long-running process like a server to be brought down because someone put a typo in a logging format string, so the recommendation is to set raiseExceptions to 0/False in such scenarios. Since you are developing a custom formatter, you can certainly catch any formatting exceptions in your format method and decide what you want to do with them. The default handleError behaviour of printing a traceback is reasonable, in my view. If you want something else, you can subclass the relevant handler class; just setting a printTracebacks flag to false isn't going to get useful behaviour specific to individual requirements. There's no real point in throwing a very specific exception from a formatter, as a handler isn't going to automatically know how to handle a SpecificFormatException in any meaningful way. Remember that in the general case, application developers don't always have control of what handlers are configured for an application (for example, this could be set by end-user or per-deployment configuration). Regards, Vinay Sajip From dihedral88888 at googlemail.com Tue Nov 22 12:03:42 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 22 Nov 2011 09:03:42 -0800 (PST) Subject: decorators and closures In-Reply-To: References: Message-ID: <24059779.511.1321981422154.JavaMail.geo-discussion-forums@prou19> On Monday, November 21, 2011 10:44:34 PM UTC+8, Andrea Crotti wrote: > With one colleague I discovered that the decorator code is always > executed, every time I call > a nested function: > > def dec(fn): > print("In decorator") > def _dec(): > fn() > > return _dec > > def nested(): > @dec > def fun(): > print("here") > > nested() > nested() > > Will give: > In decorator > In decorator > > So we were wondering, would the interpreter be able to optimize this > somehow? > I was betting it's not possible, but I'm I would like to be wrong :) I love to use decorators. I did the same things to functions and structures in c long time ago. I think that might be the dark night era in programming in the early 90's long long ago. Cheers. From dihedral88888 at googlemail.com Tue Nov 22 12:03:42 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 22 Nov 2011 09:03:42 -0800 (PST) Subject: decorators and closures In-Reply-To: References: Message-ID: <24059779.511.1321981422154.JavaMail.geo-discussion-forums@prou19> On Monday, November 21, 2011 10:44:34 PM UTC+8, Andrea Crotti wrote: > With one colleague I discovered that the decorator code is always > executed, every time I call > a nested function: > > def dec(fn): > print("In decorator") > def _dec(): > fn() > > return _dec > > def nested(): > @dec > def fun(): > print("here") > > nested() > nested() > > Will give: > In decorator > In decorator > > So we were wondering, would the interpreter be able to optimize this > somehow? > I was betting it's not possible, but I'm I would like to be wrong :) I love to use decorators. I did the same things to functions and structures in c long time ago. I think that might be the dark night era in programming in the early 90's long long ago. Cheers. From RDRichardson at rad-con.com Tue Nov 22 13:32:53 2011 From: RDRichardson at rad-con.com (Rob Richardson) Date: Tue, 22 Nov 2011 18:32:53 +0000 Subject: What replaces log4py under Python 3.2? Message-ID: <67D108EDFAD3C148A593E6ED7DCB4BBDEDD0A5@RADCONWIN2K8PDC.radcon.local> Greetings! My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? Thank you. RobR From ameyer2 at yahoo.com Tue Nov 22 13:37:32 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 22 Nov 2011 13:37:32 -0500 Subject: Using the Python Interpreter as a Reference In-Reply-To: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <4ECBEBEC.2010300@yahoo.com> On 11/20/2011 7:46 PM, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. ... I have great respect for people who take on projects like this. Your chances of popularizing the language are small. There must be thousands of projects like this for every one that gets adopted by other people. However your chances of learning a great deal are large, including many things that you'll be able to apply to programs and projects that, at first glance, wouldn't appear to benefit from this kind of experience. If you get it working you'll have an impressive item to add to your resume. I suspect that you'll also have a lot of fun. Good luck with it. Alan From ameyer2 at yahoo.com Tue Nov 22 13:55:22 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 22 Nov 2011 13:55:22 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: <4ECBF01A.7060507@yahoo.com> On 11/21/2011 11:39 AM, W. eWatson wrote: > My criterion for success is that it puts IDLE as a choice for editor on > the menu produced with a right-click on a py file. So far no response on > this has solved the problem. ... I don't know what responses you're referring to since this is the first posting in the thread. It's possible what I'm about to say was already told to you - in which case I'm wasting my and everyone's time. However, leaving that aside, I think that this is trivially easy to solve. It has nothing whatever to do with Python or Idle - though it's possible that the Python installer could have done something for that it didn't - and it's also possible that the Python installer did what you told it to do but you told it the wrong thing, or you told Windows to change it without realizing that you did. (I do that all the time. A mouse slip and inadvertent click on the wrong object, a misunderstanding of a prompt, or lots of other missteps can change things without your having any idea what happened.) Anyway, if I understand what you're looking for, here's what you need to do to fix your problem: 1. Open Windows Explorer. 2. Navigate to a Python file. 3. Right click on the Python file with the mouse. 4. Select "Open With" 5. Select "Choose Default Program" 6. Select, or navigate to and select, the python IDLE interpreter. 7. Check the box that says "Always use the selected program to open this kind of file." 8. Click "OK". The prompts I described above are the ones I saw on my Windows Server 2008 machine. Yours may vary slightly, but I think the procedures should be the same. Please let us know if that solves your problem. Alan From andrea.crotti.0 at gmail.com Tue Nov 22 14:15:47 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 22 Nov 2011 19:15:47 +0000 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> Message-ID: <4ECBF4E3.9000007@gmail.com> On 11/22/2011 04:14 PM, W. eWatson wrote: > Your joking, right, or do you just prefer 500 line threads wandering > all over the place? I would personally prefer to just not see useless discussions about Windows set up in a python mailing list, but I guess it's a price to pay for the popularity of Python.. From ameyer2 at yahoo.com Tue Nov 22 14:29:18 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 22 Nov 2011 14:29:18 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ECBF01A.7060507@yahoo.com> References: <4ECBF01A.7060507@yahoo.com> Message-ID: <4ECBF80E.9090003@yahoo.com> On 11/22/2011 1:55 PM, Alan Meyer wrote: ... > 6. Select, or navigate to and select, the python IDLE interpreter. ... On my system that's C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe Alan From irmen at -NOSPAM-xs4all.nl Tue Nov 22 14:41:00 2011 From: irmen at -NOSPAM-xs4all.nl (Irmen de Jong) Date: Tue, 22 Nov 2011 20:41:00 +0100 Subject: What replaces log4py under Python 3.2? In-Reply-To: References: Message-ID: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> On 22-11-11 19:32, Rob Richardson wrote: > Greetings! > > My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? The logging module from Python's stdlib? http://docs.python.org/py3k/library/logging.html Irmen From tjreedy at udel.edu Tue Nov 22 17:50:35 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 22 Nov 2011 17:50:35 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: Message-ID: On 11/22/2011 1:01 PM, Dennis Lee Bieber wrote: >> c:\Python32 Start in, and for Target: Python 3.2.2 (64-bit) > > Which tells me that the TARGET field is garbaged, The above is exactly what my IDLE shortcut target field says, and it works fine. > since THAT is what specifies the program (and arguments) > that has to be run when the shortcut is double-clicked. It would be nice if it DID show all that info. > Try editing the target field to read (presuming the 3.x branch of > Python keeps the same library structure): > > c:\python32\lib\idlelib\idle.bat > > save the change, and then select the short-cut to see if it runs. Target for the .msi created shortcut cannot be edited, even as admin. -- Terry Jan Reedy From wolftracks at invalid.com Tue Nov 22 22:29:57 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 19:29:57 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ECBF80E.9090003@yahoo.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/22/2011 11:29 AM, Alan Meyer wrote: > On 11/22/2011 1:55 PM, Alan Meyer wrote: > ... >> 6. Select, or navigate to and select, the python IDLE interpreter. > ... > On my system that's > C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe > > Alan OK, I'm going to try it soon. Keeping my fingers crossed. From ameyer2 at yahoo.com Tue Nov 22 22:45:41 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 22 Nov 2011 22:45:41 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <4ECC6C65.2090902@yahoo.com> On 11/22/2011 3:05 PM, Dennis Lee Bieber wrote: > On Tue, 22 Nov 2011 14:29:18 -0500, Alan Meyer > declaimed the following in gmane.comp.python.general: > >> On 11/22/2011 1:55 PM, Alan Meyer wrote: >> ... >>> 6. Select, or navigate to and select, the python IDLE interpreter. >> ... >> On my system that's >> C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe >> > Note that this is not the Tk based IDLE (which is implemented, > itself, as a .pyw file and is not natively executable -- which seems to > be one of the problems; Win7 has removed the detailed file type > association windows so you can't specify that the "application" is > pythonw.exe running idle.pyw using one's selected file as the argument > to the mess). Bummer! Sorry W.eWatson, my instructions may not work. I've got the ActiveState Python on my Windows machine. It runs a .exe file as the IDLE executable. If your implementation doesn't have an exe then you're going to have to do some more complex work. Since I don't have the version of Python from python.org under Windows, I can't really advise on what to do with that. If you haven't got an exe, my instructions will only work if you install the ActiveState version, which does have one. Alan From wolftracks at invalid.com Tue Nov 22 22:46:01 2011 From: wolftracks at invalid.com (W. eWatson) Date: Tue, 22 Nov 2011 19:46:01 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/22/2011 7:29 PM, W. eWatson wrote: > On 11/22/2011 11:29 AM, Alan Meyer wrote: >> On 11/22/2011 1:55 PM, Alan Meyer wrote: >> ... >>> 6. Select, or navigate to and select, the python IDLE interpreter. >> ... >> On my system that's >> C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe >> >> Alan > OK, I'm going to try it soon. Keeping my fingers crossed. Well, all there was there was a README.txt file that told me the purpose of the folder. "This directory exists so that 3rd party packages can be installed here. Read the source for site.py for more details." Of course, Dennis' C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe wouldn't work either. I did a Win 7 search Pythonwin.exe, and found nothing. However, sometimes that search fails even when though there is something on the PC that matches the search. There is a pythonw.exe under C:\Python32. From snorble at hotmail.com Wed Nov 23 00:19:21 2011 From: snorble at hotmail.com (snorble) Date: Tue, 22 Nov 2011 21:19:21 -0800 (PST) Subject: Writing code to be optimizable Message-ID: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> Sometimes I want to prototype a program in Python, with the idea of optimizing it later by rewriting parts of it in C or Cython. But I usually find that in order to rewrite the slow parts, I end up writing those parts very much like C or C++ anyway, and I end up wondering what is the point of using Python in such a project. I liked the idea of Cython, mainly the idea of being able to write in pure Python, then create a file that modifies the pure Python file (with type declarations and such), but I ran into the same problems. In order to be able to modify the code, I can't make a lot of use of the really helpful things in Python like dicts and such. I have to dumb down Python to where I'm basically writing C code in Python, so again I ask myself what is the point? Is it reasonable to prototype an application in Python that will require performance? Are there any recommendations on how to write code in such a way that it can later be optimized or replaced with a module written in C or Cython? Or any good examples of this being done that I could learn from? From Nikunj.Badjatya at emc.com Wed Nov 23 00:44:50 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Wed, 23 Nov 2011 00:44:50 -0500 Subject: Thread problem Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D616@MX34A.corp.emc.com> Howdy All, Please see http://pastebin.com/GuwH8B5C . Its a sample program implementing progressbar in multithreaded program. Here I am creating a thread and passing update2() function to it. Now wheneever I press CTRL-C, the program isnt returning to prompt. ! Can someone help me out with this please. ! Thanks Nikunj -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Wed Nov 23 01:45:07 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 23 Nov 2011 17:45:07 +1100 Subject: Writing code to be optimizable In-Reply-To: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> References: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> Message-ID: On Wed, Nov 23, 2011 at 4:19 PM, snorble wrote: > Sometimes I want to prototype a program in Python, with the idea of > optimizing it later by rewriting parts of it in C or Cython. But I > usually find that in order to rewrite the slow parts, I end up writing > those parts very much like C or C++ anyway, and I end up wondering > what is the point of using Python in such a project. There's a few ways to prototype. If you use Python as the language of your specs documents (or pseudo-Python, perhaps) - consider the entire Python implementation as ephemeral, and use it to verify that your specifications are correct, but not for any sort of performance - then it doesn't matter that you've rewritten it completely, nor that you've written C code in Python. You would have been writing C code in English otherwise, anyway. If you're not sure which parts you're prototyping (ie will rewrite in C/C++) and which parts you're writing properly (ie will keep the Python version as the production code), I'd still recommend using all of Python's best features... but keep your function docstrings comprehensive. When you rewrite it in C, you're able to take advantage of what you learned first time around, but otherwise it's just strictly reimplementing the docstring in a different environment. Chris Angelico From atadesse at sunedison.com Wed Nov 23 01:48:19 2011 From: atadesse at sunedison.com (Alemu Tadesse) Date: Wed, 23 Nov 2011 00:48:19 -0600 Subject: What I do and do not know about installing Python on Win 7 withregard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com><4ECBF80E.9090003@yahoo.com> Message-ID: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019677F1@mail.sunedison.com> I just subscribed for python and I am VERY NEW. I would like to have a an IDLE. My texts are just the same whether it is comment or def or statement or ...... how am I going to make it highlighted ..my scientific package is not working and complaining about not able to find/load DLL ... frustrating for the first day in the python world. ANY tip ? Thanks Alemu -----Original Message----- From: python-list-bounces+atadesse=sunedison.com at python.org [mailto:python-list-bounces+atadesse=sunedison.com at python.org] On Behalf Of Dennis Lee Bieber Sent: Tuesday, November 22, 2011 11:43 PM To: python-list at python.org Subject: Re: What I do and do not know about installing Python on Win 7 withregard to IDLE. On Tue, 22 Nov 2011 19:46:01 -0800, "W. eWatson" declaimed the following in gmane.comp.python.general: > > Of course, Dennis' > C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe > wouldn't work either. > If you didn't install an ActiveState packaged version, nor hand installed the win32 extension package into a Python.org installed system, you won't have PythonWin. > I did a Win 7 search Pythonwin.exe, and found nothing. However, > sometimes that search fails even when though there is something on the > PC that matches the search. > > There is a pythonw.exe under C:\Python32. And has been mentioned at least three times in the last week -- pythonw.exe is the version of the Python interpreter that is supposed to be the default application for .pyw files. It is the version that does NOT open a console window for stdin/stdout (IOWs, it is meant for use by Python scripts that use a graphical library for all I/O -- Tk, wxPython, etc.). If you ran a graphical script using the plain python.exe it would open a console window that would just sit there until the script exited. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- http://mail.python.org/mailman/listinfo/python-list From stefan_ml at behnel.de Wed Nov 23 02:37:53 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 23 Nov 2011 08:37:53 +0100 Subject: Writing code to be optimizable In-Reply-To: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> References: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> Message-ID: snorble, 23.11.2011 06:19: > Sometimes I want to prototype a program in Python, with the idea of > optimizing it later by rewriting parts of it in C or Cython. But I > usually find that in order to rewrite the slow parts, I end up writing > those parts very much like C or C++ anyway, and I end up wondering > what is the point of using Python in such a project. > > I liked the idea of Cython, mainly the idea of being able to write in > pure Python, then create a file that modifies the pure Python file > (with type declarations and such), but I ran into the same problems. > In order to be able to modify the code, I can't make a lot of use of > the really helpful things in Python like dicts and such. I have to > dumb down Python to where I'm basically writing C code in Python, so > again I ask myself what is the point? > > Is it reasonable to prototype an application in Python that will > require performance? Are there any recommendations on how to write > code in such a way that it can later be optimized or replaced with a > module written in C or Cython? I think the usual approach is to write it in Python and make sure it works by writing "enough" tests, then benchmark it, then decide if a non-Python level optimisation is required. If it's required, Cython compile the entire module and add static types to your hot spots, either in Python notation ("pure mode") or in an external .pxd file. If that doesn't yield enough performance, copy code into a separate Cython module and optimise it there using C paradigms instead of Python paradigms, i.e. apply algorithmic optimisations by dropping data structures into C. Then use an import to use the code from your so-called accelerator module in your original module. Try to provide both a pure Python implementation and a Cython implementation, as that will allow you to run your code in other Python implementations directly and to compare your two implementations for equivalence and performance. The advantage of stepping down into C-ish Cython code incrementally is that you will have a working implementation at each step and can decide to stop optimising because it is "good enough". If you started 'optimising' your code while still writing it, it will take longer to write it and you can never be sure that the complexity you add to the long-term maintenance by writing C-ish code is truly worth the performance gain (or if there even is any gain). Stefan From as at sci.fi Wed Nov 23 04:19:14 2011 From: as at sci.fi (Anssi Saari) Date: Wed, 23 Nov 2011 11:19:14 +0200 Subject: Python 2.7.2 on Win7 and IDLE (Try it) References: Message-ID: "W. eWatson" writes: > One thing I think no one has offered is whether their installation of > 2.7.2 has the same IDLE oddity that I've described. That is, if you > right-click on a py file, do you see a choice for the IDLE editor? I don't have 2.7.2, but my Windows (7, 32 bit) machine has 3.2 installed and also 2.6.6 included in Python(x,y) distribution. Right clicking on a .py has, under Open with, the choices GNU Emacsclient (my choice for editing), python.exe and pythonw.exe. No Idle. I was able to add idle to the menu it by clicking "Choose default program" in the menu and pointing that to idle.bat. From as at sci.fi Wed Nov 23 04:23:19 2011 From: as at sci.fi (Anssi Saari) Date: Wed, 23 Nov 2011 11:23:19 +0200 Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: goldtech writes: > Using Windows. Is there a python shell that has a history of typed in > commands? Is there a shell that doesn't have history then? At least both the vanilla shell and Idle both have basic history in Windows. IPython for more fun. From r32813 at freescale.com Wed Nov 23 04:54:22 2011 From: r32813 at freescale.com (Wong Wah Meng-R32813) Date: Wed, 23 Nov 2011 09:54:22 +0000 Subject: import _tclinter error in python 2.7.1 Itanium build Message-ID: <02EA6D704E30CE499C5071776509A925F9DC74@039-SN1MPN1-002.039d.mgd.msft.net> Hello there, I am in the midst of converting my application code from python 1.5.2 to python 2.7.1. In the build of my python 2.7.1 on Itanium 64-bit HP11.3 platform, I noticed my Tkinter module was built and linked successfully, that I am able to import the module and use it. However, I just found out that my application that utilizes Tcl/Tk code, somehow wants to use _tclinter, instead of using _tkinter (In fact I have a Tkinter.py file) . The only comment I can see from the author is "Have Pic use Tclinter instead of Tkinter to allow Pic to start with a valid X Display". That comment was left at the time python 1.5.2 and tcl/tk 8.1 (maybe) was used and I am not sure if the same issue is applicable to the current version of python and tcl/tk. However, the question I want to ask is, I build python when tcl/tk files are both available, why only tk is detected and built-in with python, not tcl? $ python Python 2.7.1 (r271:86832, Oct 6 2011, 11:10:10) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkinter >>> import Tclinter Traceback (most recent call last): File "", line 1, in File "Tclinter.py", line 5, in import _tclinter # If this fails your Python is not configured for Tcl ImportError: No module named _tclinter >>> import _tclinter Traceback (most recent call last): File "", line 1, in ImportError: No module named _tclinter >>> import _tkinter >>> Regards, Wah Meng -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Wed Nov 23 05:29:28 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Nov 2011 10:29:28 GMT Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> On Wed, 23 Nov 2011 11:23:19 +0200, Anssi Saari wrote: > goldtech writes: > >> Using Windows. Is there a python shell that has a history of typed in >> commands? > > Is there a shell that doesn't have history then? At least both the > vanilla shell and Idle both have basic history in Windows. IPython for > more fun. The default interactive interpreter for Python doesn't have persistent history, so if you exit the interpreter and restart it, your commands are gone. -- Steven From mail at timgolden.me.uk Wed Nov 23 05:37:56 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Nov 2011 10:37:56 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ECCCD04.1060408@timgolden.me.uk> On 23/11/2011 10:29, Steven D'Aprano wrote: > On Wed, 23 Nov 2011 11:23:19 +0200, Anssi Saari wrote: > >> goldtech writes: >> >>> Using Windows. Is there a python shell that has a history of typed in >>> commands? >> >> Is there a shell that doesn't have history then? At least both the >> vanilla shell and Idle both have basic history in Windows. IPython for >> more fun. > > The default interactive interpreter for Python doesn't have persistent > history, so if you exit the interpreter and restart it, your commands are > gone. Not quite The interpreter inherits the command shell's history function: Open a cmd window and then a Python session. Do some stuff. Ctrl-Z to exit to the surrounding cmd window. Do some random cmd stuff: dir, cd, etc. Start a second Python session. up-arrow etc. will bring back the previous Python session's commands (and not the ones you entered in the surrounding shell) Obviously this only applies when an underlying cmd session persists -- if you simply start Python from Start > Run twice the command history will not persist between sessions. TJG From k.sahithi2862 at gmail.com Wed Nov 23 07:09:32 2011 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Wed, 23 Nov 2011 04:09:32 -0800 (PST) Subject: WORLD BEST PICS Message-ID: <29b6c18c-a72a-46d2-94a1-5bfc9c0f8dff@e34g2000prh.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ SIMHAPUTHRUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/simhaputhrudu-movie-stills.html SOLO MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/solo-movie-stills.html BEZAWADA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/bezawada-movie-stills.html RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS SARAH JANE DIAS HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/sarah-jane-dias-hot.html KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html POONAM KAUR HOT ROMANTIC STILLS http://hotactress-kalyani.blogspot.com/2011/11/poonam-kaur-hot.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From python at bdurham.com Wed Nov 23 07:11:16 2011 From: python at bdurham.com (python at bdurham.com) Date: Wed, 23 Nov 2011 07:11:16 -0500 Subject: Choosing a Windows C compiler for use with Cython and 32-bit Python 2.7 Message-ID: <1322050276.28050.140661002645593@webmail.messagingengine.com> Looking for some tips on getting started with Cython development under Windows. I am using Python 2.7.2. After reading the Cython documentation [1] it appears that one has a choice of using either the MinGW or MS Visual C compiler. 1. Are there any issues associated with using the MinGW compiler and mixing C runtimes? This seems the be the simplest and fastest way to get started with the tradeoff being the need to distribute another C runtime (in addition to the MS C runtime required for the Python interpreter itself) 2. Regarding the MS Visual C compiler - can one use the C compiler that ships with one of the free Express editions of Visual Studio or must one purchase a full version of MS Visual Studio to get the appropriate compiler? 3. Which version (2005, 2008, 2010, ...) of MS Visual Studio is required to compile Cython libraries compatible with the 32 bit version of Python 2.7.2? Thank you, Malcolm [1] http://docs.cython.org/src/quickstart/install.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From as at sci.fi Wed Nov 23 07:16:52 2011 From: as at sci.fi (Anssi Saari) Date: Wed, 23 Nov 2011 14:16:52 +0200 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: Message-ID: Dennis Lee Bieber writes: >> c:\Python32 Start in, and for Target: Python 3.2.2 (64-bit) > > Which tells me that the TARGET field is garbaged, since THAT is what > specifies the program (and arguments) that has to be run when the > shortcut is double-clicked. Actually, no, it's what I have too. 32-bit Windows 7 here and Python 3.2. The Target for the Idle shortcut is just Python 3.2. It's also greyed out and uneditable. So yes, weird. Mine works though and I rarely use Idle, so no complaints. From lists at cheimes.de Wed Nov 23 07:27:46 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 23 Nov 2011 13:27:46 +0100 Subject: Choosing a Windows C compiler for use with Cython and 32-bit Python 2.7 In-Reply-To: <1322050276.28050.140661002645593@webmail.messagingengine.com> References: <1322050276.28050.140661002645593@webmail.messagingengine.com> Message-ID: Am 23.11.2011 13:11, schrieb python at bdurham.com: > Looking for some tips on getting started with Cython development > under Windows. I am using Python 2.7.2. > > After reading the Cython documentation [1] it appears that one > has a choice of using either the MinGW or MS Visual C compiler. > > 1. Are there any issues associated with using the MinGW compiler > and mixing C runtimes? This seems the be the simplest and fastest > way to get started with the tradeoff being the need to distribute > another C runtime (in addition to the MS C runtime required for > the Python interpreter itself) No, don't worry. MinGW from msys can link against almost any C runtime library. > 2. Regarding the MS Visual C compiler - can one use the C > compiler that ships with one of the free Express editions of > Visual Studio or must one purchase a full version of MS Visual > Studio to get the appropriate compiler? > > 3. Which version (2005, 2008, 2010, ...) of MS Visual Studio is > required to compile Cython libraries compatible with the 32 bit > version of Python 2.7.2? I've explained everything in PCbuild/readme.txt in great detail. Summary: You can use the free VS 2088 Express Edition if you don't need PGO or AMD64 builds. Christian From vinay_sajip at yahoo.co.uk Wed Nov 23 07:54:16 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Wed, 23 Nov 2011 04:54:16 -0800 (PST) Subject: Peculiarity of '@' in logging.Formatter References: <29760946.94.1321917425036.JavaMail.geo-discussion-forums@yqoo7> Message-ID: <92b117a3-21b6-46ae-9063-00d85a8d3ff8@s4g2000yqk.googlegroups.com> On Nov 21, 11:17?pm, Charlie Martin wrote: > This is what seems like an odd bug, but in code I'd > thing often-enough used it must be the expected behavior > and I just don't understand. ?Please, sirs/mesdames, is > this a bug? It may be a bug, but if so, it's in the syslog daemon rather than logging. Please try again with FileHandlers in place of SysLogHandlers, and confirm whether the anomaly still occurs. I could reproduce the problem on a Suse 11.3 machine running Python 2.6, but it doesn't occur on Ubuntu for example: Nov 23 12:33:09 eta-jaunty [slhtest3:026]:My log message:isn't it special? Nov 23 12:33:09 eta-jaunty [slhtest3 at 026]:My log message:isn't it special? I get the same (expected) result on Ubuntu for both Python 2.6 and 2.7. I noticed that on Suse the syslog daemon is rsyslogd, whereas on Ubuntu it's plain syslogd. Daemons do differ on how they parse messages :-( I ran the script with strace, and logging is writing correctly to the socket: socket(PF_FILE, SOCK_DGRAM, 0) = 3 connect(3, {sa_family=AF_FILE, path="/dev/log"}, 10) = 0 socket(PF_FILE, SOCK_DGRAM, 0) = 4 connect(4, {sa_family=AF_FILE, path="/dev/log"}, 10) = 0 gettimeofday({1322052499, 78501}, NULL) = 0 send(3, "<14>[slhtest:026]:My log message"..., 51, 0) = 51 send(4, "<14>[slhtest at 026]:My log message"..., 51, 0) = 51 close(4) = 0 close(3) = 0 This is on Suse 11.3, where the formatting anomaly does occur - so it appears to be down to how rsyslogd does things. Regards, Vinay Sajip From roy at panix.com Wed Nov 23 08:31:57 2011 From: roy at panix.com (Roy Smith) Date: Wed, 23 Nov 2011 08:31:57 -0500 Subject: Writing code to be optimizable References: <63e78437-c76b-4a9e-9a62-bfea8d078208@v5g2000yqn.googlegroups.com> Message-ID: In article <63e78437-c76b-4a9e-9a62-bfea8d078208 at v5g2000yqn.googlegroups.com>, snorble wrote: > Is it reasonable to prototype an application in Python that will > require performance? Yes. Several observations: 1) The classic 80/20 rule. 80% of the time is spent running 20% of the code. Sometimes quoted as 90/10. Why waste time optimizing the 80%? 2) Surprisingly to many people, it's difficult to predict in advance which 20% will be the slow parts. Don't sweat it until the whole thing is up and running and you can begin to gather profiling data. 3) Often enough, when you're done writing your program, you'll discover that it's fast enough to get value from. Be happy and move onto the next task on your list. > Are there any recommendations on how to write code in such a way that > it can later be optimized or replaced with a module written in C or > Cython? Sure. Make your code modular and loosely coupled. Each module or class should do one thing, and have narrow, well-defined interfaces. Limit the number of other modules or classes it interacts with directly. If you've done that, it becomes easier to a) identify the slow parts and b) plug something better in its place. From RDRichardson at rad-con.com Wed Nov 23 09:07:34 2011 From: RDRichardson at rad-con.com (Rob Richardson) Date: Wed, 23 Nov 2011 14:07:34 +0000 Subject: What replaces log4py under Python 3.2? In-Reply-To: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> References: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> Message-ID: <67D108EDFAD3C148A593E6ED7DCB4BBDEDD182@RADCONWIN2K8PDC.radcon.local> Thank you for that link. Our customers are used to the rotating log file capability of the log4py package. I did not see anything in that link that talks about rotating log files (changing file name when the date changes, and saving a limited number of old log files). Is that possible using the stdlib logging package? Is there something else available that will do that, so we don't have to roll our own (or, more likely, stick to Python 2.7, for which log4py works)? Thanks again! RobR -----Original Message----- From: python-list-bounces+rob.richardson=rad-con.com at python.org [mailto:python-list-bounces+rob.richardson=rad-con.com at python.org] On Behalf Of Irmen de Jong Sent: Tuesday, November 22, 2011 2:41 PM To: python-list at python.org Subject: Re: What replaces log4py under Python 3.2? On 22-11-11 19:32, Rob Richardson wrote: > Greetings! > > My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? The logging module from Python's stdlib? http://docs.python.org/py3k/library/logging.html Irmen -----Original Message----- From: python-list-bounces+rob.richardson=rad-con.com at python.org [mailto:python-list-bounces+rob.richardson=rad-con.com at python.org] On Behalf Of Irmen de Jong Sent: Tuesday, November 22, 2011 2:41 PM To: python-list at python.org Subject: Re: What replaces log4py under Python 3.2? On 22-11-11 19:32, Rob Richardson wrote: > Greetings! > > My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? The logging module from Python's stdlib? http://docs.python.org/py3k/library/logging.html Irmen -- http://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Wed Nov 23 09:18:26 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 23 Nov 2011 15:18:26 +0100 Subject: What replaces log4py under Python 3.2? References: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> <67D108EDFAD3C148A593E6ED7DCB4BBDEDD182@RADCONWIN2K8PDC.radcon.local> Message-ID: Rob Richardson wrote: > Our customers are used to the rotating log file capability of the log4py > package. I did not see anything in that link that talks about rotating > log files (changing file name when the date changes, and saving a limited > number of old log files). Is that possible using the stdlib logging > package? How about http://docs.python.org/py3k/library/logging.handlers.html#timedrotatingfilehandler From alec.taylor6 at gmail.com Wed Nov 23 10:06:33 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 24 Nov 2011 02:06:33 +1100 Subject: What replaces log4py under Python 3.2? In-Reply-To: References: <4ecbfacc$0$6859$e4fe514c@news2.news.xs4all.nl> <67D108EDFAD3C148A593E6ED7DCB4BBDEDD182@RADCONWIN2K8PDC.radcon.local> Message-ID: zing! On Thu, Nov 24, 2011 at 1:18 AM, Peter Otten <__peter__ at web.de> wrote: > Rob Richardson wrote: > >> Our customers are used to the rotating log file capability of the log4py >> package. ?I did not see anything in that link that talks about rotating >> log files (changing file name when the date changes, and saving a limited >> number of old log files). ?Is that possible using the stdlib logging >> package? > > How about > > http://docs.python.org/py3k/library/logging.handlers.html#timedrotatingfilehandler > > > -- > http://mail.python.org/mailman/listinfo/python-list From atadesse at sunedison.com Wed Nov 23 10:40:46 2011 From: atadesse at sunedison.com (Alemu Tadesse) Date: Wed, 23 Nov 2011 09:40:46 -0600 Subject: Python 2.7.2 on XP In-Reply-To: References: Message-ID: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> Dear All, I am new to python. I do not know why my python editor (for 2.7.2) changes everything to just black and white after saving. No color for say the built in functions for loops defs .... they all look the same - it is annoying for someone coming from another editors that help you track/easily see your work. I just un installed it to install it again. I know it is pain to install all the scientific things again. I wish Python has something like R (R-studio) from which you can install packages very easily. I just started yesterday and already frustrated with it. I am sticking to python only because I hear good things about it and I think it is my problem. Thank you all Alemu From gordon at panix.com Wed Nov 23 11:08:12 2011 From: gordon at panix.com (John Gordon) Date: Wed, 23 Nov 2011 16:08:12 +0000 (UTC) Subject: What I do and do not know about installing Python on Win 7 withregard to IDLE. References: <4ECBF01A.7060507@yahoo.com><4ECBF80E.9090003@yahoo.com> Message-ID: In "Alemu Tadesse" writes: > scientific package is not working and complaining about not able to > find/load DLL ... frustrating for the first day in the python world. ANY > tip ? Post the exact error message you're getting. Also post your code, if it's not too long. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From gordon at panix.com Wed Nov 23 11:11:25 2011 From: gordon at panix.com (John Gordon) Date: Wed, 23 Nov 2011 16:11:25 +0000 (UTC) Subject: Python 2.7.2 on XP References: Message-ID: In "Alemu Tadesse" writes: > I am new to python. I do not know why my python editor (for 2.7.2) > changes everything to just black and white after saving. No color for What editor are you using? There are quite a lot of them. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From massi_srb at msn.com Wed Nov 23 12:10:09 2011 From: massi_srb at msn.com (Massi) Date: Wed, 23 Nov 2011 09:10:09 -0800 (PST) Subject: String splitting by spaces question Message-ID: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Hi everyone, I have to parse a string and splitting it by spaces. The problem is that the string can include substrings comprises by quotations which must mantain the spaces. What I need is to pass from a string like: This is an 'example string' to the following vector: ["This", "is", "an", "example string"] Which is the best way to achieve this? Thanks in advance! From atadesse at sunedison.com Wed Nov 23 12:31:21 2011 From: atadesse at sunedison.com (Alemu Tadesse) Date: Wed, 23 Nov 2011 11:31:21 -0600 Subject: String splitting by spaces question In-Reply-To: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: <6FA6EB75E3CA4744ADF9EF97D8DAC18B01967924@mail.sunedison.com> Hi Everyone, Can we use rsplit function on an array or vector of strings ? it works for one not for vector Alemu -----Original Message----- From: python-list-bounces+atadesse=sunedison.com at python.org [mailto:python-list-bounces+atadesse=sunedison.com at python.org] On Behalf Of Massi Sent: Wednesday, November 23, 2011 10:10 AM To: python-list at python.org Subject: String splitting by spaces question Hi everyone, I have to parse a string and splitting it by spaces. The problem is that the string can include substrings comprises by quotations which must mantain the spaces. What I need is to pass from a string like: This is an 'example string' to the following vector: ["This", "is", "an", "example string"] Which is the best way to achieve this? Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list From wolftracks at invalid.com Wed Nov 23 12:33:55 2011 From: wolftracks at invalid.com (W. eWatson) Date: Wed, 23 Nov 2011 09:33:55 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/22/2011 10:43 PM, Dennis Lee Bieber wrote: > On Tue, 22 Nov 2011 19:46:01 -0800, "W. eWatson" > declaimed the following in > gmane.comp.python.general: > >> >> Of course, Dennis' >> C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe >> wouldn't work either. >> > If you didn't install an ActiveState packaged version, nor hand > installed the win32 extension package into a Python.org installed > system, you won't have PythonWin. > >> I did a Win 7 search Pythonwin.exe, and found nothing. However, >> sometimes that search fails even when though there is something on the >> PC that matches the search. >> >> There is a pythonw.exe under C:\Python32. > > And has been mentioned at least three times in the last week -- > pythonw.exe is the version of the Python interpreter that is supposed to > be the default application for .pyw files. It is the version that does > NOT open a console window for stdin/stdout (IOWs, it is meant for use by > Python scripts that use a graphical library for all I/O -- Tk, wxPython, > etc.). If you ran a graphical script using the plain python.exe it would > open a console window that would just sit there until the script exited. Glad to hear you're keeping count. :-) I'll pin it on my wall. Don't use graphics. From wolftracks at invalid.com Wed Nov 23 12:35:04 2011 From: wolftracks at invalid.com (W. eWatson) Date: Wed, 23 Nov 2011 09:35:04 -0800 Subject: What I do and do not know about installing Python on Win 7 withregard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com><4ECBF80E.9090003@yahoo.com> Message-ID: On 11/23/2011 8:08 AM, John Gordon wrote: > In "Alemu Tadesse" writes: > >> scientific package is not working and complaining about not able to >> find/load DLL ... frustrating for the first day in the python world. ANY >> tip ? > > Post the exact error message you're getting. Also post your code, if it's > not too long. > And post it in a new thread. From wolftracks at invalid.com Wed Nov 23 12:38:36 2011 From: wolftracks at invalid.com (W. eWatson) Date: Wed, 23 Nov 2011 09:38:36 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: So unless Alan Meyer has further interest in this, it looks like it's at an end. It may be time to move on to c++. From arnodel at gmail.com Wed Nov 23 12:40:37 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 23 Nov 2011 17:40:37 +0000 Subject: String splitting by spaces question In-Reply-To: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: On 23 November 2011 17:10, Massi wrote: > Hi everyone, > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces. What I need is to pass from a string like: > > This is an 'example string' > > to the following vector: You mean "list" > ["This", "is", "an", "example string"] > Here's a way: >>> s = "This is an 'example string' with 'quotes again'" >>> [x for i, p in enumerate(s.split("'")) for x in ([p] if i%2 else p.split())] ['This', 'is', 'an', 'example string', 'with', 'quotes again'] -- Arnaud From nicholas.dokos at hp.com Wed Nov 23 12:51:12 2011 From: nicholas.dokos at hp.com (Nick Dokos) Date: Wed, 23 Nov 2011 12:51:12 -0500 Subject: String splitting by spaces question In-Reply-To: Message from "Alemu Tadesse" of "Wed, 23 Nov 2011 11:31:21 CST." <6FA6EB75E3CA4744ADF9EF97D8DAC18B01967924@mail.sunedison.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> <6FA6EB75E3CA4744ADF9EF97D8DAC18B01967924@mail.sunedison.com> Message-ID: <27191.1322070672@alphaville.dokosmarshall.org> Alemu Tadesse wrote: > Can we use rsplit function on an array or vector of strings ? it works > for one not for vector > ... > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces. What I need is to pass from a string like: > > This is an 'example string' > > to the following vector: > > ["This", "is", "an", "example string"] > > Which is the best way to achieve this? > Thanks in advance! You can use a list comprehension: l2 = [x.rsplit(...) for x in l] But for the original question, maybe the csv module would be more useful: you can change delimiters and quotechars to match your input: import csv reader = csv.reader(open("foo.txt", "rb"), delimiter=' ', quotechar="'") for row in reader: print row Nick From kliateni at gmail.com Wed Nov 23 13:04:54 2011 From: kliateni at gmail.com (Karim) Date: Wed, 23 Nov 2011 19:04:54 +0100 Subject: Template class and class design on concrete example xl2csv writer Message-ID: <4ECD35C6.4070306@gmail.com> Hello All, I have the following code and I am quite satisfied with its design BUT I have the feeling I can do better. Basically the, main() execute the program (I did not put the parsing of arguments function). I am opening an Excel document and writing content in a CSV one w/ different format. The design is an abstract template class XLWriter, and derived 'Xl2Csv', 'Xl2Scsv', 'Xl2text' classes to write the correct ASCII DOCUMENT to correct format. The property hook method file_format is implement in these classes and return an object of type 'XlCsvFileFormat' or 'XlTabFileFormat'. It allows to put the right file extension and delimiter. These class are derived from standard csv.excel and csv.excel_tab. At last a Factory class MakeXlWriter has the job to create the correct writer. For now I did not add a strategy pattern which usually goes with the Template pattern. Except from that all better design or others critics will be welcome. Regards karim _______________________________________________________________________________________________________________________________________ from __future__ import print_function import sys, os, argparse, csv, xlrd __all__ = ['main', 'Xl2CsvError', 'XLWriter', 'XlCsvFileFormat', 'XlTabFileFormat', 'Xl2Csv', 'Xl2Scsv', 'Xl2text', 'MakeXlWriter'] class Xl2CsvError(Exception): """The exception class to manage the internal program errors.""" pass class XlWriter(object): """Abstract template class.""" def __init__(self, xlfilename=None, sheets=None): """Initializer.""" if self.__class__.__name__ == 'XlWriter': raise TypeError('Abstract template Class XlWriter could not be instanciated directly!') if not xlfilename: raise Xl2CsvError('Please provide a non empty file name!') else: self._source_name = xlfilename self._book = xlrd.open_workbook(xlfilename) if sheets is not None: if isinstance(sheets[0], int): self._selected_sheets = [self._book.sheet_by_index(sheetnum-1) for sheetnum in sheets] elif isinstance(sheets[0], str): try: self._selected_sheets = [self._book.sheet_by_name(sheetname) for sheetname in sheets] except xlrd.biffh.XLRDError, e: print('{0} in file document {1}'.format(e, xlfilename)) sys.exit(1) else: raise Xl2CsvError('Sheets element type not recognized!') else: self._selected_sheets = self._book.sheets() def write(self): """The file extraction public method.""" for sheet in self._selected_sheets: xlfilename = '{sheet}{ext}'.format(sheet=sheet.name, ext='.'+self.file_format.extension.lower()) try: writer = csv.writer(open(xlfilename, 'wb'), delimiter=self.file_format.delimiter) print("Creating csv file '{file}' for sheet '{sheet}' contained in document {src} ...".format( sheet=sheet.name, file=xlfilename, src=self._source_name), end=' ') for row in xrange(sheet.nrows): writer.writerow(sheet.row_values(row)) print('Done.') except csv.Error, e: print(e) return 1 return 0 @property def file_format(self): """Hook method. Need to implement in derived classes. Should return an XLAsciiFileFormat object to get file extension and inner delimiter. """ pass class XlCsvFileFormat(csv.excel): """Add file extension to the usual properties of Excel-generated CSV files.""" extension = 'CSV' class XlTabFileFormat(csv.excel_tab): """Add file extension to the usual properties of Excel-generated delimited files.""" extension = 'TXT' class Xl2Csv(XlWriter): @property def file_format(self): """Hook factory method""" return XlCsvFileFormat() class Xl2Scsv(XlWriter): @property def file_format(self): """Hook factory method""" _format = XlCsvFileFormat() _format.extension = 'SCSV' _format.delimiter = ';' return _format class Xl2Text(XlWriter): @property def file_format(self): """Hook factory method""" return XlTabFileFormat() class MakeXlWriter(object): """Factory class for XLWriter objects. """ @staticmethod def make(xlfilename=None, sheets=None, extension='CSV'): if extension == "TXT": return Xl2Text(xlfilename=xlfilename, sheets=sheets) elif extension == "SCSV": return Xl2Scsv(xlfilename=xlfilename, sheets=sheets) elif extension == "CSV": return Xl2Csv(xlfilename=xlfilename, sheets=sheets) def main(): """Main of this application""" args = _process_command_line() args.xl.close() writer = MakeXlWriter.make(xlfilename=args.xl.name, sheets=args.sheets, extension=args.ext) return writer.write() ___________________________________________________________________________________________________________________________ From arnodel at gmail.com Wed Nov 23 13:29:05 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 23 Nov 2011 18:29:05 +0000 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 23 November 2011 17:38, W. eWatson wrote: [...] > It may be time to move on to c++. Good Luck. Bye! -- Arnaud From malaclypse2 at gmail.com Wed Nov 23 13:34:39 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 23 Nov 2011 13:34:39 -0500 Subject: String splitting by spaces question In-Reply-To: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: On Wed, Nov 23, 2011 at 12:10 PM, Massi wrote: > Hi everyone, > > I have to parse a string and splitting it by spaces. The problem is > that the string can include substrings comprises by quotations which > must mantain the spaces. What I need is to pass from a string like: > > This is an 'example string' > > to the following vector: > > ["This", "is", "an", "example string"] > > Which is the best way to achieve this? > This sounds a lot like the way a shell parses arguments on the command line. If that's your desire, python has a module in the standard library that will help, called shlex (http://docs.python.org/library/shlex.html). Particularly, shlex.split may do exactly what you want out of the box: Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32 >>> import shlex >>> s = "This is an 'example string'" >>> shlex.split(s) ['This', 'is', 'an', 'example string'] >>> -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Wed Nov 23 14:00:39 2011 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 23 Nov 2011 19:00:39 +0000 Subject: Python 2.7.2 on XP In-Reply-To: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> References: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> Message-ID: <4ECD42D7.7010207@mrabarnett.plus.com> On 23/11/2011 15:40, Alemu Tadesse wrote: > I am new to python. I do not know why my python editor (for 2.7.2) > changes everything to just black and white after saving. If you're using IDLE, are you saving the file without the .py extension? That could be the problem. > No color for say the built in functions for loops defs .... they all > look the same - it is annoying for someone coming from another > editors that help you track/easily see your work. I just un installed > it to install it again. I know it is pain to install all the > scientific things again. I wish Python has something like R > (R-studio) from which you can install packages very easily. I just > started yesterday and already frustrated with it. I am sticking to > python only because I hear good things about it and I think it is my > problem. > From atadesse at sunedison.com Wed Nov 23 14:02:11 2011 From: atadesse at sunedison.com (Alemu Tadesse) Date: Wed, 23 Nov 2011 13:02:11 -0600 Subject: Python 2.7.2 on XP In-Reply-To: <4ECD42D7.7010207@mrabarnett.plus.com> References: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> <4ECD42D7.7010207@mrabarnett.plus.com> Message-ID: <6FA6EB75E3CA4744ADF9EF97D8DAC18B0196798B@mail.sunedison.com> I am saving it with .py extention -----Original Message----- From: python-list-bounces+atadesse=sunedison.com at python.org [mailto:python-list-bounces+atadesse=sunedison.com at python.org] On Behalf Of MRAB Sent: Wednesday, November 23, 2011 12:01 PM To: python-list at python.org Subject: Re: Python 2.7.2 on XP On 23/11/2011 15:40, Alemu Tadesse wrote: > I am new to python. I do not know why my python editor (for 2.7.2) > changes everything to just black and white after saving. If you're using IDLE, are you saving the file without the .py extension? That could be the problem. > No color for say the built in functions for loops defs .... they all > look the same - it is annoying for someone coming from another > editors that help you track/easily see your work. I just un installed > it to install it again. I know it is pain to install all the > scientific things again. I wish Python has something like R > (R-studio) from which you can install packages very easily. I just > started yesterday and already frustrated with it. I am sticking to > python only because I hear good things about it and I think it is my > problem. > -- http://mail.python.org/mailman/listinfo/python-list From gordon at panix.com Wed Nov 23 14:11:37 2011 From: gordon at panix.com (John Gordon) Date: Wed, 23 Nov 2011 19:11:37 +0000 (UTC) Subject: Python 2.7.2 on XP References: <6FA6EB75E3CA4744ADF9EF97D8DAC18B019678B5@mail.sunedison.com> <4ECD42D7.7010207@mrabarnett.plus.com> Message-ID: In "Alemu Tadesse" writes: > I am saving it with .py extention It would really help us answer your question if you identified which editor you're using. IDLE? PyScripter? Eclipse? PyCharm? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From miki.tebeka at gmail.com Wed Nov 23 15:40:27 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 23 Nov 2011 12:40:27 -0800 (PST) Subject: String splitting by spaces question In-Reply-To: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: <29337570.208.1322080827452.JavaMail.geo-discussion-forums@yqiv14> http://docs.python.org/library/shlex.html From nulla.epistola at web.de Wed Nov 23 16:13:28 2011 From: nulla.epistola at web.de (Sibylle Koczian) Date: Wed, 23 Nov 2011 22:13:28 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ECC6C65.2090902@yahoo.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ECC6C65.2090902@yahoo.com> Message-ID: Am 23.11.2011 04:45, schrieb Alan Meyer: > On 11/22/2011 3:05 PM, Dennis Lee Bieber wrote: >> On Tue, 22 Nov 2011 14:29:18 -0500, Alan Meyer >> declaimed the following in gmane.comp.python.general: >> >>> On 11/22/2011 1:55 PM, Alan Meyer wrote: >>> ... >>>> 6. Select, or navigate to and select, the python IDLE interpreter. >>> ... >>> On my system that's >>> C:\Python26\Lib\site-packages\pythonwin\Pythonwin.exe >>> >> Note that this is not the Tk based IDLE (which is implemented, >> itself, as a .pyw file and is not natively executable -- which seems to >> be one of the problems; Win7 has removed the detailed file type >> association windows so you can't specify that the "application" is >> pythonw.exe running idle.pyw using one's selected file as the argument >> to the mess). > > Bummer! > > Sorry W.eWatson, my instructions may not work. I've got the ActiveState > Python on my Windows machine. It runs a .exe file as the IDLE > executable. If your implementation doesn't have an exe then you're going > to have to do some more complex work. > PythonWin hasn't got anything to do with IDLE, it's another IDE for Python. It is part of the Python for Windows extensions: http://sourceforge.net/projects/pywin32/. From ben+python at benfinney.id.au Wed Nov 23 16:49:48 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 24 Nov 2011 08:49:48 +1100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <878vn67blv.fsf@benfinney.id.au> Arnaud Delobelle writes: > On 23 November 2011 17:38, W. eWatson wrote: > [...] > > It may be time to move on to c++. > > Good Luck. Bye! Sadly, IME it's most often the case that the person who threatens to leave with just about every message will instead stick around a long time, repeating the same threats while expecting those threats to elicit support. -- \ ?It is far better to grasp the universe as it really is than to | `\ persist in delusion, however satisfying and reassuring.? ?Carl | _o__) Sagan | Ben Finney From ameyer2 at yahoo.com Wed Nov 23 17:29:29 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Wed, 23 Nov 2011 17:29:29 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/23/2011 12:38 PM, W. eWatson wrote: > So unless Alan Meyer has further interest in this, it looks like it's at > an end. > > It may be time to move on to c++. > C++ is a ton of fun. You haven't lived until you've made a syntax error in a template instantiation and seen a hundred cascading error messages from included files that you didn't know you included. Unlike Python, it really builds character. I say, go for it! Alan From anacrolix at gmail.com Wed Nov 23 17:58:59 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Thu, 24 Nov 2011 09:58:59 +1100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: Moving to C++ is _always_ a step backwards. On Thu, Nov 24, 2011 at 9:29 AM, Alan Meyer wrote: > On 11/23/2011 12:38 PM, W. eWatson wrote: >> >> So unless Alan Meyer has further interest in this, it looks like it's at >> an end. >> >> It may be time to move on to c++. >> > > C++ is a ton of fun. ?You haven't lived until you've made a syntax error in > a template instantiation and seen a hundred cascading error messages from > included files that you didn't know you included. > > Unlike Python, it really builds character. > > I say, go for it! > > ? ?Alan > -- > http://mail.python.org/mailman/listinfo/python-list > From Phil_member at newsguy.com Wed Nov 23 19:02:40 2011 From: Phil_member at newsguy.com (Phil Rist) Date: 23 Nov 2011 16:02:40 -0800 Subject: Running Idle on Windows 7 Message-ID: I have installed ActiveState Python 32bit on my computer. There are potentially five different ways that Idle can be run. Actually six if you include activating a command window and typing in the command. We will not do that here. The first way is to use the shortcut put into the start menu by the ActiveState installation program. Left click on the start menu icon followed by hovering over the 'All Programs' button will bring up the menu. At this point find and click the ActiveState ActivePython entry. This will bring up the Python sub-menu on which Idle can be found and clicked to start Idle. If this is not previously you could create a shortcut as described below and move it to the start button. I do not know how to do that on Windows 7. The other methods may require some effort on your part. Each extension has a file type. Each file type has a context menu which can be accessed by right clicking an appropriate Windows Explorer entry or desktop icon. The contents of the context menu is maintained in the registry. The Regedit utility can be used to modify the menu. The following text typed into a file with a .reg extension can be used to create part of a context menu for files with either a .py or .pyw extension. Once the file is created it can be run by double clicking the file's entry in Windows Explorer. The file type I selected is pyfile. If you select a file type that already exists it will be overwritten. If these extensions have already been given a file type that file type should be used. If there is already an Open command and you do not want to replace it change the Open names here to something that is not already used. Note the wrapping of the last line. REGEDIT4 [HKEY_CLASSES_ROOT\.py] @="pyfile" [HKEY_CLASSES_ROOT\.pyw] @="pyfile" [HKEY_CLASSES_ROOT\pyfile] @="Python source" [HKEY_CLASSES_ROOT\pyfile\Shell] @="Open" [HKEY_CLASSES_ROOT\pyfile\Shell\Open] @="Open" "EditFlags"=hex:01,00,00,00 [HKEY_CLASSES_ROOT\pyfile\Shell\Open\Command] @="c:\\sys\\Language\\python\\pythonw.exe C:\\Sys\\Language\\Python\\Lib\\idlelib\\idle.pyw \"%1\" " The first two group of lines simply assign the pyfile file type to the two extensions. The third group sets the file type description displayed by Windows Explorer to 'Python Source'. The fourth group makes Open the default command. The command that will be executed when a file is doubled clicked. The last group defines the text for the command. This is basically the same as any command entered in a command window except instead of a file name %1 is entered. This will be replaced by the name of the selected python file. Also any '\' or '"' which appear in the command must be preceeded by a '\'. The command given here will run Idle. The file paths will need to be changed to what is appropriate on your computer. I noticed that I had a file type Python.File. This file type had two commands one to run the program, 'Open' and one to Edit with Pythonwin, 'Edit with Pythonwin'. This was setup by the ActiveState installation program. These can be recovered with a .reg file with the following contents. REGEDIT4 [HKEY_CLASSES_ROOT\.py] @="Python.File" [HKEY_CLASSES_ROOT\.pyw] @="Python.File" There is also a context menu for directories. One menu for all directories. An entry for Idle can be created with the following code. This also is entered into a .reg file. The same rules apply. Here %1 will be replaced by the directory path. Like the Start Menu method you do not have access to a file path. Note the wrapping of the last line. REGEDIT4 [HKEY_CLASSES_ROOT\Directory\Shell\Idle] @="Idle" "EditFlags"=hex:01,00,00,00 [HKEY_CLASSES_ROOT\Directory\Shell\Idle\Command] @="c:\\sys\\Language\\python\\pythonw.exe C:\\Sys\\Language\\Python\\Lib\\idlelib\\idle.pyw " The fourth way is to create a shortcut to Idle. This is basically the same as the Start Menu method except the shortcut can be put on the desktop where it will appear as an icon or in any directory where it can be accessed from Windows Explorer. My technique here was to create a directory called 'Python'. Within that directory I created three directories 'New', 'Explore' and 'Projects' to contain my Python programs. The 'Python' directory contains infrastructure files such as the .reg files. I created a fourth sub-menu called 'Python Shortcuts'. I added several shortcuts which I thought would be useful, including a shortcut to Idle. Windows allows me to create a toolbar on the quick launch bar. This toolbar contains a list of the contents of a selected directory. In my case the 'Python Shortcuts' directory. I can run Idle by clicking on the toolbar and then the entry for Idle. To create the shortcut find the Python interpreter pythonw.exe. Right click it and select 'Create shortcut'. The shortcut will appear in the same directory as pythonw.exe. Drag it to the directory you want it in. Right click it and select 'Properties'. In the middle of the dialog is a text box labeled 'Target'. This field contains the command which will be executed. Add the path to Idle.pyw to the end of the command. Click the OK button. You can also create a shortcut to the supplied .bat file. This will work without any further editing. The last method is to use a program which accepts command lines from some source. I have a buttonbar program which uses an initialization file which defines each command for each button. As a word of warning, .reg files are not the easiest things to work with. From Phil_member at newsguy.com Wed Nov 23 19:20:43 2011 From: Phil_member at newsguy.com (Phil Rist) Date: 23 Nov 2011 16:20:43 -0800 Subject: String splitting by spaces question References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: In article <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f at r9g2000vbw.googlegroups.com>, Massi says... > >Hi everyone, > >I have to parse a string and splitting it by spaces. The problem is >that the string can include substrings comprises by quotations which >must mantain the spaces. What I need is to pass from a string like: > >This is an 'example string' > >to the following vector: > >["This", "is", "an", "example string"] > >Which is the best way to achieve this? >Thanks in advance! Is this what you want? import shlex lText = "This is a 'short string' for you to read." lWords = shlex.split(lText) print lWords produces, ['This', 'is', 'a', 'short string', 'for', 'you', 'to', 'read.'] Shlex can be found under 'Program Frameworks' under 'The Python Standard Library' of ActivePython 2.7 documentation. C:\Source\Python\New> From steve+comp.lang.python at pearwood.info Wed Nov 23 21:16:10 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 02:16:10 GMT Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> On Wed, 23 Nov 2011 10:37:56 +0000, Tim Golden wrote: > The interpreter inherits the command shell's history function: Open a > cmd window and then a Python session. Do some stuff. > > Ctrl-Z to exit to the surrounding cmd window. Do some random cmd stuff: > dir, cd, etc. > > Start a second Python session. up-arrow etc. will bring back the > previous Python session's commands (and not the ones you entered in the > surrounding shell) Doesn't work for me, at least not with Python 2.5 and 2.6 on Linux. I don't suppose you are running a site-specific command history script in your startup.py file? [steve at wow-wow ~]$ unset PYTHONSTARTUP [steve at wow-wow ~]$ python Python 2.5 (r25:51908, Nov 6 2007, 16:54:01) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print 42 42 >>> [1]+ Stopped python [steve at wow-wow ~]$ python Python 2.5 (r25:51908, Nov 6 2007, 16:54:01) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> You can't see it, but I'm hitting the up arrow on that last line, and nothing is happening except my console is flashing :) -- Steven From devplayer at gmail.com Wed Nov 23 22:09:49 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 23 Nov 2011 19:09:49 -0800 (PST) Subject: Is there any way to unimport a library References: Message-ID: Seems so far the common way to fully unload any import is to exit the Python session. Only if this is true do I offer this hackish idea: Therefore you might wish to run an os script instead of a python script right off. Here is my hack at it... Something like this: file myapp.bat -------------- python get_availble_imports.py available_imports.log python myapp.py available_imports.log file get_availble_imports.py ---------------------------- find_module_names = """ os sys time sqlite lib1_verA lib2_verA sqlite3 lib1_verB lib2_verB """ # other code i'm leaving out of this forum post def find_module_names_using_pydoc( block_string ): '''Searchs for module names, provided in a block string, against the resultant module names list returned from pydoc. \n Returns a list of strings, being the intersection of module names from both lists.''' all_wanted_modules = parse_block_for_module_names( block_string ) # use split and drop empties module_names_found = [] # walk_packages actually imports libraries; # so you know the import should work. # i call em modules; but they could be packages too # following line can take many seconds to run package_generator = pydoc.pkgutil.walk_packages(path=None, prefix='', onerror=error_handler) for package_name in package_generator: module_loader, module_name, ispkg = package_name if module_name in all_wanted_modules: module_names_found.append( module_name ) print repr( module_name ) return module_names_found found = find_module_names_using_pydoc( find_module_names ) #Then with a switch statement (if/elif) create a string with to be #saved to the log file with what module names are in usable_mods if 'sqlite' in found and 'lib1_verA' in found and 'lib2_verA' in found: save('import sqlite, lib1_verA, lib2_verA') elif 'sqlite' in found and 'lib1_verB' in found and 'lib2_verB' in found: save('import sqlite3, lib1_verB, lib2_verB') else: raise ImportError('Necessary packages not found') file myapp.py ------------- with open('available_imports.log','r') as f: text = f.read() exec(text) # DONE From devplayer at gmail.com Wed Nov 23 22:23:09 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 23 Nov 2011 19:23:09 -0800 (PST) Subject: Is there any way to unimport a library References: Message-ID: <0edae6b0-439c-4d0f-ba03-e5b62d04693c@s6g2000vbc.googlegroups.com> btw if you like processing text outside of python (say using grep or something) python -c "help('modules')" > all_imports.log which you might note on windows get's processed to: python -c "help('modules')" 1> all_imports.log on windows from within a batch file From steve+comp.lang.python at pearwood.info Wed Nov 23 22:29:16 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 03:29:16 GMT Subject: Capturing SIGSTOP Message-ID: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> I'd like to perform a task when the user interrupts my application with Ctrl-Z on Linux. I tried installing a signal handler: import signal def handler(signalnum, stackframe): print "Received signal %d" % signalnum signal.signal(signal.SIGSTOP, handler) But I got a RuntimeError: Traceback (most recent call last): File "", line 1, in RuntimeError: (22, 'Invalid argument') This isn't documented: http://docs.python.org/library/signal.html#signal.signal Is there a way to catch SIGSTOP? -- Steven From nirmanlongjam at gmail.com Wed Nov 23 22:50:16 2011 From: nirmanlongjam at gmail.com (nirman longjam) Date: Wed, 23 Nov 2011 19:50:16 -0800 (PST) Subject: Tree data structure with: single, double and triple children option along with AVM data at each node Message-ID: <7548c4b6-f3f1-4f96-9a77-fcb9e0edeed0@s4g2000yqk.googlegroups.com> Dear sir, I am very happy to find this group. Sir, i am new to Python. Currently i am working on text processing. Can you give me some suggestions about Tree data structure representation, where i require each node capable to handle: only one child, or up to 3 children plus hold feature information. Thanking you, L. Nirman Singh From devplayer at gmail.com Wed Nov 23 22:53:44 2011 From: devplayer at gmail.com (DevPlayer) Date: Wed, 23 Nov 2011 19:53:44 -0800 (PST) Subject: String splitting by spaces question References: <3f19e4c0-e010-4cb2-9f71-dd09e0d3cb1f@r9g2000vbw.googlegroups.com> Message-ID: <45795de6-01d4-4969-9a6e-872ceadaf645@da3g2000vbb.googlegroups.com> This is an 'example string' Don't for get to watch for things like: Don't, Can't, Won't, I'll, He'll, Hor'davors, Mc'Kinly From steve+comp.lang.python at pearwood.info Wed Nov 23 22:55:56 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 03:55:56 GMT Subject: Bind key press to call function Message-ID: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> I'm looking for a way to interrupt a long-running function on a key press, but without halting the function. E.g. if I have these two functions: def handler(*args): print "caught interrupt and continuing..." def exercise_cpu(): for i in range(8): print "working..." for j in range(1000000): pass print "done" and I call exercise_cpu(), then type some key combination (say, Ctrl-x-p for the sake of the argument), I'd like the result to look something like this: >>> exercise_cpu() working... working... working... working... working... working... caught interrupt and continuing... working... working... done I think I want to use the readline module to catch the key press Ctrl-x-p and generate a signal, say SIGUSR1, then use the signal module to install a signal handler to catch SIGUSR1. Is this the right approach, or is there a better one? Does anyone show me an example of working code that does this? Linux only solutions are acceptable. -- Steven From rosuav at gmail.com Wed Nov 23 23:20:09 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 15:20:09 +1100 Subject: Bind key press to call function In-Reply-To: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 2:55 PM, Steven D'Aprano wrote: > I'm looking for a way to interrupt a long-running function on a key > press, but without halting the function. I assume there's a reason for not using Ctrl-C and SIGINT with the signal module? This looks like the classic "sigint handler sets a flag that the main loop polls" structure. ChrisA From rosuav at gmail.com Wed Nov 23 23:22:23 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 15:22:23 +1100 Subject: Capturing SIGSTOP In-Reply-To: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 2:29 PM, Steven D'Aprano wrote: > Is there a way to catch SIGSTOP? In the strictest sense, no; SIGSTOP can't be caught. However, some systems have SIGTSTP which is sent when you hit Ctrl-Z, which would be what you're looking for. http://www.gnu.org/s/hello/manual/libc/Job-Control-Signals.html Tested on my Linux box only; this almost certainly won't work on Windows. ChrisA From rosuav at gmail.com Wed Nov 23 23:30:57 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 15:30:57 +1100 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 1:16 PM, Steven D'Aprano wrote: > On Wed, 23 Nov 2011 10:37:56 +0000, Tim Golden wrote: > >> The interpreter inherits the command shell's history function: Open a >> cmd window and then a Python session. Do some stuff. >> >> Ctrl-Z to exit to the surrounding cmd window. Do some random cmd stuff: >> dir, cd, etc. >>>> > [1]+ ?Stopped ? ? ? ? ? ? ? ? python Ctrl-Z is the Windows equivalent (well, mostly) of Linux's Ctrl-D. You want to cleanly exit the interpreter, not SIGSTOP it. ChrisA From Nikunj.Badjatya at emc.com Wed Nov 23 23:44:30 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Wed, 23 Nov 2011 23:44:30 -0500 Subject: Thread problem In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D616@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D616@MX34A.corp.emc.com> Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D735@MX34A.corp.emc.com> Can someone help me on this please? From: python-list-bounces+nikunj.badjatya=emc.com at python.org [mailto:python-list-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of Nikunj.Badjatya at emc.com Sent: Wednesday, November 23, 2011 11:15 AM To: python-list at python.org Subject: Thread problem Howdy All, Please see http://pastebin.com/GuwH8B5C . Its a sample program implementing progressbar in multithreaded program. Here I am creating a thread and passing update2() function to it. Now wheneever I press CTRL-C, the program isnt returning to prompt. ! Can someone help me out with this please. ! Thanks Nikunj -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Thu Nov 24 01:07:47 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 06:07:47 GMT Subject: Bind key press to call function References: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecddf33$0$30003$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 15:20:09 +1100, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 2:55 PM, Steven D'Aprano > wrote: >> I'm looking for a way to interrupt a long-running function on a key >> press, but without halting the function. > > I assume there's a reason for not using Ctrl-C and SIGINT with the > signal module? Yes, I want to leave Ctrl-C alone and have a similar, but separate, signal handler (or equivalent). > This looks like the classic "sigint handler sets a flag that the main > loop polls" structure. Exactly. I am open to alternative methods if they are lightweight. -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 24 01:11:19 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 06:11:19 GMT Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 15:30:57 +1100, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 1:16 PM, Steven D'Aprano > wrote: >> On Wed, 23 Nov 2011 10:37:56 +0000, Tim Golden wrote: >> >>> The interpreter inherits the command shell's history function: Open a >>> cmd window and then a Python session. Do some stuff. >>> >>> Ctrl-Z to exit to the surrounding cmd window. Do some random cmd >>> stuff: dir, cd, etc. >>>>> >> [1]+ ?Stopped ? ? ? ? ? ? ? ? python > > Ctrl-Z is the Windows equivalent (well, mostly) of Linux's Ctrl-D. You > want to cleanly exit the interpreter, not SIGSTOP it. One of us is confused, and I'm pretty sure it's you :) Tim went on to say "Obviously this only applies when an underlying cmd session persists", which I understood as implying that he too is using Linux where Ctrl-Z stops the process, but does not exit it. -- Steven From torriem at gmail.com Thu Nov 24 01:15:20 2011 From: torriem at gmail.com (Michael Torrie) Date: Wed, 23 Nov 2011 23:15:20 -0700 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <1c554c22-8640-4ca3-a6f2-2cb8da318062@k5g2000pre.googlegroups.com> Message-ID: <4ECDE0F8.2030701@gmail.com> On 11/22/2011 09:14 AM, W. eWatson wrote: > On 11/21/2011 7:00 PM, alex23 wrote: >> "W. eWatson" wrote: >>> Comments? >> >> Please don't start multiple threads on the same issue. > Your joking, right, or do you just prefer 500 line threads wandering all > over the place? Most of us use threaded e-mail clients or nntp clients (Gmail's conversations are rubbish for this kind of thing) and so yes, having all 500 responses wandering all over the place in an orderly tree structure is infinitely preferred to many threads all talking about the same thing. Each message contains a referral id that refers the message that is being replied to. Thus the logical flow of the conversation is preserved very well despite many posters and meandering conversation branches. From rosuav at gmail.com Thu Nov 24 01:20:30 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 17:20:30 +1100 Subject: Bind key press to call function In-Reply-To: <4ecddf33$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdc04b$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecddf33$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 5:07 PM, Steven D'Aprano wrote: >> This looks like the classic "sigint handler sets a flag that the main >> loop polls" structure. > > Exactly. I am open to alternative methods if they are lightweight. Might be easiest to spin off a thread to do the work, and then have the main thread block on the keyboard. ChrisA From rosuav at gmail.com Thu Nov 24 01:22:35 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 17:22:35 +1100 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 5:11 PM, Steven D'Aprano wrote: > One of us is confused, and I'm pretty sure it's you :) > > Tim went on to say "Obviously this only applies when an underlying cmd > session persists", which I understood as implying that he too is using > Linux where Ctrl-Z stops the process, but does not exit it. Entirely possible :) I blithely assumed from the fact that he said "dir" that it was Windows, but it goes to show what happens when you assume. ChrisA From rick.mansilla at gmail.com Thu Nov 24 01:36:40 2011 From: rick.mansilla at gmail.com (Ricardo Mansilla) Date: Thu, 24 Nov 2011 00:36:40 -0600 Subject: Does py2app improves speed? Message-ID: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> Hi everyone.. My question is exactly as in the subject of This Mail. I have made a Python script which is to slow and i have heard (and common sense also suggest) that if you use some libraries to "frozen" the script the performance improves substantially. So I need to know; is This a myth or it is a fact? Thanks in advance for your time. From steve+comp.lang.python at pearwood.info Thu Nov 24 01:36:53 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Nov 2011 06:36:53 GMT Subject: Capturing SIGSTOP References: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 15:22:23 +1100, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 2:29 PM, Steven D'Aprano > wrote: >> Is there a way to catch SIGSTOP? > > In the strictest sense, no; SIGSTOP can't be caught. However, some > systems have SIGTSTP which is sent when you hit Ctrl-Z, which would be > what you're looking for. That's exactly what I'm looking for, thanks. After catching the interrupt and doing whatever I need to do, I want to allow the process to be stopped as normal. Is this the right way? import signal, os def handler(signalnum, stackframe): print "Received signal %d" % signalnum os.kill(os.getpid(), signal.SIGSTOP) # Hit myself with a brick. signal.signal(signal.SIGTSTP, handler) It seems to work for me (on Linux), but is it the right way? -- Steven From ian.g.kelly at gmail.com Thu Nov 24 03:04:02 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 24 Nov 2011 01:04:02 -0700 Subject: Does py2app improves speed? In-Reply-To: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> Message-ID: On Wed, Nov 23, 2011 at 11:36 PM, Ricardo Mansilla wrote: > Hi everyone.. > My question is exactly as in the subject of This Mail. > I have made a Python ?script which is to slow and i have heard (and common sense also suggest) that if you use some libraries to "frozen" the script the performance improves substantially. So I need to know; is This a myth or it is a fact? > Thanks in advance for your time. I would not expect any speedup. You might see some difference in loading times, but the actual program being run is still just the Python interpreter running your script, and that's not going to run any faster. I had a coworker who wrapped up one of his applications with py2exe / pyInstaller on the theory that since his program would be run from a network share, it would be faster to load a single exe over the network than a bunch of .pyc files plus the files needed to run the interpreter. I can't tell any difference, though. Cheers, Ian From rosuav at gmail.com Thu Nov 24 03:12:13 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 19:12:13 +1100 Subject: Capturing SIGSTOP In-Reply-To: <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 5:36 PM, Steven D'Aprano wrote: > ? ?os.kill(os.getpid(), signal.SIGSTOP) ?# Hit myself with a brick. > Sometimes there'll be a raise() function but it's going to do the same thing. Yep, that would be the way to do it. ChrisA From rosuav at gmail.com Thu Nov 24 03:15:02 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Nov 2011 19:15:02 +1100 Subject: Capturing SIGSTOP In-Reply-To: <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <4ecdba0c$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde605$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Nov 24, 2011 at 5:36 PM, Steven D'Aprano wrote: > ? ?os.kill(os.getpid(), signal.SIGSTOP) ?# Hit myself with a brick. > > > It seems to work for me (on Linux), but is it the right way? And - if your system has SIGTSTP, it'll have SIGSTOP and this will be how it works. (Windows has neither.) This code will probably work fine on all modern Unix-like systems, but if it fails anywhere, it'll be for lack of SIGTSTP I would say. ChrisA From mail at timgolden.me.uk Thu Nov 24 03:51:35 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Nov 2011 08:51:35 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ECE0597.60802@timgolden.me.uk> On 24/11/2011 06:22, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 5:11 PM, Steven D'Aprano > wrote: >> One of us is confused, and I'm pretty sure it's you :) >> >> Tim went on to say "Obviously this only applies when an underlying cmd >> session persists", which I understood as implying that he too is using >> Linux where Ctrl-Z stops the process, but does not exit it. > > Entirely possible :) I blithely assumed from the fact that he said > "dir" that it was Windows, but it goes to show what happens when you > assume. Ahem. Sorry for any confusion caused. The OP was asking about the situation on Windows, and I was responding in that context. The Ctrl-Z thing is what *exits* the interpreter on Windows (a la Ctrl-D on Linux). In short - on Windows, within one cmd shell you can open and exit the interpreter as many times as you like and the Python command history will be retained via the cmd shell's history mechanism, and kept distinct from the history of other things you may type into the cmd shell. If you exit the cmd shell then that history is lost, and I'm not aware of any mechanism for retaining it. All this may or may not be of any use to the OP. I was responding to this comment by Steven: "The default interactive interpreter for Python doesn't have persistent history, so if you exit the interpreter and restart it, your commands are gone." TJG From ulrich.eckhardt at dominolaser.com Thu Nov 24 06:56:42 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 24 Nov 2011 12:56:42 +0100 Subject: reading optional configuration from a file Message-ID: Hi! I have a few tests that require a network connection. Typically, the target will be localhost on port 20000. However, sometimes these settings differ, so I want to be able to optionally set them. What I'm currently doing is this: try: from settings import REMOTE_HOST, REMOTE_PORT except ImportError: REMOTE_HOST = 'localhost' REMOTE_PORT = 20000 This works fine. However, there are actually a few more settings that can be overridden, so I changed the whole thing to this: try: from settings import * if not 'REMOTE_HOST' in locals(): REMOTE_HOST = 'localhost' if not 'REMOTE_PORT' in locals(): REMOTE_PORT = 20000 except ImportError: REMOTE_HOST = 'localhost' REMOTE_PORT = 20000 Yes, wildcard imports are dangerous, but that's something I don't mind actually, this is an internal tool for clueful users. Still, this is ugly, since the defaults are stored redundantly, so I went to this variant: REMOTE_HOST = 'localhost' REMOTE_PORT = 20000 try: from settings import * except ImportError: pass Now, in order to avoid ambiguities, I thought about using relative imports, but there I'm stomped because wildcard imports are not supported for relative imports, it seems. How would you do it? Any other suggestions? Cheers! Uli From bnrj.rudra at gmail.com Thu Nov 24 07:31:35 2011 From: bnrj.rudra at gmail.com (Rudra Banerjee) Date: Thu, 24 Nov 2011 18:01:35 +0530 Subject: suitability of python Message-ID: <1322137895.4211.3.camel@roddur> Dear friends, I am a newbie in python and basically i use python for postprocessing like plotting, data manipulation etc. Based on ease of programming on python I am wondering if I can consider it for the main development as well. My jobs (written on fortran) runs for weeks and quite CPU intensive. How python works on these type of heavy computation? Any comment or reference is welcome. From moky.math at gmail.com Thu Nov 24 07:46:13 2011 From: moky.math at gmail.com (Laurent Claessens) Date: Thu, 24 Nov 2011 13:46:13 +0100 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: Le 24/11/2011 13:31, Rudra Banerjee a ?crit : > Dear friends, > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? > Any comment or reference is welcome. If you need mathematical power (especially symbolic computations), you should also consider Sage[1] which is kind of a module of math over python. In some situations, Sage is the "correct" successor of Fortran instead of plain python. Well, it does not answers the question, but ... Laurent [1] http://sagemath.org From d at davea.name Thu Nov 24 08:08:39 2011 From: d at davea.name (Dave Angel) Date: Thu, 24 Nov 2011 08:08:39 -0500 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: <4ECE41D7.9090103@davea.name> On 11/24/2011 07:31 AM, Rudra Banerjee wrote: > Dear friends, > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? > Any comment or reference is welcome. > If I take your description at face value, then I'd say that stock CPython would be slower than Fortran. If the CPU-intensive parts had to be rewritten in CPython, they'd be slower than the Fortran they replace, by somewhere between 10:1 and 500:1. Further, if you've already got those Fortran algorithms written and debugged, why rewrite them? And finally, even for new code, you might be getting ideas for your algorithms from journals and other resources, where the examples may well be done in Fortran, so productivity might be best in Fortran as well. HOWEVER, you don't have to use stock CPython, alone. It could be that some of your Fortran algorithms are written in shared libraries, and that you could get your CPython code to call them to do the "heavy lifting." Or it could be that numpy, sage, or other 3rd party libraries might be usable for your particular problems, and that speed is then comparable to Fortran. Or it could be that one of the alternative Python implementations might be fast enough. Or it could even be that you're mistaken that the present code is even CPU intensive. Or it could be that by the time you recode the problem in Python, you discover a more efficient algorithm, and that way gain back all the speed you theoretically lost. There are tools to measure things, though I'm not the one to recommend specifics. And those probably depend on your platform as well. The last Fortran that I wrote was over 40 years ago. I'm afraid when I need speed, I usually use C++. But if I were starting a personal math-intensive project now, I'd try to prototype it in Python, and only move portions of it to Fortran or other compiled language. Only the portions that measurably took too long. And those portions might be rewritten in Cython, C++, or Fortran, depending on what kind of work they actually did. Another alternative that might make sense is to use Python as a "macro language" to Fortran, where you call out to Python to automate some tasks within the main program. I have no experience with doing that, but I assume it'd be something like how MSWord can call out to VBA routines. And it'd make the most sense when the main app is already written, and the macro stuff is an afterthought. I think the real point is that it doesn't have to be "all or nothing." I suspect that the pieces you're already doing in Python are calling out to pre-existing libraries as well. So your plotting code does some massaging, and then calls into some plotting library, or even execs a plotting executable. -- DaveA From rick.mansilla at gmail.com Thu Nov 24 08:26:27 2011 From: rick.mansilla at gmail.com (Ricardo Mansilla) Date: Thu, 24 Nov 2011 07:26:27 -0600 Subject: Does py2app improves speed? In-Reply-To: References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> Message-ID: <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... Bye. From d at davea.name Thu Nov 24 08:38:43 2011 From: d at davea.name (Dave Angel) Date: Thu, 24 Nov 2011 08:38:43 -0500 Subject: Does py2app improves speed? In-Reply-To: <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> Message-ID: <4ECE48E3.6070701@davea.name> On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: > Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... > Bye. Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Python language for all or most of the app. There have been lots of threads on the topic. -- DaveA From rick.mansilla at gmail.com Thu Nov 24 09:02:49 2011 From: rick.mansilla at gmail.com (Ricardo Mansilla) Date: Thu, 24 Nov 2011 08:02:49 -0600 Subject: Does py2app improves speed? In-Reply-To: <4ECE48E3.6070701@davea.name> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> Message-ID: <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> Most of m?thods for improving the speed are related to efficient memory management and using specific structures for a specific tasks... But i have already optimized my code (which is very short actually) following all these rules and it is very slow yet. Do you think there is another way to do This? Probably i'm missing something here... On 24/11/2011, at 07:38, Dave Angel wrote: > On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: >> Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... >> Bye. > Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Python language for all or most of the app. There have been lots of threads on the topic. > > -- > > DaveA > From ulrich.eckhardt at dominolaser.com Thu Nov 24 09:05:55 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 24 Nov 2011 15:05:55 +0100 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <87hb23ei00.fsf@benfinney.id.au> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <8762ijlqpt.fsf@benfinney.id.au> <87hb23ei00.fsf@benfinney.id.au> Message-ID: <4jv1q8-sv.ln1@satorlaser.homedns.org> Am 17.11.2011 00:59, schrieb Ben Finney: > David Robinow writes: >> but your code works fine on Windows. Thanks. > > I'm glad to know that. Perhaps you could investigate why, and suggest an > update to the above documentation if it's wrong? The bug tracker at > would be the appropriate place for such a > suggestion. Interestingly, on MS Windows (XP here), every commandline program inherits the history functionality (browsing with cursor up/down) from the shell it runs in. That means the program itself doesn't have to supply any of that, but also that it can't customize any of that... The history is not persistent though, it is restricted to that shell. Still, this might explain why it never bothered anyone enough to fix things properly. ;) Uli From anacrolix at gmail.com Thu Nov 24 09:15:20 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Fri, 25 Nov 2011 01:15:20 +1100 Subject: Does py2app improves speed? In-Reply-To: <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> Message-ID: Yes. Try posting your code. On Fri, Nov 25, 2011 at 1:02 AM, Ricardo Mansilla wrote: > Most of m?thods for improving the speed are related to efficient memory management and using specific structures for a specific tasks... But i have already optimized my code (which is very short actually) following all these rules and it is very slow yet. > Do you think there is another way to do This? Probably i'm missing something here... > > On 24/11/2011, at 07:38, Dave Angel wrote: > >> On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: >>> Well, that's sad... I think Im gonna end getting back to C++ for This. ?But anyway, thanks a lot for the quick answer... >>> Bye. >> Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Python language for all or most of the app. There have been lots of threads on the topic. >> >> -- >> >> DaveA >> > -- > http://mail.python.org/mailman/listinfo/python-list > From anacrolix at gmail.com Thu Nov 24 09:21:24 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Fri, 25 Nov 2011 01:21:24 +1100 Subject: reading optional configuration from a file In-Reply-To: References: Message-ID: ? ?REMOTE_HOST = 'localhost' ? ?REMOTE_PORT = 20000 ? ?try: from .settings import * ? ?except ImportError: ? ? ? ?pass This works? If you're using an old version of Python you may need to mess about with __future__. On Thu, Nov 24, 2011 at 10:56 PM, Ulrich Eckhardt wrote: > Hi! > > I have a few tests that require a network connection. Typically, the target > will be localhost on port 20000. However, sometimes these settings differ, > so I want to be able to optionally set them. > > What I'm currently doing is this: > > ? ?try: > ? ? ? ?from settings import REMOTE_HOST, REMOTE_PORT > ? ?except ImportError: > ? ? ? ?REMOTE_HOST = 'localhost' > ? ? ? ?REMOTE_PORT = 20000 > > This works fine. However, there are actually a few more settings that can be > overridden, so I changed the whole thing to this: > > ? ?try: > ? ? ? ?from settings import * > ? ? ? ?if not 'REMOTE_HOST' in locals(): > ? ? ? ? ? ?REMOTE_HOST = 'localhost' > ? ? ? ?if not 'REMOTE_PORT' in locals(): > ? ? ? ? ? ?REMOTE_PORT = 20000 > ? ?except ImportError: > ? ? ? ?REMOTE_HOST = 'localhost' > ? ? ? ?REMOTE_PORT = 20000 > > Yes, wildcard imports are dangerous, but that's something I don't mind > actually, this is an internal tool for clueful users. Still, this is ugly, > since the defaults are stored redundantly, so I went to this variant: > > ? ?REMOTE_HOST = 'localhost' > ? ?REMOTE_PORT = 20000 > ? ?try: > ? ? ? ?from settings import * > ? ?except ImportError: > ? ? ? ?pass > > Now, in order to avoid ambiguities, I thought about using relative imports, > but there I'm stomped because wildcard imports are not supported for > relative imports, it seems. > > > How would you do it? Any other suggestions? > > Cheers! > > Uli > -- > http://mail.python.org/mailman/listinfo/python-list > From d at davea.name Thu Nov 24 09:27:10 2011 From: d at davea.name (Dave Angel) Date: Thu, 24 Nov 2011 09:27:10 -0500 Subject: Does py2app improves speed? In-Reply-To: <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> Message-ID: <4ECE543E.9040807@davea.name> On 11/24/2011 09:02 AM, Ricardo Mansilla wrote: > Most of m?thods for improving the speed are related to efficient memory management and using specific structures for a specific tasks... But i have already optimized my code (which is very short actually) following all these rules and it is very slow yet. > Do you think there is another way to do This? Probably i'm missing something here... > > On 24/11/2011, at 07:38, Dave Angel wrote: > >> On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: >>> Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... >>> Bye. >> Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Python language for all or most of the app. There have been lots of threads on the topic. >> >> -- >> >> DaveA >> > (Please don't top-post. If you put your comments ahead of the part you're quoting, you confuse us) Several ways to speed up code. 1) use language features to best advantage 2) use 3rd party libraries that do certain things well 3) use best algorithms, subject to #1 and #2 4) have someone else review the code (perhaps on the list, perhaps within your own organization) 5) measure (eg. profile it) 6) use optimizing tools, such as pypy or Cython. 7) rewrite parts of it in another language 8) get a faster processor 9) rewrite it all in another language It takes experience to choose between these, and each project is different. But even the most experienced developers will frequently guess entirely wrong where the bottleneck is, which is why you measure if you care. -- DaveA From Nikunj.Badjatya at emc.com Thu Nov 24 10:35:36 2011 From: Nikunj.Badjatya at emc.com (Nikunj.Badjatya at emc.com) Date: Thu, 24 Nov 2011 10:35:36 -0500 Subject: How to keep Console area fixed for a thread Message-ID: <599CEBACD49B4144A61212D837EE3C0F144604D7B8@MX34A.corp.emc.com> Hi All, Please look at the code below. I am using pypi progressbar. But in general, How can I keep the area of the console fixed for the thread to print its status on it. {{{ import sys import time import threading import os from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \ FileTransferSpeed, FormatLabel, Percentage, \ ProgressBar, ReverseBar, RotatingMarker, \ SimpleProgress, Timer def ProgBar(): widgets = [' ', Percentage(), ' ', Bar(marker='#',left='[',right=']'),' '] pbar = ProgressBar(widgets=widgets, maxval=100) pbar.start() return pbar def update2(i): os.environ["PBAR"] = i print("This will print for every call to update") return class MyThread(threading.Thread): def run(self): l = 0 while True: n = os.getenv("PBAR", "") if len(n) != 0: n = int(n) if n > l: pbar.update(n) l = n if n == 100: break else: continue pbar = ProgBar() mythread = MyThread() mythread.daemon = True mythread.start() for i in range(101): update2("{0}".format(i)) time.sleep(0.25) }}} {{{ Output: [cid:image002.jpg at 01CCAAEC.CFE44870] }}} But I require the output to be of type: {{{ 13% [########### ] This will print for every call to update This will print for every call to update This will print for every call to update This will print for every call to update This will print for every call to update }}} This is just a sample piece of code for narrowing down the problem. How can I fix the cursor position fix for the thread which is updating my progressbar .? Thanks Nikunj Bangalore-India -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 37098 bytes Desc: image002.jpg URL: From zdoor at xs4all.nl Thu Nov 24 11:28:01 2011 From: zdoor at xs4all.nl (Alex van der Spek) Date: Thu, 24 Nov 2011 17:28:01 +0100 Subject: WAVE file writing, confused about setsampwidth(n) Message-ID: <4ece7092$0$6902$e4fe514c@news2.news.xs4all.nl> I am confused about the Wave_write object setsampwidth(n). Is the sample width n the total sample width, i.e. for a stereo sample consisting of short (2 byte) integers; n=4 or is the sample width the number of bytes in either the left or the right channel? Regards, Alex van der Spek From jcea at jcea.es Thu Nov 24 11:46:48 2011 From: jcea at jcea.es (Jesus Cea) Date: Thu, 24 Nov 2011 17:46:48 +0100 Subject: DTrace probes in Python 2.7 (and next 3.3) Message-ID: <4ECE74F8.5050208@jcea.es> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all. I have spend some time trying to integrate DTrace probes in official Python: Currently I have a patch to python 2.7, and my plan in to integrate officially in 3.3. The initial probes were based on previous work from OpenSolaris, and similar, but currently I have quite a few more probes. Current details in The probes are tested under Solaris 10 x86 and x86-64. I would need somebody to try on Solaris 10 Sparc (32 and 64 bits), Solaris 11, OpenIndiana, FreeBSD (seems to need a kernel recompilation to enable user mode tracing, check Google), Mac (I doubt it works as is), etc., any other platform running DTrace. What about SystemTap compatibility? Details: How to check: . The easier way to get the patch is to clone my repository at (with mercurial) and move to the branch "dtrace-issue13405_2.7". Keep the clone around if you plan to try future versions of this patch, including the future 3.3 version. You can manually apply the patch in to python 2.7.2+ sourcecode. The patch is developed against version 3c3009f63700 (2011-11-14). It might not apply cleanly to 2.7.2 sourcecode (not checked). I will provide a direct patch to 2.7.3 when available. Maybe to 2.7.2 if there is demand. This is still work in progress. I will improve support with your feedback. I am considering probes to monitor GIL and thinking how to monitor C function calls from Python in an easy and fast way. Feedback very welcomed. Please, if you care about this, test it and provide some feedback :). PS: Better post feedback in the bug tracker that by personal email :-). - -- Jesus Cea Avion _/_/ _/_/_/ _/_/_/ jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/ . _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQCVAwUBTs50+Jlgi5GaxT1NAQKWUwQAnl99nFd6nM5yiPGl8yw4/YR81BTIS563 3wyPz74o5wAE3k9quexr+UPCndPogiH6nhnJ9DNXfUpVyaouGG/tGEbZn/x+h7Dv jc5616IRnHxGAxxuoTscCRRN88zsPVY6i71QMxK2BOS+zXMdcrsBajLrmx1UIzHY Elr7fq8L988= =uQM5 -----END PGP SIGNATURE----- From miki.tebeka at gmail.com Thu Nov 24 12:24:24 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Thu, 24 Nov 2011 09:24:24 -0800 (PST) Subject: Tree data structure with: single, double and triple children option along with AVM data at each node In-Reply-To: <7548c4b6-f3f1-4f96-9a77-fcb9e0edeed0@s4g2000yqk.googlegroups.com> References: <7548c4b6-f3f1-4f96-9a77-fcb9e0edeed0@s4g2000yqk.googlegroups.com> Message-ID: <29675595.296.1322155464662.JavaMail.geo-discussion-forums@vbjs5> There a many ways to do this, here's one: from collections import namedtuple Tree = namedtuple('Tree', ['feature', 'children']) t = Tree(1, [Tree('hello', []), Tree(3, [])]) From cv33cv33cv33 at gmail.com Thu Nov 24 13:27:09 2011 From: cv33cv33cv33 at gmail.com (BV) Date: Thu, 24 Nov 2011 10:27:09 -0800 (PST) Subject: YOU MUST KNOW THIS MAN !!!!!!!!!!!!!!! Message-ID: <4d6f12c2-f596-4c50-af96-c9ee51e66aaa@j10g2000vbe.googlegroups.com> In The Name Of Allah, Most Gracious, Most Merciful YOU MUST KNOW THIS MAN MUHAMMAD You may be an atheist or an agnostic; or you may belong to anyone of the religious denominations that exist in the world today. You may be a Communist or a believer in democracy and freedom. No matter what you are, and no matter what your religious and political beliefs, personal and social habits happen to be - YOU MUST STILL KNOW THIS MAN! He was by far the most remarkable man that ever set foot on this earth. He preached a religion, founded a state, built a nation, laid down a moral code, initiated numberless social and political reforms, established a dynamic and powerful society to practice and represent his teachings, and completely revolutionized the worlds of human thought and action for all times to come. HIS NAME IS MUHAMMAD, peace and blessings of Almighty God be upon him and he accomplished all these wonders in the unbelievably short span of twenty-three years. Muhammad, peace and blessings of God Almighty be upon him was born in Arabia on the 20th of August, in the year 570 of the Christian era, and when he died after 63 years, the whole of the Arabian Peninsula had changed from paganism and idol-worship to the worship of One God; from tribal quarrels and wars to national solidarity and cohesion; from drunkenness and debauchery to sobriety and piety; from lawlessness and anarchy to disciplined living; from utter moral bankruptcy to the highest standards of moral excellence. Human history has never known such a complete transformation of a people or a place before or since! The Encyclopedia Britannica calls him "the most successful of all religious personalities of the world". Bernard Shaw said about him that if Muhammad were alive today he would succeed in solving all those problems which threaten to destroy human civilization in our times. Thomas Carlysle was simply amazed as to how one man, single- handedly, could weld warring tribes and wandering Bedouins into a most powerful and civilized nation in less than two decades. Napoleon and Gandhi never tired of dreaming of a society along the lines established by this man in Arabia fourteen centuries ago. Indeed no other human being ever accomplished so much, in such diverse fields of human thought and behavior, in so limited a space of time, as did Muhammad, peace and blessings of God Almighty be upon him. He was a religious teacher, a social reformer, a moral guide, a political thinker, a military genius, an administrative colossus, a faithful friend, a wonderful companion, a devoted husband, a loving father - all in one. No other man in history ever excelled or equaled him in any of these difficult departments of life. The world has had its share of great personalities. But these were one sided figures who distinguished themselves in but one or two fields such as religious thought or military leadership. None of the other great leaders of the world ever combined in himself so many different qualities to such an amazing level of perfection as did Muhammad, peace and blessings of God Almighty be upon him. The lives and teachings of other great personalities of the world are shrouded in the mist of time. There is so much speculation about the time and the place of their birth, the mode and style of their life, the nature and detail of their teachings and the degree and measure of their success or failure that it is impossible for humanity today to reconstruct accurately and precisely the lives and teachings of those men. Not so this man Muhammad, peace and blessings of God Almighty be upon him. Not only was he born in the fullest blaze of recorded history, but every detail of his private and public life, of his actions and utterances, has been accurately documented and faithfully preserved to our day. The authenticity of the information so preserved is vouched for not only by faithful followers but also by unbiased critics and open-minded scholars. At the level of ideas there is no system of thought and belief-secular or religious, social or political-which could surpass or equal ISLAM- the system which Muhammad peace and blessings of God Almighty be upon him propounded. In a fast changing world, while other systems have undergone profound transformations, Islam alone has remained above all change and mutation, and retained its original form for the past 1400 years. What is more, the positive changes that are taking place in the world of human thought and behavior, truly and consistently reflect the healthy influence of Islam in these areas. Further, it is not given to the best of thinkers to put their ideas completely into practice, and to see the seeds of their labors grow and bear fruit, in their own lifetime. Except of course, Muhammad, peace and blessings of God Almighty be upon him, who not only preached the most wonderful ideas but also successfully translated each one of them into practice in his own lifetime. At the time of his death his teachings were not mere precepts and ideas straining for fulfillment, but had become the very core of the life of tens of thousands of perfectly trained individuals, each one of whom was a marvelous personification of everything that Muhammad peace and blessings of God Almighty be upon him taught and stood for. At what other time or place and in relation to what other political, social, religious system, philosophy or ideology-did the world ever witness such a perfectly amazing phenomenon? Indeed no other system or ideology secular or religious, social or political, ancient or modern - could ever claim the distinction of having been put into practice in its fullness and entirety EVEN ONCE in this world, either before or after the death of its founder. Except of course ISLAM, the ideology preached by Muhammad, peace and blessings of God Almighty be upon him which was established as a complete way of life by the teacher himself, before he departed from this world. History bears testimony to this fact and the greatest skeptics have no option but to concede this point. In spite of these amazing achievements and in spite of the countless absolutely convincing and authentic miracles performed by him and the phenomenal success which crowned his efforts, he did not for a moment claim to be God or God's incarnation or Son - but only a human being who was chosen and ordained by God to be a teacher of truth to man kind and a complete model and pattern for their actions. He was nothing more or less than a human being. But he was a man with a noble and exalted mission-and his unique mission was to unite humanity on the worship of ONE AND ONLY GOD and to teach them the way to honest and upright living in accordance with the laws and commands of God. He always described himself as A MESSENGER AND SERVANT OF GOD, and so indeed every single action and movement of his proclaimed him to be. A world which has not hesitated to raise to Divinity individuals whose very lives and missions have been lost in legend and who historically speaking did not accomplish half as much-or even one tenth-as was accomplished by Muhammad, peace and blessings of God Almighty be upon him should stop to take serious note of this remarkable man's claim to be God's messenger to mankind. Today after the lapse of some 1400 years the life and teachings of Prophet Muhammad, peace and blessings of God Almighty be upon him, have survived without the slightest loss, alteration or interpolation. Today they offer the same undying hope for treating mankind's many ills which they did when Prophet Muhammad, peace and blessings of God Almighty be upon him, was alive. This is our honest claim and this is the inescapable conclusion forced upon us by a critical and unbiased study of history. The least YOU should do as a thinking, sensitive, concerned human being is to stop for one brief moment and ask yourself: Could it be that these statements, extraordinary and revolutionary as they sound, are really true? Supposing they really are true, and you did not know this man Muhammad, peace and blessings of God Almighty be upon him or hear about his teachings? Or did not know him well and intimately enough to be able to benefit from his guidance and example? Isn't it time you responded to this tremendous challenge and made some effort to know him? It will not cost you anything but it may well prove to be the beginning of a completely new era in your life. Come, let us make a new discovery of the life of this wonderful man Muhammad, peace and blessings of God Almighty be upon him the like of whom never walked on this earth, and whose example and teachings can change YOUR LIFE and OUR WORLD for the better. May God shower His choicest blessings upon him! IF YOU WISH TO KNOW MORE ABOUT ISLAM, WE PREFER TO VISIT THE FOLLOWING WEBSITES: http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://imanway1.com/eng http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://www.chatislamonline.org/ar http://www.dar-us-salam.com http://youtubeislam.com From aszeszo at gmail.com Thu Nov 24 13:49:40 2011 From: aszeszo at gmail.com (Andrzej Szeszo) Date: Thu, 24 Nov 2011 18:49:40 +0000 Subject: [oi-dev] DTrace probes in Python 2.7 (and next 3.3) In-Reply-To: <4ECE74F8.5050208@jcea.es> References: <4ECE74F8.5050208@jcea.es> Message-ID: <4ECE91C4.2040208@gmail.com> Hi Jesus Just noticed that there is a python 2.7 package in Oracle's userland repo here: It includes DTrace patch. Did you see/use that? Andrzej On 24/11/2011 16:46, Jesus Cea wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi all. > > I have spend some time trying to integrate DTrace probes in official > Python: Currently I have a patch to python 2.7, and my plan in to > integrate officially in 3.3. > > The initial probes were based on previous work from OpenSolaris, and > similar, but currently I have quite a few more probes. Current details > in > > > The probes are tested under Solaris 10 x86 and x86-64. I would need > somebody to try on Solaris 10 Sparc (32 and 64 bits), Solaris 11, > OpenIndiana, FreeBSD (seems to need a kernel recompilation to enable > user mode tracing, check Google), Mac (I doubt it works as is), etc., > any other platform running DTrace. What about SystemTap compatibility? > > Details: > > How to check:. > > The easier way to get the patch is to clone my repository at > (with mercurial) and move to the > branch "dtrace-issue13405_2.7". Keep the clone around if you plan to > try future versions of this patch, including the future 3.3 version. > > You can manually apply the patch in > to python 2.7.2+ > sourcecode. The patch is developed against version 3c3009f63700 > (2011-11-14). It might not apply cleanly to 2.7.2 sourcecode (not > checked). I will provide a direct patch to 2.7.3 when available. Maybe > to 2.7.2 if there is demand. > > This is still work in progress. I will improve support with your > feedback. I am considering probes to monitor GIL and thinking how to > monitor C function calls from Python in an easy and fast way. Feedback > very welcomed. > > Please, if you care about this, test it and provide some feedback :). > > PS: Better post feedback in the bug tracker that by personal email :-). > > - -- > Jesus Cea Avion _/_/ _/_/_/ _/_/_/ > jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ > jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/ > . _/_/ _/_/ _/_/ _/_/ _/_/ > "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ > "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ > "El amor es poner tu felicidad en la felicidad de otro" - Leibniz > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iQCVAwUBTs50+Jlgi5GaxT1NAQKWUwQAnl99nFd6nM5yiPGl8yw4/YR81BTIS563 > 3wyPz74o5wAE3k9quexr+UPCndPogiH6nhnJ9DNXfUpVyaouGG/tGEbZn/x+h7Dv > jc5616IRnHxGAxxuoTscCRRN88zsPVY6i71QMxK2BOS+zXMdcrsBajLrmx1UIzHY > Elr7fq8L988= > =uQM5 > -----END PGP SIGNATURE----- > > _______________________________________________ > oi-dev mailing list > oi-dev at openindiana.org > http://openindiana.org/mailman/listinfo/oi-dev From wolftracks at invalid.com Thu Nov 24 16:18:59 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 24 Nov 2011 13:18:59 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/23/2011 2:29 PM, Alan Meyer wrote: > On 11/23/2011 12:38 PM, W. eWatson wrote: >> So unless Alan Meyer has further interest in this, it looks like it's at >> an end. >> >> It may be time to move on to c++. >> > > C++ is a ton of fun. You haven't lived until you've made a syntax error > in a template instantiation and seen a hundred cascading error messages > from included files that you didn't know you included. > > Unlike Python, it really builds character. > > I say, go for it! > > Alan So posting the results of the adventure you put me on has no further way to proceed? From wolftracks at invalid.com Thu Nov 24 16:22:51 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 24 Nov 2011 13:22:51 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: Whoops, I thought I was replying to Matt Meyers just above you. However, I think he chimed in above about ActiveState back on the 22nd. In any case, I think this thread has ceased to be productive. From wolftracks at invalid.com Thu Nov 24 16:24:06 2011 From: wolftracks at invalid.com (W. eWatson) Date: Thu, 24 Nov 2011 13:24:06 -0800 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: On 11/23/2011 10:29 AM, Arnaud Delobelle wrote: > On 23 November 2011 17:38, W. eWatson wrote: > [...] >> It may be time to move on to c++. > > Good Luck. Bye! > "Wellll, pardoooon meee." -- Steve Martin From dbinks at codeaurora.org Thu Nov 24 16:41:50 2011 From: dbinks at codeaurora.org (Dominic Binks) Date: Thu, 24 Nov 2011 13:41:50 -0800 Subject: Does py2app improves speed? In-Reply-To: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> Message-ID: <4ECEBA1E.4020405@codeaurora.org> On 11/23/2011 10:36 PM, Ricardo Mansilla wrote: > Hi everyone.. > My question is exactly as in the subject of This Mail. > I have made a Python script which is to slow and i have heard (and common sense also suggest) that if you use some libraries to "frozen" the script the performance improves substantially. So I need to know; is This a myth or it is a fact? > Thanks in advance for your time. Depending on the code you have pypy may be faster - I've seen it both significantly faster and about the same as CPython. -- Dominic Binks: dbinks at codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum From ben+python at benfinney.id.au Thu Nov 24 17:28:28 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 25 Nov 2011 09:28:28 +1100 Subject: reading optional configuration from a file References: Message-ID: <8739dd6tpv.fsf@benfinney.id.au> Ulrich Eckhardt writes: > I have a few tests that require a network connection. Typically, the > target will be localhost on port 20000. However, sometimes these > settings differ, so I want to be able to optionally set them. I subscribe to the view that an application's user-configurable settings should be data, not executable code. For this purpose, you will want to investigate the Python standard library modules ?json? and ?configparser? . -- \ ?I saw a sign: ?Rest Area 25 Miles?. That's pretty big. Some | `\ people must be really tired.? ?Steven Wright | _o__) | Ben Finney From alex.kapps at web.de Thu Nov 24 18:18:44 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Fri, 25 Nov 2011 00:18:44 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <4ECED0D4.6080501@web.de> On 24.11.2011 22:22, W. eWatson wrote: > Whoops, I thought I was replying to Matt Meyers just above you. Above who? As said by somebody already, most people use a mail-client (Thunderbird/Outlook) or a Usenet client to read this forum. Google Groups is (In My Opinion at least) just crap (and should be blocked/forbidden. It's *the* one spam sender already) Please always post enough context, Now, we are talking about Python 3.2.* on Win7, correct? I only have Win7 32bit in a VBox VM, but still. Please paste the following into a "python.reg", file, then right-click on that file and choose the fist option (the one wihch is in bold font, something like install/insert/insert or however it's called in your language. In my German versin it's called "Zusammenf?hren") Do you get an "Edit with IDLE" then? Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Python.File] @="Python File" [HKEY_CLASSES_ROOT\Python.File\DefaultIcon] @="C:\\Python32\\DLLs\\py.ico" [HKEY_CLASSES_ROOT\Python.File\shell] [HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE] [HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command] @="\"C:\\Python32\\pythonw.exe\" \"C:\\Python32\\Lib\\idlelib\\idle.pyw\" -e \"%1\"" [HKEY_CLASSES_ROOT\Python.File\shell\open] [HKEY_CLASSES_ROOT\Python.File\shell\open\command] @="\"C:\\Python32\\python.exe\" \"%1\" %*" From alex.kapps at web.de Thu Nov 24 18:37:03 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Fri, 25 Nov 2011 00:37:03 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ECED0D4.6080501@web.de> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ECED0D4.6080501@web.de> Message-ID: <4ECED51F.2000106@web.de> On 25.11.2011 00:18, Alexander Kapps wrote: > Do you get an "Edit with IDLE" then? And even if not. Why are you so obsessive about IDLE? I mean, seriously, IDLE is just a bare-level if-nothing-else-is-available editor/IDE. It's better than notepad, OK. I really don't buy it, that your are willing to move to C++ (or even just change the language) just because the default editor is not available in the context menu. From jcea at jcea.es Thu Nov 24 19:01:22 2011 From: jcea at jcea.es (Jesus Cea) Date: Fri, 25 Nov 2011 01:01:22 +0100 Subject: [oi-dev] DTrace probes in Python 2.7 (and next 3.3) In-Reply-To: <4ECE91C4.2040208@gmail.com> References: <4ECE74F8.5050208@jcea.es> <4ECE91C4.2040208@gmail.com> Message-ID: <4ECEDAD2.5060301@jcea.es> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 24/11/11 19:49, Andrzej Szeszo wrote: > Hi Jesus > > Just noticed that there is a python 2.7 package in Oracle's > userland repo here: > > > > > > It includes DTrace patch. Did you see/use that? That was my starting point. Talking about that... How is the license going?. Mailing the guy... - -- Jesus Cea Avion _/_/ _/_/_/ _/_/_/ jcea at jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ jabber / xmpp:jcea at jabber.org _/_/ _/_/ _/_/_/_/_/ . _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQCVAwUBTs7a0plgi5GaxT1NAQLNUAP/WUopUbet5NN5K1kgJ6/5KNJFX/HMXqIl JXWXHro72f3SFuWws1QL82nos/nhVn5JQkkc3sRDwi3EV0dFM2Zi9BS8paHfOrQi 2qNNbvnTMzGKjZ9ZQrhiC+aSfr5qG6ou53mtQch53W7v15t7flqrDWr/VqlKxRWO xn0P8WzSC8g= =G9Ie -----END PGP SIGNATURE----- From steve+comp.lang.python at pearwood.info Thu Nov 24 19:04:04 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Nov 2011 00:04:04 GMT Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 17:25:23 -0600, Tony the Tiger wrote: > On Wed, 23 Nov 2011 17:43:20 -0800, Dennis Lee Bieber wrote: > >> Windows PowerShell includes more than one hundred basic core cmdlets, >> and you can write your own cmdlets and share them with other users. > > Oh, goodie! They've found yet another way to infect a Windows system. :) My Linux system includes compilers or interpreters for C, Pascal, Haskell, Forth, Python, Ruby, PHP, Javascript, Java, bash, csh, zsh, sh, awk, sed, Perl, SQL, Tcl, Tk, OpenXion, and very likely others. Most of these were supplied by the vendor. I could write my own executable code, "cmdlets" if you will, in any of these languages, and share them with others. So by your reasoning, that's at least 20 ways to infect my Linux system. I never realised just how insecure Linux must be! If "sharing code" is considered to be synonymous with "infection", what does that say about the Free and Open Source Software movement? Linux-users-aren't-the-only-people-allowed-to-write-shell-scripts-ly y'rs, -- Steven From steve+comp.lang.python at pearwood.info Thu Nov 24 19:16:06 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Nov 2011 00:16:06 GMT Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> Message-ID: <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> On Fri, 25 Nov 2011 00:18:44 +0100, Alexander Kapps wrote: > Now, we are talking about Python 3.2.* on Win7, correct? I only have > Win7 32bit in a VBox VM, but still. I believe that W. eWatson's problems occurred when he installed a 32-bit version of Python 3.2 on a 64-bit version of Windows 7. Either the 32-bit installer doesn't set the default file associations correctly on 64-bit systems, or W. eWatson has mangled his registry by making arbitrary changes to file associations, and now even the correct 64-bit installer can't set the associations correctly. As far as I can tell, nobody running the 64-bit version of Windows 7 has chimed in to either confirm or refute W. eWatson's claim that IDLE doesn't show up, so we have no way of telling whether it doesn't show up due to a lack in the installer, or because eWatson has (slightly) broken his system and has inadvertently prevented it from showing up. Fixing the associations is a Windows issue, not a Python issue. Even if it turns out that the installer does neglect to set up menu commands for IDLE (which should be reported as a feature request on the bug tracker), this is not a problem best solved here, although we can do our best. It would be best solved on a Window forum, where experts on Windows can give advice. -- Steven From alex.kapps at web.de Thu Nov 24 19:32:08 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Fri, 25 Nov 2011 01:32:08 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ECEE208.9010602@web.de> On 25.11.2011 01:04, Steven D'Aprano wrote: > So by your reasoning, that's at least 20 ways to infect my Linux system. > I never realised just how insecure Linux must be! Yes, there are 20+ ways to "infect" your (and mine) Linux system. You cannot trust *any* kind of 3rd party code. Period. Have you ever added a 3rd party repo (PPA or such). Have you ever added some Firefox addon or installed some 3rd-party addition (of any kind) to some program) Where is the protection now? The main difference here is, that Linux makes it easy to seperate administrative accounts from end-user accounts, The custom addon/cmdlet/whatever I give you has the same dangers on Linux as on windows. If you blindly install it, you're owned! > If "sharing code" is considered to be synonymous with "infection", what > does that say about the Free and Open Source Software movement? Completely besides the topic. It's not about "sharing code", but about the seperation between normal and administrative user on the OS level (which Windows still doesn't have by default). > Linux-users-aren't-the-only-people-allowed-to-write-shell-scripts-ly y'rs, But-Linux-Users-aren't-root-by-default-ly y'rs. :) From tjreedy at udel.edu Thu Nov 24 19:51:10 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Nov 2011 19:51:10 -0500 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: On 11/24/2011 7:31 AM, Rudra Banerjee wrote: > Dear friends, > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? The first killer app for Python was running Fortran code from within Python. People use Python for both pre- and post-processing. For small jobs, this enabled running Fortran interactively. This lead to Numerical Python, now Numpy, SciPy, and later Sage and other scientific and Python packages. I believe SciPy has an f2py (fortran to py) module to help with running Fortran under Python (but it has been years since I read the details). Detailed questions might get better answers on, for instance, a scipy list. -- Terry Jan Reedy From tjreedy at udel.edu Thu Nov 24 20:06:24 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Nov 2011 20:06:24 -0500 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 11/24/2011 7:16 PM, Steven D'Aprano wrote: > As far as I can tell, nobody running the 64-bit version of Windows 7 has > chimed in to either confirm or refute W. eWatson's claim that IDLE > doesn't show up, On the contrary, back when he first posted, I stated that 64-bit Python 3.2.2 on my 64-bit Windows 7 works fine, just as he wants it to. > so we have no way of telling whether it doesn't show up > due to a lack in the installer, or because eWatson has (slightly) broken > his system and has inadvertently prevented it from showing up. I also noted that I had slightly screwed up my previous machine, and the installers never fixed up the deviation. So I gave him a better alternative that I use. He has ignored that and most everything else I posted. When he later revealed that IDLE does not run by any means, that he should fix *that* before worrying about right-clicks. > Fixing the associations is a Windows issue, not a Python issue. Even if > it turns out that the installer does neglect to set up menu commands for > IDLE (which should be reported as a feature request on the bug tracker), The installer for each version has been setting up commands for IDLE for perhaps a decade or more. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Thu Nov 24 21:19:56 2011 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 24 Nov 2011 18:19:56 -0800 (PST) Subject: Return of an old friend Message-ID: Hello Fellow Pythonistas, I am very glad to be back after an unfortunate incident caused my Google account to be deleted. Unfortunately for those of you that have been following along and supporting my crusade to bring fairness and humility to the python community, my old posts under "rantingrick" have all been deleted from Google Groups. However, you can always search the python-list archives if you need a jog down memory lane. Actually this accidental deletion may have been a good thing as i've had some extra time to muse on the innards of Python4000. In any event, this announcement is intended to be a new call to arms for my brothers and sisters who fight the good fight, and for those of you who despise me , well, this might be a good time to add my new moniker to your kill files. Thanks, and happy Thanksgiving everyone! From aljosa.mohorovic at gmail.com Thu Nov 24 22:00:52 2011 From: aljosa.mohorovic at gmail.com (Aljosa Mohorovic) Date: Thu, 24 Nov 2011 19:00:52 -0800 (PST) Subject: memory leaks - tools and docs Message-ID: i've been trying to find memory leaks in a wsgi application using gunicorn to run it and after a lot of time invested in research and testing tools i did find a lot of useful information (most really old) but i'm left with a feeling that this should be easier, better documented and with tools that generate better data. if anybody can share some tips, links, docs or better tools with better reports i would really appreciate it. i'm not against paying for a good tool so any recommendation is appreciated. i mostly used http://guppy-pe.sourceforge.net/#Heapy but found http://pysizer.8325.org/ and http://code.google.com/p/pympler/ also interesting. Aljosa From mcfletch at vrplumber.com Thu Nov 24 22:17:11 2011 From: mcfletch at vrplumber.com (Mike C. Fletcher) Date: Thu, 24 Nov 2011 22:17:11 -0500 Subject: memory leaks - tools and docs In-Reply-To: References: Message-ID: <4ECF08B7.9070201@vrplumber.com> On 11-11-24 10:00 PM, Aljosa Mohorovic wrote: > i've been trying to find memory leaks in a wsgi application using > gunicorn to run it and after a lot of time invested in research and > testing tools i did find a lot of useful information (most really old) > but i'm left with a feeling that this should be easier, better > documented and with tools that generate better data. > > if anybody can share some tips, links, docs or better tools with > better reports i would really appreciate it. > i'm not against paying for a good tool so any recommendation is > appreciated. > > i mostly used http://guppy-pe.sourceforge.net/#Heapy but found > http://pysizer.8325.org/ and http://code.google.com/p/pympler/ also > interesting. > > Aljosa Meliae is a similar tool wrt collecting memory-usage information. RunSnakeRun can process Meliae dumps to produce visualizations of the memory used in the process. HTH, Mike https://launchpad.net/meliae http://www.vrplumber.com/programming/runsnakerun/ -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dihedral88888 at googlemail.com Thu Nov 24 22:27:12 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 24 Nov 2011 19:27:12 -0800 (PST) Subject: suitability of python In-Reply-To: References: <1322137895.4211.3.camel@roddur> Message-ID: <1342091.65.1322191632498.JavaMail.geo-discussion-forums@prmu26> On Friday, November 25, 2011 8:51:10 AM UTC+8, Terry Reedy wrote: > On 11/24/2011 7:31 AM, Rudra Banerjee wrote: > > Dear friends, > > I am a newbie in python and basically i use python for postprocessing > > like plotting, data manipulation etc. > > Based on ease of programming on python I am wondering if I can consider > > it for the main development as well. My jobs (written on fortran) runs > > for weeks and quite CPU intensive. How python works on these type of > > heavy computation? > > The first killer app for Python was running Fortran code from within > Python. People use Python for both pre- and post-processing. For small > jobs, this enabled running Fortran interactively. > > This lead to Numerical Python, now Numpy, SciPy, and later Sage and > other scientific and Python packages. I believe SciPy has an f2py > (fortran to py) module to help with running Fortran under Python (but it > has been years since I read the details). > > Detailed questions might get better answers on, for instance, a scipy list. > > -- > Terry Jan Reedy If pyhthon just handles the user interface and glue logics of well written python modules that are most written c, the speed of running python pyc is OK. Of course the object reference updating required in OOP is completely supported by python. From dihedral88888 at googlemail.com Thu Nov 24 22:27:12 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 24 Nov 2011 19:27:12 -0800 (PST) Subject: suitability of python In-Reply-To: References: <1322137895.4211.3.camel@roddur> Message-ID: <1342091.65.1322191632498.JavaMail.geo-discussion-forums@prmu26> On Friday, November 25, 2011 8:51:10 AM UTC+8, Terry Reedy wrote: > On 11/24/2011 7:31 AM, Rudra Banerjee wrote: > > Dear friends, > > I am a newbie in python and basically i use python for postprocessing > > like plotting, data manipulation etc. > > Based on ease of programming on python I am wondering if I can consider > > it for the main development as well. My jobs (written on fortran) runs > > for weeks and quite CPU intensive. How python works on these type of > > heavy computation? > > The first killer app for Python was running Fortran code from within > Python. People use Python for both pre- and post-processing. For small > jobs, this enabled running Fortran interactively. > > This lead to Numerical Python, now Numpy, SciPy, and later Sage and > other scientific and Python packages. I believe SciPy has an f2py > (fortran to py) module to help with running Fortran under Python (but it > has been years since I read the details). > > Detailed questions might get better answers on, for instance, a scipy list. > > -- > Terry Jan Reedy If pyhthon just handles the user interface and glue logics of well written python modules that are most written c, the speed of running python pyc is OK. Of course the object reference updating required in OOP is completely supported by python. From wuwei23 at gmail.com Thu Nov 24 22:37:30 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 24 Nov 2011 19:37:30 -0800 (PST) Subject: suitability of python References: <1322137895.4211.3.camel@roddur> Message-ID: Terry Reedy wrote: > This lead to Numerical Python, now Numpy, SciPy, and later Sage and > other scientific and Python packages. I believe SciPy has an f2py > (fortran to py) module to help with running Fortran under Python (but it > has been years since I read the details). Andrew Dalke recently did some work on f2pypy, as a step toward running Fortran under PyPy: http://www.dalkescientific.com/writings/diary/archive/2011/11/09/f2pypy.html If PyPy's Numpy support was more advanced, I'd probably recommend the OP start there. From wuwei23 at gmail.com Thu Nov 24 22:47:29 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 24 Nov 2011 19:47:29 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> Message-ID: <944e0207-7083-4ae8-a59e-3e05b595708e@d37g2000prg.googlegroups.com> Tim Golden wrote: > The interpreter inherits the command shell's history function: > Open a cmd window and then a Python session. Do some stuff. > > Ctrl-Z to exit to the surrounding cmd window. > Do some random cmd stuff: dir, cd, etc. > > Start a second Python session. up-arrow etc. will bring back > the previous Python session's commands (and not the ones you > entered in the surrounding shell) This isn't true, at least not for ActivePython 2.7.2.5 under Windows 7-64. The second session has no history whatsoever. From wuwei23 at gmail.com Thu Nov 24 22:49:46 2011 From: wuwei23 at gmail.com (alex23) Date: Thu, 24 Nov 2011 19:49:46 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 24, 6:51?pm, Tim Golden wrote: > The > Ctrl-Z thing is what *exits* the interpreter on Windows (a la Ctrl-D > on Linux). With ActivePython, Ctrl-D works as well, which is a godsend as I'm constantly working across Windows & linux. > In short - on Windows, within one cmd shell you can open and exit > the interpreter as many times as you like and the Python command > history will be retained via the cmd shell's history mechanism, > and kept distinct from the history of other things you may type > into the cmd shell. And again, I'm definitely not seeing this. Inside the one cmd shell, each instance of Python has no recollection of the history of the last. From lists at cheimes.de Thu Nov 24 23:05:11 2011 From: lists at cheimes.de (Christian Heimes) Date: Fri, 25 Nov 2011 05:05:11 +0100 Subject: memory leaks - tools and docs In-Reply-To: References: Message-ID: Am 25.11.2011 04:00, schrieb Aljosa Mohorovic: > i mostly used http://guppy-pe.sourceforge.net/#Heapy but found > http://pysizer.8325.org/ and http://code.google.com/p/pympler/ also > interesting. Guppy is a extremely powerful tool because it can also track non GC objects without a debug build of Python. I only wished it would have a user friendly and easy to script interface. The _.more thing is killing me. :( I'm using a very simple and almost for free approach to keep track of memory usage with psutil. After every unit test case I store RSS and VM size with psutil.Process(os.getpid()).get_memory_info(), threading.active_count(), len(gc.garbage) and len(gc.get_objects()). It doesn't show what's going wrong, but it helps me to isolate the code paths, that may introduce memory leaks and reference cycles. Since we use continuous integration (Jenkins) I can track down regressions more easily, too. Christian From ameyer2 at yahoo.com Thu Nov 24 23:06:26 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Thu, 24 Nov 2011 23:06:26 -0500 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: On 11/24/2011 07:31 AM, Rudra Banerjee wrote: > Dear friends, > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? > Any comment or reference is welcome. > I would expect that a language that compiles intensive math programming to machine language will be much more than an order of magnitude faster than a program that does the same thing by interpreting byte code. If you study all of the Python math libraries I'm guessing you'll find modules that do a lot, conceivably all, of what you want in compiled machine language, but when held together with Python it may or may not be as efficient as fortran. I'm guessing there's not much out there that is as efficient as fortran for purely numerical work. I think your division of labor using fortran for the CPU intensive math parts and python for post-processing is a pretty good one. It takes advantage of the strength of each language. In addition, it completely separates the two parts so that they aren't really dependent on each other. You can change the fortran any way you want without breaking the python code as long as you output the same format, and of course you can change the python any way you want. Programs in each language don't even have to know that any other language is involved. My only suggestion is to see if you can get a profiler to see what's happening inside that weeks long running fortran program. You might find some surprises. I once wrote a 5,000 line program that was slower than I had hoped. I ran it through a profiler and it showed me that I was spending more than 50 percent of my time on one single line of my code that called a simple library routine ("strcpy"). I wrote the simple library routine inline instead adding just a few lines of code. It cut the total execution time of the whole program in half. Alan From steve+comp.lang.python at pearwood.info Thu Nov 24 23:37:21 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Nov 2011 04:37:21 GMT Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ecf1b80$0$29988$c3e8da3$5496439d@news.astraweb.com> On Thu, 24 Nov 2011 20:06:24 -0500, Terry Reedy wrote: > On 11/24/2011 7:16 PM, Steven D'Aprano wrote: > >> As far as I can tell, nobody running the 64-bit version of Windows 7 >> has chimed in to either confirm or refute W. eWatson's claim that IDLE >> doesn't show up, > > On the contrary, back when he first posted, I stated that 64-bit Python > 3.2.2 on my 64-bit Windows 7 works fine, just as he wants it to. Ah, sorry about that Terry! This thread, or multiple threads, is long and confusing and I obviously haven't been able to keep track of who said what. -- Steven From anacrolix at gmail.com Fri Nov 25 00:08:17 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Fri, 25 Nov 2011 16:08:17 +1100 Subject: Return of an old friend In-Reply-To: References: Message-ID: I haven't heard of you before, but feel like I've missed out on something. Do you (or someone else) care to link to some of your more contentious work? On Fri, Nov 25, 2011 at 1:19 PM, Rick Johnson wrote: > Hello Fellow Pythonistas, > > I am very glad to be back after an unfortunate incident caused my > Google account to be deleted. Unfortunately for those of you that have > been following along and supporting my crusade to bring fairness and > humility to the python community, my old posts under "rantingrick" > have all been deleted from Google Groups. However, you can always > search the python-list archives if you need a jog down memory lane. > > Actually this accidental deletion may have been a good thing as i've > had some extra time to muse on the innards of Python4000. > > In any event, this announcement is intended to be a new call to arms > for my brothers and sisters who fight the good fight, and for those of > you who despise me , well, this might be a good time to add my new > moniker to your kill files. > > Thanks, and happy Thanksgiving everyone! > -- > http://mail.python.org/mailman/listinfo/python-list > From 6brisk at gmail.com Fri Nov 25 00:23:13 2011 From: 6brisk at gmail.com (brisk brisk) Date: Thu, 24 Nov 2011 21:23:13 -0800 (PST) Subject: online form filling jobs Message-ID: online form filling jobs http://onlinejobsprocess.weebly.com/ From zpengxen at gmail.com Fri Nov 25 01:52:25 2011 From: zpengxen at gmail.com (ZhouPeng) Date: Fri, 25 Nov 2011 14:52:25 +0800 Subject: Strange result ffor object to bool Message-ID: Hi all, In my program, I get a listen element by listen = graphics.find("listen") print listen is print type listen is I am sure listen is not None and can be accessed properly. But print bool(listen) is False if not listen is True -- Zhou Peng From rosuav at gmail.com Fri Nov 25 03:04:11 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Nov 2011 19:04:11 +1100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Nov 25, 2011 at 3:49 PM, Dennis Lee Bieber wrote: > On 25 Nov 2011 00:04:04 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > >> My Linux system includes compilers or interpreters for C, Pascal, >> Haskell, Forth, Python, Ruby, PHP, Javascript, Java, bash, csh, zsh, sh, >> awk, sed, Perl, SQL, Tcl, Tk, OpenXion, and very likely others. Most of > > ? ? ? ?What? No REXX? > > ? ? ? ?{Granted, other than IBM's mainframes, the only decent REXX > implementation [heck, maybe even better] was the Amiga version -- it was > integrated well into the Amiga message passing IPC system, such that > pretty much any application with an ARexx port could connect to and > control any other application with an ARexx port} IBM's non-mainframes too - their OS/2 implementation was - and still is - awesome. I use REXX for a variety of odds and ends, everything from simple scripts up to full-on GUI applications. Yes, we still use OS/2 (as well as Windows and Linux - mixed LANs are fun). ChrisA From chris at simplistix.co.uk Fri Nov 25 03:14:36 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Fri, 25 Nov 2011 08:14:36 +0000 Subject: MailingLogger 3.6.0 Released! Message-ID: <4ECF4E6C.3050308@simplistix.co.uk> I'm pleased to announce a new release of Mailinglogger. Mailinglogger provides two handlers for the standard python logging framework that enable log entries to be emailed either as the entries are logged or as a summary at the end of the running process. The handlers have the following features: - customisable and dynamic subject lines for emails sent - emails sent with a configurable headers for easy filtering - flood protection to ensure the number of emails sent is not excessive - support for SMTP servers that require authentication - fully documented and tested The only change for this release is to allow summaries sent by SummarisingLogger to contain messages logged at a lower level than those which triggered the summary to be emailed. Full docs can be found here: http://packages.python.org/mailinglogger/ For more information, please see: http://www.simplistix.co.uk/software/python/mailinglogger or http://pypi.python.org/pypi/mailinglogger cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk From rosuav at gmail.com Fri Nov 25 03:46:17 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Nov 2011 19:46:17 +1100 Subject: Strange result ffor object to bool In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 5:52 PM, ZhouPeng wrote: > I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False > if not listen ?is True Casting something to boolean follows strict rules derived from the notion that emptiness is false and nonemptiness is true. For instance: >>> bool(""),bool([]),bool({}),bool(0) (False, False, False, False) Details here: http://docs.python.org/library/stdtypes.html Chris Angelico From mail at timgolden.me.uk Fri Nov 25 03:58:30 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 25 Nov 2011 08:58:30 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: <944e0207-7083-4ae8-a59e-3e05b595708e@d37g2000prg.googlegroups.com> References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <944e0207-7083-4ae8-a59e-3e05b595708e@d37g2000prg.googlegroups.com> Message-ID: <4ECF58B6.1060906@timgolden.me.uk> On 25/11/2011 03:47, alex23 wrote: > Tim Golden wrote: >> The interpreter inherits the command shell's history function: >> Open a cmd window and then a Python session. Do some stuff. >> >> Ctrl-Z to exit to the surrounding cmd window. >> Do some random cmd stuff: dir, cd, etc. >> >> Start a second Python session. up-arrow etc. will bring back >> the previous Python session's commands (and not the ones you >> entered in the surrounding shell) > > This isn't true, at least not for ActivePython 2.7.2.5 under Windows > 7-64. The second session has no history whatsoever. Well I don't know what to say. It works for me with an almost identical setup. (ActivePython 2.7.1.4 Win7 x64). And has worked for me over countless setups on different machines / versions of Windows / versions of Python etc. Do you have the pyreadline module installed? ISTR that that takes over from the standard cmd processing... TJG From steve+comp.lang.python at pearwood.info Fri Nov 25 03:59:41 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Nov 2011 08:59:41 GMT Subject: Strange result ffor object to bool References: Message-ID: <4ecf58fd$0$29988$c3e8da3$5496439d@news.astraweb.com> On Fri, 25 Nov 2011 14:52:25 +0800, ZhouPeng wrote: > Hi all, > > In my program, I get a listen element by listen = > graphics.find("listen") What is a listen element? It is not a standard Python object. What library is it from? > print listen is print type listen is 'instance'> I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False What makes you think this is a strange result? Many things are false: py> for obj in (None, [], {}, 0, 0.0, "", 42): ... print bool(obj), ... False False False False False False True -- Steven From __peter__ at web.de Fri Nov 25 04:06:05 2011 From: __peter__ at web.de (Peter Otten) Date: Fri, 25 Nov 2011 10:06:05 +0100 Subject: Strange result ffor object to bool References: Message-ID: ZhouPeng wrote: > In my program, I get a listen element by > listen = graphics.find("listen") > > print listen is > print type listen is > I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False > if not listen is True bool(listen) is False here means that the Element has no children. Quoting http://effbot.org/zone/elementtree-13-intro.htm#truth-testing """ Truth testing # The Element type now issues a warning when used in a ?boolean context?. To get rid of the warning, make the test explicit: if len(elem): ... has at least one children ... elem = root.find("tag") if elem is not None: ... found ... Explicit tests work just fine in ET 1.2, of course. The boolean interpretation will most likely change in future versions, so that all elements evaluate to true, also if they have no children. """ From zpengxen at gmail.com Fri Nov 25 05:09:43 2011 From: zpengxen at gmail.com (ZhouPeng) Date: Fri, 25 Nov 2011 18:09:43 +0800 Subject: Strange result ffor object to bool In-Reply-To: References: Message-ID: Thanks all. I am a c/c++ programer before, So I directly think it is the same roughly between if not obj: (in python) and if (!obj) {(in c/c++) / if obj: (in python) and if (obj) {(in c/c++) That if obj is not None, 'if obj:' goes true branch, 'if not obj:' goes false branch, and I don't need to care where the obj is from (what type or what lib) But, Now it seem not be consistent, so I feel strange. And it seem be obj's library related in python. On Fri, Nov 25, 2011 at 4:59 PM, Peter Otten <__peter__ at web.de> wrote: >What is a listen element? It is not a standard Python object. What >library is it from? from xml.etree.ElementTree On Fri, Nov 25, 2011 at 5:06 PM, Peter Otten <__peter__ at web.de> wrote: > ZhouPeng wrote: > >> In my program, I get a listen element by >> listen = graphics.find("listen") >> >> print listen is >> print type listen is >> I am sure listen is not None and can be accessed properly. >> >> But print bool(listen) is False >> if not listen ?is True > > bool(listen) is False here means that the Element has no children. > Quoting > http://effbot.org/zone/elementtree-13-intro.htm#truth-testing Thanks, > """ > Truth testing # > The Element type now issues a warning when used in a ?boolean context?. To > get rid of the warning, make the test explicit: > if len(elem): > ? ?... has at least one children ... > > elem = root.find("tag") > if elem is not None: > ? ?... found ... > Explicit tests work just fine in ET 1.2, of course. > The boolean interpretation will most likely change in future versions, so > that all elements evaluate to true, also if they have no children. > """ Yea, you are right. And I got it later, when I run my program in python 2.7.2, It complains: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. if not graphics: > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Zhou Peng From enalicho at gmail.com Fri Nov 25 05:13:00 2011 From: enalicho at gmail.com (Noah Hall) Date: Fri, 25 Nov 2011 10:13:00 +0000 Subject: Return of an old friend In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 5:08 AM, Matt Joiner wrote: > I haven't heard of you before, but feel like I've missed out on something. > > Do you (or someone else) care to link to some of your more contentious work? Ignore him, he's a troll with an unjustly inflated ego. From onlinedollarsgroups at gmail.com Fri Nov 25 05:33:25 2011 From: onlinedollarsgroups at gmail.com (onlinedollars earning) Date: Fri, 25 Nov 2011 02:33:25 -0800 (PST) Subject: Amazing website!!! Message-ID: <93aa2e6b-60c8-4aef-8ef6-ed6407c008a2@x30g2000prh.googlegroups.com> Hai, I have a tips for earn money from home.Just go to http://onlinedollarsgroups.blogspot.com/2011/11/blog-post_25.html this weblink.Then click open new tab via that link.One new website will display,then sign up this,and earn money (or)and get any products in low price,offers etc. From ulrich.eckhardt at dominolaser.com Fri Nov 25 05:37:14 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 25 Nov 2011 11:37:14 +0100 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: Am 25.11.2011 04:49, schrieb alex23: > On Nov 24, 6:51 pm, Tim Golden wrote: >> The Ctrl-Z thing is what *exits* the interpreter on Windows >> (a la Ctrl-D on Linux). > > With ActivePython, Ctrl-D works as well, which is a godsend as I'm > constantly working across Windows& linux. > >> In short - on Windows, within one cmd shell you can open and exit >> the interpreter as many times as you like and the Python command >> history will be retained via the cmd shell's history mechanism, >> and kept distinct from the history of other things you may type >> into the cmd shell. > > And again, I'm definitely not seeing this. Inside the one cmd shell, > each instance of Python has no recollection of the history of the > last. I'm seeing history browsing in Python on MS Windows XP here and it also works for every other commandline-based program. Well, it seems with the exception of the ActivePython distribution of Python. That one intentionally changes the MS Windows defaults like Control-Z behaviour and at the same time, maybe even as a side effect, it breaks the shell's history browsing. You don't happen to have an installation of the vanilla Python distribution to test, do you? This is getting me curious... Uli From rosuav at gmail.com Fri Nov 25 05:42:50 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Nov 2011 21:42:50 +1100 Subject: Strange result ffor object to bool In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 9:09 PM, ZhouPeng wrote: > Thanks all. > if not obj: (in python) and if (!obj) {(in c/c++) > > / if obj: (in python) and if (obj) {(in c/c++) > > Yea, ?you are right. > And I got it later, when I run my program in python 2.7.2, > It complains: > FutureWarning: The behavior of this method will change in future versions. > Use specific 'len(elem)' or 'elem is not None' test instead. if not graphics: Yep, this is exactly what you need to do. Check if 'elem is None' to see if it's there or not. Chris Angelico From jehugaleahsa at gmail.com Fri Nov 25 05:55:53 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Fri, 25 Nov 2011 02:55:53 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4ECBEBEC.2010300@yahoo.com> Message-ID: On Nov 22, 1:37?pm, Alan Meyer wrote: > On 11/20/2011 7:46 PM, Travis Parks wrote: > > > Hello: > > > I am currently working on designing a new programming language. ... > > I have great respect for people who take on projects like this. > > Your chances of popularizing the language are small. ?There must be > thousands of projects like this for every one that gets adopted by other > people. ?However your chances of learning a great deal are large, > including many things that you'll be able to apply to programs and > projects that, at first glance, wouldn't appear to benefit from this > kind of experience. ?If you get it working you'll have an impressive > item to add to your resume. > > I suspect that you'll also have a lot of fun. > > Good luck with it. > > ? ? ?Alan I've been learning a lot and having tons of fun just designing the language. First, I get think about all of the language features that I find useful. Then I get to learn a little bit how they work internally. For instance, functions are first-class citizens in Unit, supporting closures. To make that happen meant wrapping such functions inside of types and silently elavating local variables to reference counted pointers. Or, I realized that in order to support default arguments, I would have to silently wrap parameters in types that were either set or not set. That way calls to the default command could simply be replaced by an if statement. It was a really subtle implementation detail. It is also fun thinking about what makes sense. For instance, Unit will support calling methods with named arguments. Originally, I thought about using the '=' operator: Foo(name="bob" age=64) but, then I realized that the equals sign could be confused with assignment. Those types of syntactic conflicts occur quite often and lead to a lot of rethinking. Ultimately, somewhat good ideas get replaced with much better ideas. I had been contemplating Unit for months before the final look and feel of the language came into view. It isn't what I started out imagining, but I think it turned out better than I had originally planned. Recently, I rethought how functions looked, since the headers were too long: alias Predicate = function (value: & readonly T) throws() returns(Boolean) let Any = public function (values: & readonly IIterable) (?predicate: Predicate) throws() # ArgumentNullException inherits from UncheckedException returns(Boolean): # this can be on one line default predicate = (function value: true) assert predicate != null "The predicate cannot be null." ArgumentNullException for value in values: if predicate(value): return true return false Most of the time, throws clauses, returns clauses and parameter type constraints can be left off. Plus, now they can all appear on one line. Assertions and default statements now appear in the body. Assertions now optionally take a message and the exception type to throw. So, yeah, this has been an awesome project so far. I have dozens of documents and I have been keeping up on a blog. I've even started implementing a simple recursive descent parser just to make sure the syntax doesn't conflict. Now it will be a matter of formally defining a grammer and implementing the backend of the compiler... which I've never done before. I have been thinking about compiling into a language like C++ or C instead of assembler for my first time through. From rosuav at gmail.com Fri Nov 25 06:10:00 2011 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Nov 2011 22:10:00 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4ECBEBEC.2010300@yahoo.com> Message-ID: On Fri, Nov 25, 2011 at 9:55 PM, Travis Parks wrote: > I have been thinking about compiling into a > language like C++ or C instead of assembler for my first time through. Yep, or any other language you feel like using as an intermediate. Or alternatively, just start with an interpreter - whatever's easiest. Compiling to C gives you a massive leg-up on portability; so does writing an interpreter in C, as either way your language is easily made available on every platform that gcc's been ported to. As long as you're happy with the idea of building a massively language that'll never be used by anybody but yourself, you can have immense fun with this. And hey, Unit might turn out to be a beautiful niche language, or even go mainstream. But mainly, you'll have fun doing it. And if you're not having fun, what's the use of living forever? (Oh wait, you're not a vampire from Innistrad. Sorry about that.) ChrisA From andrea.crotti.0 at gmail.com Fri Nov 25 06:15:30 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 25 Nov 2011 11:15:30 +0000 Subject: getting svn tag in version Message-ID: <4ECF78D2.8000502@gmail.com> Given a project with many eggs, I would like to make it easy to have all the version numbers synchronized to the upper level SVN version. So for example I might have svn tags 0.1, 0.2 and a development version. The development version should get version -dev, and the others 0.1 and 0.2 I found few examples around that read and parse the .svn/entries file, is it really the best way to do it? From user at nospam.invalid Fri Nov 25 06:24:44 2011 From: user at nospam.invalid (user) Date: Fri, 25 Nov 2011 12:24:44 +0100 Subject: How to get path to Python standard library directory? Message-ID: In a Makefile (or sometimes inside python) I need the path to the root of the Python standard lib folder used by "env python". e.g. /usr/lib/python2.6/ or C:\Python27\Lib\ what is the best/canonical way to get that? From mail at timgolden.me.uk Fri Nov 25 06:29:51 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 25 Nov 2011 11:29:51 +0000 Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ECF7C2F.8090905@timgolden.me.uk> On 25/11/2011 10:37, Ulrich Eckhardt wrote: > Am 25.11.2011 04:49, schrieb alex23: >> On Nov 24, 6:51 pm, Tim Golden wrote: >>> The Ctrl-Z thing is what *exits* the interpreter on Windows >>> (a la Ctrl-D on Linux). >> >> With ActivePython, Ctrl-D works as well, which is a godsend as I'm >> constantly working across Windows& linux. >> >>> In short - on Windows, within one cmd shell you can open and exit >>> the interpreter as many times as you like and the Python command >>> history will be retained via the cmd shell's history mechanism, >>> and kept distinct from the history of other things you may type >>> into the cmd shell. >> >> And again, I'm definitely not seeing this. Inside the one cmd shell, >> each instance of Python has no recollection of the history of the >> last. > > I'm seeing history browsing in Python on MS Windows XP here and it also > works for every other commandline-based program. Well, it seems with the > exception of the ActivePython distribution of Python. That one > intentionally changes the MS Windows defaults like Control-Z behaviour > and at the same time, maybe even as a side effect, it breaks the shell's > history browsing. Except that, intriguingly, I'm also using an ActiveState distro and it neither adds Ctrl-D nor prevents history. But I'm fairly sure that pyreadline does both of those things. TJG From michael at stroeder.com Fri Nov 25 07:31:10 2011 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Fri, 25 Nov 2011 13:31:10 +0100 Subject: ANN: python-ldap 2.4.5 Message-ID: Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.4 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stuff (e.g. processing LDIF, LDAPURLs and LDAPv3 schema). Project's web site: http://www.python-ldap.org/ Ciao, Michael. ---------------------------------------------------------------- Released 2.4.5 2011-11-25 Changes since 2.4.4: Installation: * defines for SASL and SSL in setup.cfg to be more friendly to Python setup tools (easy_install) Lib/ * Fixed typo in ldap.functions._ldap_function_call() which always released ldap._ldap_module_lock instead of local lock * ldap.controls.ppolicy: Fixed decoding the password policy response control Demo/ * Demo script for ldap.controls.ppolicy From 1989lzhh at gmail.com Fri Nov 25 07:47:11 2011 From: 1989lzhh at gmail.com (=?GB2312?B?wfXV8bqj?=) Date: Fri, 25 Nov 2011 20:47:11 +0800 Subject: How to change the file creation timestamp? Message-ID: Hi, I want to change the file creation timestamp using python, but I can not find a solution to do it. I know the way to change the file creation timestamp in C under Windows, but I want to change it using python. I really need help! Regards, Liu Zhenhai -------------- next part -------------- An HTML attachment was scrubbed... URL: From massi_srb at msn.com Fri Nov 25 08:00:04 2011 From: massi_srb at msn.com (Massi) Date: Fri, 25 Nov 2011 05:00:04 -0800 (PST) Subject: Automatic import of submodules Message-ID: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | -- __init__.py -- EtcPlug.py Every .py file contain a class definition whose name is identical to to the file name, so in my main script I have to import each submodule like that: from plugins.wav_plug.WavPlug import WavPlug from plugins.wav_plug.Mp3Plug import Mp3Plug and so on. This is uncomfortable, since when a new plugin is added I have to import it too. So my question is, is it possible to iterate through the 'plugins' directory tree in order to automatically import the submodules contained in each subdirectory? I googled and found that the pkgutil could help, but it is not clear how. Any hints? Thanks in advance. From d at davea.name Fri Nov 25 08:08:08 2011 From: d at davea.name (Dave Angel) Date: Fri, 25 Nov 2011 08:08:08 -0500 Subject: How to get path to Python standard library directory? In-Reply-To: References: Message-ID: <4ECF9338.1050007@davea.name> On 11/25/2011 06:24 AM, user wrote: > In a Makefile (or sometimes inside python) I need the path to the root > of the Python standard lib folder used by "env python". > > e.g. /usr/lib/python2.6/ or C:\Python27\Lib\ > > what is the best/canonical way to get that? You could look at sys.executable. However, on my Linux, it's a symlink, so you have to dereference that to get the directory involved. -- DaveA From d at davea.name Fri Nov 25 08:18:30 2011 From: d at davea.name (Dave Angel) Date: Fri, 25 Nov 2011 08:18:30 -0500 Subject: Automatic import of submodules In-Reply-To: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> References: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Message-ID: <4ECF95A6.20808@davea.name> On 11/25/2011 08:00 AM, Massi wrote: > Hi everyone, > > in my project I have the following directory structure: > > plugins > | > -- wav_plug > | > -- __init__.py > -- WavPlug.py > -- mp3_plug > | > -- __init__.py > -- Mp3Plug.py > ... > -- etc_plug > | > -- __init__.py > -- EtcPlug.py > > Every .py file contain a class definition whose name is identical to > to the file name, so in my main script I have to import each submodule > like that: > > from plugins.wav_plug.WavPlug import WavPlug > from plugins.wav_plug.Mp3Plug import Mp3Plug > > and so on. This is uncomfortable, since when a new plugin is added I > have to import it too. So my question is, is it possible to iterate > through the 'plugins' directory tree in order to automatically import > the submodules contained in each subdirectory? > I googled and found that the pkgutil could help, but it is not clear > how. Any hints? > Thanks in advance. > I think the key to the problem is the __import__() function, which takes a string and returns a module object. So you make a list of the fully qualified module names (filenames less the extension), and loop through that list, Then for each one, you can extract items from the module. It doesn't make sense to define the class names at your top-level, though, since you'd not have any code to reference any new plugin if it has a unique class name. So at some point, you're probably going to have a list or map of such class objects. -- DaveA From ironfroggy at gmail.com Fri Nov 25 08:23:33 2011 From: ironfroggy at gmail.com (Calvin Spealman) Date: Fri, 25 Nov 2011 08:23:33 -0500 Subject: How to get path to Python standard library directory? In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 6:24 AM, user wrote: > In a Makefile (or sometimes inside python) I need the path to the root of > the Python standard lib folder used by "env python". > > e.g. ?/usr/lib/python2.6/ ? or ? ?C:\Python27\Lib\ > > what is the best/canonical way to get that? This should get you what you're looking for. Just look relative to a known stdlib module. import os stdlib_dir = os.path.dirname(os.__file__) > -- > http://mail.python.org/mailman/listinfo/python-list > -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy From jeanmichel at sequans.com Fri Nov 25 08:43:58 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 25 Nov 2011 14:43:58 +0100 Subject: Automatic import of submodules In-Reply-To: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> References: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Message-ID: <4ECF9B9E.704@sequans.com> Massi wrote: > Hi everyone, > > in my project I have the following directory structure: > > plugins > | > -- wav_plug > | > -- __init__.py > -- WavPlug.py > -- mp3_plug > | > -- __init__.py > -- Mp3Plug.py > ... > -- etc_plug > | > -- __init__.py > -- EtcPlug.py > > Every .py file contain a class definition whose name is identical to > to the file name, so in my main script I have to import each submodule > like that: > > from plugins.wav_plug.WavPlug import WavPlug > from plugins.wav_plug.Mp3Plug import Mp3Plug > > and so on. This is uncomfortable, since when a new plugin is added I > have to import it too. So my question is, is it possible to iterate > through the 'plugins' directory tree in order to automatically import > the submodules contained in each subdirectory? > I googled and found that the pkgutil could help, but it is not clear > how. Any hints? > Thanks in advance. > > Hi, Try something like (*untested code*) plugins = {} classes = {} for plugin, className in [('wav_plug', 'WavPlug'), ('mp3_plug', 'Mp3Plug')]: plugins[plugin] = __import__(os.path.join('plugins', plugin, className)) classes[className] = getattr(plugins[plugin], className) # raise a keyError if the plugin has not been imported wav = classes['wav_plug']() Make sure all subdirs have the __init__.py file, including the plugins directory. JM From a24061 at ducksburg.com Fri Nov 25 08:50:01 2011 From: a24061 at ducksburg.com (Adam Funk) Date: Fri, 25 Nov 2011 13:50:01 +0000 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) Message-ID: <91j4q8xgv9.ln2@news.ducksburg.com> I'm converting JSON data to XML using the standard library's json and xml.dom.minidom modules. I get the input this way: input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') big_json = json.load(input_source) input_source.close() Then I recurse through the contents of big_json to build an instance of xml.dom.minidom.Document (the recursion includes some code to rewrite dict keys as valid element names if necessary), and I save the document: xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') doc.writexml(xml_file, encoding='UTF-8') xml_file.close() I thought this would force all the output to be valid, but xmlstarlet gives some errors like these on a few documents: PCDATA invalid Char value 7 PCDATA invalid Char value 31 I guess I need to process each piece of PCDATA to clean out the control characters before creating the text node: text = doc.createTextNode(j) root.appendChild(text) What's the best way to do that, bearing in mind that there can be multibyte characters in the strings? I found some suggestions on the WWW involving filter with string.printable, which AFAICT isn't unicode-friendly --- is there a unicode.printable or something like that? -- "Mrs CJ and I avoid clich?s like the plague." From alec.taylor6 at gmail.com Fri Nov 25 08:51:34 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sat, 26 Nov 2011 00:51:34 +1100 Subject: How to change the file creation timestamp? In-Reply-To: References: Message-ID: import os import time from stat import * #returns a list of all the files on the current directory files = os.listdir('.') for f in files: #my folder has some jpegs and raw images if f.lower().endswith('jpg') or f.lower().endswith('crw'): st = os.stat(f) atime = st[ST_ATIME] #access time mtime = st[ST_MTIME] #modification time new_mtime = mtime + (4*3600) #new modification time #modify the file timestamp os.utime(f,(atime,new_mtime)) On Fri, Nov 25, 2011 at 11:47 PM, ??? <1989lzhh at gmail.com> wrote: > Hi, > I want to change the file creation timestamp using python, but I can not > find a solution to do it. > I know the way to?change the file creation timestamp in C under Windows, but > I want to change it using python. > I really need help! > > Regards, > Liu Zhenhai > > -- > http://mail.python.org/mailman/listinfo/python-list > From irmen.NOSPAM at xs4all.nl Fri Nov 25 09:11:06 2011 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Fri, 25 Nov 2011 15:11:06 +0100 Subject: getting svn tag in version In-Reply-To: References: Message-ID: <4ecfa1fc$0$6909$e4fe514c@news2.news.xs4all.nl> On 25-11-2011 12:15, Andrea Crotti wrote: > Given a project with many eggs, I would like to make it easy to have all the version > numbers synchronized > to the upper level SVN version. > > So for example I might have svn tags > 0.1, > 0.2 > and a development version. > The development version should get version -dev, and the others 0.1 and 0.2 > > I found few examples around that read and parse the .svn/entries file, is it really > the best way to do it? I wouldn't do that, you'll be dependent on the svn implementation. For instance, in svn 1.7, they changed the .svn folder. Easiest is probably parsing the output of the command line svn: svn info --xml Irmen From someone at someplace.invalid Fri Nov 25 10:44:19 2011 From: someone at someplace.invalid (HoneyMonster) Date: Fri, 25 Nov 2011 15:44:19 +0000 (UTC) Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: On Mon, 14 Nov 2011 21:55:43 +1100, Chris Angelico wrote: > On Mon, Nov 14, 2011 at 9:41 PM, Tracubik wrote: >> Hi all, >> i'm developing a new program. >> Mission: learn a bit of database management > > If your goal is to learn about databasing, then I strongly recommend a > real database engine. > >> since i'm mostly a new-bye for as regard databases, my idea is to use >> sqlite at the beginning. >> >> Is that ok? any other db to start with? (pls don't say mysql or >> similar, >> they are too complex and i'll use this in a second step) > > The complexity, in most cases, is a direct consequence of the job at > hand. I recommend PostgreSQL generally, although I've never used it with > Python and can't speak for the quality of the APIs. > > The most important thing to consider is a separation of the back end > (the "guts") from the front end (the "interface"). Since your goal is to > explore databases, the guts of your code will basically just be working > with the database (no heavy computation or anything). Make sure you can > work with that, separately from your GUI. You may find it easier to > dispense with GTK and just work through the console; you can always > change later to make a pretty window. > > If you've never worked with databases before, it may be best to skip > Python altogether and explore the fundamentals of relational database > engines. There's plenty of excellent tutorials on the web. Get to know > how things are done generally, and you'll be able to figure out how > things are done in Python. I agree that given "Mission: learn a bit of database management", Python is not really relevant at this stage. I also entirely concur with your recommendation of PostgreSQL. Just for information, PostgreSQL works very well indeed with Psycopg (a PostgreSQL adapter for Python), but for learning purposes straightforward PSQL is best to start with. From miki.tebeka at gmail.com Fri Nov 25 10:48:35 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Fri, 25 Nov 2011 07:48:35 -0800 (PST) Subject: How to get path to Python standard library directory? In-Reply-To: References: Message-ID: <1236612.727.1322236115510.JavaMail.geo-discussion-forums@yqoo7> You can try PYLIB = $(shell python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()') (or pack the long command line in a script). From rosuav at gmail.com Fri Nov 25 10:49:43 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 26 Nov 2011 02:49:43 +1100 Subject: my new project, is this the right way? In-Reply-To: References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: On Sat, Nov 26, 2011 at 2:44 AM, HoneyMonster wrote: > Just for information, PostgreSQL works very well indeed with Psycopg (a > PostgreSQL adapter for Python), but for learning purposes straightforward > PSQL is best to start with. Thanks for that. I've used PgSQL from C++ (using libpqxx), PHP, Pike, and the command line, but not from Python. (Yeah, a lot of Ps in that.) Once you start looking to write actual code, Python will be an excellent choice. But master the basics of database/schema/table/column, primary keys, etc, etc, etc, first. ChrisA From maxthemouse at googlemail.com Fri Nov 25 11:31:56 2011 From: maxthemouse at googlemail.com (MaxTheMouse) Date: Fri, 25 Nov 2011 08:31:56 -0800 (PST) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <8ce7e33b-418b-478d-bada-0e128ddf7cb6@c18g2000yqj.googlegroups.com> On Nov 24, 10:49?pm, Dennis Lee Bieber wrote: > On 25 Nov 2011 00:16:06 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > > chimed in to either confirm or refute W. eWatson's claim that IDLE > > doesn't show up, so we have no way of telling whether it doesn't show up > > due to a lack in the installer, or because eWatson has (slightly) broken > > his system and has inadvertently prevented it from showing up. > I guess I will put in my 2 cents. I installed EPD from Enthought on 64 bit Win 7 Enterprise. Both 32 bit and 64 versions resulted in having "Edit with Idle" when I right-click on a file. I don't have system administration privileges on this machine so I have no idea how the installer did it. Cheers, Adam From rustompmody at gmail.com Fri Nov 25 12:01:34 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 25 Nov 2011 09:01:34 -0800 (PST) Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> Message-ID: <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> On Nov 14, 3:41?pm, Tracubik wrote: > Hi all, > i'm developing a new program. > Mission: learn a bit of database management > Idea: create a simple, 1 window program that show me a db of movies i've > seen with few (<10) fields (actors, name, year etc) > technologies i'll use: python + gtk > db: that's the question > > since i'm mostly a new-bye for as regard databases, my idea is to use > sqlite at the beginning. > > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) > > is there any general tutorial of how to start developing a database? i > mean a general guide to databases you can suggest to me? > Thank you all > > MedeoTL > > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > easily convert it in a sqlite db? (maybe via csv) To learn DBMS you need to learn sql [Note sql is necessary but not sufficient for learning DBMS] I recommend lightweight approaches to start with -- others have mentioned access, libreoffice-base. One more lightweight playpen is firefox plugin sqlite-manager > Is that ok? any other db to start with? (pls don't say mysql or similar, > they are too complex and i'll use this in a second step) Correct. First you must figure out how to structure data -- jargon is normalization. After that you can look at transactions, ACID, distribution and all the other good stuff. From rustompmody at gmail.com Fri Nov 25 12:11:01 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 25 Nov 2011 09:11:01 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <67882be2-e60e-44c0-851c-a981f882e2ed@c16g2000pre.googlegroups.com> On Nov 21, 5:46?am, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. > > Can anyone list a good introduction to the files found in the source > code? I have been poking around the source code for a little bit and > there is a lot there. So, I was hoping someone could point me to the > "good parts". I am also wondering whether some of the code was > generated because I see state transition tables, which I doubt someone > built by hand. > > Any help would be greatly appreciated. It will be cool to see how the > interpreter works internally. I am still wonder whether designing the > language (going on 4 months now) will be harder than implementing it. > > Thanks, > Travis Parks - compiled language - indentation based - functional programming features Looks like a description of Haskell. You may want to look there. Back end: LLVM is gaining a lot of traction these days. Seems to give best of both worlds -- compiling to C and to machine code From roy at panix.com Fri Nov 25 12:16:21 2011 From: roy at panix.com (Roy Smith) Date: Fri, 25 Nov 2011 12:16:21 -0500 Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> Message-ID: In article <581dab49-e6b0-4fea-915c-4a41fa887c3b at p7g2000pre.googlegroups.com>, rusi wrote: > First you must figure out how to structure data -- jargon is > normalization. After that you can look at transactions, ACID, > distribution and all the other good stuff. And when you're all done with that, you can start unlearning everything you've learned about normalization (not that you shouldn't learn about it in the first place, just that you should also learn when excessive normalization is a bad thing). And then start looking at BASE (Basic Availability, Soft-state, Eventually consistent) as an alternative to ACID. Don't get me wrong. SQL is a powerful tool, and truly revolutionized the database world. Anybody who is thinking about going into databases as a career needs to know SQL. But, it's not the end of the road. There is life after SQL, and that's worth exploring too. From python at mrabarnett.plus.com Fri Nov 25 12:56:07 2011 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 25 Nov 2011 17:56:07 +0000 Subject: Return of an old friend In-Reply-To: References: Message-ID: <4ECFD6B7.30205@mrabarnett.plus.com> On 25/11/2011 10:13, Noah Hall wrote: > On Fri, Nov 25, 2011 at 5:08 AM, Matt Joiner wrote: >> I haven't heard of you before, but feel like I've missed out on something. >> >> Do you (or someone else) care to link to some of your more contentious work? > > Ignore him, he's a troll with an unjustly inflated ego. He has previously posted under the name "rantingrick". In brief, his posts have been about how Python is doomed unless it's rescued from the elite who are ignoring the needs of the silent majority by not fixing this or that, and he offers himself as the one who'll lead the Python community into the promised land, or something like that. From nikunjbadjatya at gmail.com Fri Nov 25 13:00:21 2011 From: nikunjbadjatya at gmail.com (Nikunj Badjatya) Date: Fri, 25 Nov 2011 23:30:21 +0530 Subject: How to keep Console area fixed for a thread In-Reply-To: <599CEBACD49B4144A61212D837EE3C0F144604D7B8@MX34A.corp.emc.com> References: <599CEBACD49B4144A61212D837EE3C0F144604D7B8@MX34A.corp.emc.com> Message-ID: Can anyone throw some light on this please ! ? On Thu, Nov 24, 2011 at 9:05 PM, wrote: > Hi All,**** > > ** ** > > Please look at the code below.**** > > I am using pypi progressbar. But in general, How can I keep the area of > the console fixed for the thread to print its status on it.**** > > ** ** > > {{{**** > > import sys**** > > import time**** > > import threading**** > > import os**** > > ** ** > > from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \* > *** > > FileTransferSpeed, FormatLabel, Percentage, \**** > > ProgressBar, ReverseBar, RotatingMarker, \**** > > SimpleProgress, Timer**** > > **** > > def ProgBar():**** > > widgets = [' ', Percentage(), ' ', > Bar(marker='#',left='[',right=']'),' ']**** > > pbar = ProgressBar(widgets=widgets, maxval=100)**** > > pbar.start()**** > > return pbar**** > > **** > > def update2(i):**** > > os.environ["PBAR"] = i**** > > print(?This will print for every call to update?)**** > > return **** > > **** > > ** ** > > ** ** > > class MyThread(threading.Thread):**** > > def run(self):**** > > l = 0**** > > while True:**** > > n = os.getenv("PBAR", "")**** > > if len(n) != 0:**** > > n = int(n)**** > > if n > l:**** > > pbar.update(n)**** > > l = n**** > > if n == 100:**** > > break **** > > else:**** > > continue **** > > ** ** > > pbar = ProgBar()**** > > mythread = MyThread()**** > > mythread.daemon = True **** > > mythread.start() **** > > ** ** > > **** > > for i in range(101):**** > > update2("{0}".format(i))**** > > time.sleep(0.25)**** > > ** ** > > }}} **** > > ** ** > > {{{**** > > Output:**** > > ** ** > > [image: output.jpeg]**** > > ** ** > > ** ** > > }}}**** > > ** ** > > But I require the output to be of type:**** > > {{{**** > > 13% [########### ]**** > > This will print for every call to update**** > > This will print for every call to update**** > > This will print for every call to update**** > > This will print for every call to update**** > > This will print for every call to update**** > > }}}**** > > ** ** > > This is just a sample piece of code for narrowing down the problem. **** > > How can I fix the cursor position fix for the thread which is updating my > progressbar .?**** > > ** ** > > Thanks**** > > Nikunj**** > > Bangalore-India**** > > ** ** > > ** ** > > ** ** > > ** ** > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 37098 bytes Desc: not available URL: From chris at simplistix.co.uk Fri Nov 25 13:54:13 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Fri, 25 Nov 2011 18:54:13 +0000 Subject: What replaces log4py under Python 3.2? In-Reply-To: <67D108EDFAD3C148A593E6ED7DCB4BBDEDD0A5@RADCONWIN2K8PDC.radcon.local> References: <67D108EDFAD3C148A593E6ED7DCB4BBDEDD0A5@RADCONWIN2K8PDC.radcon.local> Message-ID: <4ECFE455.30904@simplistix.co.uk> On 22/11/2011 18:32, Rob Richardson wrote: > My company has been using the log4py library for a long time. A co-worker recently installed Python 3.2, and log4py will no longer compile. (OK, I know that's the wrong word, but you know what I mean.) What logging package should be used now? How about the core logging package included in Python itself? cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From nulla.epistola at web.de Fri Nov 25 14:52:56 2011 From: nulla.epistola at web.de (Sibylle Koczian) Date: Fri, 25 Nov 2011 20:52:56 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: Am 25.11.2011 01:16, schrieb Steven D'Aprano: > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > chimed in to either confirm or refute W. eWatson's claim that IDLE > doesn't show up, so we have no way of telling whether it doesn't show up > due to a lack in the installer, or because eWatson has (slightly) broken > his system and has inadvertently prevented it from showing up. > I'm using Python 3.2.2 on Windows 7, 64 bit, and I get "Edit with IDLE" and "Edit with PythonWin" in my context menu. I installed Python from the Python.org site, the Windows extensions from Sourceforge, both of them for all users and without any changes to the standard installation or to file associations. This isn't the first Python 3 version on this machine, I don't know if that might be relevant. But it's a fact that changing the applications shown in the context menu for a file association isn't obvious any more on Windows 7. HTH Sibylle From dihedral88888 at googlemail.com Fri Nov 25 18:19:25 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 25 Nov 2011 15:19:25 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <26406614.367.1322263165339.JavaMail.geo-discussion-forums@prnu18> > Except that, intriguingly, I'm also using an ActiveState distro > and it neither adds Ctrl-D nor prevents history. But I'm > fairly sure that pyreadline does both of those things. > > TJG In python I can spawn a process to run python byte code that will produce a file with results. Easy to avoid a lot import A,B,C,D...... on the top level. From dihedral88888 at googlemail.com Fri Nov 25 18:19:25 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 25 Nov 2011 15:19:25 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots In-Reply-To: References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <4ecda8ea$0$30003$c3e8da3$5496439d@news.astraweb.com> <4ecde007$0$30003$c3e8da3$5496439d@news.astraweb.com> Message-ID: <26406614.367.1322263165339.JavaMail.geo-discussion-forums@prnu18> > Except that, intriguingly, I'm also using an ActiveState distro > and it neither adds Ctrl-D nor prevents history. But I'm > fairly sure that pyreadline does both of those things. > > TJG In python I can spawn a process to run python byte code that will produce a file with results. Easy to avoid a lot import A,B,C,D...... on the top level. From 1989lzhh at gmail.com Fri Nov 25 20:12:21 2011 From: 1989lzhh at gmail.com (=?GB2312?B?wfXV8bqj?=) Date: Sat, 26 Nov 2011 09:12:21 +0800 Subject: How to change the file creation timestamp? In-Reply-To: References: Message-ID: Hi Alec Thanks for your help. I want to change the creation timestamp. the code that you give is to change the modification and access time. I already find a solution using pywin32's win32file module import win32file filehandle = win32file.CreateFile(file_name, win32file.GENERIC_WRITE, 0, None, win32file.OPEN_EXISTING, 0, 0) win32file.SetFileTime(filehandle, ctime, atime, mtime) Regards, Liu Zhenhai 2011/11/25 Alec Taylor > import os > import time > from stat import * > > #returns a list of all the files on the current directory > files = os.listdir('.') > > for f in files: > #my folder has some jpegs and raw images > if f.lower().endswith('jpg') or f.lower().endswith('crw'): > st = os.stat(f) > atime = st[ST_ATIME] #access time > mtime = st[ST_MTIME] #modification time > > new_mtime = mtime + (4*3600) #new modification time > > #modify the file timestamp > os.utime(f,(atime,new_mtime)) > > On Fri, Nov 25, 2011 at 11:47 PM, ??? <1989lzhh at gmail.com> wrote: > > Hi, > > I want to change the file creation timestamp using python, but I can not > > find a solution to do it. > > I know the way to change the file creation timestamp in C under Windows, > but > > I want to change it using python. > > I really need help! > > > > Regards, > > Liu Zhenhai > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.kapps at web.de Fri Nov 25 20:34:19 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Sat, 26 Nov 2011 02:34:19 +0100 Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. In-Reply-To: References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecedb73$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ECEE208.9010602@web.de> Message-ID: <4ED0421B.3080801@web.de> On 25.11.2011 05:49, Dennis Lee Bieber wrote: > On Fri, 25 Nov 2011 01:32:08 +0100, Alexander Kapps > declaimed the following in gmane.comp.python.general: > > >> The main difference here is, that Linux makes it easy to seperate >> administrative accounts from end-user accounts, >> > So does Win7... Heck -- I have to answer prompts to OK an installer > even while logged into my admin account! For Windows, Left-Clicking an OK button to confirm potentionally dangerous admin tasks is like linking the acceleration pedal in your car to the brake pedal(If the traffic light shows Red/Stop, push the acceleration pedal to break) I mean, seriously, left-clicking an OK button is something *SO* unusual to Windows users that you could also just remove that "barrier" altogether. Now, OK, I don't really know any Windows version after XP, so things might have changed. But what I see from the casual Win users in my environment is that nothing has really changed. From wuwei23 at gmail.com Fri Nov 25 22:42:31 2011 From: wuwei23 at gmail.com (alex23) Date: Fri, 25 Nov 2011 19:42:31 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> <4ecccb07$0$29993$c3e8da3$5496439d@news.astraweb.com> <944e0207-7083-4ae8-a59e-3e05b595708e@d37g2000prg.googlegroups.com> Message-ID: On Nov 25, 6:58?pm, Tim Golden wrote: > Do you have the pyreadline module installed? ISTR that that takes > over from the standard cmd processing... I'm pretty sure I do. It's really not an issue, though, as I tend to stick to linux & iPython where possible :) From illy at otekno.biz Fri Nov 25 22:45:05 2011 From: illy at otekno.biz (Illy) Date: Sat, 26 Nov 2011 10:45:05 +0700 Subject: myComboBox.SetValue() does not work in windows. Message-ID: <4ED060C1.3050609@otekno.biz> Dear friends.... Anybody know how can I change the text of a ComboBox? Because " myComboBox.SetValue("my text") " does not work on Windows. Anybody would be so nice for telling me complete reference/documentation about wxPython on windows? Because the wxPython between on Linux and on Windows are sometimes different. Thank you very much in advance. -- Let us cut your costs for your business: http://www.otekno.biz Skype: otekno.biz Yahoo-ID: ceo.opentek at ymail.com OpenTEKID: ceo at opentek.tv Mobile: 087 888 04 26 77 Office: +62-21-4587 90 75, 4587 68 08 Fax: +62-21-4587 64 65 BlackBerry Messanger: 274DF07F From wuwei23 at gmail.com Fri Nov 25 23:15:47 2011 From: wuwei23 at gmail.com (alex23) Date: Fri, 25 Nov 2011 20:15:47 -0800 (PST) Subject: Automatic import of submodules References: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Message-ID: <1603fc14-93b7-4e07-b891-631c083c60bc@20g2000prp.googlegroups.com> On Nov 25, 11:00?pm, Massi wrote: > plugins > ? ? | > ? ? -- wav_plug > ? ? ? ? ? | > ? ? ? ? ? -- __init__.py > ? ? ? ? ? -- WavPlug.py > ? ? -- mp3_plug > ? ? ? ? ? | > ? ? ? ? ? -- __init__.py > ? ? ? ? ? -- Mp3Plug.py > ... > ? ? -- etc_plug > ? ? ? ? ? | > ? ? ? ? ? -- __init__.py > ? ? ? ? ? -- EtcPlug.py What do you gain by having each plugin as a package? Unless you're storing other resources with each plugin, I'd move all your XXXPlug.py files into plugins/ I'd also probably call the modules 'wavplug' and the class 'WavPlug' to always make it clear to which you're referring. > Every .py file contain a class definition whose name is identical to > to the file name, so in my main script I have to import each submodule > like that: > > from plugins.wav_plug.WavPlug import WavPlug > from plugins.wav_plug.Mp3Plug import Mp3Plug > > and so on. This is uncomfortable, since when a new plugin is added I > have to import it too. So my question is, is it possible to iterate > through the 'plugins' directory tree in order to automatically import > the submodules contained in each subdirectory? It's not exactly automatic, but you could move all of those imports into plugins/__init__.py, then just do a single from plugins import * in your main module. From fred.sells at adventistcare.org Fri Nov 25 23:22:46 2011 From: fred.sells at adventistcare.org (Sells, Fred) Date: Fri, 25 Nov 2011 23:22:46 -0500 Subject: Using the Python Interpreter as a Reference In-Reply-To: <67882be2-e60e-44c0-851c-a981f882e2ed@c16g2000pre.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <67882be2-e60e-44c0-851c-a981f882e2ed@c16g2000pre.googlegroups.com> Message-ID: I'm looking at a variation on this theme. I currently use Flex/ActionScript for client side work, but there is pressure to move toward HTML5+Javascript and or iOS. Since I'm an old hand at Python, I was wondering if there is a way to use it to model client side logic, then generate the javascript and ActionScript. I don't see an issue using custom python objects to render either mxml, xaml or html5 but I'm not aware if anyone has already solved the problem of converting Python (byte code?) to these languages? Any suggestions. From metolone at gmail.com Fri Nov 25 23:26:31 2011 From: metolone at gmail.com (Mark Tolonen) Date: Fri, 25 Nov 2011 20:26:31 -0800 (PST) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ECBF01A.7060507@yahoo.com> <4ECBF80E.9090003@yahoo.com> <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 25, 11:52?am, Sibylle Koczian wrote: > Am 25.11.2011 01:16, schrieb Steven D'Aprano: > > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > > chimed in to either confirm or refute W. eWatson's claim that IDLE > > doesn't show up, so we have no way of telling whether it doesn't show up > > due to a lack in the installer, or because eWatson has (slightly) broken > > his system and has inadvertently prevented it from showing up. > > I'm using Python 3.2.2 on Windows 7, 64 bit, and I get "Edit with IDLE" > and "Edit with PythonWin" in my context menu. I installed Python from > the Python.org site, the Windows extensions from Sourceforge, both of > them for all users and without any changes to the standard installation > or to file associations. > > This isn't the first Python 3 version on this machine, I don't know if > that might be relevant. > > But it's a fact that changing the applications shown in the context menu > for a file association isn't obvious any more on Windows 7. > > HTH > Sibylle I'm also using Python 2.7 and Python 3.3 on Windows 7, 64-bit, and have both "Edit" menu items as well. Changing the application defaults is now in "Default Programs" right on the Start Menu. It's more "obvious" than the old location, but the old location is just known by more people and Microsoft loves to move things around. -Mark From rustompmody at gmail.com Fri Nov 25 23:48:06 2011 From: rustompmody at gmail.com (rusi) Date: Fri, 25 Nov 2011 20:48:06 -0800 (PST) Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> Message-ID: <804444da-54f8-4325-b3b1-e37b9dc250f1@d37g2000prg.googlegroups.com> On Nov 25, 10:16?pm, Roy Smith wrote: > In article > <581dab49-e6b0-4fea-915c-4a41fa887... at p7g2000pre.googlegroups.com>, > > ?rusi wrote: > > First you must figure out how to structure data -- jargon is > > normalization. After that you can look at transactions, ACID, > > distribution and all the other good stuff. > > And when you're all done with that, you can start unlearning everything > you've learned about normalization (not that you shouldn't learn about > it in the first place, just that you should also learn when excessive > normalization is a bad thing). > > And then start looking at BASE (Basic Availability, Soft-state, > Eventually consistent) as an alternative to ACID. > > Don't get me wrong. ?SQL is a powerful tool, and truly revolutionized > the database world. ?Anybody who is thinking about going into databases > as a career needs to know SQL. ?But, it's not the end of the road. > There is life after SQL, and that's worth exploring too. Yes going all the way up to fifth normal form can be nonsensical. Putting it less jargony -- Given a real world scenario involving data can you organize it into tables with reasonable foreign-key relations, and integrity constraints? If so you can start looking beyond sql. From steve+comp.lang.python at pearwood.info Sat Nov 26 01:18:50 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Nov 2011 06:18:50 GMT Subject: How to change the file creation timestamp? References: Message-ID: <4ed084ca$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sat, 26 Nov 2011 00:51:34 +1100, Alec Taylor wrote: > import os > import time > from stat import * > > #returns a list of all the files on the current directory files = > os.listdir('.') > > for f in files: > #my folder has some jpegs and raw images if f.lower().endswith('jpg') > or f.lower().endswith('crw'): > st = os.stat(f) > atime = st[ST_ATIME] #access time > mtime = st[ST_MTIME] #modification time The original poster asks for how to change the file creation timestamp. (The poster assumes that there is a creation timestamp, which is not necessarily the case -- many file systems do not store the creation time.) > new_mtime = mtime + (4*3600) #new modification time > > #modify the file timestamp > os.utime(f,(atime,new_mtime)) Note that this is from the posix module, so it probably won't work under Windows. > > On Fri, Nov 25, 2011 at 11:47 PM, ??? <1989lzhh at gmail.com> wrote: >> Hi, >> I want to change the file creation timestamp using python, but I can >> not find a solution to do it. >> I know the way to?change the file creation timestamp in C under >> Windows, but I want to change it using python. >> I really need help! >> >> Regards, >> Liu Zhenhai >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> From anacrolix at gmail.com Sat Nov 26 07:19:43 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Sat, 26 Nov 2011 23:19:43 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <67882be2-e60e-44c0-851c-a981f882e2ed@c16g2000pre.googlegroups.com> Message-ID: http://pyjs.org/ On Sat, Nov 26, 2011 at 3:22 PM, Sells, Fred wrote: > I'm looking at a variation on this theme. ?I currently use > Flex/ActionScript for client side work, but there is pressure to move > toward HTML5+Javascript and or iOS. ?Since I'm an old hand at Python, I > was wondering if there is a way to use it to model client side logic, > then generate the javascript and ActionScript. ?I don't see an issue > using custom python objects to render either mxml, xaml or html5 but I'm > not aware if anyone has already solved the problem of converting Python > (byte code?) to these languages? ?Any suggestions. > > -- > http://mail.python.org/mailman/listinfo/python-list > From no.email at please.post Sat Nov 26 08:40:28 2011 From: no.email at please.post (kj) Date: Sat, 26 Nov 2011 13:40:28 +0000 (UTC) Subject: sick of distribute, setup, and all the rest... Message-ID: it's an all-out disgrace. when is python going to get a decent module distribution system??? and don't tell me to do it myself: it's clear that the sorry situation we have now is precisely that too many programmers without the requisite expertise or policy-making authority have decided to pitch in. This is something for GvR and his top Python core library team to do, because the problems are as much policy and institutional ones as they are technical (programming) ones. From steve+comp.lang.python at pearwood.info Sat Nov 26 09:22:11 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Nov 2011 14:22:11 GMT Subject: sick of distribute, setup, and all the rest... References: Message-ID: <4ed0f612$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sat, 26 Nov 2011 13:40:28 +0000, kj wrote: > it's an all-out disgrace. > > when is python going to get a decent module distribution system??? Python 4.3, scheduled for March 2038. It's been ready for a few years now, and a small secret coterie of privileged developers have been using it for their own in-house projects since version 2.1, but it was decided not to release it to the general public, because they'll just bitch and moan that it's a disgrace without actually explaining why they think so, or volunteering to help build a better system. -- Steven From marduk at letterboxes.org Sat Nov 26 09:51:22 2011 From: marduk at letterboxes.org (Albert W. Hopkins) Date: Sat, 26 Nov 2011 09:51:22 -0500 Subject: sick of distribute, setup, and all the rest... In-Reply-To: <4ed0f612$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ed0f612$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <1322319082.3652.3.camel@stretch> On Sat, 2011-11-26 at 14:22 +0000, Steven D'Aprano wrote: > > when is python going to get a decent module distribution system??? > > Python 4.3, scheduled for March 2038. It's been ready for a few years > now, and a small secret coterie of privileged developers have been > using > it for their own in-house projects since version 2.1, but it was > decided > not to release it to the general public, because they'll just bitch > and > moan that it's a disgrace without actually explaining why they think > so, > or volunteering to help build a better system. > > I suspected that all along! > > From maxthemouse at googlemail.com Sat Nov 26 11:22:18 2011 From: maxthemouse at googlemail.com (MaxTheMouse) Date: Sat, 26 Nov 2011 08:22:18 -0800 (PST) Subject: What I do and do not know about installing Python on Win 7 with regard to IDLE. References: <4ecede45$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3fe404cb-7a6d-45c4-88ea-830441d22878@p9g2000vbb.googlegroups.com> On Nov 26, 1:13?am, Dennis Lee Bieber wrote: > On Fri, 25 Nov 2011 20:26:31 -0800 (PST), Mark Tolonen > declaimed the following in > gmane.comp.python.general: > > > Changing the application defaults is now in "Default Programs" right > > on the Start Menu. ?It's more "obvious" than the old location, but the > > old location is just known by more people and Microsoft loves to move > > things around. > > ? ? ? ? Maybe I missed it, but when I looked at that on my Win7 laptop, I > only saw a way to define a default for "open" action -- which, for .py > and .pyw files, should be python.exe and pythonw.exe, respectively; > otherwise you can't run them via double-click. > > ? ? ? ? What I did NOT find was a way to define OTHER actions for the > menu... IE; no way to define an "edit with xxx", or a > "print" operation. > -- > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ I haven't gone back through this complicated thread so I apologize if this has already been mentioned. I only found a registry based way for vista and win7. http://www.techspot.com/guides/210-edit-windows-extended-context-menu/ http://www.winvistaclub.com/e11.html There is also the 'extended' menu by shift+right-click. Maybe the Edit option can show up there. Adam From rustompmody at gmail.com Sat Nov 26 12:11:38 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 26 Nov 2011 09:11:38 -0800 (PST) Subject: Return of an old friend References: Message-ID: On Nov 25, 7:19?am, Rick Johnson wrote: > Hello Fellow Pythonistas, > > I am very glad to be back after an unfortunate incident caused my > Google account to be deleted. Unfortunately for those of you that have > been following along and supporting my crusade to bring fairness and > humility to the python community, my old posts under "rantingrick" > have all been deleted from Google Groups. However, you can always > search the python-list archives if you need a jog down memory lane. > > Actually this accidental deletion may have been a good thing as i've > had some extra time to muse on the innards of Python4000. > > In any event, this announcement is intended to be a new call to arms > for my brothers and sisters who fight the good fight, and for those of > you who despise me , well, this might be a good time to add my new > moniker to your kill files. > > Thanks, and happy Thanksgiving everyone! Hi Rick! Glad to see you back! [Courts can be dull places without jesters ye-know!] From rustompmody at gmail.com Sat Nov 26 12:28:48 2011 From: rustompmody at gmail.com (rusi) Date: Sat, 26 Nov 2011 09:28:48 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: Message-ID: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> On Nov 26, 6:40?pm, kj wrote: > it's an all-out disgrace. > > when is python going to get a decent module distribution system??? > > and don't tell me to do it myself: it's clear that the sorry > situation we have now is precisely that too many programmers without > the requisite expertise or policy-making authority have decided to > pitch in. ?This is something for GvR and his top Python core library > team to do, because the problems are as much policy and institutional > ones as they are technical (programming) ones. I second this. The only thing I disagree about is that GvR is 'top' enough to handle this. For example on my debian box my python system is a mishmash of debian- apt-packages, eggs, and hand-installed stuff. [I believe I tried something like pypi and did not succeed -- dont exactly remember] So for systems like mine python and apt need to talk courteously to each other -- not possible for the likes of u&me; hard even for the likes of GvR. Frankly, this is not great but could be much worse. Some years ago when I worked with Ruby on Rails the rails that came from debian was an travesty. After some suffering I gathered that the optimal diplomacy was: - ruby from apt - gem hand installed - rails from gem While Ive never seen anything as ridiculous as the debian-rails in the python world, its still always a hobson choice: use a deb package that will cleanly install, deinstall, upgrade etc but is out of date or use a fresh and shiny egg that messes up the system. Haskell's cabal/hackage system is just as much a mess http://www.reddit.com/r/haskell/comments/f3lh5/haskells_own_dll_hell/ In short the mess arises from this that each of these languages comes up with its own package management system, neglecting the fact that the language invariably exists in a larger ecosystem From rosuav at gmail.com Sat Nov 26 12:38:18 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 04:38:18 +1100 Subject: Return of an old friend In-Reply-To: References: Message-ID: On Sun, Nov 27, 2011 at 4:11 AM, rusi wrote: > Hi Rick! > Glad to see you back! > [Courts can be dull places without jesters ye-know!] So, what... you'd take someone to court for being funny? That sounds like the -other- Pythons. ChrisA From rantingrickjohnson at gmail.com Sat Nov 26 12:46:32 2011 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 26 Nov 2011 09:46:32 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> Message-ID: <4092a435-02fd-4705-80db-ec958a5fc968@r28g2000yqj.googlegroups.com> On Nov 26, 11:28?am, rusi wrote: > On Nov 26, 6:40?pm, kj wrote: > The only thing I disagree about is that GvR is 'top' enough to handle > this. For a concrete example of how uninterested Mr. Van Rossum has become, take a look at the gawd awful state of Tkinter and especially IDLE. Whist I applaud GvR's initial good will attempts when creating these modules, i am simultaneously ashamed of their current bit-rot states. From alec.taylor6 at gmail.com Sat Nov 26 13:46:52 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sun, 27 Nov 2011 05:46:52 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: Consider implementing OOP, reflection and implement in HLA or C =] On Mon, Nov 21, 2011 at 11:46 AM, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, lambdas, non-locals and my language will partially > support dynamic programming. > > Can anyone list a good introduction to the files found in the source > code? I have been poking around the source code for a little bit and > there is a lot there. So, I was hoping someone could point me to the > "good parts". I am also wondering whether some of the code was > generated because I see state transition tables, which I doubt someone > built by hand. > > Any help would be greatly appreciated. It will be cool to see how the > interpreter works internally. I am still wonder whether designing the > language (going on 4 months now) will be harder than implementing it. > > Thanks, > Travis Parks > -- > http://mail.python.org/mailman/listinfo/python-list From rantingrickjohnson at gmail.com Sat Nov 26 13:53:15 2011 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 26 Nov 2011 10:53:15 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: On Nov 20, 6:46?pm, Travis Parks wrote: > Hello: > > I am currently working on designing a new programming language. It is > a compiled language, but I still want to use Python as a reference. > Python has a lot of similarities to my language, such as indentation > for code blocks, I hope you meant to say "*forced* indention for code blocks"! "Forced" being the key word here. What about tabs over spaces, have you decided the worth of one over the other or are you going to repeat Guido's folly? And please, i love Python, but the language is a bit asymmetrical. Do try to bring some symmetry to this new language. You can learn a lot from GvR's triumphs, however, you can learn even more from his follys. From rosuav at gmail.com Sat Nov 26 14:34:25 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 06:34:25 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: On Sun, Nov 27, 2011 at 5:53 AM, Rick Johnson wrote: > I hope you meant to say "*forced* indention for code blocks"! "Forced" > being the key word here. What about tabs over spaces, have you decided > the worth of one over the other or are you going to repeat Guido's > folly? I recommend demanding that indentation strictly alternate tabs or spaces in successive non-blank lines. Comment-only lines must be identical to the immediately-preceding line. A tab is equivalent to seven spaces. End the ambiguity! ChrisA From rantingrickjohnson at gmail.com Sat Nov 26 16:15:57 2011 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 26 Nov 2011 13:15:57 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <34d119af-3aa9-4720-944c-3852c720552a@4g2000yqu.googlegroups.com> On Nov 26, 1:34?pm, Chris Angelico wrote: > On Sun, Nov 27, 2011 at 5:53 AM, Rick Johnson > > wrote: > > I hope you meant to say "*forced* indention for code blocks"! "Forced" > > being the key word here. What about tabs over spaces, have you decided > > the worth of one over the other or are you going to repeat Guido's > > folly? > > I recommend demanding that indentation strictly alternate tabs or > spaces in successive non-blank lines. Funny. > Comment-only lines must be > identical to the immediately-preceding line. ...as in "indentation" you mean, then yes. OR suffer the syntax error. > A tab is equivalent to > seven spaces. ...as for "the litmus test of stdlib code" you mean, then yes. OR suffer the syntax error. From candide at free.invalid Sat Nov 26 16:20:36 2011 From: candide at free.invalid (candide) Date: Sat, 26 Nov 2011 22:20:36 +0100 Subject: Pragmatics of the standard is() function Message-ID: <4ed15825$0$21841$426a34cc@news.free.fr> In which cases should we use the is() function ? The is() function compares identity of objects rather than values so I was wondering in which circumstances comparing identities of objects is really vital. Examining well reputated Python source code, I realize that is() function is mainly used in the following set form : spam is None But how much "spam is None" is different from "spam == None" ? is() function makes comparaison of (abstract representation of) adresses of objects in memory. Comparing addresses of objects is a low level feature performed by low level langages such as C but seldom needed in high level languages like Python, isn'it ? From roy at panix.com Sat Nov 26 16:32:17 2011 From: roy at panix.com (Roy Smith) Date: Sat, 26 Nov 2011 16:32:17 -0500 Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: In article <4ed15825$0$21841$426a34cc at news.free.fr>, candide wrote: > In which cases should we use the is() function ? The is() function > compares identity of objects rather than values so I was wondering in > which circumstances comparing identities of objects is really vital. > > Examining well reputated Python source code, I realize that is() > function is mainly used in the following set form : > > spam is None > > But how much "spam is None" is different from "spam == None" ? It's the difference between *being* None, and being equal to None. For example: class Spam: def __eq__(self, other): return not other spam = Spam() print spam is None print spam == None When I run that, it prints: False True In practice, when you compare something to None, you usually want the "is" form. In cases where either would work (i.e. 99% of the time), it's convention (and/or good practice) to use "is" because it more more clearly expresses what it is that you're trying to do. From b49P23TIvg at stny.rr.com Sat Nov 26 16:42:00 2011 From: b49P23TIvg at stny.rr.com (Dave) Date: Sat, 26 Nov 2011 13:42:00 -0800 (PST) Subject: tkinter Message-ID: http://forums.devshed.com/python-programming-11/setting-tkinter-checkbox-default-graphical-state-865148.html Please answer this question I failed to resolve. Thanks, Dave. From rosuav at gmail.com Sat Nov 26 17:22:40 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 09:22:40 +1100 Subject: Pragmatics of the standard is() function In-Reply-To: <4ed15825$0$21841$426a34cc@news.free.fr> References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: On Sun, Nov 27, 2011 at 8:20 AM, candide wrote: > is() function makes comparaison of (abstract representation of) adresses of > objects in memory. Comparing addresses of objects is a low level feature > performed by low level langages such as C but seldom needed in high level > languages like Python, isn'it ? You also want 'is' when you're testing for a singleton used as a default value: DEFAULT = object() def foo(arg1,arg2,arg3=DEFAULT): if arg3 is DEFAULT: print("You gave me two args") ChrisA From alex.kapps at web.de Sat Nov 26 17:38:26 2011 From: alex.kapps at web.de (Alexander Kapps) Date: Sat, 26 Nov 2011 23:38:26 +0100 Subject: Pragmatics of the standard is() function In-Reply-To: <4ed15825$0$21841$426a34cc@news.free.fr> References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: <4ED16A62.4050009@web.de> On 26.11.2011 22:20, candide wrote: You already got answers for the "is" vs. "==" difference. I'd like to add the following. > In which cases should we use the is() function ? "is" is not a function, It's an operator, just like == or +. > is() function makes comparaison of (abstract representation of) > adresses of objects in memory. That's an implementation detail. CPython (and maybe others) implement "is" in terms of memory addresses. Other implementations might use an object ID number or whatever else. From steve+comp.lang.python at pearwood.info Sat Nov 26 18:01:13 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Nov 2011 23:01:13 GMT Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sat, 26 Nov 2011 22:20:36 +0100, candide wrote: > In which cases should we use the is() function ? The is() function > compares identity of objects rather than values so I was wondering in > which circumstances comparing identities of objects is really vital. `is` is not a function. It is a keyword and an operator. You should always use `is` when you intend to test for object identity, and never use `is` when you do not intend to test for object identity. For example: TASK: check whether a number is equal to 42. # WRONG don't do this if x is 42: ... # RIGHT use equality instead if x == 42: ... Object identity is the wrong solution here, because you cannot control whether Python will re-use the same object for every instance of 42, or different objects each time. TASK: check whether an object is a specific sentinel value, and no other value, even if it happens to compare equal to the sentinel. The most common sentinel is the singleton None. # WRONG don't do this if x == None: ... # RIGHT use is instead if x is None: ... Use of equality is inappropriate, because it tests whether the object compares equal to None. Although there are no built-ins that compare equal to None, there could be any number of custom objects that do, and so your code contains a bug: you intend to branch *only* on None, but might branch on some other object by mistake. > Examining well reputated Python source code, I realize that is() > function is mainly used in the following set form : > > spam is None > > But how much "spam is None" is different from "spam == None" ? Even if you can guarantee that your code base does not contain any object which compares equal to None except for None itself (and how would you do that? a full audit of every line of code in every library you use?), the use of `is` should be preferred because it signals your intention much better. If your intention is to accept arbitrary objects which compare equal to None, than by all means use == for your comparison. But normally the intention is to accept None, and nothing else. > is() function makes comparaison of (abstract representation of) adresses > of objects in memory. Comparing addresses of objects is a low level > feature performed by low level langages such as C but seldom needed in > high level languages like Python, isn'it ? That is correct. You probably should rarely use `is`. Apart from testing for None, use of `is` should be rare. -- Steven From jason.swails at gmail.com Sat Nov 26 18:10:40 2011 From: jason.swails at gmail.com (Jason Swails) Date: Sat, 26 Nov 2011 18:10:40 -0500 Subject: tkinter In-Reply-To: References: Message-ID: The problem is that the logMode1 reference is _only_ bound to the name logMode1. Assigning it to "variable" in the Checkbutton instance (logCheck1) does not actually generate a reference to that variable inside logCheck1. Therefore, once the initialize method terminates, all references to logMode1 are destroyed and the variable is garbage-collected. Therefore, that variable will be None by default, regardless of what you do to it inside "initialize", which is why the button appears unchecked. If you create a reference to it, then the Checkbutton behaves as you'd expect (that is, it appears checked). You can verify this easily by just making logMode1 an attribute of simpleapp_tk (replace logMode1 with self.logMode1 in every case). You can also see this behavior by artificially lengthening the initialize method. Import the time module and run "time.sleep(5)" at the end of initialize, and you will see the check button remain checked for 5 seconds (while the reference logMode1 survives), before the check vanishes as sleep ends and the reference leaves scope. I would suggest that this is a checking feature rather than a bug. The variable that you set is useless unless you plan to use the value (or if there's a case where you may use it). If such a case exists, then you'll need a reference to that variable in the relevant scope you're dealing with. Hope this helps, Jason On Nov 26, 2011, at 4:42 PM, Dave wrote: > http://forums.devshed.com/python-programming-11/setting-tkinter-checkbox-default-graphical-state-865148.html > Please answer this question I failed to resolve. > Thanks, > Dave. > -- > http://mail.python.org/mailman/listinfo/python-list From dihedral88888 at googlemail.com Sat Nov 26 18:41:38 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 26 Nov 2011 15:41:38 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> Message-ID: <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > On Nov 14, 3:41?pm, Tracubik wrote: > > Hi all, > > i'm developing a new program. > > Mission: learn a bit of database management > > Idea: create a simple, 1 window program that show me a db of movies i've > > seen with few (<10) fields (actors, name, year etc) > > technologies i'll use: python + gtk > > db: that's the question > > > > since i'm mostly a new-bye for as regard databases, my idea is to use > > sqlite at the beginning. > > > > Is that ok? any other db to start with? (pls don't say mysql or similar, > > they are too complex and i'll use this in a second step) > > > > is there any general tutorial of how to start developing a database? i > > mean a general guide to databases you can suggest to me? > > Thank you all > > > > MedeoTL > > > > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > easily convert it in a sqlite db? (maybe via csv) > > To learn DBMS you need to learn sql > [Note sql is necessary but not sufficient for learning DBMS] > I recommend lightweight approaches to start with -- others have > mentioned access, libreoffice-base. > One more lightweight playpen is firefox plugin sqlite-manager > > > Is that ok? any other db to start with? (pls don't say mysql or similar, > > they are too complex and i'll use this in a second step) > > Correct. First you must figure out how to structure data -- jargon is > normalization. > After that you can look at transactions, ACID, distribution and all > the other good stuff. If I have a fast hash library that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? From candide at free.invalid Sat Nov 26 20:42:52 2011 From: candide at free.invalid (candide) Date: Sun, 27 Nov 2011 02:42:52 +0100 Subject: Pragmatics of the is operator In-Reply-To: <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed1959d$0$690$426a74cc@news.free.fr> Thanks to all for your response. Le 27/11/2011 00:01, Steven D'Aprano a ?crit : > On Sat, 26 Nov 2011 22:20:36 +0100, candide wrote: > >> In which cases should we use the is() function ? The is() function >> compares identity of objects rather than values so I was wondering in >> which circumstances comparing identities of objects is really vital. > > `is` is not a function. It is a keyword and an operator. oops exponent 10 !! I have in mind the id() function, very close to the is operator. An operator named "is" makes search of code snippets very complicated because the verb "is" is always embedded in comments or documentation. >> But how much "spam is None" is different from "spam == None" ? > > Even if you can guarantee that your code base does not contain any object > which compares equal to None except for None itself (and how would you do > that? a full audit of every line of code in every library you use?), the > use of `is` should be preferred because it signals your intention much > better. OK but tons of good code use "spam == None" ; for instance, many tests files in Python official code. A random example (from openshot/openshot/windows/MainGTK.py): # --------------------------------------------------------------- parent_name = item.parent if parent_name == None: match_iter = None # Check for NO files if mode == None and self.project.project_folder.items.__len__() == 0: #switch to the detail view if drop_track == None: # keep old parent, if no track found if self.new_clip_object == None: self.item_detected = False # --------------------------------------------------------------- > > If your intention is to accept arbitrary objects which compare equal to > None, than by all means use == for your comparison. But normally the > intention is to accept None, and nothing else. So, for the same reason, wouldn't it be better to use "if spam is True" against to "if spam == True" (or better "if spam") ? > That is correct. You probably should rarely use `is`. Apart from testing > for None, use of `is` should be rare. OK, thanks From rosuav at gmail.com Sat Nov 26 20:50:52 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 12:50:52 +1100 Subject: Pragmatics of the is operator In-Reply-To: <4ed1959d$0$690$426a74cc@news.free.fr> References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed1959d$0$690$426a74cc@news.free.fr> Message-ID: On Sun, Nov 27, 2011 at 12:42 PM, candide wrote: > So, for the same reason, wouldn't it be better to use "if spam is True" > against to "if spam == True" ?(or better "if spam") ? > They're quite different. "if spam" will check the truthiness of spam - it's equivalent to "if bool(spam) is True"; "if spam is True" checks that it's actually a boolean. But I would recommend against the "== True" form, as it's unclear which form you meant to use. (Others may disagree.) ChrisA From d at davea.name Sat Nov 26 21:20:01 2011 From: d at davea.name (Dave Angel) Date: Sat, 26 Nov 2011 21:20:01 -0500 Subject: How to keep Console area fixed for a thread In-Reply-To: References: <599CEBACD49B4144A61212D837EE3C0F144604D7B8@MX34A.corp.emc.com> Message-ID: <4ED19E51.5000302@davea.name> On 11/25/2011 01:00 PM, Nikunj Badjatya wrote: > Can anyone throw some light on this please ! ? > > > ( when you top-post, you confuse things. comp.lang.python follows the usual convention of putting new material after the parts you're quoting. Further, trying to embed images inside html messages will mess up all of us who use text readers to read a text forum. ) > On Thu, Nov 24, 2011 at 9:05 PM, wrote: > >> Hi All,**** >> >> ** ** >> >> Please look at the code below.**** >> >> I am using pypi progressbar. But in general, How can I keep the area of >> the console fixed for the thread to print its status on it.**** >> No idea what you're really asking. But I'll take a wild guess. Perhaps you're trying to divvy up a console box, and have different parts of it updated by different threads. In the general case, it can't be done. But if you are going to make it work, you'll need to restrict the environment some. Perhaps if you reword the question, with more information, someone can help. What operating system and what Python version will this have to run on? On Unix/Linux, you have curses that can be used at least to print without scrolling. On Windows, you may have something similar, by using ANSI sequences, but it's been so long since I tried that I have no idea. But if you just use print from different threads, the characters may be intermingled. -- DaveA From d at davea.name Sat Nov 26 21:35:29 2011 From: d at davea.name (Dave Angel) Date: Sat, 26 Nov 2011 21:35:29 -0500 Subject: my new project, is this the right way? In-Reply-To: <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: <4ED1A1F1.1080404@davea.name> On 11/26/2011 06:41 PM, 88888 Dihedral wrote: > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: >> On Nov 14, 3:41 pm, Tracubik wrote: >>> Hi all, >>> i'm developing a new program. >>> Mission: learn a bit of database management >>> Idea: create a simple, 1 window program that show me a db of movies i've >>> seen with few (<10) fields (actors, name, year etc) >>> technologies i'll use: python + gtk >>> db: that's the question >>> >>> since i'm mostly a new-bye for as regard databases, my idea is to use >>> sqlite at the beginning. >>> >>> Is that ok? any other db to start with? (pls don't say mysql or similar, >>> they are too complex and i'll use this in a second step) >>> >>> is there any general tutorial of how to start developing a database? i >>> mean a general guide to databases you can suggest to me? >>> Thank you all >>> >>> MedeoTL >>> >>> P.s. since i have a ods sheet files (libreoffice calc), is there a way to >>> easily convert it in a sqlite db? (maybe via csv) >> To learn DBMS you need to learn sql >> [Note sql is necessary but not sufficient for learning DBMS] >> I recommend lightweight approaches to start with -- others have >> mentioned access, libreoffice-base. >> One more lightweight playpen is firefox plugin sqlite-manager >> >>> Is that ok? any other db to start with? (pls don't say mysql or similar, >>> they are too complex and i'll use this in a second step) >> Correct. First you must figure out how to structure data -- jargon is >> normalization. >> After that you can look at transactions, ACID, distribution and all >> the other good stuff. > If I have a fast hash library that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > If you're using Python, you already have a "fast hash" library, in the dictionary class. And yes, if a problem doesn't need the full generality of a database, you may be able to implement it with dictionaries, and it may even be practical to store those dictionaries to disk for later retrieval. However, there are quite a few reasons this may not be good enough. To start with just two: if there are multiple users of the database, and they have to be synched. Or if you have to be safe from a program or a system crashing. -- DaveA From roy at panix.com Sat Nov 26 21:49:20 2011 From: roy at panix.com (Roy Smith) Date: Sat, 26 Nov 2011 21:49:20 -0500 Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: In article , Dave Angel wrote: > If you're using Python, you already have a "fast hash" library, in the > dictionary class. And yes, if a problem doesn't need the full > generality of a database, you may be able to implement it with > dictionaries, and it may even be practical to store those dictionaries > to disk for later retrieval. However, there are quite a few reasons > this may not be good enough. To start with just two: if there are > multiple users of the database, and they have to be synched. Or if you > have to be safe from a program or a system crashing. This is a good point. In general, databases differ from in-memory data structures in that they provide: 1) Persistence 2) Data integrity 3) Shared access Different kinds of databases provide different amounts and flavors of these (especially #2). I think it's fair to say, however, that those three in some form are essential for something that calls itself a database. Where thing get fun is when you start looking at the various things out there that call themselves databases and need to evaluate which ones give you the combination of these that best match your needs. From steve+comp.lang.python at pearwood.info Sat Nov 26 22:13:00 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Nov 2011 03:13:00 GMT Subject: Pragmatics of the is operator References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed1959d$0$690$426a74cc@news.free.fr> Message-ID: <4ed1aabc$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sun, 27 Nov 2011 02:42:52 +0100, candide wrote: >> Even if you can guarantee that your code base does not contain any >> object which compares equal to None except for None itself (and how >> would you do that? a full audit of every line of code in every library >> you use?), the use of `is` should be preferred because it signals your >> intention much better. > > OK but tons of good code use "spam == None" ; for instance, many tests > files in Python official code. A random example (from > openshot/openshot/windows/MainGTK.py): I don't know what openshot is, but I don't think it is "official" in the sense of being in the Python standard library: >>> import openshot Traceback (most recent call last): File "", line 1, in ImportError: No module named openshot But even if it were, the standard library is not written by superhuman perfect gods, only by ordinary human beings who can make mistakes. Comparing against None with == is not idiomatic Python, and is usually a mistake. It rarely leads to obvious bugs, so it can survive in code without notice for a long time. >> If your intention is to accept arbitrary objects which compare equal to >> None, than by all means use == for your comparison. But normally the >> intention is to accept None, and nothing else. > > > So, for the same reason, wouldn't it be better to use "if spam is True" > against to "if spam == True" (or better "if spam") ? No. Normally should just say "if spam" and allow Python to test the truthiness of spam. "if spam == True" is worse, because there are many truthy objects which are not equal to True, e.g. 42, "norwegian blue", [1, 2, 3] are all truthy objects that (almost always) should be accepted but will wrongly be rejected. "if spam is True" is even worse, because there are many truthy objects that are not the True singleton. Old code, especially if it was written before the introduction of bools in (I think) 2.1 or 2.2, often uses 1 as the standard true-like value. To save typing, many people will still pass 1 or 0 as an argument when a bool is expected, which will then fail if you test for identity. The exception is if for some reason you actually care whether your flag is the True object and absolutely nothing else. This violates Python's preference for duck-typing and support for truthiness, but if you have a good reason, go right ahead. Suppose spam is already a bool. Then "if spam" is enough, since spam is a bool. "if spam is True" is no more necessary than if spam is True is True if spam is True is True is True if spam is True is True is True is True if spam is True is True is True is True is True if spam is True is True is True is True is True is True # I never know when to stop... The right place to stop is not to start. "if spam is True" is redundant. And lastly, testing for identity against None is guaranteed by the language: any implementation of Python must have None a singleton. But True and False are not such a strong promise. A future version of Python, or another implementation, might not bother to make True and False singletons. (Doubletons?) Unlikely, but why make assumptions that you don't need to? -- Steven From dihedral88888 at googlemail.com Sat Nov 26 22:14:36 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 26 Nov 2011 19:14:36 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> On Sunday, November 27, 2011 10:49:20 AM UTC+8, Roy Smith wrote: > In article , > Dave Angel wrote: > > > If you're using Python, you already have a "fast hash" library, in the > > dictionary class. And yes, if a problem doesn't need the full > > generality of a database, you may be able to implement it with > > dictionaries, and it may even be practical to store those dictionaries > > to disk for later retrieval. However, there are quite a few reasons > > this may not be good enough. To start with just two: if there are > > multiple users of the database, and they have to be synched. Or if you > > have to be safe from a program or a system crashing. > > This is a good point. In general, databases differ from in-memory data > structures in that they provide: > > 1) Persistence > > 2) Data integrity > > 3) Shared access Shared in access in a local lan or a wide wan? In python there are packages can solve these easily. From rosuav at gmail.com Sat Nov 26 22:24:09 2011 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Nov 2011 14:24:09 +1100 Subject: my new project, is this the right way? In-Reply-To: <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> Message-ID: On Sun, Nov 27, 2011 at 2:14 PM, 88888 Dihedral wrote: > Shared in access in a local lan or a wide wan? > That question isn't inherent to databasiness; it might not even be network-shared at all - in fact, most database-driven web sites have a database that's accessible only from localhost (which is where the web server runs). It's still shared access, and has all the same concerns. ChrisA From d at davea.name Sat Nov 26 22:27:38 2011 From: d at davea.name (Dave Angel) Date: Sat, 26 Nov 2011 22:27:38 -0500 Subject: my new project, is this the right way? In-Reply-To: <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> Message-ID: <4ED1AE2A.50709@davea.name> On 11/26/2011 10:14 PM, 88888 Dihedral wrote: > On Sunday, November 27, 2011 10:49:20 AM UTC+8, Roy Smith wrote: >> >> This is a good point. In general, databases differ from in-memory data >> structures in that they provide: >> >> 1) Persistence >> >> 2) Data integrity >> >> 3) Shared access > Shared in access in a local lan or a wide wan? > > In python there are packages can solve these easily. Right, and they are not in-memory databases. or to go back to the OP in this fork of the thread, they are not "fast hashes." -- DaveA From roy at panix.com Sat Nov 26 22:41:39 2011 From: roy at panix.com (Roy Smith) Date: Sat, 26 Nov 2011 22:41:39 -0500 Subject: my new project, is this the right way? References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <26232548.146.1322363676465.JavaMail.geo-discussion-forums@pruu5> Message-ID: In article <26232548.146.1322363676465.JavaMail.geo-discussion-forums at pruu5>, 88888 Dihedral wrote: > > In general, databases differ from in-memory data > > structures in that they provide: > > > > 1) Persistence > > > > 2) Data integrity > > > > 3) Shared access > > Shared in access in a local lan or a wide wan? Well, like I said in my original post, "Different kinds of databases provide different amounts and flavors of these". Sharing across a network is one type of shared access, but there are lots of things that don't do network access that I would still consider databases. From anacrolix at gmail.com Sat Nov 26 23:03:26 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Sun, 27 Nov 2011 15:03:26 +1100 Subject: my new project, is this the right way? In-Reply-To: <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: Sounds like you want a key-value store. If it's a lot of data, you may still want a "database", I think it's just relational databases that you're trying to avoid? On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral wrote: > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: >> On Nov 14, 3:41?pm, Tracubik wrote: >> > Hi all, >> > i'm developing a new program. >> > Mission: learn a bit of database management >> > Idea: create a simple, 1 window program that show me a db of movies i've >> > seen with few (<10) fields (actors, name, year etc) >> > technologies i'll use: python + gtk >> > db: that's the question >> > >> > since i'm mostly a new-bye for as regard databases, my idea is to use >> > sqlite at the beginning. >> > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, >> > they are too complex and i'll use this in a second step) >> > >> > is there any general tutorial of how to start developing a database? i >> > mean a general guide to databases you can suggest to me? >> > Thank you all >> > >> > MedeoTL >> > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to >> > easily convert it in a sqlite db? (maybe via csv) >> >> To learn DBMS you need to learn sql >> [Note sql is necessary but not sufficient for learning DBMS] >> I recommend lightweight approaches to start with -- others have >> mentioned access, libreoffice-base. >> One more lightweight playpen is firefox plugin sqlite-manager >> >> > Is that ok? any other db to start with? (pls don't say mysql or similar, >> > they are too complex and i'll use this in a second step) >> >> Correct. First you must figure out how to structure data -- jargon is >> normalization. >> After that you can look at transactions, ACID, distribution and all >> the other good stuff. > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > -- > http://mail.python.org/mailman/listinfo/python-list > From dihedral88888 at googlemail.com Sun Nov 27 03:29:52 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 27 Nov 2011 00:29:52 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > Sounds like you want a key-value store. If it's a lot of data, you may > still want a "database", I think it's just relational databases that > you're trying to avoid? > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > wrote: > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > >> On Nov 14, 3:41?pm, Tracubik wrote: > >> > Hi all, > >> > i'm developing a new program. > >> > Mission: learn a bit of database management > >> > Idea: create a simple, 1 window program that show me a db of movies i've > >> > seen with few (<10) fields (actors, name, year etc) > >> > technologies i'll use: python + gtk > >> > db: that's the question > >> > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > >> > sqlite at the beginning. > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > > >> > is there any general tutorial of how to start developing a database? i > >> > mean a general guide to databases you can suggest to me? > >> > Thank you all > >> > > >> > MedeoTL > >> > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > >> > easily convert it in a sqlite db? (maybe via csv) > >> > >> To learn DBMS you need to learn sql > >> [Note sql is necessary but not sufficient for learning DBMS] > >> I recommend lightweight approaches to start with -- others have > >> mentioned access, libreoffice-base. > >> One more lightweight playpen is firefox plugin sqlite-manager > >> > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > >> Correct. First you must figure out how to structure data -- jargon is > >> normalization. > >> After that you can look at transactions, ACID, distribution and all > >> the other good stuff. > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. Each entry is just a type and value stored in a row of my database. I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. Can I do this in 1024 hashes in python ? From dihedral88888 at googlemail.com Sun Nov 27 03:29:52 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 27 Nov 2011 00:29:52 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> Message-ID: <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > Sounds like you want a key-value store. If it's a lot of data, you may > still want a "database", I think it's just relational databases that > you're trying to avoid? > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > wrote: > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > >> On Nov 14, 3:41?pm, Tracubik wrote: > >> > Hi all, > >> > i'm developing a new program. > >> > Mission: learn a bit of database management > >> > Idea: create a simple, 1 window program that show me a db of movies i've > >> > seen with few (<10) fields (actors, name, year etc) > >> > technologies i'll use: python + gtk > >> > db: that's the question > >> > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > >> > sqlite at the beginning. > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > > >> > is there any general tutorial of how to start developing a database? i > >> > mean a general guide to databases you can suggest to me? > >> > Thank you all > >> > > >> > MedeoTL > >> > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > >> > easily convert it in a sqlite db? (maybe via csv) > >> > >> To learn DBMS you need to learn sql > >> [Note sql is necessary but not sufficient for learning DBMS] > >> I recommend lightweight approaches to start with -- others have > >> mentioned access, libreoffice-base. > >> One more lightweight playpen is firefox plugin sqlite-manager > >> > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > >> Correct. First you must figure out how to structure data -- jargon is > >> normalization. > >> After that you can look at transactions, ACID, distribution and all > >> the other good stuff. > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. Each entry is just a type and value stored in a row of my database. I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. Can I do this in 1024 hashes in python ? From dihedral88888 at googlemail.com Sun Nov 27 03:49:14 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 27 Nov 2011 00:49:14 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> Message-ID: <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> On Sunday, November 27, 2011 4:29:52 PM UTC+8, 88888 Dihedral wrote: > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > Sounds like you want a key-value store. If it's a lot of data, you may > > still want a "database", I think it's just relational databases that > > you're trying to avoid? > > > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > > wrote: > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > >> On Nov 14, 3:41?pm, Tracubik wrote: > > >> > Hi all, > > >> > i'm developing a new program. > > >> > Mission: learn a bit of database management > > >> > Idea: create a simple, 1 window program that show me a db of movies i've > > >> > seen with few (<10) fields (actors, name, year etc) > > >> > technologies i'll use: python + gtk > > >> > db: that's the question > > >> > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > >> > sqlite at the beginning. > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > > >> > is there any general tutorial of how to start developing a database? i > > >> > mean a general guide to databases you can suggest to me? > > >> > Thank you all > > >> > > > >> > MedeoTL > > >> > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > >> > easily convert it in a sqlite db? (maybe via csv) > > >> > > >> To learn DBMS you need to learn sql > > >> [Note sql is necessary but not sufficient for learning DBMS] > > >> I recommend lightweight approaches to start with -- others have > > >> mentioned access, libreoffice-base. > > >> One more lightweight playpen is firefox plugin sqlite-manager > > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > >> Correct. First you must figure out how to structure data -- jargon is > > >> normalization. > > >> After that you can look at transactions, ACID, distribution and all > > >> the other good stuff. > > > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. > > Each entry is just a type and value stored in a row of my database. > I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. > > Can I do this in 1024 hashes in python ? Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. I'll reserve 24 entries per row for book keeping. Thus the record can have 1000 entries maximum first. The number of record can be very large. Each value will be a string with type 1 byte and the stored value 8 to 255 bytes represented as a string when fetching the value can be auto-transformed according to the type. The sort and search will be rewritten for the comparison operator. From dihedral88888 at googlemail.com Sun Nov 27 03:49:14 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 27 Nov 2011 00:49:14 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> Message-ID: <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> On Sunday, November 27, 2011 4:29:52 PM UTC+8, 88888 Dihedral wrote: > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > Sounds like you want a key-value store. If it's a lot of data, you may > > still want a "database", I think it's just relational databases that > > you're trying to avoid? > > > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > > wrote: > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > >> On Nov 14, 3:41?pm, Tracubik wrote: > > >> > Hi all, > > >> > i'm developing a new program. > > >> > Mission: learn a bit of database management > > >> > Idea: create a simple, 1 window program that show me a db of movies i've > > >> > seen with few (<10) fields (actors, name, year etc) > > >> > technologies i'll use: python + gtk > > >> > db: that's the question > > >> > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > >> > sqlite at the beginning. > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > > >> > is there any general tutorial of how to start developing a database? i > > >> > mean a general guide to databases you can suggest to me? > > >> > Thank you all > > >> > > > >> > MedeoTL > > >> > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > >> > easily convert it in a sqlite db? (maybe via csv) > > >> > > >> To learn DBMS you need to learn sql > > >> [Note sql is necessary but not sufficient for learning DBMS] > > >> I recommend lightweight approaches to start with -- others have > > >> mentioned access, libreoffice-base. > > >> One more lightweight playpen is firefox plugin sqlite-manager > > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > >> Correct. First you must figure out how to structure data -- jargon is > > >> normalization. > > >> After that you can look at transactions, ACID, distribution and all > > >> the other good stuff. > > > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. > > Each entry is just a type and value stored in a row of my database. > I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. > > Can I do this in 1024 hashes in python ? Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. I'll reserve 24 entries per row for book keeping. Thus the record can have 1000 entries maximum first. The number of record can be very large. Each value will be a string with type 1 byte and the stored value 8 to 255 bytes represented as a string when fetching the value can be auto-transformed according to the type. The sort and search will be rewritten for the comparison operator. From anacrolix at gmail.com Sun Nov 27 07:54:24 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Sun, 27 Nov 2011 23:54:24 +1100 Subject: sick of distribute, setup, and all the rest... In-Reply-To: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> Message-ID: Agreed. I recently gave Haskell a go, and it was remarkable how similar the package management is to Python's. How well does the new "packaging" (set for release in Python 3.3?) module deal with the problems? With a better package management system, the half of the standard library that nobody uses can be unceremoniously dumped, and their more recent upstream versions used correctly. Even distutils itself is "obsolete", the first recommendation people give is to replace it with distribute and/or pip. On Sun, Nov 27, 2011 at 4:28 AM, rusi wrote: > On Nov 26, 6:40?pm, kj wrote: >> it's an all-out disgrace. >> >> when is python going to get a decent module distribution system??? >> >> and don't tell me to do it myself: it's clear that the sorry >> situation we have now is precisely that too many programmers without >> the requisite expertise or policy-making authority have decided to >> pitch in. ?This is something for GvR and his top Python core library >> team to do, because the problems are as much policy and institutional >> ones as they are technical (programming) ones. > > I second this. > > The only thing I disagree about is that GvR is 'top' enough to handle > this. > For example on my debian box my python system is a mishmash of debian- > apt-packages, > eggs, and hand-installed stuff. ?[I believe I tried something like > pypi and did not succeed -- dont exactly remember] > So for systems like mine python and apt need to talk courteously to > each other -- not possible for the likes of u&me; hard even for the > likes of GvR. > > Frankly, this is not great but could be much worse. ?Some years ago > when I worked with Ruby on Rails the rails that came from debian was > an travesty. ?After some suffering I gathered that the optimal > diplomacy was: > - ruby from apt > - gem hand installed > - rails from gem > > While Ive never seen anything as ridiculous as the debian-rails in the > python world, its still always a hobson choice: ?use a deb package > that will cleanly install, deinstall, upgrade etc but is out of date > or use a fresh and shiny egg that messes up the system. > > Haskell's cabal/hackage system is just as much a mess > http://www.reddit.com/r/haskell/comments/f3lh5/haskells_own_dll_hell/ > > In short the mess arises from this that each of these languages comes > up with its own package management system, neglecting the fact that > the language invariably exists in a larger ecosystem > -- > http://mail.python.org/mailman/listinfo/python-list > From anacrolix at gmail.com Sun Nov 27 08:04:01 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Mon, 28 Nov 2011 00:04:01 +1100 Subject: Return of an old friend In-Reply-To: References: Message-ID: On Sun, Nov 27, 2011 at 4:38 AM, Chris Angelico wrote: > On Sun, Nov 27, 2011 at 4:11 AM, rusi wrote: >> Hi Rick! >> Glad to see you back! >> [Courts can be dull places without jesters ye-know!] > > So, what... you'd take someone to court for being funny? That sounds > like the -other- Pythons. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > Burn!! :D From irmen.NOSPAM at xs4all.nl Sun Nov 27 09:33:22 2011 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Sun, 27 Nov 2011 15:33:22 +0100 Subject: why is bytearray treated so inefficiently by pickle? Message-ID: <4ed24a33$0$6869$e4fe514c@news2.news.xs4all.nl> Hi, A bytearray is pickled (using max protocol) as follows: >>> pickletools.dis(pickle.dumps(bytearray([255]*10),2)) 0: \x80 PROTO 2 2: c GLOBAL '__builtin__ bytearray' 25: q BINPUT 0 27: X BINUNICODE u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' 52: q BINPUT 1 54: U SHORT_BINSTRING 'latin-1' 63: q BINPUT 2 65: \x86 TUPLE2 66: q BINPUT 3 68: R REDUCE 69: q BINPUT 4 71: . STOP >>> bytearray("\xff"*10).__reduce__() (, (u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff', 'latin-1'), None) Is there a particular reason it is encoded so inefficiently? Most notably, the actual *bytes* in the bytearray are represented by an UTF-8 string. This needs to be transformed into a unicode string and then encoded back into bytes, when unpickled. The thing being a bytearray, I would expect it to be pickled as such: a sequence of bytes. And then possibly converted back to bytearray using the constructor that takes the bytes directly (BINSTRING/BINBYTES pickle opcodes). The above occurs both on Python 2.x and 3.x. Any ideas? Candidate for a patch? Irmen. From delmarmcbride at gmail.com Sun Nov 27 09:57:10 2011 From: delmarmcbride at gmail.com (Horace Quinn) Date: Sun, 27 Nov 2011 06:57:10 -0800 (PST) Subject: Buy Google AdWords Vouchers & Coupons Message-ID: <8e9c5394-68c9-449e-bbf5-4fdcfd5b3d39@f30g2000pri.googlegroups.com> Hi Friends, Do You Need Google AdWords Vouchers. You Can Get All Coupons Of $100, $75, $50 Credit. Just Visit http://buyadwordsvoucher.tk/ To Get Them. You Will Receive Coupon With In 12 Hrs 100%. Thankyou & Good Luck In Google AdWords. adwords voucher, adwords coupon, buy adwords voucher, buy adwords coupon, adwords credit, adwords Gutschein, adwords buono, adwords kupon From delmarmcbride at gmail.com Sun Nov 27 09:59:02 2011 From: delmarmcbride at gmail.com (Horace Quinn) Date: Sun, 27 Nov 2011 06:59:02 -0800 (PST) Subject: Buy Google AdWords Vouchers & Coupons Message-ID: <158025fc-151e-456f-81e8-abcdcf8c8210@s17g2000pra.googlegroups.com> Hi Friends, Do You Need Google AdWords Vouchers. You Can Get All Coupons Of $100, $75, $50 Credit. Just Visit http://buyadwordsvoucher.tk/ To Get Them. You Will Receive Coupon With In 12 Hrs 100%. Thankyou & Good Luck In Google AdWords. adwords voucher, adwords coupon, buy adwords voucher, buy adwords coupon, adwords credit, adwords Gutschein, adwords buono, adwords kupon From delmarmcbride at gmail.com Sun Nov 27 09:59:29 2011 From: delmarmcbride at gmail.com (Horace Quinn) Date: Sun, 27 Nov 2011 06:59:29 -0800 (PST) Subject: hii Message-ID: <2d643f3a-ee29-4ced-9471-7d44b101ef35@n22g2000prh.googlegroups.com> okk From stef.mientki at gmail.com Sun Nov 27 11:46:26 2011 From: stef.mientki at gmail.com (Stef Mientki) Date: Sun, 27 Nov 2011 17:46:26 +0100 Subject: [ANN] Android Debug Bridge (ADB) Scripting Language For Android (SL4A) convenience library Message-ID: <4ED26962.8070901@gmail.com> hello, The information on ADB / SL4A is quiet overwhelming. Despite that, especially for people, not familiar with Linux, it's not an easy task to get their first program running. This library allows you to easy upload and run Python files on a Android device, without pressing any button on the Android device. After installing SL4A and Py4A on the Android device, and ADB on the hostmachine, it's just a matter of connecting the USB cable between Android device and host-PC, and run the program. One of the simplest program that will run out of the box (without touching any button on the Android device) : # ***************************************************** from adb_sl4a_support import ADB_Connection ADB = ADB_Connection () print ADB # Create a simple program Simple_Program = """ import android droid = android.Android (( '%s', %s )) droid.makeToast ( "Wasn't that easy?") """ % ( ADB.SL4A_Servers [-1][0], ADB.SL4A_Servers [-1][1] ) # execute the program (this will run the program from the host PC !!) exec ( Simple_Program ) # ***************************************************** you can find the library here: http://code.google.com/p/pylab-works/downloads/detail?name=adb_sl4a_support.py&can=2&q= cheers, Stef From invalid at invalid.invalid Sun Nov 27 12:19:27 2011 From: invalid at invalid.invalid (Grant Edwards) Date: Sun, 27 Nov 2011 17:19:27 +0000 (UTC) Subject: suitability of python References: <1322137895.4211.3.camel@roddur> Message-ID: On 2011-11-24, Rudra Banerjee wrote: > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? You'll have to tell us what "these type of heavy computation" are before we can answer. There are a _lot_ of heavy-duty computational libraries (many of them written in FORTAN) that have been interfaced to Python (BLAS and so on). If the heavy lifting can be done by those libraries, Python might be very suitable. You might want to check out scipy, Scientific Python, and the Enthought python distro. http://www.scipy.org/ http://dirac.cnrs-orleans.fr/plone/software/scientificpython/overview/ http://www.enthought.com/products/epd.php From stefan_ml at behnel.de Sun Nov 27 12:54:47 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 27 Nov 2011 17:54:47 +0000 Subject: suitability of python In-Reply-To: <1322137895.4211.3.camel@roddur> References: <1322137895.4211.3.camel@roddur> Message-ID: Rudra Banerjee, 24.11.2011 12:31: > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? You already got a lot of answers that pointed you to the scientific computing tools that are available for Python. The reason why they exist is because (and nowadays also "why") Python is so extremely popular in that field: it's an easy to learn and use language and the standard implementation (often referred to as CPython) makes it really easy to interface with external code (C/C++/Fortran/etc.) in a very efficient way. In addition to looking at NumPy/SciPy and/or Sage (depending on the kind of computations you are involved with), you should also look at fwrap and Cython. They will allow you to easily wrap your existing Fortran code for Python, and to quickly write very fast glue code for the two language environments. Thus, you can keep your existing code as it is, and use and control it from Python, using all the nice tools that Python provides for quickly writing anything from distributed code and test suites to graphical user interfaces for visualising your data. Since you specifically asked about plotting, don't miss out on matplotlib. Stefan From gelonida at gmail.com Sun Nov 27 13:57:29 2011 From: gelonida at gmail.com (Gelonida N) Date: Sun, 27 Nov 2011 19:57:29 +0100 Subject: lxml precaching DTD for document verification. Message-ID: Hi, I'd like to verify some (x)html / / html5 / xml documents from a server. These documents have a very limited number of different doc types / DTDs. So what I would like to do is to build a small DTD cache and some code, that would avoid searching the DTDs over and over from the net. What would be the best way to do this? I guess, that the fields od en ElementTre, that I have to look at are docinfo.public_id docinfo.system_uri There's also mentioning af a catalogue, but I don't know how to use a catalog and how to know what is inside my catalogue and what isn't. Below a non working skeleto (first shot): --------------------------------------------- Would this be the right way?? ### ufnctions with '???' are not implemented / are the ones ### where I don't know whether they exist alreday. import os import urllib from lxml import etree cache_dir = os.path.join(os.environ['HOME'], ''.my_dtd_cache') def get_from_cache(docinfo): """ the function which I'd like to implement most efficiently """ fpi = docinfo.public_id uri = docinfo.system_uri dtd = ???get_from_dtd_cache(fpi, uri) if dtd is not None: return dtd # how can I check what is in my 'catalogue' if ???dtd_in_catalogue(??): return ???get_dtd_from_catalogue??? dtd_rdr = urllib.urlopen(uri) dtd_filename = ???create_cache_filename(docinfo) (fname, _headers) = urllib.urlretrieve(uri, dtd_filename) return etree.DTD(fname) def check_doc_cached(filename): """ function, which should report errors if a doc doesn't validate. """ doc = etree.parse(filename) dtd = get_from_cache(doc.docinfo) rslt = dtd.validate(doc) if not rlst: print "validate error:" print(dtd.error_log.filter_from_errors()[0]) From roy at panix.com Sun Nov 27 15:29:13 2011 From: roy at panix.com (Roy Smith) Date: Sun, 27 Nov 2011 15:29:13 -0500 Subject: lxml precaching DTD for document verification. References: Message-ID: In article , Gelonida N wrote: > I'd like to verify some (x)html / / html5 / xml documents from a server. I'm sure you could roll your own validator with lxml and some DTDs, but you would probably save yourself a huge amount of effort by just using the validator the W3C provides (http://validator.w3.org/). From gordon at panix.com Sun Nov 27 16:33:44 2011 From: gordon at panix.com (John Gordon) Date: Sun, 27 Nov 2011 21:33:44 +0000 (UTC) Subject: lxml precaching DTD for document verification. References: Message-ID: In Roy Smith writes: > In article , > Gelonida N wrote: > > > I'd like to verify some (x)html / / html5 / xml documents from a server. > I'm sure you could roll your own validator with lxml and some DTDs, but > you would probably save yourself a huge amount of effort by just using > the validator the W3C provides (http://validator.w3.org/). With regards to XML, he may mean that he wants to validate that the document conforms to a specific format, not just that it is generally valid XML. I don't think the w3 validator will do that. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From cs at zip.com.au Sun Nov 27 16:46:13 2011 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 28 Nov 2011 08:46:13 +1100 Subject: sick of distribute, setup, and all the rest... In-Reply-To: References: Message-ID: <20111127214613.GA11514@cskk.homeip.net> On 27Nov2011 23:54, Matt Joiner wrote: | Agreed. I recently gave Haskell a go, and it was remarkable how | similar the package management is to Python's. | | How well does the new "packaging" (set for release in Python 3.3?) | module deal with the problems? | | With a better package management system, the half of the standard | library that nobody uses can be unceremoniously dumped, and their more | recent upstream versions used correctly. Even distutils itself is | "obsolete", the first recommendation people give is to replace it with | distribute and/or pip. Ah the cheery optimism of the end user. Package systems have a lot of fun complications. Install for the user only? For the whole system? Architecture specific? What if people want access to different versions of a package? What about vendor supplied (eg RPM) versus user obtained? They'll fight, one way or another. What if policy has user supplied installing to its own tree (sensible to avoid conflicts) - the fetch/install kit need to know this. What about stability? Your "half of the standard library that nobody uses can be unceremoniously dumped, and their more recent upstream versions used correctly" leads to bugs in the apps that use the packages if they depend on particular versions/APIs. The stdlib is generally quite careful about breaking APIs but other packagers often are less so. I can make this list bigger or more detailed if you want. All package systems have these issues. They're not as trivial as you might imagine. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The problem with elections is that the government always wins. - Chris Rudram From jehugaleahsa at gmail.com Sun Nov 27 17:21:01 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Sun, 27 Nov 2011 14:21:01 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> Message-ID: <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> On Nov 26, 1:53?pm, Rick Johnson wrote: > On Nov 20, 6:46?pm, Travis Parks wrote: > > > Hello: > > > I am currently working on designing a new programming language. It is > > a compiled language, but I still want to use Python as a reference. > > Python has a lot of similarities to my language, such as indentation > > for code blocks, > > I hope you meant to say "*forced* indention for code blocks"! "Forced" > being the key word here. What about tabs over spaces, have you decided > the worth of one over the other or are you going to repeat Guido's > folly? > > And please, i love Python, but the language is a bit asymmetrical. Do > try to bring some symmetry to this new language. You can learn a lot > from GvR's triumphs, however, you can learn even more from his follys. Personally, I find a lot of good things in Python. I thinking tabs are out-of-date. Even the MAKE community wishes that the need for tabs would go away and many implementations have done just that. I have been seriously debating about whether to force a specific number of spaces, such as the classic 4, but I am not sure yet. Some times, 2 or even 8 spaces is appropriate (although I'm not sure when). I have always found the standard library for Python to be disjoint. That can be really beneficial where it keeps the learning curve down and the size of the standard modules down. At the same time, it means re-learning whenever you use a new module. My language combines generators and collection initializers, instead of creating a whole new syntax for comprehensions. [| for i in 0..10: for j in 0.10: yield return i * j |] Lambdas and functions are the same thing in my language, so no need for a special keyword. I also distinguish between initialization and assignment via the let keyword. Also, non-locals do not need to be defined explicitly, since the scoping rules in Unit are far more "anal". In reality though, it takes a certain level of arrogance to assume that any language will turn out without bumps. It is like I was told in college long ago, "Only the smallest programs are bug free." I think the same thing could be said for a language. The only language without flaws would be so small that it would be useless. I love these types of discussions though, because it helps me to be aware. When designing a language, it is extremely helpful to hear what language features have led to problems. For instance, C#'s foreach loops internally reuse a variable, which translates to something like this: using (IEnumerator enumerator = enumerable.GetEnumerator()) { T current; while (enumerator.MoveNext()) { current = enumerator.Current; // inner loop code goes here } } Since the same variable is reused, threads referencing the loop variable work against whatever value is currently in the variable, rather than the value when the thread was created. Most of the time, this means every thread works against the same value, which isn't the expected outcome. Moving the variable inside the loop _may_ help, but it would probably be optimized back out of the loop by the compiler. With the growth of threaded applications, these types of stack-based optimizations may come to an end. That is why it is important for a next-gen language to have a smarter stack - one that is context sensitive. In Unit, the stack grows and shrinks like a dynamic array, at each scope, rather than at the beginning and end of each function. Sure, there's a slight cost in performance, but a boost in consistency. If a programmer really wants the performance, they can move the variable out of the loop themselves. In fact, there are a lot of features in Unit that will come with overhead, such as default arguments, non-locals, function-objects, etc. However, the game plan is to avoid the overhead if it isn't used. Some things, such as exception handling, will be hard to provide without overhead. My belief is that, provided a tool, most developers will use it and accept the slight runtime overhead. I think everyone has an idea about what would make for the perfect language. I am always willing to entertain ideas. I have pulled from many sources: C#, Java, Python, JavaScript, F#, Lisp and more. The hope is to provide as much expression with as much consistency as possible. Just the other day I spent 2 hours trying to determine how to create a null pointer (yeah, it took that long). let pi = null as shared * Integer32 # null is always a pointer Originally, I wanted 'as' to be a safe conversion. However, I decided to make use of the 'try' keyword to mean a safe conversion. let nd = try base as shared * Derived let d = if nd.Succeeded: nd.Value else: null # or, shorthand let i = try Integer32.Parse("123") else 0 Of course, the last line could cost performance wise. For that reason, Unit will allow for "try" versions of methods. let Parse = public static method (value: String) throws(FormatException UnderflowException OverflowException) returns(Integer32): ... and Parse = public static try method (value: String) returns(TryResult): ... Of course, such methods are required to never throw and must return a specific named tuple type. Type, type, type. In short, I can only hope my language is useful and that I dodge as many inconsistencies as possible. The good thing about an unknown language is that no one gets mad when things change. In that sense, Python's annoyances are probably an indication of its quality. :-) From colinh at somewhere.invalid Sun Nov 27 18:02:37 2011 From: colinh at somewhere.invalid (Colin Higwell) Date: Sun, 27 Nov 2011 23:02:37 +0000 (UTC) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> Message-ID: On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > On Nov 26, 1:53?pm, Rick Johnson wrote: >> On Nov 20, 6:46?pm, Travis Parks wrote: >> >> > Hello: >> >> > I am currently working on designing a new programming language. It is >> > a compiled language, but I still want to use Python as a reference. >> > Python has a lot of similarities to my language, such as indentation >> > for code blocks, >> >> I hope you meant to say "*forced* indention for code blocks"! "Forced" >> being the key word here. What about tabs over spaces, have you decided >> the worth of one over the other or are you going to repeat Guido's >> folly? >> >> And please, i love Python, but the language is a bit asymmetrical. Do >> try to bring some symmetry to this new language. You can learn a lot >> from GvR's triumphs, however, you can learn even more from his follys. > > Personally, I find a lot of good things in Python. I thinking tabs are > out-of-date. Even the MAKE community wishes that the need for tabs would > go away and many implementations have done just that. I have been > seriously debating about whether to force a specific number of spaces, > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > spaces is appropriate (although I'm not sure when). > > I have always found the standard library for Python to be disjoint. That > can be really beneficial where it keeps the learning curve down and the > size of the standard modules down. At the same time, it means > re-learning whenever you use a new module. > > My language combines generators and collection initializers, instead of > creating a whole new syntax for comprehensions. > > [| for i in 0..10: for j in 0.10: yield return i * j |] > > Lambdas and functions are the same thing in my language, so no need for > a special keyword. I also distinguish between initialization and > assignment via the let keyword. Also, non-locals do not need to be > defined explicitly, since the scoping rules in Unit are far more "anal". > > In reality though, it takes a certain level of arrogance to assume that > any language will turn out without bumps. It is like I was told in > college long ago, "Only the smallest programs are bug free." I think the > same thing could be said for a language. The only language without flaws > would be so small that it would be useless. > > I love these types of discussions though, because it helps me to be > aware. When designing a language, it is extremely helpful to hear what > language features have led to problems. For instance, C#'s foreach loops > internally reuse a variable, which translates to something like this: > > using (IEnumerator enumerator = enumerable.GetEnumerator()) > { > T current; > while (enumerator.MoveNext()) > { > current = enumerator.Current; > // inner loop code goes here > } > } > > Since the same variable is reused, threads referencing the loop variable > work against whatever value is currently in the variable, rather than > the value when the thread was created. Most of the time, this means > every thread works against the same value, which isn't the expected > outcome. Moving the variable inside the loop _may_ help, but it would > probably be optimized back out of the loop by the compiler. With the > growth of threaded applications, these types of stack-based > optimizations may come to an end. That is why it is important for a > next-gen language to have a smarter stack - one that is context > sensitive. In Unit, the stack grows and shrinks like a dynamic array, at > each scope, rather than at the beginning and end of each function. Sure, > there's a slight cost in performance, but a boost in consistency. If a > programmer really wants the performance, they can move the variable out > of the loop themselves. > > In fact, there are a lot of features in Unit that will come with > overhead, such as default arguments, non-locals, function-objects, etc. > However, the game plan is to avoid the overhead if it isn't used. Some > things, such as exception handling, will be hard to provide without > overhead. My belief is that, provided a tool, most developers will use > it and accept the slight runtime overhead. > > I think everyone has an idea about what would make for the perfect > language. I am always willing to entertain ideas. I have pulled from > many sources: C#, Java, Python, JavaScript, F#, Lisp and more. The hope > is to provide as much expression with as much consistency as possible. > Just the other day I spent 2 hours trying to determine how to create a > null pointer (yeah, it took that long). > > let pi = null as shared * Integer32 # null is always a pointer > > Originally, I wanted 'as' to be a safe conversion. However, I decided to > make use of the 'try' keyword to mean a safe conversion. > > let nd = try base as shared * Derived let d = if nd.Succeeded: nd.Value > else: null # or, shorthand let i = try Integer32.Parse("123") else 0 > > Of course, the last line could cost performance wise. For that reason, > Unit will allow for "try" versions of methods. > > let Parse = public static method (value: String) throws(FormatException > UnderflowException OverflowException) returns(Integer32): ... > and Parse = public static try method (value: String) > returns(TryResult): ... > > Of course, such methods are required to never throw and must return a > specific named tuple type. > > Type, type, type. In short, I can only hope my language is useful and > that I dodge as many inconsistencies as possible. The good thing about > an unknown language is that no one gets mad when things change. In that > sense, Python's annoyances are probably an indication of its quality. > :-) Most of this is way above my head but FWIW, I am very happy with four spaces for indentation. I forget now what I used in BASIC and COBOL, but I have always used four spaces in PL/SQL, PL/pgSQL, PL/Tcl, c, ksh, bash and Python. From steve+comp.lang.python at pearwood.info Sun Nov 27 18:55:09 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Nov 2011 23:55:09 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> Message-ID: <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > Personally, I find a lot of good things in Python. I thinking tabs are > out-of-date. Even the MAKE community wishes that the need for tabs would > go away and many implementations have done just that. Tabs have every theoretical advantage and only one practical disadvantage: the common toolsets used by Unix programmers are crap in their handling of tabs, and instead of fixing the toolsets, they blame the tabs. The use of spaces as indentation is a clear case of a technically worse solution winning over a better solution. > I have been > seriously debating about whether to force a specific number of spaces, > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > spaces is appropriate (although I'm not sure when). Why on earth should your language dictate the width of an indentation? I can understand that you might care that indents are consistent within a single source code unit (a file?), but anything more than that is just obnoxious. > I have always found the standard library for Python to be disjoint. That > can be really beneficial where it keeps the learning curve down and the > size of the standard modules down. At the same time, it means > re-learning whenever you use a new module. I know what disjoint means, but I don't understand what you think it means for a software library to be disjoint. I don't understand the rest of the paragraph. > My language combines generators and collection initializers, instead of > creating a whole new syntax for comprehensions. > > [| for i in 0..10: for j in 0.10: yield return i * j |] Are we supposed to intuit what that means? Is | a token, or are the delimiters [| and |] ? Is there a difference between iterating over 0..10 and iterating over what looks like a float 0.10? What is "yield return"? > Lambdas and functions are the same thing in my language, so no need for > a special keyword. That does not follow. Lambdas and def functions are the same thing in Python, but Python requires a special keyword. > I also distinguish between initialization and > assignment via the let keyword. What does this mean? I can guess, but I might guess wrong. > Also, non-locals do not need to be > defined explicitly, since the scoping rules in Unit are far more "anal". What does this mean? I can't even guess what you consider more anal scoping rules. > In reality though, it takes a certain level of arrogance to assume that > any language will turn out without bumps. It is like I was told in > college long ago, "Only the smallest programs are bug free." I think the > same thing could be said for a language. The only language without flaws > would be so small that it would be useless. I'm pretty sure that being so small that it is useless would count as a flaw. What does it mean to say that a language is "small"? A Turing Machine is a pretty small language, with only a few instructions: step forward, step backwards, erase a cell, write a cell, branch on the state of the cell. And yet anything that can be computed, anything at all, can be computed by a Turning Machine: a Turing Machine can do anything you can do in C, Lisp, Fortran, Python, Java... and very probably anything you can (mentally) do, full stop. So what does that mean about "small" languages? On the other hand, take Epigram, a functional programming language: http://en.wikipedia.org/wiki/Epigram_(programming_language) It is *less* powerful than a Turing Machine, despite being far more complex. Similarly languages like regular expressions, finite automata and context-free grammers are more complex, "bigger", possibly with dozens or hundreds of instructions, and yet less powerful. Likewise for spreadsheets without cycles. Forth is much smaller than Java, but I would say that Forth is much, much more powerful in some sense than Java. You could write a Java compiler in Forth more easily than you could write a Forth compiler in Java. -- Steven From rosuav at gmail.com Sun Nov 27 19:26:17 2011 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 28 Nov 2011 11:26:17 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Nov 28, 2011 at 10:55 AM, Steven D'Aprano wrote: > What does it mean to say that a language is "small"? > > A Turing Machine is a pretty small language, with only a few > instructions: step forward, step backwards, erase a cell, write a cell, > branch on the state of the cell. And yet anything that can be computed, > anything at all, can be computed by a Turning Machine... Ook has only three tokens (okay, it's a derivative of BrainF** so it kinda has eight, but they're implemented on three). It's Turing-complete, but it is so small as to be useless for any practical purposes. The ONLY way to use Ook for any useful code would be to write an interpreter for another language in it, and use that other language. However, Ook can be proven to be flawless, as can an Ook interpreter, much more easily than a full-featured language like Python or C. ChrisA From gelonida at gmail.com Sun Nov 27 19:32:33 2011 From: gelonida at gmail.com (Gelonida N) Date: Mon, 28 Nov 2011 01:32:33 +0100 Subject: lxml precaching DTD for document verification. In-Reply-To: References: Message-ID: On 11/27/2011 10:33 PM, John Gordon wrote: > In Roy Smith writes: > >> In article , >> Gelonida N wrote: >> >>> I'd like to verify some (x)html / / html5 / xml documents from a server. > >> I'm sure you could roll your own validator with lxml and some DTDs, but >> you would probably save yourself a huge amount of effort by just using >> the validator the W3C provides (http://validator.w3.org/). This validator requires that I post the code to some host. The contents that I'd like to verify is intranet contents, which I am not allowed to post to an external site. > > With regards to XML, he may mean that he wants to validate that the > document conforms to a specific format, not just that it is generally > valid XML. I don't think the w3 validator will do that. > Basically I want to integrate this into a django unit test. I noticed, that some of of the templates generate documents with mismatching DTD headers / contents. All of the HTML code is parsable as xml (if it isn't it's a bug) There are also some custom XML files, which have their specific DTDs So I thought about validating some of the generated html with lxml. the django test environment allows to run test clients, which are supposedly much faster than a real http client. From devplayer at gmail.com Sun Nov 27 20:20:13 2011 From: devplayer at gmail.com (DevPlayer) Date: Sun, 27 Nov 2011 17:20:13 -0800 (PST) Subject: python shell that saves history of typed in commands that will persist between reboots References: <4737007e-029d-4ecb-9315-f3ceb4bb06ed@t16g2000vba.googlegroups.com> Message-ID: On Nov 15, 10:38?pm, goldtech wrote: > Hi, > > Using Windows. Is there a python shell that has a history of typed in > commands? > > I don't need output of commands just what I typed it. I need it to > save between sessions - something that no shell seems to do. If I > reboot there will still be a command history somewhere. > > Like bash history in Linux. > > Thanks Something that might be of interest is wxPython's pyslicesshell.py it's not commandline in console window but the interpreter in a window. And you can save it. I haven't used it lately by there's also PythonWin http://python.net/crew/skippy/win32/PythonwinPreview.html From tjreedy at udel.edu Sun Nov 27 21:09:47 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 27 Nov 2011 21:09:47 -0500 Subject: why is bytearray treated so inefficiently by pickle? In-Reply-To: <4ed24a33$0$6869$e4fe514c@news2.news.xs4all.nl> References: <4ed24a33$0$6869$e4fe514c@news2.news.xs4all.nl> Message-ID: On 11/27/2011 9:33 AM, Irmen de Jong wrote: > Hi, > > A bytearray is pickled (using max protocol) as follows: > >>>> pickletools.dis(pickle.dumps(bytearray([255]*10),2)) > 0: \x80 PROTO 2 > 2: c GLOBAL '__builtin__ bytearray' > 25: q BINPUT 0 > 27: X BINUNICODE u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' > 52: q BINPUT 1 > 54: U SHORT_BINSTRING 'latin-1' > 63: q BINPUT 2 > 65: \x86 TUPLE2 > 66: q BINPUT 3 > 68: R REDUCE > 69: q BINPUT 4 > 71: . STOP > >>>> bytearray("\xff"*10).__reduce__() > (, (u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff', 'latin-1'), None) > > > Is there a particular reason it is encoded so inefficiently? Most notably, the actual > *bytes* in the bytearray are represented by an UTF-8 string. This needs to be > transformed into a unicode string and then encoded back into bytes, when unpickled. The > thing being a bytearray, I would expect it to be pickled as such: a sequence of bytes. > And then possibly converted back to bytearray using the constructor that takes the bytes > directly (BINSTRING/BINBYTES pickle opcodes). > > The above occurs both on Python 2.x and 3.x. > > Any ideas? Candidate for a patch? Possibly. The two developers listed as particularly interested in pickle are 'alexandre.vassalotti,pitrou' (antoine), so if you do open a tracker issue, add them as nosy. Take a look at http://www.python.org/dev/peps/pep-3154/ by Antoine Pitrou or forwary your message to him. -- Terry Jan Reedy From fpm at u.washington.edu Sun Nov 27 23:16:43 2011 From: fpm at u.washington.edu (cassiope) Date: Sun, 27 Nov 2011 20:16:43 -0800 (PST) Subject: Proper way to delete/kill a logger? Message-ID: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> I've been trying to migrate some code to using the standard python logging classes/objects. And they seem quite capable of doing what I need them to do. Unfortunately there's a problem in my unit tests. It's fairly common to have to create quite a few entities in the course of a series of tests. What appears to be happening is that the loggers don't get entirely eliminated, so that new invocations end up spewing output messages from each of the loggers that were started with this invocation of the python interpreter. I haven't found a function within the logging module that completely kills a given instance. The removeHandler() function seems to leave a stdout/stderr output even if all the assigned handlers have been removed. I've tried a few workarounds, such as increasing the level to an absurdly large level, which mostly kinda works, and killing the old entity before creating the new test version. There is probably something simple that I'm missing. If you know what that is, please point me to that fine manual - I'd appreciate it. Thanks! -f From rustompmody at gmail.com Sun Nov 27 23:25:16 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 27 Nov 2011 20:25:16 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: Message-ID: <46c11371-411a-4ba0-89b9-967e2f83e942@k5g2000pre.googlegroups.com> On Nov 28, 2:46?am, Cameron Simpson wrote: > On 27Nov2011 23:54, Matt Joiner wrote: > | Agreed. I recently gave Haskell a go, and it was remarkable how > | similar the package management is to Python's. > | > | How well does the new "packaging" (set for release in Python 3.3?) > | module deal with the problems? > | > | With a better package management system, the half of the standard > | library that nobody uses can be unceremoniously dumped, and their more > | recent upstream versions used correctly. Even distutils itself is > | "obsolete", the first recommendation people give is to replace it with > | distribute and/or pip. > > Ah the cheery optimism of the end user. > Package systems have a lot of fun complications. > > Install for the user only? For the whole system? > Architecture specific? > What if people want access to different versions of a package? > What about vendor supplied (eg RPM) versus user obtained? They'll fight, > one way or another. What if policy has user supplied installing to its > own tree (sensible to avoid conflicts) - the fetch/install kit need to > know this. > What about stability? Your "half of the standard library that nobody uses can > be unceremoniously dumped, and their more recent upstream versions used > correctly" leads to bugs in the apps that use the packages if they depend on > particular versions/APIs. The stdlib is generally quite careful about > breaking APIs but other packagers often are less so. > > I can make this list bigger or more detailed if you want. ?All package > systems have these issues. They're not as trivial as you might imagine. Where is there any implication that there are not issues or that they are trivial? At the end of his life Dijkstra said: The single biggest problem in computer science is how not to make a mess of it; that problem remains unsolved. The OP simply expressed a wish for improvement and I seconded that [and pls ignore ranters with oedipal problems] >From my post from a few months http://mail.python.org/pipermail/python-list/2011-May/1271765.html If I may restate: Too much mindshare is devoted to all the linguistic features of python: garbage collection, identation, metaclasses and all that other good stuff from the 70s and too little to extra-linguistic ecosystem features below: If the linguistic features were all that mattered Lisp would be the king of languages today > > > | Area | Tool(s) | > > |------------------+------------------------| > > | packaging | distutils, setuptools, | > > | | distutils2, distribute | > > | | Native tools (eg apt) | > > | versioning | hg, git, bzr | > > | multiple pythons | virtualenv | > > | ?? | tox | > > | testing | unittest, nose, pytest | > > | build | scons, make... | > > | deployment | fabric | > From roy at panix.com Sun Nov 27 23:31:42 2011 From: roy at panix.com (Roy Smith) Date: Sun, 27 Nov 2011 23:31:42 -0500 Subject: sick of distribute, setup, and all the rest... References: <46c11371-411a-4ba0-89b9-967e2f83e942@k5g2000pre.googlegroups.com> Message-ID: In article <46c11371-411a-4ba0-89b9-967e2f83e942 at k5g2000pre.googlegroups.com>, rusi wrote: > If the linguistic features were all that mattered Lisp would be the > king of languages today (that (is (one (of (the (most (absurd (statements (I've (read (in (a (long (time)))))))))))))) From Shambhu.Rajak at kpitcummins.com Sun Nov 27 23:31:59 2011 From: Shambhu.Rajak at kpitcummins.com (Shambhu Rajak) Date: Mon, 28 Nov 2011 04:31:59 +0000 Subject: Automatic import of submodules In-Reply-To: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> References: <459a7690-ca58-4fad-80f4-349ca4ac4fe3@t16g2000vba.googlegroups.com> Message-ID: <408F64D89899604FB24015E64E10490C179CA4BA@KCHJEXMB02.kpit.com> -----Original Message----- From: Massi [mailto:massi_srb at msn.com] Sent: 25/11/2011 6:30 PM To: python-list at python.org Subject: Automatic import of submodules Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | -- __init__.py -- EtcPlug.py Every .py file contain a class definition whose name is identical to to the file name, so in my main script I have to import each submodule like that: from plugins.wav_plug.WavPlug import WavPlug from plugins.wav_plug.Mp3Plug import Mp3Plug and so on. This is uncomfortable, since when a new plugin is added I have to import it too. So my question is, is it possible to iterate through the 'plugins' directory tree in order to automatically import the submodules contained in each subdirectory? I googled and found that the pkgutil could help, but it is not clear how. Any hints? Thanks in advance. ===== What you could do is : Instead of importing method wise , import the module. from plugins.wav_plug import WavPlug you can then use like this then WavPlug.WavPlug This will avoid the-every time importing of each method Regards, Shambhu From wuwei23 at gmail.com Sun Nov 27 23:37:41 2011 From: wuwei23 at gmail.com (alex23) Date: Sun, 27 Nov 2011 20:37:41 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> Message-ID: <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> rusi wrote: > While Ive never seen anything as ridiculous as the debian-rails in the > python world, its still always a hobson choice: ?use a deb package > that will cleanly install, deinstall, upgrade etc but is out of date > or use a fresh and shiny egg that messes up the system. The only time I use the OS package manager to install a Python library is if some other application requires it as a dependency. If you're not making the distinction between your system install of Python and your development install, you're really inviting a whole world of pain and confusion on yourself. With that approach in mind, I've never had any real issues using pip, virtualenv etc for managing my development environment. From chris at simplistix.co.uk Mon Nov 28 02:13:15 2011 From: chris at simplistix.co.uk (Chris Withers) Date: Mon, 28 Nov 2011 07:13:15 +0000 Subject: Proper way to delete/kill a logger? In-Reply-To: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> References: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> Message-ID: <4ED3348B.4020301@simplistix.co.uk> On 28/11/2011 04:16, cassiope wrote: > I've been trying to migrate some code to using the standard python > logging classes/objects. And they seem quite capable of doing what I > need them to do. Unfortunately there's a problem in my unit tests. > It's fairly common to have to create quite a few entities in the > course of a series of tests. What appears to be happening is that the > loggers don't get entirely eliminated, so that new invocations end up > spewing output messages from each of the loggers that were started > with this invocation of the python interpreter. Two suggestions: - unless you are specifically testing the logging set up of your application, your code under test shouldn't be setting up logging. - if you want to check that your code under test is emitting log messages correctly, use a LogCapture from testfixtures: http://packages.python.org/testfixtures. cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From rustompmody at gmail.com Mon Nov 28 02:18:15 2011 From: rustompmody at gmail.com (rusi) Date: Sun, 27 Nov 2011 23:18:15 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> Message-ID: <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> On Nov 28, 9:37?am, alex23 wrote: > With that approach in mind, I've never had any real issues using pip, > virtualenv etc for managing my development environment. Yes that is in a way my point also: we discuss (things like) pip, virtualenv etc too little. Try working out the ratio of the number of helps/tutorials on functions/lists/types/classes to those on these extra-linguistic features needed for environment/build/deployment/versioning and you can see the skewness of focus From stefan_ml at behnel.de Mon Nov 28 02:38:12 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 28 Nov 2011 07:38:12 +0000 Subject: lxml precaching DTD for document verification. In-Reply-To: References: Message-ID: Gelonida N, 27.11.2011 18:57: > I'd like to verify some (x)html / / html5 / xml documents from a server. > > These documents have a very limited number of different doc types / DTDs. > > So what I would like to do is to build a small DTD cache and some code, > that would avoid searching the DTDs over and over from the net. > > What would be the best way to do this? Configure your XML catalogues. > I guess, that > the fields od en ElementTre, that I have to look at are > docinfo.public_id > docinfo.system_uri Yes, catalogue lookups generally happen through the public ID. > There's also mentioning af a catalogue, but I don't know how to > use a catalog and how to know what is inside my catalogue > and what isn't. Does this help? http://lxml.de/resolvers.html#xml-catalogs http://xmlsoft.org/catalog.html They should normally come pre-configured on Linux distributions, but you may have to install additional packages with the respective DTDs. Look for any packages with "dtd" and "html" in their name, for example. Stefan From dihedral88888 at googlemail.com Mon Nov 28 03:51:06 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 28 Nov 2011 00:51:06 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> Message-ID: <18928439.420.1322470266331.JavaMail.geo-discussion-forums@prnv8> On Sunday, November 27, 2011 4:49:14 PM UTC+8, 88888 Dihedral wrote: > On Sunday, November 27, 2011 4:29:52 PM UTC+8, 88888 Dihedral wrote: > > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > > Sounds like you want a key-value store. If it's a lot of data, you may > > > still want a "database", I think it's just relational databases that > > > you're trying to avoid? > > > > > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > > > wrote: > > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > > >> On Nov 14, 3:41?pm, Tracubik wrote: > > > >> > Hi all, > > > >> > i'm developing a new program. > > > >> > Mission: learn a bit of database management > > > >> > Idea: create a simple, 1 window program that show me a db of movies i've > > > >> > seen with few (<10) fields (actors, name, year etc) > > > >> > technologies i'll use: python + gtk > > > >> > db: that's the question > > > >> > > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > > >> > sqlite at the beginning. > > > >> > > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > > >> > they are too complex and i'll use this in a second step) > > > >> > > > > >> > is there any general tutorial of how to start developing a database? i > > > >> > mean a general guide to databases you can suggest to me? > > > >> > Thank you all > > > >> > > > > >> > MedeoTL > > > >> > > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > > >> > easily convert it in a sqlite db? (maybe via csv) > > > >> > > > >> To learn DBMS you need to learn sql > > > >> [Note sql is necessary but not sufficient for learning DBMS] > > > >> I recommend lightweight approaches to start with -- others have > > > >> mentioned access, libreoffice-base. > > > >> One more lightweight playpen is firefox plugin sqlite-manager > > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > > >> > they are too complex and i'll use this in a second step) > > > >> > > > >> Correct. First you must figure out how to structure data -- jargon is > > > >> normalization. > > > >> After that you can look at transactions, ACID, distribution and all > > > >> the other good stuff. > > > > > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. > > > > Each entry is just a type and value stored in a row of my database. > > I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. > > > > Can I do this in 1024 hashes in python ? > Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) > Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. For the same value stored , I need a column_no+next stored, a list. All relations can be derived. From dihedral88888 at googlemail.com Mon Nov 28 03:51:06 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 28 Nov 2011 00:51:06 -0800 (PST) Subject: my new project, is this the right way? In-Reply-To: <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> References: <4ec0f070$0$1378$4fafbaef@reader2.news.tin.it> <581dab49-e6b0-4fea-915c-4a41fa887c3b@p7g2000pre.googlegroups.com> <11840843.114.1322350898307.JavaMail.geo-discussion-forums@prfi36> <24389083.226.1322382592895.JavaMail.geo-discussion-forums@prij11> <15951139.49.1322383754305.JavaMail.geo-discussion-forums@prnv8> Message-ID: <18928439.420.1322470266331.JavaMail.geo-discussion-forums@prnv8> On Sunday, November 27, 2011 4:49:14 PM UTC+8, 88888 Dihedral wrote: > On Sunday, November 27, 2011 4:29:52 PM UTC+8, 88888 Dihedral wrote: > > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > > Sounds like you want a key-value store. If it's a lot of data, you may > > > still want a "database", I think it's just relational databases that > > > you're trying to avoid? > > > > > > On Sun, Nov 27, 2011 at 10:41 AM, 88888 Dihedral > > > wrote: > > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > > >> On Nov 14, 3:41?pm, Tracubik wrote: > > > >> > Hi all, > > > >> > i'm developing a new program. > > > >> > Mission: learn a bit of database management > > > >> > Idea: create a simple, 1 window program that show me a db of movies i've > > > >> > seen with few (<10) fields (actors, name, year etc) > > > >> > technologies i'll use: python + gtk > > > >> > db: that's the question > > > >> > > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > > >> > sqlite at the beginning. > > > >> > > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > > >> > they are too complex and i'll use this in a second step) > > > >> > > > > >> > is there any general tutorial of how to start developing a database? i > > > >> > mean a general guide to databases you can suggest to me? > > > >> > Thank you all > > > >> > > > > >> > MedeoTL > > > >> > > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > > > >> > easily convert it in a sqlite db? (maybe via csv) > > > >> > > > >> To learn DBMS you need to learn sql > > > >> [Note sql is necessary but not sufficient for learning DBMS] > > > >> I recommend lightweight approaches to start with -- others have > > > >> mentioned access, libreoffice-base. > > > >> One more lightweight playpen is firefox plugin sqlite-manager > > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > > > >> > they are too complex and i'll use this in a second step) > > > >> > > > >> Correct. First you must figure out how to structure data -- jargon is > > > >> normalization. > > > >> After that you can look at transactions, ACID, distribution and all > > > >> the other good stuff. > > > > > > > > If I have a fast hash library ?that each hash function supports insertion and deletion and can be frozen to be stored into the file system if desired and retrieved lator . Can I use several hashes to replace a database that is slow and expensive? > > > > > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. > > > > Each entry is just a type and value stored in a row of my database. > > I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. > > > > Can I do this in 1024 hashes in python ? > Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) > Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. For the same value stored , I need a column_no+next stored, a list. All relations can be derived. From ramapraba2653 at gmail.com Mon Nov 28 05:05:01 2011 From: ramapraba2653 at gmail.com (SUPREME) Date: Mon, 28 Nov 2011 02:05:01 -0800 (PST) Subject: XXX HOT PHOTOS&VIDEOS Message-ID: FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ URIMI LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/urimi-movie-stills.html NIPPU MOVIE WORKING STILLS http://actressgallery-kalyani.blogspot.com/2011/11/nippu-movie-stills.html SIMHAPUTHRUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/simhaputhrudu-movie-stills.html SOLO MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/solo-movie-stills.html BEZAWADA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/bezawada-movie-stills.html RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS SARAH JANE DIAS HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/sarah-jane-dias-hot.html KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html POONAM KAUR HOT ROMANTIC STILLS http://hotactress-kalyani.blogspot.com/2011/11/poonam-kaur-hot.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From gelonida at gmail.com Mon Nov 28 05:15:58 2011 From: gelonida at gmail.com (Gelonida N) Date: Mon, 28 Nov 2011 11:15:58 +0100 Subject: lxml precaching DTD for document verification. In-Reply-To: References: Message-ID: Thanks Stefan, On 11/28/2011 08:38 AM, Stefan Behnel wrote: > Gelonida N, 27.11.2011 18:57: >> I'd like to verify some (x)html / / html5 / xml documents from a server. >> >> These documents have a very limited number of different doc types / DTDs. >> >> So what I would like to do is to build a small DTD cache and some code, >> that would avoid searching the DTDs over and over from the net. >> >> What would be the best way to do this? > > Configure your XML catalogues. . . . > > Yes, catalogue lookups generally happen through the public ID. > > . . . > Does this help? > > http://lxml.de/resolvers.html#xml-catalogs > > http://xmlsoft.org/catalog.html These links look perfect. > > They should normally come pre-configured on Linux distributions, but you > may have to install additional packages with the respective DTDs. Look > for any packages with "dtd" and "html" in their name, for example. > Thanks once more. Indeed the package w3c-dtd-xhtml wasn't installed on my Ubuntu host. I'll check this lateron today. (Just have to remove my own hackish cashing solution, which downloads if not found in a cash dir) From steve+comp.lang.python at pearwood.info Mon Nov 28 06:42:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 11:42:30 GMT Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> Message-ID: <4ed373a5$0$29988$c3e8da3$5496439d@news.astraweb.com> On Sun, 27 Nov 2011 23:18:15 -0800, rusi wrote: > On Nov 28, 9:37?am, alex23 wrote: > >> With that approach in mind, I've never had any real issues using pip, >> virtualenv etc for managing my development environment. > > Yes that is in a way my point also: we discuss (things like) pip, > virtualenv etc too little. I don't know about that. I think we discuss things like pip, etc. exactly the right amount. > Try working out the ratio of the number of helps/tutorials on > functions/lists/types/classes to those on these extra-linguistic > features needed for environment/build/deployment/versioning and you can > see the skewness of focus We don't chase people down on the street and lecture them about the problems we think they are having, we answer questions about ACTUAL problems that they have experienced and asking about. If there are 10 or 100 times more answers about (say) classes than about (say) pip, that is because there are 10 or 100 times as many questions about classes. Maybe that's because pip users are cleverer, more experienced and don't have problems; maybe it's because only 1 in 100 people go on to use pip. Maybe it's because pip is a heap of trash that nobody touches; or perhaps it is so fantastic that nobody has any problems with it. Whatever the reason, there's no great big queue of unanswered questions about pip that I can see. Hence, ever question gets an answer, and we're discussing things about as much as we ought to. (I don't mean to single out pip, it is just an example.) -- Steven From andrea.crotti.0 at gmail.com Mon Nov 28 06:45:57 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 28 Nov 2011 11:45:57 +0000 Subject: python 2.5 and ast Message-ID: <4ED37475.3050709@gmail.com> I'm happily using the ast module to analyze some code, but my scripts need also to run unfortunately on python 2.5 The _ast was there already, but the ast helpers not yet. Is it ok if I just copy over the source from the ast helpers in my code base or is there a smarter way? (I don't even need all of them, just "parse" and NodeVisitor at the moment) From jayronsoares at gmail.com Mon Nov 28 06:54:18 2011 From: jayronsoares at gmail.com (Jayron Soares) Date: Mon, 28 Nov 2011 09:54:18 -0200 Subject: Cursor.fetchall Message-ID: Hi guys! I'm stuck at a problem, when I run the follow code: http://pastebin.com/4Gd9V325 I get this error: Traceback (most recent call last): File "/home/jayron/Downloads/grafos.py", line 49, in g, e = ministro_lei() File "/home/jayron/Downloads/grafos.py", line 24, in ministro_lei resp = Q.fetchall() AttributeError: 'long' object has no attribute 'fetchall' Please any help ? cheers -- *" A Vida ? arte do Saber...Quem quiser saber tem que Estudar!"* http://bucolick.tumblr.com http://artecultural.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.vinturini at gmail.com Mon Nov 28 07:06:30 2011 From: felipe.vinturini at gmail.com (Felipe Vinturini) Date: Mon, 28 Nov 2011 10:06:30 -0200 Subject: Cursor.fetchall In-Reply-To: References: Message-ID: Hi Jayron, Instead of using "Q" to loop over the result, use: "dbcursor". resp = dbcursor.fetchall() I hope it helps. Regards, Felipe. On Mon, Nov 28, 2011 at 9:54 AM, Jayron Soares wrote: > Hi guys! > > I'm stuck at a problem, when I run the follow code: > > http://pastebin.com/4Gd9V325 > > I get this error: > > Traceback (most recent call last): > File "/home/jayron/Downloads/grafos.py", line 49, in > g, e = ministro_lei() > File "/home/jayron/Downloads/grafos.py", line 24, in ministro_lei > resp = Q.fetchall() > AttributeError: 'long' object has no attribute 'fetchall' > > Please any help ? > > cheers > > > -- > *" A Vida ? arte do Saber...Quem quiser saber tem que Estudar!"* > > http://bucolick.tumblr.com > http://artecultural.wordpress.com/ > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Mon Nov 28 07:11:15 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 12:11:15 GMT Subject: suppressing bad characters in output PCDATA (converting JSON to XML) References: <91j4q8xgv9.ln2@news.ducksburg.com> Message-ID: <4ed37a63$0$29988$c3e8da3$5496439d@news.astraweb.com> On Fri, 25 Nov 2011 13:50:01 +0000, Adam Funk wrote: > I'm converting JSON data to XML using the standard library's json and > xml.dom.minidom modules. I get the input this way: > > input_source = codecs.open(input_file, 'rb', encoding='UTF-8', > errors='replace') big_json = json.load(input_source) > input_source.close() > > Then I recurse through the contents of big_json to build an instance of > xml.dom.minidom.Document (the recursion includes some code to rewrite > dict keys as valid element names if necessary), How are you doing that? What do you consider valid? > and I save the document: > > xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', > errors='replace') doc.writexml(xml_file, encoding='UTF-8') > xml_file.close() > > > I thought this would force all the output to be valid, but xmlstarlet > gives some errors like these on a few documents: It will force the output to be valid UTF-8 encoded to bytes, not necessarily valid XML. > PCDATA invalid Char value 7 > PCDATA invalid Char value 31 What's xmlstarlet, and at what point does it give this error? It doesn't appear to be in the standard library. > I guess I need to process each piece of PCDATA to clean out the control > characters before creating the text node: > > text = doc.createTextNode(j) > root.appendChild(text) > > What's the best way to do that, bearing in mind that there can be > multibyte characters in the strings? Are you mixing unicode and byte strings? Are you sure that the input source is actually UTF-8? If not, then all bets are off: even if the decoding step works, and returns a string, it may contain the wrong characters. This might explain why you are getting unexpected control characters in the output: they've come from a badly decoded input. Another possibility is that your data actually does contain control characters where there shouldn't be any. -- Steven From python.list at tim.thechases.com Mon Nov 28 07:12:06 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 28 Nov 2011 06:12:06 -0600 Subject: cmd.Cmd asking questions? Message-ID: <4ED37A96.2090905@tim.thechases.com> Are there best-practices for creating wizards or asking various questions (whether yes/no or text/numeric entry) in a cmd.Cmd class? Something like the imaginary confirm() and get_string() methods here: class MyCmd(cmd.Cmd): def do_name(self,line): s = get_string(prompt=line, default="Whatever") ... def do_save(self,line): if os.path.isfile(line): if not confirm("%r exists. Continue?", True): return self.save(line) def save(self, filename): ... I can monkey with printing messages and using raw_input(), but I'd like to know if there's a better way (such as something interacting with readline for text-entry-with-history-and-completion, or raw-character input for Y/N answers rather than the need to hit , making it feel more uniform), Thanks, -tkc From robert.kern at gmail.com Mon Nov 28 07:27:50 2011 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 28 Nov 2011 12:27:50 +0000 Subject: cmd.Cmd asking questions? In-Reply-To: <4ED37A96.2090905@tim.thechases.com> References: <4ED37A96.2090905@tim.thechases.com> Message-ID: On 11/28/11 12:12 PM, Tim Chase wrote: > Are there best-practices for creating wizards or asking various questions > (whether yes/no or text/numeric entry) in a cmd.Cmd class? Something like the > imaginary confirm() and get_string() methods here: > > class MyCmd(cmd.Cmd): > def do_name(self,line): > s = get_string(prompt=line, default="Whatever") > ... > def do_save(self,line): > if os.path.isfile(line): > if not confirm("%r exists. Continue?", True): return > self.save(line) > def save(self, filename): > ... > > I can monkey with printing messages and using raw_input(), but I'd like to know > if there's a better way (such as something interacting with readline for > text-entry-with-history-and-completion, If you import readline, then any following uses of raw_input() will automatically use readline. You may want to swap out the history when you use get_string() or confirm() so they don't mess up the regular Cmd history, but the basic functionality should work out-of-box. > or raw-character input for Y/N answers > rather than the need to hit , making it feel more uniform), I actually have a preference for needing to press enter for Y/N answers, too. It's distinctly *less* uniform to have some questions requiring an enter and some not. It can be unpleasantly surprising to the user, too. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From jayronsoares at gmail.com Mon Nov 28 07:45:53 2011 From: jayronsoares at gmail.com (Jayron Soares) Date: Mon, 28 Nov 2011 10:45:53 -0200 Subject: Cursor.fetchall In-Reply-To: References: Message-ID: Hi Felipe, I did, however I got this error: Traceback (most recent call last): File "/home/jayron/Downloads/grafos.py", line 48, in g, e = ministro_lei() File "/home/jayron/Downloads/grafos.py", line 34, in ministro_lei for i in G.degree(): TypeError: 'int' object is not iterable I could not understood what's going on, I've tried so many different approaches to solve this problem, but unfortunately no success. Cheers 2011/11/28 Felipe Vinturini > Hi Jayron, > > Instead of using "Q" to loop over the result, use: "dbcursor". > > resp = dbcursor.fetchall() > > I hope it helps. > > Regards, > Felipe. > > On Mon, Nov 28, 2011 at 9:54 AM, Jayron Soares wrote: > >> Hi guys! >> >> I'm stuck at a problem, when I run the follow code: >> >> http://pastebin.com/4Gd9V325 >> >> I get this error: >> >> Traceback (most recent call last): >> File "/home/jayron/Downloads/grafos.py", line 49, in >> g, e = ministro_lei() >> File "/home/jayron/Downloads/grafos.py", line 24, in ministro_lei >> resp = Q.fetchall() >> AttributeError: 'long' object has no attribute 'fetchall' >> >> Please any help ? >> >> cheers >> >> >> -- >> *" A Vida ? arte do Saber...Quem quiser saber tem que Estudar!"* >> >> http://bucolick.tumblr.com >> http://artecultural.wordpress.com/ >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> >> > -- *" A Vida ? arte do Saber...Quem quiser saber tem que Estudar!"* http://bucolick.tumblr.com http://artecultural.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanmichel at sequans.com Mon Nov 28 07:57:16 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 28 Nov 2011 13:57:16 +0100 Subject: Pragmatics of the standard is() function In-Reply-To: <4ed15825$0$21841$426a34cc@news.free.fr> References: <4ed15825$0$21841$426a34cc@news.free.fr> Message-ID: <4ED3852C.6090102@sequans.com> candide wrote: > In which cases should we use the is() function ? The is() function > compares identity of objects rather than values so I was wondering in > which circumstances comparing identities of objects is really vital. > > Examining well reputated Python source code, I realize that is() > function is mainly used in the following set form : > > spam is None > > But how much "spam is None" is different from "spam == None" ? > > > > is() function makes comparaison of (abstract representation of) > adresses of objects in memory. Comparing addresses of objects is a low > level feature performed by low level langages such as C but seldom > needed in high level languages like Python, isn'it ? I remember meeting a use case where testing identity is required, when you are searching for an instance containing a specific object: class Someone: def __init__(self, name, car): self.name = name self.car = car class Car: def __init__(self, brand): self.brand = brand def __eq__(self, other): return self.brand == other.brand people = { 'bob':Someone('bob', Car('chrys')), 'cindy': Someone('cindy', Car('Volk')), 'carlos':Someone('carlos', Car('Volk'))} aCar = people['carlos'].car print "people owning a Volk car", [ people[ppl].name for ppl in people if people[ppl].car == Car('Volk')] print "people owning Carlos's car", [ people[ppl].name for ppl in people if people[ppl].car is aCar] people owning a Volk car ['carlos', 'cindy'] people owning Carlos's car ['carlos'] JM From rustompmody at gmail.com Mon Nov 28 08:14:27 2011 From: rustompmody at gmail.com (rusi) Date: Mon, 28 Nov 2011 05:14:27 -0800 (PST) Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> <4ed373a5$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 28, 4:42 pm, Steven D'Aprano wrote: > We don't chase people down on the street and lecture them about the > problems we think they are having, we answer questions about ACTUAL > problems that they have experienced and asking about. > ... ever question gets an answer, and we're discussing > things about as much as we ought to. How about applying these claims to the OP? From jeanmichel at sequans.com Mon Nov 28 08:20:44 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 28 Nov 2011 14:20:44 +0100 Subject: Cursor.fetchall In-Reply-To: References: Message-ID: <4ED38AAC.3090103@sequans.com> Jayron Soares wrote: > Hi Felipe, > > I did, however I got this error: > > Traceback (most recent call last): > File "/home/jayron/Downloads/grafos.py", line 48, in > g, e = ministro_lei() > File "/home/jayron/Downloads/grafos.py", line 34, in ministro_lei > for i in G.degree(): > TypeError: 'int' object is not iterable > > I could not understood what's going on, I've tried so many different > approaches to solve this problem, but unfortunately no success. > > Cheers > > > > 2011/11/28 Felipe Vinturini > > > Hi Jayron, > > Instead of using "Q" to loop over the result, use: "dbcursor". > > resp = dbcursor.fetchall() > > I hope it helps. > > Regards, > Felipe. > > On Mon, Nov 28, 2011 at 9:54 AM, Jayron Soares > > wrote: > > Hi guys! > > I'm stuck at a problem, when I run the follow code: > > http://pastebin.com/4Gd9V325 > > I get this error: > > Traceback (most recent call last): > File "/home/jayron/Downloads/grafos.py", line 49, in > g, e = ministro_lei() > File "/home/jayron/Downloads/grafos.py", line 24, in > ministro_lei > resp = Q.fetchall() > AttributeError: 'long' object has no attribute 'fetchall' > > Please any help ? > > cheers > Hello, You are iterating on G.degree(), which is fine when it is a dictionary. However regarding DiGraph documentation: "Returns : nd : dictionary, or number A dictionary with nodes as keys and degree as values or a number if a single node is specified." So you may get an integer and thus cannot iterate on it. You could use if type(G.degree()) is int: lista.append(G.degree()) else: for i in G.degree().values(): lista.append(i) I'm quite surprised that a distributed graph API uses such inconsistent interface. I guess you'll have to live with it. JM PS : Try to code & document in English, it's much better especially when asking for help on this list, mixing spanish and english has few benefits since you may bother both spanish and english ppl :o) From jeanmichel at sequans.com Mon Nov 28 08:47:51 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 28 Nov 2011 14:47:51 +0100 Subject: Proper way to delete/kill a logger? In-Reply-To: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> References: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> Message-ID: <4ED39107.20109@sequans.com> cassiope wrote: > I've been trying to migrate some code to using the standard python > logging classes/objects. And they seem quite capable of doing what I > need them to do. Unfortunately there's a problem in my unit tests. > It's fairly common to have to create quite a few entities in the > course of a series of tests. What appears to be happening is that the > loggers don't get entirely eliminated, so that new invocations end up > spewing output messages from each of the loggers that were started > with this invocation of the python interpreter. > > I haven't found a function within the logging module that completely > kills a given instance. The removeHandler() function seems to leave a > stdout/stderr output even if all the assigned handlers have been > removed. I've tried a few workarounds, such as increasing the level > to an absurdly large level, which mostly kinda works, and killing the > old entity before creating the new test version. > > There is probably something simple that I'm missing. If you know what > that is, please point me to that fine manual - I'd appreciate it. > Thanks! > > -f > Loggers are static objects managed by the module itself. When you create one, it won't be removed until you leave the shell. Thas is way it is advise not to create thousands of loggers with different names. That's the module design, nothing you can do about it. It takes a little time to get used to it but the logging documentation has a lot of examples showing how to use to module. Your main problem is that some of your test instances are configuring the loggers, they should not. Configuration should be done in the 'main' function *only*. import logging, sys class Test1: def __init__(self): self.logger = logging.getLogger(self.__class__.__name__) # create a new logger or reuse one if a logger with that name already exists self.logger.info('I am created') # adding a handler to the logger here would be a mistake, configuration is let to the user, in this case the program main entry point # objects raising log events should not care about how they are formated/displayed class Test2: def __init__(self): self.logger = logging.getLogger(self.__class__.__name__) self.logger.info('I am created') def main(): # configure here the logger, usually the root logger root = logging.getLogger() root.handlers = [] # required if you don't want to exit the shell between 2 executions (not very wise) root.setLevel(logging.DEBUG) root.addHandler(logging.StreamHandler(sys.stdout)) root.handlers[-1].setFormatter(logging.Formatter('%(name)s - %(levelname)s - %(message)s')) t1 = Test1() t2 = Test2() t3 = Test2() if __name__ == '__main__': main() > run test.py Test1 - INFO - I am created Test2 - INFO - I am created Test2 - INFO - I am created JM PS : one way to cleanup a logger is to remove all its handlers, i.e. logger.handlers = [], but if you need to do this you may have done something wrong. From steve+comp.lang.python at pearwood.info Mon Nov 28 09:04:26 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 14:04:26 GMT Subject: sick of distribute, setup, and all the rest... References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> <4ed373a5$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed394e9$0$29988$c3e8da3$5496439d@news.astraweb.com> On Mon, 28 Nov 2011 05:14:27 -0800, rusi wrote: > On Nov 28, 4:42 pm, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> We don't chase people down on the street and lecture them about the >> problems we think they are having, we answer questions about ACTUAL >> problems that they have experienced and asking about. > >> ... ever question gets an answer, and we're discussing things about as >> much as we ought to. > > How about applying these claims to the OP? The OP ranted that the existing packaging systems are an "all-out disgrace" (his words), without giving even a single example of a concrete problem, and unilaterally declared that this needs the personal attention of Guido van Rossum. There's a word for posts like that one: starts with T, ends in ROLL. Presumably the OP believes that not only should he not have to solve his own problems with existing packaging systems, but he should not have to even describe those supposed problems. The OP's only question was "when is python going to get a decent module distribution system???", to which the right answer is presumably "about a decade ago". Decent does not necessarily mean perfect. If the OP decides to ask a sensible question about an actual problem, I'm sure he'll get a sensible answer. Perhaps not the answer he is hoping for, but an an answer. -- Steven From jeanmichel at sequans.com Mon Nov 28 09:18:54 2011 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 28 Nov 2011 15:18:54 +0100 Subject: Cursor.fetchall In-Reply-To: <4ED38AAC.3090103@sequans.com> References: <4ED38AAC.3090103@sequans.com> Message-ID: <4ED3984E.700@sequans.com> Jean-Michel Pichavant wrote: > > PS : Try to code & document in English, it's much better especially > when asking for help on this list, mixing spanish and english has few > benefits since you may bother both spanish and english ppl :o) Actually it is english mixed with portuguese, sorry if I offended anyone :o( . JM From andreas.perstinger at gmx.net Mon Nov 28 09:23:23 2011 From: andreas.perstinger at gmx.net (Andreas Perstinger) Date: Mon, 28 Nov 2011 15:23:23 +0100 Subject: sick of distribute, setup, and all the rest... In-Reply-To: References: <3dcbbd82-0f95-4e00-94ee-26d6d5dd1812@c16g2000pre.googlegroups.com> <76f81679-4806-47dd-827e-7ff60a4e3ae9@d37g2000prg.googlegroups.com> <5d3b3106-dc27-4aab-9e62-8290aac0e885@20g2000prp.googlegroups.com> <4ed373a5$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ED3995B.9040308@gmx.net> On 2011-11-28 14:14, rusi wrote: > On Nov 28, 4:42 pm, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> We don't chase people down on the street and lecture them about the >> problems we think they are having, we answer questions about ACTUAL >> problems that they have experienced and asking about. > >> ... ever question gets an answer, and we're discussing >> things about as much as we ought to. > > How about applying these claims to the OP? > OP asked only one question (the rest was just ranting) and Steven answered it (IMHO in the right manner). OP never mentioned specific problems or what's wrong with any of the distribution systems. So what answers are you expecting from such a post? Bye, Andreas From roy at panix.com Mon Nov 28 09:56:53 2011 From: roy at panix.com (Roy Smith) Date: Mon, 28 Nov 2011 09:56:53 -0500 Subject: Proper way to delete/kill a logger? References: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> Message-ID: In article , Jean-Michel Pichavant wrote: > Loggers are static objects managed by the module itself. For reasons I can't quite explain, that sentence makes me want to sing The Lumberjack Song. "I'm a logger(*) and I'm OK..." (*) Yes, I know that's not right. From jtim.arnold at gmail.com Mon Nov 28 10:36:17 2011 From: jtim.arnold at gmail.com (Tim) Date: Mon, 28 Nov 2011 07:36:17 -0800 (PST) Subject: correct usage of a generator? Message-ID: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Hi, I need to generate a list of file names that increment, like this: fname1 fname2 fname3 and so on. I don't know how many I'll need until runtime so I figure a generator is called for. def fname_gen(stem): i = 0 while True: i = i+1 yield '%s%d' % (stem,i) blarg = fname_gen('blarg') boo = fname_gen('boo') n = 3 for w in range(0,n): in_name = blarg.next() out_name = boo.next() This works, but is it the 'normal' way to accomplish the task when you don't know 'n' until run-time? thanks, --Tim From fpm at u.washington.edu Mon Nov 28 11:27:07 2011 From: fpm at u.washington.edu (cassiope) Date: Mon, 28 Nov 2011 08:27:07 -0800 (PST) Subject: Proper way to delete/kill a logger? References: <3e7e156f-8197-4a2e-a490-b418b2e99a30@w7g2000yqc.googlegroups.com> Message-ID: <11b21871-0bf2-4957-a0a3-65d3c039632d@u1g2000prl.googlegroups.com> Thanks Chris and JM, I will explore how much work it's going to take to change the various scripts to _always_ starting the logger from main(). As further explanation - this code predates the logging module, and many of the functions/classes had an optional argument for the home- made logger - and where the caller didn't provide it, it was locally created. The unit tests were carefully enough put together to provide almost complete coverage, resulting in creating the logger possibly a dozen or more times in the course of the tests. So I appreciate what "doing it the right way" means, I was just hoping not to have to go there, as I have a lot of code that uses the old structures. It makes it harder to justify moving to the "newer" module. I'll have to try the logger.handlers=[] approach, thanks. From steve+comp.lang.python at pearwood.info Mon Nov 28 11:44:40 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 16:44:40 GMT Subject: correct usage of a generator? References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Message-ID: <4ed3ba77$0$29988$c3e8da3$5496439d@news.astraweb.com> On Mon, 28 Nov 2011 07:36:17 -0800, Tim wrote: > Hi, I need to generate a list of file names that increment, like this: > fname1 > fname2 > fname3 and so on. > > I don't know how many I'll need until runtime so I figure a generator is > called for. > > def fname_gen(stem): > i = 0 > while True: > i = i+1 > yield '%s%d' % (stem,i) > > blarg = fname_gen('blarg') > boo = fname_gen('boo') > > n = 3 > for w in range(0,n): > in_name = blarg.next() > out_name = boo.next() > > > This works, but is it the 'normal' way to accomplish the task when you > don't know 'n' until run-time? thanks, Looks perfectly fine to me. In Python 2.6 onwards, I'd write next(blarg) rather than blarg.next(), and similarly for boo. In Python 3.x, you have to use next(blarg). If I were to nit-pick, I'd write the last part as: for _ in range(3): in_name = blarg.next() out_name = boo.next() where _ is the traditional "don't care" name in Python. -- Steven From __peter__ at web.de Mon Nov 28 11:54:48 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 28 Nov 2011 17:54:48 +0100 Subject: correct usage of a generator? References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Message-ID: Tim wrote: > Hi, I need to generate a list of file names that increment, like this: > fname1 > fname2 > fname3 and so on. > > I don't know how many I'll need until runtime so I figure a generator is > called for. > > def fname_gen(stem): > i = 0 > while True: > i = i+1 > yield '%s%d' % (stem,i) > > blarg = fname_gen('blarg') > boo = fname_gen('boo') > > n = 3 > for w in range(0,n): > in_name = blarg.next() > out_name = boo.next() > > > This works, but is it the 'normal' way to accomplish the task when you > don't know 'n' until run-time? thanks, As a fan of the itertools module I would spell it (untested) from itertools import count, islice, izip def fname_gen(stem): return ("%s%d" % (stem, i) for i in count(1)) # ... for in_name, out_name in islice(izip(blarg, boo), n): #... but your way is perfectly OK. From neilc at norwich.edu Mon Nov 28 12:04:25 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 28 Nov 2011 17:04:25 GMT Subject: correct usage of a generator? References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> <4ed3ba77$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9jht8pFrs3U1@mid.individual.net> On 2011-11-28, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 07:36:17 -0800, Tim wrote: >> Hi, I need to generate a list of file names that increment, like this: >> fname1 >> fname2 >> fname3 and so on. >> >> I don't know how many I'll need until runtime so I figure a >> generator is called for. >> >> def fname_gen(stem): >> i = 0 >> while True: >> i = i+1 >> yield '%s%d' % (stem,i) >> >> blarg = fname_gen('blarg') >> boo = fname_gen('boo') I don't see anything wrong with that. I've written similar code in terms of itertools.count, myself. If I may make a suggestion, it would be nice to zero-pad the number to achieve lexicographical ordering of filenames. However, if you really have no idea of the magnitude you might need that won't work. The following assumes you'll need less than 1000. counter = itertools.count() ... with open("%03d" % counter.next(), "w") as the_next_file: ... My Python < 3.0 is rusty, so sorry if I messed that up. -- Neil Cerutti From !nospam!astrochelonian at gmail.com Mon Nov 28 12:21:37 2011 From: !nospam!astrochelonian at gmail.com (Eduardo Alvarez) Date: Mon, 28 Nov 2011 17:21:37 +0000 (UTC) Subject: mailbox module difficulties Message-ID: Hello, everyone, I'm in the process of learning how to use the mailbox module with python 3.2. I've noticed the following seemingly inconsistent behavior: if I call a Maildir object directly, the module works perfectly. I can, for example, call mailbox.Maildir("~/Maildir").items() and get the expected list of (key,Message) pairs. however, if I do the following: b = mailbox.Maildir("~/Maildir") b.items() I get an empty list. I don't understand why this is so, specially since the last example in the documentation shows a reference to a Maildir object being created. Why does this happen? yours, -- Eduardo Alvarez From rosuav at gmail.com Mon Nov 28 12:29:45 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 04:29:45 +1100 Subject: mailbox module difficulties In-Reply-To: References: Message-ID: On Tue, Nov 29, 2011 at 4:21 AM, Eduardo Alvarez wrote: > if I call a Maildir object directly, the module works perfectly. I can, > for example, call > > mailbox.Maildir("~/Maildir").items() > > and get the expected list of (key,Message) pairs. > > however, if I do the following: > > b = mailbox.Maildir("~/Maildir") > b.items() > > I get an empty list. They ought to be equivalent. Can you post your whole code? Maybe there's some other difference. ChrisA From __peter__ at web.de Mon Nov 28 12:50:17 2011 From: __peter__ at web.de (Peter Otten) Date: Mon, 28 Nov 2011 18:50:17 +0100 Subject: mailbox module difficulties References: Message-ID: Eduardo Alvarez wrote: > however, if I do the following: > > b = mailbox.Maildir("~/Maildir") > b.items() > > I get an empty list. > > I don't understand why this is so, specially since the last example in > the documentation shows a reference to a Maildir object being created. > Why does this happen? Could this be http://bugs.python.org/issue13254 ? From mwilson at the-wire.com Mon Nov 28 12:58:50 2011 From: mwilson at the-wire.com (Mel Wilson) Date: Mon, 28 Nov 2011 12:58:50 -0500 Subject: correct usage of a generator? References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Message-ID: Tim wrote: > Hi, I need to generate a list of file names that increment, like this: > fname1 > fname2 > fname3 and so on. > > I don't know how many I'll need until runtime so I figure a generator is > called for. > > def fname_gen(stem): > i = 0 > while True: > i = i+1 > yield '%s%d' % (stem,i) > > blarg = fname_gen('blarg') > boo = fname_gen('boo') > > n = 3 > for w in range(0,n): > in_name = blarg.next() > out_name = boo.next() > > > This works, but is it the 'normal' way to accomplish the task when you > don't know 'n' until run-time? thanks, It's kind of overkill in the toy demo example, but if the main loop is a little more abstract, e.g. for task in task_supplier(): in_name = blarg.next() out_name = boo.next() handle_task (task, in_name, out_name) then it's obviously a good thing. One quibble (that Peter Otten also suggested): if your business rules expect that files blarg25 and boo25 (for example) work together, then you'd be better off generating them together as a pair in a single generator call. As it is, there's a chance of the blarg and boo generators getting out of step and supplying mismatched names. Mel. From jehugaleahsa at gmail.com Mon Nov 28 13:03:38 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 10:03:38 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <61aacaf4-4953-4e6d-8f5e-2c999a9e2b63@k26g2000yqd.googlegroups.com> On Nov 27, 6:55?pm, Steven D'Aprano wrote: > On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > > Personally, I find a lot of good things in Python. I thinking tabs are > > out-of-date. Even the MAKE community wishes that the need for tabs would > > go away and many implementations have done just that. > > Tabs have every theoretical advantage and only one practical > disadvantage: the common toolsets used by Unix programmers are crap in > their handling of tabs, and instead of fixing the toolsets, they blame > the tabs. > > The use of spaces as indentation is a clear case of a technically worse > solution winning over a better solution. > > > I have been > > seriously debating about whether to force a specific number of spaces, > > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > > spaces is appropriate (although I'm not sure when). > > Why on earth should your language dictate the width of an indentation? I > can understand that you might care that indents are consistent within a > single source code unit (a file?), but anything more than that is just > obnoxious. > > > I have always found the standard library for Python to be disjoint. That > > can be really beneficial where it keeps the learning curve down and the > > size of the standard modules down. At the same time, it means > > re-learning whenever you use a new module. > > I know what disjoint means, but I don't understand what you think it > means for a software library to be disjoint. I don't understand the rest > of the paragraph. > > > My language combines generators and collection initializers, instead of > > creating a whole new syntax for comprehensions. > > > [| for i in 0..10: for j in 0.10: yield return i * j |] > > Are we supposed to intuit what that means? > > Is | a token, or are the delimiters [| and |] ? > > Is there a difference between iterating over 0..10 and iterating over > what looks like a float 0.10? > > What is "yield return"? > > > Lambdas and functions are the same thing in my language, so no need for > > a special keyword. > > That does not follow. Lambdas and def functions are the same thing in > Python, but Python requires a special keyword. > > > I also distinguish between initialization and > > assignment via the let keyword. > > What does this mean? I can guess, but I might guess wrong. > > > Also, non-locals do not need to be > > defined explicitly, since the scoping rules in Unit are far more "anal". > > What does this mean? I can't even guess what you consider more anal > scoping rules. > > > In reality though, it takes a certain level of arrogance to assume that > > any language will turn out without bumps. It is like I was told in > > college long ago, "Only the smallest programs are bug free." I think the > > same thing could be said for a language. The only language without flaws > > would be so small that it would be useless. > > I'm pretty sure that being so small that it is useless would count as a > flaw. > > What does it mean to say that a language is "small"? > > A Turing Machine is a pretty small language, with only a few > instructions: step forward, step backwards, erase a cell, write a cell, > branch on the state of the cell. And yet anything that can be computed, > anything at all, can be computed by a Turning Machine: a Turing Machine > can do anything you can do in C, Lisp, Fortran, Python, Java... and very > probably anything you can (mentally) do, full stop. So what does that > mean about "small" languages? > > On the other hand, take Epigram, a functional programming language: > > http://en.wikipedia.org/wiki/Epigram_(programming_language) > > It is *less* powerful than a Turing Machine, despite being far more > complex. Similarly languages like regular expressions, finite automata > and context-free grammers are more complex, "bigger", possibly with > dozens or hundreds of instructions, and yet less powerful. Likewise for > spreadsheets without cycles. > > Forth is much smaller than Java, but I would say that Forth is much, much > more powerful in some sense than Java. You could write a Java compiler in > Forth more easily than you could write a Forth compiler in Java. > > -- > Steven > > Yes. I was mostly rambling. More explanation would have meant more typing. Languages that use type inference heavily typically find unique ways of indicating literals, including numbers and collections. In Unit, [||] indicates fixed length arrays, [] is for dynamic arrays, {} is for sets and unordered dictionaries (at least one value is needed). A frozen set might be represented with a {||} in the future. I stole the syntax from F#. Numbers have a trailing letter indicating their types: signed byte (y), short (s), long (l), float (f), fixed (m), arbitrary precision (i), rational (r) and imaginary (j). Unsigned versions have a u before the letter (uy). Also, .. is the range operator in Unit. 0..10 means "0 through 10" and 0.1 means a floating point number (I missed a dot). 0..10..2 means 0, 2, 4, 6, 8, 10. Saves me from needing a range function, like Python. Quite a few functional languages support that syntax. From !nospam!astrochelonian at gmail.com Mon Nov 28 13:10:47 2011 From: !nospam!astrochelonian at gmail.com (Eduardo Alvarez) Date: Mon, 28 Nov 2011 18:10:47 +0000 (UTC) Subject: mailbox module difficulties References: Message-ID: On 2011-11-28, Peter Otten <__peter__ at web.de> wrote: > Eduardo Alvarez wrote: > >> however, if I do the following: >> >> b = mailbox.Maildir("~/Maildir") >> b.items() >> >> I get an empty list. >> >> I don't understand why this is so, specially since the last example in >> the documentation shows a reference to a Maildir object being created. >> Why does this happen? > > Could this be > > http://bugs.python.org/issue13254 > > ? Peter and Chris, This is exactly it. I guess the version in my linux distribution is not patched. I'll let the maintainer know, thank you! Yours, -- Eduardo Alvarez From stefan_ml at behnel.de Mon Nov 28 13:20:40 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 28 Nov 2011 19:20:40 +0100 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) In-Reply-To: <91j4q8xgv9.ln2@news.ducksburg.com> References: <91j4q8xgv9.ln2@news.ducksburg.com> Message-ID: Adam Funk, 25.11.2011 14:50: > I'm converting JSON data to XML using the standard library's json and > xml.dom.minidom modules. I get the input this way: > > input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') It doesn't make sense to use codecs.open() with a "b" mode. > big_json = json.load(input_source) You shouldn't decode the input before passing it into json.load(), just open the file in binary mode. Serialised JSON is defined as being UTF-8 encoded (or BOM-prefixed), not decoded Unicode. > input_source.close() In case of a failure, the file will not be closed safely. All in all, use this instead: with open(input_file, 'rb') as f: big_json = json.load(f) > Then I recurse through the contents of big_json to build an instance > of xml.dom.minidom.Document (the recursion includes some code to > rewrite dict keys as valid element names if necessary) If the name "big_json" is supposed to hint at a large set of data, you may want to use something other than minidom. Take a look at the xml.etree.cElementTree module instead, which is substantially more memory efficient. > and I save the document: > > xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') > doc.writexml(xml_file, encoding='UTF-8') > xml_file.close() Same mistakes as above. Especially the double encoding is both unnecessary and likely to fail. This is also most likely the source of your problems. > I thought this would force all the output to be valid, but xmlstarlet > gives some errors like these on a few documents: > > PCDATA invalid Char value 7 > PCDATA invalid Char value 31 This strongly hints at a broken encoding, which can easily be triggered by your erroneous encode-and-encode cycles above. Also, the kind of problem you present here makes it pretty clear that you are using Python 2.x. In Python 3, you'd get the appropriate exceptions when trying to write binary data to a Unicode file. Stefan From jtim.arnold at gmail.com Mon Nov 28 14:20:22 2011 From: jtim.arnold at gmail.com (Tim) Date: Mon, 28 Nov 2011 11:20:22 -0800 (PST) Subject: correct usage of a generator? In-Reply-To: References: <9312767.592.1322494577357.JavaMail.geo-discussion-forums@vbbhk3> Message-ID: <6572253.26.1322508022441.JavaMail.geo-discussion-forums@yqf20> thanks everyone. I thought blarg.next() looked a little strange--I'm just learning generators now and I'm glad too see that next(blarg) is the way to go. The example really was just a toy or I would use an iterator. I do need the two (well, the several) generators to not be coupled together so they increment independently. I'll keep the zero-padding advice in mind--I didn't think of that one. what a great group this is. thanks again! --Tim From patentsvnc at gmail.com Mon Nov 28 14:22:09 2011 From: patentsvnc at gmail.com (Den) Date: Mon, 28 Nov 2011 11:22:09 -0800 (PST) Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 26, 3:01?pm, Steven D'Aprano wrote: > On Sat, 26 Nov 2011 22:20:36 +0100, candide wrote: >>SNIP<< > > That is correct. You probably should rarely use `is`. Apart from testing > for None, use of `is` should be rare. > > -- > Steven With respect, I disagree with advice that the use of a language construct should be rare. All constructs should be used *appropriately*. While in general a particular use of a Python construct may be rare, if the programmer is involved deeply with that rare use, then it is NOT rare to him/her. Thus, for a particular programmer, use of 'is' may be quite frequent because the program they're working on requires knowledge of object identity. The same goes for global variables, by the way. While it's easy to shoot yourself in the foot with global variables, that doesn't lead to never-use-them. It leads to use-them-appropriately-and-carefully. Sorry, you plucked a string of mine. One does not throw a tool out of your tool box because it might be dangerous. Table saws are incredibly dangerous, but in the hands of a skilled operator can be competently and safely used to produce beautiful woodwork. To say *never* use a table saw because it's dangerous is silly. Language constructs are put there intentionally. Advice that they be used *rarely* or *never* should *never* be given ((chuckle)). Just learn what they are, learn how they work, learn what the consequences of misuse can be (loss of a hand, in the case of a table saw), and use them confidently when the circumstances make them the best choice of tool to solve your problem. To make a long comment short (too late!!) learn the differences between 'is' and ==, and use them appropriately. When I was learning Python, I found the two books by Mark Lutz to be filled with information of such things as these. D From patentsvnc at gmail.com Mon Nov 28 14:24:10 2011 From: patentsvnc at gmail.com (Den) Date: Mon, 28 Nov 2011 11:24:10 -0800 (PST) Subject: Return of an old friend References: Message-ID: On Nov 25, 2:13?am, Noah Hall wrote: > On Fri, Nov 25, 2011 at 5:08 AM, Matt Joiner wrote: > > I haven't heard of you before, but feel like I've missed out on something. > > > Do you (or someone else) care to link to some of your more contentious work? > > Ignore him, he's a troll with an unjustly inflated ego. ((laugh)) Well, that didn't take long. From ian.g.kelly at gmail.com Mon Nov 28 14:32:59 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 28 Nov 2011 12:32:59 -0700 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano wrote: >> My language combines generators and collection initializers, instead of >> creating a whole new syntax for comprehensions. >> >> [| for i in 0..10: for j in 0.10: yield return i * j |] > > Are we supposed to intuit what that means? > > Is | a token, or are the delimiters [| and |] ? > > Is there a difference between iterating over 0..10 and iterating over > what looks like a float 0.10? > > What is "yield return"? I would assume that "yield return" is borrowed from C#, where it is basically equivalent to Python's yield statement. The advantage of using two keywords like that is that you can compare the statements "yield return foo" and "yield break", which is a bit clearer than comparing the equivalent "yield foo" and "return". Having to type out "yield return" in every comprehension seems a bit painful to me, but I can understand the approach: what is shown above is a full generator, not a single "generator expression" like we use in Python, so the statement keywords can't be omitted. It's trading off convenience for expressiveness (a bad trade-off IMO -- complex generators should be named, not anonymous). >> Lambdas and functions are the same thing in my language, so no need for >> a special keyword. > > That does not follow. Lambdas and def functions are the same thing in > Python, but Python requires a special keyword. I think the implication is that Unit has only one syntax for creating functions, which is lambda-style. In any case, why does Python require a special keyword? def is only used in a statement context, and lambda is only used in an expression context. Why not use the same keyword for both? I think the answer is historical: def came first, and when anonymous functions were added it didn't make sense to use the keyword "def" for them, because "def" implies a name being defined. Cheers, Ian From ameyer2 at yahoo.com Mon Nov 28 15:03:13 2011 From: ameyer2 at yahoo.com (Alan Meyer) Date: Mon, 28 Nov 2011 15:03:13 -0500 Subject: Does py2app improves speed? In-Reply-To: References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> Message-ID: <4ED3E901.30306@yahoo.com> On 11/24/2011 9:27 AM, Dave Angel wrote: ... > Several ways to speed up code. > > 1) use language features to best advantage > 2) use 3rd party libraries that do certain things well > 3) use best algorithms, subject to #1 and #2 > 4) have someone else review the code (perhaps on the list, perhaps > within your own organization) > 5) measure (eg. profile it) > 6) use optimizing tools, such as pypy or Cython. > 7) rewrite parts of it in another language > 8) get a faster processor > 9) rewrite it all in another language > > It takes experience to choose between these, and each project is > different. But even the most experienced developers will frequently > guess entirely wrong where the bottleneck is, which is why you measure > if you care. I agree that measuring (profiling) is the most critical. As you say, even the most experienced programmers can guess wrong. The first time I used a profiler a couple of decades ago I was egotistical enough to wonder how this thing could help me. After all, I wrote the code. I knew what it did. The profiler wasn't going to tell me anything I didn't know. I learned a little humility after reading the profiler output. The program was spending most of its time in a place that I never dreamed was a problem, and a 10 minute fix cut run times in half. In that particular case there wasn't even a design problem, it was just a procedure call inside a tight loop that executed far more often than I imagined and could be replaced with a few lines of inline code. I think the rest of your list is excellent too. Alan From ethan at stoneleaf.us Mon Nov 28 15:05:00 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 28 Nov 2011 12:05:00 -0800 Subject: Pragmatics of the standard is() function In-Reply-To: References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ED3E96C.9040701@stoneleaf.us> Den wrote: > With respect, I disagree with advice that the use of a language > construct should be rare. All constructs should be used > *appropriately*. +1 ~Ethan~ From tjreedy at udel.edu Mon Nov 28 15:08:23 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 28 Nov 2011 15:08:23 -0500 Subject: python 2.5 and ast In-Reply-To: <4ED37475.3050709@gmail.com> References: <4ED37475.3050709@gmail.com> Message-ID: On 11/28/2011 6:45 AM, Andrea Crotti wrote: > I'm happily using the ast module to analyze some code, > but my scripts need also to run unfortunately on python 2.5 > > The _ast was there already, but the ast helpers not yet. > Is it ok if I just copy over the source from the ast helpers in my code > base That is the standard way of backporting features of later versions. -- Terry Jan Reedy From neilc at norwich.edu Mon Nov 28 15:20:36 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 28 Nov 2011 20:20:36 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9ji8okFs94U2@mid.individual.net> On 2011-11-28, Ian Kelly wrote: > I think the implication is that Unit has only one syntax for > creating functions, which is lambda-style. In any case, why > does Python require a special keyword? def is only used in a > statement context, and lambda is only used in an expression > context. Why not use the same keyword for both? I think the > answer is historical: def came first, and when anonymous > functions were added it didn't make sense to use the keyword > "def" for them, because "def" implies a name being defined. I've always held with the "anti-functional style conspiracy" interpretation of Python's lambda expressions. They were added but grudgingingly, made weak on purpose to discourage their use. -- Neil Cerutti "This room is an illusion and is a trap devisut by Satan. Go ahead and dauntlessly! Make rapid progres!" --Ghosts 'n Goblins From plsullivan1 at gmail.com Mon Nov 28 15:24:32 2011 From: plsullivan1 at gmail.com (plsullivan1 at gmail.com) Date: Mon, 28 Nov 2011 12:24:32 -0800 (PST) Subject: remove characters before last occurance of "." Message-ID: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> I need for GIS.GIS.Cadastral\GIS.GIS.Citylimit to be Citylimit. The "cadastral" and "citylimit" will be different as I readlines from a list. In other words, the above could be GIS.GIS.Restricted\GIS.GIS.Pipeline and I would need Pipeline. s = GIS.GIS.Cadastral\GIS.GIS.Citylimit NeededValue = Citylimit Thanks. From greg.ewing at canterbury.ac.nz Mon Nov 28 15:40:01 2011 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 29 Nov 2011 09:40:01 +1300 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> Message-ID: <9ji9t4FdphU1@mid.individual.net> Travis Parks wrote: > I thinking tabs are > out-of-date. Even the MAKE community wishes that the need for tabs > would go away The situation with make is a bit different, because it *requires* tabs in certain places -- spaces won't do. Python lets you choose which to use as long as you don't mix them up, and I like it that way. > let Parse = public static method (value: String) > throws(FormatException UnderflowException OverflowException) Checked exceptions? I fear you're repeating a huge mistake going down that route... -- Greg From ethan at stoneleaf.us Mon Nov 28 15:45:55 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 28 Nov 2011 12:45:55 -0800 Subject: remove characters before last occurance of "." In-Reply-To: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> References: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> Message-ID: <4ED3F303.8020307@stoneleaf.us> plsullivan1 at gmail.com wrote: > s = GIS.GIS.Cadastral\GIS.GIS.Citylimit > NeededValue = Citylimit NeededValue = s.rsplit('.', 1)[1] ~Ethan~ From greg.ewing at canterbury.ac.nz Mon Nov 28 15:48:34 2011 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 29 Nov 2011 09:48:34 +1300 Subject: Using the Python Interpreter as a Reference In-Reply-To: <9ji8okFs94U2@mid.individual.net> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <9ji8okFs94U2@mid.individual.net> Message-ID: <9jiad5Fhr9U1@mid.individual.net> Neil Cerutti wrote: > I've always held with the "anti-functional style conspiracy" > interpretation of Python's lambda expressions. They were added > but grudgingingly, made weak on purpose to discourage their use. Seems to me that Python's lambdas are about as powerful as they can be given the statement/expression distinction. No conspiracy is needed, just an understandable desire on Guido's part not to do violence to the overall syntactic style of the language. -- Greg From alemumihretu at gmail.com Mon Nov 28 15:52:13 2011 From: alemumihretu at gmail.com (Alemu mihretu) Date: Mon, 28 Nov 2011 13:52:13 -0700 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: Hello all, My python runs and crashes after another run. I am getting errors like Microsoft Visual C++ Runtime Library program c:\Python27\pythonw.exe This application has requested the Runtime to terminate it in an usuak way. Please contact the application's support team for more information. Any Idea ? my plot also does not work ? frustrating On Mon, Nov 28, 2011 at 12:32 PM, Ian Kelly wrote: > On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano > wrote: > >> My language combines generators and collection initializers, instead of > >> creating a whole new syntax for comprehensions. > >> > >> [| for i in 0..10: for j in 0.10: yield return i * j |] > > > > Are we supposed to intuit what that means? > > > > Is | a token, or are the delimiters [| and |] ? > > > > Is there a difference between iterating over 0..10 and iterating over > > what looks like a float 0.10? > > > > What is "yield return"? > > I would assume that "yield return" is borrowed from C#, where it is > basically equivalent to Python's yield statement. The advantage of > using two keywords like that is that you can compare the statements > "yield return foo" and "yield break", which is a bit clearer than > comparing the equivalent "yield foo" and "return". > > Having to type out "yield return" in every comprehension seems a bit > painful to me, but I can understand the approach: what is shown above > is a full generator, not a single "generator expression" like we use > in Python, so the statement keywords can't be omitted. It's trading > off convenience for expressiveness (a bad trade-off IMO -- complex > generators should be named, not anonymous). > > >> Lambdas and functions are the same thing in my language, so no need for > >> a special keyword. > > > > That does not follow. Lambdas and def functions are the same thing in > > Python, but Python requires a special keyword. > > I think the implication is that Unit has only one syntax for creating > functions, which is lambda-style. In any case, why does Python > require a special keyword? def is only used in a statement context, > and lambda is only used in an expression context. Why not use the > same keyword for both? I think the answer is historical: def came > first, and when anonymous functions were added it didn't make sense to > use the keyword "def" for them, because "def" implies a name being > defined. > > Cheers, > Ian > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at gmail.com Mon Nov 28 16:08:29 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Mon, 28 Nov 2011 21:08:29 +0000 Subject: remove characters before last occurance of "." In-Reply-To: <4ED3F303.8020307@stoneleaf.us> References: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> <4ED3F303.8020307@stoneleaf.us> Message-ID: On 28 November 2011 20:45, Ethan Furman wrote: > plsullivan1 at gmail.com wrote: >> >> s = GIS.GIS.Cadastral\GIS.GIS.Citylimit >> NeededValue = Citylimit > > NeededValue = s.rsplit('.', 1)[1] Also: >>> s[s.rfind(".") + 1:] 'Citylimit' >>> s.rpartition(".")[2] 'Citylimit' -- Arnaud From neilc at norwich.edu Mon Nov 28 16:11:06 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 28 Nov 2011 21:11:06 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <9ji8okFs94U2@mid.individual.net> <9jiad5Fhr9U1@mid.individual.net> Message-ID: <9jibnaFrjeU1@mid.individual.net> On 2011-11-28, Gregory Ewing wrote: > Neil Cerutti wrote: >> I've always held with the "anti-functional style conspiracy" >> interpretation of Python's lambda expressions. They were added >> but grudgingingly, made weak on purpose to discourage their >> use. > > Seems to me that Python's lambdas are about as powerful as they > can be given the statement/expression distinction. No > conspiracy is needed, just an understandable desire on Guido's > part not to do violence to the overall syntactic style of the > language. It's true. Most conspiracy theories do fall apart once facts and clear thinking are applied. But we love them anyway. ;) -- Neil Cerutti From plsullivan1 at gmail.com Mon Nov 28 16:13:44 2011 From: plsullivan1 at gmail.com (plsullivan1 at gmail.com) Date: Mon, 28 Nov 2011 13:13:44 -0800 (PST) Subject: remove characters before last occurance of "." In-Reply-To: References: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> <4ED3F303.8020307@stoneleaf.us> Message-ID: <28260178.222.1322514824753.JavaMail.geo-discussion-forums@yqi26> Thanks! From plsullivan1 at gmail.com Mon Nov 28 16:13:44 2011 From: plsullivan1 at gmail.com (plsullivan1 at gmail.com) Date: Mon, 28 Nov 2011 13:13:44 -0800 (PST) Subject: remove characters before last occurance of "." In-Reply-To: References: <9707115.134.1322511872642.JavaMail.geo-discussion-forums@yqeu24> <4ED3F303.8020307@stoneleaf.us> Message-ID: <28260178.222.1322514824753.JavaMail.geo-discussion-forums@yqi26> Thanks! From jehugaleahsa at gmail.com Mon Nov 28 16:29:06 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 13:29:06 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <9ji9t4FdphU1@mid.individual.net> Message-ID: On Nov 28, 3:40?pm, Gregory Ewing wrote: > Travis Parks wrote: > > I thinking tabs are > > out-of-date. Even the MAKE community wishes that the need for tabs > > would go away > > The situation with make is a bit different, because it > *requires* tabs in certain places -- spaces won't do. > Python lets you choose which to use as long as you don't > mix them up, and I like it that way. > > > let Parse = public static method (value: String) > > throws(FormatException UnderflowException OverflowException) > > Checked exceptions? I fear you're repeating a huge mistake > going down that route... > > -- > Greg > > Exception handling is one of those subjects few understand and fewer can implement properly in modern code. Languages that don't support exceptions as part of their signature lead to capturing generic Exception all throughout code. It is one of those features I wish .NET had. At the same time, with my limited experience with Java, it has been a massive annoyance. Perhaps something to provide or just shut off via a command line parameter. What indications have there been that this has been a flaw? I can see it alienating a large group of up- and-coming developers. From jehugaleahsa at gmail.com Mon Nov 28 16:34:07 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 13:34:07 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <16c6a453-22de-4dc3-bc99-16a45200fca2@o13g2000vbo.googlegroups.com> On Nov 28, 2:32?pm, Ian Kelly wrote: > On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano > > wrote: > >> My language combines generators and collection initializers, instead of > >> creating a whole new syntax for comprehensions. > > >> [| for i in 0..10: for j in 0.10: yield return i * j |] > > > Are we supposed to intuit what that means? > > > Is | a token, or are the delimiters [| and |] ? > > > Is there a difference between iterating over 0..10 and iterating over > > what looks like a float 0.10? > > > What is "yield return"? > > I would assume that "yield return" is borrowed from C#, where it is > basically equivalent to Python's yield statement. ?The advantage of > using two keywords like that is that you can compare the statements > "yield return foo" and "yield break", which is a bit clearer than > comparing the equivalent "yield foo" and "return". > > Having to type out "yield return" in every comprehension seems a bit > painful to me, but I can understand the approach: what is shown above > is a full generator, not a single "generator expression" like we use > in Python, so the statement keywords can't be omitted. ?It's trading > off convenience for expressiveness (a bad trade-off IMO -- complex > generators should be named, not anonymous). > > >> Lambdas and functions are the same thing in my language, so no need for > >> a special keyword. > > > That does not follow. Lambdas and def functions are the same thing in > > Python, but Python requires a special keyword. > > I think the implication is that Unit has only one syntax for creating > functions, which is lambda-style. ?In any case, why does Python > require a special keyword? ?def is only used in a statement context, > and lambda is only used in an expression context. ?Why not use the > same keyword for both? ?I think the answer is historical: ?def came > first, and when anonymous functions were added it didn't make sense to > use the keyword "def" for them, because "def" implies a name being > defined. > > Cheers, > Ian > > Most languages I have worked with have a "lambda" syntax and a function syntax. It has always been a historical artifact. Languages start out avoiding functional features and then eventually adopt them. It seems that eventually, convenient high-order functions become a must-have (most standard algorithm packages). It is a conflict between old C-style programming and the need for functional code. As soon as functions can be assigned to variables, the code starts looking oddly like JavaScript. From rosuav at gmail.com Mon Nov 28 16:57:46 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 08:57:46 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <9ji9t4FdphU1@mid.individual.net> Message-ID: On Tue, Nov 29, 2011 at 8:29 AM, Travis Parks wrote: > Languages that don't support > exceptions as part of their signature lead to capturing generic > Exception all throughout code. It is one of those features I wish .NET > had. At the same time, with my limited experience with Java, it has > been a massive annoyance. In Java, it mainly feels like syntactic salt. There's still a class of RuntimeExceptions that aren't listed in the signature, so you still have to concern yourself with the possibility that unexpected exceptions will propagate; and you're forced to decorate every method with the list of what it might propagate up, other than that. It's like const-decorating a series of functions in C++, only far less consequential and requiring far more typing. ChrisA From steve+comp.lang.python at pearwood.info Mon Nov 28 17:24:46 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 22:24:46 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> On Mon, 28 Nov 2011 12:32:59 -0700, Ian Kelly wrote: > On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano > wrote: [...] >>> Lambdas and functions are the same thing in my language, so no need >>> for a special keyword. >> >> That does not follow. Lambdas and def functions are the same thing in >> Python, but Python requires a special keyword. > > I think the implication is that Unit has only one syntax for creating > functions, which is lambda-style. In any case, why does Python require > a special keyword? def is only used in a statement context, and lambda > is only used in an expression context. Why not use the same keyword for > both? Because the syntax is completely different. One is a statement, and stands alone, the other is an expression. Even putting aside the fact that lambda's body is an expression, and a def's body is a block, def also requires a name. Using the same keyword for both would require special case reasoning: sometimes def is followed by a name, sometimes without a name. That's ugly. def name(args): block # okay funcs = [def args: expr, # okay so far def name(args): expr, # not okay def: expr, # okay ] def: expr # also okay def: expr expr # but not okay x = def x: expr # okay x = def x(x): expr # not okay Using the same keyword for named and unnamed functions is, in my opinion, one of those foolish consistencies we are warned about. When deciding on syntax, the difference between anonymous and named functions are more significant than their similarities. > I think the answer is historical: def came first, and when > anonymous functions were added it didn't make sense to use the keyword > "def" for them, because "def" implies a name being defined. That reasoning still applies even if they were added simultaneously. Lambda is pretty old: it certainly exists in Python 1.5 and almost certainly in 1.4. While it doesn't exist as a keyword in Python 0.9.1, there is a module called "lambda" with a function "lambda" that uses more or less the same syntax. Instead of lambda x: x+1, you would instead write lambda("x", "x+1"). So the idea of including anonymous functions was around in Python circles before the syntax was locked in. -- Steven From rosuav at gmail.com Mon Nov 28 17:48:24 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 09:48:24 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Nov 29, 2011 at 9:24 AM, Steven D'Aprano wrote: > Because the syntax is completely different. One is a statement, and > stands alone, the other is an expression. Even putting aside the fact > that lambda's body is an expression, and a def's body is a block, def > also requires a name. Using the same keyword for both would require > special case reasoning: sometimes def is followed by a name, sometimes > without a name. That's ugly. > All you need to do is define that a block of code is an object (and thus suitable material for an expression), and you have easy commonality. fn = def(args): block of code Now def is an expression that takes an optional name (omitted in the above), an arg list, and a block of code... and there's minimal difference between named and anonymous functions. (If it's given a name, then it sets __name__ and also binds to that name, being convenient for the common case. The above code is a silly way to do almost the default.) ChrisA From steve+comp.lang.python at pearwood.info Mon Nov 28 17:57:47 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Nov 2011 22:57:47 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <9ji9t4FdphU1@mid.individual.net> Message-ID: <4ed411eb$0$29988$c3e8da3$5496439d@news.astraweb.com> On Mon, 28 Nov 2011 13:29:06 -0800, Travis Parks wrote: > Exception handling is one of those subjects few understand and fewer can > implement properly in modern code. Languages that don't support > exceptions as part of their signature lead to capturing generic > Exception all throughout code. It is one of those features I wish .NET > had. At the same time, with my limited experience with Java, it has been > a massive annoyance. Perhaps something to provide or just shut off via a > command line parameter. What indications have there been that this has > been a flaw? I can see it alienating a large group of up- and-coming > developers. http://www.ibm.com/developerworks/java/library/j-jtp05254/index.html Note also that Bruce Eckel repeats a rumour that checked exceptions were *literally* an experiment snuck into the Java language while James Gosling was away on holiday. http://www.mindview.net/Etc/Discussions/UnCheckedExceptionComments Even if that is not true, checked exceptions are a feature that *in practice* seems to lead to poor exception handling and cruft needed only to satisfy the compiler: http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/#comment-219143 and other annoyances. It's main appeal, it seems to me, is to give a false sense of security to Java developers who fail to realise that under certain circumstances Java will raise certain checked exceptions *even if they are not declared*. E.g. null pointer exceptions. See also: http://java.dzone.com/articles/checked-exceptions-i-love-you and note especially the comment from the coder who says that he simply declares his functions to throw Exception (the most generic checked exception), thus defeating the whole point of checked exceptions. -- Steven From devplayer at gmail.com Mon Nov 28 19:54:08 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 28 Nov 2011 16:54:08 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 27, 6:55?pm, Steven D'Aprano wrote: > On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > > Personally, I find a lot of good things in Python. I thinking tabs are > > out-of-date. Even the MAKE community wishes that the need for tabs would > > go away and many implementations have done just that. > > Tabs have every theoretical advantage and only one practical > disadvantage: the common toolsets used by Unix programmers are crap in > their handling of tabs, and instead of fixing the toolsets, they blame > the tabs. > > The use of spaces as indentation is a clear case of a technically worse > solution winning over a better solution. > > > I have been > > seriously debating about whether to force a specific number of spaces, > > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > > spaces is appropriate (although I'm not sure when). > > Why on earth should your language dictate the width of an indentation? I > can understand that you might care that indents are consistent within a > single source code unit (a file?), but anything more than that is just > obnoxious. > I do not understand why the interpreter preprocesses each logical line of source code using something as simple as this: def reindent( line, spaces_per_tab=os.spaces_per_tab): index = 0 # index into line of text indent = 0 # increase 1 when in next tab column spaces = 0 # index into current column for c in line: if c == ' ': spaces +=1 if spaces >= spaces_per_tab: indent += 1 spaces = 0 if c == '\t': # jump to next tab column indent += 1 spaces = 0 if c <> ' ' and c <> '\t': break index += 1 rest_of_line = line[index:] new_indent = ' ' * indent * spaces_per_tab + ' ' * spaces newline = new_indent + rest_of_line return newline or even some regex equivelent. That function would need to be run on each line of source code, after processing the line continuation character and single/double/triple quote pairs are processed but before the code block tokenizer (INDENT/ DEDENT) if possible. Unless some of you expert parser/compiler writers know fancier tricks. To me, I would think the interpreter finding the coder's intended indent wouldn't be that hard. And just make the need for consistant spaces or tabs irrevelent simply by reformatting the indent as expected. Pretty much all my text editors can. From devplayer at gmail.com Mon Nov 28 19:59:42 2011 From: devplayer at gmail.com (DevPlayer) Date: Mon, 28 Nov 2011 16:59:42 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: > I do not understand why the interpreter preprocesses each logical line > of source code using something as simple as this: correction: I do not understand why the interpreter - does not- preprocess each logical line of source code using something as simple as this: From rosuav at gmail.com Mon Nov 28 20:49:49 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 12:49:49 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Nov 29, 2011 at 11:54 AM, DevPlayer wrote: > To me, I would think the interpreter finding the coder's intended > indent wouldn't be that hard. And just make the need for consistant > spaces or tabs irrevelent simply by reformatting the indent as > expected. Pretty much all my text editors can. The trouble with having a language declaration that "a tab is equivalent to X spaces" is that there's no consensus as to what X should be. Historically X has always been 8, and quite a few programs still assume this. I personally like 4. Some keep things narrow with 2. You can even go 1 - a strict substitution of \t with \x20. Once you declare it in your language, you immediately break everyone who uses anything different. ChrisA From jehugaleahsa at gmail.com Mon Nov 28 21:42:12 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 18:42:12 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> On Nov 28, 5:24?pm, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 12:32:59 -0700, Ian Kelly wrote: > > On Sun, Nov 27, 2011 at 4:55 PM, Steven D'Aprano > > wrote: > [...] > >>> Lambdas and functions are the same thing in my language, so no need > >>> for a special keyword. > > >> That does not follow. Lambdas and def functions are the same thing in > >> Python, but Python requires a special keyword. > > > I think the implication is that Unit has only one syntax for creating > > functions, which is lambda-style. ?In any case, why does Python require > > a special keyword? ?def is only used in a statement context, and lambda > > is only used in an expression context. ?Why not use the same keyword for > > both? > > Because the syntax is completely different. One is a statement, and > stands alone, the other is an expression. Even putting aside the fact > that lambda's body is an expression, and a def's body is a block, def > also requires a name. Using the same keyword for both would require > special case reasoning: sometimes def is followed by a name, sometimes > without a name. That's ugly. > > def name(args): block ?# okay > > funcs = [def args: expr, ?# okay so far > ? ? ? ? ?def name(args): expr, ?# not okay > ? ? ? ? ?def: expr, ?# okay > ? ? ? ? ?] > > def: expr ?# also okay > > def: expr > ? ? expr ?# but not okay > > x = def x: expr ?# okay > x = def x(x): expr ?# not okay > > Using the same keyword for named and unnamed functions is, in my opinion, > one of those foolish consistencies we are warned about. When deciding on > syntax, the difference between anonymous and named functions are more > significant than their similarities. A good example I have run into is recursion. When a local function calls itself, the name of the function may not be part of scope (non- local). Languages that support tail-end recursion optimization can't optimize. In order to support this, a function in Unit will have access to its own name and type. In other words, special scoping rules are in place in Unit to allow treating a function as an expression. > > > I think the answer is historical: ?def came first, and when > > anonymous functions were added it didn't make sense to use the keyword > > "def" for them, because "def" implies a name being defined. > > That reasoning still applies even if they were added simultaneously. > > Lambda is pretty old: it certainly exists in Python 1.5 and almost > certainly in 1.4. While it doesn't exist as a keyword in Python 0.9.1, > there is a module called "lambda" with a function "lambda" that uses more > or less the same syntax. Instead of lambda x: x+1, you would instead > write lambda("x", "x+1"). So the idea of including anonymous functions > was around in Python circles before the syntax was locked in. I find that interesting. I also find it interesting that the common functional methods (all, any, map, filter) are basically built into Python core language. That is unusual for most imperative programming languages early-on. From rosuav at gmail.com Mon Nov 28 21:57:32 2011 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 29 Nov 2011 13:57:32 +1100 Subject: Using the Python Interpreter as a Reference In-Reply-To: <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> Message-ID: On Tue, Nov 29, 2011 at 1:42 PM, Travis Parks wrote: > A good example I have run into is recursion. When a local function > calls itself, the name of the function may not be part of scope (non- > local). Languages that support tail-end recursion optimization can't > optimize. In order to support this, a function in Unit will have > access to its own name and type. In other words, special scoping rules > are in place in Unit to allow treating a function as an expression. I'm inclined toward an alternative: explicit recursion. Either a different syntax, or a special-case on the use of the function's own name, but whichever syntax you use, it compiles in a "recurse" opcode. That way, if name bindings change, it's still going to recurse - something few languages guarantee, and therefore few languages can optimize. ChrisA From jehugaleahsa at gmail.com Mon Nov 28 21:57:54 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 18:57:54 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <9ji9t4FdphU1@mid.individual.net> <4ed411eb$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 28, 5:57?pm, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 13:29:06 -0800, Travis Parks wrote: > > Exception handling is one of those subjects few understand and fewer can > > implement properly in modern code. Languages that don't support > > exceptions as part of their signature lead to capturing generic > > Exception all throughout code. It is one of those features I wish .NET > > had. At the same time, with my limited experience with Java, it has been > > a massive annoyance. Perhaps something to provide or just shut off via a > > command line parameter. What indications have there been that this has > > been a flaw? I can see it alienating a large group of up- and-coming > > developers. > > http://www.ibm.com/developerworks/java/library/j-jtp05254/index.html > > Note also that Bruce Eckel repeats a rumour that checked exceptions were > *literally* an experiment snuck into the Java language while James > Gosling was away on holiday. > > http://www.mindview.net/Etc/Discussions/UnCheckedExceptionComments > > Even if that is not true, checked exceptions are a feature that *in > practice* seems to lead to poor exception handling and cruft needed only > to satisfy the compiler: > > http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-ex... > > and other annoyances. It's main appeal, it seems to me, is to give a > false sense of security to Java developers who fail to realise that under > certain circumstances Java will raise certain checked exceptions *even if > they are not declared*. E.g. null pointer exceptions. > > See also: > > http://java.dzone.com/articles/checked-exceptions-i-love-you > > and note especially the comment from the coder who says that he simply > declares his functions to throw Exception (the most generic checked > exception), thus defeating the whole point of checked exceptions. > > -- > Steven I think all of the examples you listed referred specifically to most programmers finding ways around the annoyance. I have heard about throwing generic Exception or inheriting all custom exception types from RuntimeException. I did this quite often myself. In general, unchecked exceptions shouldn't be caught. They occur because of bad code and insufficient testing. Checked exceptions occur because of downed databases, missing files, network problems - things that may become available later without code changes. One day, I went through about 10,000 lines of code and moved argument checking code outside of try blocks because I realized I was handling some of them by accident. Here is the program: if me == idiot: exit(). People don't think about this, but the exceptions thrown by a module are part of that module's interface. Being able to make sure only what you expect to come out is important. Unlike Java, Unit requires you to opt in to using throws clauses. If you don't list one, one is generated for you automatically. The benefit: you can see what a function throws and protect yourself without all the babysitting. A lack of exception handling is big problem in .NET. I have had libraries from big names including Novell and Oracle throw NullReferenceExceptions because _they_ didn't know what would happen in cases where a DLL is missing or a dependency isn't installed. They could have done better testing, but if the biggest names in development can't manage to figure it, I say leave it up to the compiler. Returning nulls or special value in cases of failures takes us back to the days of C and Fortran. From jehugaleahsa at gmail.com Mon Nov 28 22:00:48 2011 From: jehugaleahsa at gmail.com (Travis Parks) Date: Mon, 28 Nov 2011 19:00:48 -0800 (PST) Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2cb176e6-322f-4c2d-a9bd-c3c5b6729cb6@e2g2000vbb.googlegroups.com> On Nov 28, 8:49?pm, Chris Angelico wrote: > On Tue, Nov 29, 2011 at 11:54 AM, DevPlayer wrote: > > To me, I would think the interpreter finding the coder's intended > > indent wouldn't be that hard. And just make the need for consistant > > spaces or tabs irrevelent simply by reformatting the indent as > > expected. Pretty much all my text editors can. > > The trouble with having a language declaration that "a tab is > equivalent to X spaces" is that there's no consensus as to what X > should be. Historically X has always been 8, and quite a few programs > still assume this. I personally like 4. Some keep things narrow with > 2. You can even go 1 - a strict substitution of \t with \x20. Once you > declare it in your language, you immediately break everyone who uses > anything different. > > ChrisA Yeah. We must remember the Unix users, espcially those who don't know how to hack Vim or bash. I've decided not to require a specific number of spaces. I am still teetering on whether to allow tabs. From d at davea.name Mon Nov 28 22:53:14 2011 From: d at davea.name (Dave Angel) Date: Mon, 28 Nov 2011 22:53:14 -0500 Subject: Does py2app improves speed? In-Reply-To: <4ED3E901.30306@yahoo.com> References: <0F07657D-9C87-417E-ADCB-150EB5040CAF@gmail.com> <3F9F123B-4A94-46C7-9184-2D0EF7F3A27C@gmail.com> <4ECE48E3.6070701@davea.name> <432E5AEC-F306-4043-B28D-AF4213F0526E@gmail.com> <4ED3E901.30306@yahoo.com> Message-ID: <4ED4572A.5020508@davea.name> On 11/28/2011 03:03 PM, Alan Meyer wrote: > On 11/24/2011 9:27 AM, Dave Angel wrote: > ... >> Several ways to speed up code. >> >> 1) use language features to best advantage >> 2) use 3rd party libraries that do certain things well >> 3) use best algorithms, subject to #1 and #2 >> 4) have someone else review the code (perhaps on the list, perhaps >> within your own organization) >> 5) measure (eg. profile it) >> 6) use optimizing tools, such as pypy or Cython. >> 7) rewrite parts of it in another language >> 8) get a faster processor >> 9) rewrite it all in another language >> >> It takes experience to choose between these, and each project is >> different. But even the most experienced developers will frequently >> guess entirely wrong where the bottleneck is, which is why you measure >> if you care. > > I agree that measuring (profiling) is the most critical. > > As you say, even the most experienced programmers can guess wrong. > The first time I used a profiler a couple of decades ago I was > egotistical enough to wonder how this thing could help me. After all, > I wrote the code. I knew what it did. The profiler wasn't going to > tell me anything I didn't know. > > I learned a little humility after reading the profiler output. The > program was spending most of its time in a place that I never dreamed > was a problem, and a 10 minute fix cut run times in half. > > In that particular case there wasn't even a design problem, it was > just a procedure call inside a tight loop that executed far more often > than I imagined and could be replaced with a few lines of inline code. > > I think the rest of your list is excellent too. > > Alan Thanks. I once had an assignment to speed up a function implementation which was obviously slow (I had noted the same thing to the architect when I first saw the code; it would definitely be slow on large data sets). I knew faster algorithms. But I stopped instead to measure how many times it was being called in the particularly slow scenario that the customer complained about. Turns out it wasn't being called at all. I asked the appropriate developer why he had chosen to do it another way (expecting he'd say because he knew this function was slow), and he gave me an entirely different reason. I asked him whether he'd be willing to call this function if I fixed his complaint about its interface, and he agreed. Now, I rewrote the function, making a change to tighten its interface restrictions. And it cut the customer's wait time from 90 minutes to 2. Everyone was happy. Total time spent, a week. But I didn't start coding till the 4th day. -- DaveA From d at davea.name Mon Nov 28 22:55:49 2011 From: d at davea.name (Dave Angel) Date: Mon, 28 Nov 2011 22:55:49 -0500 Subject: python 2.5 and ast In-Reply-To: References: <4ED37475.3050709@gmail.com> Message-ID: <4ED457C5.2020407@davea.name> On 11/28/2011 03:08 PM, Terry Reedy wrote: > On 11/28/2011 6:45 AM, Andrea Crotti wrote: >> I'm happily using the ast module to analyze some code, >> but my scripts need also to run unfortunately on python 2.5 >> >> The _ast was there already, but the ast helpers not yet. >> Is it ok if I just copy over the source from the ast helpers in my code >> base > > That is the standard way of backporting features of later versions. > But don't forget to tag it as version specific, so it gets removed when the later version of the library is available. There are various ways of doing that, but the easiest is probably to put a test in the acceptance suite that fails if this code is used in 2.6 or later. -- DaveA From wuwei23 at gmail.com Mon Nov 28 22:58:17 2011 From: wuwei23 at gmail.com (alex23) Date: Mon, 28 Nov 2011 19:58:17 -0800 (PST) Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Nov 29, 5:22?am, Den wrote: > On Nov 26, 3:01?pm, Steven D'Aprano > That is correct. You probably should rarely use `is`. Apart from testing > > for None, use of `is` should be rare. > > With respect, I disagree with advice that the use of a language > construct should be rare. ?All constructs should be used > *appropriately*. Steven didn't say it _shouldn't_ be used, only that it it should be _rarely_ used. General consensus would be that that is the most appropriate use of 'is'. Value comparisons are _far_ more common in Python than identity comparisons, the ubiquitous None notwithstanding. But for your general point, I totally agree. I feel the same way about the ternary syntax, boolean defaults for conditionals etc From ian.g.kelly at gmail.com Mon Nov 28 23:56:19 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 28 Nov 2011 21:56:19 -0700 Subject: Using the Python Interpreter as a Reference In-Reply-To: <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> Message-ID: On Mon, Nov 28, 2011 at 7:42 PM, Travis Parks wrote: > I find that interesting. I also find it interesting that the common > functional methods (all, any, map, filter) are basically built into > Python core language. That is unusual for most imperative programming > languages early-on. all and any are actually quite recent additions. Guido added them to placate users of "reduce(lambda x, y: x and y, foo)" back when the plan was to remove reduce in Python 3. Cheers, Ian From mrinalini at edss.co.in Tue Nov 29 02:34:01 2011 From: mrinalini at edss.co.in (Mrinalini Kulkarni) Date: Tue, 29 Nov 2011 13:04:01 +0530 Subject: Executing .pyc using python c api Message-ID: <98b3b679c77003a565bd306bc06c5709@edss.co.in> Hi I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. thanks, From steve+comp.lang.python at pearwood.info Tue Nov 29 03:04:14 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Nov 2011 08:04:14 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed491fe$0$14018$c3e8da3$76491128@news.astraweb.com> On Tue, 29 Nov 2011 12:49:49 +1100, Chris Angelico wrote: > On Tue, Nov 29, 2011 at 11:54 AM, DevPlayer wrote: >> To me, I would think the interpreter finding the coder's intended >> indent wouldn't be that hard. And just make the need for consistant >> spaces or tabs irrevelent simply by reformatting the indent as >> expected. Pretty much all my text editors can. > > The trouble with having a language declaration that "a tab is equivalent > to X spaces" is that there's no consensus as to what X should be. > Historically X has always been 8, and quite a few programs still assume > this. I personally like 4. Some keep things narrow with 2. You can even > go 1 - a strict substitution of \t with \x20. Once you declare it in > your language, you immediately break everyone who uses anything > different. Why should we enforce how many spaces a tab is set to? That is literally only visible to the editor, not the compiler. (Unless the parser is particularly stupid and merely substitutes X spaces for a tab every time it sees one.) Mixed spaces and tabs in an indent are ambiguous, and so raises SyntaxError (or at least it *should* raise SyntaxError). But separate code blocks can use different absolute indent levels without ambiguity, so long as the relative indentation is consistent: def ham(): # tab stops at 4 and 8 do(a) do(b) if c: do(c) else: do(d) def spam(): # tab stops at 8 and 12 do(a) do(b) if c: do(c) else: do(d) There is no meaningful difference in indentation between ham and spam above. In either case, I could replace spaces with tabs to get the same relative indents regardless of the absolute indentation. I can appreciate the aesthetic argument that *within a single file*, indentation should be consistent. But it's not logically necessary for the parser: it need only be consistent within a single code unit (function or class usually). In other words: syntax should only care about relative indentation, absolute indentation belongs as a coding standard. -- Steven From steve+comp.lang.python at pearwood.info Tue Nov 29 03:12:09 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Nov 2011 08:12:09 GMT Subject: Using the Python Interpreter as a Reference References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> Message-ID: <4ed493d8$0$14018$c3e8da3$76491128@news.astraweb.com> On Tue, 29 Nov 2011 13:57:32 +1100, Chris Angelico wrote: > I'm inclined toward an alternative: explicit recursion. Either a > different syntax, or a special-case on the use of the function's own > name, but whichever syntax you use, it compiles in a "recurse" opcode. > That way, if name bindings change, it's still going to recurse - > something few languages guarantee, and therefore few languages can > optimize. As I recall, Forth uses (or used) a special RECURSE word which turned on the recursion bit while compiling, so that the compiled word could see itself. By memory, the (incomplete) definition: : fact dup 1- fact * ; would fail, unless you happened to already have another word called fact existing at compilation time. To make it recurse correctly, the compiler needs to make sure that the namespace fact sees includes itself: RECURSE : fact dup 1- fact * ; which should work, apart from the embarrassing fact that I don't recall the syntax for conditional jumps and so the recursion never terminates. :) -- Steven From stefan_ml at behnel.de Tue Nov 29 03:15:41 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 29 Nov 2011 09:15:41 +0100 Subject: Executing .pyc using python c api In-Reply-To: <98b3b679c77003a565bd306bc06c5709@edss.co.in> References: <98b3b679c77003a565bd306bc06c5709@edss.co.in> Message-ID: Mrinalini Kulkarni, 29.11.2011 08:34: > I need to run .pyc files using python c api. if i do PyImport_Import it > executes the script. However, i need to pass a set of variables and their > values which will be accessed from within the script. How can this be done. Assuming you have the source as well, you should change your script to be usable as an importable module as well as an executable script. Here is how: http://docs.python.org/tutorial/modules.html#executing-modules-as-scripts If you do not have the source, however, you are a bit out of luck. In that case, what so you mean by "pass a set of variables"? Do you mean command line arguments, or do you want to pass in global names that the module can use? In the first case, you may need to modify sys.argv. If the latter, you could change the globals() of the imported module. However, both are clumsy solutions, and if possible at all, you should change the module source code instead. Stefan From steve+comp.lang.python at pearwood.info Tue Nov 29 03:41:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Nov 2011 08:41:30 GMT Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ed49aba$0$14018$c3e8da3$76491128@news.astraweb.com> On Mon, 28 Nov 2011 11:22:09 -0800, Den wrote: > With respect, I disagree with advice that the use of a language > construct should be rare. All constructs should be used > *appropriately*. And if those appropriate conditions are rare, then the use of the appropriate construct should also be rare. Since it is rare to need to care about identity, use of `is` should be rare too. This is mostly descriptive statement rather than a prescriptive one: it is a fact that use of `is` is much less common than use of ==, and even more so if you disregard the obvious case of "x is None". I am however being a little prescriptive: if somebody thinks they need to care about identity, chances are good -- but not certain -- that they're mistaken. In code that gives you the choice between writing `is` and ==, it is usually, but not often, a bug to write `is`. The proof of this is that in actual, existing code, if you swapped == and `is`, most of the code would stop working correctly. On the other hand if you actually do need to care about identity, then go for it. I'm not saying that caring about identity should be prohibited, only that in practice it is uncommon that you will. > While in general a particular use of a Python construct may be rare, if > the programmer is involved deeply with that rare use, then it is NOT > rare to him/her. Regardless of how common brain surgery might be to a brain surgeon, it is rare in general. That's all I'm saying. If you happen to work for a data recovery centre, then pulling the disk platter out of a hard disk drive might be commonplace to you, nevertheless pulling platters out of disks is vanishingly rare: out of tens of thousands of HDDs, perhaps only a few dozen will be sent to a recover centre at all. [...] > Sorry, you plucked a string of mine. One does not throw a tool out of > your tool box because it might be dangerous. Table saws are incredibly > dangerous, but in the hands of a skilled operator can be competently and > safely used to produce beautiful woodwork. To say *never* use a table > saw because it's dangerous is silly. Fortunately, I didn't say "never". In the case of `is`, one shouldn't avoid using `is` because it is dangerous, but merely because it is the wrong thing to use. In the same way, the average programmer will rarely need to use the math.sinh and math.cosh functions, not because they are bad, evil, or dangerous, but because they are used for specialist purposes that most coders would never care about. Hell, most coders rarely use the standard trigonometric functions sin and cos, let alone the hyperbolic versions! This is not a value judgement. If I, in a misplaced sense of egalitarianism ("Emancipation for maths functions! Right on brothers!") decided to use sinh instead of sin because they looked and sounded similar, my code would almost certain be buggy. Likewise if I decided to use `is` instead of == because in English they have similar meanings, my code would probably be buggy too. Sorry to belabour the point, but we're in violent agreement here -- Steven From d at davea.name Tue Nov 29 03:53:16 2011 From: d at davea.name (Dave Angel) Date: Tue, 29 Nov 2011 03:53:16 -0500 Subject: Using the Python Interpreter as a Reference In-Reply-To: <4ed493d8$0$14018$c3e8da3$76491128@news.astraweb.com> References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com> <4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com> <4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed40a2e$0$29988$c3e8da3$5496439d@news.astraweb.com> <861e1820-e70b-4f17-b668-53c4052974f5@w3g2000vbw.googlegroups.com> <4ed493d8$0$14018$c3e8da3$76491128@news.astraweb.com> Message-ID: <4ED49D7C.9000704@davea.name> On 11/29/2011 03:12 AM, Steven D'Aprano wrote: > On Tue, 29 Nov 2011 13:57:32 +1100, Chris Angelico wrote: > >> I'm inclined toward an alternative: explicit recursion. Either a >> different syntax, or a special-case on the use of the function's own >> name, but whichever syntax you use, it compiles in a "recurse" opcode. >> That way, if name bindings change, it's still going to recurse - >> something few languages guarantee, and therefore few languages can >> optimize. > As I recall, Forth uses (or used) a special RECURSE word which turned on > the recursion bit while compiling, so that the compiled word could see > itself. > > By memory, the (incomplete) definition: > > : fact dup 1- fact * ; > > would fail, unless you happened to already have another word called fact > existing at compilation time. To make it recurse correctly, the compiler > needs to make sure that the namespace fact sees includes itself: > > RECURSE : fact dup 1- fact * ; > > which should work, apart from the embarrassing fact that I don't recall > the syntax for conditional jumps and so the recursion never terminates. > > :) > The way I remember it, the current definition was "smudged" which made it invisible (it basically changed the name to something unlikely) during the compilation. After all, if you actually ran it at compile time (which was frequently done), you could fall right into uninitialized space. Anyway, some implementations had an immediate SMUDGE word, which toggled the smudge bit and made it visible again. Other implementations had an immediate word RECURSE, which compiled in whatever word was being currently defined. I'm pretty sure neither FIG nor Forth79 had either of these. But I don't recall the ANSI standard (X3J14 ?), even though I was officially an observer. I can't even remember what happened to my printed copy of the standard. The easiest word for conditional is IF/ELSE/THEN. IF will skip to the ELSE or THEN if the condition is false. So something resembling: : fact dup 1- dup 0<> if recurse * then ; might do it. That's very rough, however. It's been a long time. -- DaveA From ulrich.eckhardt at dominolaser.com Tue Nov 29 04:02:31 2011 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 29 Nov 2011 10:02:31 +0100 Subject: Executing .pyc using python c api In-Reply-To: References: Message-ID: <7mjeq8-ubf.ln1@satorlaser.homedns.org> Am 29.11.2011 08:34, schrieb Mrinalini Kulkarni: > I need to run .pyc files using python c api. if i do PyImport_Import it > executes the script. However, i need to pass a set of variables and > their values which will be accessed from within the script. How can this > be done. I don't think what you want is possible, due to a think-o in your design. Let me explain... Firstly, .pyc files are basically the same as .py files, only in a different presentation. Then, PyImport_Import is basically the same as using "import" in a Python program. Now, and that is where your fault lies, importing a module actually means executing that module! For example, the definition of a function is code that when executed will cause a function to be created and attached to the current scope with the according name. This is what makes it so easy to implement local functions that are parametrized by arguments to the outer function. Still, a function is not something that is "static", like in C or Java, but rather the result of executing its function definition. Now, how to get around this? The specialty about the import is that the __name__ attribute is not set to "__main__", upon which many scripts already react. So, in order to "prevent execution" (in the sense that you probably mean), you simply wrap the according code in a function. The function definition will then be executed, giving you a function that you can call with the according parameters, but the function itself will not be executed automatically. If you want that to happen when executing the .pyc file directly, check the content of __name__ and call the function if it is "__main__". Note that another approach would be introspection, traversing through the namespaces to find out those parameters, but I would consider this solution as hackish if the one above is feasible. Good luck! Uli From andrea.crotti.0 at gmail.com Tue Nov 29 04:51:24 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 29 Nov 2011 09:51:24 +0000 Subject: python 2.5 and ast In-Reply-To: <4ED457C5.2020407@davea.name> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> Message-ID: <4ED4AB1C.3080609@gmail.com> On 11/29/2011 03:55 AM, Dave Angel wrote: > > But don't forget to tag it as version specific, so it gets removed > when the later version of the library is available. There are various > ways of doing that, but the easiest is probably to put a test in the > acceptance suite that fails if this code is used in 2.6 or later. > Ok thanks, something like this is ok? (or maybe I can use a try/catch and export my own if is not found in the standard library?) from sys import version_info if version_info[1] == 5: from psi.devsonly.ast import parse, NodeVisitor else: from ast import parse, NodeVisitor From arnodel at gmail.com Tue Nov 29 05:11:06 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 29 Nov 2011 10:11:06 +0000 Subject: python 2.5 and ast In-Reply-To: <4ED4AB1C.3080609@gmail.com> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> <4ED4AB1C.3080609@gmail.com> Message-ID: On 29 November 2011 09:51, Andrea Crotti wrote: > from sys import version_info > > if version_info[1] == 5: > ? ?from psi.devsonly.ast import parse, NodeVisitor > else: > ? ?from ast import parse, NodeVisitor Why don't you just: try: from ast import parse, NodeVisitor except ImportError: from psi.devsonly.ast import parse, NodeVisitor -- Arnaud From mlto at live.jp Tue Nov 29 05:46:24 2011 From: mlto at live.jp (Toshiyuki Ogura) Date: Tue, 29 Nov 2011 19:46:24 +0900 Subject: Can I submit an issue with Python 2.5.6? Message-ID: Hi. I found a problem with Python 2.5.6. test_commands fails when 'make test'. bugs.python.org doesn't seem to have an option for Python 2.5 in "Versions:" drop-down menu when creating an issue. The problem seems to be the same as #11946. http://bugs.python.org/issue11946 I also made a patch for 2.5.6. --- Python-2.5.6/Lib/test/test_commands.py.orig 2006-06-29 04:10:08.000000000 +0000 +++ Python-2.5.6/Lib/test/test_commands.py 2011-11-29 08:46:29.602607019 +0000 @@ -46,11 +46,7 @@ # drwxr-xr-x 15 Joe User My Group 4096 Aug 12 12:50 / # Note that the first case above has a space in the group name # while the second one has a space in both names. - pat = r'''d......... # It is a directory. - \+? # It may have ACLs. - \s+\d+ # It has some number of links. - [^/]* # Skip user, group, size, and date. - /\. # and end with the name of the file. + pat = r'''^.*(\/\.)[\ ]*[\n\r]*$ ''' self.assert_(re.match(pat, getstatus("/."), re.VERBOSE)) Can I submit the issue at bugs.python.org? I think many people are still using Python 2.5 because of Google App Engine and fixing bugs with 2.5 is still helpful. Toshiyuki Ogura -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Nov 29 06:32:30 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Nov 2011 11:32:30 GMT Subject: python 2.5 and ast References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> Message-ID: <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> On Tue, 29 Nov 2011 09:51:24 +0000, Andrea Crotti wrote: > On 11/29/2011 03:55 AM, Dave Angel wrote: >> >> But don't forget to tag it as version specific, so it gets removed when >> the later version of the library is available. There are various ways >> of doing that, but the easiest is probably to put a test in the >> acceptance suite that fails if this code is used in 2.6 or later. >> >> > Ok thanks, > something like this is ok? > (or maybe I can use a try/catch and export my own if is not found in the > standard library?) > > from sys import version_info > > if version_info[1] == 5: > from psi.devsonly.ast import parse, NodeVisitor > else: > from ast import parse, NodeVisitor I prefer to check against sys.version. import sys if sys.version <= '2.5': from psi.devsonly.ast import parse, NodeVisitor else: from ast import parse, NodeVisitor Or even: try: from ast import parse, NodeVisitor except ImportError: from ast import parse, NodeVisitor -- Steven From a24061 at ducksburg.com Tue Nov 29 07:50:59 2011 From: a24061 at ducksburg.com (Adam Funk) Date: Tue, 29 Nov 2011 12:50:59 +0000 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) References: <91j4q8xgv9.ln2@news.ducksburg.com> <4ed37a63$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2011-11-28, Steven D'Aprano wrote: > On Fri, 25 Nov 2011 13:50:01 +0000, Adam Funk wrote: > >> I'm converting JSON data to XML using the standard library's json and >> xml.dom.minidom modules. I get the input this way: >> >> input_source = codecs.open(input_file, 'rb', encoding='UTF-8', >> errors='replace') big_json = json.load(input_source) >> input_source.close() >> >> Then I recurse through the contents of big_json to build an instance of >> xml.dom.minidom.Document (the recursion includes some code to rewrite >> dict keys as valid element names if necessary), > > How are you doing that? What do you consider valid? Regex-replacing all whitespace ('\s+') with '_', and adding 'a_' to the beginning of any potential tag that doesn't start with a letter. This is good enough for my purposes. >> I thought this would force all the output to be valid, but xmlstarlet >> gives some errors like these on a few documents: > > It will force the output to be valid UTF-8 encoded to bytes, not > necessarily valid XML. Yes! >> PCDATA invalid Char value 7 >> PCDATA invalid Char value 31 > > What's xmlstarlet, and at what point does it give this error? It doesn't > appear to be in the standard library. It's a command-line tool I use a lot for finding the bad bits in XML, nothing to do with python. http://xmlstar.sourceforge.net/ >> I guess I need to process each piece of PCDATA to clean out the control >> characters before creating the text node: >> >> text = doc.createTextNode(j) >> root.appendChild(text) >> >> What's the best way to do that, bearing in mind that there can be >> multibyte characters in the strings? > > Are you mixing unicode and byte strings? I don't think I am. > Are you sure that the input source is actually UTF-8? If not, then all > bets are off: even if the decoding step works, and returns a string, it > may contain the wrong characters. This might explain why you are getting > unexpected control characters in the output: they've come from a badly > decoded input. I'm pretty sure that the input is really UTF-8, but has a few control characters (fairly rare). > Another possibility is that your data actually does contain control > characters where there shouldn't be any. I think that's the problem, and I'm looking for an efficient way to delete them from unicode strings. -- Some say the world will end in fire; some say in segfaults. [XKCD 312] From a24061 at ducksburg.com Tue Nov 29 07:57:22 2011 From: a24061 at ducksburg.com (Adam Funk) Date: Tue, 29 Nov 2011 12:57:22 +0000 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) References: <91j4q8xgv9.ln2@news.ducksburg.com> Message-ID: On 2011-11-28, Stefan Behnel wrote: > Adam Funk, 25.11.2011 14:50: >> I'm converting JSON data to XML using the standard library's json and >> xml.dom.minidom modules. I get the input this way: >> >> input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') > > It doesn't make sense to use codecs.open() with a "b" mode. OK, thanks. >> big_json = json.load(input_source) > > You shouldn't decode the input before passing it into json.load(), just > open the file in binary mode. Serialised JSON is defined as being UTF-8 > encoded (or BOM-prefixed), not decoded Unicode. So just do input_source = open(input_file, 'rb') big_json = json.load(input_source) ? >> input_source.close() > > In case of a failure, the file will not be closed safely. All in all, use > this instead: > > with open(input_file, 'rb') as f: > big_json = json.load(f) OK, thanks. >> Then I recurse through the contents of big_json to build an instance >> of xml.dom.minidom.Document (the recursion includes some code to >> rewrite dict keys as valid element names if necessary) > > If the name "big_json" is supposed to hint at a large set of data, you may > want to use something other than minidom. Take a look at the > xml.etree.cElementTree module instead, which is substantially more memory > efficient. Well, the input file in this case contains one big JSON list of reasonably sized elements, each of which I'm turning into a separate XML file. The output files range from 600 to 6000 bytes. >> and I save the document: >> >> xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') >> doc.writexml(xml_file, encoding='UTF-8') >> xml_file.close() > > Same mistakes as above. Especially the double encoding is both unnecessary > and likely to fail. This is also most likely the source of your problems. Well actually, I had the problem with the occasional control characters in the output *before* I started sticking encoding="UTF-8" all over the place (in an unsuccessful attempt to beat them down). >> I thought this would force all the output to be valid, but xmlstarlet >> gives some errors like these on a few documents: >> >> PCDATA invalid Char value 7 >> PCDATA invalid Char value 31 > > This strongly hints at a broken encoding, which can easily be triggered by > your erroneous encode-and-encode cycles above. No, I've checked the JSON input and those exact control characters are there too. I want to suppress them (delete or replace with spaces). > Also, the kind of problem you present here makes it pretty clear that you > are using Python 2.x. In Python 3, you'd get the appropriate exceptions > when trying to write binary data to a Unicode file. Sorry, I forgot to mention the version I'm using, which is "2.7.2+". -- In the 1970s, people began receiving utility bills for -?999,999,996.32 and it became harder to sustain the myth of the infallible electronic brain. (Stob 2001) From cheap.meds4eu at gmail.com Tue Nov 29 08:00:22 2011 From: cheap.meds4eu at gmail.com (cheap meds) Date: Tue, 29 Nov 2011 05:00:22 -0800 (PST) Subject: Viagra - First and Best Cure for Erectile Dysfunction Message-ID: For over a decade Viagra has helped millions of men all over the world to restore their sex lives. Viagra is the medication that has proven to act best over erectile problems in men. This medication is so successful because of its chief key ingredient Sildenafil Citrate. Viagra works by relaxing the arterial wall which affect the penile erection since erection happens when blood circulates and remains in the penis. The primary benefit of Viagra is that it hardens the penis of a man making it erect and stiff so that he can have a satisfactory sexual intercourse. Secondly, Viagra is not required to be taken like a daily prescription drug. You can take it as early as 1 hour to 4 hours before your sexual activity and it would work just the same. Viagra should not be used with other treatments that cause erections. Buy Discount Viagra Online on www.cheap.meds4u.eu Your Satisfaction Reflects our Image! From andrea.crotti.0 at gmail.com Tue Nov 29 08:51:26 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 29 Nov 2011 13:51:26 +0000 Subject: python 2.5 and ast In-Reply-To: <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4ED4E35E.6090405@gmail.com> On 11/29/2011 11:32 AM, Steven D'Aprano wrote: > > I prefer to check against sys.version. > > import sys > if sys.version<= '2.5': > from psi.devsonly.ast import parse, NodeVisitor > else: > from ast import parse, NodeVisitor > > > > Or even: > > > try: > from ast import parse, NodeVisitor > except ImportError: > from ast import parse, NodeVisitor > > > The try/except is probably the nicest... I've seen in other places using sys.version <=, but is it a good idea to rely on the fact that the <= on strings has the right semantic? After all that's just a string, version_info looks more correct to me.. From anacrolix at gmail.com Tue Nov 29 09:07:08 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Wed, 30 Nov 2011 01:07:08 +1100 Subject: Can I submit an issue with Python 2.5.6? In-Reply-To: References: Message-ID: Note the re.VERBOSE flag allows this whitespace treatment of the pattern. 2011/11/29 Toshiyuki Ogura : > Hi. > > I found a problem with Python 2.5.6. > test_commands fails when 'make test'. > bugs.python.org doesn't seem to have an option for Python 2.5 in "Versions:" > drop-down menu when creating an issue. > The problem seems to be the same as #11946. > http://bugs.python.org/issue11946 > I also made a patch for 2.5.6. > > --- Python-2.5.6/Lib/test/test_commands.py.orig??? 2006-06-29 > 04:10:08.000000000 +0000 > +++ Python-2.5.6/Lib/test/test_commands.py??? 2011-11-29 08:46:29.602607019 > +0000 > @@ -46,11 +46,7 @@ > ???????? #???? drwxr-xr-x?? 15 Joe User My Group???? 4096 Aug 12 12:50 / > ???????? # Note that the first case above has a space in the group name > ???????? # while the second one has a space in both names. > -? ?????? pat = r'''d.........?? # It is a directory. > -????????????????? \+?????????? # It may have ACLs. > -????????????????? \s+\d+?????? # It has some number of links. > -????????????????? [^/]*??????? # Skip user, group, size, and date. > -????????????????? /\.????????? # and end with the name of the file. > +??????? pat = r'''^.*(\/\.)[\ ]*[\n\r]*$ > ??????????&nbs p;???? ''' > > ???????? self.assert_(re.match(pat, getstatus("/."), re.VERBOSE)) > > > Can I submit the issue at bugs.python.org? > I think many people are still using Python 2.5 because of Google App Engine > and fixing bugs with 2.5 is still helpful. > > Toshiyuki Ogura > > > -- > http://mail.python.org/mailman/listinfo/python-list > From dihedral88888 at googlemail.com Tue Nov 29 09:19:55 2011 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 29 Nov 2011 06:19:55 -0800 (PST) Subject: Executing .pyc using python c api In-Reply-To: <7mjeq8-ubf.ln1@satorlaser.homedns.org> References: <7mjeq8-ubf.ln1@satorlaser.homedns.org> Message-ID: <4302173.419.1322576395669.JavaMail.geo-discussion-forums@prnh1> On Tuesday, November 29, 2011 5:02:31 PM UTC+8, Ulrich Eckhardt wrote: > Am 29.11.2011 08:34, schrieb Mrinalini Kulkarni: > > I need to run .pyc files using python c api. if i do PyImport_Import it > > executes the script. However, i need to pass a set of variables and > > their values which will be accessed from within the script. How can this > > be done. > > I don't think what you want is possible, due to a think-o in your > design. Let me explain... > Firstly, .pyc files are basically the same as .py files, only in a > different presentation. Then, PyImport_Import is basically the same as > using "import" in a Python program. Now, and that is where your fault > lies, importing a module actually means executing that module! For > example, the definition of a function is code that when executed will > cause a function to be created and attached to the current scope with > the according name. This is what makes it so easy to implement local > functions that are parametrized by arguments to the outer function. > Still, a function is not something that is "static", like in C or Java, > but rather the result of executing its function definition. > > Now, how to get around this? The specialty about the import is that the > __name__ attribute is not set to "__main__", upon which many scripts > already react. So, in order to "prevent execution" (in the sense that > you probably mean), you simply wrap the according code in a function. > The function definition will then be executed, giving you a function > that you can call with the according parameters, but the function itself > will not be executed automatically. If you want that to happen when > executing the .pyc file directly, check the content of __name__ and call > the function if it is "__main__". > > Note that another approach would be introspection, traversing through > the namespaces to find out those parameters, but I would consider this > solution as hackish if the one above is feasible. > > Good luck! > > Uli Please use psyco and pyrex and C or whatever that can read saved results in a file, or just learn how to replace a hash or a sort in python's build in library of better speed, don't do reference overheads in those c type variables that won't overflow and underflow and used by other objects in python. Not trivial but well documented to cheer for a race! From stefan_ml at behnel.de Tue Nov 29 09:33:57 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 29 Nov 2011 15:33:57 +0100 Subject: suppressing bad characters in output PCDATA (converting JSON to XML) In-Reply-To: References: <91j4q8xgv9.ln2@news.ducksburg.com> Message-ID: Adam Funk, 29.11.2011 13:57: > On 2011-11-28, Stefan Behnel wrote: >> Adam Funk, 25.11.2011 14:50: >>> Then I recurse through the contents of big_json to build an instance >>> of xml.dom.minidom.Document (the recursion includes some code to >>> rewrite dict keys as valid element names if necessary) >> >> If the name "big_json" is supposed to hint at a large set of data, you may >> want to use something other than minidom. Take a look at the >> xml.etree.cElementTree module instead, which is substantially more memory >> efficient. > > Well, the input file in this case contains one big JSON list of > reasonably sized elements, each of which I'm turning into a separate > XML file. The output files range from 600 to 6000 bytes. It's also substantially easier to use, but if your XML writing code works already, why change it. >>> and I save the document: >>> >>> xml_file = codecs.open(output_fullpath, 'w', encoding='UTF-8', errors='replace') >>> doc.writexml(xml_file, encoding='UTF-8') >>> xml_file.close() >> >> Same mistakes as above. Especially the double encoding is both unnecessary >> and likely to fail. This is also most likely the source of your problems. > > Well actually, I had the problem with the occasional control > characters in the output *before* I started sticking encoding="UTF-8" > all over the place (in an unsuccessful attempt to beat them down). You should read up on Unicode a bit. >>> I thought this would force all the output to be valid, but xmlstarlet >>> gives some errors like these on a few documents: >>> >>> PCDATA invalid Char value 7 >>> PCDATA invalid Char value 31 >> >> This strongly hints at a broken encoding, which can easily be triggered by >> your erroneous encode-and-encode cycles above. > > No, I've checked the JSON input and those exact control characters are > there too. Ah, right, I didn't look closely enough. Those are forbidden in XML: http://www.w3.org/TR/REC-xml/#charsets It's sad that minidom (apparently) lets them pass through without even a warning. > I want to suppress them (delete or replace with spaces). Ok, then you need to process your string content while creating XML from it. If replacing is enough, take a look at string.maketrans() in the string module and str.translate(), a method on strings. Or maybe just use a regular expression that matches any whitespace character and replace it with a space. Or whatever suits your data best. >> Also, the kind of problem you present here makes it pretty clear that you >> are using Python 2.x. In Python 3, you'd get the appropriate exceptions >> when trying to write binary data to a Unicode file. > > Sorry, I forgot to mention the version I'm using, which is "2.7.2+". Yep, Py2 makes Unicode handling harder than it should be. Stefan From mlto at live.jp Tue Nov 29 10:17:50 2011 From: mlto at live.jp (Toshiyuki Ogura) Date: Wed, 30 Nov 2011 00:17:50 +0900 Subject: Can I submit an issue with Python 2.5.6? In-Reply-To: References: , Message-ID: I mistakenly posted the previous message in html format, and some rubbish text '&nbs p;' was unexpectedly inserted in the patch. I'll post the content of the patch again. Sorry for the inconvenience. --- Python-2.5.6/Lib/test/test_commands.py.orig??? 2006-06-29 04:10:08.000000000 +0000 +++ Python-2.5.6/Lib/test/test_commands.py??? 2011-11-29 08:46:29.602607019 +0000 @@ -46,11 +46,7 @@ ???????? #???? drwxr-xr-x?? 15 Joe User My Group???? 4096 Aug 12 12:50 / ???????? # Note that the first case above has a space in the group name ???????? # while the second one has a space in both names. -??????? pat = r'''d.........?? # It is a directory. -????????????????? \+?????????? # It may have ACLs. -????????????????? \s+\d+?????? # It has some number of links. -????????????????? [^/]*??????? # Skip user, group, size, and date. -????????????????? /\.????????? # and end with the name of the file. +??????? pat = r'''^.*(\/\.)[\ ]*[\n\r]*$ ??????????????? ''' ? ???????? self.assert_(re.match(pat, getstatus("/."), re.VERBOSE)) Toshiyuki Ogura From jmarcedwards at gmail.com Tue Nov 29 10:21:52 2011 From: jmarcedwards at gmail.com (J. Marc Edwards) Date: Tue, 29 Nov 2011 10:21:52 -0500 Subject: Amateur question on class definitions... Message-ID: <4ED4F890.70201@gmail.com> So I am defining my Python classes for a Django data model. I have a the following class hierarchy and would value some expert input on how to best implement this. I have many instances of a particular class which I call a "workflow", e.g. wf_1, wf_2, wf_3, etc. These class instances of workflows can be combined into "composite workflows", e.g. {cwf_1 is comprised of wf1 & wf_3}, {cwf_2 is wf_2 and wf_3}, or {cwf_3 is just wf_2}, etc. The workflows that constitute the composite workflow is positionally dependent, i.e. if cwf_1 is comprised of wf_1 and wf_3, then wf_1 comes 1st AND wf_3 is 2nd. As I have many workflow instances that accumulate in my persistent database (Django data model), then the composite workflows become an ordered collection of workflow instances. My first thought here is that the composite workflow class should have a field that is a simple list of workflows, i.e. list(workflows), but I am somewhat unsure of how to code this correctly. Here is a sample pseudo-code... class a_workflow(models.Model): ... class composite_workflow(models.Model): ...a list of "a_workflows", i.e. a composite workflow, should I use this syntax? set_of_workflows = list(a_workflow) Is this how a pro would do this? Regards, Marc -- J. Marc Edwards Lead Architect - Semiconductor Design Portals Nimbis Services, Inc. Skype: (919) 747-3775 Cell: (919) 345-1021 Fax: (919) 882-8602 marc.edwards at nimbisservices.com www.nimbisservices.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Tue Nov 29 10:59:40 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 30 Nov 2011 02:59:40 +1100 Subject: Amateur question on class definitions... In-Reply-To: <4ED4F890.70201@gmail.com> References: <4ED4F890.70201@gmail.com> Message-ID: On Wed, Nov 30, 2011 at 2:21 AM, J. Marc Edwards wrote: > ??? ...a list of "a_workflows", i.e. a composite workflow, should I use this > syntax? > ??? set_of_workflows = list(a_workflow) > This would be usual: set_of_workflows = [a_workflow] Using the list() constructor directly is for when you have some other iterable; for instance, a string is iterable over its characters: >>> list("Hello") ['H', 'e', 'l', 'l', 'o'] When you want to wrap up a single object in a list, square brackets syntax is what you want. ChrisA From ian.g.kelly at gmail.com Tue Nov 29 11:38:19 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 29 Nov 2011 09:38:19 -0700 Subject: Amateur question on class definitions... In-Reply-To: <4ED4F890.70201@gmail.com> References: <4ED4F890.70201@gmail.com> Message-ID: On Tue, Nov 29, 2011 at 8:21 AM, J. Marc Edwards wrote: > So I am defining my Python classes for a Django data model.? I have a the > following class hierarchy and would value some expert input on how to best > implement this. > > I have many instances of a particular class which I call a "workflow", e.g. > wf_1, wf_2, wf_3, etc. > These class instances of workflows can be combined into "composite > workflows", e.g. {cwf_1 is comprised of wf1 & wf_3}, {cwf_2 is wf_2 and > wf_3}, or {cwf_3 is just wf_2}, etc. > The workflows that constitute the composite workflow is positionally > dependent, i.e. if cwf_1 is comprised of wf_1 and wf_3, then wf_1 comes 1st > AND wf_3 is 2nd. > As I have many workflow instances that accumulate in my persistent database > (Django data model), then the composite workflows become an ordered > collection of workflow instances. > > My first thought here is that the composite workflow class should have a > field that is a simple list of workflows, i.e. list(workflows), but I am > somewhat unsure of how to code this correctly. > > Here is a sample pseudo-code... > > class a_workflow(models.Model): > ... > > class composite_workflow(models.Model): > ??? ...a list of "a_workflows", i.e. a composite workflow, should I use this > syntax? > ??? set_of_workflows = list(a_workflow) > > Is this how a pro would do this? That would work in general, but since these are Django models I assume that this relationship will need to be stored in the database. You'll need to use a ManyToManyField instead. I would do something like this: class Workflow(models.Model): pass class CompositeWorkflow(models.Model): workflow_set = models.ManyToManyField('Workflow', through='CompositeWorkflowOrder') class CompositeWorkflowOrder(models.Model): workflow = models.ForeignKey('Workflow') composite_workflow = models.ForeignKey('CompositeWorkflow') sequence_num = models.IntegerField() The CompositeWorkflowOrder model is then responsible for tracking which workflows are contained by which composite workflows, and in what order they appear (using sequence_num). See the Django docs on ManyToManyFields for more info. Cheers, Ian From patentsvnc at gmail.com Tue Nov 29 12:11:26 2011 From: patentsvnc at gmail.com (Den) Date: Tue, 29 Nov 2011 09:11:26 -0800 (PST) Subject: Pragmatics of the standard is() function References: <4ed15825$0$21841$426a34cc@news.free.fr> <4ed16fb9$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ed49aba$0$14018$c3e8da3$76491128@news.astraweb.com> Message-ID: <7de6a1b0-299e-468b-9ef2-9809643957a9@t16g2000vba.googlegroups.com> On Nov 29, 12:41?am, Steven D'Aprano wrote: > On Mon, 28 Nov 2011 11:22:09 -0800, Den wrote: > > With respect, I disagree with advice that the use of a language > > construct should be rare. ?All constructs should be used > > *appropriately*. > > And if those appropriate conditions are rare, then the use of the > appropriate construct should also be rare. Since it is rare to need to > care about identity, use of `is` should be rare too. > > This is mostly descriptive statement rather than a prescriptive one: it > is a fact that use of `is` is much less common than use of ==, and even > more so if you disregard the obvious case of "x is None". > > I am however being a little prescriptive: if somebody thinks they need to > care about identity, chances are good -- but not certain -- that they're > mistaken. In code that gives you the choice between writing `is` and ==, > it is usually, but not often, a bug to write `is`. The proof of this is > that in actual, existing code, if you swapped == and `is`, most of the > code would stop working correctly. > > On the other hand if you actually do need to care about identity, then go > for it. I'm not saying that caring about identity should be prohibited, > only that in practice it is uncommon that you will. > > > While in general a particular use of a Python construct may be rare, if > > the programmer is involved deeply with that rare use, then it is NOT > > rare to him/her. > > Regardless of how common brain surgery might be to a brain surgeon, it is > rare in general. That's all I'm saying. If you happen to work for a data > recovery centre, then pulling the disk platter out of a hard disk drive > might be commonplace to you, nevertheless pulling platters out of disks > is vanishingly rare: out of tens of thousands of HDDs, perhaps only a few > dozen will be sent to a recover centre at all. > > [...] > > > Sorry, you plucked a string of mine. ?One does not throw a tool out of > > your tool box because it might be dangerous. ?Table saws are incredibly > > dangerous, but in the hands of a skilled operator can be competently and > > safely used to produce beautiful woodwork. ?To say *never* use a table > > saw because it's dangerous is silly. > > Fortunately, I didn't say "never". > > In the case of `is`, one shouldn't avoid using `is` because it is > dangerous, but merely because it is the wrong thing to use. In the same > way, the average programmer will rarely need to use the math.sinh and > math.cosh functions, not because they are bad, evil, or dangerous, but > because they are used for specialist purposes that most coders would > never care about. Hell, most coders rarely use the standard trigonometric > functions sin and cos, let alone the hyperbolic versions! This is not a > value judgement. > > If I, in a misplaced sense of egalitarianism ("Emancipation for maths > functions! Right on brothers!") decided to use sinh instead of sin > because they looked and sounded similar, my code would almost certain be > buggy. Likewise if I decided to use `is` instead of == because in English > they have similar meanings, my code would probably be buggy too. > > Sorry to belabour the point, but we're in violent agreement here > > -- > Steven ((laugh)) Yes, I believe we are. D From malaclypse2 at gmail.com Tue Nov 29 13:34:00 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 29 Nov 2011 13:34:00 -0500 Subject: Can I submit an issue with Python 2.5.6? In-Reply-To: References: Message-ID: 2011/11/29 Toshiyuki Ogura > I found a problem with Python 2.5.6. > ... > Can I submit the issue at bugs.python.org? > I think many people are still using Python 2.5 because of Google App > Engine and fixing bugs with 2.5 is still helpful. > I don't think they'll be accepted. Python 2.5 is not slated to receive any more releases, ever. Not even source-only security fixes. According to http://www.python.org/getit/releases/2.5.6/, "This release is the final release of Python 2.5; under the current release policy, no security issues in Python 2.5 will be fixed anymore." Given that they're not even accepting security patches, I'm sure they won't accept non-security bugfixes either. If your goal is to get your patch accepted and deployed on google's app engine infrastructure, you could try getting a hold of someone at google, and asking if they accept patches directly, since there will be no further maintenance from the core python developers. I have no idea how difficult it would be to do that, or if there's any interest in accepting patches against python 2.5 at google. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From dpalao.python at gmail.com Tue Nov 29 14:09:44 2011 From: dpalao.python at gmail.com (DPalao) Date: Tue, 29 Nov 2011 20:09:44 +0100 Subject: 70% [* SPAM *] multiprocessing.Queue blocks when sending large object Message-ID: <23330_1322593803_pATJ9jRv011464_201111292009.44527.dpalao.python@gmail.com> Hello, I'm trying to use multiprocessing to parallelize a code. There is a number of tasks (usually 12) that can be run independently. Each task produces a numpy array, and at the end, those arrays must be combined. I implemented this using Queues (multiprocessing.Queue): one for input and another for output. But the code blocks. And it must be related to the size of the item I put on the Queue: if I put a small array, the code works well; if the array is realistically large (in my case if can vary from 160kB to 1MB), the code blocks apparently forever. I have tried this: http://www.bryceboe.com/2011/01/28/the-python-multiprocessing-queue-and-large- objects/ but it didn't work (especifically I put a None sentinel at the end for each worker). Before I change the implementation, is there a way to bypass this problem with multiprocessing.Queue? Should I post the code (or a sketchy version of it)? TIA, David From python.list at tim.thechases.com Tue Nov 29 14:37:58 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 29 Nov 2011 13:37:58 -0600 Subject: cmd.Cmd asking questions? In-Reply-To: References: <4ED37A96.2090905@tim.thechases.com> Message-ID: <4ED53496.6070408@tim.thechases.com> On 11/28/11 06:27, Robert Kern wrote: > On 11/28/11 12:12 PM, Tim Chase wrote: >> I can monkey with printing messages and using raw_input(), >> but I'd like to know if there's a better way (such as >> something interacting with readline for >> text-entry-with-history-and-completion, > > If you import readline, then any following uses of > raw_input() will automatically use readline. You may want to > swap out the history when you use get_string() or confirm() so > they don't mess up the regular Cmd history, but the basic > functionality should work out-of-box. I didn't realize raw_input() was so nicely overloaded. After about 30 minutes of fighting with various bits of code (and learning that pdb's readline doesn't save/restore history), I tweaked up some "save the history; restore the history" wrapper which worked well. >> or raw-character input for Y/N answers rather than the need >> to hit, making it feel more uniform), > > I actually have a preference for needing to press enter for > Y/N answers, too. It's distinctly *less* uniform to have some > questions requiring an enter and some not. It can be > unpleasantly surprising to the user, too. After playing with it, allowing for a default Y/N value seems to make it a one-key selection via , but allow for less-surprising behavior as you detail. Thanks for your input (no pun intended), -tkc From colinh at somewhere.invalid Tue Nov 29 15:06:30 2011 From: colinh at somewhere.invalid (Colin Higwell) Date: Tue, 29 Nov 2011 20:06:30 +0000 (UTC) Subject: Total newbie question: Best practice Message-ID: Hi, I am just starting to learn Python (I have been at it only a few hours), so please bear with me. I have a few very small scripts (do you call them scripts or programs?) which work properly, and produce the results intended. However, they are monolithic in nature; i.e. they begin at the beginning and finish at the end. Having done a little reading, I note that it seems to be quite common to have a function main() at the start (which in turn calls other functions as appropriate), and then to call main() to do the work. Is that standard best practice? Thanks From arnodel at gmail.com Tue Nov 29 15:34:01 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 29 Nov 2011 20:34:01 +0000 Subject: Total newbie question: Best practice In-Reply-To: References: Message-ID: On 29 November 2011 20:06, Colin Higwell wrote: > Hi, Hi Colin, and welcome to Python :) > I am just starting to learn Python (I have been at it only a few hours), > so please bear with me. I have a few very small scripts (do you call them > scripts or programs?) which work properly, and produce the results > intended. I think you can call them either. > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other functions as appropriate), and then to call main() to do the > work. > > Is that standard best practice? When code should be put in a function is a matter of judgement in the end, so it's not an easy question. But roughly speaking: - if you need to perform the same task at several points in you program, then it's a good idea to put this in a function. It avoids duplication of code, minimises the chances for bugs, makes the program easier to read (provided you find a nice name for the function!) and also improves testability. - if there is a task that could be performed is several different ways but with the same result, then it's good to put in a function. This way when reading the program you can focus on the important thing, which is the result of the process, without being distracted by the details of how the result is arrived at. Moreover, it gives you added flexibility as you can later try a different method for performing the same task and very easily plug it into your existing program to see if it improves performance for example. - if you have a piece of code which is too long to be understood easily, consider whether you could break it down into smaller bits, each of which has some meaning of its own, and make each bit into a function with a name that describes clearly what it does. Then rewrite your big piece of code in terms of these functions. It will make your program a lot easier to understand when you come back to it in the future. As for the main() function, I don't think it is standard practice in Python. There is no requirement to have a main() function. You can use the idiom: if __name__ == "__main__": ... which will execute if you call the file as a script (as opposed to importing it as a module) -- Arnaud From rosuav at gmail.com Tue Nov 29 15:36:35 2011 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 30 Nov 2011 07:36:35 +1100 Subject: Total newbie question: Best practice In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 7:06 AM, Colin Higwell wrote: > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other functions as appropriate), and then to call main() to do the > work. The reason for this practice is to allow your .py file to be either a top-level program or an imported module. if __name__ == "__main__": main() When you run a .py file directly, __name__ will be "__main__", and it'll execute main(). (Some programs directly embed the main routine in that if block - appropriate if main() would be very short, eg just calling some other function.) But if you import it as a module in some other program, that won't be the case; so instead, the module's functions are made available to the calling program. For simple scripts that don't have anything to offer as a module, it's fine to not bother with this structure. Python doesn't demand syntactic salt; that's one of its greatest features, IMHO. Chris Angelico From neilc at norwich.edu Tue Nov 29 16:12:48 2011 From: neilc at norwich.edu (Neil Cerutti) Date: 29 Nov 2011 21:12:48 GMT Subject: Total newbie question: Best practice References: Message-ID: <9jl06gFg9oU1@mid.individual.net> On 2011-11-29, Arnaud Delobelle wrote: > As for the main() function, I don't think it is standard > practice in Python. There is no requirement to have a main() > function. You can use the idiom: I don't start off with a main function, but if my script gets long and complicated, or if global names have proliferated and have become confusing, I'll refactor the whole thing into functions, including a "main". With most globals moved into main's namespace, calling subroutines from main forces me to define the context that's actually necessary for each part of the program. The resultant refactored programs are much easier to test, read and maintain. TLDR: "Called-only-once" functions like main are useful as documentation, hooks for testing, and for unraveling a snarl of global variables. -- Neil Cerutti From d at davea.name Tue Nov 29 16:57:18 2011 From: d at davea.name (Dave Angel) Date: Tue, 29 Nov 2011 16:57:18 -0500 Subject: Total newbie question: Best practice In-Reply-To: References: Message-ID: <4ED5553E.4050104@davea.name> On 11/29/2011 03:06 PM, Colin Higwell wrote: > Hi, > > I am just starting to learn Python (I have been at it only a few hours), > so please bear with me. I have a few very small scripts (do you call them > scripts or programs?) which work properly, and produce the results > intended. > > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other functions as appropriate), and then to call main() to do the > work. > > Is that standard best practice? > > Thanks > Welcome to Python, and to the comp.lang.python list. Is this your first experience programming? Yes, factoring your code from "monolithic" to "modular' (several functions, or even functions and classes), is good practice. That's not to say that some problems don't deserve a monolithic answer, but if you're a beginner, i'd like to see you get into a modular habit. You can use the words script and program pretty much interchangeably. in some contexts, each has additional connotations. For example, somebody used to a compiled language may refer to a python source file as a script, implying it's not as sophisticated as his own product. But, closer to home, we usually refer to the file you directly pass to the interpreter as a script, and any added files that get imported, as modules, or libraries. Other times, people will refer to a simple program as a script, implying that all it does is invoke some standard library functions, or even run some external programs. But when it gets more complex, it gradually turns into a "real program." Why break up a monolith? Several reasons. If you factor the code into independent functions, and give them good names, then each piece of the program is easier to understand. You will especially appreciate that if you come back to the code after doing something else for two weeks. Similarly if somebody else has to take over your code, or maybe adapt it to a slightly different purpose. Next, if it doesn't quite work, you can exercise the individual pieces independently, and narrow down the problem more quickly. Next, if the progfram is slow, usually you can narrow it down to a few key functions that take most of the time. You can write two versions of the same function, and do some careful timings to decide which one to use. Next, some of those functions may be useful in the next program you write. If you "reuse" the code by copy & paste, and find a problem in the new one, it's quite possible that the same problem may exist in your first program. it's easier to bring those changes back if they're in a function than if they're in lines 14 through 71. Finally, some of that reusable code may be worth moving to an external file, called a module. Then the same copy can be literally shared between multiple projects. This is how libraries were born, and you can write your own, eventually. there are many other reasons, but some of them might not make sense to you yet. How do you break it up? First, separate the classic parts that most scripts will have. Put the imports at the top, along with a comment describing the whole progfram's purpose. Next put the global variables, which should be few. If there are any constants, use all UPPERCASE for their names. Next, put the function and class definitions. Notice that none of them will be called yet, so the order of execution isn't important to the compiler. Each function needs a name, and you should use a name that makes sense to you. Try to write functions that work at a single level of complexity, and do one complete operation. Try not to do input/output in the same functions that do the computation. And finally, put the actual mainline. It could be as simple as a call to main(), but it may make more sense to you to put the calls to argument processing here, rather than in a main function. By arguments here, i'm referring to the stuff you typed on the command line when youi invoked the script. This part of the code is where you do the magic incantation: if __name__ == "__main__": main() When the number of functions gets unwieldy, it's time to move some of them to a new file. They should be related, and should work at the same level of complexity. And the file name should remind you of their purpose. At that point, you add an import of that file to your main source script. Congratulations, you've created a module. One catch with writing a lengthy reply is that others have already given you good feedback. Hopefully, mine will complement theirs. -- DaveA From xahlee at gmail.com Tue Nov 29 17:53:15 2011 From: xahlee at gmail.com (Xah Lee) Date: Tue, 29 Nov 2011 14:53:15 -0800 (PST) Subject: Programing Language: latitude-longitude-decimalize Message-ID: fun programing exercise. Write a function ?latitude-longitude- decimalize?. It should take a string like this: ?"37?26?36.42?N 06?15?14.28?W"?. The return value should be a pair of numbers, like this: ?[37.44345 -6.25396]?. Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp solution in a couple of days. Xah From colinh at somewhere.invalid Tue Nov 29 18:08:30 2011 From: colinh at somewhere.invalid (Colin Higwell) Date: Tue, 29 Nov 2011 23:08:30 +0000 (UTC) Subject: Total newbie question: Best practice References: Message-ID: On Tue, 29 Nov 2011 16:57:18 -0500, Dave Angel wrote: > On 11/29/2011 03:06 PM, Colin Higwell wrote: >> Hi, >> >> I am just starting to learn Python (I have been at it only a few >> hours), so please bear with me. I have a few very small scripts (do you >> call them scripts or programs?) which work properly, and produce the >> results intended. >> >> However, they are monolithic in nature; i.e. they begin at the >> beginning and finish at the end. Having done a little reading, I note >> that it seems to be quite common to have a function main() at the start >> (which in turn calls other functions as appropriate), and then to call >> main() to do the work. >> >> Is that standard best practice? >> >> Thanks >> > Welcome to Python, and to the comp.lang.python list. Is this your first > experience programming? > > Yes, factoring your code from "monolithic" to "modular' (several > functions, or even functions and classes), is good practice. > > That's not to say that some problems don't deserve a monolithic answer, > but if you're a beginner, i'd like to see you get into a modular habit. > > You can use the words script and program pretty much interchangeably. > in some contexts, each has additional connotations. For example, > somebody used to a compiled language may refer to a python source file > as a script, implying it's not as sophisticated as his own product. > But, closer to home, we usually refer to the file you directly pass to > the interpreter as a script, and any added files that get imported, as > modules, or libraries. > > Other times, people will refer to a simple program as a script, implying > that all it does is invoke some standard library functions, or even run > some external programs. But when it gets more complex, it gradually > turns into a "real program." > > > Why break up a monolith? > > Several reasons. If you factor the code into independent functions, and > give them good names, then each piece of the program is easier to > understand. You will especially appreciate that if you come back to the > code after doing something else for two weeks. Similarly if somebody > else has to take over your code, or maybe adapt it to a slightly > different purpose. > > Next, if it doesn't quite work, you can exercise the individual pieces > independently, and narrow down the problem more quickly. > > Next, if the progfram is slow, usually you can narrow it down to a few > key functions that take most of the time. You can write two versions of > the same function, and do some careful timings to decide which one to > use. > > Next, some of those functions may be useful in the next program you > write. If you "reuse" the code by copy & paste, and find a problem in > the new one, it's quite possible that the same problem may exist in your > first program. it's easier to bring those changes back if they're in a > function than if they're in lines 14 through 71. > > Finally, some of that reusable code may be worth moving to an external > file, called a module. Then the same copy can be literally shared > between multiple projects. This is how libraries were born, and you can > write your own, eventually. > > there are many other reasons, but some of them might not make sense to > you yet. > > > How do you break it up? > > First, separate the classic parts that most scripts will have. Put the > imports at the top, along with a comment describing the whole progfram's > purpose. Next put the global variables, which should be few. If there > are any constants, use all UPPERCASE for their names. > > Next, put the function and class definitions. Notice that none of them > will be called yet, so the order of execution isn't important to the > compiler. Each function needs a name, and you should use a name that > makes sense to you. Try to write functions that work at a single level > of complexity, and do one complete operation. Try not to do > input/output in the same functions that do the computation. > > And finally, put the actual mainline. It could be as simple as a call > to main(), but it may make more sense to you to put the calls to > argument processing here, rather than in a main function. By arguments > here, i'm referring to the stuff you typed on the command line when youi > invoked the script. This part of the code is where you do the magic > incantation: > > if __name__ == "__main__": > main() > > > > When the number of functions gets unwieldy, it's time to move some of > them to a new file. They should be related, and should work at the same > level of complexity. And the file name should remind you of their > purpose. At that point, you add an import of that file to your main > source script. Congratulations, you've created a module. > > One catch with writing a lengthy reply is that others have already given > you good feedback. Hopefully, mine will complement theirs. Thank you, and thanks also to all the other respondents. I have programmed before in a number of other languages, but there is still plenty in this thread for me to digest. From mickyhulse.lists at gmail.com Tue Nov 29 18:29:29 2011 From: mickyhulse.lists at gmail.com (Micky Hulse) Date: Tue, 29 Nov 2011 15:29:29 -0800 Subject: Programing Language: latitude-longitude-decimalize In-Reply-To: References: Message-ID: Last time I did this was using AS3. The format I used was DMS: GPSLongitude: 122,42,47.79 GPSLongitudeRef: W GPSLatitude: 45,30,30.390001198897014 GPSLatitudeRef: N Here's the method: Not shown in above code: If West longitude or South latitude I would make that DD (decimal degree) value negative. Anyway, that was a fun learning experience! :) From ian.g.kelly at gmail.com Tue Nov 29 18:49:18 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 29 Nov 2011 16:49:18 -0700 Subject: Programing Language: latitude-longitude-decimalize In-Reply-To: References: Message-ID: On Tue, Nov 29, 2011 at 3:53 PM, Xah Lee wrote: > fun programing exercise. Write a function ?latitude-longitude- > decimalize?. > > It should take a string like this: ?"37?26?36.42?N 06?15?14.28?W"?. > The return value should be a pair of numbers, like this: ?[37.44345 > -6.25396]?. > > Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp > solution in a couple of days. For Python 3: import re def latitude_longitude_decimalize(string): regex = r"""(\d+)\xb0(\d+)'([\d+.]+)"([NS])\s*(\d+)\xb0(\d+)'([\d+.]+)"([EW])""" match = re.match(regex, string) if not match: raise ValueError("Invalid input string: {0:r}".format(string)) def decimalize(degrees, minutes, seconds, direction): decimal = int(degrees) + int(minutes) / 60 + float(seconds) / 3600 if direction in 'SW': decimal = -decimal return decimal latitude = decimalize(*match.groups()[:4]) longitude = decimalize(*match.groups()[4:8]) return latitude, longitude From thad at thadlabs.com Tue Nov 29 18:50:33 2011 From: thad at thadlabs.com (Thad Floryan) Date: Tue, 29 Nov 2011 15:50:33 -0800 Subject: Programing Language: latitude-longitude-decimalize In-Reply-To: References: Message-ID: <4ED56FC9.5020007@thadlabs.com> On 11/29/2011 2:53 PM, Xah Lee wrote: > fun programing exercise. Write a function ?latitude-longitude- > decimalize?. > > It should take a string like this: ?"37?26?36.42?N 06?15?14.28?W"?. > The return value should be a pair of numbers, like this: ?[37.44345 > -6.25396]?. > > Feel free to use perl, python, ruby, lisp, etc. I'll post a emacs lisp > solution in a couple of days. What a waste of time when the following works fine (probably Java): From Bruce.Nairn at kingcounty.gov Tue Nov 29 19:12:54 2011 From: Bruce.Nairn at kingcounty.gov (Nairn, Bruce) Date: Tue, 29 Nov 2011 16:12:54 -0800 Subject: pythoncom on Windows Server 2008 Message-ID: Hi, I'm trying to move some code to a Windows Server 2008 machine. It runs on Windows 7 and XP, but fails on Windows Server 2008. The python installation is seemingly identical (python 2.6.4, 32 bit). The following replicates the problem: import pythoncom IDispatch = pythoncom.CoCreateInstance ('OPC.Automation', None, pythoncom.CLSCTX_SERVER, pythoncom.IID_IDispatch) On Windows 7 x64 or Windows XP x32: this returns an PyIDispatch object On Windows Server 2008 x64 this gives: com_error: (-2147221005, 'Invalid class string', None, None) Any suggestions would be appreciated! Bruce Nairn King County Wastewater Treatment Division 201 S Jackson St., KSC-NR-0503 Seattle, WA, 98104-3855 206-263-3693 email: bruce.nairn at kingcounty.gov -------------- next part -------------- An HTML attachment was scrubbed... URL: From irmen.NOSPAM at xs4all.nl Tue Nov 29 19:20:10 2011 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Wed, 30 Nov 2011 01:20:10 +0100 Subject: why is bytearray treated so inefficiently by pickle? In-Reply-To: References: <4ed24a33$0$6869$e4fe514c@news2.news.xs4all.nl> Message-ID: <4ed576bb$0$6908$e4fe514c@news2.news.xs4all.nl> On 28-11-2011 3:09, Terry Reedy wrote: > Possibly. The two developers listed as particularly interested in pickle are > 'alexandre.vassalotti,pitrou' (antoine), so if you do open a tracker issue, add them as > nosy. > > Take a look at http://www.python.org/dev/peps/pep-3154/ > by Antoine Pitrou or forwary your message to him. > Created a bug report + patches, http://bugs.python.org/issue13503 I've read the PEP, thanks, it was interesting. But I don't think my changes require a new pickle protocol version bump. Irmen From skippy.hammond at gmail.com Tue Nov 29 19:34:23 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 30 Nov 2011 11:34:23 +1100 Subject: pythoncom on Windows Server 2008 In-Reply-To: References: Message-ID: <4ED57A0F.6080805@gmail.com> On 30/11/2011 11:12 AM, Nairn, Bruce wrote: > Hi, > > I?m trying to move some code to a Windows Server 2008 machine. It runs > on Windows 7 and XP, but fails on Windows Server 2008. The python > installation is seemingly identical (python 2.6.4, 32 bit). The > following replicates the problem: > > import pythoncom > > IDispatch = pythoncom.CoCreateInstance (?OPC.Automation?, None, > pythoncom.CLSCTX_SERVER, pythoncom.IID_IDispatch) > > On Windows 7 x64 or Windows XP x32: > > this returns an PyIDispatch object > > On Windows Server 2008 x64 this gives: > > com_error: (-2147221005, ?Invalid class string?, None, None) > > Any suggestions would be appreciated! The OPC.Automation object isn't installed on the Server 2008 box. I'm not sure what this object is so can't advise on how to install it. Note also that you will need the same "bittedness" of the object as Python itself has - ie, assuming a 32bit Python, you need the 32bit implementation of the COM object, or if a 64bit Python, you need the 64bit COM object. Note that both the 32 and 64bit versions of both will work fine on a 64bit version of Windows - you just need to make sure they match. Mark From jurgenex at hotmail.com Tue Nov 29 20:14:23 2011 From: jurgenex at hotmail.com (Jürgen Exner) Date: Tue, 29 Nov 2011 17:14:23 -0800 Subject: Programing Language: latitude-longitude-decimalize References: <4ED56FC9.5020007@thadlabs.com> Message-ID: Thad Floryan wrote: >On 11/29/2011 2:53 PM, Xah Lee wrote: Please do not reply to the eternal troll Thanks jue From thad at thadlabs.com Tue Nov 29 21:10:17 2011 From: thad at thadlabs.com (Thad Floryan) Date: Tue, 29 Nov 2011 18:10:17 -0800 Subject: Programing Language: latitude-longitude-decimalize In-Reply-To: References: <4ED56FC9.5020007@thadlabs.com> Message-ID: <4ED59089.4000101@thadlabs.com> On 11/29/2011 5:14 PM, J?rgen Exner wrote: > Thad Floryan wrote: >> On 11/29/2011 2:53 PM, Xah Lee wrote: > > Please do not reply to the eternal troll > > Thanks Mea culpa, you're correct. I responded only because the subject is something with which I'm familiar, e.g., one of my posts from 1988 (23 years ago): and :-) From iamforufriends at gmail.com Tue Nov 29 21:42:22 2011 From: iamforufriends at gmail.com (sweet girl) Date: Tue, 29 Nov 2011 18:42:22 -0800 (PST) Subject: This girl want a boy friend for dating Message-ID: This girl want a boy friend for dating http://goo.gl/vPGGP http://goo.gl/vPGGP http://goo.gl/vPGGP http://goo.gl/vPGGP From cs at zip.com.au Tue Nov 29 22:30:38 2011 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 30 Nov 2011 14:30:38 +1100 Subject: cmd.Cmd asking questions? In-Reply-To: <4ED53496.6070408@tim.thechases.com> References: <4ED53496.6070408@tim.thechases.com> Message-ID: <20111130033038.GA19431@cskk.homeip.net> On 29Nov2011 13:37, Tim Chase wrote: | On 11/28/11 06:27, Robert Kern wrote: [...] | >I actually have a preference for needing to press enter for | >Y/N answers, too. It's distinctly *less* uniform to have some | >questions requiring an enter and some not. It can be | >unpleasantly surprising to the user, too. | | After playing with it, allowing for a default Y/N value seems to | make it a one-key selection via , but allow for | less-surprising behavior as you detail. As a matter of good practice, I like default responses (especially yes/no ones) to default to the safer/more-conservative choice, and generally to default to "no", with the question suitably framed so that "no" means "safer/more-conservative". In this way an accidental unthinking has less chance of doing damage. What that means depends on context, but I hope you take the point. (Oh yes, traditionally the default is also capitalised to be evident.) Example: Remove your database now? (y/N) I would want to mean "no" here, usually. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ There are old climbers, and there are bold climbers; but there are no old bold climbers. From k.sahithi2862 at gmail.com Tue Nov 29 22:52:38 2011 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Tue, 29 Nov 2011 19:52:38 -0800 (PST) Subject: XXX HOT PHOTOS&VIDEOS Message-ID: <6118c841-8e22-4601-9102-bdac88037cac@cu3g2000vbb.googlegroups.com> FOR GOOD JOBS SITES TO YOU http://goodjobssites.blogspot.com/ SHRUTI HASSAN HOT IN 3 MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/shruti-hassan-in-3-movie.html PANJA MOVIE LATEST STILLS http://actressgallery-kalyani.blogspot.com/2011/11/panja-movie-stills.html URIMI LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/urimi-movie-stills.html NIPPU MOVIE WORKING STILLS http://actressgallery-kalyani.blogspot.com/2011/11/nippu-movie-stills.html ROUDRAM MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/roudram-movie-stills.html SIMHAPUTHRUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/simhaputhrudu-movie-stills.html SOLO MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/solo-movie-stills.html BEZAWADA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/bezawada-movie-stills.html RAJANNA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/rajanna-movie-stills.html\ POOLARANGADU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/poolarangadu-movie-stills.html ILEANA HOT STILLS IN NANBAN MOVIE http://actressgallery-kalyani.blogspot.com/2011/11/nanban-movie-stills.html PRIYUDU HOT ROMANTIC STILLS http://actressgallery-kalyani.blogspot.com/2011/11/priyudu-movie-stills.html ADHINAYAKUDU LATEST MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/11/adhinayakudu-movie-stills.html HOT KATRINA KAIF PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/katrina-kaif.html AISHWARYA RAI HOT HQ PHOTO STILLS http://actressgallery-kalyani.blogspot.com/2011/09/aishwarya-rai.html ASIN HOT PHOTO GALLERY http://actressgallery-kalyani.blogspot.com/2011/09/asin.html SAKUNI MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/sakuni-movie-stills.html 7TH SENSE MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/10/7th-sense-movie-stills.html MOGUDU MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/mogudu-movie-stills.html HANSIKA MATOWNI LATEST HOT STILLS http://actressgallery-kalyani.blogspot.com/2011/09/hansika-motwani.html KAJAL AGARWAL HOT PHOTOS http://actressgallery-kalyani.blogspot.com/2011/09/kajal-agarwal.html TAMANNA SIRUTHAI HOT MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/siruthai-movie-stills.html SNEHA HOT GOA MOVIE STILLS http://actressgallery-kalyani.blogspot.com/2011/09/goa-movie-stills.html FOR FAST UPDATES IN FILM INDUSTRY http://allyouwants.blogspot.com/ FOR ONLY HOT GUYS SEE THIS PAYAL GHOSH HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/payal-ghosh-hot.html PARVATHI MELTON LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/parvathi-melton-hot.html SARAH JANE DIAS HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/11/sarah-jane-dias-hot.html KAJAL AGARWAL HOT SAREE STILLS http://hotactress-kalyani.blogspot.com/2011/11/kajal-agarwal-hot-in-saree.html POONAM KAUR HOT ROMANTIC STILLS http://hotactress-kalyani.blogspot.com/2011/11/poonam-kaur-hot.html AMISHA PATEL LATEST HOT BIKINI STILLS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TRISHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/trisha-hot.html CHARMI LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/charmi-hot.html PRIYAMANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/priyamani-hot.html KAJAL AGARWAL LATEST HOT WITHOUT TOP http://hotactress-kalyani.blogspot.com/2011/08/kajal-agarwal-hot-photos.html SAMANTHA LATEST HOT STILLS http://hotactress-kalyani.blogspot.com/2011/09/samantha-hot.html SNEHA ULLAL HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/sneha-ullal-hot.html ANJALI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/anjali-hot.html HANSIKA MOTWANI HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/10/hansika-motwani-hot.html PRANITHA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/pranitha-hot.html HOT KATRINAKAIF WALLPAPERS http://hotactress-kalyani.blogspot.com/2011/08/katrina-kaif-hot.html HOT MALLU ACTRESS BHAMA http://hotactress-kalyani.blogspot.com/2011/09/bhama-hot.html TOLLYWOOD HOT ACTRESSES http://hotactress-kalyani.blogspot.com/2011/08/hot-actrsess.html SONAKSHI SINHA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/09/sonakshi-sinha-hot.html PRIYANKA CHOPRA LATEST HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/priyanka-chopra-hot.html LATEST AMISHA PATEL HOT PICS http://hotactress-kalyani.blogspot.com/2011/08/amisha-patel-hot.html TAPSEE DIFFERENT STILLS http://hotactress-kalyani.blogspot.com/2011/08/tapsee-hot.html TAMANNA HOT PHOTOS http://hotactress-kalyani.blogspot.com/2011/08/tamanna-hot.html From alec.taylor6 at gmail.com Tue Nov 29 23:49:29 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 30 Nov 2011 15:49:29 +1100 Subject: Converting MS Access DB to Postgres or MySQL for ORM support with SQLalchemy Message-ID: Good afternoon, I was recently shown that my client runs MS Access everywhere, rather than a "real" database. There are many features they would be missing that something like a django frontend would provide. So I would like to move them to Postgres or MySQL (since MS Access support was been dropped after 0.4). But I would also like to move there schema &etc to ORM, for easy editing with SQLalchemy (or similar). What approach would you recommend? Thanks for all suggestions, Alec Taylor From guojunquan at gmail.com Wed Nov 30 01:20:30 2011 From: guojunquan at gmail.com (=?UTF-8?B?6YOt5Yab5p2D?=) Date: Wed, 30 Nov 2011 14:20:30 +0800 Subject: How convert a list string to a real list Message-ID: Good after I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it to a list like list = ["aaaa","bbbb","ccc"],what can id do? Thanks. -- ??? ??????????????? guojunquan{at}gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Wed Nov 30 01:24:59 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 30 Nov 2011 17:24:59 +1100 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: import json s = json.dumps([1, 2, 3, 4]) # '[1, 2, 3, 4]' l = json.loads(s) # [1, 2, 3, 4] 2011/11/30 ??? : > Good after > I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert > it to a list like list = ["aaaa","bbbb","ccc"],what can id do? > Thanks. > > > -- > ??? > ??????????????? > guojunquan{at}gmail.com > > > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Wed Nov 30 01:54:22 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Nov 2011 01:54:22 -0500 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: On 11/30/2011 1:20 AM, ??? wrote: > Good after > I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it > to a list like list = ["aaaa","bbbb","ccc"],what can id do? The easiest -- and most dangerous -- way is >>> eval('["aaaa","bbbb","ccc"]') ['aaaa', 'bbbb', 'ccc'] But DO NOT eval unexamined strings from untrusted sources. The reason is that it is much the same as letting an untrusted person sit unsupervised as the keyboard of your computer with a command window open. You would not want to eval "from os import system; system('')" where '' is replaced by something obnoxious for your operating system. -- Terry Jan Reedy From arnodel at gmail.com Wed Nov 30 02:09:48 2011 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 30 Nov 2011 07:09:48 +0000 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: On Nov 30, 2011 6:21 AM, "???" wrote: > > Good after > I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it to a list like list = ["aaaa","bbbb","ccc"],what can id do? > Thanks. > Look up the json module. -- Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Wed Nov 30 02:23:08 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 30 Nov 2011 18:23:08 +1100 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: Arnaud: Already showed that solution On Wed, Nov 30, 2011 at 6:09 PM, Arnaud Delobelle wrote: > > On Nov 30, 2011 6:21 AM, "???" wrote: >> >> Good after >> ? ? I have a string ?liststr = '["aaaa","bbbb","ccc"]' ,and I need convert >> it to a list like list =?["aaaa","bbbb","ccc"],what can id do? >> Thanks. >> > > Look up the json module. > > -- > Arnaud > > > -- > http://mail.python.org/mailman/listinfo/python-list > From Shambhu.Rajak at kpitcummins.com Wed Nov 30 03:50:19 2011 From: Shambhu.Rajak at kpitcummins.com (Shambhu Rajak) Date: Wed, 30 Nov 2011 08:50:19 +0000 Subject: Total newbie question: Best practice In-Reply-To: References: Message-ID: <408F64D89899604FB24015E64E10490C179CAB10@KCHJEXMB02.kpit.com> Collins Congratulations for your first step into Python Programming. You can call them script or programs(not necessarily but depends on what your coding for). Yaa..it's always a good practice to call it through main(), but it doesn't really matter you can call the method in way.... Regards, Shambhu -----Original Message----- From: Colin Higwell [mailto:colinh at somewhere.invalid] Sent: 30/11/2011 1:37 AM To: python-list at python.org Subject: Total newbie question: Best practice Hi, I am just starting to learn Python (I have been at it only a few hours), so please bear with me. I have a few very small scripts (do you call them scripts or programs?) which work properly, and produce the results intended. However, they are monolithic in nature; i.e. they begin at the beginning and finish at the end. Having done a little reading, I note that it seems to be quite common to have a function main() at the start (which in turn calls other functions as appropriate), and then to call main() to do the work. Is that standard best practice? Thanks From __peter__ at web.de Wed Nov 30 03:58:08 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Nov 2011 09:58:08 +0100 Subject: How convert a list string to a real list References: Message-ID: Terry Reedy wrote: > On 11/30/2011 1:20 AM, ??? wrote: >> Good after >> I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it >> to a list like list = ["aaaa","bbbb","ccc"],what can id do? > > The easiest -- and most dangerous -- way is > >>> eval('["aaaa","bbbb","ccc"]') > ['aaaa', 'bbbb', 'ccc'] > > But DO NOT eval unexamined strings from untrusted sources. The reason is > that it is much the same as letting an untrusted person sit unsupervised > as the keyboard of your computer with a command window open. You would > not want to eval > "from os import system; system('')" > where '' is replaced by something obnoxious for your > operating system. You can avoid these problems with ast.literal_eval(): literal_eval(node_or_string) Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None. From jasonveldicott at gmail.com Wed Nov 30 04:34:23 2011 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Wed, 30 Nov 2011 20:34:23 +1100 Subject: Debug python from DLL callback? Message-ID: Hi, I am wondering if anyone here might be able to suggest if there is a way of switching over from python execution into debug mode of an IDE, from python code that is executed as a callback from a C++ DLL? Thanks Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From fabiofz at gmail.com Wed Nov 30 04:48:19 2011 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 30 Nov 2011 07:48:19 -0200 Subject: Debug python from DLL callback? In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 7:34 AM, Jason Veldicott wrote: > Hi, > > I am wondering if anyone here might be able to suggest if there is a way of > switching over from python execution into debug mode of an IDE, from python > code that is executed as a callback from a C++ DLL? > Use a remote debugger: http://pydev.org/manual_adv_remote_debugger.html Cheers, Fabio From robert.kern at gmail.com Wed Nov 30 05:05:52 2011 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 30 Nov 2011 10:05:52 +0000 Subject: cmd.Cmd asking questions? In-Reply-To: <20111130033038.GA19431@cskk.homeip.net> References: <4ED53496.6070408@tim.thechases.com> <20111130033038.GA19431@cskk.homeip.net> Message-ID: On 11/30/11 3:30 AM, Cameron Simpson wrote: > On 29Nov2011 13:37, Tim Chase wrote: > | On 11/28/11 06:27, Robert Kern wrote: > [...] > |>I actually have a preference for needing to press enter for > |>Y/N answers, too. It's distinctly *less* uniform to have some > |>questions requiring an enter and some not. It can be > |>unpleasantly surprising to the user, too. > | > | After playing with it, allowing for a default Y/N value seems to > | make it a one-key selection via, but allow for > | less-surprising behavior as you detail. > > As a matter of good practice, I like default responses (especially > yes/no ones) to default to the safer/more-conservative choice, and > generally to default to "no", with the question suitably framed so that > "no" means "safer/more-conservative". > > In this way an accidental unthinking has less chance of doing > damage. What that means depends on context, but I hope you take the point. > > (Oh yes, traditionally the default is also capitalised to be evident.) > > Example: > > Remove your database now? (y/N) > > I would want to mean "no" here, usually. I would also add that if you can, try to make it such that the user can go back and change their mind before actually doing anything. In the "wizard" scenario that the OP describes, it is frequently the case that you are going to ask a number of questions first before actually doing anything rather than doing something after each question. I don't think that letting the user go back a previous question is particularly common, and every interface for it that I can think of off the top of my head seems awkward, but I think it deserves some thought. At the very least, what you can do is collect all of the answers, show them to the user at the end and ask if there is anything the user wants to change before continuing. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From ben.richardson at gmx.com Wed Nov 30 05:42:26 2011 From: ben.richardson at gmx.com (Ben Richardson) Date: Wed, 30 Nov 2011 02:42:26 -0800 (PST) Subject: Python crashes on segmentation error Message-ID: <8bffed0f-1050-418a-834d-f7060a899ab7@h5g2000yqk.googlegroups.com> Hi! Python crashes every time i run the following command? >>> import cv Segmentation fault: 11 Python quit unexpectedly - any help would be greatly appreciated - thankyou in advance :) Here is crash report? Process: Python [276] Path: /Library/Frameworks/Python.framework/Versions/2.7/ Resources/Python.app/Contents/MacOS/Python Identifier: Python Version: ??? (???) Code Type: X86-64 (Native) Parent Process: bash [271] Date/Time: 2011-11-30 21:40:17.798 +1100 OS Version: Mac OS X 10.7.2 (11C74) Report Version: 9 Interval Since Last Report: 34062 sec Crashes Since Last Report: 3 Per-App Crashes Since Last Report: 3 Anonymous UUID: 559858AC-B741-4FB9-842D- C0E1D157BDFF Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 VM Regions Near 0: --> __TEXT 0000000100000000-0000000100001000 [ 4K] r-x/rwx SM=COW /Library/Frameworks/Python.framework/Versions/2.7/ Resources/Python.app/Contents/MacOS/Python Application Specific Information: objc[276]: garbage collection is OFF Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 ??? 000000000000000000 0 + 0 1 org.python.python 0x00000001006c7885 PyImport_Import + 121 2 org.python.python 0x00000001006c7a1e PyImport_ImportModule + 32 3 cv.so 0x00000001004f5082 initcv + 18 4 org.python.python 0x00000001000dc071 _PyImport_LoadDynamicModule + 177 5 org.python.python 0x00000001000da33f import_submodule + 383 6 org.python.python 0x00000001000da84a load_next + 234 7 org.python.python 0x00000001000dab5b PyImport_ImportModuleLevel + 363 8 org.python.python 0x00000001000b9483 builtin___import__ + 131 9 org.python.python 0x000000010000c5e2 PyObject_Call + 98 10 org.python.python 0x00000001000ba5f7 PyEval_CallObjectWithKeywords + 87 11 org.python.python 0x00000001000bec78 PyEval_EvalFrameEx + 13256 12 org.python.python 0x00000001000c2d29 PyEval_EvalCodeEx + 2137 13 org.python.python 0x00000001000c2e46 PyEval_EvalCode + 54 14 org.python.python 0x00000001000e769c PyRun_InteractiveOneFlags + 380 15 org.python.python 0x00000001000e78fe PyRun_InteractiveLoopFlags + 78 16 org.python.python 0x00000001000e80e1 PyRun_AnyFileExFlags + 161 17 org.python.python 0x00000001000fe77c Py_Main + 2940 18 org.python.python 0x0000000100000f14 0x100000000 + 3860 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000100781870 rbx: 0x00000001019b3030 rcx: 0x00007fff5fbfe968 rdx: 0x0000000000000000 rdi: 0x0000000000000000 rsi: 0x00000001006f5ebc rbp: 0x00007fff5fbfea60 rsp: 0x00007fff5fbfea58 r8: 0x0800000000000100 r9: 0x2000000000000200 r10: 0x0000000000000000 r11: 0x00000001019b6054 r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x00000001019b3030 r15: 0x00007fff5fbfeb80 rip: 0x0000000000000000 rfl: 0x0000000000010206 cr2: 0x0000000000000000 Logical CPU: 1 Binary Images: 0x100000000 - 0x100000fff +org.python.python (2.7.2 - 2.7.2) <639E72E4-F205-C034-8E34-E59DE9C46369> /Library/Frameworks/ Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/ Python 0x100003000 - 0x10016cfef +org.python.python (2.7.2, [c] 2004-2011 Python Software Foundation. - 2.7.2) <49D18B1A-C92D-E32E- A7C1-086D0B14BD76> /Library/Frameworks/Python.framework/Versions/2.7/ Python 0x1002eb000 - 0x1002edfff +readline.so (??? - ???) <25AB2CA6-C3CC-9F24-F619-C85D51AD8A38> /Library/Frameworks/ Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so 0x1002f4000 - 0x1002f7fff +libopencv_flann.2.2.dylib (2.2.0 - compatibility 2.2.0) / usr/local/lib/libopencv_flann.2.2.dylib 0x1004b0000 - 0x1004d4fff libedit.2.dylib (3.0.0 - compatibility 2.0.0) /usr/lib/ libedit.2.dylib 0x1004e4000 - 0x1005fcff7 +cv.so (??? - ???) /usr/local/lib/python2.6/site- packages/cv.so 0x100632000 - 0x10073efff org.python.python (2.6.7 - 2.6.7) /System/Library/ Frameworks/Python.framework/Versions/2.6/Python 0x10079f000 - 0x1007d2ff7 +libopencv_video.2.2.dylib (2.2.0 - compatibility 2.2.0) <152DFA46-7D58-336B-B773-860D856A6FB7> / usr/local/lib/libopencv_video.2.2.dylib 0x101000000 - 0x10128fff7 +libopencv_core.2.2.dylib (2.2.0 - compatibility 2.2.0) <1FD2FD64-F301-31C7-836E-E2E283247BD7> / usr/local/lib/libopencv_core.2.2.dylib 0x1012d2000 - 0x10146ffe7 +libopencv_imgproc.2.2.dylib (2.2.0 - compatibility 2.2.0) <8FB2C0B0-ABA9-39B3-A5AA-574BF8F31C21> / usr/local/lib/libopencv_imgproc.2.2.dylib 0x101546000 - 0x1015a3fff +libopencv_ml.2.2.dylib (2.2.0 - compatibility 2.2.0) <24C6ADCF-EC65-3BE9-A2E1-3FEBE8FA5ECD> /usr/ local/lib/libopencv_ml.2.2.dylib 0x1015b9000 - 0x10168cff7 +libopencv_features2d. 2.2.dylib (2.2.0 - compatibility 2.2.0) /usr/local/lib/libopencv_features2d.2.2.dylib 0x1016bd000 - 0x1017aafe7 +libopencv_highgui.2.2.dylib (2.2.0 - compatibility 2.2.0) <94F7FA85-D4D0-33A4-9FC5-CECF2C3433FF> / usr/local/lib/libopencv_highgui.2.2.dylib 0x1017da000 - 0x101850ff7 +libopencv_calib3d.2.2.dylib (2.2.0 - compatibility 2.2.0) / usr/local/lib/libopencv_calib3d.2.2.dylib 0x10185c000 - 0x10189bfff +libopencv_objdetect.2.2.dylib (2.2.0 - compatibility 2.2.0) <486BD824-717F-3DB4-913B-F9EA66D018B8> / usr/local/lib/libopencv_objdetect.2.2.dylib 0x1018a7000 - 0x101949ff7 +libopencv_legacy.2.2.dylib (2.2.0 - compatibility 2.2.0) <7031719B-6D1D-39F2-86D0-3D6028F1B690> / usr/local/lib/libopencv_legacy.2.2.dylib 0x10196d000 - 0x1019a3fe7 +libopencv_contrib.2.2.dylib (2.2.0 - compatibility 2.2.0) <32C5ABA5-64CF-33A4-95E7-B37B0C68354C> / usr/local/lib/libopencv_contrib.2.2.dylib 0x7fff6316e000 - 0x7fff631a2ac7 dyld (195.5 - ???) <4A6E2B28- C7A2-3528-ADB7-4076B9836041> /usr/lib/dyld 0x7fff8a0b8000 - 0x7fff8a0c3ff7 com.apple.speech.recognition.framework (4.0.19 - 4.0.19) <7ADAAF5B-1D78-32F2-9FFF-D2E3FBB41C2B> /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/ Versions/A/SpeechRecognition 0x7fff8a0c4000 - 0x7fff8a0d2ff7 libkxld.dylib (??? - ???) <9C937433-A362-3E40-BF71-FDABA986B56C> /usr/lib/system/libkxld.dylib 0x7fff8a2aa000 - 0x7fff8a2b1fff com.apple.NetFS (4.0 - 4.0) /System/Library/Frameworks/ NetFS.framework/Versions/A/NetFS 0x7fff8a2b2000 - 0x7fff8a2b5fff com.apple.help (1.3.2 - 42) /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help 0x7fff8a2c2000 - 0x7fff8a361fff com.apple.LaunchServices (480.21 - 480.21) <6BFADEA9-5BC1-3B53-A013-488EB7F1AB57> /System/ Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/ LaunchServices.framework/Versions/A/LaunchServices 0x7fff8a362000 - 0x7fff8a364ff7 com.apple.print.framework.Print (7.1 - 247.1) <8A4925A5- BAA3-373C-9B5D-03E0270C6B12> /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/ Print 0x7fff8a365000 - 0x7fff8a384fff libresolv.9.dylib (46.0.0 - compatibility 1.0.0) <33263568-E6F3-359C-A4FA-66AD1300F7D4> /usr/lib/ libresolv.9.dylib 0x7fff8a47a000 - 0x7fff8a4a2ff7 com.apple.CoreVideo (1.7 - 70.1) <98F917B2-FB53-3EA3-B548-7E97B38309A7> /System/Library/ Frameworks/CoreVideo.framework/Versions/A/CoreVideo 0x7fff8a53e000 - 0x7fff8a544fff libGFXShared.dylib (??? - ???) <343AE6C0-EB02-333C-8D35-DF6093B92758> /System/Library/ Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib 0x7fff8a545000 - 0x7fff8a55bff7 com.apple.ImageCapture (7.0 - 7.0) <69E6E2E1-777E-332E-8BCF-4F0611517DD0> /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/ A/ImageCapture 0x7fff8a55c000 - 0x7fff8a56afff com.apple.NetAuth (1.0 - 3.0) /System/Library/ PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth 0x7fff8a56b000 - 0x7fff8a598ff7 com.apple.opencl (1.50.63 - 1.50.63) /System/Library/ Frameworks/OpenCL.framework/Versions/A/OpenCL 0x7fff8a5a1000 - 0x7fff8a5a3fff libCVMSPluginSupport.dylib (??? - ???) <61D89F3C-C64D-3733-819F-8AAAE4E2E993> /System/Library/ Frameworks/OpenGL.framework/Versions/A/Libraries/ libCVMSPluginSupport.dylib 0x7fff8a641000 - 0x7fff8a650ff7 com.apple.opengl (1.7.5 - 1.7.5) <2945F1A6-910C-3596-9988-5701B04BD821> /System/Library/ Frameworks/OpenGL.framework/Versions/A/OpenGL 0x7fff8a7fc000 - 0x7fff8a8affff com.apple.CoreText (220.11.0 - ???) <4EA8E2DF-542D-38D5-ADB9-C0DAA73F898B> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ CoreText.framework/Versions/A/CoreText 0x7fff8a8b0000 - 0x7fff8a8bdff7 libbz2.1.0.dylib (1.0.5 - compatibility 1.0.0) <8EDE3492-D916-37B2-A066-3E0F054411FD> /usr/lib/ libbz2.1.0.dylib 0x7fff8a8be000 - 0x7fff8a8c5fff libcopyfile.dylib (85.1.0 - compatibility 1.0.0) <172B1985-F24A-34E9-8D8B-A2403C9A0399> /usr/lib/ system/libcopyfile.dylib 0x7fff8a8c6000 - 0x7fff8acf8fff com.apple.VideoToolbox (1.0 - 705.42) /System/Library/ PrivateFrameworks/VideoToolbox.framework/Versions/A/VideoToolbox 0x7fff8acf9000 - 0x7fff8b48dfef com.apple.CoreAUC (6.11.04 - 6.11.04) /System/Library/ PrivateFrameworks/CoreAUC.framework/Versions/A/CoreAUC 0x7fff8b49d000 - 0x7fff8b4b9ff7 com.apple.GenerationalStorage (1.0 - 125) <31F60175-E38D-3C63-8D95-32CFE7062BCB> /System/Library/ PrivateFrameworks/GenerationalStorage.framework/Versions/A/ GenerationalStorage 0x7fff8b520000 - 0x7fff8b55fff7 libGLImage.dylib (??? - ???) <2D1D8488-EC5F-3229-B983-CFDE0BB37586> /System/Library/Frameworks/ OpenGL.framework/Versions/A/Libraries/libGLImage.dylib 0x7fff8b5e6000 - 0x7fff8b6adff7 com.apple.ColorSync (4.7.0 - 4.7.0) /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ ColorSync.framework/Versions/A/ColorSync 0x7fff8b6ae000 - 0x7fff8b729ff7 com.apple.print.framework.PrintCore (7.1 - 366.1) <3F140DEB-9F87-3672-97CC-F983752581AC> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ PrintCore.framework/Versions/A/PrintCore 0x7fff8b72a000 - 0x7fff8b72ffff com.apple.OpenDirectory (10.7 - 146) <91A87249-6A2F-3F89-A8DE-0E95C0B54A3A> /System/Library/ Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory 0x7fff8b835000 - 0x7fff8b916fff com.apple.CoreServices.OSServices (478.29 - 478.29) /System/Library/Frameworks/ CoreServices.framework/Versions/A/Frameworks/OSServices.framework/ Versions/A/OSServices 0x7fff8b921000 - 0x7fff8bf05fff libBLAS.dylib (??? - ???) /System/Library/Frameworks/ Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/ libBLAS.dylib 0x7fff8bf6e000 - 0x7fff8c188fef com.apple.CoreData (104 - 358.12) <33B1FA75-7970-3751-9DCC-FF809D3E1FA2> /System/Library/ Frameworks/CoreData.framework/Versions/A/CoreData 0x7fff8c1c1000 - 0x7fff8c4ddff7 com.apple.CoreServices.CarbonCore (960.18 - 960.18) <6020C3FB-6125-3EAE-A55D-1E77E38BEDEA> /System/Library/Frameworks/ CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/ Versions/A/CarbonCore 0x7fff8c4de000 - 0x7fff8c87cfef com.apple.MediaToolbox (1.0 - 705.42) /System/Library/ PrivateFrameworks/MediaToolbox.framework/Versions/A/MediaToolbox 0x7fff8c87d000 - 0x7fff8ccaafff libLAPACK.dylib (??? - ???) <4F2E1055-2207-340B-BB45-E4F16171EE0D> /System/Library/Frameworks/ Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/ libLAPACK.dylib 0x7fff8ccb7000 - 0x7fff8cd94fef libsystem_c.dylib (763.12.0 - compatibility 1.0.0) /usr/lib/ system/libsystem_c.dylib 0x7fff8d278000 - 0x7fff8d2e0ff7 com.apple.CoreSymbolication (2.1 - 71) <2ADD7C5B-C8C8-3CA8-8A5C-8FB1C7F6A549> /System/Library/ PrivateFrameworks/CoreSymbolication.framework/Versions/A/ CoreSymbolication 0x7fff8d5cd000 - 0x7fff8d651ff7 com.apple.ApplicationServices.ATS (317.5.0 - ???) /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/ Versions/A/ATS 0x7fff8d974000 - 0x7fff8e087587 com.apple.CoreGraphics (1.600.0 - ???) /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ CoreGraphics.framework/Versions/A/CoreGraphics 0x7fff8e088000 - 0x7fff8e092ff7 liblaunch.dylib (392.18.0 - compatibility 1.0.0) <39EF04F2-7F0C-3435-B785-BF283727FFBD> /usr/lib/ system/liblaunch.dylib 0x7fff8e093000 - 0x7fff8e106fff libstdc++.6.dylib (52.0.0 - compatibility 7.0.0) <6BDD43E4-A4B1-379E-9ED5-8C713653DFF2> /usr/lib/ libstdc++.6.dylib 0x7fff8e107000 - 0x7fff8e107fff com.apple.Cocoa (6.6 - ???) <021D4214-9C23-3CD8-AFB2-F331697A4508> /System/Library/Frameworks/ Cocoa.framework/Versions/A/Cocoa 0x7fff8e108000 - 0x7fff8e108fff com.apple.Carbon (153 - 153) /System/Library/Frameworks/ Carbon.framework/Versions/A/Carbon 0x7fff8e109000 - 0x7fff8e109fff com.apple.ApplicationServices (41 - 41) <03F3FA8F-8D2A-3AB6-A8E3-40B001116339> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/ ApplicationServices 0x7fff8e124000 - 0x7fff8e230fff libcrypto.0.9.8.dylib (44.0.0 - compatibility 0.9.8) <3A8E1F89-5E26-3C8B-B538-81F5D61DBF8A> /usr/lib/ libcrypto.0.9.8.dylib 0x7fff8e231000 - 0x7fff8e293fff com.apple.coreui (1.2.1 - 164.1) /System/Library/ PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI 0x7fff8e2be000 - 0x7fff8e2bfff7 libsystem_blocks.dylib (53.0.0 - compatibility 1.0.0) <8BCA214A-8992-34B2-A8B9-B74DEACA1869> / usr/lib/system/libsystem_blocks.dylib 0x7fff8e2c0000 - 0x7fff8e362ff7 com.apple.securityfoundation (5.0 - 55005) <0D59908C-A61B-389E-AF37-741ACBBA6A94> /System/Library/ Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation 0x7fff8e363000 - 0x7fff8e3cbff7 com.apple.audio.CoreAudio (4.0.1 - 4.0.1) <7966E3BE-376B-371A-A21D-9BD763C0BAE7> /System/Library/ Frameworks/CoreAudio.framework/Versions/A/CoreAudio 0x7fff8e3ce000 - 0x7fff8e4acfff com.apple.ImageIO.framework (3.1.1 - 3.1.1) <13E549F8-5BD6-3BAE-8C33-1D0BD269C081> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ ImageIO.framework/Versions/A/ImageIO 0x7fff8e4ad000 - 0x7fff8e4b2fff libcache.dylib (47.0.0 - compatibility 1.0.0) /usr/lib/ system/libcache.dylib 0x7fff8e546000 - 0x7fff8e54afff libmathCommon.A.dylib (2026.0.0 - compatibility 1.0.0) /usr/lib/system/libmathCommon.A.dylib 0x7fff8e54b000 - 0x7fff8e550ff7 libsystem_network.dylib (??? - ???) <5DE7024E-1D2D-34A2-80F4-08326331A75B> /usr/lib/system/ libsystem_network.dylib 0x7fff8e60d000 - 0x7fff8e640ff7 com.apple.GSS (2.1 - 2.0) <9A2C9736-DA10-367A-B376-2C7A584E6C7A> /System/Library/Frameworks/ GSS.framework/Versions/A/GSS 0x7fff8e641000 - 0x7fff8e642fff libunc.dylib (24.0.0 - compatibility 1.0.0) /usr/lib/ system/libunc.dylib 0x7fff8e7af000 - 0x7fff8f3b0ff7 com.apple.AppKit (6.7.2 - 1138.23) <5CD2C850-4F52-3BA2-BA11-3107DFD2D23C> /System/Library/ Frameworks/AppKit.framework/Versions/C/AppKit 0x7fff8f3b1000 - 0x7fff8f5b3fff libicucore.A.dylib (46.1.0 - compatibility 1.0.0) <38CD6ED3-C8E4-3CCD-89AC-9C3198803101> /usr/lib/ libicucore.A.dylib 0x7fff8f5b4000 - 0x7fff8f5eefe7 com.apple.DebugSymbols (2.1 - 87) <149201BE-A8A4-3E40-AD65-E5194B59162E> /System/Library/ PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols 0x7fff8f5ef000 - 0x7fff8f5f5fff libmacho.dylib (800.0.0 - compatibility 1.0.0) /usr/lib/ system/libmacho.dylib 0x7fff8f5f6000 - 0x7fff8f641ff7 com.apple.SystemConfiguration (1.11.1 - 1.11) /System/Library/ Frameworks/SystemConfiguration.framework/Versions/A/ SystemConfiguration 0x7fff8f666000 - 0x7fff8f76bff7 libFontParser.dylib (??? - ???) /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ ATS.framework/Versions/A/Resources/libFontParser.dylib 0x7fff8f76c000 - 0x7fff8f7c7ff7 com.apple.HIServices (1.10 - ???) /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ HIServices.framework/Versions/A/HIServices 0x7fff8f7c8000 - 0x7fff8f84bfef com.apple.Metadata (10.7.0 - 627.20) /System/Library/ Frameworks/CoreServices.framework/Versions/A/Frameworks/ Metadata.framework/Versions/A/Metadata 0x7fff8f84c000 - 0x7fff8f8e2ff7 libvMisc.dylib (325.4.0 - compatibility 1.0.0) <642D8D54-F9F5-3FBB-A96C-EEFE94C6278B> /System/ Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ vecLib.framework/Versions/A/libvMisc.dylib 0x7fff8fd74000 - 0x7fff8fdafff7 libsystem_info.dylib (??? - ???) <9C8C2DCB-96DB-3471-9DCE-ADCC26BE2DD4> /usr/lib/system/ libsystem_info.dylib 0x7fff8fdb0000 - 0x7fff8feb3fff libsqlite3.dylib (9.6.0 - compatibility 9.0.0) <7F60B0FF-4946-3639-89AB-B540D318B249> /usr/lib/ libsqlite3.dylib 0x7fff8feb4000 - 0x7fff8ff29ff7 libc++.1.dylib (19.0.0 - compatibility 1.0.0) /usr/lib/ libc++.1.dylib 0x7fff8ff2a000 - 0x7fff8ff3ffff com.apple.speech.synthesis.framework (4.0.74 - 4.0.74) /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ SpeechSynthesis.framework/Versions/A/SpeechSynthesis 0x7fff8ff40000 - 0x7fff8ff82ff7 libcommonCrypto.dylib (55010.0.0 - compatibility 1.0.0) /usr/lib/system/libcommonCrypto.dylib 0x7fff902d0000 - 0x7fff902e3ff7 libCRFSuite.dylib (??? - ???) <034D4DAA-63F0-35E4-BCEF-338DD7A453DD> /usr/lib/libCRFSuite.dylib 0x7fff902e4000 - 0x7fff9034bff7 com.apple.Symbolication (1.2 - 89) /System/Library/ PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication 0x7fff90769000 - 0x7fff9076cfff libCoreVMClient.dylib (??? - ???) /System/Library/ Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib 0x7fff9076d000 - 0x7fff909e0fff com.apple.CoreImage (7.82 - 1.0.1) <282801B6-5D80-3E2C-88A4-00FE29906D5A> /System/Library/ Frameworks/QuartzCore.framework/Versions/A/Frameworks/ CoreImage.framework/Versions/A/CoreImage 0x7fff90aaf000 - 0x7fff90afdfff libauto.dylib (??? - ???) /usr/lib/libauto.dylib 0x7fff90b0f000 - 0x7fff90b11fff com.apple.TrustEvaluationAgent (2.0 - 1) <1F31CAFF- C1C6-33D3-94E9-11B721761DDF> /System/Library/PrivateFrameworks/ TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent 0x7fff90b12000 - 0x7fff90b66ff7 com.apple.ScalableUserInterface (1.0 - 1) <1873D7BE-2272-31A1-8F85- F70C4D706B3B> /System/Library/Frameworks/QuartzCore.framework/Versions/ A/Frameworks/ScalableUserInterface.framework/Versions/A/ ScalableUserInterface 0x7fff90ea9000 - 0x7fff90eaffff com.apple.DiskArbitration (2.4.1 - 2.4.1) /System/Library/ Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration 0x7fff90f05000 - 0x7fff90f5cfff libTIFF.dylib (??? - ???) /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libTIFF.dylib 0x7fff90f5d000 - 0x7fff90f61fff libdyld.dylib (195.5.0 - compatibility 1.0.0) /usr/lib/ system/libdyld.dylib 0x7fff90fa3000 - 0x7fff90fa4fff libDiagnosticMessagesClient.dylib (??? - ???) <3DCF577B-F126-302B- BCE2-4DB9A95B8598> /usr/lib/libDiagnosticMessagesClient.dylib 0x7fff90fa9000 - 0x7fff912cdfff com.apple.HIToolbox (1.8 - ???) /System/Library/ Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/ Versions/A/HIToolbox 0x7fff912ce000 - 0x7fff915e7ff7 com.apple.Foundation (6.7.1 - 833.20) /System/Library/ Frameworks/Foundation.framework/Versions/C/Foundation 0x7fff91632000 - 0x7fff9164fff7 com.apple.openscripting (1.3.3 - ???) /System/Library/ Frameworks/Carbon.framework/Versions/A/Frameworks/ OpenScripting.framework/Versions/A/OpenScripting 0x7fff91650000 - 0x7fff916bafff com.apple.framework.IOKit (2.0 - ???) <87D55F1D-CDB5-3D13-A5F9-98EA4E22F8EE> /System/Library/ Frameworks/IOKit.framework/Versions/A/IOKit 0x7fff91704000 - 0x7fff91709fff libpam.2.dylib (3.0.0 - compatibility 3.0.0) /usr/lib/ libpam.2.dylib 0x7fff9170a000 - 0x7fff91744fff libncurses.5.4.dylib (5.4.0 - compatibility 5.4.0) <387DE593-9CC5-38C7-911B-A5F2264D34F2> /usr/lib/ libncurses.5.4.dylib 0x7fff91745000 - 0x7fff91762ff7 libxpc.dylib (77.17.0 - compatibility 1.0.0) <72A16104-2F23-3C22-B474-1953F06F9376> /usr/lib/ system/libxpc.dylib 0x7fff91799000 - 0x7fff917e9fff com.apple.CoreMediaIO (210.0 - 3180) <13374EA4-83BE-3407-B9DD-D199426D0E7A> /System/Library/ Frameworks/CoreMediaIO.framework/Versions/A/CoreMediaIO 0x7fff917ea000 - 0x7fff9185afff com.apple.datadetectorscore (3.0 - 179.4) <2A822A13-94B3-3A43-8724-98FDF698BB12> /System/Library/ PrivateFrameworks/DataDetectorsCore.framework/Versions/A/ DataDetectorsCore 0x7fff9185b000 - 0x7fff9185bfff com.apple.Accelerate.vecLib (3.7 - vecLib 3.7) /System/ Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ vecLib.framework/Versions/A/vecLib 0x7fff9185c000 - 0x7fff918affff com.apple.AppleVAFramework (5.0.14 - 5.0.14) <45159B9E-05BF-35B2-AF76-D933490FBFB1> /System/ Library/PrivateFrameworks/AppleVA.framework/Versions/A/AppleVA 0x7fff918b0000 - 0x7fff918b7ff7 com.apple.CommerceCore (1.0 - 17) /System/Library/ PrivateFrameworks/CommerceKit.framework/Versions/A/Frameworks/ CommerceCore.framework/Versions/A/CommerceCore 0x7fff918d8000 - 0x7fff91917fff com.apple.AE (527.7 - 527.7) /System/Library/Frameworks/ CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/ AE 0x7fff91953000 - 0x7fff91956fff libRadiance.dylib (??? - ???) /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libRadiance.dylib 0x7fff91957000 - 0x7fff9195ffff libsystem_dnssd.dylib (??? - ???) <407A48F3-64A0-348B-88E6-70CECD3D0D67> /usr/lib/system/ libsystem_dnssd.dylib 0x7fff91960000 - 0x7fff91969ff7 libsystem_notify.dylib (80.1.0 - compatibility 1.0.0) / usr/lib/system/libsystem_notify.dylib 0x7fff9196a000 - 0x7fff91a4edef libobjc.A.dylib (228.0.0 - compatibility 1.0.0) /usr/lib/ libobjc.A.dylib 0x7fff91c8c000 - 0x7fff91cccff7 libcups.2.dylib (2.9.0 - compatibility 2.0.0) /usr/lib/ libcups.2.dylib 0x7fff91ccd000 - 0x7fff91cd2fff libcompiler_rt.dylib (6.0.0 - compatibility 1.0.0) <98ECD5F6-E85C-32A5-98CD-8911230CB66A> /usr/lib/ system/libcompiler_rt.dylib 0x7fff91cd3000 - 0x7fff91cd3fff libkeymgr.dylib (23.0.0 - compatibility 1.0.0) <61EFED6A-A407-301E-B454-CD18314F0075> /usr/lib/ system/libkeymgr.dylib 0x7fff91d28000 - 0x7fff91d3aff7 libbsm.0.dylib (??? - ???) <349BB16F-75FA-363F-8D98-7A9C3FA90A0D> /usr/lib/libbsm.0.dylib 0x7fff91d3b000 - 0x7fff91d55fff com.apple.CoreMediaAuthoring (2.0 - 889) <99D8E4C6-DDD3-3B0C-BBFB-A513877F10F6> /System/Library/ PrivateFrameworks/CoreMediaAuthoring.framework/Versions/A/ CoreMediaAuthoring 0x7fff91d56000 - 0x7fff91e6eff7 com.apple.DesktopServices (1.6.1 - 1.6.1) <4418EAA6-7163-3A77-ABD3-F8289796C81A> /System/Library/ PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/ DesktopServicesPriv 0x7fff91e6f000 - 0x7fff91e9aff7 libxslt.1.dylib (3.24.0 - compatibility 3.0.0) <8051A3FC-7385-3EA9-9634-78FC616C3E94> /usr/lib/ libxslt.1.dylib 0x7fff91f88000 - 0x7fff91f89ff7 libremovefile.dylib (21.0.0 - compatibility 1.0.0) /usr/lib/ system/libremovefile.dylib 0x7fff91f8a000 - 0x7fff91fa1fff com.apple.CFOpenDirectory (10.7 - 144) <9709423E-8484-3B26-AAE8-EF58D1B8FB3F> /System/Library/ Frameworks/OpenDirectory.framework/Versions/A/Frameworks/ CFOpenDirectory.framework/Versions/A/CFOpenDirectory 0x7fff920a1000 - 0x7fff920a5ff7 com.apple.CommonPanels (1.2.5 - 94) <0BB2C436-C9D5-380B-86B5-E355A7711259> /System/Library/ Frameworks/Carbon.framework/Versions/A/Frameworks/ CommonPanels.framework/Versions/A/CommonPanels 0x7fff92130000 - 0x7fff92142ff7 libz.1.dylib (1.2.5 - compatibility 1.0.0) <30CBEF15-4978-3DED-8629-7109880A19D4> /usr/lib/ libz.1.dylib 0x7fff92143000 - 0x7fff9260afff FaceCoreLight (1.4.7 - compatibility 1.0.0) /System/ Library/PrivateFrameworks/FaceCoreLight.framework/Versions/A/ FaceCoreLight 0x7fff9260b000 - 0x7fff92611fff IOSurface (??? - ???) <2114359C-D839-3855-8735-BBAA2704DB93> /System/Library/Frameworks/ IOSurface.framework/Versions/A/IOSurface 0x7fff92612000 - 0x7fff92672fff libvDSP.dylib (325.4.0 - compatibility 1.0.0) <3A7521E6-5510-3FA7-AB65-79693A7A5839> /System/ Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ vecLib.framework/Versions/A/libvDSP.dylib 0x7fff92697000 - 0x7fff927f0fff com.apple.audio.toolbox.AudioToolbox (1.7.1 - 1.7.1) <4877267E- F736-3019-85D3-40A32A042A80> /System/Library/Frameworks/ AudioToolbox.framework/Versions/A/AudioToolbox 0x7fff927f1000 - 0x7fff927fcfff com.apple.CommonAuth (2.1 - 2.0) /System/Library/ PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth 0x7fff92802000 - 0x7fff92828ff7 com.apple.framework.familycontrols (3.0 - 300) <41A6DFC2- EAF5-390A-83A1-C8832528705C> /System/Library/PrivateFrameworks/ FamilyControls.framework/Versions/A/FamilyControls 0x7fff92c13000 - 0x7fff92cadff7 com.apple.SearchKit (1.4.0 - 1.4.0) <4E70C394-773E-3A4B-A93C-59A88ABA9509> /System/Library/ Frameworks/CoreServices.framework/Versions/A/Frameworks/ SearchKit.framework/Versions/A/SearchKit 0x7fff92cae000 - 0x7fff92caefff com.apple.audio.units.AudioUnit (1.7.1 - 1.7.1) <04C10813- CCE5-3333-8C72-E8E35E417B3B> /System/Library/Frameworks/ AudioUnit.framework/Versions/A/AudioUnit 0x7fff92caf000 - 0x7fff92cdcfe7 libSystem.B.dylib (159.1.0 - compatibility 1.0.0) <095FDD3C-3961-3865-A59B-A5B0A4B8B923> /usr/lib/ libSystem.B.dylib 0x7fff92ea3000 - 0x7fff92f47fef com.apple.ink.framework (1.3.2 - 110) /System/Library/ Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/ Versions/A/Ink 0x7fff92f48000 - 0x7fff92f6cfff com.apple.Kerberos (1.0 - 1) <1F826BCE-DA8F-381D-9C4C-A36AA0EA1CB9> /System/Library/Frameworks/ Kerberos.framework/Versions/A/Kerberos 0x7fff92f6d000 - 0x7fff92f6efff libdnsinfo.dylib (395.6.0 - compatibility 1.0.0) <718A135F-6349-354A-85D5-430B128EFD57> /usr/lib/ system/libdnsinfo.dylib 0x7fff92f6f000 - 0x7fff92f8cfff libPng.dylib (??? - ???) <3C70A94C-9442-3E11-AF51-C1B0EF81680E> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libPng.dylib 0x7fff92f8d000 - 0x7fff92fb6fff libJPEG.dylib (??? - ???) <64D079F9-256A-323B-A837-84628B172F21> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libJPEG.dylib 0x7fff92fdf000 - 0x7fff92fe2ff7 com.apple.securityhi (4.0 - 1) /System/Library/Frameworks/ Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/ SecurityHI 0x7fff93022000 - 0x7fff93046ff7 com.apple.RemoteViewServices (1.2 - 39) <862849C8-84C1-32A1-B87E-B29E74778C9F> /System/Library/ PrivateFrameworks/RemoteViewServices.framework/Versions/A/ RemoteViewServices 0x7fff93057000 - 0x7fff9305dff7 libunwind.dylib (30.0.0 - compatibility 1.0.0) <1E9C6C8C-CBE8-3F4B-A5B5-E03E3AB53231> /usr/lib/ system/libunwind.dylib 0x7fff93797000 - 0x7fff937deff7 com.apple.CoreMedia (1.0 - 705.42) /System/Library/ Frameworks/CoreMedia.framework/Versions/A/CoreMedia 0x7fff93b2f000 - 0x7fff93b82fff libFontRegistry.dylib (??? - ???) <57FBD85F-41A6-3DB9-B5F4-FCC6B260F1AD> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ ATS.framework/Versions/A/Resources/libFontRegistry.dylib 0x7fff93e07000 - 0x7fff93e09fff libquarantine.dylib (36.0.0 - compatibility 1.0.0) <4C3BFBC7-E592-3939-B376-1C2E2D7C5389> /usr/lib/ system/libquarantine.dylib 0x7fff93e5a000 - 0x7fff93f93fef com.apple.vImage (5.1 - 5.1) /System/Library/Frameworks/ Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/ vImage 0x7fff93fbc000 - 0x7fff9400eff7 libGLU.dylib (??? - ???) <3C9153A0-8499-3DC0-AAA4-9FA6E488BE13> /System/Library/Frameworks/ OpenGL.framework/Versions/A/Libraries/libGLU.dylib 0x7fff9400f000 - 0x7fff9401aff7 libc++abi.dylib (14.0.0 - compatibility 1.0.0) <8FF3D766-D678-36F6-84AC-423C878E6D14> /usr/lib/ libc++abi.dylib 0x7fff9412d000 - 0x7fff9423afff libJP2.dylib (??? - ???) <6052C973-9354-35CB-AAB9-31D00D8786F9> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libJP2.dylib 0x7fff95175000 - 0x7fff9519cfff com.apple.PerformanceAnalysis (1.10 - 10) <2A058167-292E-3C3A-B1F8-49813336E068> /System/Library/ PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/ PerformanceAnalysis 0x7fff951a0000 - 0x7fff951a0fff com.apple.vecLib (3.7 - vecLib 3.7) <9A58105C-B36E-35B5-812C-4ED693F2618F> /System/Library/ Frameworks/vecLib.framework/Versions/A/vecLib 0x7fff951a1000 - 0x7fff951b5ff7 com.apple.LangAnalysis (1.7.0 - 1.7.0) <04C31EF0-912A-3004-A08F-CEC27030E0B2> /System/Library/ Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ LangAnalysis.framework/Versions/A/LangAnalysis 0x7fff951b6000 - 0x7fff9538afff com.apple.CoreFoundation (6.7.1 - 635.15) /System/ Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x7fff953a0000 - 0x7fff95506fff com.apple.CFNetwork (520.2.5 - 520.2.5) <406712D9-3F0C-3763-B4EB-868D01F1F042> /System/Library/ Frameworks/CoreServices.framework/Versions/A/Frameworks/ CFNetwork.framework/Versions/A/CFNetwork 0x7fff95507000 - 0x7fff95691ff7 com.apple.QTKit (7.7.1 - 2306) /System/Library/ Frameworks/QTKit.framework/Versions/A/QTKit 0x7fff9578d000 - 0x7fff957cefff com.apple.QD (3.12 - ???) <4F3C5629-97C7-3E55-AF3C-ACC524929DA2> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/QD.framework/ Versions/A/QD 0x7fff957cf000 - 0x7fff957d4fff libGIF.dylib (??? - ???) <393E2DB5-9479-39A6-A75A-B5F20B852532> /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ Versions/A/Resources/libGIF.dylib 0x7fff957d5000 - 0x7fff957f5fff libsystem_kernel.dylib (1699.22.81 - compatibility 1.0.0) /usr/lib/system/ libsystem_kernel.dylib 0x7fff957f6000 - 0x7fff958ebfff libiconv.2.dylib (7.0.0 - compatibility 7.0.0) <5C40E880-0706-378F-B864-3C2BD922D926> /usr/lib/ libiconv.2.dylib 0x7fff95960000 - 0x7fff95961fff liblangid.dylib (??? - ???) /usr/lib/liblangid.dylib 0x7fff95962000 - 0x7fff95992ff7 com.apple.DictionaryServices (1.2.1 - 158.2) <3FC86118-7553-38F7-8916-B329D2E94476> /System/Library/ Frameworks/CoreServices.framework/Versions/A/Frameworks/ DictionaryServices.framework/Versions/A/DictionaryServices 0x7fff95b46000 - 0x7fff95b5cfff libGL.dylib (??? - ???) <6A473BF9-4D35-34C6-9F8B-86B68091A9AF> /System/Library/Frameworks/ OpenGL.framework/Versions/A/Libraries/libGL.dylib 0x7fff96239000 - 0x7fff963d8fff com.apple.QuartzCore (1.7 - 270.0) /System/Library/ Frameworks/QuartzCore.framework/Versions/A/QuartzCore 0x7fff963d9000 - 0x7fff963f0fff com.apple.MultitouchSupport.framework (220.62.1 - 220.62.1) /System/Library/ PrivateFrameworks/MultitouchSupport.framework/Versions/A/ MultitouchSupport 0x7fff963f3000 - 0x7fff966cbff7 com.apple.security (7.0 - 55010) <93713FF4-FE86-3B4C-8150-5FCC7F3320C8> /System/Library/ Frameworks/Security.framework/Versions/A/Security 0x7fff9677e000 - 0x7fff96880ff7 libxml2.2.dylib (10.3.0 - compatibility 10.0.0) /usr/lib/ libxml2.2.dylib 0x7fff969c5000 - 0x7fff96a4aff7 com.apple.Heimdal (2.1 - 2.0) /System/Library/ PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal 0x7fff96a4b000 - 0x7fff96a4bfff com.apple.Accelerate (1.7 - Accelerate 1.7) <82DDF6F5-FBC3-323D-B71D-CF7ABC5CF568> /System/Library/ Frameworks/Accelerate.framework/Versions/A/Accelerate 0x7fff96bd7000 - 0x7fff96bd7fff com.apple.CoreServices (53 - 53) <043C8026-8EDD-3241-B090-F589E24062EF> /System/Library/Frameworks/ CoreServices.framework/Versions/A/CoreServices 0x7fff96bd8000 - 0x7fff96be6fff libdispatch.dylib (187.7.0 - compatibility 1.0.0) <712AAEAC-AD90-37F7-B71F-293FF8AE8723> /usr/lib/ system/libdispatch.dylib 0x7fff96be7000 - 0x7fff96be8fff libsystem_sandbox.dylib (??? - ???) <8D14139B-B671-35F4-9E5A-023B4C523C38> /usr/lib/system/ libsystem_sandbox.dylib External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 371 thread_create: 1 thread_set_state: 0 VM Region Summary: ReadOnly portion of Libraries: Total=169.5M resident=106.9M(63%) swapped_out_or_unallocated=62.6M(37%) Writable regions: Total=19.8M written=2360K(12%) resident=3028K(15%) swapped_out=0K(0%) unallocated=16.8M(85%) REGION TYPE VIRTUAL =========== ======= MALLOC 10.6M MALLOC guard page 16K STACK GUARD 56.0M Stack 8192K __CI_BITMAP 80K __DATA 14.2M __IMAGE 1256K __LINKEDIT 49.4M __TEXT 120.0M __UNICODE 544K shared memory 12K =========== ======= TOTAL 260.2M Model: MacBook5,1, BootROM MB51.007D.B03, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.32f8 Graphics: NVIDIA GeForce 9400M, NVIDIA GeForce 9400M, PCI, 256 MB Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1067 MHz, 0x80CE, 0x4D34373142353637334448312D4346382020 Memory Module: BANK 0/DIMM1, 2 GB, DDR3, 1067 MHz, 0x80CE, 0x4D34373142353637334448312D4346382020 AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), Broadcom BCM43xx 1.0 (5.100.98.75.18) Bluetooth: Version 4.0.1f4, 2 service, 18 devices, 1 incoming serial ports Network Service: Wi-Fi, AirPort, en1 Serial ATA Device: FUJITSU MHZ2250BH FFS G1, 250.06 GB Serial ATA Device: HL-DT-ST DVDRW GS21N USB Device: Built-in iSight, apple_vendor_id, 0x8507, 0x24400000 / 2 USB Device: Apple Internal Keyboard / Trackpad, apple_vendor_id, 0x0237, 0x04600000 / 3 USB Device: IR Receiver, apple_vendor_id, 0x8242, 0x04500000 / 2 USB Device: BRCM2046 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0x06100000 / 2 USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x8213, 0x06110000 / 5 From pedro.h.souto at gmail.com Wed Nov 30 06:36:15 2011 From: pedro.h.souto at gmail.com (Pedro Henrique G. Souto) Date: Wed, 30 Nov 2011 09:36:15 -0200 Subject: Total newbie question: Best practice In-Reply-To: <408F64D89899604FB24015E64E10490C179CAB10@KCHJEXMB02.kpit.com> References: <408F64D89899604FB24015E64E10490C179CAB10@KCHJEXMB02.kpit.com> Message-ID: <4ED6152F.3020307@gmail.com> On 30/11/2011 06:50, Shambhu Rajak wrote: > Collins Congratulations for your first step into Python Programming. > You can call them script or programs(not necessarily but depends on what your coding for). > Yaa..it's always a good practice to call it through main(), but it doesn't really matter you > can call the method in way.... > > Regards, > Shambhu > > -----Original Message----- > From: Colin Higwell [mailto:colinh at somewhere.invalid] > Sent: 30/11/2011 1:37 AM > To: python-list at python.org > Subject: Total newbie question: Best practice > > Hi, > > I am just starting to learn Python (I have been at it only a few hours), > so please bear with me. I have a few very small scripts (do you call them > scripts or programs?) which work properly, and produce the results > intended. > > However, they are monolithic in nature; i.e. they begin at the beginning > and finish at the end. Having done a little reading, I note that it seems > to be quite common to have a function main() at the start (which in turn > calls other functions as appropriate), and then to call main() to do the > work. > > Is that standard best practice? > > Thanks Congratulations on becoming a Pythonist! Like Shambhu said, it doesn't matter where do you put the code, but is interesting to have a main() function when you have a program, and you want to differentiate if it is running directly (i.e. python program.py) or if it is running as a module, imported by other program (i.e. import program). To do so, you do this: main(): # blablabla if __name__ == '__main__': main() If the program is running directly, the variable __name__ will be '__main__', if not, __name__ will be the name of the module ('program', in this case). Att; Pedro From durumdara at gmail.com Wed Nov 30 07:08:13 2011 From: durumdara at gmail.com (durumdara) Date: Wed, 30 Nov 2011 04:08:13 -0800 (PST) Subject: Python 3 - xml - crlf handling problem Message-ID: <3aae0b18-a194-444f-a2fc-da156204bd95@20g2000yqa.googlegroups.com> Hi! As I see that XML parsing is "wrong" in Python. I must use predefined XML files, parsing them, extending them, and produce some result. But as I see that in Windows this is working wrong. When the predefined XMLs are "formatted" (prettied) with CRLFs, then the parser keeps these plus LF characters (not handle the logic that CR = LF = CRLF), and it is appearing in the new result too. xo = parse('test_original.xml') de = xo.documentElement de.setAttribute('b', "2") b = xo.toxml('utf-8') f = open('test_original2.xml', 'wb') f.write(b) f.close() And: if I used text elements, this can extend the information with plus characters and make wrong xml... I can use only "myowngenerated", and not prettied xmls because of this problem! Is this normal? Thanks for your read: dd From ndbecker2 at gmail.com Wed Nov 30 07:32:39 2011 From: ndbecker2 at gmail.com (Neal Becker) Date: Wed, 30 Nov 2011 07:32:39 -0500 Subject: order independent hash? Message-ID: I like to hash a list of words (actually, the command line args of my program) in such a way that different words will create different hash, but not sensitive to the order of the words. Any ideas? From mail at timgolden.me.uk Wed Nov 30 07:38:14 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 30 Nov 2011 12:38:14 +0000 Subject: order independent hash? In-Reply-To: References: Message-ID: <4ED623B6.602@timgolden.me.uk> On 30/11/2011 12:32, Neal Becker wrote: > I like to hash a list of words (actually, the command line args of my program) > in such a way that different words will create different hash, but not sensitive > to the order of the words. Any ideas? How about? hash (frozenset ("hello world".split ())) TJG From __peter__ at web.de Wed Nov 30 07:47:13 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Nov 2011 13:47:13 +0100 Subject: order independent hash? References: Message-ID: Neal Becker wrote: > I like to hash a list of words (actually, the command line args of my > program) in such a way that different words will create different hash, > but not sensitive to the order of the words. Any ideas? You mean a typical python hash value which would be /likely/ to differ for different lists and /guaranteed/ to be equal for equal lists is not good enough? Because that would be easy: args = sys.argv[1:] hash(tuple(sorted(args))) # consider duplicate args hash(frozenset(args)) # ignore duplicate args From lists at cheimes.de Wed Nov 30 07:58:41 2011 From: lists at cheimes.de (Christian Heimes) Date: Wed, 30 Nov 2011 13:58:41 +0100 Subject: Python crashes on segmentation error In-Reply-To: <8bffed0f-1050-418a-834d-f7060a899ab7@h5g2000yqk.googlegroups.com> References: <8bffed0f-1050-418a-834d-f7060a899ab7@h5g2000yqk.googlegroups.com> Message-ID: Am 30.11.2011 11:42, schrieb Ben Richardson: > Python crashes every time i run the following command? > >>>> import cv > Segmentation fault: 11 > > Python quit unexpectedly - any help would be greatly appreciated - > thankyou in advance :) > > Here is crash report? [...] > > Thread 0 Crashed:: Dispatch queue: com.apple.main-thread > 0 ??? 000000000000000000 0 + 0 > 1 org.python.python 0x00000001006c7885 PyImport_Import > + 121 > 2 org.python.python 0x00000001006c7a1e > PyImport_ImportModule + 32 > 3 cv.so 0x00000001004f5082 initcv + 18 > 4 org.python.python 0x00000001000dc071 > _PyImport_LoadDynamicModule + 177 It looks like you have a faulty 3rd party library with an extension module called cv.so that is causing the segfault. The segfault occurs either inside or during the import of the cv module. initcv() is the init function of the cv module that is called automatically during the import. Christian From stefan_ml at behnel.de Wed Nov 30 08:47:59 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 30 Nov 2011 14:47:59 +0100 Subject: Python 3 - xml - crlf handling problem In-Reply-To: <3aae0b18-a194-444f-a2fc-da156204bd95@20g2000yqa.googlegroups.com> References: <3aae0b18-a194-444f-a2fc-da156204bd95@20g2000yqa.googlegroups.com> Message-ID: durumdara, 30.11.2011 13:08: > As I see that XML parsing is "wrong" in Python. You didn't say what you are using for parsing, but from your example, it appears likely that you are using the xml.dom.minidom module. > I must use predefined XML files, parsing them, extending them, and > produce some result. > > But as I see that in Windows this is working wrong. > > When the predefined XMLs are "formatted" (prettied) with CRLFs, then > the parser keeps these plus LF characters (not handle the logic that > CR = LF = CRLF), and it is appearing in the new result too. I assume that you are referring to XML's newline normalisation algorithm? That should normally be handled by the parser, which, in the case of minidom, is usually expat. And I seriously doubt that expat has a problem with something as basic as newline normalisation. Did you verify that the newlines are really not being converted by the parser? From your example, I can only see that you are serialising the XML tree back into a file, which may or may not alter the line endings by itself. Instead, take a look at the text content in the tree right after parsing to see how line endings look at that level. > xo = parse('test_original.xml') > de = xo.documentElement > de.setAttribute('b', "2") > b = xo.toxml('utf-8') > f = open('test_original2.xml', 'wb') > f.write(b) > f.close() This doesn't do any pretty printing, though, in case that's what you were really after (which appears likely according to your comments). > And: if I used text elements, this can extend the information with > plus characters and make wrong xml... Sorry, I don't understand this sentence. > I can use only "myowngenerated", and not prettied xmls because of this > problem! Then what is the actual problem? Do you get an error somewhere? And if so, could you paste the exact error message and describe what you do to produce it? The mere fact that the line endings use the normal platform specific representation doesn't seem like a problem to me. Stefan From miki.tebeka at gmail.com Wed Nov 30 09:55:10 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 30 Nov 2011 06:55:10 -0800 (PST) Subject: Converting MS Access DB to Postgres or MySQL for ORM support with SQLalchemy In-Reply-To: References: Message-ID: <7671543.1221.1322664911105.JavaMail.geo-discussion-forums@yqny18> You can read data using win32com (ADODB?) and then write it to the desired database using the right package (psycopg2 ...). See example for reading data at http://mail.python.org/pipermail/python-win32/2006-March/004420.html From miki.tebeka at gmail.com Wed Nov 30 09:55:10 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 30 Nov 2011 06:55:10 -0800 (PST) Subject: Converting MS Access DB to Postgres or MySQL for ORM support with SQLalchemy In-Reply-To: References: Message-ID: <7671543.1221.1322664911105.JavaMail.geo-discussion-forums@yqny18> You can read data using win32com (ADODB?) and then write it to the desired database using the right package (psycopg2 ...). See example for reading data at http://mail.python.org/pipermail/python-win32/2006-March/004420.html From alec.taylor6 at gmail.com Wed Nov 30 10:19:31 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 02:19:31 +1100 Subject: Defining a new base-type in Python based off Hexavigesimal Message-ID: Good evening, I have defined a new numbering structure for certain mathematical advantages. How do I implement this in Python, or would I be better off writing this in C or C++? Ultra concise definition: http://i42.tinypic.com/af7w4h.png LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI Thanks for all suggestions, Alec Taylor From steve+comp.lang.python at pearwood.info Wed Nov 30 10:38:58 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 30 Nov 2011 15:38:58 GMT Subject: Defining a new base-type in Python based off Hexavigesimal References: Message-ID: <4ed64e12$0$29988$c3e8da3$5496439d@news.astraweb.com> On Thu, 01 Dec 2011 02:19:31 +1100, Alec Taylor wrote: > Good evening, > > I have defined a new numbering structure for certain mathematical > advantages. > > How do I implement this in Python, or would I be better off writing this > in C or C++? > > Ultra concise definition: http://i42.tinypic.com/af7w4h.png Care to translate it into English? Then translate the English into pseudo-code. And the pseudo-code into Python. Then, if and only if the Python version is too slow, translate it into C. And now you are done! -- Steven From __peter__ at web.de Wed Nov 30 11:00:55 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Nov 2011 17:00:55 +0100 Subject: Defining a new base-type in Python based off Hexavigesimal References: Message-ID: Alec Taylor wrote: > I have defined a new numbering structure for certain mathematical > advantages. > > How do I implement this in Python, or would I be better off writing > this in C or C++? > > Ultra concise definition: http://i42.tinypic.com/af7w4h.png > LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI > > Thanks for all suggestions, I don't know if that helps you with your project but Python already understands some hexavigesimal: >>> int("fool", 26) 280509 From ian.g.kelly at gmail.com Wed Nov 30 11:18:39 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 30 Nov 2011 09:18:39 -0700 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor wrote: > Good evening, > > I have defined a new numbering structure for certain mathematical advantages. > > How do I implement this in Python, or would I be better off writing > this in C or C++? > > Ultra concise definition: http://i42.tinypic.com/af7w4h.png > LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI > > Thanks for all suggestions, So if I am understanding your definition correctly your hexavigesimals are ordered like this? 0, 1, ..., 9, A, B, ..., P, 0A, 0B, ..., 0P, 1A, 1B, ..., 1P, ..., 9A, 9B, ..., 9P, A0, A1, ..., A9, B0, B1, ..., B9, ..., P0, P1, ..., P9 And that's it, since your constraints preclude anything with more than 2 digits? From alec.taylor6 at gmail.com Wed Nov 30 11:26:53 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 03:26:53 +1100 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 3:18 AM, Ian Kelly wrote: > On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor wrote: >> Good evening, >> >> I have defined a new numbering structure for certain mathematical advantages. >> >> How do I implement this in Python, or would I be better off writing >> this in C or C++? >> >> Ultra concise definition: http://i42.tinypic.com/af7w4h.png >> LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI >> >> Thanks for all suggestions, > > So if I am understanding your definition correctly your hexavigesimals > are ordered like this? > > 0, 1, ..., 9, A, B, ..., P, > > 0A, 0B, ..., 0P, > 1A, 1B, ..., 1P, > ..., > 9A, 9B, ..., 9P, > > A0, A1, ..., A9, > B0, B1, ..., B9, > ..., > P0, P1, ..., P9 > > And that's it, since your constraints preclude anything with more than 2 digits? To put it simply: I want a hexavigesimal of length n where each element contains at least one letter {A, B, ..., P} and one number {0, 1, 2, ... }. (unless n is less than 2, in which case only one of those constraints need to be met) and I want addition only for incrementing the element. Why do I want all this I hear you ask? - For use as a unique-identifier. I want a unique-ID of size 3. (3 positions, i.e. P0A) Any suggestions on how to implement this in python would be appreciated. Thanks, Alec Taylor From jeanpierreda at gmail.com Wed Nov 30 12:08:24 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 30 Nov 2011 12:08:24 -0500 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: <4ed64e12$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ed64e12$0$29988$c3e8da3$5496439d@news.astraweb.com> Message-ID: > Care to translate it into English? > > Then translate the English into pseudo-code. And the pseudo-code into > Python. Then, if and only if the Python version is too slow, translate it > into C. And now you are done! Mathematical English is pseudocode. Related: all theorems are also programs and vice versa. That said, I don't understand the notation either. What's \mathbb{M}? What does it mean ti be "in" some natural number n? (Are you using a set theoretic definition of natural numbers: e.g. x in y iff x <= y ?) Devin On Wed, Nov 30, 2011 at 10:38 AM, Steven D'Aprano wrote: > On Thu, 01 Dec 2011 02:19:31 +1100, Alec Taylor wrote: > >> Good evening, >> >> I have defined a new numbering structure for certain mathematical >> advantages. >> >> How do I implement this in Python, or would I be better off writing this >> in C or C++? >> >> Ultra concise definition: http://i42.tinypic.com/af7w4h.png > > Care to translate it into English? > > Then translate the English into pseudo-code. And the pseudo-code into > Python. Then, if and only if the Python version is too slow, translate it > into C. And now you are done! > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > From egg1nog at gmail.com Wed Nov 30 12:10:09 2011 From: egg1nog at gmail.com (Michael Hennebry) Date: Wed, 30 Nov 2011 09:10:09 -0800 (PST) Subject: tp_new, tp_alloc, tp_init Message-ID: I've been reading about writing extension types in C and am rather fuzzy about the relationship between tp_new, tp_alloc and tp_init. Most especially, why tp_new? It seems to me that tp_alloc and tp_init would be sufficient. Most of my reading has been in the Noddy and Shoddy portions of docs.python.,org . From andrea.crotti.0 at gmail.com Wed Nov 30 13:03:35 2011 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 30 Nov 2011 18:03:35 +0000 Subject: python 2.5 and ast In-Reply-To: <4ED4E35E.6090405@gmail.com> References: <4ED37475.3050709@gmail.com> <4ED457C5.2020407@davea.name> <4ed4c2ce$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ED4E35E.6090405@gmail.com> Message-ID: <4ED66FF7.1030104@gmail.com> Another thing about the AST, I am having fun trying to for example list out all the unused imports. I have already a visitor which works quite nicely I think, but now I would like to get a way to find all the unused imports, so I need more visitors that find out all the used names. I didn't find too much documentation about these kind of things, so any suggestions on how to approach? Pylint and snakefood have similar code, but they use the old "compiler" module, so it's not really helpful. From ian.g.kelly at gmail.com Wed Nov 30 13:38:45 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 30 Nov 2011 11:38:45 -0700 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 9:26 AM, Alec Taylor wrote: > On Thu, Dec 1, 2011 at 3:18 AM, Ian Kelly wrote: >> On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor wrote: >>> Good evening, >>> >>> I have defined a new numbering structure for certain mathematical advantages. >>> >>> How do I implement this in Python, or would I be better off writing >>> this in C or C++? >>> >>> Ultra concise definition: http://i42.tinypic.com/af7w4h.png >>> LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI >>> >>> Thanks for all suggestions, >> >> So if I am understanding your definition correctly your hexavigesimals >> are ordered like this? >> >> 0, 1, ..., 9, A, B, ..., P, >> >> 0A, 0B, ..., 0P, >> 1A, 1B, ..., 1P, >> ..., >> 9A, 9B, ..., 9P, >> >> A0, A1, ..., A9, >> B0, B1, ..., B9, >> ..., >> P0, P1, ..., P9 >> >> And that's it, since your constraints preclude anything with more than 2 digits? > > To put it simply: > > I want a hexavigesimal of length n where each element contains at > least one letter {A, B, ..., P} and one number {0, 1, 2, ... }. > (unless n is less than 2, in which case only one of those constraints > need to be met) > > and I want addition only for incrementing the element. > > Why do I want all this I hear you ask? - For use as a > unique-identifier. I want a unique-ID of size 3. (3 positions, i.e. > P0A) > > Any suggestions on how to implement this in python would be appreciated. Okay, that's much clearer. If you don't actually care about the ordinal value of each element, only about incrementing them, then I suggest implementing increment as follows: 1. Convert the string to an int using the regular base-26 conversion with the int() built-in. 2. In a loop, add 1 to the value. 3. Convert the value back to a string using the same base-26 conversion. I don't know of a built-in that does this, so you'll need to write your own, which isn't too difficult. 4. Check whether the new string meets all your constraints. If it does, return it. If not, go back to 2. and try again with the next integer. At most it will take 17 iterations to find a valid value, but most of the time the first value tried will be valid. I assume you're already aware that with 3 digits you'll only have 12480 possible unique IDs using this scheme? It just doesn't seem like very many to me. Cheers, Ian From detlev at die-offenbachs.de Wed Nov 30 13:55:05 2011 From: detlev at die-offenbachs.de (Detlev Offenbach) Date: Wed, 30 Nov 2011 19:55:05 +0100 Subject: How to get a correct entry in the menu for a Python application on Mac OS X Message-ID: Hello, I am fairly new to Mac OS X and would like to know, what I have to do to make my Python application show the correct name in the menu bar. What did I do so far. I created an application package containing the .plist file with correct entries and a shell script, that starts the correct Python interpreter with the the main script. The menu bar just shows Python instead of the name of my application. If you are interested the application can be found via http://eric-ide.python-projects.org. Regards, Detlev -- Detlev Offenbach detlev at die-offenbachs.de From alec.taylor6 at gmail.com Wed Nov 30 14:00:38 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 06:00:38 +1100 Subject: Defining a new base-type in Python based off Hexavigesimal In-Reply-To: References: Message-ID: Excellent, I'll see if I can implement that. I was thinking more base data-type, but that seems impossible in python. 17 iterations (rarghh!) But yeah, I'll try that, thanks. On Thu, Dec 1, 2011 at 5:38 AM, Ian Kelly wrote: > On Wed, Nov 30, 2011 at 9:26 AM, Alec Taylor wrote: >> On Thu, Dec 1, 2011 at 3:18 AM, Ian Kelly wrote: >>> On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor wrote: >>>> Good evening, >>>> >>>> I have defined a new numbering structure for certain mathematical advantages. >>>> >>>> How do I implement this in Python, or would I be better off writing >>>> this in C or C++? >>>> >>>> Ultra concise definition: http://i42.tinypic.com/af7w4h.png >>>> LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI >>>> >>>> Thanks for all suggestions, >>> >>> So if I am understanding your definition correctly your hexavigesimals >>> are ordered like this? >>> >>> 0, 1, ..., 9, A, B, ..., P, >>> >>> 0A, 0B, ..., 0P, >>> 1A, 1B, ..., 1P, >>> ..., >>> 9A, 9B, ..., 9P, >>> >>> A0, A1, ..., A9, >>> B0, B1, ..., B9, >>> ..., >>> P0, P1, ..., P9 >>> >>> And that's it, since your constraints preclude anything with more than 2 digits? >> >> To put it simply: >> >> I want a hexavigesimal of length n where each element contains at >> least one letter {A, B, ..., P} and one number {0, 1, 2, ... }. >> (unless n is less than 2, in which case only one of those constraints >> need to be met) >> >> and I want addition only for incrementing the element. >> >> Why do I want all this I hear you ask? - For use as a >> unique-identifier. I want a unique-ID of size 3. (3 positions, i.e. >> P0A) >> >> Any suggestions on how to implement this in python would be appreciated. > > Okay, that's much clearer. ?If you don't actually care about the > ordinal value of each element, only about incrementing them, then I > suggest implementing increment as follows: > > 1. Convert the string to an int using the regular base-26 conversion > with the int() built-in. > 2. In a loop, add 1 to the value. > 3. Convert the value back to a string using the same base-26 > conversion. ?I don't know of a built-in that does this, so you'll need > to write your own, which isn't too difficult. > 4. Check whether the new string meets all your constraints. ?If it > does, return it. ?If not, go back to 2. and try again with the next > integer. > > At most it will take 17 iterations to find a valid value, but most of > the time the first value tried will be valid. > > I assume you're already aware that with 3 digits you'll only have > 12480 possible unique IDs using this scheme? ?It just doesn't seem > like very many to me. > > Cheers, > Ian From __peter__ at web.de Wed Nov 30 14:05:50 2011 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Nov 2011 20:05:50 +0100 Subject: Defining a new base-type in Python based off Hexavigesimal References: Message-ID: Alec Taylor wrote: > On Thu, Dec 1, 2011 at 3:18 AM, Ian Kelly wrote: >> On Wed, Nov 30, 2011 at 8:19 AM, Alec Taylor >> wrote: >>> Good evening, >>> >>> I have defined a new numbering structure for certain mathematical >>> advantages. >>> >>> How do I implement this in Python, or would I be better off writing >>> this in C or C++? >>> >>> Ultra concise definition: http://i42.tinypic.com/af7w4h.png >>> LaTeX source: http://pastebin.tlhiv.org/Kf6jPRkI >>> >>> Thanks for all suggestions, >> >> So if I am understanding your definition correctly your hexavigesimals >> are ordered like this? >> >> 0, 1, ..., 9, A, B, ..., P, >> >> 0A, 0B, ..., 0P, >> 1A, 1B, ..., 1P, >> ..., >> 9A, 9B, ..., 9P, >> >> A0, A1, ..., A9, >> B0, B1, ..., B9, >> ..., >> P0, P1, ..., P9 >> >> And that's it, since your constraints preclude anything with more than 2 >> digits? > > To put it simply: > > I want a hexavigesimal of length n where each element contains at > least one letter {A, B, ..., P} and one number {0, 1, 2, ... }. > (unless n is less than 2, in which case only one of those constraints > need to be met) > > and I want addition only for incrementing the element. > > Why do I want all this I hear you ask? - For use as a > unique-identifier. I want a unique-ID of size 3. (3 positions, i.e. > P0A) > > Any suggestions on how to implement this in python would be appreciated. Maybe you don't need a class if you produce the ids with a generator like so: >>> from itertools import product >>> def hxv(n): ... letters = "ABCDEFGHIJKLMNOP" ... digits = "0123456789" ... both = digits + letters ... if n == 1: ... for x in both: ... yield x ... else: ... for x in product(*[both]*n): ... s = "".join(x) ... if not s.isdigit() and not s.isalpha(): ... yield s ... >>> ids = hxv(3) >>> next(ids) '00A' >>> next(ids) '00B' >>> for i, x in enumerate(hxv(3)): pass ... >>> i, x (12479, 'PP9') From nospam at torek.net Wed Nov 30 14:29:31 2011 From: nospam at torek.net (Chris Torek) Date: 30 Nov 2011 19:29:31 GMT Subject: Py2.7/FreeBSD: maximum number of open files References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C26485F@EXVMBX020-12.exch020.serverdata.net> Message-ID: In article Christian Heimes wrote: >Am 14.11.2011 19:28, schrieb Tobias Oberstein: >> Thanks! This is probably the most practical option I can go. >> >> I've just tested: the backported new IO on Python 2.7 will indeed >> open >32k files on FreeBSD. It also creates the files much faster. >> The old, non-monkey-patched version was getting slower and >> slower as more files were opened/created .. > >I wonder what's causing the O(n^2) behavior. Is it the old file type or >BSD's fopen() fault? It is code in libc. My old stdio (still in use on FreeBSD) was never designed to be used in situations with more than roughly 256 file descriptors -- hence the "short" in the file number field. (The OS used to be full of other places that kept the maximum allowable file descriptor fairly small, such as the on-stack copies of fd_set objects in select() calls.) You will want to redesign the code that finds or creates a free "FILE" object, and probably some of the things that work with line-buffered FILEs (specifically calls to _fwalk() when reading from a line-buffered stream). -- In-Real-Life: Chris Torek, Wind River Systems Intel require I note that my opinions are not those of WRS or Intel Salt Lake City, UT, USA (40?39.22'N, 111?50.29'W) +1 801 277 2603 email: gmail (figure it out) http://web.torek.net/torek/index.html From tdldev at gmail.com Wed Nov 30 15:30:48 2011 From: tdldev at gmail.com (Verde Denim) Date: Wed, 30 Nov 2011 15:30:48 -0500 Subject: Py and SQL Message-ID: All I have a sql script that I've included in a simple Py file that gives an error in the SQL. The problem is that the SQL code executes correctly in a database IDE environment (in this case ora developer). So, I'm concluding that I'm doing something amiss in the Py code. Does anyone see why this code would return a 'missing expression' sql error? Essentially, the code should start, ask for a privilege, and then collect the priv, role, and user data. Any input is appreciated. #!/bin/bash import time import cx_Oracle dbConn = cx_Oracle.connect('juser', 'pass', '1.2.3.4:/orcl:DEDICATED', cclass = "ABC", purity = cx_Oracle.ATTR_PURITY_SELF) pStart = time.time() dbVersion = dbConn.version.split(".") majVer = dbVersion[0] print "Oracle Version: %s" %(majVer) print "Full Version: %s" %(dbConn.version) dbCursor1 = dbConn.cursor() dbCursor1.execute('select lpad(' ', 2*level) || c "Privilege, Roles and Users" from ( select null p, name c from system_privilege_map where name like upper(\'%&enter_privliege%\') union select granted_role p, grantee c from dba_role_privs union select privilege p, grantee c from dba_sys_privs) start with p is null connect by p = prior c') dbRowResult = dbCursor1.fetchall() for dbRow in dbRowResult: print dbRow dbCursor1.close() pElapsed = (time.time() - pStart) print pElapsed, " seconds" dbConn.close() -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodperson at rodperson.com Wed Nov 30 15:37:44 2011 From: rodperson at rodperson.com (Rod Person) Date: Wed, 30 Nov 2011 15:37:44 -0500 Subject: Py and SQL In-Reply-To: References: Message-ID: <20111130153744.0000017c@unknown> On Wed, 30 Nov 2011 15:30:48 -0500 Verde Denim wrote: > All > I have a sql script that I've included in a simple Py file that gives > an error in the SQL. The problem is that the SQL code executes > correctly in a database IDE environment (in this case ora developer). > So, I'm concluding that I'm doing something amiss in the Py code. > Does anyone see why this code would return a 'missing expression' sql > error? Essentially, the code should start, ask for a privilege, and > then collect the priv, role, and user data. Any input is appreciated. > > #!/bin/bash > import time > import cx_Oracle > > dbConn = cx_Oracle.connect('juser', 'pass', '1.2.3.4:/orcl:DEDICATED', > cclass = "ABC", purity = cx_Oracle.ATTR_PURITY_SELF) > > pStart = time.time() > > dbVersion = dbConn.version.split(".") > > majVer = dbVersion[0] > > print "Oracle Version: %s" %(majVer) > print "Full Version: %s" %(dbConn.version) > > dbCursor1 = dbConn.cursor() > dbCursor1.execute('select lpad(' ', 2*level) || c "Privilege, Roles > and Users" from ( select null p, name c from system_privilege_map > where name like upper(\'%&enter_privliege%\') union select > granted_role p, grantee c from dba_role_privs union select privilege > p, grantee c from dba_sys_privs) start with p is null connect by p = > prior c') dbRowResult = dbCursor1.fetchall() > for dbRow in dbRowResult: > print dbRow > Try changing the wrapping ' ' to " " and the inside double qoutes to single, like this dbCursor1.execute("select lpad(' ', 2*level) || c 'Privilege, Roles and Users' from ( select null p, name c from system_privilege_map where name like upper(\'%&enter_privliege%\') union select granted_role p, grantee c from dba_role_privs union select privilege p, grantee c from dba_sys_privs) start with p is null connect by p = prior c") -- Rod The club is like groceries, and I jus bag a bi@$&! ? Santonio Holmes on the Twitter From bahamutzero8825 at gmail.com Wed Nov 30 16:03:22 2011 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Wed, 30 Nov 2011 15:03:22 -0600 Subject: Need some IPC pointers Message-ID: <4ED69A1A.3080609@gmail.com> I've done some research, but I'm not sure what's most appropriate for my situation. What I want to do is have a long running process that spawns processes (that aren't necessarily written in Python) and communicates with them. The children can be spawned at any time and communicate at any time. Being able to communicate with non-local processes would be nice, but is not necessary. The implementation needs to be cross-platform, but child processes will use the same OS as the parent during runtime. I don't think I'll ever need to transfer anything complicated or large - just strings or possibly tuples/lists. I'd rather not go outside the standard library (but I'd consider it). I don't need to worry about compatibility with older Python versions; if it only works with Python 3.2, that's not a problem. I'm thinking sockets, but perhaps there's something simpler/easier. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0 From miki.tebeka at gmail.com Wed Nov 30 16:22:25 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 30 Nov 2011 13:22:25 -0800 (PST) Subject: Need some IPC pointers In-Reply-To: References: Message-ID: <3519788.203.1322688146008.JavaMail.geo-discussion-forums@yqfv40> There are two different problems. One is the medium to pass messages, sockets are good but there are other options and depends on your requirement you need to pick the best one. The other is serialization format, here you have marshal, pickle, JSON, XML and more. For me JSON over sockets works well in the past. It has the nice property that you can read messages without need for a special decoder (like in the case of marshal/pickle). From miki.tebeka at gmail.com Wed Nov 30 16:22:25 2011 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 30 Nov 2011 13:22:25 -0800 (PST) Subject: Need some IPC pointers In-Reply-To: References: Message-ID: <3519788.203.1322688146008.JavaMail.geo-discussion-forums@yqfv40> There are two different problems. One is the medium to pass messages, sockets are good but there are other options and depends on your requirement you need to pick the best one. The other is serialization format, here you have marshal, pickle, JSON, XML and more. For me JSON over sockets works well in the past. It has the nice property that you can read messages without need for a special decoder (like in the case of marshal/pickle). From jeanpierreda at gmail.com Wed Nov 30 16:32:31 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 30 Nov 2011 16:32:31 -0500 Subject: Need some IPC pointers In-Reply-To: <4ED69A1A.3080609@gmail.com> References: <4ED69A1A.3080609@gmail.com> Message-ID: > I'm thinking sockets, but perhaps there's something simpler/easier. Sockets are the only thing that will work without threads on all platforms. You could also use threads and pipes. (I'm not actually sure how threads+pipes works, but I'm told that it's a viable approach). Usually things are simpler and easier because they wrap all the cross-platform messiness behind a nice API, and then give you a higher level protocol for IPC on top of that. Unfortunately, the fewer external dependencies you have, the more you have to rewrite yourself. For what it's worth, I wrote something potentially similar using Twisted and AMP. AMP is an Asynchronous Messaging Protocol: this basically means that clients and servers can send messages to each other at any time in any order. Twisted makes sure that the right response gets associated with the right message. This can be very convenient -- you might request something from another process, and then to compute its answer it might ask for some additional information from you, and then you give it that information, and it sends back the final result. All the communication is done over TCP, usually using Twisted. So this does involve bringing in a fairly large dependency. For me, the tradeoff in programmer productivity was worth it, but of course it really depends on your situation. A more synchronous protocol might be more useful to you (although my impression was that perhaps you might be interested in something like AMP), and synchronous protocols directly on top of sockets are not so difficult to implement (although making them work across platforms is still too hard for my taste). Devin On Wed, Nov 30, 2011 at 4:03 PM, Andrew Berg wrote: > I've done some research, but I'm not sure what's most appropriate for my > situation. What I want to do is have a long running process that spawns > processes (that aren't necessarily written in Python) and communicates > with them. The children can be spawned at any time and communicate at > any time. Being able to communicate with non-local processes would be > nice, but is not necessary. The implementation needs to be > cross-platform, but child processes will use the same OS as the parent > during runtime. > I don't think I'll ever need to transfer anything complicated or large - > just strings or possibly tuples/lists. I'd rather not go outside the > standard library (but I'd consider it). I don't need to worry about > compatibility with older Python versions; if it only works with Python > 3.2, that's not a problem. > I'm thinking sockets, but perhaps there's something simpler/easier. > > -- > CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0 > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Wed Nov 30 17:12:10 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Nov 2011 17:12:10 -0500 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: On 11/30/2011 3:58 AM, Peter Otten wrote: > Terry Reedy wrote: > >> On 11/30/2011 1:20 AM, ??? wrote: >>> Good after >>> I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it >>> to a list like list = ["aaaa","bbbb","ccc"],what can id do? >> >> The easiest -- and most dangerous -- way is >> >>> eval('["aaaa","bbbb","ccc"]') >> ['aaaa', 'bbbb', 'ccc'] >> >> But DO NOT eval unexamined strings from untrusted sources. The reason is >> that it is much the same as letting an untrusted person sit unsupervised >> as the keyboard of your computer with a command window open. You would >> not want to eval >> "from os import system; system('')" >> where '' is replaced by something obnoxious for your >> operating system. > > You can avoid these problems with ast.literal_eval(): > > literal_eval(node_or_string) > Safely evaluate an expression node or a string containing a Python > expression. The string or node provided may only consist of the > following Python literal structures: strings, numbers, tuples, lists, > dicts, booleans, and None. I keep forgetting that someone thought to solve the problem of eval being both convinient and dangerous. Maybe if I type it once, I will remember. >>> import ast >>> ast.literal_eval('["aaaa","bbbb","ccc"]') ['aaaa', 'bbbb', 'ccc'] I think it would be better if safe_eval were available as an easily accessible builtin and dangerous_eval were tucked away in a module ;-). -- Terry Jan Reedy From malaclypse2 at gmail.com Wed Nov 30 17:14:57 2011 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 30 Nov 2011 17:14:57 -0500 Subject: Py and SQL In-Reply-To: References: Message-ID: On Wed, Nov 30, 2011 at 3:30 PM, Verde Denim wrote: > dbCursor1.execute('select lpad(' ', 2*level) || c "Privilege, Roles and > Users" from ( select null p, name c from system_privilege_map where name > like upper(\'%&enter_privliege%\') union select granted_role p, grantee c > from dba_role_privs union select privilege p, grantee c from dba_sys_privs) > start with p is null connect by p = prior c') > I think this is your problem. Your string is delimited with single quotes on the outside ('), but you also have a mix of single and double quotes inside your string. If you were to assign this to a variable and print it out, you would probably see the problem right away. You have two options. First, you could flip the outer quotes to double quotes, then switch all of the quotes inside the string to single quotes (I think that will work fine in SQL). Second, you could use a triple-quoted string by switching the outer quotes to ''' or """. Doing that would let you mix whatever kinds of quotes you like inside your string, like this (untested): sql = '''select lpad(' ', 2*level) || c "Privilege, Roles and Users" from ( select null p, name c from system_privilege_map where name like upper(\'%&enter_privliege%\') union select granted_role p, grantee c from dba_role_privs union select privilege p, grantee c from dba_sys_privs) start with p is null connect by p = prior c''' dbCursor1.execute(sql) Once you do that, I think you will find that the "&enter_priviliege" bit in your SQL isn't going to do what you want. I assume you're expecting that to automatically pop up some sort of dialog box asking the user to enter a value for that variable? That isn't going to happen in python. That's a function of the database IDE you use. You'll need to use python to ask the user for the privilege level, then substitute it into the sql yourself. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From bahamutzero8825 at gmail.com Wed Nov 30 17:19:39 2011 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Wed, 30 Nov 2011 16:19:39 -0600 Subject: Need some IPC pointers In-Reply-To: References: <4ED69A1A.3080609@gmail.com> Message-ID: <4ED6ABFB.2040808@gmail.com> On 11/30/2011 3:32 PM, Devin Jeanpierre wrote: > You could also use threads and pipes. (I'm not actually > sure how threads+pipes works, but I'm told that it's a viable > approach). Sounds interesting, but I'm not familiar with threading (not that I wouldn't be willing to learn). Is it even possible to pipe into a running process, though? > For what it's worth, I wrote something potentially similar using Twisted > and AMP. AMP is an Asynchronous Messaging Protocol: this basically > means that clients and servers can send messages to each other at any > time in any order. Twisted makes sure that the right response gets > associated with the right message. This can be very convenient -- you > might request something from another process, and then to compute its > answer it might ask for some additional information from you, and then > you give it that information, and it sends back the final result. > > All the communication is done over TCP, usually using Twisted. So this > does involve bringing in a fairly large dependency. Sounds like overkill, but I'll take a look. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0 From kuaile.xu at gmail.com Wed Nov 30 17:24:45 2011 From: kuaile.xu at gmail.com (kuaile xu) Date: Wed, 30 Nov 2011 14:24:45 -0800 (PST) Subject: unpack('>f', b'\x00\x01\x00\x00') Message-ID: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> Hi: I am working on a python script that parses mp4 video header. Once of the field is a 32-bit fixed-point number. I know that the four bytes are: 00, 01, 00, 00. I have a third party mp4 parsing program which displays this field's value is:1.0. However, the struct.unpack gets a value of 0.0. Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from struct import * >>> unpack('>f', b'\x00\x01\x00\x00') (9.183549615799121e-41,) >>> In addition, there is another field which is a 16-bit fixed point number. How do I unpack two bytes into a float? Thank you very much, From irmen at -NOSPAM-xs4all.nl Wed Nov 30 17:28:15 2011 From: irmen at -NOSPAM-xs4all.nl (Irmen de Jong) Date: Wed, 30 Nov 2011 23:28:15 +0100 Subject: Need some IPC pointers In-Reply-To: References: Message-ID: <4ed6ae00$0$6843$e4fe514c@news2.news.xs4all.nl> On 30-11-11 22:03, Andrew Berg wrote: > I've done some research, but I'm not sure what's most appropriate for my > situation. What I want to do is have a long running process that spawns > processes (that aren't necessarily written in Python) and communicates > with them. The children can be spawned at any time and communicate at > any time. Being able to communicate with non-local processes would be > nice, but is not necessary. The implementation needs to be > cross-platform, but child processes will use the same OS as the parent > during runtime. > I don't think I'll ever need to transfer anything complicated or large - > just strings or possibly tuples/lists. I'd rather not go outside the > standard library (but I'd consider it). I don't need to worry about > compatibility with older Python versions; if it only works with Python > 3.2, that's not a problem. > I'm thinking sockets, but perhaps there's something simpler/easier. > Standard library, local processes: multiprocessing module. If that doesn't suit your needs, maybe check out Pyro: http://packages.python.org/Pyro4/ Pyro allows objects to talk to each other over the network, with minimal programming effort. You can just use normal Python method calls to call objects on other machines (or locally, ofcourse). It's written in 100% pure Python and works on Python 2.6 and upwards (including 3.x). Regards, Irmen de Jong From tjreedy at udel.edu Wed Nov 30 17:29:12 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Nov 2011 17:29:12 -0500 Subject: Python crashes on segmentation error In-Reply-To: References: <8bffed0f-1050-418a-834d-f7060a899ab7@h5g2000yqk.googlegroups.com> Message-ID: On 11/30/2011 7:58 AM, Christian Heimes wrote: > Am 30.11.2011 11:42, schrieb Ben Richardson: >> Python crashes every time i run the following command? >> >>>>> import cv >> Segmentation fault: 11 >> >> Python quit unexpectedly - any help would be greatly appreciated - >> thankyou in advance :) >> >> Here is crash report? > [...] >> >> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread >> 0 ??? 000000000000000000 0 + 0 >> 1 org.python.python 0x00000001006c7885 PyImport_Import >> + 121 >> 2 org.python.python 0x00000001006c7a1e >> PyImport_ImportModule + 32 >> 3 cv.so 0x00000001004f5082 initcv + 18 >> 4 org.python.python 0x00000001000dc071 >> _PyImport_LoadDynamicModule + 177 > > It looks like you have a faulty 3rd party library with an extension > module called cv.so that is causing the segfault. The segfault occurs > either inside or during the import of the cv module. initcv() is the > init function of the cv module that is called automatically during the > import. In other words, contact the authors of the cv module. Or perhaps first check to make sure that the cv.so build you are running is intended to be compatible with the Python build you are running. -- Terry Jan Reedy From irmen at -NOSPAM-xs4all.nl Wed Nov 30 17:31:08 2011 From: irmen at -NOSPAM-xs4all.nl (Irmen de Jong) Date: Wed, 30 Nov 2011 23:31:08 +0100 Subject: Need some IPC pointers In-Reply-To: <4ed6ae00$0$6843$e4fe514c@news2.news.xs4all.nl> References: <4ed6ae00$0$6843$e4fe514c@news2.news.xs4all.nl> Message-ID: <4ed6aeac$0$6843$e4fe514c@news2.news.xs4all.nl> On 30-11-11 23:28, Irmen de Jong wrote: > On 30-11-11 22:03, Andrew Berg wrote: >> processes (that aren't necessarily written in Python) and communicates Oops, missed this on my first read. This rules out my suggestion of Pyro because that requires Python on both ends (or Java/.net on the client side). Sorry for the noise. Irmen From jeanpierreda at gmail.com Wed Nov 30 17:41:33 2011 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 30 Nov 2011 17:41:33 -0500 Subject: Need some IPC pointers In-Reply-To: <4ED6ABFB.2040808@gmail.com> References: <4ED69A1A.3080609@gmail.com> <4ED6ABFB.2040808@gmail.com> Message-ID: > Sounds interesting, but I'm not familiar with threading (not that I > wouldn't be willing to learn). > Is it even possible to pipe into a running process, though? You create the pipe to the process when you start it. e.g. subprocess.Popen(['ls', 'foo'], stdout=subprocess.PIPE, stdin=subprocess.PIPE) Irmen de Jong mentions the multiprocessing module, that might be a better approach. I don't use it for production purposes because it has bad properties when processes are killed abruptly (it can't tell necessarily the difference between a truncated message and a normal message). It doesn't feel safe, you know? (Of course, neither do threads!) Devin On Wed, Nov 30, 2011 at 5:19 PM, Andrew Berg wrote: > On 11/30/2011 3:32 PM, Devin Jeanpierre wrote: >> You could also use threads and pipes. (I'm not actually >> sure how threads+pipes works, but I'm told that it's a viable >> approach). > Sounds interesting, but I'm not familiar with threading (not that I > wouldn't be willing to learn). > Is it even possible to pipe into a running process, though? > >> For what it's worth, I wrote something potentially similar using Twisted >> and AMP. AMP is an Asynchronous Messaging Protocol: this basically >> means that clients and servers can send messages to each other at any >> time in any order. Twisted makes sure that the right response gets >> associated with the right message. This can be very convenient -- you >> might request something from another process, and then to compute its >> answer it might ask for some additional information from you, and then >> you give it that information, and it sends back the final result. >> >> All the communication is done over TCP, usually using Twisted. So this >> does involve bringing in a fairly large dependency. > Sounds like overkill, but I'll take a look. > > -- > CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0 > -- > http://mail.python.org/mailman/listinfo/python-list > From hidura at gmail.com Wed Nov 30 17:48:37 2011 From: hidura at gmail.com (Hidura) Date: Wed, 30 Nov 2011 18:48:37 -0400 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: Why you don't make this "['1','2','3']".strip("[]").split(',') work for me El nov 30, 2011 10:16 p.m., "Terry Reedy" escribi?: > On 11/30/2011 3:58 AM, Peter Otten wrote: > >> Terry Reedy wrote: >> >> On 11/30/2011 1:20 AM, ??? wrote: >>> >>>> Good after >>>> I have a string liststr = '["aaaa","bbbb","ccc"]' ,and I need convert it >>>> to a list like list = ["aaaa","bbbb","ccc"],what can id do? >>>> >>> >>> The easiest -- and most dangerous -- way is >>> >>> eval('["aaaa","bbbb","ccc"]') >>> ['aaaa', 'bbbb', 'ccc'] >>> >>> But DO NOT eval unexamined strings from untrusted sources. The reason is >>> that it is much the same as letting an untrusted person sit unsupervised >>> as the keyboard of your computer with a command window open. You would >>> not want to eval >>> "from os import system; system('')" >>> where '' is replaced by something obnoxious for your >>> operating system. >>> >> >> You can avoid these problems with ast.literal_eval(): >> >> literal_eval(node_or_string) >> Safely evaluate an expression node or a string containing a Python >> expression. The string or node provided may only consist of the >> following Python literal structures: strings, numbers, tuples, lists, >> dicts, booleans, and None. >> > > I keep forgetting that someone thought to solve the problem of eval being > both convinient and dangerous. Maybe if I type it once, I will remember. > >>> import ast > >>> ast.literal_eval('["aaaa","**bbbb","ccc"]') > ['aaaa', 'bbbb', 'ccc'] > > I think it would be better if safe_eval were available as an easily > accessible builtin and dangerous_eval were tucked away in a module ;-). > > -- > Terry Jan Reedy > > > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Wed Nov 30 18:02:53 2011 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 30 Nov 2011 15:02:53 -0800 Subject: unpack('>f', b'\x00\x01\x00\x00') In-Reply-To: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> References: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> Message-ID: On Wed, Nov 30, 2011 at 2:24 PM, kuaile xu wrote: > Hi: > > I am working on a python script that parses mp4 video header. Once of > the field is a 32-bit fixed-point number. > > I know that the four bytes are: 00, 01, 00, 00. I have a third party > mp4 parsing program which displays this field's value is:1.0. > > However, the struct.unpack gets a value of 0.0. > > Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit > (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from struct import * >>>> unpack('>f', b'\x00\x01\x00\x00') > (9.183549615799121e-41,) Floating-point and fixed-point are *separate* number formats with distinct representations. You cannot expect to correctly (un)pack one as if it was the other. Similarly, converting between the two formats can introduce range and/or imprecision error. C does not have a built-in fixed-point datatype, so the `struct` module doesn't handle fixed-point numbers directly. You're going to have to unpack it (or parts of it) as something more raw, and then do the necessary bit manipulation yourself. Cheers, Chris -- http://rebertia.com From tjreedy at udel.edu Wed Nov 30 18:12:14 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Nov 2011 18:12:14 -0500 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: <4ED6B84E.6080706@udel.edu> On 11/30/2011 5:48 PM, Hidura wrote: > Why you don't make this "['1','2','3']".strip("[]").split(',') work for me Look more carefully. This is not the same as ast.literal_eval(). >>> "['1','2','3']".strip("[]").split(',') ["'1'", "'2'", "'3'"] # list of 3-char strings >>> ast.literal_eval("['1','2','3']") ['1', '2', '3'] # list of 1-char strings Even if it were the same, it would be specific to lists of strings and would not work for anything else. From kuaile.xu at gmail.com Wed Nov 30 18:25:27 2011 From: kuaile.xu at gmail.com (kuaile xu) Date: Wed, 30 Nov 2011 15:25:27 -0800 (PST) Subject: unpack('>f', b'\x00\x01\x00\x00') References: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> Message-ID: <6628ac4b-f6d2-40b6-b1e6-6b0a4bf4e5e2@c18g2000yqj.googlegroups.com> On Nov 30, 6:02?pm, Chris Rebert wrote: > On Wed, Nov 30, 2011 at 2:24 PM, kuaile xu wrote: > > Hi: > > > I am working on a python script that parses mp4 video header. Once of > > the field is a 32-bit fixed-point number. > > > I know that the four bytes are: 00, 01, 00, 00. I have a third party > > mp4 parsing program which displays this field's value is:1.0. > > > However, the struct.unpack gets a value of 0.0. > > > Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit > > (AMD64)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> from struct import * > >>>> unpack('>f', b'\x00\x01\x00\x00') > > (9.183549615799121e-41,) > > Floating-point and fixed-point are *separate* number formats with > distinct representations. You cannot expect to correctly (un)pack one > as if it was the other. Similarly, converting between the two formats > can introduce range and/or imprecision error. > > C does not have a built-in fixed-point datatype, so the `struct` > module doesn't handle fixed-point numbers directly. You're going to > have to unpack it (or parts of it) as something more raw, and then do > the necessary bit manipulation yourself. > > Cheers, > Chris > --http://rebertia.com > > Thanks a lot. From python.list at tim.thechases.com Wed Nov 30 18:25:46 2011 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 30 Nov 2011 17:25:46 -0600 Subject: How convert a list string to a real list In-Reply-To: References: Message-ID: <4ED6BB7A.30809@tim.thechases.com> On 11/30/11 16:48, Hidura wrote: > Why you don't make this "['1','2','3']".strip("[]").split(',') work for me because it breaks on things like s = """ [[1,2,3],42,'''triple the fun!''', "can't touch this, eh?",r'"Back\\\slashes?!", she said.', [4,5,6]] """ Commas can be embedded in strings, strings can be delimited with single, double, or triple quotes, raw strings can be used, more than one opening or closing "["/"]" can appear in a row, leading or trailing whitespace might throw you off...using ast.literal_eval() should just Do the Right Thing?. -tkc From ian.g.kelly at gmail.com Wed Nov 30 18:49:52 2011 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 30 Nov 2011 16:49:52 -0700 Subject: unpack('>f', b'\x00\x01\x00\x00') In-Reply-To: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> References: <6b7251ef-3479-412f-8acb-882be1e25633@n35g2000yqf.googlegroups.com> Message-ID: On Wed, Nov 30, 2011 at 3:24 PM, kuaile xu wrote: > Hi: > > I am working on a python script that parses mp4 video header. Once of > the field is a 32-bit fixed-point number. > > I know that the four bytes are: 00, 01, 00, 00. I have a third party > mp4 parsing program which displays this field's value is:1.0. > > However, the struct.unpack gets a value of 0.0. > > Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit > (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from struct import * >>>> unpack('>f', b'\x00\x01\x00\x00') > (9.183549615799121e-41,) >>>> Like Chris said, you can't unpack it as a float. Assuming that's Q16 fixed-point, what you can do is unpack it as an int and then multiply by 2.0 ** -16 to get the corresponding float value. There should be no loss of precision converting to a float since floats store 52 bits of precision, but be aware that you could have overflow or loss of precision when converting in the opposite direction. > In addition, there is another field which is a 16-bit fixed point > number. How do I unpack two bytes into a float? Same as above, just change the multiplier to match the scale. Cheers, Ian From rosuav at gmail.com Wed Nov 30 21:14:26 2011 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 1 Dec 2011 13:14:26 +1100 Subject: Need some IPC pointers In-Reply-To: <4ED69A1A.3080609@gmail.com> References: <4ED69A1A.3080609@gmail.com> Message-ID: On Thu, Dec 1, 2011 at 8:03 AM, Andrew Berg wrote: > processes (that aren't necessarily written in Python) ... > non-local processes would be nice ... > The implementation needs to be cross-platform ... > I don't think I'll ever need to transfer anything complicated or large - > just strings or possibly tuples/lists. > I'm thinking sockets, but perhaps there's something simpler/easier. Definitely sockets, as other posters have said. The only question is, what encapsulation format (since sockets give just a stream of bytes). Since you want non-Python processes to be involved, I would be inclined to avoid using Python's own pickling system; JSON may be viable, and it's well known so you should be able to find support in other languages. Alternatively, take a careful look at your dataset and invent your own system. If your strings will never contain a pipe character, you could define a tuple/list to be simply pipe-separated strings; if they'll never contain newlines, you can specify your protocol to be newline-terminated. For command/response protocols over TCP/IP, I strongly recommend poking around with existing protocols such as the email trio (SMTP, POP, and IMAP); there's many good ideas to be gained from them. If you can, try to keep your protocol to ASCII text. It makes debugging far easier, as you can simply point a telnet/mud client at your server and manually step through things. Chris Angelico From roy at panix.com Wed Nov 30 22:15:27 2011 From: roy at panix.com (Roy Smith) Date: Wed, 30 Nov 2011 22:15:27 -0500 Subject: Clever hack or code abomination? Message-ID: I need to try a bunch of names in sequence until I find one that works (definition of "works" is unimportant). The algorithm is: 1) Given a base name, "foo", first see if just plain "foo" works. 2) If not, try "foo-1", "foo-2", and so on 3) If you reach "foo-20", give up. What would you say if you saw this: for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]: It generates the right sequence of strings. But, if you came upon that code, would it make sense to you, or would you spend half the afternoon trying to figure out what it did and the other half of the afternoon ranting about the deranged lunatic who wrote it? From steve+comp.lang.python at pearwood.info Wed Nov 30 22:38:13 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Dec 2011 03:38:13 GMT Subject: Clever hack or code abomination? References: Message-ID: <4ed6f6a5$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 30 Nov 2011 22:15:27 -0500, Roy Smith wrote: > I need to try a bunch of names in sequence until I find one that works > (definition of "works" is unimportant). The algorithm is: > > 1) Given a base name, "foo", first see if just plain "foo" works. > > 2) If not, try "foo-1", "foo-2", and so on > > 3) If you reach "foo-20", give up. > > What would you say if you saw this: > > for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]: > > It generates the right sequence of strings. But, if you came upon that > code, would it make sense to you, or would you spend half the afternoon > trying to figure out what it did and the other half of the afternoon > ranting about the deranged lunatic who wrote it? Nah, it's fine. Not exactly the clearest piece of code in the world, but hardly worth a rant. I'd be more likely to write that as: for suffix in [''] + ["-%d" % i for i in range(1, 21)]: or if I needed to do it more than once, as a generator: def suffixes(max=20): yield "" for i in range(1, max+1): yield "-%d" % i -- Steven From steve+comp.lang.python at pearwood.info Wed Nov 30 22:42:54 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Dec 2011 03:42:54 GMT Subject: How convert a list string to a real list References: Message-ID: <4ed6f7be$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote: > I think it would be better if safe_eval were available as an easily > accessible builtin and dangerous_eval were tucked away in a module ;-). +100000 -- Steven From anacrolix at gmail.com Wed Nov 30 22:49:46 2011 From: anacrolix at gmail.com (Matt Joiner) Date: Thu, 1 Dec 2011 14:49:46 +1100 Subject: Clever hack or code abomination? In-Reply-To: References: Message-ID: def possible_names(): yield "foo" for i in range(20): yield "foo-" + str(i) ?_? On Thu, Dec 1, 2011 at 2:15 PM, Roy Smith wrote: > I need to try a bunch of names in sequence until I find one that works > (definition of "works" is unimportant). ?The algorithm is: > > 1) Given a base name, "foo", first see if just plain "foo" works. > > 2) If not, try "foo-1", "foo-2", and so on > > 3) If you reach "foo-20", give up. > > What would you say if you saw this: > > for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]: > > It generates the right sequence of strings. ?But, if you came upon that > code, would it make sense to you, or would you spend half the afternoon > trying to figure out what it did and the other half of the afternoon > ranting about the deranged lunatic who wrote it? > -- > http://mail.python.org/mailman/listinfo/python-list From steve+comp.lang.python at pearwood.info Wed Nov 30 23:17:49 2011 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Dec 2011 04:17:49 GMT Subject: Disable readline Message-ID: <4ed6ffed$0$29986$c3e8da3$5496439d@news.astraweb.com> Is there a way to disable readline support in the interactive interpreter at runtime? Either from within an existing session, or when the session starts up will do. I am trying to test the behaviour of some interactive scripts which rely on readline. I have work-arounds for missing readline (such as on Windows systems) but no way to test them properly on Linux. If all else fails, are there any traps or pitfalls in installing a second Python installation with readline support disabled? Any other suggestions? -- Steven From ben+python at benfinney.id.au Wed Nov 30 23:25:23 2011 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 01 Dec 2011 15:25:23 +1100 Subject: How convert a list string to a real list References: <4ed6f7be$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87ehwo5364.fsf@benfinney.id.au> Steven D'Aprano writes: > On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote: > > > I think it would be better if safe_eval were available as an easily > > accessible builtin and dangerous_eval were tucked away in a module ;-). > > +100000 You do realise that any vote outside the range ?1 through +1 is invalid, right? Every person gets a maximum of 1, positive or negative. Outside that, the vote police come to kick you off the internet. -- \ ?Everything is futile.? ?Marvin of Borg | `\ | _o__) | Ben Finney From alec.taylor6 at gmail.com Wed Nov 30 23:33:51 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 15:33:51 +1100 Subject: How convert a list string to a real list In-Reply-To: <87ehwo5364.fsf@benfinney.id.au> References: <4ed6f7be$0$29986$c3e8da3$5496439d@news.astraweb.com> <87ehwo5364.fsf@benfinney.id.au> Message-ID: Dammit, been awake too long researching on the Internet, but I finally reached the Last Page On Thu, Dec 1, 2011 at 3:25 PM, Ben Finney wrote: > Steven D'Aprano writes: > >> On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote: >> >> > I think it would be better if safe_eval were available as an easily >> > accessible builtin and dangerous_eval were tucked away in a module ;-). >> >> +100000 > > You do realise that any vote outside the range -1 through +1 is invalid, > right? Every person gets a maximum of 1, positive or negative. Outside > that, the vote police come to kick you off the internet. > > -- > \ "Everything is futile." --Marvin of Borg | > `\ | > _o__) | > Ben Finney > -- > http://mail.python.org/mailman/listinfo/python-list From alec.taylor6 at gmail.com Wed Nov 30 23:35:22 2011 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 1 Dec 2011 15:35:22 +1100 Subject: Need some IPC pointers In-Reply-To: <4ED69A1A.3080609@gmail.com> References: <4ED69A1A.3080609@gmail.com> Message-ID: Sure, I'll give you some pointers: 0x3A28213A 0x6339392C 0x7363682E