Re: Many newbie questions regarding python

2010-10-08 Thread Steven D'Aprano
On Thu, 07 Oct 2010 18:34:58 -0700, alex23 wrote: > On Oct 8, 10:27 am, Steven D'Aprano cybersource.com.au> wrote: >> >     v = [0 for i in range(20)] >> >> Absolutely not. Such a code snippet is very common, in fact I've done >> it myself, but it is a "hammer solution" -- to a small boy with a >

Re: question about a program

2010-10-08 Thread Steven D'Aprano
On Thu, 07 Oct 2010 17:39:51 -0700, Logan Butler wrote: > question about an assignment: > places("home sweet home is here",' ') > [4, 10, 15, 18] > > this is my code: > > def places(x, y): > return [x.index(y) for v in x if (v == y)] > > so far I'm only getting > [4, 4, 4, 4] > > so

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 22:10:35 +0200, Hallvard B Furuseth wrote: > Jed Smith writes: > a = [1, 2, 3, 4, 5, 6] > a[::-1] >> [6, 5, 4, 3, 2, 1] > > Nice. Is there a trick to get a "-0" index too? Other than doing 'i or > len(L)' instead of 'i', that is. What exactly are you expecting? I do

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote: > On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano > wrote: >> On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: >> >>> Personnaly I find it horrible >>> that in the following expression: L[a:b:-1], it is impossible to give >>> a numeric

Re: script in Linux vs Windows

2010-10-08 Thread aurfalien
On Oct 8, 2010, at 4:27 PM, Ian Kelly wrote: On Fri, Oct 8, 2010 at 3:52 PM, wrote: Hi all, Unsure how to deal with what appears to be \n vs \r issues. The following code works in Linux; o = open("axenfs.reg") n = open("axenfs2.reg", "a") while 1: line = o.readline() if not line: break l

Re: script in Linux vs Windows

2010-10-08 Thread MRAB
On 08/10/2010 22:52, aurfal...@gmail.com wrote: Hi all, Unsure how to deal with what appears to be \n vs \r issues. The following code works in Linux; o = open("axenfs.reg") n = open("axenfs2.reg", "a") while 1: line = o.readline() if not line: break line = line.replace("dword:0","dw

Re: Help with sets

2010-10-08 Thread Gregory Ewing
Lawrence D'Oliveiro wrote: Did you know that applying the “set” or “frozenset” functions to a dict return a set of its keys? Seems a bit dodgy, somehow. That's just a consequence of the fact that dicts produce their keys when iterated over, and the set constructor iterates over whatever you

Re: Opening a webpage in the background via webbrowser.open()

2010-10-08 Thread Tim Chase
On 10/08/10 15:11, Vlastimil Brom wrote: webbrowser.open(url[, new=0[, autoraise=True]]) however, the sidenote in the docs also seems to apply: "If autoraise is True, the window is raised if possible (note that under many window managers this will occur regardless of the setting of this variable)

Re: script in Linux vs Windows

2010-10-08 Thread Ian Kelly
On Fri, Oct 8, 2010 at 3:52 PM, wrote: > Hi all, > > Unsure how to deal with what appears to be \n vs \r issues. > > The following code works in Linux; > > o = open("axenfs.reg") > n = open("axenfs2.reg", "a") > while 1: > line = o.readline() > if not line: break > line = line.replace("dword:0

Re: question about a program

2010-10-08 Thread Andreas Waldenburger
On Fri, 8 Oct 2010 14:34:21 -0700 Chris Rebert wrote: > On Thu, Oct 7, 2010 at 5:39 PM, Logan Butler > wrote: > > question about an assignment: > > > places("home sweet home is here",' ') > > [4, 10, 15, 18] > > > > this is my code: > > > > def places(x, y): > >    return [x.index(y) for v

script in Linux vs Windows

2010-10-08 Thread aurfalien
Hi all, Unsure how to deal with what appears to be \n vs \r issues. The following code works in Linux; o = open("axenfs.reg") n = open("axenfs2.reg", "a") while 1: line = o.readline() if not line: break line = line.replace("dword:0","dword:044e") n.write(line) n.close() But in Wind

Re: Unicode Decode Error

2010-10-08 Thread Ian Kelly
On Fri, Oct 8, 2010 at 3:31 PM, Pratik Khemka wrote: > *UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position > 152: ordinal not in range(128)*. Can someone please help me with this > error > The error occurs in line *wbk.save(p4_merge.xls)*. I have used * > import xlwt*..Can some

Re: Unicode Decode Error

2010-10-08 Thread Chris Rebert
On Fri, Oct 8, 2010 at 2:31 PM, Pratik Khemka wrote: > UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 152: > ordinal not in range(128). Can someone please help me with  this error > The error occurs in line wbk.save(p4_merge.xls). I have used > import xlwt..Can someone just t

Re: [Python-Dev] Inclusive Range

2010-10-08 Thread Ian
On Oct 8, 3:05 pm, Terry Reedy wrote: > > doesn't imply that the sequence I need is easiest defined by > > using aninclusivelower limit. What if I wanted all none-empty > > strings/tuples keys in the tree? > > Use 'a' as the lower bound, it being the string that follows ''. No, that would be '\0'

Re: Simple database explorer

2010-10-08 Thread Martin Gregorie
On Fri, 08 Oct 2010 02:04:39 -0700, dusans wrote: > On Oct 7, 7:49 am, Lawrence D'Oliveiro central.gen.new_zealand> wrote: >> In message >> <21c99273-ed58-4f93-b98a-d9292de5d...@k10g2000yqa.googlegroups.com>, >> dusans wrote: >> >> >  - all the others having ODBC drivers... >> >> ODBC seems to be

script in Linux vs Windows

2010-10-08 Thread aurfalien
Hi all, Unsure how to deal with what appears to be \n vs \r issues. The following code works in Linux; o = open("axenfs.reg") n = open("axenfs2.reg", "a") while 1: line = o.readline() if not line: break line = line.replace("dword:0","dword:044e") n.write(line) n.close() But in

Re: harmful str(bytes)

2010-10-08 Thread Terry Reedy
On 10/8/2010 9:31 AM, Hallvard B Furuseth wrote: That's not the point - the point is that for 2.* code which _uses_ str vs unicode, the equivalent 3.* code uses str vs bytes. Yet not the same way - a 2.* 'str' will sometimes be 3.* bytes, sometime str. So upgraded old code will have to expect

Re: harmful str(bytes)

2010-10-08 Thread Terry Reedy
On 10/8/2010 9:45 AM, Hallvard B Furuseth wrote: Actually, the implicit contract of __str__ is that it never fails, so that everything can be printed out (for debugging purposes, etc.). Nope: $ python2 -c 'str(u"\u1000")' Traceback (most recent call last): File "", line 1, in ? UnicodeEnco

Unicode Decode Error

2010-10-08 Thread Pratik Khemka
UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 152: ordinal not in range(128). Can someone please help me with this error The error occurs in line wbk.save(p4_merge.xls). I have used import xlwt..Can someone just tell what do I need to do to get rid of this error. I read

Re: question about a program

2010-10-08 Thread Chris Rebert
On Thu, Oct 7, 2010 at 5:39 PM, Logan Butler wrote: > question about an assignment: > places("home sweet home is here",' ') > [4, 10, 15, 18] > > this is my code: > > def places(x, y): >    return [x.index(y) for v in x if (v == y)] > > so far I'm only getting > [4, 4, 4, 4] > > so the first

Re: if the else short form

2010-10-08 Thread BartC
"NevilleDNZ" wrote in message news:ad9841df-49a1-4c1b-95d0-e76b72df6...@w9g2000prc.googlegroups.com... On Oct 7, 9:23 am, Lawrence D'Oliveiro wrote: x = {1 : "One", 2 : "Two", 3 : "Three"}.get(i, "None Of The Above") More like: x = {1:lambda:"One", 2:lambda:"Two", 3:lambda:"Three"}.get(i,

Re: Sys.exit in secondary threads

2010-10-08 Thread Ned Deily
In article , Pakal wrote: > I've noticed that there is nothing in python's documentation regarding > the use of sys.exit(code) in a non-main thread. > > As far as I've seen, the behaviour in this case is to simply exit the > thread, without caring about the return code. in the main thread > how

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Terry Reedy
On 10/8/2010 4:21 AM, Antoon Pardon wrote: On Wed, Oct 06, 2010 at 05:28:13PM -0400, Terry Reedy wrote: Strings and tuples are not natural numbers, but do have least members ('' and ()), so the bottom end had better be closed. Why? Because otherwise one can never include the least member i

Re: harmful str(bytes)

2010-10-08 Thread Antoine Pitrou
On Fri, 08 Oct 2010 15:45:58 +0200 Hallvard B Furuseth wrote: > Antoine Pitrou writes: > >Hallvard B Furuseth wrote: > >> The offender is bytes.__str__: str(b'foo') == "b'foo'". > >> It's often not clear from looking at a piece of code whether > >> some data is treated as strings or bytes, partic

Re: open file on mac

2010-10-08 Thread Brian Jones
On Fri, Oct 8, 2010 at 10:41 AM, tinauser wrote: > hallo, i'm sorry if the question is very stupid, but i cannot > understand what i'm doing wrong here. > > i have this myModule.py > > class Starter: >def init(self,num): >print "hithere!" >print "the answer is ",num >

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Arnaud Delobelle
Hallvard B Furuseth writes: > Jed Smith writes: > a = [1, 2, 3, 4, 5, 6] > a[::-1] >> [6, 5, 4, 3, 2, 1] > > Nice. Is there a trick to get a "-0" index too? > Other than doing 'i or len(L)' instead of 'i', that is. > L = [1,2,3,4,5] L[2:-2], L[2:-1], L[2:-0] # not quite right

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Arnaud Delobelle
Jed Smith writes: > On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano > wrote: >> On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: >> >>> Personnaly I find it horrible >>> that in the following expression: L[a:b:-1], it is impossible to give a >>> numeric value to b, that will include L[0]

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Hallvard B Furuseth
Jed Smith writes: a = [1, 2, 3, 4, 5, 6] a[::-1] > [6, 5, 4, 3, 2, 1] Nice. Is there a trick to get a "-0" index too? Other than doing 'i or len(L)' instead of 'i', that is. >>> L = [1,2,3,4,5] >>> L[2:-2], L[2:-1], L[2:-0] # not quite right:-) ([3], [3, 4], []) -- Hallvard -- htt

Re: Opening a webpage in the background via webbrowser.open()

2010-10-08 Thread Vlastimil Brom
2010/10/7 : > Python 2.7 (32-bit/Windows): Is there a way to use webbrowser.open() to open > a web page in the default browser, but in the background, so that the > application making the webbrowser.open() call remains the active > application? > > Thank you, > Malcolm > -- > http://mail.python.or

Re: question about a program

2010-10-08 Thread Richard Thomas
On Oct 8, 1:39 am, Logan Butler wrote: > question about an assignment: > > >>> places("home sweet home is here",' ') > > [4, 10, 15, 18] > > this is my code: > > def places(x, y): >     return [x.index(y) for v in x if (v == y)] > > so far I'm only getting > [4, 4, 4, 4] > > so the first value is

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Jed Smith
On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano wrote: > On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: > >> Personnaly I find it horrible >> that in the following expression: L[a:b:-1], it is impossible to give a >> numeric value to b, that will include L[0] into the reversed slice. > >

Re: question about a program

2010-10-08 Thread Andreas Waldenburger
On Thu, 7 Oct 2010 17:39:51 -0700 (PDT) Logan Butler wrote: > question about an assignment: > > >>> places("home sweet home is here",' ') > [4, 10, 15, 18] > > this is my code: > > def places(x, y): > return [x.index(y) for v in x if (v == y)] > > so far I'm only getting > [4, 4, 4, 4] >

Re: Many newbie questions regarding python

2010-10-08 Thread Carl Banks
On Oct 7, 4:10 pm, Rogério Brito wrote: [snip] > >     v = [0 for i in range(20)] > >     v = [0] * 20 > >     v = [] >     for i in range(20): v.append(0) > > What should I prefer? Any other alternative? The Pythonic way is to not to preinitialize the list at all. Don't put anything in the list

question about a program

2010-10-08 Thread Logan Butler
question about an assignment: >>> places("home sweet home is here",' ') [4, 10, 15, 18] this is my code: def places(x, y): return [x.index(y) for v in x if (v == y)] so far I'm only getting [4, 4, 4, 4] so the first value is correct, it is just not iterating on to the next three items it n

Re: open file on mac

2010-10-08 Thread Jason Swails
On Fri, Oct 8, 2010 at 3:39 PM, Jason Swails wrote: > > > On Fri, Oct 8, 2010 at 10:16 AM, tinauser wrote: > >> hi, sorry if it is a stupid qustio,but i cannot figure out where's the >> problem. >> i've a simpleModule: >> class Starter: >>def init(self,num): >> > > If you want this to execut

Re: SysLogHandler message formatting

2010-10-08 Thread Dustin C. Hatch
On Oct 7, 6:18 am, Vinay Sajip wrote: > Thanks for the detailed report. I tried posting a response a couple of times, > but Google appears to have swallowed it ... trying again. Sorry if it results > in > multiple responses. Hmm, I too seem to be experiencing this problem... > The SysLogHandler

Re: open file on mac

2010-10-08 Thread Jason Swails
On Fri, Oct 8, 2010 at 10:16 AM, tinauser wrote: > hi, sorry if it is a stupid qustio,but i cannot figure out where's the > problem. > i've a simpleModule: > class Starter: >def init(self,num): > If you want this to execute upon declaring an instance of Starter, rename this as __init__. >

Re: harmful str(bytes)

2010-10-08 Thread Hallvard B Furuseth
Steven D'Aprano writes: >On Fri, 08 Oct 2010 15:31:27 +0200, Hallvard B Furuseth wrote: >> That's not the point - the point is that for 2.* code which _uses_ str >> vs unicode, the equivalent 3.* code uses str vs bytes. Yet not the same >> way - a 2.* 'str' will sometimes be 3.* bytes, sometime st

Re: open file on mac

2010-10-08 Thread Emile van Sebille
On 10/8/2010 7:16 AM tinauser said... hi, sorry if it is a stupid qustio,but i cannot figure out where's the problem. i've a simpleModule: class Starter: def init(self,num): print "hithere!" print "the answer is ",num import sys,os print "path:",sys.path

Re: open file on mac

2010-10-08 Thread Andreas Waldenburger
On Fri, 8 Oct 2010 07:16:13 -0700 (PDT) tinauser wrote: > on mac I get an error if i do not give the full path of initfile.py > (commented out in the code above); > on windows i did not have this problem. > Am I missing anything? open("initfile.py") opens initfile.py in the current working direc

Re: Ordering tests in a testsuite

2010-10-08 Thread Mike Kent
But sometimes you just wanna do it the way you wanna do it. If you name your tests like 'test_01_yadda' and test_02_whatever', then they will be run in the order you want, as given by the numbers. -- http://mail.python.org/mailman/listinfo/python-list

how to handle network failures

2010-10-08 Thread harryos
hi I am trying to write a DataGrabber which reads some data from given url..I made DataGrabber as a Thread and want to wait for some interval of time in case there is a network failure that prevents read(). I am not very sure how to implement this class DataGrabber(threading.Thread): def __in

Re: Many newbie questions regarding python

2010-10-08 Thread Andreas Waldenburger
On Thu, 7 Oct 2010 18:34:58 -0700 (PDT) alex23 wrote: > On Oct 8, 10:27 am, Steven D'Aprano cybersource.com.au> wrote: > > >     v = [0 for i in range(20)] > > > > Absolutely not. Such a code snippet is very common, in fact I've > > done it myself, but it is a "hammer solution" -- to a small boy

Re: frozendict (v0.1)

2010-10-08 Thread Arnaud Delobelle
kj wrote: > In <878w29kxjp@gmail.com> Arnaud Delobelle writes: > > >E.g., try with {1:'a', 1j:'b'} > > I see. Thanks for this clarification. I learned a lot from it. > > I guess that frozenset must have some way of canonicalizing the > order of its elements that is dependent on their Pytho

Unicode Support in Ruby, Perl, Python, Emacs Lisp

2010-10-08 Thread Xah Lee
here's my experiences dealing with unicode in various langs. Unicode Support in Ruby, Perl, Python, Emacs Lisp Xah Lee, 2010-10-07 I looked at Ruby 2 years ago. One problem i found is that it does not support Unicode well. I just checked today, it still doesn't. Just do a web search on blog and

Re: ConFoo spam?

2010-10-08 Thread Raymond Hettinger
On Oct 7, 10:01 am, Jack Diederich > [For the record > ConFoo /does/ interest me, but I can't take a week and a half off to > do that plus PyCon]. CooFoo is an excellent conference. Even in the non-python tracks, there are plenty of high quality talks that would be of interest to people tracking

open file on mac

2010-10-08 Thread tinauser
hallo, i'm sorry if the question is very stupid, but i cannot understand what i'm doing wrong here. i have this myModule.py class Starter: def init(self,num): print "hithere!" print "the answer is ",num import sys,os print "path:",sys.path print "bye"

Sys.exit in secondary threads

2010-10-08 Thread Pakal
I've noticed that there is nothing in python's documentation regarding the use of sys.exit(code) in a non-main thread. As far as I've seen, the behaviour in this case is to simply exit the thread, without caring about the return code. in the main thread however, the return code becomes the offici

Re: SysLogHandler message formatting

2010-10-08 Thread Dustin C. Hatch
On Oct 7, 6:18 am, Vinay Sajip wrote: > Thanks for the detailed report. I tried posting a response a couple of times, > but Google appears to have swallowed it ... trying again. Sorry if it results > in > multiple responses. Hmm, I too seem to be experiencing this problem... > The SysLogHandler

HI... WE R HOT COUPLES AND SEARCHING FOR HOT MAN, WOMAN OR COUPLES FOR REAL FUN

2010-10-08 Thread COUPLES FOR FUN
HI... WE R HOT COUPLES AND SEARCHING FOR HOT MAN, WOMAN OR COUPLES FOR REAL FUN JUST CLICK... http://adultfriendfinder.com/go/page/reg_form_video_03?pid=g1250650-ppc http://adultfriendfinder.com/go/page/reg_form_video_03?pid=g1250650-ppc http://adultfriendfinder.com/go/page/reg_form_video

Re: pywebkit - python bindings for webkit DOM (alpha)

2010-10-08 Thread lkcl
apologies for the 3 copies of the post: mail.python.org's SMTP service was offline yesterday. just a quick update: XMLHttpRequest support has been fixed today, and the correct version of libsoup discovered which actually works. that puts PythonWebkit into a "useful and useable" state, despite bei

Re: Simple database explorer

2010-10-08 Thread dusans
On Oct 7, 7:49 am, Lawrence D'Oliveiro wrote: > In message > <21c99273-ed58-4f93-b98a-d9292de5d...@k10g2000yqa.googlegroups.com>, dusans > wrote: > > >  - all the others having ODBC drivers... > > ODBC seems to be something you use when you can’t use a proper database > driver. yes. first i have

Re: Many newbie questions regarding python

2010-10-08 Thread nn
On Oct 7, 7:10 pm, Rogério Brito wrote: > Hi there. > > I am used to some languages like C, but I am just a complete newbie with > Python > and, while writing some small snippets, I had encountered some problems, with > which I would sincerely appreciate any help, since I appreciate this language

google.com/trends

2010-10-08 Thread pooja kavala
google.com/trends -- http://mail.python.org/mailman/listinfo/python-list

Re: SysLogHandler message formatting

2010-10-08 Thread Dustin C. Hatch
On Oct 7, 6:18 am, Vinay Sajip wrote: > Thanks for the detailed report. I tried posting a response a couple of times, > but Google appears to have swallowed it ... trying again. Sorry if it results > in > multiple responses. I tried to respond yesterday, but I also noticed this probelm. > The S

Re: Many newbie questions regarding python

2010-10-08 Thread alex23
On Oct 8, 10:27 am, Steven D'Aprano wrote: > >     v = [0 for i in range(20)] > > Absolutely not. Such a code snippet is very common, in fact I've done it > myself, but it is a "hammer solution" -- to a small boy with a hammer, > everything looks like a nail that needs hammering. Writing such a li

open file on mac

2010-10-08 Thread tinauser
hi, sorry if it is a stupid qustio,but i cannot figure out where's the problem. i've a simpleModule: class Starter: def init(self,num): print "hithere!" print "the answer is ",num import sys,os print "path:",sys.path try: #f = open("/Users/l

Re: if the else short form

2010-10-08 Thread NevilleDNZ
On Oct 7, 10:36 am, "BartC" wrote: > i=16 > x = {1 : fna(), 2 : fnb(), 3 : fnc()}.get(i, "None Of The Above") > print x > > Other than efficiency concerns, sometimes you don't want the extra > side-effects. > > Probably there are workarounds here too, but I suspect the syntax won't be > quite as p

Re: Many newbie questions regarding python

2010-10-08 Thread gregf...@gmail.com
On Oct 7, 6:10 pm, Rogério Brito wrote: > Hi there. > > I am used to some languages like C, but I am just a complete newbie with > Python > and, while writing some small snippets, I had encountered some problems, with > which I would sincerely appreciate any help, since I appreciate this language

Re: if the else short form

2010-10-08 Thread NevilleDNZ
On Oct 7, 9:23 am, Lawrence D'Oliveiro wrote: > x = {1 : "One", 2 : "Two", 3 : "Three"}.get(i, "None Of The Above") More like: x = {1:lambda:"One", 2:lambda:"Two", 3:lambda:"Three"}.get(i, lambda:"None Of The Above")() i.e. deferred evaluation of selected case. In Algol68 this would be: x:=(i|"

Re: PYTHON

2010-10-08 Thread Seebs
On 2010-10-08, k.. wrote: > PLEASE LEARN ME PYTHON Done! Please be sure to drop by sometimes to let us know how it's going, now that we've learned you Python. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ <-- lawsuits, rel

PYTHON

2010-10-08 Thread k..........
PLEASE LEARN ME PYTHON -- http://mail.python.org/mailman/listinfo/python-list

Re: Many newbie questions regarding python

2010-10-08 Thread Emile van Sebille
On 10/8/2010 10:15 AM Grant Edwards said... Damn. I should give up and go golfing. +1 QOTW Emile -- http://mail.python.org/mailman/listinfo/python-list

Re: harmful str(bytes)

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 15:31:27 +0200, Hallvard B Furuseth wrote: > Arnaud Delobelle writes: >>Hallvard B Furuseth writes: >>> I've been playing a bit with Python3.2a2, and frankly its charset >>> handling looks _less_ safe than in Python 2. (...) >>> With 2. conversion Unicode <-> string the equiva

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: > Personnaly I find it horrible > that in the following expression: L[a:b:-1], it is impossible to give a > numeric value to b, that will include L[0] into the reversed slice. >>> L = [1, 2, 3, 4, 5] >>> L[5:-6:-1] [5, 4, 3, 2, 1] --

Re: frozendict (v0.1)

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 14:00:17 +, kj wrote: > In kj writes: > >>At any rate, using your [i.e. Arnaud's] suggestions in this and your >>other post, the current implementation of frozendict stands at: > >>class frozendict(dict): >>for method in ('__delitem__ __setitem__ clear pop popitem'

Re: Many newbie questions regarding python

2010-10-08 Thread Grant Edwards
On 2010-10-08, Grant Edwards wrote: > On 2010-10-08, Grant Edwards wrote: >> On 2010-10-07, Rog??rio Brito wrote: >> >>> If possible, I would like to simply declare the list and fill it >>> latter in my program, as lazily as possible (this happens notoriously >>> when one is using a technique of

Re: Many newbie questions regarding python

2010-10-08 Thread Grant Edwards
On 2010-10-08, Grant Edwards wrote: > On 2010-10-07, Rog??rio Brito wrote: > >> If possible, I would like to simply declare the list and fill it >> latter in my program, as lazily as possible (this happens notoriously >> when one is using a technique of programming called dynamic >> programming w

Re: frozendict (v0.1)

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 12:10:50 +, kj wrote: > In <4cae667c$0$29993$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano > writes: > >>On Fri, 08 Oct 2010 00:23:30 +, kj wrote: > >>Because it's always better to use a well-written, fast, efficient, >>correct, well-tested wheel than to invent

Re: Many newbie questions regarding python

2010-10-08 Thread Grant Edwards
On 2010-10-07, Rog??rio Brito wrote: > If possible, I would like to simply declare the list and fill it > latter in my program, as lazily as possible (this happens notoriously > when one is using a technique of programming called dynamic > programming where initializing all positions of a table m

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-08 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message <87hbgyosdc@web.de>, Diez B. Roggisch wrote: Lawrence D'Oliveiro writes: In message <87d3rorf2f@web.de>, Diez B. Roggisch wrote: Lawrence D'Oliveiro writes: What exactly is the point of a BOM in a UTF-8-encoded file? It's a marker like the

Re: Many newbie questions regarding python

2010-10-08 Thread Tim Harig
On 2010-10-08, BartC wrote: > "Rogério Brito" wrote in message > news:i8lk0n$g3...@speranza.aioe.org... >> If possible, I would like to simply declare the list and fill it latter in >> my >> program, as lazily as possible (this happens notoriously when one is using >> a >> technique of program

Re: Help with pointers when calling from python to C

2010-10-08 Thread Jonas H.
On 10/08/2010 05:23 PM, Carolyn MacLeod wrote: "How do I pass an integer by reference to a C function?" That's impossible in pure Python. The only thing I can think of is a wrapper in C. -- http://mail.python.org/mailman/listinfo/python-list

Help with pointers when calling from python to C

2010-10-08 Thread Carolyn MacLeod
Hi. This is kind of a cross-product question, having to do with accessibility on Linux using ATK (AT-SPI). However, I think it really boils down to a python question: "How do I pass an integer by reference to a C function?" I am using Accerciser (http://live.gnome.org/Accerciser), an accessibi

Re: frozendict (v0.1)

2010-10-08 Thread kj
In "Jonas H." writes: >Hope this helps :-) It did! Thanks! For one thing now I see that I was barking up the wrong tree in focusing on a canonical order, when, as the code you posted shows, it is actually not required for hashing. In fact, I'd come to the conclusion that frozensets had a c

Re: frozendict (v0.1)

2010-10-08 Thread kj
In "Jonas H." writes: >On 10/08/2010 02:23 AM, kj wrote: >Here's my implementation suggestion: >class frozendict(dict): > def _immutable_error(self, *args, **kwargs): > raise TypeError("%r object is immutable" % self.__class__.__name__) > __setitem__ = __delitem__ = clear = p

Re: frozendict (v0.1)

2010-10-08 Thread kj
In kj writes: >At any rate, using your [i.e. Arnaud's] suggestions in this and >your other post, the current implementation of frozendict stands >at: >class frozendict(dict): >for method in ('__delitem__ __setitem__ clear pop popitem setdefault ' > 'update').split(): >

Re: frozendict (v0.1)

2010-10-08 Thread Jonas H.
On 10/08/2010 03:27 PM, kj wrote: I tried to understand this by looking at the C source but I gave up after 10 fruitless minutes. (This has been invariably the outcome of all my attempts at finding my way through the Python C source.) It's not you. CPython's code is ... [censored] Anyway, you

Re: harmful str(bytes)

2010-10-08 Thread Hallvard B Furuseth
Antoine Pitrou writes: >Hallvard B Furuseth wrote: >> The offender is bytes.__str__: str(b'foo') == "b'foo'". >> It's often not clear from looking at a piece of code whether >> some data is treated as strings or bytes, particularly when >> translating from old code. Which means one cannot see fro

Re: mantissa and exponent in base 10

2010-10-08 Thread C or L Smith
Jason Swails wrote: >> s = ('%%%ig' % sigfigs) % n # double-% cancels the % Thanks! I see that the parenthesis can be dropped, too: >>> '%%.%ig' % 3 % 4.23456e-5 '4.23e-05' /c -- http://mail.python.org/mailman/listinfo/python-list

Re: harmful str(bytes)

2010-10-08 Thread Hallvard B Furuseth
Arnaud Delobelle writes: >Hallvard B Furuseth writes: >> I've been playing a bit with Python3.2a2, and frankly its charset >> handling looks _less_ safe than in Python 2. >> (...) >> With 2. conversion Unicode <-> string the equivalent operation did >> not silently produce garbage: it raised Unico

Re: frozendict (v0.1)

2010-10-08 Thread kj
In <878w29kxjp@gmail.com> Arnaud Delobelle writes: >E.g., try with {1:'a', 1j:'b'} I see. Thanks for this clarification. I learned a lot from it. I guess that frozenset must have some way of canonicalizing the order of its elements that is dependent on their Python values but not on their

Re: Many newbie questions regarding python

2010-10-08 Thread BartC
"Rogério Brito" wrote in message news:i8lk0n$g3...@speranza.aioe.org... My first try to write it in Python was something like this: v = [] for i in range(20): v[i] = 0 Unfortunately, this doesn't work, as I get an index out of bounds when trying to index the v list. Python can't grow

Re: frozendict (v0.1)

2010-10-08 Thread kj
In <4cae667c$0$29993$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano writes: >On Fri, 08 Oct 2010 00:23:30 +, kj wrote: >Because it's always better to use a well-written, fast, efficient, >correct, well-tested wheel than to invent your own slow, incorrect >wheel :) IOW, "don't you wo

Re: frozendict (v0.1)

2010-10-08 Thread Jonas H.
On 10/08/2010 02:23 AM, kj wrote: I imagine that frozenset is better than sorted(tuple(...)) here, but it's not obvious to me why. dicts are unsorted. That means their item-order is undefined. So are sets. If you want a hash that is independent from the order of items, you could ensure the it

Re: Many newbie questions regarding python

2010-10-08 Thread Jean-Michel Pichavant
Rogério Brito wrote: class C: f = 1 def g(self): return f I get an annoying message when I try to call the g method in an object of type C, telling me that there's no global symbol called f. If I make g return self.f instead, things work as expected, but the code loses some reada

Re: add bitbucket repo url to install_requires

2010-10-08 Thread Chris Withers
On 05/10/2010 12:43, Julian wrote: I'm developing a django app which depends on an app in a private bitbucket repository, for example ssh://h...@bitbucket.org/username/my-django-app. is it possible to add this url to the list of install_requires in my setup.py? tried various possibilities, but n

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Antoon Pardon
On Wed, Oct 06, 2010 at 05:28:13PM -0400, Terry Reedy wrote: > On 10/6/2010 7:14 AM, Antoon Pardon wrote: > > >>That right-hand-half-open intervals (i.e. a<= i< b, equivalently [a, > >>b) ), which are what Python uses, are to be preferred. > >>(See aforelinked PDF: http://www.cs.utexas.edu/users/

Re: harmful str(bytes)

2010-10-08 Thread Antoine Pitrou
On Thu, 07 Oct 2010 23:33:35 +0200 Hallvard B Furuseth wrote: > > The offender is bytes.__str__: str(b'foo') == "b'foo'". > It's often not clear from looking at a piece of code whether > some data is treated as strings or bytes, particularly when > translating from old code. Which means one cann