Re: Implicit initialization is EXCELLENT

2011-07-07 Thread Ulrich Eckhardt
Ian Kelly wrote: > On Wed, Jul 6, 2011 at 12:49 AM, Ulrich Eckhardt > wrote: >> Mel wrote: >>> In wx, many of the window classes have Create methods, for filling in >>> various attributes in "two-step construction". [...] >> >> Just guessing, is it legacy, C-with-classes code rather than C++ code

Re: web browsing short cut

2011-07-07 Thread Cousin Stanley
Chris Angelico wrote: > > > http://blah/blah";> > http://another/blah";> > > > http://third/blah";> > http://final/blah";> > > > > That should divide your screen four ways > ( if I haven't botched my HTML > - ages since I've used frames ). html !botched :-

TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Kannan Varadhan
Hi Folks, Here is something I don't fully understand. 1 def DefaultTracer(fmt, *args): 2 fmt = 'in DefaultTracer ' + fmt 3 print(fmt % args) 4 pass 5 def myTracer(fmt, *args): 6 fmt = 'in myTracer ' + fmt 7 print(fmt % args) 8 9 class MyClass: 10 ClassDefaultTracer

Re: wx MenuItem - icon is missing

2011-07-07 Thread Laszlo Nagy
I can understand why it's frustrating but a menu items with icons on them aren't exactly common, so you're wandering into territory that's probably not so throughly explored (nor standard across platforms). Now that I think about it, I don't know that I've ever seen one under OSX, and I don't

more advanced learning resources (code structure, fundamentals)

2011-07-07 Thread John [H2O]
Hello, I've been programming in Python for a few years now. I have read most the typical learning resources, such as 'Dive Into Python', 'A Byte of Python', etc. In general I feel I have a good overview of the language. However, as I advanced toward trying to create more OO styled programs, I fee

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Peter Otten
Kannan Varadhan wrote: > Here is something I don't fully understand. > > 1 def DefaultTracer(fmt, *args): > 2 fmt = 'in DefaultTracer ' + fmt > 3 print(fmt % args) > 4 pass > 5 def myTracer(fmt, *args): > 6 fmt = 'in myTracer ' + fmt > 7 print(fmt % args) > 8 > 9 class

Re: Large number multiplication

2011-07-07 Thread Ulrich Eckhardt
Billy Mays wrote: > On 07/06/2011 04:02 PM, Ian Kelly wrote: >> According to Wikipedia: >> >> """ >> In practice the Schönhage–Strassen algorithm starts to outperform >> older methods such as Karatsuba and Toom–Cook multiplication for >> numbers beyond 2**2**15 to 2**2**17 (10,000 to 40,000 decimal

find max and min values from a column of a csv file

2011-07-07 Thread prakash jp
Hi All , Could any one help to get max and min values from a specified column of a csv file. The* csv file is large* and hence the below code did go bad. *Alternate methods would be highly appreciated ** minimum.py*: import csv filename = "testLog_4.csv" f = open(filename) def col_min(mincname):

Re: bash: testing whether anyone is or has recently been logged in?

2011-07-07 Thread Adam Funk
On 2011-04-20, Bill Marcum wrote: > On 2011-04-20, Adam Funk wrote: >> I'd appreciate any suggestions for testing (preferably from a bash >> script, although perl or python would be OK too) whether anyone is >> currently logged in, and whether anyone has been logged in during the >> past $N minut

Re: find max and min values from a column of a csv file

2011-07-07 Thread John [H2O]
I think you would benefit from reading the data into a numpy array first, then using numpy min, max functions. prakash jp wrote: > > Hi All , > > Could any one help to get max and min values from a specified column of a > csv file. The* csv file is large* and hence the below code did go bad.

Re: more advanced learning resources (code structure, fundamentals)

2011-07-07 Thread Mel
John [H2O] wrote: [ ... ] > What are the key points to the classes? Is it okay to reference or pass > classes to instantiate a class? Yes. The standard library does this in BaseHTTPServer (via its parent SocketServer.) Maybe looks abstruse at the outset, but it's the natural way to assign a f

Re: Does hashlib support a file mode?

2011-07-07 Thread Anssi Saari
Mel writes: > def file_to_hash(path, m = hashlib.md5()): > > hashlib.md5 *is* called once; that is when the def statement is executed. Very interesting, I certainly wasn't clear on this. So after that def, the created hashlib object is in the module's scope and can be accessed via file_to_hash._

blist question

2011-07-07 Thread dmitrey
hi all, I feel lack of native Python lists operations (e.g. taking N greatest elements with the involved key function and O(n) speed) and occasionally found blist http://pypi.python.org/pypi/blist/ Its entry says it is better than Python list. Did anyone ensure? Will it ever be merged into Python s

Re: Does hashlib support a file mode?

2011-07-07 Thread Paul Rudin
Anssi Saari writes: > Mel writes: > >> def file_to_hash(path, m = hashlib.md5()): >> >> hashlib.md5 *is* called once; that is when the def statement is executed. > > Very interesting, I certainly wasn't clear on this. So after that def, > the created hashlib object is in the module's scope and c

Re: find max and min values from a column of a csv file

2011-07-07 Thread Peter Otten
prakash jp wrote: > Could any one help to get max and min values from a specified column of a > csv file. The* csv file is large* and hence the below code did go bad. > *Alternate > methods would be highly appreciated > ** > minimum.py*: > import csv > filename = "testLog_4.csv" > f = open(filenam

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Steven D'Aprano
Kannan Varadhan wrote: > Hi Folks, > > Here is something I don't fully understand. > > 1 def DefaultTracer(fmt, *args): > 2 fmt = 'in DefaultTracer ' + fmt > 3 print(fmt % args) > 4 pass > 5 def myTracer(fmt, *args): > 6 fmt = 'in myTracer ' + fmt > 7 print(fmt % args) P

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Paul Rudin
Steven D'Aprano writes: > Please don't post code with line numbers. That makes it difficult to copy > and paste your function into an interactive session, so that we can run it > and see what it does. C-x r d -- http://mail.python.org/mailman/listinfo/python-list

Re: Does hashlib support a file mode?

2011-07-07 Thread Andrew Berg
On 2011.07.06 06:16 PM, Steven D'Aprano wrote: > Phlip wrote: > > > Note the fix also avoids comparing to None, which, as usual, is also > > icky and less typesafe! > > "Typesafe"? Are you trying to make a joke? Maybe he has a duck phobia. Maybe he denies the existence of ducks. Maybe he doesn't li

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Peter Otten
Peter Otten wrote: > or you wrap the callable in a descriptor: > def DefaultTracer(*args): print args > ... class D(object): > ... def __init__(self, f): > ... self.f = f > ... def __get__(self, *args): > ... return self.f > ... After skimming over Steve

Re: Does hashlib support a file mode?

2011-07-07 Thread Phlip
> On 2011.07.06 06:16 PM, Steven D'Aprano wrote:> Phlip wrote: > > > > Note the fix also avoids comparing to None, which, as usual, is also > > > icky and less typesafe! > > > "Typesafe"? Are you trying to make a joke? No, I was pointing out that passing a type is more ... typesafe. -- http://ma

Re: Does hashlib support a file mode?

2011-07-07 Thread Andrew Berg
On 2011.07.07 08:11 AM, Phlip wrote: > No, I was pointing out that passing a type is more ... typesafe. None is a type. >>> None.__class__ -- http://mail.python.org/mailman/listinfo/python-list

Re: Does hashlib support a file mode?

2011-07-07 Thread Phlip
On Jul 7, 6:24 am, Andrew Berg wrote: > On 2011.07.07 08:11 AM, Phlip wrote:> No, I was pointing out that passing a > type is more ... typesafe. > > None is a type. I never said it wasn't. -- http://mail.python.org/mailman/listinfo/python-list

Re: Does hashlib support a file mode?

2011-07-07 Thread Andrew Berg
On 2011.07.07 08:39 AM, Phlip wrote: > On Jul 7, 6:24 am, Andrew Berg wrote: > > On 2011.07.07 08:11 AM, Phlip wrote:> No, I was pointing out that passing a > > type is more ... typesafe. > > > > None is a type. > > I never said it wasn't. You are talking about this code, right? def file_to_hash

Re: Testing if a global is defined in a module

2011-07-07 Thread Grant Edwards
On 2011-07-06, Waldek M. wrote: > Dnia Wed, 06 Jul 2011 03:36:24 +1000, Steven D'Aprano napisa?(a): >> Because unless you are extremely disciplined, code and the comments >> describing them get out of sync. [...] > True, but that gets far worse with external docs. Do you have in mind > any bette

Tips/lessons learned for writing a Python powered DSL?

2011-07-07 Thread python
Looking for tips and lessons learned (advice on what to do and not do) for writing a Python based DSL. Googling python dsl yields some wonderful content which I've just started to read. If there are specific articles or 3rd party libraries that you used to implement a DSL, I would appreciate heari

Re: Tips/lessons learned for writing a Python powered DSL?

2011-07-07 Thread Paul Woolcock
For me, diving into the data model really helped me grasp some of the metaprogramming capabilities that python has, which is helping me as I am implementing my own DSL in python. http://docs.python.org/reference/datamodel.html On Thu, Jul 7, 2011 at 10:20 AM, wrote: > Looking for tips and less

Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread António Rocha
Greetings I'm running Python (32b) in Windows7 (at 64bits) and I would like to know how can I check if my machine is a 32b or 64b in Python. Is it possible? I saw a few examples (like platform) but they only provide information about Python not the machine. Thanks Toze -- http://mail.python.org/m

Re: Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread Andrew Berg
On 2011.07.07 10:21 AM, António Rocha wrote: > I'm running Python (32b) in Windows7 (at 64bits) and I would like to > know how can I check if my machine is a 32b or 64b in Python. Is it > possible? I saw a few examples (like platform) but they only provide > information about Python not the machine

Re: Large number multiplication

2011-07-07 Thread Ian Kelly
On Thu, Jul 7, 2011 at 2:30 AM, Ulrich Eckhardt wrote: > Even worse, most people would actually pay for its use, because they don't > use numbers large enough to merit the Schönhage–Strassen algorithm. As it stands, Karatsuba is only used for numbers greater than a specific threshold. Adding Sch

Re: Large number multiplication

2011-07-07 Thread Ian Kelly
On Thu, Jul 7, 2011 at 9:49 AM, Ian Kelly wrote: > On Thu, Jul 7, 2011 at 2:30 AM, Ulrich Eckhardt > wrote: >> Even worse, most people would actually pay for its use, because they don't >> use numbers large enough to merit the Schönhage–Strassen algorithm. > > As it stands, Karatsuba is only used

Re: Implicit initialization is EXCELLENT

2011-07-07 Thread Ian Kelly
On Thu, Jul 7, 2011 at 1:12 AM, Ulrich Eckhardt wrote: >>> Just guessing, is it legacy, C-with-classes code rather than C++ code >>> perhaps? Haven't looked at wx for a while. Such code typically lacks >>> understanding of exceptions, which are the only way to signal failure >>> from e.g. construc

Re: Large number multiplication

2011-07-07 Thread Parerga
Hi, Billy Mays wrote: > >> On 07/06/2011 04:02 PM, Ian Kelly wrote: >> > On Wed, Jul 6, 2011 at 1:30 PM, Billy Mays wrote: >> >> I was looking through the python source and noticed that long >> multiplication >> >> is done using the Karatsuba method (O(~n^1.5)) rather than using FFTs >> O(~n >

Re: Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread Philip Reynolds
On Thu, 07 Jul 2011, Andrew Berg wrote: > On 2011.07.07 10:21 AM, António Rocha wrote: > > I'm running Python (32b) in Windows7 (at 64bits) and I would like to > > know how can I check if my machine is a 32b or 64b in Python. Is it > > possible? I saw a few examples (like platform) but they only p

Re: Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread Robert Kern
On 7/7/11 11:33 AM, Philip Reynolds wrote: On Thu, 07 Jul 2011, Andrew Berg wrote: On 2011.07.07 10:21 AM, António Rocha wrote: I'm running Python (32b) in Windows7 (at 64bits) and I would like to know how can I check if my machine is a 32b or 64b in Python. Is it possible? I saw a few example

Re: blist question

2011-07-07 Thread Daniel Stutzbach
On Thu, Jul 7, 2011 at 5:08 AM, dmitrey wrote: > I feel lack of native Python lists operations (e.g. taking N greatest > elements with the involved key function and O(n) speed) and > occasionally found blist > http://pypi.python.org/pypi/blist/ > > Its entry says it is better than Python list.

Re: Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread Brian Curtin
2011/7/7 António Rocha > Greetings > > I'm running Python (32b) in Windows7 (at 64bits) and I would like to know > how can I check if my machine is a 32b or 64b in Python. Is it possible? I > saw a few examples (like platform) but they only provide information about > Python not the machine. > Th

Programming tips :-)

2011-07-07 Thread Martin Schöön
I just found the following url in my archives at work and thought you might enjoy it: http://thc.org/root/phun/unmaintain.html /Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: module problem on windows 64bit

2011-07-07 Thread miamia
On Jul 5, 5:05 pm, Thomas Jollans wrote: > On 06/27/2011 06:59 PM, miamia wrote: > > > Hello, > > > on 32-bit windows everything works ok but on 64-bit win I am getting > > this error: > > Traceback (most recent call last): > >   File "app.py", line 1040, in do_this_now > >   File "kinterbasdb\__i

Re: blist question

2011-07-07 Thread Miki Tebeka
Have you looked at http://docs.python.org/library/collections.html#collections.deque ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit initialization is EVIL!

2011-07-07 Thread rantingrick
On Jul 7, 12:34 am, Gregory Ewing wrote: > rantingrick wrote: > > Yes but what benefit does that gain over say, Tkinter's design > > (because that has been your argument). > > Like I said, it's a tangential issue. Agreed. > The important thing is that it's okay for an app to stay > alive until i

Re: Large number multiplication

2011-07-07 Thread casevh
On Jul 7, 1:30 am, Ulrich Eckhardt wrote: > Billy Mays wrote: > > On 07/06/2011 04:02 PM, Ian Kelly wrote: > >> According to Wikipedia: > > >> """ > >> In practice the Schönhage–Strassen algorithm starts to outperform > >> older methods such as Karatsuba and Toom–Cook multiplication for > >> numbe

making socket.getaddrinfo use cached dns

2011-07-07 Thread high bandwidth
I use cached dns lookups with pdnsd on my ubuntu machine to speed up web access as regular lookups can take 15-30 seconds. However, python's mechanize and urllib etc use socket.getaddrinfo, which seems not to be using dns cacheing or taking a long time because of ipv6 lookups. In either case, I sub

i get different answers based on run platform

2011-07-07 Thread linda
I have this simple palindrome program that yields different results depending on whether I run it from Windows or from IDLE. The answer is correct off IDLE, but why is this the case? Here's the code: def reverse(text): return text[::-1] def is_palindrome(text): return text==reverse(text)

Re: Implicit initialization is EVIL!

2011-07-07 Thread Chris Angelico
On Fri, Jul 8, 2011 at 3:29 AM, rantingrick wrote: > So your argument is: >    """ A window hierarchy is bad because if your application requires > a user to open a gazillion windows (read as: designed poorly) --each > representing completely different transactions-- and if you close the > origina

Re: making socket.getaddrinfo use cached dns

2011-07-07 Thread Chris Angelico
On Fri, Jul 8, 2011 at 4:18 AM, high bandwidth wrote: > I use cached dns lookups with pdnsd on my ubuntu machine to speed up web > access as regular lookups can take 15-30 seconds. However, python's > mechanize and urllib etc use socket.getaddrinfo, which seems not to be using > dns cacheing or ta

Re: Programming tips :-)

2011-07-07 Thread Andrew Berg
On 2011.07.07 12:22 PM, Martin Schöön wrote: > I just found the following url in my archives at work and > thought you might enjoy it: > http://thc.org/root/phun/unmaintain.html That's awesome. > If a maintenance programmer can't quote entire Monty Python movies > from memory, he or she has *no* b

Re: i get different answers based on run platform

2011-07-07 Thread John Gordon
In <842fce9d-1b3f-434a-b748-a6dc4828c...@h12g2000pro.googlegroups.com> linda writes: > I have this simple palindrome program that yields different results > depending on whether I run it from Windows or from IDLE. The answer > is correct off IDLE, but why is this the case? Here's the code: Yo

Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman
linda wrote: I have this simple palindrome program that yields different results depending on whether I run it from Windows or from IDLE. The answer is correct off IDLE, but why is this the case? Here's the code: def reverse(text): return text[::-1] def is_palindrome(text): return text

Re: i get different answers based on run platform

2011-07-07 Thread MRAB
On 07/07/2011 19:18, linda wrote: I have this simple palindrome program that yields different results depending on whether I run it from Windows or from IDLE. The answer is correct off IDLE, but why is this the case? Here's the code: def reverse(text): return text[::-1] def is_palindrome(

Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman
John Gordon wrote: By the way, I could not make your program work as you provided it; I had to replace input() with raw_input(). Does it really work for you this way? input() is the 3.x name for raw_input() ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: i get different answers based on run platform

2011-07-07 Thread MRAB
On 07/07/2011 19:37, John Gordon wrote: In<842fce9d-1b3f-434a-b748-a6dc4828c...@h12g2000pro.googlegroups.com> linda writes: I have this simple palindrome program that yields different results depending on whether I run it from Windows or from IDLE. The answer is correct off IDLE, but why is

Serial & reset of the device

2011-07-07 Thread yorick
Hello, I'm trying to access a hardware board of my company through a serial connection using a Python script and the pyserial module. I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python- serial with version 2.5.2, http://pyserial.sourceforge.net/pyserial_api.html). The board to

multiprocessing.Manager().Namespace() and data copying

2011-07-07 Thread ichi
Hi! I'm trying to share data between processes using multiprocessing.Manager and  creating shared Namespace. I have the following code: from multiprocessing import Manager from scipy import rand x = rand(5000, 5000) m = Manager() n = m.Namespace() n.x = x   It seems that at n.x = x data is ser

Re: i get different answers based on run platform

2011-07-07 Thread linda
I tried something = input('enter text:').rstrip('\n') as suggested but the problem persists. BTW, the intermediate print commands agree and so are not an issue. The disagreement is in IDLE correctly identifying palindromes and Windows not. I do suspect it may be a trailing '\r' issue. Is there

Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman
linda wrote: I tried something = input('enter text:').rstrip('\n') as suggested but the problem persists. BTW, the intermediate print commands agree and so are not an issue. The disagreement is in IDLE correctly identifying palindromes and Windows not. I do suspect it may be a trailing '\r' is

Re: i get different answers based on run platform

2011-07-07 Thread linda
On Jul 7, 2:42 pm, Ethan Furman wrote: > linda wrote: > > I tried something = input('enter text:').rstrip('\n') as suggested but > > the problem persists.  BTW, the intermediate print commands agree and > > so are not an issue.  The disagreement is in IDLE correctly > > identifying palindromes and

Re: blist question

2011-07-07 Thread Raymond Hettinger
On Jul 7, 5:08 am, dmitrey wrote: > hi all, > I feel lack of native Python lists operations (e.g. taking N greatest > elements with the involved key function and O(n) speed) Take a look at heapq.nlargest()... > and > occasionally found blisthttp://pypi.python.org/pypi/blist/ > Its entry says it

Re: Testing if a global is defined in a module

2011-07-07 Thread Chris Rebert
On Thu, Jul 7, 2011 at 7:18 AM, Grant Edwards wrote: > On 2011-07-06, Waldek M. wrote: >> Dnia Wed, 06 Jul 2011 03:36:24 +1000, Steven D'Aprano napisa?(a): > >>> Because unless you are extremely disciplined, code and the comments >>> describing them get out of sync. [...] > >> True, but that gets

Re: Implicit initialization is EVIL!

2011-07-07 Thread Steven D'Aprano
rantingrick wrote: > On Jul 7, 12:34 am, Gregory Ewing wrote: >> The important thing is that it's okay for an app to stay >> alive until its *last* top level window is closed. I partially disagree with Greg on this. This is not the only model: on the Apple Mac, or any system with a similar GUI

Re: Does hashlib support a file mode?

2011-07-07 Thread Steven D'Aprano
Andrew Berg wrote: > On 2011.07.07 08:39 AM, Phlip wrote: >> On Jul 7, 6:24 am, Andrew Berg wrote: >> > On 2011.07.07 08:11 AM, Phlip wrote:> No, I was pointing out that >> > passing a type is more ... typesafe. >> > >> > None is a type. >> >> I never said it wasn't. Unfortunately, it isn't. No

Re: Implicit initialization is EVIL!

2011-07-07 Thread Gregory Ewing
rantingrick wrote: So you prefer to close a gazillion windows one by one? If I want to close all the windows, I can use the application's "Quit" or "Exit" command, or whatever the platform calls it. (Note that if there is a separate instance of the application for each window -- as was sugges

Re: Does hashlib support a file mode?

2011-07-07 Thread Andrew Berg
On 2011.07.07 08:46 PM, Steven D'Aprano wrote: > None is not a type, it is an instance. > > >>> isinstance(None, type) # is None a type? > False > >>> isinstance(None, type(None)) # is None an instance of None's type? > True > > So None is not itself a type, although it *has* a type: > > >>> type

Re: Programming tips :-)

2011-07-07 Thread Phlip
On Jul 7, 11:36 am, Andrew Berg wrote: > On 2011.07.07 12:22 PM, Martin Schöön wrote:> I just found the following url > in my archives at work and > > thought you might enjoy it: > >http://thc.org/root/phun/unmaintain.html > > That's awesome. That's "How To Write Unmaintainable Code" - a venera

Re: Does hashlib support a file mode?

2011-07-07 Thread Phlip
> I worded that poorly. None is (AFAIK) the only instance of NoneType, but > I should've clarified the difference.> The is operator does not compare > types, it compares instances for identity. None is typesafe, because it's strongly typed. However, what's even MORE X-safe (for various values of

Re: Serial & reset of the device

2011-07-07 Thread Dan Stromberg
On Thu, Jul 7, 2011 at 12:34 PM, yorick wrote: > Hello, > > I'm trying to access a hardware board of my company through a serial > connection using a Python script and the pyserial module. > > I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python- > serial with version 2.5.2, > htt

Hello Sweet Friends.

2011-07-07 Thread Ashraf Ali
I bring you a source of entertaintment.Just visit the following link and know about Bollywood actresses www.bollywoodactresseshotpictures.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: making socket.getaddrinfo use cached dns

2011-07-07 Thread Nobody
On Fri, Jul 8, 2011 at 4:18 AM, high bandwidth wrote: >> I use cached dns lookups with pdnsd on my ubuntu machine to speed up >> web access as regular lookups can take 15-30 seconds. However, python's >> mechanize and urllib etc use socket.getaddrinfo, which seems not to be >> using dns cacheing