Re: Docstrings considered too complicated

2010-02-26 Thread Jean-Michel Pichavant
Andreas Waldenburger wrote: On Fri, 26 Feb 2010 09:09:36 -0600 Tim Daneliuk wrote: On 2/24/2010 2:23 PM, Andreas Waldenburger wrote: [stuff] Reminiscent of: mov AX,BX ; Move the contents of BX into AX Well, there might be some confusion there as to what

Re: Docstrings considered too complicated

2010-02-26 Thread Jean-Michel Pichavant
Roy Smith wrote: In article , Tim Daneliuk wrote: On 2/24/2010 2:23 PM, Andreas Waldenburger wrote: Hi all, a company that works with my company writes a lot of of their code in Python (lucky jerks). I've seen their code and it basically looks like this: """Function that does stuff

Re: Docstrings considered too complicated

2010-03-01 Thread Jean-Michel Pichavant
MRAB wrote: Gregory Ewing wrote: Mel wrote: You could think of it as a not bad use of the design principle "Clear The Simple Stuff Out Of The Way First". Destinations are commonly a lot simpler than sources That's not usually true in assembly languages, though, where the source and destina

Re: Class attributes / methods lost?

2010-03-01 Thread Jean-Michel Pichavant
Gabor Urban wrote: Hi guys, I am building a nested data structure with the following compontens: <> class Item: def __init__(self, pId, pChange, pComment): self.ID = pId self.Delta = pChange self.Comment = pComment def PrintItem(self): str = '%s,%s,%s'%

Re: Docstrings considered too complicated

2010-03-01 Thread Jean-Michel Pichavant
Andreas Waldenburger wrote: On Tue, 02 Mar 2010 03:18:30 +1100 Lie Ryan wrote: On 03/02/10 00:09, Andreas Waldenburger wrote: On Mon, 1 Mar 2010 05:01:49 -0800 (PST) alex23 wrote: Andreas Waldenburger wrote: But as I said: a) I am (we are) not in a position to imp

Re: Adding to a module's __dict__?

2010-03-02 Thread Jean-Michel Pichavant
Roy Smith wrote: >From inside a module, I want to add a key-value pair to the module's __dict__. I know I can just do: FOO = 'bar' at the module top-level, but I've got 'FOO' as a string and what I really need to do is __dict__['Foo'] = 'bar' When I do that, I get "NameError: name '__dict__'

Re: Docstrings considered too complicated

2010-03-02 Thread Jean-Michel Pichavant
Andreas Waldenburger wrote: On Tue, 02 Mar 2010 09:48:47 +1100 Ben Finney wrote: It's not our concern. Then I don't see what that problem is. There is none. I was griping about how stupid they are. That is a personal problem I have with their *code* (not software), and I tho

Re: Pylint Argument number differs from overridden method

2010-03-04 Thread Jean-Michel Pichavant
Wanderer wrote: On Mar 3, 2:33 pm, Robert Kern wrote: On 2010-03-03 11:39 AM, Wanderer wrote: Pylint W0221 gives the warning Argument number differs from overridden method. Why is this a problem? I'm overriding the method to add additional functionality. There are exce

Re: A "scopeguard" for Python

2010-03-04 Thread Jean-Michel Pichavant
Alf P. Steinbach wrote: From your post, the scope guard technique is used "to ensure some desired cleanup at the end of a scope, even when the scope is exited via an exception." This is precisely what the try: finally: syntax is for. You'd have to nest it. That's ugly. And more importantly,

Re: A "scopeguard" for Python

2010-03-04 Thread Jean-Michel Pichavant
Alf P. Steinbach wrote: * Jean-Michel Pichavant: Alf P. Steinbach wrote: From your post, the scope guard technique is used "to ensure some desired cleanup at the end of a scope, even when the scope is exited via an exception." This is precisely what the try: finally: syntax is for

Re: A "scopeguard" for Python

2010-03-04 Thread Jean-Michel Pichavant
Michael Rudolf wrote: Am 04.03.2010 17:32, schrieb Jean-Michel Pichavant: It looks like to me that 'with' statements are like decorators: overrated. Oh no, you just insulted my favourite two python features, followed immediately by generators, iterators and list comprehensions /

Re: Evaluate my first python script, please

2010-03-05 Thread Jean-Michel Pichavant
Pete Emerson wrote: I've written my first python program, and would love suggestions for improvement. I'm a perl programmer and used a perl version of this program to guide me. So in that sense, the python is "perlesque" This script parses /etc/hosts for hostnames, and based on terms given on t

Re: A "scopeguard" for Python

2010-03-05 Thread Jean-Michel Pichavant
Robert Kern wrote: On 2010-03-04 15:12 , Mike Kent wrote: On Mar 4, 12:30 pm, Robert Kern wrote: He's ignorant of the use cases of the with: statement, true. Ouch! Ignorant of the use cases of the with statement, am I? Odd, I use it all the time. No, I was referring to Jean-M

Re: Evaluate my first python script, please

2010-03-05 Thread Jean-Michel Pichavant
Duncan Booth wrote: Jean-Michel Pichavant wrote: You've already been given good advices. Unlike some of those, I don't think using regexp an issue in any way. Yes they are not readable, for sure, I 100% agree to that statement, but you can make them readable very easily. # no

Re: Escaping variable names

2010-03-05 Thread Jean-Michel Pichavant
Kamil Wasilewski wrote: Hi, Ive got an issue where a variable name needs to have a minus sign (-) in it. #Python 2.6 from SOAPpy import WSDL wsdlFile = "http://webapi.allegro.pl/uploader.php?wsdl"; server = WSDL.Proxy(wsdlFile) server.soapproxy.config.argsOrdering = {'doGetCountries': ['country

Re: isinstance(False, int)

2010-03-05 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Fri, 05 Mar 2010 18:14:16 +0100, mk wrote: isinstance(False, int) True >>> >>> isinstance(True, int) True Huh? Yes. Do you have an actual question? >>> issubclass(bool, int) True Huh?! Exactly. Bools are a late-comer to Python.

Re: Conditional based on whether or not a module is being used

2010-03-08 Thread Jean-Michel Pichavant
Pete Emerson wrote: On Mar 5, 1:14 pm, Chris Rebert wrote: On Fri, Mar 5, 2010 at 12:25 PM, Pete Emerson wrote: On Fri, Mar 5, 2010 at 12:17 PM, Chris Rebert wrote: On 3/5/10, Pete Emerson wrote: In a module, how do I create a conditional that will do something bas

Re: Import problem

2010-03-08 Thread Jean-Michel Pichavant
Johny wrote: I have this directory structure C: \A __init__.py amodule.py \B __init__.py bmodule.py \D __init__.py dmodule.py and I want to import bmodule.py C:\>cd \ C:\>python Python 2.5 (r25:51908, S

Re: Import problem

2010-03-10 Thread Jean-Michel Pichavant
News123 wrote: Jean-Michel Pichavant wrote: Johny wrote: I have this directory structure C: \A __init__.py amodule.py \B __init__.py bmodule.py \D __init__.py dmodule.py and I want to import

Re: Named loops for breaking

2010-03-10 Thread Jean-Michel Pichavant
Daniel Klein wrote: Hey, I did a little searching and couldn't really find much recent on this. The only thing I found was this: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a696624c92b91181/5b7479fdc3362b83?lnk=gst&q=break+named+loop#5b7479fdc3362b83 Basically I'm wond

Re: pexpect and logging integration

2010-03-10 Thread Jean-Michel Pichavant
Lars Stavholm wrote: Hi all, has anyone managed to integrate pexpect and logging? I.e., I'd like to be able to pick up the dialog, commands sent and responses received, in my logging. I know about the pexpect logfile, and I can log things to stdout or stderr, but I really need to log using the

Re: about Telnetlib problem

2010-03-10 Thread Jean-Michel Pichavant
JEHERUL wrote: Dear All I am trying to telnet to a Cisco router . Following is my code . #code router.py import getpass import sys import telnetlib HOST = "router address" # router address is ommitted for security reason user = raw_input("Username : ") password = getpass.getpa

Re: logging: local functions ==> loss of lineno

2010-03-11 Thread Jean-Michel Pichavant
Hellmut Weber wrote: Hi Vinay Sajip, I'm very glad discoverd your logging module ;-) (That's what I would have liked 25 years ago when I was working as a technical software developper!) Now I'm writing just some personal tools, I like python and want to use logging on a regular basis. Loggi

Re: a newbie's question

2010-03-11 Thread Jean-Michel Pichavant
PEYMAN ASKARI wrote: Hello I need some help dynamically reloading modules. As it turns out, it is not as simple as calling reload, as outlined here http://pyunit.sourceforge.net/notes/reloading.html Is there builtin support for this? The example they gave does not seem to work for me, and I

Re: Need advice on starting a Python group

2010-03-12 Thread Jean-Michel Pichavant
News123 wrote: Jonathan Gardner wrote: On Thu, Mar 11, 2010 at 6:57 AM, gb345 wrote: And even when we've had volunteers, hardly anyone shows up! Any suggestions would be appreciated. Two things: One, only you and your friend really care. Let that sink in. No one is going to c

Re: to create variable from dict

2010-03-12 Thread Jean-Michel Pichavant
Luis M. González wrote: On Mar 12, 10:59 am, hiral wrote: Hi, Is there any way to create variables which name matches with dict key? For example: dict1 = {"abc":'1", "def":"2"} Now I am looking to have variable name abc and it's value be '1' etc. Pl. suggest. Thank you. Check out

Re: class inheritance

2010-03-15 Thread Jean-Michel Pichavant
JLundell wrote: I've got a subclass of fractions.Fraction called Value; it's a mostly trivial class, except that it overrides __eq__ to mean 'nearly equal'. However, since Fraction's operations result in a Fraction, not a Value, I end up with stuff like this: x = Value(1) + Value(2) where x is

Re: staticmethod and setattr

2010-03-15 Thread Jean-Michel Pichavant
Am Montag, den 15.03.2010, 05:42 -0700 schrieb Michael.Lausch: On Mar 15, 11:40 am, Steven D'Aprano wrote: On Mon, 15 Mar 2010 01:43:02 -0700, Michael.Lausch wrote: Hi, I managed to get confused by Python, which is not such an easy task. The problem i have is root

Re: "Breaking" the __main__ script

2010-03-15 Thread Jean-Michel Pichavant
Steve Holden wrote: pyt...@bdurham.com wrote: Any reason you prefer PDB over WinPDB? http://winpdb.org/ Yes. I don't have Windows except one one PC :P WinPDB runs on non-Windows platforms :) One might reasonably argue that it has a pretty couter-intuitive name, then.

Re: "Breaking" the __main__ script

2010-03-15 Thread Jean-Michel Pichavant
vsoler wrote: Hello, I am still learning python, thus developnig small scripts. Some of them consist only of the main module. While testing them (debugging) I sometimes want to stop the script at a certain point, with something likestop, break, end or something similar. What statement ca

Re: "Breaking" the __main__ script

2010-03-15 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: vsoler wrote: Hello, I am still learning python, thus developnig small scripts. Some of them consist only of the main module. While testing them (debugging) I sometimes want to stop the script at a certain point, with something likestop, break, end or

Re: affectation in if statement

2010-03-16 Thread Jean-Michel Pichavant
samb wrote: Hi, I've found a work around, inspired from Rob Williscroft : class ReMatch(object): """ Object to be called : 1st time : do a regexp.match and return the answer (args: regexp, line) 2nd time : return the previous result (args: prev) """ def __cal

Re: logging: local functions ==> loss of lineno

2010-03-19 Thread Jean-Michel Pichavant
Hellmut Weber wrote: Am 11.03.2010 12:14, schrieb Peter Otten: Hellmut Weber wrote: Logging works very well giving the filename and line number of the point where it is called. As long as I use the loggers directly. BUT when I have to wrap the logger call in some other function, I always ge

Re: logging: local functions ==> loss of lineno

2010-03-19 Thread Jean-Michel Pichavant
Peter Otten wrote: Jean-Michel Pichavant wrote: Hellmut Weber wrote: Am 11.03.2010 12:14, schrieb Peter Otten: Hellmut Weber wrote: Logging works very well giving the filename and line number of the point where it is called. As long as I use the loggers directly

Re: Tuples vs. variable-length argument lists

2010-03-22 Thread Jean-Michel Pichavant
Spencer Pearson wrote: Hi! This might be more of a personal-preference question than anything, but here goes: when is it appropriate for a function to take a list or tuple as input, and when should it allow a varying number of arguments? It seems as though the two are always interchangeable. For

Re: accessing variable of the __main__ module

2010-03-22 Thread Jean-Michel Pichavant
News123 wrote: Hi, I wondered about the best way, that a module's function could determine the existance and value of variables in the __main__ module. What I came up with is: ### main.py ## import mod A = 4 if __name__ == "__main__": mod.f() ### mod.py ## def

Re: short-circuiting any/all ?

2010-03-22 Thread Jean-Michel Pichavant
kj wrote: I have a list of items L, and a test function is_invalid that checks the validity of each item. To check that there are no invalid items in L, I could check the value of any(map(is_invalid, L)). But this approach is suboptimal in the sense that, no matter what L is, is_invalid will be

Re: short-circuiting any/all ?

2010-03-23 Thread Jean-Michel Pichavant
kj wrote: Arguably, Knuth's "premature optimization is the root of all evil" applies even to readability (e.g. "what's the point of making code optimally readable if one is going to change it completely next day?") The guy who will change it will have to read it. The only waste would be if the

Re: logging: local functions ==> loss of lineno

2010-03-24 Thread Jean-Michel Pichavant
Peter Otten wrote: Vinay Sajip wrote: Sorry I'm a little late to this discussion. I could add a _findCaller function to the module (not part of the public API, but replaceable by someone who really needs to) which does the heavy lifting, and Logger.findCaller just calls it. Then those who ne

Re: Automatic import ?

2010-03-26 Thread Jean-Michel Pichavant
C. B. wrote: Hi everyone, I'm currently coding a C library which provides several modules and objects. Let's say that some of these objects are classes called AAA and BBB. The constructor of AAA needs to get BBB as argument. So I can run the following code : from mymodule import AAA from mymo

Re: python logging writes an empty file

2010-03-26 Thread Jean-Michel Pichavant
Ovidiu Deac wrote: Then I tried this: file = logging.FileHandler(logFileBasename, 'w') file.setLevel(logging.INFO) # set a format which is simpler for console use formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s',) # tell the handler to use th

Re: python logging writes an empty file

2010-03-26 Thread Jean-Michel Pichavant
Ovidiu Deac wrote: You set le level of your handler, but did not set the level of the logger itself. Replace file.setLevel(logging.INFO) by logging.getLogger().setLevel(logging.INFO) Log events are matched versus the logger level 1st, then the handler level (if applicable). Most of the time you

Re: Classes as namespaces?

2010-03-26 Thread Jean-Michel Pichavant
kj wrote: What's the word on using "classes as namespaces"? E.g. class _cfg(object): spam = 1 jambon = 3 huevos = 2 breakfast = (_cfg.spam, _cfg.jambon, _cfg.huevos) Granted, this is not the "intended use" for classes, and therefore could be viewed as a misuse ("that's what dic

Re: Classes as namespaces?

2010-03-27 Thread Jean-Michel Pichavant
Jonathan Hartley wrote: On Mar 26, 6:26 pm, Luis M. González wrote: On 26 mar, 11:49, kj wrote: What's the word on using "classes as namespaces"? E.g. class _cfg(object): spam = 1 jambon = 3 huevos = 2 breakfast = (_cfg.spam, _cfg.jambon, _cfg.huevos)

Re: Automatic import ?

2010-03-27 Thread Jean-Michel Pichavant
C. B. wrote: [snip] It takes time to write the relative importations, that's ok, but I think it could be more pleasant for the end-user to not have to write a huge list of "from mymodule import xxx" if it is possible to take advantage of automatic importations. Cheers, In that particular ca

Re: "Usability, the Soul of Python"

2010-03-30 Thread Jean-Michel Pichavant
John Nagle wrote: Jonathan Hayward wrote: I've posted "Usability, the Soul of Python: An Introduction to the Python Programming Language Through the Eyes of Usability", at: http://JonathansCorner.com/python/ No, it's just a rather verbose introduction to Python, in dark brown type on a

Re: libpst - python bindings

2010-03-31 Thread Jean-Michel Pichavant
Richard Lamboj wrote: Hello, are there any python bindings for libpst? http://www.five-ten-sg.com/libpst/ https://alioth.debian.org/projects/libpst/ Kind Regards Richi http://www.lmgtfy.com/?q=libpst+python 3rd hit Cheers, JM -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting references to objects without incrementing reference counters

2010-11-14 Thread Jean-Paul Calderone
d here because getting a real reference from a weakref increases a > reference counter. Maybe another option would be to store reference > counters not in objects, but in a separate array to minimize number of > memory pages they occupy... It might be interesting to try with Jython or PyPy.

Re: Getting references to objects without incrementing reference counters

2010-11-15 Thread Jean-Paul Calderone
ng to have them drag you down. Fortunately the PyPy team is making great progress in implementing a runtime that transparently sheds those dynamic features when running a program that doesn't take advantage of them. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: strange subprocess behavior when calling ps

2010-11-17 Thread Jean-Michel Pichavant
Roger Davis wrote: Hi all, [snip] Roger Davis # code follows #!/usr/bin/python import sys import subprocess def main(): psargs= ["/bin/ps", "-e"] try: ps= subprocess.Popen(psargs, stdout=subprocess.PIPE, close_fds=True) psout= ps.comm

Re: strange subprocess behavior when calling ps

2010-11-18 Thread Jean-Michel Pichavant
Roger Davis wrote: Completely off topic but I think the try clause could be rewritten that way: ... Don't use bare except clause, you're masking syntax errors for instance, which will be flagged as 'unexpected error in generation ...". In a more general manner, if something unexpected happens it'

Re: How to run an EXE, with argument, capture output value

2010-11-18 Thread Jean-Michel Pichavant
Tim Harig wrote: On 2010-11-18, noydb wrote: I have an executable that I want to run within python code. The exe requires an input text file, the user to click a 'compute' button, and then the exe calculates several output values, one of which I want to capture into a variable. Can I use P

Re: Twisted on Windows

2010-11-18 Thread Jean-Paul Calderone
und. When running as root, or when running on Windows, twistd does not add the working directory to sys.path. So with all that in mind, the solution should be pretty clear - just set PYTHONPATH to include MyServerApp. This variation of twistd behavior is pretty confusing, and I think a future ver

Re: Is Unladen Swallow dead?

2010-11-18 Thread Jean-Paul Calderone
completely accurate. It *is* possible to write a JIT compiler for a Python runtime which has fast path code for the common case, the case where the meaning of "+" doesn't change between every opcode. PyPy has produced some pretty good results with this approach. For those who haven't seen it yet, http://speed.pypy.org/ has some graphs which reflect fairly well on PyPy's performance for benchmarks that are not entirely dissimilar to real world code. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Distribution of Python Scripts

2010-11-19 Thread Jean-Michel Pichavant
tazz_ben wrote: Hi Folks - I'm an experienced programmer, but this is my first app with python, so I apologize for any stupidity on my part. So I've written/still working on a command line tool written in Python. It talks to a web service, so there really isn't anything in it that is dependen

Re: building a web interface

2010-11-22 Thread Jean-Michel Pichavant
Shel wrote: Hello, I am pretty new to all this. I have some coding experience, and am currently most comfortable with Python. I also have database design experience with MS Access, and have just created my first mySQL db. So right now I have a mySQL db structure and some Python code. My end go

regexp matching end of line or comma

2010-11-25 Thread Jean-Michel Pichavant
Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?P\S+),', ex1) m2 = re.match('(?P\S+)$', ex2) m3 = re.match('(?P\S+)[,$]', ex1) m4 = re.match('(?P\S+)[,$]', ex2) print m1, m2 print m3 print m4

Re: regexp matching end of line or comma

2010-11-25 Thread Jean-Michel Pichavant
MRAB wrote: On 25/11/2010 14:40, Jean-Michel Pichavant wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?P\S+),', ex1) m2 = re.matc

Re: Change one list item in place

2010-12-01 Thread Jean-Michel Pichavant
Gnarlodious wrote: This works for me: def sendList(): return ["item0", "item1"] def query(): l=sendList() return ["Formatting only {0} into a string".format(l[0]), l[1]] query() However, is there a way to bypass the l=sendList() and change one list item in-place? Possibly a lis

Re: Change one list item in place

2010-12-01 Thread Jean-Michel Pichavant
Gnarlodious wrote: On Dec 1, 6:23 am, Jean-Michel Pichavant wrote: what about def query(): return ["Formating only {0} into a string".format(sendList()[0])] + sendList()[1:] However this solution calls sendList() twice, which is too processor intensive. You got to

Re: Python's equivalent to Main calling program and subprograms

2010-12-01 Thread Jean-Michel Pichavant
Tim Harig wrote: On 2010-12-01, goldtech wrote: Start Main Global Var Subprogram1 Subprogram2 Subprogram3 End of Main End module_wide_var = value def Subprogram1: # code def Subprogram2: # code def Subprogram3: # code def main: Subpr

Re: Python's equivalent to Main calling program and subprograms

2010-12-01 Thread Jean-Michel Pichavant
m b wrote: > > > > if __name__ == "__main__": > > main() What does this mean? /Mikael __name__ is an attribute of the module. Usually it is set to the module name, except when the module is acutally executed as the entry point, in that case __name__ is set to '__main__'. foo.py: print __n

Re: Comparison with False - something I don't understand

2010-12-02 Thread Jean-Michel Pichavant
Harishankar wrote: As I said before, the way exceptions are caught seem to me to be the most confusing bit. Non-atomic operations always worry me. What if my function which is wrapped inside a try block has two different statements that raised the same exception but for different reasons? With

is id(self) constant over an object lifetime ?

2010-12-03 Thread Jean-Michel Pichavant
Hello fellows, I would need a unique internal identifier to an object. Can I use the object python id ? class Foo: def getUniqueIdentifier(): return id(self) This id needs to be unique and constant over the python process lifetime. JM -- http://mail.python.org/mailman/listinfo/pyt

Re: is id(self) constant over an object lifetime ?

2010-12-03 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Hello fellows, I would need a unique internal identifier to an object. Can I use the object python id ? class Foo: def getUniqueIdentifier(): return id(self) This id needs to be unique and constant over the python process lifetime. JM erratum

Re: is id(self) constant over an object lifetime ?

2010-12-03 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Hello fellows, I would need a unique internal identifier to an object. Can I use the object python id ? class Foo: def getUniqueIdentifier(): return id(self) This id needs to be unique and constant over the python process lifetime. JM sorry guys "

Re: is id(self) constant over an object lifetime ?

2010-12-03 Thread Jean-Michel Pichavant
Adam Tauno Williams wrote: On Fri, 2010-12-03 at 14:44 +0100, Jean-Michel Pichavant wrote: Hello fellows, I would need a unique internal identifier to an object. Can I use the object python id ? class Foo: def getUniqueIdentifier(): return id(self) This id needs to be unique and

Re: [ANN] Pyclewn: Vim as a front end to pdb

2010-12-06 Thread Jean-Michel Pichavant
Xavier de Gaye wrote: Pyclewn 1.5 has been released at http://pyclewn.sourceforge.net/ Pyclewn is a python program that allows the use of Vim as a front end to gdb and pdb. This release adds support for ``pdb``, the python debugger. + A python script may be run under the control of ``pdb``. F

Re: is it possible to see if a class has a decorator ?

2010-12-06 Thread Jean-Michel Pichavant
Stef Mientki wrote: On 06-12-2010 12:08, Ben Finney wrote: Stef Mientki writes: I would like to know if a class definition has a decorator, I'm not sure what this question means. Applying a decorator to a class definition produces a normal class. Classes don't “have” decorators

Re: Using logging module to log either to screen or a file

2010-12-07 Thread Jean-Michel Pichavant
RedBaron wrote: Hi, I am beginner to python and i am writing a program that does a lot of things. One of the requirements is that the program shud generate a log file. I came across python loggging module and found it very useful. But I have a few problems Suppose by giving option '-v' along with

Re: class browser

2010-12-08 Thread Jean-Michel Pichavant
Rustom Mody wrote: If I have a medium to large python code base to browse/study, what are the class browsers available? vim + ctags is one of them. JM -- http://mail.python.org/mailman/listinfo/python-list

Re: use of __new__ to permit "dynamic" completion within (any?) IDE ?

2010-12-08 Thread Jean-Michel Pichavant
gst wrote: greg. nb: so this "hack" is only relevant during dev ; once the project would be finished the "hack" could be removed (i.e : in class2 init I would directly do : self.object1 = object1) Expect some bugs then on the 'release' version. I'm not sure I understood everything you menti

Re: use of __new__ to permit "dynamic" completion within (any?) IDE ?

2010-12-08 Thread Jean-Michel Pichavant
quoting eclipse page: "Pydev [...] uses advanced type inference techniques to provide features such code completion and code analysis" I don't know exactly what's hidden behind this marketing stuff. Did you try to document your method with a markup language supported by Eclipse (if there is an

Re: run a function in another processor in python

2010-12-09 Thread Jean-Michel Pichavant
Astan Chee wrote: Hi, I've got a python script that calls a function many times with various arguments and returns a result. What I'm trying to do is run this function each on different processors and compile the result at the end based on the function result. The script looks something like this

Re: dns library

2010-12-09 Thread Jean-Paul Calderone
On Dec 9, 8:15 pm, Paulo da Silva wrote: > Hi. > > Is there a python library/module to handle both the server and client > sides of dns protocol? > > I have googled for it but I only found client side ones (at least from > the superficial readings I did). > > Thanks. Twisted Names is one such lib

Re: Proposed changes to logging defaults

2010-12-10 Thread Jean-Michel Pichavant
Vinay Sajip wrote: Some changes are being proposed to how logging works in default configurations. Briefly - when a logging event occurs which needs to be output to some log, the behaviour of the logging package when no explicit logging configuration is provided will change, most likely to log t

Re: printing error message from an Exception

2010-12-10 Thread Jean-Michel Pichavant
mark jason wrote: On Dec 10, 11:55 am, Steven D'Aprano wrote: # By the way, IOError is not the only exception you could see. thanks for the help Steven. Is it OK to catch Exception instead of IOError ? In some operation which can cause many errors ,can I use the following? try:

Re: Python critique

2010-12-10 Thread Jean-Michel Pichavant
Octavian Rasnita wrote: It is true that Python doesn't use scope limitations for variables? Octavian Python does have scope. The problem is not the lack of scope, to problem is the shadow declaration of some python construct in the current scope. print x # raise NameError [x for x in ra

Re: decouple copy of a list

2010-12-10 Thread Jean-Michel Pichavant
Dirk Nachbar wrote: I want to take a copy of a list a b=a and then do things with b which don't affect a. How can I do this? Dirk In [1]: a = [1,2,3] In [2]: b = a[:] In [3]: b[0] = 5 In [4]: a Out[4]: [1, 2, 3] In [5]: b Out[5]: [5, 2, 3] Alternatively, you can write import copy a

Re: decouple copy of a list

2010-12-10 Thread Jean-Michel Pichavant
cassiope wrote: Alternatively, you can write import copy a = [1,2,3] b = a.copy() JM I'm not a pyguru, but... you didn't use copy quite right. Try instead: b= copy.copy(a) You're right, you're not a python guru so don't even try to contradict me ever again. ... :D of course I di

Re: Proposed changes to logging defaults

2010-12-13 Thread Jean-Michel Pichavant
Vinay Sajip wrote: On Dec 10, 10:17 am, Jean-Michel Pichavant wrote: Hi Jean-Michel, I think Antoine answered your other points, so I'll address the last one: Last question, if no handler is found, why not simply drop the log event, doing nothing ? It sounds pretty reasonable and

Re: Python critique

2010-12-13 Thread Jean-Michel Pichavant
Octavian Rasnita wrote: From: "Steven D'Aprano" ... Can you please tell me how to write the following program in Python? my $n = 1; { my $n = 2; print "$n\n"; } print "$n\n"; If this program if ran in Perl, it prints: 2 1 Lots of ways. Here's one: n = 1 class Scope: n

Re: default argument in method

2010-12-13 Thread Jean-Michel Pichavant
ernest wrote: Hi, I'd like to have a reference to an instance attribute as default argument in a method. It doesn't work because "self" is not defined at the time the method signature is evaluated. For example: class C(object): def __init__(self): self.foo = 5 def m(self, val=se

Re: while True or while 1

2010-12-13 Thread Jean-Michel Pichavant
Paul Rubin wrote: Steven D'Aprano writes: I'm actually quite fond of the look of "while 1:", and sometimes use it, not because it's faster, but just because I like it. for v in itertools.repeat(True): ... ;-) while '__For_ever___' not in ['nit-picking']: :) JM -- http

string identity and comparison

2010-12-16 Thread Jean-Michel Pichavant
Fellows, I'd like to illutrate the fact that comparing strings using identity is, most of the time, a bad idea. However I'm searching a short example of code that yields 2 differents object for the same string content. id('foo') 3082385472L id('foo') 3082385472L Anyone has that kind of code

Re: string identity and comparison

2010-12-16 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Fellows, I'd like to illutrate the fact that comparing strings using identity is, most of the time, a bad idea. However I'm searching a short example of code that yields 2 differents object for the same string content. id('foo')

Re: string identity and comparison

2010-12-16 Thread Jean-Michel Pichavant
bruno.desthuilli...@gmail.com wrote: On 16 déc, 12:55, Jean-Michel Pichavant wrote: id('foo') 3082385472L id('foo') 3082385472L Anyone has that kind of code ? 2 points: 1- an id is only valid for the lifetime of a given object - when the object has been coll

Re: string identity and comparison

2010-12-16 Thread Jean-Michel Pichavant
Mel wrote: Jean-Michel Pichavant wrote: Fellows, I'd like to illutrate the fact that comparing strings using identity is, most of the time, a bad idea. However I'm searching a short example of code that yields 2 differents object for the same string content. id('foo')

Re: If/then style question

2010-12-17 Thread Jean-Michel Pichavant
John Gordon wrote: (This is mostly a style question, and perhaps one that has already been discussed elsewhere. If so, a pointer to that discussion will be appreciated!) When I started learning Python, I wrote a lot of methods that looked like this: def myMethod(self, arg1, arg2): if s

Re: If/then style question

2010-12-17 Thread Jean-Michel Pichavant
Rob Richardson wrote: -Original Message- What about, def myMethod(): for condition, exitCode in [ (cond1, 'error1'), (cond2, 'very bad error'), ]: if not condition: break else: do_some_usefull_stuff() # executed only if the

Re: Design Ideals Goals Python 3 - Forest for the trees

2010-12-26 Thread Jean-Paul Calderone
cts, however, is an issue of larger scope than mere portability.   > ;) > The PyPy JIT supports x86_64. It's still being improved, but it does provide real speedups in some cases already. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Interrput a thread

2011-01-03 Thread Jean-Paul Calderone
e tooking too much time, which > > > solution do you propose? > > > If possible, use multiple processes instead. > > > Diez- Nascondi testo citato > > > - Mostra testo citato - > > Multiple processes, ok, but then regarding processes' interruption > there will be the same problems pointed out by using threads? > No. Processes can be terminated easily on all major platforms. See `os.kill`. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Interrput a thread

2011-01-03 Thread Jean-Paul Calderone
On Jan 3, 4:17 pm, Adam Skutt wrote: > On Jan 3, 4:06 pm, Jean-Paul Calderone > wrote: > > > > > > Multiple processes, ok, but then regarding processes' interruption > > > there will be the same problems pointed out by using threads? > > > No.  

Re: Interrput a thread

2011-01-03 Thread Jean-Paul Calderone
On Jan 3, 6:17 pm, Adam Skutt wrote: > On Jan 3, 5:24 pm, Jean-Paul Calderone > wrote: > > > Of course.  The whole point here is not about threads vs processes. > > It's about shared memory concurrency vs non-shared memory > > concurrency.  You can implement

Re: Interrput a thread

2011-01-04 Thread Jean-Paul Calderone
On Jan 4, 12:31 pm, Fuzzyman wrote: > On Jan 4, 3:31 pm, Roy Smith wrote: > > > > > In article > > <2ebc11a5-1b45-4faa-97b9-c84f0db01...@k22g2000yqh.googlegroups.com>, > > >  Fuzzyman wrote: > > > It is unsafe to terminate an os level thread at an arbitrary point > > > because it may be executin

Re: Which coding style is better? public API or private method inside class definition

2011-01-05 Thread Jean-Michel Pichavant
Inyeol wrote: For example: I'm writing simple class: class Numbers: def __init__(self, numbers): self._numbers = numbers def get_all(self): for number in self._numbers: yield number If I want to add another method for yielding even num

Re: Convert arbitrary function inputs to string

2011-01-06 Thread Jean-Michel Pichavant
David wrote: Hi, I'd like to have a function that takes arbitrary inputs and returns them as a single string, with proper escapes for special characters I can define. For example: fun( ( + 1 2 ) ) => "( + 1 2)" or fun( (define (myhello str) (begin (print (string-append "Hello " str)) (newli

Re: Rewriting __getattr__

2011-01-07 Thread Jean-Michel Pichavant
kost BebiX wrote: Hi everyone! I just saw a bug (?) in bson.dbref:DBRef.__getattr__ Here's they're code: def __getattr__(self, key): return self.__kwargs[key] And when you do copy.deepcopy on that object it will raise you KeyError. So here's a small piece of code that reproduces th

Re: Rewriting __getattr__

2011-01-07 Thread Jean-Michel Pichavant
kost BebiX wrote: You're absolutely right! Now try to do except Keyerror: raise AttributeError and it will also fail. But why? 07.01.2011, 15:45, "Jean-Michel Pichavant" : kost BebiX wrote: Hi everyone! I just saw a bug (?) in bson.dbref:DBRef.__getattr__ Here

Re: Rewriting __getattr__

2011-01-07 Thread Jean-Michel Pichavant
kost BebiX wrote: Sorry for top posting, didn't know about that) I'm quote new to posting to mailing lists. Well, actually the code you showed doesn't work) class A(object): .. def __init__(self): .. self.d = {} .. def __getattr__(self, key): .. try: ..

<    11   12   13   14   15   16   17   18   19   20   >