Re: doted filenames in import statements

2009-07-22 Thread Jean-Michel Pichavant
Piet van Oostrum wrote: [snip] JP> file = "/home/dsp/4.6.0.0/test.py" JP> test = __import__(file) JP> => no module name blalalal found. JP> Any suggestion ? I tried multiple escape technics without any success. Rightly so. I think the best would be to add the directory to sy

Re: Changing the private variables content

2009-07-22 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 22 Jul 2009 14:29:20 +0200, Ryniek90 wrote: When i use this class in Python IDLE, i've got this error: " ... Traceback (most recent call last): File "", line 1, in mod.print_module('socket') File "", line 48, in print_module module_open =

Re: doted filenames in import statements

2009-07-24 Thread Jean-Michel Pichavant
Terry Reedy wrote: Jean-Michel Pichavant wrote: Piet van Oostrum wrote: [snip] JP> file = "/home/dsp/4.6.0.0/test.py" JP> test = __import__(file) JP> => no module name blalalal found. JP> Any suggestion ? I tried multiple escape technics without any success.

Re: Override a method but inherit the docstring

2009-07-27 Thread Jean-Michel Pichavant
Ben Finney wrote: Howdy all, The following is a common idiom:: class FooGonk(object): def frobnicate(self): """ Frobnicate this gonk. """ basic_implementation(self.wobble) class BarGonk(FooGonk): def frobnicate(self): special_implemen

Re: How to comment constant values?

2009-07-27 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 27 Jul 2009 00:47:08 +0200, Diez B. Roggisch wrote: Only modules, classes, and functions/methods can have docstrings associated with them. For anything else, you have to use comments; or you can mention them in the docstrings of related things. While th

Re: Override a method but inherit the docstring

2009-07-28 Thread Jean-Michel Pichavant
Shai wrote: On Jul 27, 5:05 pm, Jean-Michel Pichavant wrote: Ben Finney wrote: The docstring for ‘FooGonk.frobnicate’ is, intentionally, perfectly applicable to the ‘BarGonk.frobnicate’ method also. Yet in overriding the method, the original docstring is not associated with it

Re: index nested lists

2009-07-28 Thread Jean-Michel Pichavant
Alex wrote: On 28 Lug, 15:12, "Andreas Tawn" wrote: hi at all, If I have this list: lista ['ciao', 1, ['mela', 'pera', 'banana'], [1, 2, 3]] if I want enumerate elements...I can see: for parola in lista: print lista[i] i = i + 1

Re: Confessions of a Python fanboy

2009-07-30 Thread Jean-Michel Pichavant
superpollo wrote: Masklinn wrote: ... That's an interesting point, but not relevant at the end of the day: `foo.length` and `length(foo)` have the same "practicality". On the other hand Ruby can be praised for the coherence: everything's a method period end of the story; while Python does h

Re: Confessions of a Python fanboy

2009-07-30 Thread Jean-Michel Pichavant
r wrote: On Jul 30, 11:31 am, Falcolas wrote: On Jul 29, 9:06 pm, r wrote: 1.) No need to use "()" to call a function with no arguments. Python --> "obj.m2().m3()" --ugly Ruby --> "obj.m1.m2.m3" -- sweeet! Man, i must admit i really like this, and your code will look so much clean

Re: Confessions of a Python fanboy

2009-07-31 Thread Jean-Michel Pichavant
r wrote: The purpose of his thread was to get feedback on how Python and Ruby ideas could be cumulated into the best high level language. And being that i am the BDFL of the "Confessions of a Python Fanboy" thread, you have my personal permission to continue on with this subject matter..., Ch

Re: Confused About Python Loggin

2009-07-31 Thread Jean-Michel Pichavant
Jannik Sundø wrote: Hi all. I think I fixed this problem by setting fileLogger.propagate = 0. Otherwise it will propagate up to the root logger, which outputs to stdout, as far as I can understand. On 31 Jul 2009, at 01:17, Jannik Sundø wrote: Dear all, I am quite confused about the Python l

Re: Printing with colors in a portable way

2009-08-03 Thread Jean-Michel Pichavant
Nobody wrote: On Thu, 30 Jul 2009 15:40:37 -0700, Robert Dailey wrote: Anyone know of a way to print text in Python 3.1 with colors in a portable way? In other words, I should be able to do something like this: print_color( "This is my text", COLOR_BLUE ) And this should be portable (i.e.

Re: Generate a new object each time a name is imported

2009-08-03 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: I would like to generate a new object each time I import a name from a module, rather than getting the same object each time. For example, currently I might do something like this: # Module count = 0 def factory(): # Generate a unique object each time this is called

Re: Unexpected side-effects of assigning to sys.modules[__name__]

2009-08-06 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: Given this module: #funny.py import sys print "Before:" print " __name__ =", __name__ print " sys.modules[__name__] =", sys.modules[__name__] sys.modules[__name__] = 123 print "After:" print " __name__ =", __name__ print " sys =", sys when I run it I get these result

Re: help with threads

2009-08-07 Thread Jean-Michel Pichavant
Michael Mossey wrote: Hello, I have a simple application that needs one thread to manage networking in addition to the main "thread" that does the main job. It's not working right. I know hardly anything about threads, so I was hoping someone could point me in the right direction to research thi

Re: Python docs disappointing - group effort to hire writers?

2009-08-07 Thread Jean-Michel Pichavant
alex23 wrote: Paul Rubin wrote: The PHP docs as I remember are sort of regular (non-publically editable) doc pages, each of which has a public discussion thread where people can post questions and answers about the topic of that doc page. I thought it worked re

Re: Need cleanup advice for multiline string

2009-08-12 Thread Jean-Michel Pichavant
Simon Brunning wrote: 2009/8/11 Robert Dailey : On Aug 11, 3:40 pm, Bearophile wrote: There are gals too here. It's a figure of speech. And besides, why would I want programming advice from a woman? lol. Thanks for the help. Give the attitudes still prevalent in our indu

Re: best practice for documenting a project? pydoc?

2009-08-12 Thread Jean-Michel Pichavant
Esmail wrote: shaileshkumar wrote: Hello, EPYDOC is very good for automatic generation of documentation from source code. You may also consider Sphinx http://sphinx.pocoo.org/ which is used for many projects including the official Python documentation, documentation of Zope (http://docs.zope.o

Re: trouble with reload

2009-08-14 Thread Jean-Michel Pichavant
Dr. Phillip M. Feldman wrote: Actually, I've tried both of these, and I get (different) errors in both cases: In [1]: from mymath import * In [2]: reload(mymath) NameError: name 'mymath' is not defined In [3]: reload('mymath') TypeError: reload() argument must be module Please don't top p

Re: implementing descriptors

2009-08-14 Thread Jean-Michel Pichavant
Emile van Sebille wrote: On 8/13/2009 3:17 PM dippim said... I am new to Python and I have a question about descriptors. If I have a class as written below, is there a way to use descriptors to be certain that the datetime in start is always before the one in end? class foo(object): def __i

callable virtual method

2009-08-14 Thread Jean-Michel Pichavant
Hi fellows, Does anyone know a way to write virtual methods (in one virtual class) that will raise an exception only if called without being overridden ? Currently in the virtual method I'm checking that the class of the instance calling the method has defined that method as well. Example: c

Re: callable virtual method

2009-08-14 Thread Jean-Michel Pichavant
MRAB wrote: Jean-Michel Pichavant wrote: Hi fellows, Does anyone know a way to write virtual methods (in one virtual class) that will raise an exception only if called without being overridden ? Currently in the virtual method I'm checking that the class of the instance calling the m

Re: callable virtual method

2009-08-14 Thread Jean-Michel Pichavant
Diez B. Roggisch wrote: Jean-Michel Pichavant schrieb: MRAB wrote: Jean-Michel Pichavant wrote: Hi fellows, Does anyone know a way to write virtual methods (in one virtual class) that will raise an exception only if called without being overridden ? Currently in the virtual method I&#

Re: A Exhibition Of Tech Geekers Incompetence: Emacs whitespace-mode

2009-08-14 Thread Jean-Michel Pichavant
vippstar wrote: On Aug 14, 8:25 pm, fortunatus wrote: On Aug 14, 1:01 pm, vippstar wrote: Why would you fill your website with junk? The OP made it clear: Just wanted to express some frustration with whitespace-mode. You took my question out of context and ans

Re: callable virtual method

2009-08-14 Thread Jean-Michel Pichavant
Nigel Rantor wrote: Jean-Michel Pichavant wrote: Your solution will work, for sure. The problem is that it will dumb down the Base class interface, multiplying the number of methods by 2. This would not be an issue in many cases, in mine there's already too much meaningful methods

Re: callable virtual method

2009-08-14 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Fri, 14 Aug 2009 18:49:26 +0200, Jean-Michel Pichavant wrote: Sorry guys (means guys *and* gals :op ), I realized I've not been able to describe precisely what I want to do. I'd like the base class to be virtual (aka abstract). However it may be

Re: callable virtual method

2009-08-14 Thread Jean-Michel Pichavant
Dave Angel wrote: Jean-Michel Pichavant wrote: Nigel Rantor wrote: Jean-Michel Pichavant wrote: Your solution will work, for sure. The problem is that it will dumb down the Base class interface, multiplying the number of methods by 2. This would not be an issue in many cases, in mine

Re: callable virtual method

2009-08-16 Thread Jean-Michel Pichavant
Scott David Daniels wrote: Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Fri, 14 Aug 2009 18:49:26 +0200, Jean-Michel Pichavant wrote: Sorry guys (means guys *and* gals :op ), I realized I've not been able to describe precisely what I want to do. I'd like the b

Re: callable virtual method

2009-08-16 Thread Jean-Michel Pichavant
Christian Heimes wrote: Jean-Michel Pichavant wrote: talking about approaches: 1/ class Interface: def foo(self): if self.__class__.foo == Interface.foo: raise NotImplementedError 2/ class Interface: def foo(self): self._foo() def _foo(sef): raise

Re: callable virtual method

2009-08-16 Thread jean-michel Pichavant
Christian Heimes a écrit : Jean-Michel Pichavant wrote: scott.dani...@acm.org That could do the trick, sparing me from writing additional code in each methods. Thanks. Why are you trying to reinvent the wheel? Python's abc module already takes care of these details. Christian I'

Re: Need cleanup advice for multiline string

2009-08-17 Thread Jean-Michel Pichavant
Grant Edwards wrote: On 2009-08-11, Bearophile wrote: Robert Dailey: This breaks the flow of scope. Would you guys solve this problem by moving failMsg into global scope? Perhaps through some other type of syntax? There are gals too here. Straying a bit OT, but I find t

Re: Diversity in Python (was Re: Need cleanup advice for multiline string)

2009-08-17 Thread Jean-Michel Pichavant
Aahz wrote: In article <461cc6f1-fc23-4bc7-a719-6f29babf8...@o15g2000yqm.googlegroups.com>, Robert Dailey wrote: It's a figure of speech. And besides, why would I want programming advice from a woman? lol. Thanks for the help. Well, I'm sorry to see this, it means I was wrong about t

Re: Need cleanup advice for multiline string

2009-08-18 Thread Jean-Michel Pichavant
MRAB wrote: Carl Banks wrote: On Aug 17, 10:03 am, Jean-Michel Pichavant wrote: I'm no English native, but I already heard women/men referring to a group as "guys", no matter that group gender configuration. It's even used for group composed exclusively of women. More

Re: Code formatting question: conditional expression

2009-08-18 Thread Jean-Michel Pichavant
Diez B. Roggisch wrote: John Posner wrote: While refactoring some code, I ran across an opportunity to use a conditional expression. Original: if total > P.BASE: excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True) else: excessblk = None Is there any

Re: Code formatting question: conditional expression

2009-08-18 Thread Jean-Michel Pichavant
John Posner wrote: My choice would be excessblk = None if total > P.BASE: excessblk = ... Diez and Jean-Michel, Ha! Your suggestion above was my *original* coding. It looks like I'm evolving backwards! But doesn't it violate the DRY principle? The token "excessblk" appears twice ins

Re: Start-up program

2009-08-18 Thread Jean-Michel Pichavant
Virgil Stokes wrote: How difficult is to create a program that will be executed when Windows Vista is started? As Windows Calendar does, for example. I am actually more interested in the Python tools that might be used for this task. I hope that this question is not inappropriate for the list

Re: Need cleanup advice for multiline string

2009-08-18 Thread Jean-Michel Pichavant
Steve Holden wrote: Robert Dailey: [...] It's a figure of speech. And besides, why would I want programming advice from a woman? lol. Thanks for the help. Sorry, Robert, simply not acceptable. Whether designed to be funny or not it's the kind of inane remark I would be really h

Re: Need cleanup advice for multiline string

2009-08-19 Thread Jean-Michel Pichavant
Grant Edwards wrote: On 2009-08-18, Simon Forman wrote: Sexism, racism, homophobia, religious intolerance, etc., all stem from a fundamental forgetfulness of our Unity in God (as I would put it) and this is perhaps the single greatest cause of human misery. You mean the single greate

Re: Need cleanup advice for multiline string

2009-08-19 Thread Jean-Michel Pichavant
Simon Forman wrote: On Tue, Aug 18, 2009 at 8:03 PM, Steven D'Aprano wrote: On Tue, 18 Aug 2009 17:13:02 -0400, Simon Forman wrote: Sexism, racism, homophobia, religious intolerance, etc., all stem from a fundamental forgetfulness of our Unity in God (as I would put it) and Of

Re: Sanitising arguments to shell commands

2009-08-21 Thread Jean-Michel Pichavant
Ben Finney wrote: Miles Kaufmann writes: I would recommend avoiding shell=True whenever possible. It's used in the examples, I suspect, to ease the transition from the functions being replaced, but all it takes is for a filename or some other input to unexpectedly contain whitespace or a me

Re: Sanitising arguments to shell commands

2009-08-21 Thread Jean-Michel Pichavant
Ben Finney wrote: Jean-Michel Pichavant writes: Can someone explain the difference with the shell argument ? giving for instance an example of what True will do that False won't. The ‘shell’ argument to the ‘subprocess.Popen’ constructor specifies whether the command-line shou

Re: your favorite debugging tool?

2009-08-24 Thread Jean-Michel Pichavant
Esmail wrote: Hi all, What is your favorite tool to help you debug your code? I've been getting along with 'print' statements but that is getting old and somewhat cumbersome. I'm primarily interested in utilities for Linux (but if you have recommendations for Windows, I'll take them too :) I u

Re: Is Python what I need?

2009-08-24 Thread Jean-Michel Pichavant
Peter Otten wrote: newbie wrote: I'm interested in developing computer based, interactive programs for students in a special school who have an aversion to pen and paper. I've searched the net to find ready made software that will meet my needs but it is either written to a level much higher

Re: your favorite debugging tool?

2009-08-25 Thread Jean-Michel Pichavant
Esmail wrote: Hi Ben, Ben Finney wrote: Whenever a simple output statement is too cumbersome for debugging, I take it as a sign that the program is too cumbersome to follow. I'll have to think about this .. though my gut says this is true :-) That is not always true. When it comes to implem

Re: Need help with Python scoping rules

2009-08-25 Thread Jean-Michel Pichavant
kj wrote: I have many years of programming experience, and a few languages, under my belt, but still Python scoping rules remain mysterious to me. (In fact, Python's scoping behavior is the main reason I gave up several earlier attempts to learn Python.) Here's a toy example illustrating what

Re: Need help with Python scoping rules

2009-08-25 Thread Jean-Michel Pichavant
Diez B. Roggisch wrote Classes are not scopes. Too bad, could have been handy. JM -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with Python scoping rules

2009-08-27 Thread Jean-Michel Pichavant
Ulrich Eckhardt wrote: Ulrich Eckhardt wrote: Jean-Michel Pichavant wrote: class Color: def __init__(self, r, g,b): pass BLACK = Color(0,0,0) It make sens from a design point of view to put BLACK in the Color namespace. But I don't think it's possible w

Re: Need help with Python scoping rules

2009-08-27 Thread Jean-Michel Pichavant
kj wrote: I think I understand the answers well enough. What I *really* don't understand is why this particular "feature" of Python (i.e. that functions defined within a class statement are forbidden from "seeing" other identifiers defined within the class statement) is generally considered to b

Re: passing object between classes

2009-09-21 Thread Jean-Michel Pichavant
daved170 wrote: On Sep 21, 1:44 pm, Duncan Booth wrote: daved170 wrote: Hi everybody, I built my owen log obj as a class. I'm passing it to another object (actually to a thread). When I run my app it raise error at the line when I'm using that log obj. is there any problem with the co

Re: Module inspection by name

2009-09-22 Thread Jean-Michel Pichavant
Nadav Chernin wrote: Hi all, a have easy question for python developers. Assume I have list of all objects: obj=dir() Now I want to know which object from “obj” list is module. I searched some method in module inspection, but there is not any method that get ‘string’ as parameters Any rep

Re: Logging question

2009-09-23 Thread Jean-Michel Pichavant
Gabor Urban wrote: Hi guys, I have embarassing problem using the logging module. I would like to encapsulate the creation and setting up of the logger in a class, but it does not seem working. Here are my relevant parts of the code: -- import sys import logging class LogClass: def __init

Re: cleanup in sys.excepthook?

2009-09-23 Thread Jean-Michel Pichavant
akonsu wrote: hello, my script creates files that i need to delete if an exception is thrown. is this a good pythonic style to do this kind of cleanup in sys.excepthook instead of inside except clause of a try block? konstantin def doIt(): pass try: doIt() except Exception, exc:

Re: Looger object only prints "ERROR"s

2009-09-24 Thread Jean-Michel Pichavant
daved170 wrote: hi everybody, I took your adviced and used the logging object. I copied the example in 16.6.15.2 - "using logging in multiple modules" from http://docs.activestate.com/activepython/3.1/python/library/logging.html. unfortunattly it only prints to file the ERROR level's messages a

Re: Looger object only prints "ERROR"s

2009-09-24 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: daved170 wrote: hi everybody, I took your adviced and used the logging object. I copied the example in 16.6.15.2 - "using logging in multiple modules" from http://docs.activestate.com/activepython/3.1/python/library/logging.html. unfortunattly it only

Re: Evaluate coding and style

2009-09-25 Thread Jean-Michel Pichavant
Rhodri James wrote: On Thu, 24 Sep 2009 21:11:36 +0100, Brown, Rodrick wrote: I recently started playing with Python about 3 days now (Ex Perl guy) and wanted some input on style and structure of what I'm doing before I really start picking up some bad habits here is a simple test tool I w

Re: Calling an arbitrary function with the right arguments

2010-09-27 Thread Jean-Michel Pichavant
John O'Hagan wrote: How to call a function with the right arguments without knowing in advance which function? For example: import random def f1(): pass def f2(foo): pass def f3(foo, bar): pass foo=random.choice((1,2,3)) bar=random.choice((1,2,3)) myfunc=random.choice((f1, f2,

Re: Module loading trickery

2010-10-05 Thread Jean-Michel Pichavant
Jonas Galvez wrote: Is there a way to "inject" something into a module right before it's loaded? For instance, a.py defines "foo". b.py print()s "foo". I want to load b.py into a.py, but I need to let b.py know about "foo" before it can execute. Is this any way to achieve this? -- Jonas

Re: Many newbie questions regarding python

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

Re: Many newbie questions regarding python

2010-10-11 Thread Jean-Michel Pichavant
Peter Pearson wrote: On Sat, 09 Oct 2010 19:30:16 -0700, Ethan Furman wrote: Steven D'Aprano wrote: [snip] But that doesn't mean that the list comp is the general purpose solution. Consider the obvious use of the idiom: def func(arg, count): # Initialise the list. L = [ar

Re: Class-level variables - a scoping issue

2010-10-11 Thread Jean-Michel Pichavant
John Nagle wrote: Here's an obscure bit of Python semantics which is close to being a bug: >>> class t(object) : ... classvar = 1 ... ... def fn1(self) : ... print("fn1: classvar = %d" % (self.classvar,)) ... self.classvar = 2 ... print("fn1: classvar = %d" % (

Re: optparser: how to register callback to display binary's help

2010-10-13 Thread Jean-Michel Pichavant
hiral wrote: Hi, I want to display help message of python script and then display help message from the binary file (which also supports -h option): Assumptions: 1) 'mybinary' - is linux executable file which supports '-h' and on '- h' option it displays the help message 2) myscript.py - when p

Re: My first Python program

2010-10-13 Thread Jean-Michel Pichavant
Seebs wrote: So, I'm new to Python, though I've got a bit of experience in a few other languages. My overall impressions are pretty mixed, but overall positive; it's a reasonably expressive language which has a good mix between staying out of my way and taking care of stuff I don't want to waste

Re: PyCharm

2010-10-15 Thread Jean-Michel Pichavant
Kai Diefenbach wrote: On 2010-10-13 23:36:31 +0200, Robert H said: Since the new IDE from Jetbrains is out I was wondering if "you" are using it and what "you" think about it. It sucks. http://regebro.wordpress.com/2010/10/14/python-ide-code-completion-test Kai You're not serious, this 'b

Re: Deditor -- pythonic text-editor

2010-10-18 Thread Jean-Michel Pichavant
Kruptein wrote: on steven, peter and eliasf: Well okay I'm new to the world of developing programs, if I encounter problems I directly post a bug on the relevant page, that's maybe why I was a bit frustrated :) but what you three say is indeed true.. Hi, It does not work with python 2.5 (w

Re: ANN: stats 0.1a calculator statistics for Python

2010-10-18 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: I am pleased to announce the first public release of stats for Python. http://pypi.python.org/pypi/stats stats is a pure-Python module providing basic statistics functions similar to those found on scientific calculators. It currently includes: Univariate statistics in

Re: OO and game design questions

2010-10-18 Thread Jean-Michel Pichavant
dex wrote: In each object's __init__() that object is added to game_object list, and in each __del__() they are removed from game_object list. This mechanism keeps them safe from garbage collector. How pythonic is this design? You don't have to manage memory with python, I don't know if you w

Re: Classes in a class: how to access variables from one in another

2010-10-18 Thread Jean-Michel Pichavant
f...@slick.airforce-one.org wrote: Neil Cerutti wrote: I have a class A that contains two classes B and C: class A: class B: self.x = 2 class C: I only wanted to show the structure of the code, not the actual instructions. Always post working code, or at least some

Re: Classes in a class: how to access variables from one in another

2010-10-18 Thread Jean-Michel Pichavant
f...@slick.airforce-one.org wrote: Christian Heimes wrote: Don't nest classes. Just don't. This might be a valid and good approach in some programming languages but it's not Pythonic. Your code can easily be implemented without nested classes. I think you're right. It would have been

Re: Classes in a class: how to access variables from one in another

2010-10-18 Thread Jean-Michel Pichavant
f...@slick.airforce-one.org wrote: Jean-Michel Pichavant wrote: Always post working code, or at least something we can paste in the python interpreter (even if it's buggy) Ok, noted. class A: class B: x=2 class C: def __init__(self): print A.B

Re: ANN: stats 0.1a calculator statistics for Python

2010-10-19 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Tue, 19 Oct 2010 11:53:40 +1100, Ben Finney wrote: Steven D'Aprano writes: On Mon, 18 Oct 2010 11:56:39 +0200, Jean-Michel Pichavant wrote: I already have a stats module: /usr/lib/python2.5/site-packages/stats.py The name of my

Re: pylint -- should I just ignore it sometimes?

2010-10-20 Thread Jean-Michel Pichavant
Seebs wrote: On 2010-10-19, Martin P. Hellwig wrote: Speaking without context here, so take it with as much salt as required ;-), it is not that unusual. However there are some things to consider, for example are all these attributes related to each other? If so wouldn't it be more pythoni

Re: pylint -- should I just ignore it sometimes?

2010-10-21 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 20 Oct 2010 12:47:02 +0200, Jean-Michel Pichavant wrote: except ValueError, e: Use meaningful names, this is so important. 'e' is not meaningful. 'exception' would be slighly better. While I agree with everything else you h

Re: pylint -- should I just ignore it sometimes?

2010-10-21 Thread Jean-Michel Pichavant
Martin P. Hellwig wrote: On 10/20/10 22:09, Seebs wrote: On 2010-10-20, Matteo Landi wrote: Another situation in which I needed to disable such kind of warnings is while working with graphics modules. I often use variable names such as x, y, z for coordinates, or r,g,b for colors. Would long

Re: pylint -- should I just ignore it sometimes?

2010-10-21 Thread Jean-Michel Pichavant
You won't be that happy everyone wrote their mail in this list like a mobile text message, if u c what I mean. I never suggested that. What I am trying to get across is that long names are not automatically better than short names, and even one letter names can be as good or better than

Re: pylint -- should I just ignore it sometimes?

2010-10-21 Thread Jean-Michel Pichavant
Mel wrote: Steven D'Aprano wrote: On Thu, 21 Oct 2010 12:49:47 +, Neil Cerutti wrote: _The Practice of Programming_ has this right. In general the bigger the scope of a variable, the longer and more descriptive should be its name. In a small scope, a big name is mostly noise.

Re: pylint -- should I just ignore it sometimes?

2010-10-22 Thread Jean-Michel Pichavant
Seebs wrote: On 2010-10-21, Jean-Michel Pichavant wrote: Let me quote the paper I linked in the previous post: list1 = [] for x in theList: if x[0] == 4: list1 += x; return list1 compare it to: flaggedCells = [] for cell in theBoard: if cell[STATUS_VALUE] == FLAGGED

Re: pylint -- should I just ignore it sometimes?

2010-10-22 Thread Jean-Michel Pichavant
Seebs wrote: On 2010-10-21, Jean-Michel Pichavant wrote: It can be short if descriptive: for o, c in cars: park(o) phone(c) for owner, car in cars: # by just using meaningful names you give the info to the reader that you expect cars to be a list of tuple

Re: pylint -- should I just ignore it sometimes?

2010-10-22 Thread Jean-Michel Pichavant
I'm all for descriptive names, but there's a great deal of benefit to knowing when a descriptive name will help, and when all you need is a variable which will be quickly recognized. Compare: [theValueInTheList.func() forTheValueInTheList in theList] [x.func() for x in list] One of these is mu

python logging, handling multiline log entries

2010-11-04 Thread Jean-Michel Pichavant
Hi python fellows, I'm looking to do the following : import logging l = logging.getLogger('aHeader') l.handlers = [] l.addHandler(logging.StreamHandler()) l.handlers[-1].setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(message)s")) l.error('1st line\n2nd line') output: 2010-11-04 1

Re: python logging, handling multiline log entries

2010-11-04 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Hi python fellows, I'm looking to do the following : import logging l = logging.getLogger('aHeader') l.handlers = [] l.addHandler(logging.StreamHandler()) l.handlers[-1].setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(message)s&q

Re: Deditor 0.2.2

2010-11-08 Thread Jean-Michel Pichavant
TheSeeker wrote: On Nov 6, 7:06 am, Kruptein wrote: Hey, I released version 0.2.2 of my pythonic text-editor Deditor. It adds the use of projects, a project is a set of files which you can open all at once to make development much faster and easier. For more information visit launchpad:ht

Re: How to test if a module exists?

2010-11-09 Thread Jean-Michel Pichavant
Jon Dufresne wrote: On Sat, Nov 6, 2010 at 1:52 PM, Roy Smith wrote: import sys try: import xx except ImportError: tb = sys.exc_traceback while tb: print tb tb = tb.tb_next I went ahead and implemented this and it now works. I even uncovered a bug I wasn't prev

Re: Pythonic/idiomatic?

2010-11-09 Thread Jean-Michel Pichavant
Seebs wrote: I have an existing hunk of Makefile code: CPPFLAGS = "$(filter -D* -I* -i* -U*,$(TARGET_CFLAGS))" For those not familiar with GNU makeisms, this means "assemble a string which consists of all the words in $(TARGET_CFLAGS) which start with one of -D, -I, -i, or -U". So if you

Re: Dictionary of lists strange behaviour

2010-11-09 Thread Jean-Michel Pichavant
Ciccio wrote: Hi all, hope you can help me understanding why the following happens: In [213]: g = {'a': ['a1','a2'], 'b':['b1','b2']} In [214]: rg = dict.fromkeys(g.keys(),[]) In [215]: rg Out[215]: {'a': [], 'b': []} In [216]: rg['a'].append('x') In [217]: rg Out[217]: {'a': ['x'], 'b': ['x']}

<    5   6   7   8   9   10