Re: pythonize this!

2010-06-15 Thread Jean-Michel Pichavant
superpollo wrote: superpollo ha scritto: Peter Otten ha scritto: superpollo wrote: goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three consecutive + must be followed by two - (^ meaning ** in this context) from itertools import cycle, izip sum

Re: logging = logging.getLogger(__name__)

2010-06-15 Thread Jean-Michel Pichavant
genkuro wrote: On Jun 15, 8:49 am, Mark Lawrence wrote: On 15/06/2010 16:35, genkuro wrote: Newbie here. I may be missing something obvious, in which case, please feel free to berate and laugh at me. Here's a dubious line of code: logging = logging.getLogger(__name__)

Re: Possible to make subprocess.Popen jobs run serially rather than in parallel?

2010-06-16 Thread Jean-Michel Pichavant
Chris Seberino wrote: On Jun 15, 2:03 pm, Stephen Hansen wrote: Just call "process.wait()" after you call process = subprocess.Popen(...) I may have not been clear. I *don't* want web app to block on Popen.wait. I *do* want the Popen process to run in the background which web app

Re: super() woes (n00b)

2010-06-18 Thread Jean-Michel Pichavant
Deadly Dirk wrote: I cannot get right the super() function: Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22) [GCC 4.4.1] on linux2 Type "copyright", "credits" or "license()" for more information. No Subprocess class P: def __init__(__class__,self): print("I

Re: variable variables

2010-06-18 Thread Jean-Michel Pichavant
someone wrote: On Jun 18, 12:49 pm, James Mills wrote: On Fri, Jun 18, 2010 at 8:31 PM, someone wrote: I was looking for a "short way" to do it because I have a lot "some_object.attr.attr or some_object.other_attr.attr" in code. it looks like I cannot replace attr with just other vari

Re: super() woes (n00b)

2010-06-18 Thread Jean-Michel Pichavant
Deadly Dirk wrote: On Fri, 18 Jun 2010 11:19:56 +0200, Jean-Michel Pichavant wrote: Deadly Dirk wrote: I cannot get right the super() function: Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22) [GCC 4.4.1] on linux2 Type "copyright", "credits" or "licens

Re: constructing an object from another instance of the same class

2010-06-21 Thread Jean-Michel Pichavant
Christoph Groth wrote: Dear all, sometimes it is handy to have a function which can take as argument anything which can be converted into something, e.g. def foo(arg): arg = float(arg) # ... I would like to mimic this behavior of float for a user-defined type, e.g. def bar(arg):

Re: Should I Learn Python or Ruby next?

2010-06-22 Thread Jean-Michel Pichavant
Josef Tupag wrote: I've been programming (when I do program) mainly in Perl for the last 10 years or so. But I've been itching to learn a new language for a while now, and the two near the top of the list are Ruby and Python

Re: From Dict to Classes yes or no and how

2010-06-22 Thread Jean-Michel Pichavant
Jerry Rocteur wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/22/2010 01:32 PM, Jerry Rocteur wrote: My input is NOT CSV, I used this format to try and make the question shorter. Although I could create a CSV file, I'd like to learn how to code a class to work the way I describ

Re: Should I Learn Python or Ruby next?

2010-06-23 Thread Jean-Michel Pichavant
rantingrick wrote: --- On Jun 22, 4:29 am, Jean-Michel Pichavant wrote: This is a python list, fully dedicated to our dutch semi God. So how can you even immagine that someone here will suggest you to go for rub... sorry I can't prononce this blasphemous name. --- ...After re

Re: Extract doc strings

2010-07-01 Thread Jean-Michel Pichavant
moerchendiser2k3 wrote: Hi all, when I have a PyCodeObject, is there any way to extract a doc string from the code? For instance the following script <---script> """ Hello World! """ def main(): pass main() I would like to get "Hello World!". Any chance? Thanks in advance!! Bye, moer

Re: Why are String Formatted Queries Considered So Magical?

2010-07-01 Thread Jean-Michel Pichavant
Stephen Hansen wrote: On 6/30/10 11:58 PM, Jorgen Grahn wrote: On Wed, 2010-06-30, Steven D'Aprano wrote: On Wed, 30 Jun 2010 14:14:38 +, Jorgen Grahn wrote: On Tue, 2010-06-29, Stephen Hansen wrote: There's nothing silly about it. It is an exaggeration though: but it does represent a g

Re: optphart (alpha2)

2010-07-01 Thread Jean-Michel Pichavant
Stephen Hansen wrote: On 6/28/10 11:50 PM, rantingrick wrote: You just don't get the point, do you? And just what *point* an i supposed to be "getting" Stephen? That you don't like my contribution? If thats your point then i very much "get" it. This garbage: "optphart is the nemisis of the

Re: [ANN] eric 5.0.0 released

2010-07-05 Thread Jean-Michel Pichavant
Detlev Offenbach wrote: Hi, I just uploaded eric 5.0.0. This is the first official release. It is available via the eric web site. http://eric-ide.python-projects.org/index.html What is it? --- eric5 is the Python3 variant of the well know eric4 Python IDE and is the first developme

Re: 'reload M' doesn't update 'from M inport *'

2010-07-09 Thread Jean-Michel Pichavant
Frederic Rentsch wrote: I develop in an IDLE window. Module M says 'from service import *'. Next I correct a mistake in function 'service.f'. Now 'service.f' works fine. I do 'reload (service); reload (M)'. The function 'M.f' still misbehaves. 'print inspect.getsource (service.f)' and 'print i

Re: Hello

2010-07-09 Thread Jean-Michel Pichavant
Dani Valverde wrote: Sorry, I forgot to mention that I am using Linux. In fact, my first test have been with gedit. Is there any way to directly run the Python code into the console? Cheers! Dani Bradley Hintze wrote: There are lots of great editors out there. It really depends on personal

Re: simples setup for an wsgi https server in python

2010-07-10 Thread Jean-Paul Calderone
an https server, that > supports wsgi modules > > TIA You could do this with Twisted: twistd -n web --https 443 --certificate server.pem --privkey server.key --wsgi your.application Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: 'reload M' doesn't update 'from M inport *'

2010-07-12 Thread Jean-Michel Pichavant
Aahz wrote: In article , Jean-Michel Pichavant wrote: PS : You're misusing the del statement. It does not remove any object >from mmory, however, it removes the reference to it, the object is still in memory. They are very few cases where del is usefull in python, so try

Re: 'reload M' doesn't update 'from M inport *'

2010-07-12 Thread Jean-Michel Pichavant
Hi, Don't use reload, this is nothing but a trap, espacially if your using it to update your objects with the code you are writting. JM I've found "reload" very usable for development in IDLE. IDLE memorizes my input, and the variables I assign output to. If restart IDLE I lose it all

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-12 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: My complaint (an oddly enough the title of this thread!) concerns the fact that Python treats 0 as False and every integer above and below 0 as True. Which is another example of how *some* aspects of Python support bad coding styles. Yes, Python does support bad codi

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-12 Thread Jean-Michel Pichavant
rantingrick wrote: On Jul 11, 3:03 am, "Günther Dietrich" wrote: So, it is not a disadvantage that the functions you listed above are named in this way. In the contrary, it is an advantage, as it keeps newcomers from using stupid variable names. "int" for an Integer is stupid? "list"

Re: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

2010-07-13 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 12 Jul 2010 19:28:28 -0600, Ian Kelly wrote: On Mon, Jul 12, 2010 at 6:18 PM, Steven D'Aprano wrote: I prefere to explicitly write what I want to test: if myInt <> 0: I would argue against that. Why do you, the coder, care about the specific d

Re: Check if a command is valid

2010-07-13 Thread Jean-Michel Pichavant
Kenny Meyer wrote: Hello, I have to figure out if a string is callable on a Linux system. I'm actually doing this: def is_valid_command(command): retcode = 100 # initialize if command: retcode = subprocess.call(command, shell=True) if retcode is 0:

Re: Code generator and visitor pattern

2010-07-16 Thread Jean-Michel Pichavant
Karsten Wutzke wrote: Yes, typo, I meant strictly. Damn, I mean strongly. At least not for identifying which methods to call depending on the type/s. Karsten Stringly is the perfect combination of strictly and strongly. Nice one :) JM -- http://mail.python.org/mailman/listinfo/pytho

Re: Difference between import in script and from interpreter

2010-07-19 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 19 Jul 2010 00:53:56 -0400, Edward Diener wrote: In a python script a: from xxx.yyy.zzz import aaa fails with the message: "ImportError: No module named xxx.yyy.zzz" but from within the python interpreter the same line succeeds. What would be the causes of

Re: hasattr + __getattr__: I think this is Python bug

2010-07-20 Thread Jean-Michel Pichavant
dmitrey wrote: hi all, I have a class (FuncDesigner oofun) that has no attribute "size", but it is overloaded in __getattr__, so if someone invokes "myObject.size", it is generated (as another oofun) and connected to myObject as attribute. So, when I invoke in other code part "hasattr(myObject,

Re: hasattr + __getattr__: I think this is Python bug

2010-07-20 Thread Jean-Michel Pichavant
dmitrey wrote: On 20 июл, 15:00, Jean-Michel Pichavant wrote: dmitrey wrote: hi all, I have a class (FuncDesigner oofun) that has no attribute "size", but it is overloaded in __getattr__, so if someone invokes "myObject.size", it is generated (as another oof

Re: loading configuration files that are themselves python

2010-07-29 Thread Jean-Michel Pichavant
Ben Finney wrote: Lawrence D'Oliveiro writes: In message <7j8w5tylmw@rapun.sel.cam.ac.uk>, Matthew Vernon wrote: Is there a more idiomatic way of loading in a configuration file that's python code ... Is it really a good idea to have a configuration language that’s Turing

Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-29 Thread Jean-Michel Pichavant
Robert Kern wrote: On 7/23/10 7:08 PM, Lawrence D'Oliveiro wrote: In message, Robert Kern wrote: There are also utilities for mounting ISOs directly without burning them to a physical disk. You need special utilities to do this?? On at least some versions of Windows, Yes. You need the

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Sun, 25 Jul 2010 13:58:00 +1200, Gregory Ewing wrote: Lacrima wrote: But what if SuperClass1 is from third party library? If it hasn't been designed for super(), then you can't use super() with it. super() only works when *every* class in the hierarc

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: [snip] super() is just as explicit as len(), or str.upper(). It says, explicitly, that it will call the method belonging to one or more superclass of the given class. Come on Steven, you're better than this :) . Everybody can accurately guess what len and upper are d

Re: stdout of external program.

2010-07-30 Thread Jean-Michel Pichavant
Paul Lemelle wrote: HELP! :) I am trying to output the following program's output to either a file or variable, how can this be done? # Writing the output to a standard argv argument #1/usr/bin/python import sys for arg in sys.argv: print arg #END Thanks, Paul Hi Paul, after reading

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote: [snip] As someone already said in this list, the main problem with super is that it tends to refer to the superclass method while in fact it calls the next MRO method. Why do you think that

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Fri, 30 Jul 2010 19:37:29 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote: > "mro" would have been the proper name for "super".

Re: Basic Information about Python

2010-07-30 Thread Jean-Michel Pichavant
Durga D wrote: Hi All, I am new to python based application developement. I am using Windows XP. 1. Can I create desktop application (just hello world program) with Python language like exe in VC++? yes http://www.py2exe.org/ 2. If First statement is Yes, Can I include this applicati

Re: Access stdout from external program.

2010-07-30 Thread Jean-Michel Pichavant
Paul Lemelle wrote: JM, Thanks for the response. I am trying to capture the stdout of a program from another program. Example, I want to launch the below program from a second python script then capture the first's program stdout to a file or variable. Is this possible? Thanks again, Paul

Re: Access stdout from external program.

2010-08-02 Thread Jean-Michel Pichavant
Paul Lemelle wrote: Hi JM, My last dumb question: When I try to run the below script as an executable, I get the following error: ptt...@ptttestvm:~$ ./argv.py 4 import: unable to open X server `/tmp/launch-c8feFG/org.x:0' @ import.c/ImportImageCommand/361. ./argv.py: line 8: syntax error n

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Jean-Michel Pichavant
Paul Rubin wrote: Michele Simionato writes: I am actually more radical than that. From http://www.artima.com/weblogs/viewpost.jsp?thread=237121: In this series I have argued that super is tricky; I think nobody can... When I look at that URL, I see a Java stack dump: java.lang.Runt

Re: namespaces, scoping and variables

2010-08-03 Thread Jean-Michel Pichavant
rantingrick wrote: On Aug 2, 3:12 pm, Chris Hare wrote: Also you should use 4 space indention and never use tabs. This is the accepted way. Then ask yourself why tabs are still in python 3. Nice troll by the way. JM -- http://mail.python.org/mailman/listinfo/python-list

Re: simple (I hope!) problem

2010-08-03 Thread Jean-Michel Pichavant
samwyse wrote: I'm writing for the Google app engine and have stubbed my toe yet again on a simple obstacle. Non-trivial app engines programs require the import of several modules that aren't normally in my PYTHONPATH. I'd like to be able to test my code outside of the app engine framework. I'v

Re: simple integer subclass

2010-08-03 Thread Jean-Michel Pichavant
Andreas Pfrengle wrote: On 3 Aug., 03:22, Carl Banks wrote:> You are creating an object that differs from a built-in, int, in a highly misleading way that only makes sense in a very limited context, and this object's modified behavior gives no clue that it's been modified in such as way. (T

Re: simple integer subclass

2010-08-03 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Andreas Pfrengle wrote: On 3 Aug., 03:22, Carl Banks wrote:> You are creating an object that differs from a built-in, int, in a highly misleading way that only makes sense in a very limited context, and this object's modified behavior gives no clue t

Re: Why is python not written in C++ ?

2010-08-04 Thread Jean-Michel Pichavant
Carl Banks wrote: On Aug 3, 7:07 pm, Paul Rubin wrote: Mozilla is fed up with C++ and seems to be working on its own language, called Rust: http://lambda-the-ultimate.org/node/4009 That looks much better than Go. It's like all the cool features of Go without the annoying polemics

Re: Global variables problem

2010-08-04 Thread Jean-Michel Pichavant
Navkirat Singh wrote: On 04-Aug-2010, at 9:46 AM, Daniel da Silva wrote: Please post approximate code that actually works and displays the problem. On Tue, Aug 3, 2010 at 9:00 PM, Navkirat Singh > wrote: Hey guys, I am using a multiprocessing program, w

Re: A new syntax for writing tests

2010-08-05 Thread Jean-Michel Pichavant
Jonathan Fine wrote: Hi I just discovered today a new syntax for writing tests. The basic idea is to write a function that contains some statements, and run it via a decorator. I wonder if anyone had seen this pattern before, and how you feel about it. For myself, I quite like it. Let's

Re: simple (I hope!) problem

2010-08-05 Thread Jean-Michel Pichavant
samwyse wrote: On Aug 3, 1:20 am, Steven D'Aprano wrote: On Mon, 02 Aug 2010 17:19:46 -0700, samwyse wrote: Fortunately, I don't need the functionality of the object, I just want something that won't generate an error when I use it. So, what is the quickest way to to create such an ob

Re: subprocess escaping POpen?!

2010-08-05 Thread Jean-Michel Pichavant
Chris Withers wrote: Hi All, I have a script that does the following: from subprocess import Popen,PIPE,STDOUT def execute(command,cwd): return Popen( command, stderr=STDOUT, stdout=PIPE, universal_newlines=True, cwd=cwd, shell=True,

Re: subprocess escaping POpen?!

2010-08-05 Thread Jean-Michel Pichavant
Chris Withers wrote: Jean-Michel Pichavant wrote: You did not redirect stdin, so it is expected you can still read input from the console. Okay, so if I definitely wanted no input, what should I pass as the stdin parameter to the POpen constructor? You do want an input don't you ? &

Re: A new syntax for writing tests

2010-08-05 Thread Jean-Michel Pichavant
jfine wrote: On 5 Aug, 10:17, Jean-Michel Pichavant wrote: Jonathan Fine wrote: Hi I just discovered today anewsyntaxfor writing tests. The basic idea is to write a function that contains some statements, and run it via a decorator. I wonder if anyone had seen this pattern

Re: easy question on parsing python: "is not None"

2010-08-05 Thread Jean-Michel Pichavant
wheres pythonmonks wrote: How does "x is not None" make any sense? "not x is None" does make sense. I can only surmise that in this context (preceding is) "not" is not a unary right-associative operator, therefore: x is not None === IS_NOTEQ(X, None) Beside "not in" which seems to work simila

Re: easy question on parsing python: "is not None"

2010-08-06 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Thu, 05 Aug 2010 12:07:53 -0400, wheres pythonmonks wrote: P.S. Sorry for the top-post -- is there a way to not do top posts from gmail? I haven't used usenet since tin. Er, surely you can just move the cursor before you start typing??? CTRL+END will b

Re: Python Script Cannot Write to Directory

2010-08-06 Thread Jean-Michel Pichavant
Lawrence D'Oliveiro wrote: In message <4c5a6d00$0$29614$426a3...@news.free.fr>, News123 wrote: The original question lacks necessary information That seems to be very common in this newsgroup. ... JM -- http://mail.python.org/mailman/listinfo/python-list

Re: easy question on parsing python: "is not None"

2010-08-10 Thread Jean-Michel Pichavant
Ben Finney wrote: Peter Pearson writes: Hey, that's a cute example, but . . . what a trap! Is it possible to document the use-the-object-not-the-string requirement loudly enough that people won't get caught? Don't use strings for such values. The data isn't going to be used, so there

Re: Python "why" questions

2010-08-10 Thread Jean-Michel Pichavant
Ben Finney wrote: "D'Arcy J.M. Cain" writes: No. You are giving me math and logic but the subject was common sense. Common sense is often unhelpful, and in such cases the best way to teach something is to plainly contradict that common sense. Common sense, for example, would have t

Re: GUI automation tool (windows)

2010-08-11 Thread Jean-Michel Pichavant
Grant Edwards wrote: On 2010-08-11, Lawrence D'Oliveiro wrote: In message , Alex Barna wrote: On Aug 10, 10:05 am, Lawrence D'Oliveiro Can???t understand the point to it. ???GUI automation??? is a contradiction in terms, because a GUI is designed for use by humans to do man

Re: How to swallow traceback message

2010-08-11 Thread Jean-Michel Pichavant
Back9 wrote: Hi, I run my py app to display a file's contents, and it is normally very long. So I use it like below: python myapp.py input_file | more to see them step by step. But when I try to exit it, normally I use Ctrl+ C key to quit it. Problem is every time I do like it, it shows Traceb

Re: Confused: Newbie Function Calls

2010-08-11 Thread Jean-Michel Pichavant
fuglyducky wrote: I am a complete newbie to Python (and programming in general) and I have no idea what I'm missing. Below is a script that I am trying to work with and I cannot get it to work. When I call the final print function, nothing prints. However, if I print within the individual functio

Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-12 Thread Jean-Michel Pichavant
Baba wrote: level: beginner exercise: given that packs of McNuggets can only be bought in 6, 9 or 20 packs, write an exhaustive search to find the largest number of McNuggets that cannot be bought in exact quantity. exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer

Re: __class__ of what

2010-08-12 Thread Jean-Michel Pichavant
Eric J. Van der Velden wrote: Hello, I have, class C: n=0 def __init__(s): __class__.n+=1 Should be class C: n = 0 def __init__(self): self.__class__.n+=1 C.n+=1 # equivalent to this line (I prefer this one, more readable, less refactor-

writing \feff at the begining of a file

2010-08-13 Thread Jean-Michel Pichavant
Hello python world, I'm trying to update the content of a $Microsoft$ VC2005 project files using a python application. Since those files are XML data, I assumed I could easily do that. My problem is that VC somehow thinks that the file is corrupted and update the file like the following: -

Re: Dump logging configuration

2010-08-16 Thread Jean-Michel Pichavant
Kxepal wrote: Hi all! Sorry for dumb question if it is - I'd tried to google it before but have found nothing. Is there any way to dump current logging configuration for future loading it via fileConfig/dictConfig? I may be wrong but I don't think so. JM -- http://mail.python.org/mailman/li

Re: Dump logging configuration

2010-08-16 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Kxepal wrote: Hi all! Sorry for dumb question if it is - I'd tried to google it before but have found nothing. Is there any way to dump current logging configuration for future loading it via fileConfig/dictConfig? I may be wrong but I don't thi

Re: passing variables as object attributes

2010-08-16 Thread Jean-Michel Pichavant
Vikas Mahajan wrote: On 16 August 2010 19:23, Nitin Pawar wrote: you would need to define a class first with its attiributes and then you may want to initiate the variables by calling the class initilializer Actually I have to dynamically add attributes to a object. I am writing pytho

Re: 79 chars or more?

2010-08-17 Thread Jean-Michel Pichavant
Michele Simionato wrote: On Aug 17, 6:50 am, AK wrote: On 08/17/2010 12:26 AM, James Mills wrote: By the way, the reason I asked is that we're working on a python tutorial and I realized that even though I'm used to 99, I wasn't sure if it's ok to teach that to new users or not.. -andrei

Re: 79 chars or more?

2010-08-18 Thread Jean-Michel Pichavant
D'Arcy J.M. Cain wrote: On Tue, 17 Aug 2010 16:28:02 +0200 Stefan Schwarzer wrote: I'd probably reformat this to self.expiration_date = translate_date( find(response, 'MPNExpirationDate').text, '%Y-%m-%d', '%m%d%Y') or even self.expiration_date

Re: 79 chars or more?

2010-08-24 Thread Jean-Michel Pichavant
Lawrence D'Oliveiro wrote: In message , Jean-Michel Pichavant wrote: Saying that, if one intend to distribute its code, he should stick to 80 chars per line. Why? Because some(many ?) people cannot deal with more than 80 chars, otherwise this rule would be pointless.

Re: What is a class method?

2010-08-24 Thread Jean-Michel Pichavant
Paulo da Silva wrote: Em 23-08-2010 04:30, James Mills escreveu: On Mon, Aug 23, 2010 at 12:49 PM, Paulo da Silva wrote: I understand the concept of a static method. However I don't know what is a class method. Would anybody pls. explain me? Please read this first: http://docs.

Re: Helper classes design question

2010-08-24 Thread Jean-Michel Pichavant
John O'Hagan wrote: I want to know the best way to organise a bunch of functions designed to operate on instances of a given class without cluttering the class itself with a bunch of unrelated methods. What I've done is make what I think are called helper classes, each of which are initialize

Re: How to see intermediate fail results from unittest as tests are running?

2010-08-25 Thread Jean-Paul Calderone
why, rather than > waiting until all the tests are done. > > I've searched the doc and even looked at the code, and it seems the > answer is no, but I'm just wondering if I'm missing something. > > Thanks! > > Margie trial (Twisted's test runner) has

Re: Messing up with classes and their namespace

2009-06-05 Thread Jean-Michel Pichavant
Scott David Daniels wrote: Jean-Michel Pichavant wrote: Hello world, I had recently a very nasty bug in my python application. The context is quite complex, but in the end the problem can be resume as follow: 2 files in the same directory : lib.py: >import foo >foo.Foo.BOOM='l

Re: can it be shorter?

2009-06-08 Thread Jean-Michel Pichavant
ution is by **far** the one I prefer if not url.endswith('/'): url += '/' Maybe not the shorter, but the most concise and clear to me. Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Start the interactive shell within an application

2009-06-09 Thread Jean-Michel Pichavant
I may use the raw_input and eval the captured text but honestly, this requires some coding and I won't benefit from the shell features. Would it be even possible to use a shell like Ipython ? By the way, if anyone has cunning ways for debugging code to share, he would be much welcome

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread Jean-Michel Pichavant
__ exceptions.LookupError exceptions.UnboundLocalError exceptions.__reduce_ex__ exceptions.MemoryError exceptions.UnicodeDecodeError exceptions.__repr__ exceptions.NameError exceptions.UnicodeEncodeError exceptions.__setattr__ exceptions.NotImplementedError exceptions.UnicodeError exceptions.__str__ CTRL+C (SIG_INT) i

Re: What is the actual type of "interrupted system call"?

2009-06-10 Thread Jean-Michel Pichavant
try: ... except Exception, excInstance: print excInstance.__class__.__name__ print excInstance.__dict__ If you know how to trigger the exception, it should print the class name of the exception, along with its attributes. It will help you then write a more focused except clause. Jean-M

Re: OT: Periodic table gets a new element

2009-06-11 Thread Jean-Michel Pichavant
Not if this element is to end up in some further ultimate nuclear weapon :-) , unless you are using python to conquer the world (I've been told this is GVR main secret objective). MRAB wrote: Element 112 is to be named. Do you think we could persuade the scientists to name it "Pythonium"? :-

Re: Need help in Python regular expression

2009-06-12 Thread Jean-Michel Pichavant
To the OP, I suggest if you haven't yet Kodos, to get it here http://kodos.sourceforge.net/. It's a python regexp debugger, a lifetime saver. Jean-Michel John S wrote: On Jun 11, 10:30 pm, meryl wrote: Hi, I have this regular expression blockRE = re.compile(".*RenderBl

Re: trying to understand dictionaries

2009-06-12 Thread Jean-Michel Pichavant
7;barack', 'obama', 'male'), 42 : ('bob', 'bib', 'male'), # you can use 42 as index, like strings integers are not mutable True: ('', '', ''), # meaningless example just to show that any immutable object wil

Re: EOF problem with ENTER

2009-06-12 Thread Jean-Michel Pichavant
x27;s still a major issue with your code, check out http://tottinge.blogsome.com/meaningfulnames/ If your code is a private script targeted at your personal use, well I guess you can just ignore my comment. But I'm still impressed by how some of the python-list users have dived into you

Re: matplotlib installation

2009-06-12 Thread Jean-Paul Calderone
, the people responsible for how CPython builds on Windows don't seem to consider this an issue. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: matplotlib installation

2009-06-12 Thread Jean-Paul Calderone
On Fri, 12 Jun 2009 22:54:14 +0900, David Cournapeau wrote: On Fri, Jun 12, 2009 at 9:50 PM, Jean-Paul Calderone wrote: On Fri, 12 Jun 2009 11:33:36 GMT, Alan G Isaac wrote: On 6/12/2009 5:55 AM Virgil Stokes apparently wrote: Any suggestions on installing matplotlib for Python 2.6.2 on a

Re: Question about None

2009-06-12 Thread Jean-Michel Pichavant
a famous coffee representative. If you like perfection, replace nxt==None by nxt is None. Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Re: waling a directory with very many files

2009-06-15 Thread Jean-Paul Calderone
bout APIs and ctypes deals with ABIs. http://pypi.python.org/pypi/ctypes_configure/0.1 helps with the problem, and is a bit more accessible than gccxml. It is basically correct to say that using ctypes without using something like gccxml or ctypes_configure will give you non-portable code. Jean-Paul

Re: twisted server

2009-06-15 Thread Jean-Paul Calderone
7;t a good way to make a web server with Twisted. Take a look at http://twistedmatrix.com/projects/web/documentation/howto/using-twistedweb.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Limit (max) connections SimpleHTTPServer

2009-06-15 Thread Jean-Paul Calderone
x.com/trac/ http://twistedmatrix.com/projects/core/documentation/howto/servers.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Perl's @foo[3,7,1,-1] ?

2009-06-17 Thread Jean-Michel Pichavant
On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange? import numpy as np -- Pierre "delroth" Bourdon Étudiant à l'EPITA / Student at EPITA Perfect example of why renaming namespaces should be done only when absolutely required, that

Re: Regarding Python is scripting language or not

2009-06-17 Thread Jean-Michel Pichavant
Regarding your last question, I'm not sure scripting and OOP language are not compatible, I'm pretty sure you'll be able to find OOP scripting language. Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way to overwrite a file

2009-06-17 Thread Jean-Michel Pichavant
Cameron Pulsford wrote: Hey all, hopefully a simple question. I'm writing a simple python tool that opens a file, and does something like for line in file.readlines(): temp.write(line.doStuff()) However, I want to provide the option do this "in place", as in have the destination file be

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Jean-Paul Calderone
that rely on technical details you know nothing about? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread Jean-Michel Pichavant
J. Cliff Dyer wrote: On Wed, 2009-06-17 at 14:13 +0200, Jean-Michel Pichavant wrote: On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange? import numpy as np -- Pierre "delroth" Bourdon Étudiant à l'EPITA / Student at EPITA

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread Jean-Michel Pichavant
J. Cliff Dyer wrote: On Mon, 2009-06-22 at 14:57 +0200, Jean-Michel Pichavant wrote: J. Cliff Dyer wrote: On Wed, 2009-06-17 at 14:13 +0200, Jean-Michel Pichavant wrote: On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread Jean-Michel Pichavant
Lie Ryan wrote: Jean-Michel Pichavant wrote: Maybe I've been a little bit too dictatorial when I was saying that renaming namespaces should be avoided. Sure your way of doing make sense. In fact they're 2 main purposes of having strong coding rules: 1/ ease the coder's l

Re: A superclass using a child classes' methods

2009-06-24 Thread Jean-Michel Pichavant
f): print "I'm your son" class Daughter(Parent): def foo(self): print "I'm your daughter" Son().bar() "I'm your son" Declaring the foo method at the Parent level is not required. But it's a good practice: explicit > im

Re: Get name of class without instance

2009-06-24 Thread Jean-Michel Pichavant
Bryan wrote: Given a class: class Foo(object): pass How can I get the name "Foo" without having an instance of the class? str(Foo) gives me more than just the name Foo. "__main__.Account" Foo.__class__.__name__ gives me "type" I don't want to do: Foo().__class__.__name__ if possible. I

Re: Matplotlib - an odd problem

2009-06-24 Thread Jean-Paul Calderone
ureCanvas(fig) canvas.set_size_request(640, 480) fig.savefig("foo.png") Hope this helps, Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: pep 8 constants

2009-06-30 Thread Jean-Michel Pichavant
, as someone mentioned before, PEPs are only guidelines, and you are entitled to break them if the rule hurts you. This is one of the many beauties of python, it's flexible. Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Re: string character count

2009-07-01 Thread Jean-Michel Pichavant
dir2/test', '.log') >>>os.path.splitext(os.path.basename(f)) ('test', '.log') >>>f2 = 'test.log' >>>os.path.splitext(os.path.basename(f2)) ('test', '.log') one safe way would be then >>> import os >>> x = "text12345.txt" >>> base , ext = os.path.splitext(os.path.basename(x)) >>> print len(base) 9 Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Re: question of style

2009-07-03 Thread Jean-Michel Pichavant
Simon Forman wrote: Hey I was hoping to get your opinions on a sort of minor stylistic point. These two snippets of code are functionally identical. Which would you use and why? The first one is easier [for me anyway] to read and understand, but Easier for you but not for those who are familia

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Jean-Michel Pichavant
h the abstraction (these notions does not necessarily collide). Here's a link on my how-to-name bible : http://tottinge.blogsome.com/meaningfulnames/ Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

Re: Clarity vs. code reuse/generality

2009-07-06 Thread Jean-Michel Pichavant
kj wrote: I've rewritten it like this: sense = cmp(func(hi), func(lo)) assert sense != 0, "func is not strictly monotonic in [lo, hi]" Thanks for your feedback! kj As already said before, unlike other languages, sense in english does **not** mean direction. You should rewrite th

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

2009-07-06 Thread Jean-Michel Pichavant
protocol = {"start":initialiser,"hunt":hunter,"classify":classifier,other states} def state_machine(): next_step = protocol["start"]() while True: next_step = protocol[next_step]() Woot ! I'll keep this one in my mind, while I may not be that concerned by speed unlike t

<    13   14   15   16   17   18   19   20   >