Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-06 Thread Jean-Michel Pichavant
Hendrik van Rooyen wrote: "Jean-Michel Pichavant" wrote: Woot ! I'll keep this one in my mind, while I may not be that concerned by speed unlike the OP, I still find this way of doing very simple and so intuitive (one will successfully argue how I was not figuring this o

Re: Clarity vs. code reuse/generality

2009-07-07 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Tue, 07 Jul 2009 05:13:28 +, Lie Ryan wrote: When people are fighting over things like `sense`, although sense may not be strictly wrong dictionary-wise, it smells of something burning... That would be my patience. I can't believe the direction this disc

Re: Clarity vs. code reuse/generality

2009-07-10 Thread Jean-Michel Pichavant
Nobody wrote: On Thu, 09 Jul 2009 04:57:15 -0300, Gabriel Genellina wrote: Nobody says you shouldn't check your data. Only that "assert" is not the right way to do that. "assert" is not the right way to check your *inputs*. It's a perfectly reasonable way to check data which "should"

the ultimate logging facility for debugging code

2009-07-10 Thread Jean-Michel Pichavant
ned value. It just saved me from hours of ipython interactive debugging with the old print way, and to beauty of it: I don't have to write any "self._log('Please log me')" line. As it is so useful, I bet there is a module that is doing this in a more reliable way th

Re: language analysis to enforce code standards

2009-07-10 Thread Jean-Michel Pichavant
fferent characters record = [] for c in s: if c not in record: record += [c] if len(record) >= N: print "at least %s different characters" % N Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a tool to checkfor python script backward compatibility

2009-07-12 Thread Jean-Paul Calderone
with whichever versions of Python you want to support. Tools like Hudson (<https://hudson.dev.java.net/>) and BuildBot (<http://buildbot.net/>) can help with this. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not enforce four space indentations in version 3.x?

2009-07-15 Thread Jean-Michel Pichavant
John Nagle wrote: walterbyrd wrote: I believe Guido himself has said that all indentions should be four spaces - no tabs. Since backward compatibility is being thrown away anyway, why not enforce the four space rule? At least that way, when I get python code from somebody else, I would know wh

Re: Colour of output text

2009-07-15 Thread Jean-Michel Pichavant
Nobody wrote: On Fri, 10 Jul 2009 09:23:54 +, garabik-news-2005-05 wrote: I would like to learn a way of changing the colour of a particular part of the output text. I've tried the following On Unix operating systems this would be done through the curses interface: http://docs

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
Christian Heimes wrote: Chris Rebert wrote: Using the xor bitwise operator is also an option: bool(x) ^ bool(y) I prefer something like: bool(a) + bool(b) == 1 It works even for multiple tests (super xor): if bool(a) + bool(b) + bool(c) + bool(d) != 1: raise ValueError("

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). >>> l = [(True, True), (True, False), (False, True), (False, False)] >>> for p in l: ... p[0] or p[1] ... True True True False >>> for p in l: ... not(not p[0] and not p[1]) ... T

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
Miles Kaufmann wrote: On Jul 15, 2009, at 1:43 PM, Jean-Michel Pichavant wrote: Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). >>> l = [(True, True), (True, False), (False, True), (False, False)] >>> for p in l: .

Re: missing 'xor' Boolean operator

2009-07-16 Thread Jean-Michel Pichavant
Nobody wrote: On Wed, 15 Jul 2009 21:05:16 +0200, Jean-Michel Pichavant wrote: So if I resume: - not 'foo' => False - 'foo' or 'foo' => 'foo' I may be missing something, but honestly, Guido must have smoked some heavy stuff to write such logic

Re: missing 'xor' Boolean operator

2009-07-16 Thread Jean-Michel Pichavant
Emile van Sebille wrote: On 7/16/2009 2:06 AM Jean-Michel Pichavant said... Ok then, why "or" does not return True, if the first element is considered True ? Why returning the element itself. Any reason for that ? Because it's confusing, maybe people used to that logic find it

Re: missing 'xor' Boolean operator

2009-07-16 Thread Jean-Michel Pichavant
Emile van Sebille wrote: On 7/16/2009 7:04 AM Unknown said... On 2009-07-16, Emile van Sebille wrote: daysInAdvance = int(inputVar) or 25 I don't get it. That doesn't work right when inputVar == "0". Aah, but you didn't get to define right. :) For that particular example 0 is not a vali

Re: Override a method but inherit the docstring

2009-07-16 Thread Jean-Paul Calderone
e) With the result of BarGonk.frobnicate.__doc__ being set to: Frobnicate this gonk. This implementation takes the warble into consideration. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-17 Thread Jean-Michel Pichavant
Luis Alberto Zarrabeitia Gomez wrote: Quoting Jean-Michel Pichavant : Emile van Sebille wrote: On 7/16/2009 7:04 AM Unknown said... On 2009-07-16, Emile van Sebille wrote: daysInAdvance = int(inputVar) or 25 I don't get it. That doesn't work

Re: missing 'xor' Boolean operator

2009-07-17 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Given three result codes, where 0 means "no error" and an arbitrary non- zero integer means some error, it is simple and easy to write: failed = result_1 or result_2 or result_3 The equi

Re: proposal: add setresuid() system call to python

2009-07-17 Thread Jean-Paul Calderone
following paper: Yes, it'd be good for Python to expose setresuid. The best course of action is to file a ticket in the issue tracker. Things will be sped along if you also attach a patch implementing the change. :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Design question.

2009-07-20 Thread Jean-Michel Pichavant
Lacrima wrote: Hello! I am newbie in python and I have really simple question, but I need your advice to know how to do best. I need to store a number of dictionaries in certain place. I've decided to store them in a separate module. Like this: dicts.py --- dict1 = {} dic

Re: How to import pydoc and then use it?

2009-07-21 Thread Jean-Michel Pichavant
Albert Hopkins wrote: On Mon, 2009-07-20 at 13:38 -0700, mrstevegross wrote: I know how to use pydoc from the command line. However, because of complicated environmental setup, it would be preferable to run it within a python script as a native API call. That is, my python runner looks a bit

Re: Regular expression

2009-07-21 Thread Jean-Michel Pichavant
Rhodri James wrote: On Tue, 21 Jul 2009 14:30:47 +0100, Peter Fodrek wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') Also, whoever wrote this regular expression

doted filenames in import statements

2009-07-21 Thread Jean-Michel Pichavant
Hi fellows, I'd like to use the dynamic __import__ statement. It works pretty well with non dotted names, but I cannot figure how to make it work with dotted file paths. example: file = "/home/dsp/test.py" test = __import__(file) works like a charm file = "/home/dsp/4.6.0.0/test.py" test =

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: If Scheme is so good why MIT drops it?

2009-07-22 Thread Jean-Paul Calderone
d somehow prevent I/O from being serviced? I'm not sure why, as long as the implementation pays attention to I/O events. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

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: Looking for a dream language: sounds like Python to me.

2009-07-27 Thread Jean-Paul Calderone
y2exe doesn't really change the performance characteristics of a Python application at all - for better or for worse. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

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: bad certificate error

2009-07-28 Thread Jean-Paul Calderone
ded to let OpenSSL make the decision about whether to accept the certificate or not. Either M2Crypto or pyOpenSSL will let you ignore verification errors. The new ssl module in Python 2.6 may also as well. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

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
your initial namespace. try this one: #funny.py import sys print "Before:" print " __name__ =", __name__ print " sys.modules[__name__] =", sys.modules[__name__] foo = sys.modules[__name__] # backup ref for the garbage collector sys.modules[__name__] = 123 print &quo

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 "excessb

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

Python and PHP encryption/decryption

2009-08-19 Thread Jean-Claude Neveu
on the Python side of things to do so. Many Thanks, Jean-Claude -- http://mail.python.org/mailman/listinfo/python-list

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
to your theoretical question : Use the standard python module logging for logging activities. http://docs.python.org/library/logging.html It's very powerful, standard, thread safe and time-saving. cheers, Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

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
relies on MyApp configuration logger # You can add code in case you are executing your module in standalone mode (for unit testing for instance) if __name__ == '__main__': _logger = logging.getLogger('moduleA') _logger.addHandler(logging.FileHandler('moduleA.test','a')) # here is some unit tests Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Re: cleanup in sys.excepthook?

2009-09-23 Thread Jean-Michel Pichavant
: #cleaning up files I mean, what is the problem with try except ? It's pythonic. If you tell us what wrong with it in your case, we may spend time on hacking sys.excepthook. Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Re: Looger object only prints "ERROR"s

2009-09-24 Thread Jean-Michel Pichavant
ler to you logger object. Try to change the format to "%(asctime)s - %(levelname)s - %(message)s" for testing purpose and tell us if you still have issues. /logging/ is the way to go, keep going :o) Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

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

File read from stdin and printed to temp file are not identicial?

2010-09-16 Thread Jean Luc Truchtersheim
d):\"%s\"" % (i+1, len(line), line, len(data[i]), data[i]) i += 1 sys.exit() #- I feel that I must be doing something very stupid, but I don't really know what. Any idea?

Re: File read from stdin and printed to temp file are not identicial?

2010-09-16 Thread Jean Luc Truchtersheim
Dear Fellow python users, Many thanks for your help. Those missing brackets were the cause of my problem. Now my program works as expected. Many, many heartfelt thanks. -- http://mail.python.org/mailman/listinfo/python-list

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: Python becoming orphaned over ssh

2010-09-30 Thread Jean-Paul Calderone
On Sep 30, 9:08 am, David wrote: > On Wed, Sep 29, 2010 at 6:49 PM, John Nagle wrote: > >   Python's signal handling for multithread and multiprocess programs > > leaves something to be desired. > > Thanks for the confirmation (that I'm not missing something obvious). > > I've reported a bug for

Re: Determine sockets in use by python

2010-09-30 Thread Jean-Paul Calderone
t, but appreciate any/all advice) > Linux has /proc/self/fd and OS X has /dev/fd. Those both suppose you have some way of determining which file descriptor corresponds to the socket or sockets that the library is using, of course. Vastly better would be to convince the author to expose that information via a real API. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python becoming orphaned over ssh

2010-10-01 Thread Jean-Paul Calderone
On Oct 1, 10:35 am, Antoine Pitrou wrote: > On Thu, 30 Sep 2010 07:01:09 -0700 (PDT) > > Jean-Paul Calderone wrote: > > > But signal dispositions are inherited by child processes.  So you run > > ping from your short Python program, and it inherits SIGPIPE being > >

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
remove_option('-h') parser.add_option("-h", "--help", help="display the help message", action='callback', callback = myHelp) Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

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

<    14   15   16   17   18   19   20   >