Re: IDE+hg

2009-11-24 Thread alex23
NiklasRTZ wrote: > no py IDE I found has easy hg access. ActiveState's Komodo IDE has support for CVS, Perforce, subversion, bazaar, git and mercurial. -- http://mail.python.org/mailman/listinfo/python-list

Re: python and Postgresq

2009-11-24 Thread Tim Roberts
Krishnakant wrote: > >Python-pgsql is a much better choice when it comes to big applications, >specially if you are going to deal with xml-rpc. I have found that >python-pgsql handles integers and other such postgresql datatypes >better. I wonder if you would mind expanding on the experiences th

Re: get line number and filename in a source file

2009-11-24 Thread Dave Angel
Peng Yu wrote: __LINE__ __FILE__ in C++ can give the current line number and filename. Is there a similar thing in python that can give me the current line number and filename? Is there a similar thing to __PRETTY_FUNCTION__ (also from C++)? mod.__name__ gives the module name, and mod.__f

CentOS 5.3 vs. Python 2.5

2009-11-24 Thread John Nagle
My dedicated hosting provider wants to switch me to a new server with CentOS 5.3, so I have to look at how much work is required. CentOS 5.3 apparently still ships with Python 2.4. Worse, it requires Python 2.4 for its own internal purposes, and actually installing Python 2.5 breaks the pa

Re: get line number and filename in a source file

2009-11-24 Thread Rami Chowdhury
On Nov 24, 2009, at 21:47 , Peng Yu wrote: > __LINE__ __FILE__ in C++ can give the current line number and > filename. Is there a similar thing in python that can give me the > current line number and filename? > Is there a similar thing to __PRETTY_FUNCTION__ (also from C++)? What do you want to

Re: get line number and filename in a source file

2009-11-24 Thread Chris Rebert
On Tue, Nov 24, 2009 at 9:47 PM, Peng Yu wrote: > __LINE__ __FILE__ in C++ can give the current line number and > filename. Is there a similar thing in python that can give me the > current line number and filename? import inspect filename, linenum, funcname = inspect.getframeinfo(inspect.current

Re: Can "self" crush itself?

2009-11-24 Thread n00m
> Whatever you rebind ‘self’ to inside the function... Seems you are right! Thanks, Ben, for the lesson :-) class Moo: cnt = 0 def __init__(self, x): self.x = x self.__class__.cnt += 1 if self.__class__.cnt > 2: self.crush_me() def crush_me(self)

get line number and filename in a source file

2009-11-24 Thread Peng Yu
__LINE__ __FILE__ in C++ can give the current line number and filename. Is there a similar thing in python that can give me the current line number and filename? Is there a similar thing to __PRETTY_FUNCTION__ (also from C++)? -- http://mail.python.org/mailman/listinfo/python-list

Re: python gui builders

2009-11-24 Thread Shawn Wheatley
It's not quite all encompassing, but I found this link last year when looking for a similar comparison of Python GUIs: http://ginstrom.com/scribbles/2008/02/26/python-gui-programming-platforms-for-windows/ Tkinter, Qt, GTK, IronPython... I think the only thing missing is Jython w/ Swing or SWT. Ch

Re: Can "self" crush itself?

2009-11-24 Thread Ben Finney
n00m writes: > def crush_me(self): > print 'Will self be crushed?' > self = None As with any function, the parameter is bound to a *local* name, in this case the name ‘self’. Whatever you rebind ‘self’ to inside the function, the binding is lost once the function exits. None

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-24 Thread Chris Jones
On Tue, Nov 24, 2009 at 05:43:32PM EST, Steven D'Aprano wrote: > On Tue, 24 Nov 2009 13:19:10 -0500, Chris Jones wrote: > > > On Tue, Nov 24, 2009 at 08:02:09AM EST, Steven D'Aprano wrote: > > > >> Good grief, it's about six weeks away from 2010 and Thunderbird still > >> uses mbox as it's defaul

Can "self" crush itself?

2009-11-24 Thread n00m
Why does "h" instance stay alive? class Moo: cnt = 0 def __init__(self, x): self.x = x self.__class__.cnt += 1 if self.__class__.cnt > 2: self.crush_me() def crush_me(self): print 'Will self be crushed?' self = None f = Moo(1) g = Mo

Re: Raw strings as input from File?

2009-11-24 Thread Grant Edwards
On 2009-11-25, Rhodri James wrote: > On Tue, 24 Nov 2009 21:20:25 -, utabintarbo > wrote: > >> On Nov 24, 3:27 pm, MRAB wrote: >>> >>> .readlines() doesn't change the "\10" in a file to "\x08" in the string >>> it returns. >>> >>> Could you provide some code which shows your problem? >> >>

Re: python bijection

2009-11-24 Thread Joshua Bronson
On Nov 24, 6:49 pm, Gregory Ewing wrote: > Joshua Bronson wrote: > > So I'm > > thinking of renaming the class injectivedict or idict instead of > > bijection. Is that crazy?) > > I think you'd be better off calling it something more > down-to-earth such as bidict (bidirectional dictionary). > Tha

Re: attributes, properties, and accessors -- philosophy

2009-11-24 Thread Ethan Furman
Chris Rebert wrote: On Tue, Nov 24, 2009 at 9:39 AM, Ethan Furman wrote: Bruno Desthuilliers wrote: Ethan Furman a écrit : The problem I have with properties is my typing. I'll end up assigning to an attribute, but get the spelling slightly wrong (capitalized, or missing an underscore --

Re: Beginning Question about Python functions, parameters...

2009-11-24 Thread r
On Nov 24, 9:45 am, astral orange <457r0...@gmail.com> wrote: > > As for the "class Name():" example above? Even though I haven't seen > exactly what purpose 'self' serves > yet I can follow and understand what is going on very easily, that > helps out tremendously. > Very clearly written...Thank y

Re: Raw strings as input from File?

2009-11-24 Thread Rhodri James
On Wed, 25 Nov 2009 01:11:29 -, Rhodri James wrote: On Tue, 24 Nov 2009 21:20:25 -, utabintarbo wrote: On Nov 24, 3:27 pm, MRAB wrote: .readlines() doesn't change the "\10" in a file to "\x08" in the string it returns. Could you provide some code which shows your problem? H

Re: Raw strings as input from File?

2009-11-24 Thread Rhodri James
On Tue, 24 Nov 2009 21:20:25 -, utabintarbo wrote: On Nov 24, 3:27 pm, MRAB wrote: .readlines() doesn't change the "\10" in a file to "\x08" in the string it returns. Could you provide some code which shows your problem? Here is the code block I have so far: for l in open(CONTENTS,

Re: pointless musings on performance

2009-11-24 Thread Paul Boddie
On 24 Nov, 19:25, Antoine Pitrou wrote: > > Sorry, I have trouble parsing your sentence. Do you mean bytecode > interpretation overhead is minimal compared to the cost of actual useful > work, or the contrary? > (IMO both are wrong by the way) I'm referring to what you're talking about at the end

Re: python bijection

2009-11-24 Thread Gregory Ewing
Joshua Bronson wrote: So I'm thinking of renaming the class injectivedict or idict instead of bijection. Is that crazy?) I think you'd be better off calling it something more down-to-earth such as bidict (bidirectional dictionary). That way people without an advanced degree in mathematics have

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-24 Thread samwyse
On Nov 24, 4:43 pm, Steven D'Aprano wrote: > Oh yes, and people using Windows can't use maildir because (1) it doesn't > allow colons in names, and (2) it doesn't have atomic renames. Neither of > these are insurmountable problems: an implementation could substitute > another character for the co

Re: Newsgroup for beginners

2009-11-24 Thread John Machin
On Nov 17, 2:56 pm, Grant Edwards wrote: > On 2009-11-17, Paul Rubin wrote: > > > mrholtsr writes: > >> Is there a Python newsgroup for those who are strictly beginners at > >> programming and python? > > > This group has its grouchy moments > > You've really got to try pretty hard to create one

Re: Raw strings as input from File?

2009-11-24 Thread Terry Reedy
utabintarbo wrote: I have a log file with full Windows paths on a line. eg: K:\A\B\C\10xx\somerandomfilename.ext->/a1/b1/c1/10xx \somerandomfilename.ext ; txx; 11/23/2009 15:00:16 ; 1259006416 As I try to pull in the line and process it, python changes the "\10" to a "\x08". This should on

Re: Python-URL! - weekly Python news and links (Nov 24)

2009-11-24 Thread Erik Max Francis
Bruno Desthuilliers wrote: Cameron Laird a écrit : Grant Edwards on the best way to get help from this group :) http://groups.google.com/group/comp.lang.python/t/b8a0c32cae495522/21e80ac383745d88?#21e80ac383745d88 This one really deserves a POTM award !-) It is a bit surprising

Re: csv and mixed lists of unicode and numbers

2009-11-24 Thread Terry Reedy
Sibylle Koczian wrote: Peter Otten schrieb: I'd preprocess the rows as I tend to prefer the simplest approach I can come up with. Example: def recode_rows(rows, source_encoding, target_encoding): def recode(field): if isinstance(field, unicode): return field.encode(targ

Re: Where to put the error handing test?

2009-11-24 Thread Steven D'Aprano
On Tue, 24 Nov 2009 10:14:19 -0600, Peng Yu wrote: > I'll still confused by the guideline that an error should be caught as > early as possible. I think you are confused by what that means. It means the error should be caught as early as possible in *time*, not in the function chain. In Python,

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-24 Thread Steven D'Aprano
On Tue, 24 Nov 2009 13:19:10 -0500, Chris Jones wrote: > On Tue, Nov 24, 2009 at 08:02:09AM EST, Steven D'Aprano wrote: > >> Good grief, it's about six weeks away from 2010 and Thunderbird still >> uses mbox as it's default mail box format. Hello, the nineties called, >> they want their mail form

Re: Perl conversion to python...

2009-11-24 Thread Hans Mulder
J Kenneth King wrote: Benjamin Schollnick writes: select(undef, undef, undef, 0.01); # select() is a system call in Perl.. # insert Python equivalent here That would be: time.sleep(0.01) Perl has a sleep() built-in, but it truncates its argumen

Re: Beginning Question about Python functions, parameters...

2009-11-24 Thread Terry Reedy
Peter Otten wrote: Terry Reedy wrote: remember exactly what was stored. Maybe a typo. That's a bug in the store() function # as posted def store(data, full_name): names = full_name.split() if len(names) == 2: names.insert(1, '') labels = 'first', 'middle', 'last' for label,

Re: Securing a multiprocessing.BaseManager connection via SSL

2009-11-24 Thread Xavier Sanz
I recommend u to test it before use it in production environment. On 24 nov, 22:45, Xavier Sanz wrote: > Hi Jonas > > I've having same need so i found a solution but you need to hack a bit > > I am using python 2.6.3 but i suppose it could be applicable to your > case. > > First of all u need to

Re: pointless musings on performance

2009-11-24 Thread Terry Reedy
Chris Rebert wrote: On Tue, Nov 24, 2009 at 4:31 AM, Rob Williscroft wrote: mk wrote in news:mailman.915.1259064240.2873.python-l...@python.org in comp.lang.python: def pythonic(): def unpythonic(): Decidedly counterintuitive: are there special optimizations for "if nonevar:" type of state

Re: pointless musings on performance

2009-11-24 Thread Benjamin Peterson
Tim Wintle teamrubber.com> writes: > Out of interest - has anyone else spotted that the call to > PyObject_IsTrue in the XXX_JUMP_IF_ blocks performs two unnecessary > pointer comparisons? I doubt two pointer comparisons will make much of a difference. > Would it be worth in-lining the remai

Re: csv and mixed lists of unicode and numbers

2009-11-24 Thread Peter Otten
Sibylle Koczian wrote: > This problem really goes away with Python 3 (tried it on another > machine), but something else changes too: in Python 2.6 the > documentation for the csv module explicitly says "If csvfile is a file > object, it must be opened with the ‘b’ flag on platforms where that > m

Re: Raw strings as input from File?

2009-11-24 Thread Jon Clements
On Nov 24, 9:50 pm, Jon Clements wrote: > On Nov 24, 9:20 pm, utabintarbo wrote: [snip] > Although, "Pat\x08DJQ.D5-30Q5B-B-D5-BSHOE-MM.smz" and "Pat > \x08DJQ.D5-30Q5B-B-D5-BSHOE-MM.smz" seem to be fairly different -- are > you sure you're posting the correct output!? > Ugh... let's try that...

Re: Raw strings as input from File?

2009-11-24 Thread Jon Clements
On Nov 24, 9:20 pm, utabintarbo wrote: > On Nov 24, 3:27 pm, MRAB wrote: > > > > > .readlines() doesn't change the "\10" in a file to "\x08" in the string > > it returns. > > > Could you provide some code which shows your problem? > > Here is the code block I have so far: > for l in open(CONTENTS

Re: Securing a multiprocessing.BaseManager connection via SSL

2009-11-24 Thread Xavier Sanz
Hi Jonas I've having same need so i found a solution but you need to hack a bit I am using python 2.6.3 but i suppose it could be applicable to your case. First of all u need to edit /usr/lib/python2.6/lib/python2.6/ multiprocessing/connection.py This is mine: # # A higher level module for usi

Re: Creating a drop down filter in Admin site

2009-11-24 Thread Jon Clements
On Nov 24, 9:08 pm, Jase wrote: > Hoping someone could help me out. I am updating an admin site and > added a couple "list_filter"s. They are rather long so I wanted to > turn them into a drop down filter. Can this be done? Any suggestions? > > Thanks, > > Jase I'm guessing you mean Django - You

Re: Raw strings as input from File?

2009-11-24 Thread utabintarbo
On Nov 24, 3:27 pm, MRAB wrote: > > .readlines() doesn't change the "\10" in a file to "\x08" in the string > it returns. > > Could you provide some code which shows your problem? Here is the code block I have so far: for l in open(CONTENTS, 'r').readlines(): f = os.path.splitext(os.path.spli

Re: Where to put the error handing test?

2009-11-24 Thread Lie Ryan
Peng Yu wrote: On Tue, Nov 24, 2009 at 4:58 AM, Dave Angel wrote: I'll put an extra emphasis on this: Your question is so open-ended as to be unanswerable. I'll still confused by the guideline that an error should be caught as early

Re: Newsgroup for beginners

2009-11-24 Thread bruno.desthuilli...@gmail.com
On 20 nov, 20:42, Ethan Furman wrote: > Aahz wrote: > > In article , > > Grant Edwards   wrote: > > >>You've really got to try pretty hard to create one.  But if you > >>want to, here's how to do it: > > >>1) Start by complaining that your program doesn't work because > >>   of a bug in Python. >

Creating a drop down filter in Admin site

2009-11-24 Thread Jase
Hoping someone could help me out. I am updating an admin site and added a couple "list_filter"s. They are rather long so I wanted to turn them into a drop down filter. Can this be done? Any suggestions? Thanks, Jase -- http://mail.python.org/mailman/listinfo/python-list

Re: Inserting Unicode text with MySQLdb in Python 2.4-2.5?

2009-11-24 Thread Keith Hughitt
Hi John, Thanks for the suggestions: I have finally been able to get it working :) In anyone else runs into the same problem, here is some example code that works in Python 2.4+: = Begin Example == #!/usr/bin/env python #-*- coding:utf-8 -*- import sys def main():

Re: csv and mixed lists of unicode and numbers

2009-11-24 Thread Sibylle Koczian
Peter Otten schrieb: > I'd preprocess the rows as I tend to prefer the simplest approach I can come > up with. Example: > > def recode_rows(rows, source_encoding, target_encoding): > def recode(field): > if isinstance(field, unicode): > return field.encode(target_encoding)

Re: How to log messages _only once_ from all modules ?

2009-11-24 Thread Vinay Sajip
On Nov 24, 3:14 pm, Ron Barak wrote: > Many thanks Soltys, that did the trick (actually, no need for setting > propagate to 0), namely, > [snip] It might work for now, but instantiating a handler in an instance constructor can be an anti-pattern. If you ever create multiple client instances, for

Re: Raw strings as input from File?

2009-11-24 Thread Carsten Haese
utabintarbo wrote: > I have a log file with full Windows paths on a line. eg: > K:\A\B\C\10xx\somerandomfilename.ext->/a1/b1/c1/10xx > \somerandomfilename.ext ; txx; 11/23/2009 15:00:16 ; 1259006416 > > As I try to pull in the line and process it, python changes the "\10" > to a "\x08". Pytho

Re: Raw strings as input from File?

2009-11-24 Thread MRAB
utabintarbo wrote: I have a log file with full Windows paths on a line. eg: K:\A\B\C\10xx\somerandomfilename.ext->/a1/b1/c1/10xx \somerandomfilename.ext ; txx; 11/23/2009 15:00:16 ; 1259006416 As I try to pull in the line and process it, python changes the "\10" to a "\x08". This is before I

Re: attributes, properties, and accessors -- philosophy

2009-11-24 Thread Lie Ryan
Ethan Furman wrote: Good tools to know about, and a consistent naming pattern also makes life easier (which I have since done ;). Let's head towards murkier waters (at least murkier to me -- hopefully they can be easily clarified): some of the attributes are read-only, such as record count

Raw strings as input from File?

2009-11-24 Thread utabintarbo
I have a log file with full Windows paths on a line. eg: K:\A\B\C\10xx\somerandomfilename.ext->/a1/b1/c1/10xx \somerandomfilename.ext ; txx; 11/23/2009 15:00:16 ; 1259006416 As I try to pull in the line and process it, python changes the "\10" to a "\x08". This is before I can do anything with

Re: pointless musings on performance

2009-11-24 Thread Tim Wintle
On Tue, 2009-11-24 at 18:25 +, Antoine Pitrou wrote: > Le Tue, 24 Nov 2009 08:58:40 -0800, Paul Boddie a écrit : > > As you > > point out, a lot of this RISC vs. CISC analysis (and inferences > drawn > > from Python bytecode analysis) is somewhat academic: the cost of the > > JUMP_IF_FALSE inst

Re: csv and mixed lists of unicode and numbers

2009-11-24 Thread Peter Otten
Sibylle Koczian wrote: > I want to put data from a database into a tab separated text file. This > looks like a typical application for the csv module, but there is a > snag: the rows I get from the database module (kinterbasdb in this case) > contain unicode objects and numbers. And of course the

Python-URL! - weekly Python news and links (Nov 24)

2009-11-24 Thread Gabriel Genellina
QOTW: "... it's generally accepted that COM sucks rocks through straws, so explore alternatives when they're available ;-)" - Chris Withers http://groups.google.com/group/comp.lang.python/msg/29577c851ceed167 From nothing to a complete working program - Peter Otten on stepwise

Re: pointless musings on performance

2009-11-24 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 08:58:40 -0800, Paul Boddie a écrit : > As you > point out, a lot of this RISC vs. CISC analysis (and inferences drawn > from Python bytecode analysis) is somewhat academic: the cost of the > JUMP_IF_FALSE instruction is likely to be minimal in the context of all > the activity

Re: attributes, properties, and accessors -- philosophy

2009-11-24 Thread Chris Rebert
On Tue, Nov 24, 2009 at 9:39 AM, Ethan Furman wrote: > Bruno Desthuilliers wrote: >> Ethan Furman a écrit : >>> The problem I have with properties is my typing.  I'll end up assigning >>> to an attribute, but get the spelling slightly wrong (capitalized, or >>> missing an underscore -- non-obvious

Re: python bijection

2009-11-24 Thread Joshua Bronson
Hey Raymond, Thanks for your thoughtful reply! I think your idea for a class- generation approach in the spirit of namedtuple is brilliant; looking forward to coding this up and seeing how it feels to use it. (By the way, it occurred to me that "bijection" is perhaps the wrong term to use for thi

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-24 Thread Chris Jones
On Tue, Nov 24, 2009 at 08:02:09AM EST, Steven D'Aprano wrote: > Good grief, it's about six weeks away from 2010 and Thunderbird still > uses mbox as it's default mail box format. Hello, the nineties called, > they want their mail formats back! Are the tbird developers on crack or > something?

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 09:27:24 -0800, sturlamolden a écrit : > > Windows does not have daemons, so this is obviously incorrect. (There > are something called Windows Services, but multiprocessing does not use > them.) This is nitpicking. Technically it might not be a daemon but it's used as such.

Re: attributes, properties, and accessors -- philosophy

2009-11-24 Thread Ethan Furman
Bruno Desthuilliers wrote: Ethan Furman a écrit : The problem I have with properties is my typing. I'll end up assigning to an attribute, but get the spelling slightly wrong (capitalized, or missing an underscore -- non-obvious things when bug-hunting), so now I have an extra attribute which

Python-URL! - weekly Python news and links (Nov 24)

2009-11-24 Thread Cameron Laird
QOTW: "... it's generally accepted that COM sucks rocks through straws, so explore alternatives when they're available ;-)" - Chris Withers http://groups.google.com/group/comp.lang.python/msg/29577c851ceed167 From nothing to a complete working program - Peter Otten on stepwise refine

Re: csv and mixed lists of unicode and numbers

2009-11-24 Thread Benjamin Kaplan
On Tue, Nov 24, 2009 at 11:42 AM, Sibylle Koczian wrote: > Hello, > > I want to put data from a database into a tab separated text file. This > looks like a typical application for the csv module, but there is a > snag: the rows I get from the database module (kinterbasdb in this case) > contain u

Re: IDE+hg

2009-11-24 Thread Günther Dietrich
NiklasRTZ wrote: >Since no py IDE I found has easy hg access. Obviously, you didn't try Eclipse with PyDev () and Mercurial Eclipse () plugins. This combination is also available stuffed into one package as 'EasyEclipse for Pyth

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread sturlamolden
On 24 Nov, 16:13, Antoine Pitrou wrote: > >> Has anyone every tried wrapping the CPython lib into a daemon with an > >> RPC mechanism in order to move the GIL out of the process? > > >> I imagine this is how the multiprocessing module works. > > > It does not. > > Actually, it is how multiprocess

howto send signal to a OS daemon on linux

2009-11-24 Thread bheemesh v
Hello, Greetings. I am a newbie to python programming. Can anybody please help me with options to send a user defined signal to a OS daemon (example a daemon snmpd). I tried finding options to get pid of a daemon (process) by passing it's name. Once a pid is available thenwe can use os.kill(sign

Re: pointless musings on performance

2009-11-24 Thread Paul Boddie
On 24 Nov, 16:11, Antoine Pitrou wrote: > [JUMP_IF_FALSE] > It tries to evaluate the op of the stack (here nonevar) in a boolean > context (which theoretically involves calling __nonzero__ on the type) > and then jumps if the result is False (rather than True). [...] > As someone pointed out,

csv and mixed lists of unicode and numbers

2009-11-24 Thread Sibylle Koczian
Hello, I want to put data from a database into a tab separated text file. This looks like a typical application for the csv module, but there is a snag: the rows I get from the database module (kinterbasdb in this case) contain unicode objects and numbers. And of course the unicode objects contai

fixing xml output format

2009-11-24 Thread wadi wadi
Hi all, I am creating some xml output using minidom and saving it to a file using doc.writexml() The output however is as follows: bill catman Is there a way to save xml output in a file such as xml is formatted the right way? I mean with the right indentation and the elements val

Re: Where to put the error handing test?

2009-11-24 Thread Peng Yu
On Tue, Nov 24, 2009 at 4:58 AM, Dave Angel wrote: > Peng Yu wrote: >> >> On Mon, Nov 23, 2009 at 9:44 PM, Lie Ryan wrote: >> >>> >>> Peng Yu wrote: >>> Suppose that I have function f() that calls g(), I can put a test on the argument 'x' in either g() or f(). I'm wondering what is

Re: IDE+hg

2009-11-24 Thread rustom
On Nov 24, 8:13 pm, Richard Riley wrote: > Gerhard Häring writes: > > Rhodri James wrote: > >> On Mon, 23 Nov 2009 19:20:27 -, NiklasRTZ wrote: > > >>> Dear experts, > >>> Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim > >>> Mercurial support not found i.e. buttons to c

Re: pointless musings on performance

2009-11-24 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 15:11:29 +, Antoine Pitrou a écrit : > Hello, > > Le Tue, 24 Nov 2009 14:41:19 +0100, mk a écrit : >> >> As Rob pointed out (thanks): >> >> 11 31 LOAD_FAST0 (nonevar) >> 34 JUMP_IF_FALSE4 (to 41) >> >> I'm no good at py

Re: pointless musings on performance

2009-11-24 Thread Neil Cerutti
On 2009-11-24, Antoine Pitrou wrote: > It tries to evaluate the op of the stack (here nonevar) in a > boolean context (which theoretically involves calling > __nonzero__ on the type) ...or __bool__ in Py3K. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help to understand a getattr syntax.

2009-11-24 Thread Diez B. Roggisch
NMarcu wrote: > Hello all, > I need some help to understand a getattr syntax. The syntax is: > > try: > getattr(self, command)(cursor, row) > except Exception, e: > print "Action failed : '%s'" % command > raise e > > I don't understand why is not like this: a = getattr(), and wh

Need help to understand a getattr syntax.

2009-11-24 Thread NMarcu
Hello all, I need some help to understand a getattr syntax. The syntax is: try: getattr(self, command)(cursor, row) except Exception, e: print "Action failed : '%s'" % command raise e I don't understand why is not like this: a = getattr(), and what are the scope of the second ():

Re: Beginning Question about Python functions, parameters...

2009-11-24 Thread astral orange
On Nov 23, 10:37 pm, r wrote: > On Nov 23, 11:19 am, astral orange <457r0...@gmail.com> wrote: > > > > > Hi, I am trying to teach myself Python and have a good book to help me > > but I am stuck on something and I would like for someone to explain > > the following piece of code for me and what it

Re: Where to put the error handing test?

2009-11-24 Thread Peng Yu
On Tue, Nov 24, 2009 at 12:27 AM, alex23 wrote: > On Nov 24, 1:15 pm, Peng Yu wrote: >> Suppose that I have function f() that calls g(), I can put a test on >> the argument 'x' in either g() or f(). I'm wondering what is the >> common practice. >> >> If I put the test in f(), then g() becomes mor

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread Antoine Pitrou
Le Tue, 24 Nov 2009 02:53:30 -0800, sturlamolden a écrit : > On 22 Nov, 22:38, Patrick Stinson > wrote: > >> Has anyone every tried wrapping the CPython lib into a daemon with an >> RPC mechanism in order to move the GIL out of the process? > >> I imagine this is how the multiprocessing module w

Re: How to log messages _only once_ from all modules ?

2009-11-24 Thread Ron Barak
On Nov 24, 5:08 pm, Soltys wrote: > Ron Barak pisze: > > > > > > > On Nov 24, 3:45 pm, Soltys wrote: > >> Barak, Ron pisze: > > >>> Hi, > >>> I'm trying to add the logging module to my application, but I seem to be > >>> missing something. > >>> My application (a wxPython one) has a main script

Re: IDE+hg

2009-11-24 Thread Richard Riley
Gerhard Häring writes: > Rhodri James wrote: >> On Mon, 23 Nov 2009 19:20:27 -, NiklasRTZ wrote: >> >>> Dear experts, >>> Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim >>> Mercurial support not found i.e. buttons to clone, commit and push to >>> repositories to define

Re: pointless musings on performance

2009-11-24 Thread Antoine Pitrou
Hello, Le Tue, 24 Nov 2009 14:41:19 +0100, mk a écrit : > > As Rob pointed out (thanks): > > 11 31 LOAD_FAST0 (nonevar) > 34 JUMP_IF_FALSE4 (to 41) > > I'm no good at py compiler or implementation internals and so I have no > idea what bytecod

Re: How to log messages _only once_ from all modules ?

2009-11-24 Thread Soltys
Ron Barak pisze: On Nov 24, 3:45 pm, Soltys wrote: Barak, Ron pisze: Hi, I'm trying to add the logging module to my application, but I seem to be missing something. My application (a wxPython one) has a main script that calls various helper classes. I want the log messages from all modu

Re: pointless musings on performance

2009-11-24 Thread Rob Williscroft
mk wrote in news:mailman.923.1259070092.2873.python-l...@python.org in comp.lang.python: > MRAB wrote: >> In what way is it counterintuitive? In 'pythonic' the conditions are >> simpler, less work is being done, therefore it's faster. > > But the pythonic condition is more general: nonevar or ze

Re: IDE+hg

2009-11-24 Thread Gerhard Häring
Rhodri James wrote: > On Mon, 23 Nov 2009 19:20:27 -, NiklasRTZ wrote: > >> Dear experts, >> Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim >> Mercurial support not found i.e. buttons to clone, commit and push to >> repositories to define dev env dvcs, editor and deploym

Re: Line-continuation "Anti-Idiom" and with statement

2009-11-24 Thread Neil Cerutti
On 2009-11-23, Terry Reedy wrote: > Neil Cerutti wrote: >> Unfortunately, the new "nested" with statement (which I also read >> about today) forces me into this anti-idiom. When replacing an >> appearance of contextlib.nested with the 3K with statement, I >> ended up with an unexpected syntax erro

Re: How to log messages _only once_ from all modules ?

2009-11-24 Thread Ron Barak
On Nov 24, 3:45 pm, Soltys wrote: > Barak, Ron pisze: > > > > > > > Hi, > > > I'm trying to add the logging module to my application, but I seem to be > > missing something. > > My application (a wxPython one) has a main script that calls various helper > > classes. > > I want the log messages f

Re: How to log messages _only once_ from all modules ?

2009-11-24 Thread Soltys
Barak, Ron pisze: Hi, I'm trying to add the logging module to my application, but I seem to be missing something. My application (a wxPython one) has a main script that calls various helper classes. I want the log messages from all modules to go to one central log file. When I implement loggi

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread Brian Blais
On Nov 24, 2009, at 5:58 , sturlamolden wrote: I have programmed parallel numerical software in Python, including on- line signal processing. I have yet to find the GIL gets in my way. Usually people complaining about the GIL does not know what they are talking about. I'd love to know which

Re: pointless musings on performance

2009-11-24 Thread mk
MRAB wrote: In what way is it counterintuitive? In 'pythonic' the conditions are simpler, less work is being done, therefore it's faster. But the pythonic condition is more general: nonevar or zerovar can be '', 0, or None. So I thought it was more work for interpreter to compare those, while

Re: Go versus Brand X

2009-11-24 Thread Antoine Pitrou
Le Mon, 23 Nov 2009 15:30:16 -0600, Robert Kern a écrit : > particularly constrained environments like editors that may not be > extensible at all. I'm not really an expert on this, but I think most good editors /are/ extensible (through plugins, scripts or other things). > You can get away wit

How to log messages _only once_ from all modules ?

2009-11-24 Thread Barak, Ron
Hi, I'm trying to add the logging module to my application, but I seem to be missing something. My application (a wxPython one) has a main script that calls various helper classes. I want the log messages from all modules to go to one central log file. When I implement logging, I think that due

How to log messages _only once_ from all modules ?

2009-11-24 Thread Barak, Ron
Hi, I'm trying to add the logging module to my application, but I seem to be missing something. My application (a wxPython one) has a main script that calls various helper classes. I want the log messages from all modules to go to one central log file. When I implement logging, I think that due

Recall: How to log messages _only once_ from all modules ?

2009-11-24 Thread Barak, Ron
Barak, Ron would like to recall the message, "How to log messages _only once_ from all modules ?". -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginning Question about Python functions, parameters...

2009-11-24 Thread Peter Otten
Terry Reedy wrote: > astral orange wrote: > >> As far as the program. I did add print statements such as print >> (MyNames) and got back: >> >> {'middle': {}, 'last': {'Smith': ['John Larry Smith']}, 'first': {}} > > Hmmm, as I understood the code, either that should be ... 'last': {} ... > bef

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-24 Thread Steven D'Aprano
On Mon, 23 Nov 2009 22:06:29 +0100, Alf P. Steinbach wrote: > 6. Googling, yes, it seems Thunderbird has a habit of "forgetting" > mails. But they're really there after all. It's just the index that's > screwed up. [...] > And I'm hesitant to just delete index file, hoping that it'll rebuild. Ri

Re: Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-24 Thread Malte Helmert
Paul Miller wrote: > On Mon, 23 Nov 2009 19:57:05 -0800, Richard Thomas wrote: > >> Not sure exactly how you're representing graphs, this seems like the >> simplest way of listing the edges. >> >> def complete_partite(*sizes): >> total = sum(sizes) >> nodes, edges = range(total), [] >>

Re: pointless musings on performance

2009-11-24 Thread Chris Rebert
On Tue, Nov 24, 2009 at 4:31 AM, Rob Williscroft wrote: > mk wrote in news:mailman.915.1259064240.2873.python-l...@python.org in > comp.lang.python: > >> >> def pythonic(): > >> def unpythonic(): > > >> Decidedly counterintuitive: are there special optimizations for "if >> nonevar:" type of statem

Re: Where to put the error handing test?

2009-11-24 Thread Steven D'Aprano
On Mon, 23 Nov 2009 21:15:48 -0600, Peng Yu wrote: > Suppose that I have function f() that calls g(), I can put a test on the > argument 'x' in either g() or f(). I'm wondering what is the common > practice. > > My thought is that if I put the test in g(x), the code of g(x) is safer, > but the te

Re: pointless musings on performance

2009-11-24 Thread Rob Williscroft
mk wrote in news:mailman.915.1259064240.2873.python-l...@python.org in comp.lang.python: > > def pythonic(): > def unpythonic(): > Decidedly counterintuitive: are there special optimizations for "if > nonevar:" type of statements in cpython implementation? > from dis import dis dis( un

Re: pointless musings on performance

2009-11-24 Thread MRAB
mk wrote: #!/usr/local/bin/python import timeit def pythonic(): nonevar = None zerovar = 0 for x in range(100): if nonevar: pass if zerovar: pass def unpythonic(): nonevar = None zerovar = 0 for x in range(100): i

pointless musings on performance

2009-11-24 Thread mk
#!/usr/local/bin/python import timeit def pythonic(): nonevar = None zerovar = 0 for x in range(100): if nonevar: pass if zerovar: pass def unpythonic(): nonevar = None zerovar = 0 for x in range(100): if nonevar i

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread sturlamolden
On 24 Nov, 12:15, Daniel Fetchinson wrote: > By the way, you might be interested in this thread as well: > > http://groups.google.com/group/comp.lang.python/browse_thread/thread/... It is Windows specific, and it does not work with extension modules. Yes we can embed multiple interpreters just

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread Daniel Fetchinson
>> icating) the multiprocessing module would be ideal. >>> > The problem is that the OP has a embedded application running threads. >>> > multiprocssing doesn't help there. >>> >>> that's right. I cannot make CPython calls from my original C-based >>> threads. >> >> >> It's quite possible to do tha

Re: xmlrpc idea for getting around the GIL

2009-11-24 Thread sturlamolden
On 23 Nov, 22:02, Patrick Stinson wrote: > What I meant was that I am *not allowed* to make calls to the CPython > API from the threads I currently have because these threads are high > priority and are never allowed to make blocking calls. Fortunately, > each of these threads can have a complete

  1   2   >