Re: JSON Strict Mode

2011-08-04 Thread Chris Rebert
On Thu, Aug 4, 2011 at 8:25 PM, John Riselvato wrote: > I am working on a license verification script. I am rather new to the > concept and to JSON files in general. Based on your questions, reading a programming tutorial might be a good idea. Here's one that uses Python and that I've heard prais

JSON Strict Mode

2011-08-04 Thread John Riselvato
I am working on a license verification script. I am rather new to the concept and to JSON files in general. This is what my pseudocode looks like: licenses = meta['license'] > for x in licenses: > if licenses[x]['terms'] is not valid opensource license > if in strict mode >

Re: PyWhich

2011-08-04 Thread Chris Angelico
On Fri, Aug 5, 2011 at 1:34 AM, Steven D'Aprano wrote: > Especially for a tool aimed at programmers (who else would be interested in > PyWhich?) The use that first springs to my mind is debugging import paths etc. If you have multiple pythons installed and aren't sure that they're finding the rig

Re: Community Involvement

2011-08-04 Thread Steve Holden
Haven't had much Cc input so far, but this one is definitely worth following up on. Thanks! regards Steve On Aug 4, 2011, at 5:42 PM, Eric Snow wrote: > On Wed, Aug 3, 2011 at 9:14 PM, Steve Holden wrote: >> [Ccs appreciated] >> After some three years labor I (@holdenweb) at last find myself

Re: error compiling python, and "plat-linux2" versus "plat-linux3"

2011-08-04 Thread Terry Reedy
There has been some discussion about what to do with 'linux3'. See http://bugs.python.org/issue12326 for example. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWhich

2011-08-04 Thread Tim Chase
On 08/04/2011 07:34 PM, Steven D'Aprano wrote: Billy Mays wrote: #!/usr/bin/python I believe the recommended, platform independent hash-bang line is #!/usr/bin/which python I think you mean #!/usr/bin/env python -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: with statement and context managers

2011-08-04 Thread Steven D'Aprano
Thomas Rachel wrote: > Am 03.08.2011 04:15 schrieb Steven D'Aprano: [...] > > but to me that looks badly wrong. Surely the spam context manager > > object will exit after the first iteration, and always raise an > > exception on the second? But I don't quite understand context > > managers eno

Re: problem with bcd and a number

2011-08-04 Thread Dan Stromberg
It sounds like you have what you need, but here's an amusing way of dealing with a BCD byte: >>> print int(hex(0x72).replace('0x', '')) 72 On Thu, Aug 4, 2011 at 5:15 PM, shawn bright wrote: > Thanks for your help on this, gents. Got it working now. > shawn > > On Thu, Aug 4, 2011 at 2:28 PM, D

Re: PyWhich

2011-08-04 Thread Steven D'Aprano
Billy Mays wrote: > Hey c.l.p., > > I wrote a little python script that finds the file that a python module > came from. Does anyone see anything wrong with this script? Yes -- the most screamingly obvious question has to be, why are you writing directly to sys.stdout instead of just using pri

error compiling python, and "plat-linux2" versus "plat-linux3"

2011-08-04 Thread Robert P. J. Day
i may have asked about this once upon a time but i'm still fighting with it so i'll throw myself on the mercy of the list and ask again. (and if there's a better forum for this question, let me know.) i'm using the development environment wind river linux 4.2 (hereafter just "WRL") to configu

Re: problem with bcd and a number

2011-08-04 Thread shawn bright
Thanks for your help on this, gents. Got it working now. shawn On Thu, Aug 4, 2011 at 2:28 PM, Dave Angel wrote: > nibbles from a byte -- http://mail.python.org/mailman/listinfo/python-list

Re: Text to image with same results on any platform

2011-08-04 Thread Gelonida N
Just FYI. Thread continued in thread with the subject line 'PIL question. having exactly same font on multiple platforms' I'm currently not pixel true, but images are sufficiently similiar. On 08/03/2011 11:40 AM, Gelonida N wrote: > Hi, > > >>From within a django application > I'd like create

Re: PIL question. having exactly same font on multiple platforms

2011-08-04 Thread Gelonida N
Thanks again to everybody, Your answers helped me to understand better. My pragmatic solution is now to package my program with an open source .ttf font, which will be used on both platforms. On 08/04/2011 10:24 PM, Irmen de Jong wrote: > On 4-8-2011 21:30, Irmen de Jong wrote: > >> As far as

HSeparator() in gtk.layour

2011-08-04 Thread Peter Irbizon
hello, how can I add hseparator to gtk.layout? I tried hseparator = gtk.HSeparator() self.layout.put(hseparator, 50,195) but it does not work :/ -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWhich

2011-08-04 Thread Dan Stromberg
On Thu, Aug 4, 2011 at 10:22 AM, Chris Rebert wrote: > > > #!/usr/bin/python > > > > import sys > > if __name__ == '__main__': > >if len(sys.argv) > 1: > >try: > >m = __import__(sys.argv[1]) > >sys.stdout.write(m.__file__ + '\n') > >sys.stdout.flush

Re: Community Involvement

2011-08-04 Thread Eric Snow
On Wed, Aug 3, 2011 at 9:14 PM, Steve Holden wrote: > [Ccs appreciated] > After some three years labor I (@holdenweb) at last find myself approaching > the completion of the Python Certificate Series with O'Reilly School of > Technology (@OReillySchool). > At OSCON last week the team fell to talki

Re: Inconsistencies with tab/space indentation between Cygwin/Win32?

2011-08-04 Thread Nobody
On Thu, 04 Aug 2011 13:55:37 +0930, Christian Gelinek wrote: > I find it at least confusing to read that Python expects a tab size of 8 but > at the same time uses 4 spaces for one indent level. Or maybe I am > completely on the wron track here? 4-column indents are a convention, not a rule. You

Re: Community Involvement

2011-08-04 Thread Rhodri James
On Thu, 04 Aug 2011 18:04:48 +0100, Ethan Furman wrote: Of the two, I like the StackOverflow option better -- but keep in mind that at this moment, about 6,600 unanswered Python questions remain. (I've made it to page 23 of 132 over the last week.) Getting an answer upvoted can be prett

Re: PIL question. having exactly same font on multiple platforms

2011-08-04 Thread Irmen de Jong
On 4-8-2011 21:30, Irmen de Jong wrote: > As far as I know, I did not see any difference in output on windows, linux > and mac os x > as long as the code used the same ttf file and PIL versions. (but I'll double > check now > and see if I remember this correctly). To follow up on myself, I've j

Re: problem with bcd and a number

2011-08-04 Thread Ethan Furman
MRAB wrote: On 04/08/2011 19:26, nephish wrote: Hey all, I have been trying to get my head around how to do something, but i am missing how to pull it off. I am reading a packet from a radio over a serial port. i have " two bytes containing the value i need. The first byte is the LSB, second

Re: problem with bcd and a number

2011-08-04 Thread Christoph Hansen
MRAB schrieb: The value is MSB * 100 + (LSB>> 4) * 10 + (LSB& 0xF) i would say (MSB >> 4)*100 + (MSB & 0xF)*10 + (LSB >> 4) but who knows -- http://mail.python.org/mailman/listinfo/python-list

Re: Early binding as an option

2011-08-04 Thread Chris Torek
>Chris Angelico wrote: [snippage] >> def func(x): >>len = len # localize len >>for i in x: >>len(i) # use it exactly as you otherwise would In article <4e39a6b5$0$29973$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano wrote: >That can't work. The problem is that because len

Re: problem with bcd and a number

2011-08-04 Thread MRAB
On 04/08/2011 19:26, nephish wrote: Hey all, I have been trying to get my head around how to do something, but i am missing how to pull it off. I am reading a packet from a radio over a serial port. i have " two bytes containing the value i need. The first byte is the LSB, second is MSB. Both

Re: PIL question. having exactly same font on multiple platforms

2011-08-04 Thread Irmen de Jong
On 4-8-2011 20:54, Gelonida N wrote: > The reason why I want the images to look identical is very simple. > Though the final web server will run on a linux server, I use sometimes > windows for development or as test server. > > For automated tests I would have liked pixel identical images. > th

Re: problem with bcd and a number

2011-08-04 Thread Christoph Hansen
nephish schrieb: thanks for any tips on this. I'll try. In BCD a (decimal) digit is stored in a halfbyte (or a 'nibble'). So, in a byte you can store two decimal digits. For instance 42 would be nibble1 nibble2 0100 0010 42 >>> c=0b0110 >>> c 66 >>> c >> 4

Re: problem with bcd and a number

2011-08-04 Thread Ethan Furman
nephish wrote: Hey all, I have been trying to get my head around how to do something, but i am missing how to pull it off. I am reading a packet from a radio over a serial port. i have " two bytes containing the value i need. The first byte is the LSB, second is MSB. Both bytes are BCD-encode

Re: problem with bcd and a number

2011-08-04 Thread Dave Angel
On 01/-10/-28163 02:59 PM, nephish wrote: Hey all, I have been trying to get my head around how to do something, but i am missing how to pull it off. I am reading a packet from a radio over a serial port. i have " two bytes containing the value i need. The first byte is the LSB, second is MSB.

python glibc issue

2011-08-04 Thread Garrett, Benjamin D
Hi, I am running into a problem with Python 2.6 and SuSe 11 SP1. The error message looks just like this one: https://bugzilla.redhat.com/show_bug.cgi?id=556584 That link implies the fix is to upgrade to > glibc-2.11.90. But for this particular hardware, it would be difficult to upgrade the cor

Re: PIL question. having exactly same font on multiple platforms

2011-08-04 Thread Gelonida N
On 08/04/2011 12:32 PM, Thomas Jollans wrote: > On 04/08/11 12:04, Gelonida N wrote: Thanks for your answer. >> >From within a django application >> I'd like create a small image file (e.g. .png) >> which just contains some text. >> >> I wondered what library would be appropriate and would yield t

problem with bcd and a number

2011-08-04 Thread nephish
Hey all, I have been trying to get my head around how to do something, but i am missing how to pull it off. I am reading a packet from a radio over a serial port. i have " two bytes containing the value i need. The first byte is the LSB, second is MSB. Both bytes are BCD-encoded, with the LSB c

problem with bcd and a number

2011-08-04 Thread nephish
Hey all, I have been trying to get my head around how to do something, but i am missing how to pull it off. I am reading a packet from a radio over a serial port. i have " two bytes containing the value i need. The first byte is the LSB, second is MSB. Both bytes are BCD-encoded, with the LSB c

Re: PyWhich

2011-08-04 Thread Tim Chase
On 08/04/2011 07:43 AM, Billy Mays wrote: Hey c.l.p., I wrote a little python script that finds the file that a python module came from. Does anyone see anything wrong with this script? #!/usr/bin/python import sys if __name__ == '__main__': if len(sys.argv)> 1: try:

Re: PyWhich

2011-08-04 Thread Chris Rebert
On Thu, Aug 4, 2011 at 5:43 AM, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote: > Hey c.l.p., > > I wrote a little python script that finds the file that a python module came > from.  Does anyone see anything wrong with this script? > > > #!/usr/bin/python > > impor

Re: Community Involvement

2011-08-04 Thread sparky gmail
On 8/3/2011 8:14 PM, Steve Holden wrote: [Ccs appreciated] After some three years labor I (@holdenweb) at last find myself approaching the completion of the Python Certificate Series with O'Reilly School of Technology (@OReillySchool). At OSCON last week the team fell to talking about the fi

Re: Community Involvement

2011-08-04 Thread Ethan Furman
Steve Holden wrote: We would ideally like the last project to to be something that demonstrates at least some minimal involvement with the Python community. Something like "get a Python answer upvoted on StackOverflow", for example, or getting a question answered on c.l.p. At the same time it

Re: making my extensions work together

2011-08-04 Thread Mathew
okay. It worked to make my 3'rd party library dynamic. Hopefully this will help someone else in the future. "Mathew" wrote in message news:j1cs2t$j2f$1...@news.jpl.nasa.gov... > This isn't exactly a Python question but maybe someone here has run into > this. > > I have 2 extensions and they b

Re: making my extensions work together

2011-08-04 Thread Katriel Cohn-Gordon
Wrap your 3rd party library with a Python interface module, and run all calls from foo and goo through your interface. On Thu, Aug 4, 2011 at 2:48 PM, Mathew wrote: > more info. I have a large 3rd party library with a function that looks > like > this > void dumbfunc() { > static int statevar=0

Re: making my extensions work together

2011-08-04 Thread Mathew
more info. I have a large 3rd party library with a function that looks like this void dumbfunc() { static int statevar=0; ++statevar; if (startvar ==3) printf("I have been called 3 times\n"); } and I have 2 extensions, foo,py goo.py,created with SWIG, and the both make calls to dumbfunc. In cre

PyWhich

2011-08-04 Thread Billy Mays
Hey c.l.p., I wrote a little python script that finds the file that a python module came from. Does anyone see anything wrong with this script? #!/usr/bin/python import sys if __name__ == '__main__': if len(sys.argv) > 1: try: m = __import__(sys.argv[1])

Re: PIL question. having exactly same font on multiple platforms

2011-08-04 Thread Steven D'Aprano
Gelonida N wrote: > I wondered what library would be appropriate and would yield the same > result independent of the OS (assuming the versions of the python > libraries are the same) > Images should be pixel identical independent on the platform on which > the image is created. Short answer: you

Re: PIL question. having exactly same font on multiple platforms

2011-08-04 Thread Thomas Jollans
On 04/08/11 12:04, Gelonida N wrote: > I posted already a question, but perhaps the subject line wasn't clear. > > > Subject line was "Text to image with same results on any platform" > Oh, your original message was perfectly clear, and if I knew the answer, I might have responded. Anyway, int

PIL question. having exactly same font on multiple platforms

2011-08-04 Thread Gelonida N
I posted already a question, but perhaps the subject line wasn't clear. Subject line was "Text to image with same results on any platform" >From within a django application I'd like create a small image file (e.g. .png) which just contains some text. I wondered what library would be appropria

Re: range() vs xrange() Python2|3 issues for performance

2011-08-04 Thread Steven D'Aprano
Chris Angelico wrote: > On Thu, Aug 4, 2011 at 4:01 AM, Steven D'Aprano > wrote: >> a, b = divmod(n, i) >> if b == 0: >> total += a+i >> > > Wouldn't this fail on squares? It happens to give correct results as > far as I've checked; no square up to 10,000 is called perfect, and > there are no pe

Re: ImportError: No module named PyQt4.QtGui

2011-08-04 Thread Thomas Jollans
On 04/08/11 11:39, 守株待兔 wrote: > i have installed such things: > > sudo apt-get install libqt4-dev > sudo apt-get install g++ automake > sudo apt-get install qt4-dev-tools qt4-designer qt4-doc > sudo apt-get install libqt4-opengl-dev > sudo apt-get install libqt4-sql-mysql libqt4-sql-odbc libqt4-

ImportError: No module named PyQt4.QtGui

2011-08-04 Thread 守株待兔
i have installed such things: sudo apt-get install libqt4-dev sudo apt-get install g++ automake sudo apt-get install qt4-dev-tools qt4-designer qt4-doc sudo apt-get install libqt4-opengl-dev sudo apt-get install libqt4-sql-mysql libqt4-sql-odbc libqt4-sql-psql libqt4-sql-sqlite libqt4-sql-sqlite

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 04.08.2011 10:42 schrieb Chris Rebert: I was considering the more general case where one of the strings may have come from user input. You then need to also escape $looks_like_a_var, `some_command`, and way more other such stuff that your simple function doesn't cover. Even these things are

Re: Inconsistent SMTP/Gmail connection drop

2011-08-04 Thread Astley Le Jasper
Just to add a little bit to the mix, I have started having these problems since I rebuilt my machine (Xubuntu 11) and I changed the disc formats to ext4 without even thinking about it ... I was wondering if maybe that had something to do with it? -- http://mail.python.org/mailman/listinfo/python-l

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Chris Rebert
On Thu, Aug 4, 2011 at 1:10 AM, Thomas Rachel wrote: > Am 03.08.2011 19:27 schrieb Chris Rebert: > >>>                     shell= True, >> >> I would strongly encourage you to avoid shell=True. > > ACK, but not because it is hard, but because it is unnecessary and unelegant > at this point. > >> Y

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 03.08.2011 17:29 schrieb Phlip: Groupies: This is either a code snippet, if you like it, or a request for a critique, if you don't. Well, at first, I cannot see the real point about it... def command(*cmdz): process = Popen( flatten(cmdz), shell= True,

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 03.08.2011 19:27 schrieb Chris Rebert: shell= True, I would strongly encourage you to avoid shell=True. ACK, but not because it is hard, but because it is unnecessary and unelegant at this point. You really don't want to have to worry about doing proper shell esca

Re: Inconsistent SMTP/Gmail connection drop

2011-08-04 Thread Astley Le Jasper
Thanks for those suggestions. I tried something last night before I got your ideas. 1. I added a line to send a copy of the report just to me, 2 lines before the line where it emails the report to all the recipients. 2. I also added a timer.sleep(5) pause just before the line that emails the repo

finding the object corresponding to a stack frame

2011-08-04 Thread Eric Snow
For any given stack frame, the corresponding code object is derived most immediately from either a module [definition], a class definition, or function definition. I want to be able to determine the specific module, class, or function object for any arbitrary code/frame object. For modules it is

Re: making my extensions work together

2011-08-04 Thread Chris Angelico
On Thu, Aug 4, 2011 at 2:19 AM, Mathew wrote: > I have 2 extensions and they both access a function in a (static) library. > The function maintains state information using a static variable. If your extensions are DLLs and they're both linking to the same static library, you should have two indep

Re: Inconsistencies with tab/space indentation between Cygwin/Win32?

2011-08-04 Thread Chris Rebert
On Wed, Aug 3, 2011 at 9:25 PM, Christian Gelinek wrote: > Hi all, > > I have a problem running some python program using version 2.6.4 (or version > 2.7.2, I tried both) from the Win7 command line - it never finishes due to > an infinite loop. The thing is, when I run the same program through Cyg

Re: range() vs xrange() Python2|3 issues for performance

2011-08-04 Thread Chris Angelico
On Thu, Aug 4, 2011 at 4:01 AM, Steven D'Aprano wrote: >        a, b = divmod(n, i) >        if b == 0: >            total += a+i > Wouldn't this fail on squares? It happens to give correct results as far as I've checked; no square up to 10,000 is called perfect, and there are no perfect squares