Re: Reversing backslashed escape sequences

2010-06-30 Thread Steven D'Aprano
On Wed, 30 Jun 2010 23:11:59 -0700, Chris Rebert wrote: > Python 2.6.5 (r265:79063, May 25 2010, 18:21:57) '\\xFF'.decode('string_escape') > '\xff' I knew unicode-escape, obviously, and then I tried just 'escape', but never thought of 'string_escape'. Thanks for the quick answer. -- Ste

Re: Reversing backslashed escape sequences

2010-06-30 Thread Mark Tolonen
"Steven D'Aprano" wrote in message news:4c2c2cab$0$14136$c3e8...@news.astraweb.com... I have a byte-string which is an escape sequence, that is, it starts with a backslash, followed by either a single character, a hex or octal escape sequence. E.g. something like one of these in Python 2.5: '

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread Ryan Kelly
On Wed, 2010-06-30 at 16:20 -0700, ru...@yahoo.com wrote: > On Jun 30, 10:48 am, John Nagle wrote: > > On 6/30/2010 12:13 AM, Дамјан Георгиевски wrote: > > > > >> A 'raise-yield' expression would break the flow of a program just like > > >> an exception, going up the call stack until it would be h

Re: Reversing backslashed escape sequences

2010-06-30 Thread Chris Rebert
On Wed, Jun 30, 2010 at 10:50 PM, Steven D'Aprano wrote: > I have a byte-string which is an escape sequence, that is, it starts with > a backslash, followed by either a single character, a hex or octal escape > sequence. E.g. something like one of these in Python 2.5: > > '\\n' > '\\xFF' > '\\023'

Solutions for hand injury from computer use (was: I strongly dislike Python 3)

2010-06-30 Thread Ben Finney
geremy condra writes: > > Right. I'm much more concerned about the position of my Ctrl key, to > > avoid hand injury from all the key chording done as a programmer. > > Not saying its a cure-all, but I broke my hand pretty badly a few years > ago and had a lot of luck with a homemade foot switch

Reversing backslashed escape sequences

2010-06-30 Thread Steven D'Aprano
I have a byte-string which is an escape sequence, that is, it starts with a backslash, followed by either a single character, a hex or octal escape sequence. E.g. something like one of these in Python 2.5: '\\n' '\\xFF' '\\023' If s is such a string, what is the right way to un-escape them to s

Re: Python dynamic attribute creation

2010-06-30 Thread Stephen Hansen
On 6/30/10 10:37 PM, Aahz wrote: In article<4c29ad38$0$26210$426a7...@news.free.fr>, Bruno Desthuilliers wrote: Aahz a écrit : In article<4c285e7c$0$17371$426a7...@news.free.fr>, Bruno Desthuilliers wrote: Aahz a écrit : In article<4c2747c1$0$4545$426a7...@news.free.fr>, Bruno Desthuilliers

Re: Need instruction on how to use isinstance

2010-06-30 Thread alex23
Hans Mulder wrote: > There's also: hasattr(, '__call__').  It works in both 2.x and 3.x. Good work, Hans. I do find that to be a more pythonic approach, personally, being more concerned with an object's ability than its abstract type. -- http://mail.python.org/mailman/listinfo/python-list

Re: [farther OT] Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Michael Torrie
On 06/30/2010 06:36 PM, Lawrence D'Oliveiro wrote: > In message , > Michael Torrie wrote: > >> Okay, I will. Your code passes a char** when a char* is expected. > > No it doesn’t. You're right; it doesn't. Your code passes char (*)[512]. warning: passing argument 1 of ‘snprintf’ from incompati

Re: Python dynamic attribute creation

2010-06-30 Thread Aahz
In article <4c29ad38$0$26210$426a7...@news.free.fr>, Bruno Desthuilliers wrote: >Aahz a écrit : >> In article <4c285e7c$0$17371$426a7...@news.free.fr>, >> Bruno Desthuilliers wrote: >>> Aahz a écrit : In article <4c2747c1$0$4545$426a7...@news.free.fr>, Bruno Desthuilliers wrote: >>>

Re: I strongly dislike Python 3

2010-06-30 Thread geremy condra
On Thu, Jul 1, 2010 at 1:02 AM, Ben Finney wrote: > Steven D'Aprano writes: > >> On Thu, 01 Jul 2010 13:13:53 +1000, Ben Finney wrote: >> >> > Steven D'Aprano writes: >> >> I suppose in principle those extra three key presses (shift-9 >> >> shift-0 vs space) could be the straw that breaks the ca

Re: I strongly dislike Python 3

2010-06-30 Thread Ben Finney
Steven D'Aprano writes: > On Thu, 01 Jul 2010 13:13:53 +1000, Ben Finney wrote: > > > Steven D'Aprano writes: > >> I suppose in principle those extra three key presses (shift-9 > >> shift-0 vs space) could be the straw that breaks the camel's back, > >> but I doubt it. > > > > There's also Fitt

Re: I strongly dislike Python 3

2010-06-30 Thread Steven D'Aprano
On Thu, 01 Jul 2010 13:13:53 +1000, Ben Finney wrote: > Steven D'Aprano writes: > >> But, honestly, is there anyone here, even the most heavy users of >> print, who would seriously expect that adding parentheses to print >> calls will do more than add a tiny fraction to the amount of typing >> e

Re: Composition of functions

2010-06-30 Thread Mladen Gogala
On Wed, 30 Jun 2010 21:04:28 -0700, Stephen Hansen wrote: > On 6/30/10 8:50 PM, Mladen Gogala wrote: > x="quick brown fox jumps over a lazy dog" > y=''.join(list(x).reverse()) >> Traceback (most recent call last): >>File "", line 1, in >> TypeError > > >> >> Why is TypeError be

Re: Very odd output from subprocess

2010-06-30 Thread Chris Rebert
On Wed, Jun 30, 2010 at 9:12 PM, m wrote: > I have this function: > > > def GetMakeOutput(make, rules, out=None): >    p = subprocess.Popen('%s %s' % (make,rules), >                         shell=True, >                         bufsize=1024, >                         stderr=subprocess.PIPE, >    

Re: Composition of functions

2010-06-30 Thread Zubin Mithra
> Er, I don't think you thought that one entirely through (/ tried it out): > > My Apologies. Here is a working one. >>> x="123" >>> t = list(x) >>> t.reverse() >>> print ''.join(t) 321 But of course, the method which was suggested earlier is far more elegant. >>> print ''.join(reversed(list(

Re: Composition of functions

2010-06-30 Thread Chris Rebert
On Wed, Jun 30, 2010 at 9:09 PM, Zubin Mithra wrote: > Hello, > >> >>> y=list(x).reverse() >> >>> print y >> None > L = ["a", "b", "c"] L.reverse() L > ["c", "b", "a"] > > As you can see, L.reverse() performs the operation on itself and returns > nothing. Hence, the return type None

Very odd output from subprocess

2010-06-30 Thread m
I have this function: def GetMakeOutput(make, rules, out=None): p = subprocess.Popen('%s %s' % (make,rules), shell=True, bufsize=1024, stderr=subprocess.PIPE, stdout=subprocess.PIPE,

Re: Composition of functions

2010-06-30 Thread Zubin Mithra
Hello, >>> y=list(x).reverse() > >>> print y > None > >>> L = ["a", "b", "c"] >>> L.reverse() >>> L ["c", "b", "a"] As you can see, L.reverse() performs the operation on itself and returns nothing. Hence, the return type None. Instead of y=''.join(list(x).reverse()) you should probably do, >

Re: Composition of functions

2010-06-30 Thread Stephen Hansen
On 6/30/10 8:50 PM, Mladen Gogala wrote: x="quick brown fox jumps over a lazy dog" y=''.join(list(x).reverse()) Traceback (most recent call last): File "", line 1, in TypeError Why is TypeError being thrown? The reason for throwing the type error is the fact that the internal expressio

Composition of functions

2010-06-30 Thread Mladen Gogala
If I write things with the intermediate variables like below, everything works: >>> x="quick brown fox jumps over a lazy dog" >>> y=list(x) >>> y ['q', 'u', 'i', 'c', 'k', ' ', 'b', 'r', 'o', 'w', 'n', ' ', 'f', 'o', 'x', ' ', 'j', 'u', 'm', 'p', 's', ' ', 'o', 'v', 'e', 'r', ' ', 'a', ' ', 'l'

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread Carl Banks
On Jun 30, 12:13 am, Дамјан Георгиевски wrote: > > I'm writing this as a complete newbie (on the issue), so don't be > > surprised if it's the stupidest idea ever. > > > I was wondering if there was ever a discusision in the python > > community on a 'raise-yield' kind-of combined expression. I'd

Re: I strongly dislike Python 3

2010-06-30 Thread Ben Finney
Steven D'Aprano writes: > But, honestly, is there anyone here, even the most heavy users of > print, who would seriously expect that adding parentheses to print > calls will do more than add a tiny fraction to the amount of typing > effort already required to use Python? I suppose in principle th

Re: I strongly dislike Python 3

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 10:06 PM, Steven D'Aprano wrote: > On Wed, 30 Jun 2010 18:57:58 -0400, geremy condra wrote: > Actually, I agree with this complaint though- it is much easier to type spaces than parens. >>> >>> Yes. And typing "p" is easier than typing "print". Perhaps we should >

Re: I strongly dislike Python 3

2010-06-30 Thread MRAB
John Nagle wrote: On 6/27/2010 1:09 PM, Martin v. Loewis wrote: I agree that there may be not much reason to port custom proprietary apps that are working fine and which would hardly benefit from, let alone need, and new Py3 features. In the long run, there will be a benefit: at some point in

Re: I strongly dislike Python 3

2010-06-30 Thread Stephen Hansen
On 6/30/10 6:48 PM, John Nagle wrote: The 10th anniversary of the announcement of PERL 6 is coming up on July 19th, and it still hasn't displaced PERL 5 as the "primary" version. Now, I may be totally off-base, because I do not grok perl and so have never made much of an effort to follow perl-

Re: I strongly dislike Python 3

2010-06-30 Thread Steven D'Aprano
On Wed, 30 Jun 2010 18:57:58 -0400, geremy condra wrote: >>> Actually, I agree with this complaint though- it is much easier to >>> type spaces than parens. >> >> Yes. And typing "p" is easier than typing "print". Perhaps we should >> replace all Python built-ins with one letter names so that we c

Re: automate minesweeper with python

2010-06-30 Thread Paul McGuire
On Jun 30, 6:39 pm, Jay wrote: > I would like to create a python script that plays the Windows game > minesweeper. > > The python code logic and running minesweeper are not problems. > However, "seeing" the 1-8 in the minesweeper map and clicking on > squares is. I have no idea how to proceed. Yo

Re: I strongly dislike Python 3

2010-06-30 Thread John Nagle
On 6/27/2010 1:09 PM, Martin v. Loewis wrote: I agree that there may be not much reason to port custom proprietary apps that are working fine and which would hardly benefit from, let alone need, and new Py3 features. In the long run, there will be a benefit: at some point in the future (surely

Re: automate minesweeper with python

2010-06-30 Thread Ian Kelly
On Wed, Jun 30, 2010 at 7:15 PM, Jay wrote: > On Jun 30, 6:01 pm, Justin Ezequiel > wrote: >> you may want to have a look at sikulihttp://groups.csail.mit.edu/uid/sikuli/ > > Intresting, but I actually have something already in python I want to > modify. You should be able to use it with Jython.

Re: automate minesweeper with python

2010-06-30 Thread MRAB
Jay wrote: On Jun 30, 6:01 pm, Justin Ezequiel wrote: On Jul 1, 7:39 am, Jay wrote: I would like to create a python script that plays the Windows game minesweeper. The python code logic and running minesweeper are not problems. However, "seeing" the 1-8 in the minesweeper map and clicking on

Re: automate minesweeper with python

2010-06-30 Thread Jay
On Jun 30, 6:01 pm, Justin Ezequiel wrote: > On Jul 1, 7:39 am, Jay wrote: > > > I would like to create a python script that plays the Windows game > > minesweeper. > > > The python code logic and running minesweeper are not problems. > > However, "seeing" the 1-8 in the minesweeper map and click

Re: automate minesweeper with python

2010-06-30 Thread Justin Ezequiel
On Jul 1, 7:39 am, Jay wrote: > I would like to create a python script that plays the Windows game > minesweeper. > > The python code logic and running minesweeper are not problems. > However, "seeing" the 1-8 in the minesweeper map and clicking on > squares is. I have no idea how to proceed. you

Re: I strongly dislike Python 3

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 8:25 PM, rantingrick wrote: > On Jun 30, 4:21 pm, geremy condra wrote: > >> Actually, I agree with this complaint though- it is much easier to type >> spaces than parens. > > Oh Geremy please. If you're going to whine about something at least > find something worth whining

Re: [OT] Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Lawrence D'Oliveiro
In message , Michael Torrie wrote: > Okay, I will. Your code passes a char** when a char* is expected. No it doesn’t. > Consider this variation where I use a dynamically allocated buffer > instead of static: And so you misunderstand the difference between a C array and a pointer. -- http://ma

Re: I strongly dislike Python 3

2010-06-30 Thread rantingrick
On Jun 30, 4:21 pm, geremy condra wrote: > Actually, I agree with this complaint though- it is much easier to type > spaces than parens. Oh Geremy please. If you're going to whine about something at least find something worth whining about! Yes a few more key strokes are needed. But print should

Re: I strongly dislike Python 3

2010-06-30 Thread ru...@yahoo.com
On Jun 30, 9:42 am, Michele Simionato wrote: > Actually when debugging I use pdb which uses "p" (no parens) for > printing, so having > print or print() would not make any difference for me. Perhaps you don't use CJK strings much? p u'\u30d1\u30a4\u30c8\u30f3' give quite a different result than

Re: Need instruction on how to use isinstance

2010-06-30 Thread Hans Mulder
alex23 wrote: Stephen Hansen wrote: P.S. The removal of callable is something I don't understand in Python 3: while generally speaking I do really believe and use duck typing, I too have on occassion wanted to dispatch based on 'is callable? do x'. Sometimes its not convenient to do so via duck

automate minesweeper with python

2010-06-30 Thread Jay
I would like to create a python script that plays the Windows game minesweeper. The python code logic and running minesweeper are not problems. However, "seeing" the 1-8 in the minesweeper map and clicking on squares is. I have no idea how to proceed. -- http://mail.python.org/mailman/listinfo/py

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread ru...@yahoo.com
On Jun 30, 10:48 am, John Nagle wrote: > On 6/30/2010 12:13 AM, Дамјан Георгиевски wrote: > > >> A 'raise-yield' expression would break the flow of a program just like > >> an exception, going up the call stack until it would be handled, but > >> also like yield it would be possible to continue th

Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Cameron Simpson
On 30Jun2010 12:19, Paul Rubin wrote: | Cameron Simpson writes: | > The original V7 (and probably earlier) UNIX filesystem has 16 byte directory | > entries: 2 bytes for an inode and 14 bytes for the name. You could use 14 | > bytes of that name, and strncpy makes it effective to work with that d

Re: I strongly dislike Python 3

2010-06-30 Thread Mark Lawrence
On 30/06/2010 23:30, Steven D'Aprano wrote: [snips] The rule against premature optimization doesn't just apply to *code*. +1QOTW Kindest regards. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list

Re: I strongly dislike Python 3

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 6:30 PM, Steven D'Aprano wrote: > On Wed, 30 Jun 2010 17:21:32 -0400, geremy condra wrote: > >> On Wed, Jun 30, 2010 at 4:34 PM, Steven D'Aprano >> wrote: >>> On Wed, 30 Jun 2010 22:52:06 +1000, Lie Ryan wrote: >>> On 06/27/10 11:24, Steven D'Aprano wrote: >> > Pr

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stef Mientki
On 30-06-2010 20:56, Gary Herron wrote: > On 06/30/2010 11:39 AM, Stef Mientki wrote: >> hello, >> >> I've lot of functions that returns their result in some kind of tuple / list >> / array, >> and if there is no result, these functions return None. >> Now I'm often what to do something if I've m

Re: I strongly dislike Python 3

2010-06-30 Thread Brian Blais
On Jun 30, 2010, at 8:52 , Lie Ryan wrote: On 06/27/10 11:24, Steven D'Aprano wrote: Producing print function takes a little bit more effort than producing a print statement. (1) The main use-cases for print are quick (and usually dirty) scripts, interactive use, and as a debugging aid.

Re: I strongly dislike Python 3

2010-06-30 Thread Steven D'Aprano
On Wed, 30 Jun 2010 17:21:32 -0400, geremy condra wrote: > On Wed, Jun 30, 2010 at 4:34 PM, Steven D'Aprano > wrote: >> On Wed, 30 Jun 2010 22:52:06 +1000, Lie Ryan wrote: >> >>> On 06/27/10 11:24, Steven D'Aprano wrote: > > Producing print function takes a little bit more effort than > >

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Steven D'Aprano
Please pardon me for breaking threading, but Stef's original post has not come through to me. On 6/30/10 11:39 AM, Stef Mientki wrote: > hello, > > I've lot of functions that returns their result in some kind of tuple / > list / array, > and if there is no result, these functions return None.

Re: Ignorance and Google Groups (again)

2010-06-30 Thread Thomas Jollans
On 06/30/2010 10:55 PM, D'Arcy J.M. Cain wrote: > in all it's glory. > > :0: Hir > * ^List-Id:.*python-list.python.org > * ^From:@gmail.com > * ^Newsgroups: > /dev/null * X-Complaints-To: groups-ab...@google.com looks like a nice header to filter on -- http://mail.python.org/mailman/listi

Re: Ignorance and Google Groups (again)

2010-06-30 Thread Philip Semanchuk
On Jun 30, 2010, at 4:55 PM, D'Arcy J.M. Cain wrote: On Wed, 30 Jun 2010 13:10:43 -0700 (PDT) garryTX wrote: On Jun 29, 5:31 pm, nanothermite911fbibustards [...] you ignorant mf. stfu. You shouldn't be calling people ignorant for what they post if you are just going to repost every word

Re: Ignorance and Google Groups (again)

2010-06-30 Thread D'Arcy J.M. Cain
On Wed, 30 Jun 2010 14:18:55 -0700 Stephen Hansen wrote: > Okay, un-Bye :) Nice to be back. :-) -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http

Re: Ignorance and Google Groups (again)

2010-06-30 Thread rantingrick
On Jun 30, 3:55 pm, "D'Arcy J.M. Cain" wrote: > I have had it with GG.  For the last few months I have been filtering > all mail from gmail.com that comes through the news gateway into a > separate folder to see where the spam and abuse comes from.  Over that > time about 99% of all the useless c

Re: Using Python for web applications

2010-06-30 Thread Mithrandir
Wyatt Schwartz wrote in news:mailman.33.1277921551.1673.python-l...@python.org: > Dear Python-List members, > > Sorry for asking such a simple (or possibly complicated) question, as > I am new to Python programming. Anyways, I have read online that many > popular websites use Python for som

Re: Ignorance and Google Groups (again)

2010-06-30 Thread D'Arcy J.M. Cain
On Wed, 30 Jun 2010 17:25:55 -0400 geremy condra wrote: > If you get this, you get the gmail-but-not-google-groups stuff. Hello. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP)

Re: Ignorance and Google Groups (again)

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 5:15 PM, D'Arcy J.M. Cain wrote: > On Wed, 30 Jun 2010 14:06:05 -0700 > Stephen Hansen wrote: >> Gmail and Google Groups are not one and the same. There's a number of >> people who subscribe to the list directly, use Gmail, and don't go >> anywhere near Google Groups. > >

Re: I strongly dislike Python 3

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 4:34 PM, Steven D'Aprano wrote: > On Wed, 30 Jun 2010 22:52:06 +1000, Lie Ryan wrote: > >> On 06/27/10 11:24, Steven D'Aprano wrote: > Producing print function takes a little bit more effort than > producing a print statement. >>> >>> (1) The main use-cases for pr

Re: Ignorance and Google Groups (again)

2010-06-30 Thread Stephen Hansen
On 6/30/10 2:15 PM, D'Arcy J.M. Cain wrote: If anyone is interested in the procmail recipe I will be using, here it is in all it's glory. :0: Hir * ^List-Id:.*python-list.python.org * ^From:@gmail.com * ^Newsgroups: /dev/null As you can see, to be caught in the filter you need to have a gm

Re: Ignorance and Google Groups (again)

2010-06-30 Thread D'Arcy J.M. Cain
On Wed, 30 Jun 2010 14:06:05 -0700 Stephen Hansen wrote: > Gmail and Google Groups are not one and the same. There's a number of > people who subscribe to the list directly, use Gmail, and don't go > anywhere near Google Groups. I know that. My filter doesn't catch them. > > If anyone is inte

Re: Ignorance and Google Groups (again)

2010-06-30 Thread Stephen Hansen
On 6/30/10 1:55 PM, D'Arcy J.M. Cain wrote: I have had it with GG. For the last few months I have been filtering all mail from gmail.com that comes through the news gateway into a separate folder to see where the spam and abuse comes from. Over that time about 99% of all the useless crap has be

Re: Ignorance and Google Groups (again)

2010-06-30 Thread D'Arcy J.M. Cain
On Wed, 30 Jun 2010 13:10:43 -0700 (PDT) garryTX wrote: > On Jun 29, 5:31 pm, nanothermite911fbibustards [...] > you ignorant mf. stfu. You shouldn't be calling people ignorant for what they post if you are just going to repost every word again. Everything that applies to him applies to you. I

Re: I strongly dislike Python 3

2010-06-30 Thread Steven D'Aprano
On Wed, 30 Jun 2010 22:52:06 +1000, Lie Ryan wrote: > On 06/27/10 11:24, Steven D'Aprano wrote: >>> > Producing print function takes a little bit more effort than >>> > producing a print statement. >> >> (1) The main use-cases for print are quick (and usually dirty) scripts, >> interactive use, an

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Steven D'Aprano
On Wed, 30 Jun 2010 14:14:38 +, Jorgen Grahn wrote: > On Tue, 2010-06-29, Stephen Hansen wrote: >> On 6/29/10 5:41 AM, Roy Smith wrote: >>> Nobody wrote: >>> > And what about regular expressions? What about them? As the saying goes: Some people, when confronted with

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Emile van Sebille
On 6/30/2010 11:39 AM Stef Mientki said... hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: which work

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Ian Kelly
On Wed, Jun 30, 2010 at 12:39 PM, Stef Mientki wrote: > So I wonder why len is not allowed on None > and if there are objections to extend the len function . For the same reason that (None + 42) doesn't return 42, and that (None.upper()) doesn't return NONE. -- http://mail.python.org/mailman/lis

Re: Python as a scripting language. Alternative to bash script?

2010-06-30 Thread Mithrandir
Michael Torrie wrote in news:mailman.2313.1277759925.32709.python-l...@python.org: > On 06/28/2010 02:06 PM, Mithrandir wrote: >> I can't see Python as an alt. to bash. (As I recall) Python is much >> more object-oriented than bash, but also there are many commands >> (such as apt- get, etc.) th

Python/C++ timer intermittent bug

2010-06-30 Thread Paul
I have a problem with threading using the Python/C API. I have an extension that implements a timer, and the C++ timer callback function calls a Python function. The relevant code looks like this: static PyObject *timer_setmodname( PyObject *pSelf, PyObject *pArgs ) { char *b; PyA

Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Paul Rubin
Cameron Simpson writes: > The original V7 (and probably earlier) UNIX filesystem has 16 byte directory > entries: 2 bytes for an inode and 14 bytes for the name. You could use 14 > bytes of that name, and strncpy makes it effective to work with that data > structure. Why not use memcpy for that

Re: Ancient C string conventions

2010-06-30 Thread Paul Rubin
Jorgen Grahn writes: > It's somewhat believable. If I handled thousands of student names in a > big C array char[30][], I would resent the fact that 1/30 of the > memory was wasted on NUL bytes. But you'd be wasting even more of the memory on bytes left unused when the student's name is less tha

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Dave Angel
Stephen Hansen wrote: On 6/30/10 11:39 AM, Stef Mientki wrote: hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stephen Hansen
On 6/30/10 12:02 PM, Tim Chase wrote: On 06/30/2010 01:50 PM, Stephen Hansen wrote: On 6/30/10 11:39 AM, Stef Mientki wrote: if len ( Result )> 1 : But to prevent exceptions, i've to write ( I often forget) if Result and ( len ( Result )> 1 ) : Just do: if Result: You don't have to do a le

Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Carl Banks
On Jun 30, 2:55 am, Cameron Simpson wrote: > On 29Jun2010 21:49, Carl Banks wrote: > | On Jun 28, 2:44 am, Gregory Ewing wrote: > | > Carl Banks wrote: > | > > Indeed, strncpy does not copy that final NUL if it's at or beyond the > | > > nth element.  Probably the most mind-bogglingly stupid thi

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Tim Chase
On 06/30/2010 01:50 PM, Stephen Hansen wrote: On 6/30/10 11:39 AM, Stef Mientki wrote: if len ( Result )> 1 : But to prevent exceptions, i've to write ( I often forget) if Result and ( len ( Result )> 1 ) : Just do: if Result: You don't have to do a length check> 1; because if Resul

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stefan Behnel
Stef Mientki, 30.06.2010 20:39: I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Result )> 1 : But

Re: Using Python for web applications

2010-06-30 Thread Zubin Mithra
On Wed, Jun 30, 2010 at 11:34 PM, Wyatt Schwartz wrote: > Dear Python-List members, > > Sorry for asking such a simple (or possibly complicated) question, as I am > new to Python programming. Anyways, I have read online that many popular > websites use Python for some of their web-based applicatio

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Gary Herron
On 06/30/2010 11:39 AM, Stef Mientki wrote: hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Zubin Mithra
On Thu, Jul 1, 2010 at 12:09 AM, Stef Mientki wrote: > hello, > > I've lot of functions that returns their result in some kind of tuple / > list / array, > and if there is no result, these functions return None. > Now I'm often what to do something if I've more than 1 element in the > result. > S

Re: Using Python for web applications

2010-06-30 Thread Daniel Fetchinson
> Sorry for asking such a simple (or possibly complicated) question, as > I am new to Python programming. Anyways, I have read online that many > popular websites use Python for some of their web-based applications > (for example, Reddit), and that lead me to wonder how is this done? There are var

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stephen Hansen
On 6/30/10 11:39 AM, Stef Mientki wrote: hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Resul

Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stef Mientki
hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Result ) > 1 : But to prevent exceptions, i'

Using Python for web applications

2010-06-30 Thread Wyatt Schwartz
Dear Python-List members, Sorry for asking such a simple (or possibly complicated) question, as I am new to Python programming. Anyways, I have read online that many popular websites use Python for some of their web-based applications (for example, Reddit), and that lead me to wonder how is

Re: I strongly dislike Python 3

2010-06-30 Thread Stephen Hansen
On 6/30/10 9:22 AM, Lie Ryan wrote: On 07/01/10 01:30, Stephen Hansen wrote: On 6/30/10 5:52 AM, Lie Ryan wrote: On 06/27/10 11:24, Steven D'Aprano wrote: Producing print function takes a little bit more effort than producing a print statement. (1) The main use-cases for print are quick (and

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Ethan Furman
Terry Reedy wrote: On 6/30/2010 8:22 AM, Nobody wrote: I've noticed over the years a significant anti-RE sentiment in the Python community. IMHO, the sentiment isn't so much against REs per se, but against excessive or inappropriate use. Apart from making it easy to write illegible code, they

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Terry Reedy
On 6/30/2010 8:22 AM, Nobody wrote: I've noticed over the years a significant anti-RE sentiment in the Python community. IMHO, the sentiment isn't so much against REs per se, but against excessive or inappropriate use. Apart from making it easy to write illegible code, they also make it easy t

Re: numpy - save many arrays into a file object

2010-06-30 Thread Peter Otten
Laszlo Nagy wrote: > import numpy > data = numpy.array(...) > numpy.save("test.np",data) > > This is very good, but I want to save the data into a file object with a > write() method. E.g. not a real file. (My purpose right now is to save > many arrays into one binary file, while recording starti

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread John Nagle
On 6/30/2010 12:13 AM, Дамјан Георгиевски wrote: A 'raise-yield' expression would break the flow of a program just like an exception, going up the call stack until it would be handled, but also like yield it would be possible to continue the flow of the program from where it was raise-yield-ed.

Re: dynamically modify help text

2010-06-30 Thread Aahz
In article , Thomas Jollans wrote: > >% python2.6 >Python 2.6.5+ (release26-maint, Jun 28 2010, 19:46:36) >[GCC 4.4.4] on linux2 >Type "help", "copyright", "credits" or "license" for more information. class OLD: pass >... class NEW(object): pass >... OLD.__doc__ = "foo" NEW.__

Re: I strongly dislike Python 3

2010-06-30 Thread Lie Ryan
On 07/01/10 01:42, Michele Simionato wrote: > On Jun 30, 2:52 pm, Lie Ryan wrote: >> On 06/27/10 11:24, Steven D'Aprano wrote: >> > Producing print function takes a little bit more effort than producing a > print statement. >> >>> (1) The main use-cases for print are quick (and usually dir

Re: I strongly dislike Python 3

2010-06-30 Thread Lie Ryan
On 07/01/10 01:30, Stephen Hansen wrote: > On 6/30/10 5:52 AM, Lie Ryan wrote: >> On 06/27/10 11:24, Steven D'Aprano wrote: > Producing print function takes a little bit more effort than > producing a > print statement. >>> >>> (1) The main use-cases for print are quick (and usually dir

Re: numpy - save many arrays into a file object

2010-06-30 Thread Terry Reedy
On 6/30/2010 11:48 AM, Laszlo Nagy wrote: import numpy data = numpy.array(...) numpy.save("test.np",data) This is very good, but I want to save the data into a file object with a write() method. E.g. not a real file. (My purpose right now is to save many arrays into one binary file, while record

Re: git JSONRPC web service and matching pyjamas front-end

2010-06-30 Thread CM
On Jun 30, 4:27 am, "Martin P. Hellwig" wrote: > On 06/30/10 03:29, CM wrote:> On Jun 29, 6:54 pm, Luke Kenneth Casson > Leighton > > wrote: > >> as more than just a proof-of-concept but to get pyjamas out of looking > >> like "a nice toy, doesn't do much, great demos, shame about real > >> life"

numpy - save many arrays into a file object

2010-06-30 Thread Laszlo Nagy
import numpy data = numpy.array(...) numpy.save("test.np",data) This is very good, but I want to save the data into a file object with a write() method. E.g. not a real file. (My purpose right now is to save many arrays into one binary file, while recording starting positions of the arrays.)

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Daniel Fetchinson
> I have this python list that represets a sitemap: > > tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, > {'indent': 1, 'title':'Item 2', 'hassubfolder':False}, > {'indent': 1, 'title':'Folder 1', 'hassubfolder':True}, > {'indent': 2, 'title':'Sub Item 1.1'

Re: I strongly dislike Python 3

2010-06-30 Thread Michele Simionato
On Jun 30, 2:52 pm, Lie Ryan wrote: > On 06/27/10 11:24, Steven D'Aprano wrote: > > >> > Producing print function takes a little bit more effort than producing a > >> > print statement. > > > (1) The main use-cases for print are quick (and usually dirty) scripts, > > interactive use, and as a debu

Re: I strongly dislike Python 3

2010-06-30 Thread Stephen Hansen
On 6/30/10 5:52 AM, Lie Ryan wrote: On 06/27/10 11:24, Steven D'Aprano wrote: Producing print function takes a little bit more effort than producing a print statement. (1) The main use-cases for print are quick (and usually dirty) scripts, interactive use, and as a debugging aid. That is pre

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Stephen Hansen
On 6/30/10 7:14 AM, Jorgen Grahn wrote: On Tue, 2010-06-29, Stephen Hansen wrote: On 6/29/10 5:41 AM, Roy Smith wrote: Nobody wrote: And what about regular expressions? What about them? As the saying goes: Some people, when confronted with a problem, think "I know, I'll u

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Jorgen Grahn
On Wed, 2010-06-30, Kushal Kumaran wrote: > On Wed, Jun 30, 2010 at 2:04 PM, Nico Grubert wrote: >> Dear list members >> >> I have this python list that represets a sitemap: >> >> tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, >>        {'indent': 1, 'title':'Item 2', 'hassubfolder

Re: Find slope of function given empirical data.

2010-06-30 Thread Grant Edwards
On 2010-06-29, Thomas wrote: > Trying to find slope of function using numpy. Getting close, but > results are a bit off. Hope someone out here can help. > > import numpy as np > > def deriv(y): > x = list(range(len(y))) > x.reverse() # Change from [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Jorgen Grahn
On Tue, 2010-06-29, Stephen Hansen wrote: > On 6/29/10 5:41 AM, Roy Smith wrote: >> Nobody wrote: >> And what about regular expressions? >>> >>> What about them? As the saying goes: >>> >>> Some people, when confronted with a problem, think >>> "I know, I'll use regular expressions."

Re: [OT] Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Michael Torrie
On 06/30/2010 03:00 AM, Jorgen Grahn wrote: > On Wed, 2010-06-30, Michael Torrie wrote: >> On 06/29/2010 10:17 PM, Michael Torrie wrote: >>> On 06/29/2010 10:05 PM, Michael Torrie wrote: #include int main(int argc, char ** argv) { char *buf = malloc(512 * sizeof(char));

Re: pyc runtime error

2010-06-30 Thread Baris CUHADAR
On Jun 30, 3:10 pm, Thomas Jollans wrote: > On 06/30/2010 01:20 PM, Baris CUHADAR wrote: > > > > > On Jun 30, 12:06 pm, Christian Heimes wrote: > >>> Actually i wrote some scripts in python that are working as gateway > >>> controlling scripts iptables/tc/squid-proxy, and i want to execute > >>>

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Dave Angel
Nico Grubert wrote: Use a stack? Whenever you start a new list, push the corresponding closing tag onto a stack. Whenever your "indent level" decreases, pop the stack and write out the closing tag you get. It's straightforward to use a python list as a stack. Thanks for the tip, Kushal.

  1   2   >