Re: Absolute imports?

2011-01-10 Thread Jean-Michel Pichavant
Roy Smith wrote: [snip] It's reasonably straight-forward to figure out that absolute path, starting from sys.argv[0] and using the tools in os.path. Now I need to import the file, given that I know its absolute pathname. It looks like imp.load_source() does what I want, I'm just wondering if

Re: importing modules dynamicly

2011-01-11 Thread Jean-Michel Pichavant
dubux wrote: I am trying to import modules dynamicly from a directory (modules/) in which i have __init__.py with the __all__ variable set. Everything imports correctly and I have verified this however I am stuck on actually using my classes in the dynamicly imported modules. this bit is in my m

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Jean-Michel Pichavant
Michele Simionato wrote: On Jan 11, 4:06 pm, Alice Bevan–McGregor wrote: Plac appears (from the documentation) to be written on top of argparse. :( And the problem with that being what? ... not available to python 2.5 / 2.6 users :) JM -- http://mail.python.org/mailman/listinfo/

Re: Nested structures question

2011-01-13 Thread Jean-Michel Pichavant
Physics Python wrote: Hello, I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number betw

Re: Which is the best book to learn python

2011-01-24 Thread Jean-Michel Pichavant
santosh hs wrote: Hi All, i am beginner to python please tell me which is the best available reference for beginner to start from novice Hi, You could have searched the archive, this question was raised many times. http://wiki.python.org/moin/IntroductoryBooks I read "Learning Python" whe

Re: Syntax help

2011-01-26 Thread Jean-Michel Pichavant
sl33k_ wrote: How to read syntax like this given in the documentation of python? (Newbie) defparameter ::= parameter ["=" expression] http://docs.python.org/reference/compound_stmts.html#function-definitions Just in case you're about to learn python using these defintions: Nobody's lea

Re: method-to-instance binding, callable generator decorator

2011-01-26 Thread Jean-Michel Pichavant
Jack Bates wrote: Am struggling to understand Python method-to-instance binding Anyone know why this example throws a TypeError? #!/usr/bin/env python import functools # Take a generator function (i.e. a callable which returns a generator) and # return a callable which calls .send() class

Re: use class factory to set required class variables?

2011-01-27 Thread Jean-Michel Pichavant
Alan wrote: I have a class ``A`` that is intentionally incomplete: it has methods that refer to class variables that do not exist. The class ``A`` has several complicated methods, a number of which reference the "missing" class variables. Obviously, I do not directly use ``A``. I have a class fa

Re: Executing multiple subprocesses and waiting

2011-01-27 Thread Jean-Michel Pichavant
JB wrote: One of my python scripts that takes a bunch of inputs from a tKinter gui, generates a set of command line stings, and then threads them off to subprocess for calls to other programs like Nuke and our render farm has recently started randomly crashing pythonw.exe. I'm taking a look at m

Re: Wrappers in python

2011-01-27 Thread Jean-Michel Pichavant
sl33k_ wrote: What are wrappers? What entities do they wrap around? Struggling to understand the concept. We would need a little bit of a context to answer that question, you could be refering to differents things. I'll give it a try on one common usage for wrapper: A wrapper is a pytho

Re: Which is the best book to learn python

2011-01-27 Thread Jean-Michel Pichavant
santosh hs wrote: I am very new to object oriented concept, so I need to learn everything frm basic, Will the above books fulfill My need read this http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm and stop when they start to talk about VBscript :) JM -- http://mail.python.org/m

Re: Style question: Nicknames for deeply nested objects

2011-01-31 Thread Jean-Michel Pichavant
Gerald Britton wrote: Hi all, Today I was thinking about a problem I often encounter. [snip] 1. You need to call this thing many times with different arguments, so you wind up with: x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) y = some.deeply.nested.obj

Re: Understanding def foo(*args)

2011-01-31 Thread Jean-Michel Pichavant
sl33k_ wrote: Hi, I am struggling to grasp this concept about def foo(*args). Also, what is def bar(*args, *kwargs)? Isnt it like self must be the first parameter to the method/function? If not what are the exceptions? Also, can the terms method and function be used interchangeably? TIA "

Re: multiple values for keyword argument

2011-01-31 Thread Jean-Michel Pichavant
pa...@cruzio.com wrote: I have been avoiding understanding this 'self', [snip] Regards, Patty What is to be understood ?? self references the instance. Did I miss something ? JM -- http://mail.python.org/mailman/listinfo/python-list

Re: simplest way to create simple standalone wsgi server without import wsgi_lib.server

2011-01-31 Thread Jean-Paul Calderone
ave a module named "foo" that defines an "application" name, you would pass "foo.application". Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple values for keyword argument

2011-02-01 Thread Jean-Michel Pichavant
Patty wrote: pa...@cruzio.com wrote: I have been avoiding understanding this 'self', [snip] Regards, Patty What is to be understood ?? self references the instance. Did I miss something ? JM Yes, there was more. And it's been fully explained at this point. Patty Hmm... I re-

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Jean-Michel Pichavant
rantingrick wrote: On Feb 1, 6:53 am, Adam Tauno Williams wrote: If you despise IDLE so much - use one of the many other IDE's that support Python; move on. Not exactly. Can we continue to ignore such lackluster and shabby code in OUR stdlib. Remember the code reflects on all of us!

Re: simplest way to create simple standalone wsgi server without import wsgi_lib.server

2011-02-01 Thread Jean-Paul Calderone
On Feb 1, 2:01 pm, Gelonida wrote: > On 02/01/2011 03:07 AM, Jean-Paul Calderone wrote: > > > > > On Jan 31, 5:28 pm, Gelonida wrote: > >> Hi, > > >> Normally I use following code snippet to quickly test a wsgi module > >> wit

Re: Style question: Nicknames for deeply nested objects

2011-02-03 Thread Jean-Michel Pichavant
Gerald Britton wrote: however, considering what "import a.module.that.is.quite.nested as myModule" Won't work since I get the objects at run time myModule = __import__('whatever.module.imported.at.run.time', globals(), locals(), [], -1) See http://docs.python.org/library/function

Re: Style question: Nicknames for deeply nested objects

2011-02-03 Thread Jean-Michel Pichavant
Gerald Britton wrote: Nope. it's nothing to do with imports. It's about objects passed to methods at run time. Complicated objects with many levels. Not about modules at all. Who is providing these objects ? - Your code ? => as said before, you can fix your design with a proper object

Re: socket.rcv timeout while-loop

2011-02-04 Thread Jean-Michel Pichavant
Stephen Hansen wrote: On 2/3/11 9:56 AM, Dwayne Blind wrote: However I would like to set timeout on the socket rcv method, so that the while loop stops exactly after 3 seconds. Is this possible ? I rarely do low-level socket stuff -- [snip] Good point. Python has a module for almos

Re: socket.rcv timeout while-loop

2011-02-04 Thread Jean-Michel Pichavant
Dwayne Blind wrote: Thanks to all of you. @ Jean-Michel Pichavant I am writing a small multiplayer game. Several clients are connected to the server. Games last, say, 20 seconds. You can think of the game as a small chat lasting 20 seconds. All the data received by the server is sent back to

Re: Converging Multiple Classes

2011-02-04 Thread Jean-Michel Pichavant
Wanderer wrote: I have a bunch of cameras I want to run tests on. They each have different drivers and interfaces. What I want to do is create python wrappers so that they all have a common interface and can be called by the same python test bench program. I'm not sure what to call it. I don't th

Re: sending through non-default gateway

2011-02-06 Thread Jean-Paul Calderone
by the first router that sees them). You just need to make a different decision at the first hop. You can do this with the SO_BINDTODEVICE option on a raw socket. But this probably also requires administrative privileges. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: using attributes as defaults

2011-02-08 Thread Jean-Michel Pichavant
Westley Martínez wrote: On Fri, 2011-02-04 at 13:08 -0800, Wanderer wrote: I want to give the option of changing attributes in a method or using the current values of the attributes as the default. class MyClass(): """ my Class """ def __init__(self): """ initialize

Re: AF_UNIX socket not supported

2011-02-08 Thread Jean-Paul Calderone
://docs.python.org/library/socket.html#socket.AF_UNIX Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Idea for removing the GIL...

2011-02-08 Thread Jean-Paul Calderone
ltiple interpreters in a single process. However, you cannot have your cake and eat it too. If you create multiple interpreters, then why do you think you'll be able to share objects between them for free? In what sense would you have *multiple* interpreters in that scenario? You will need some

Re: Idea for removing the GIL...

2011-02-08 Thread Jean-Paul Calderone
On Feb 8, 7:12 pm, Paul Rubin wrote: > But the refcount scheme is just an implementation hack > that gets rationalized way too much.  I hope PyPy abandons it. Done. :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Remove whitespaces and line breaks in a XML file

2011-02-09 Thread Jean-Michel Pichavant
Josh English wrote: I found the code posted at http://infix.se/2007/02/06/gentlemen-indent-your-xml quite helpful in turning my xml into human-readable structures. It works best for XML-Data. Josh It's done in one line with http://docs.python.org/library/xml.dom.minidom.html#xml.dom.mini

Re: Python subprocesses experience mysterious delay in receiving stdin EOF

2011-02-09 Thread Jean-Michel Pichavant
Yang Zhang wrote: On Wed, Feb 9, 2011 at 11:01 AM, MRAB wrote: On 09/02/2011 01:59, Yang Zhang wrote: I reduced a problem I was seeing in my application down into the following test case. In this code, a parent process concurrently spawns 2 (you can spawn more) subprocesses that read a

Re: Shared memory python between two separate shell-launched processes

2011-02-10 Thread Jean-Paul Calderone
from possible bugs where the data gets corrupted by the code that operates on it, since there's only one copy shared amongst all your tests. Is there some other benefit that the shared memory approach gives you? Of course, adding unit tests that exercise your code on a smaller data set migh

Re: Shared memory python between two separate shell-launched processes

2011-02-10 Thread Jean-Paul Calderone
On Feb 10, 12:21 pm, "Charles Fox (Sheffield)" wrote: > On Feb 10, 3:43 pm, Jean-Paul Calderone > wrote: > > > > > > > > > > > On Feb 10, 9:30 am, "Charles Fox (Sheffield)" > > wrote: > > > > Hi guys, > > >

Re: Shared memory python between two separate shell-launched processes

2011-02-11 Thread Jean-Paul Calderone
On Feb 11, 5:52 am, "Charles Fox (Sheffield)" wrote: > On Feb 10, 6:22 pm, Jean-Paul Calderone > wrote: > > > > > > > > > > > On Feb 10, 12:21 pm, "Charles Fox (Sheffield)" > > wrote: > > > > On Feb 10, 3:43 pm,

Re: Class or Dictionary?

2011-02-11 Thread Jean-Michel Pichavant
Martin De Kauwe wrote: Hi, I have a series of parameter values which i need to pass throughout my code (>100), in C I would use a structure for example. However in python it is not clear to me if it would be better to use a dictionary or build a class object? Personally I think accessing the val

Re: How to run another python script?

2011-02-14 Thread Jean-Michel Pichavant
Dan Lee wrote: Hi. I just knew what python is. Now I'm about to write backup script.Now I got 2 scripts. AAA : generate zip file BBB : delete old file. AAA is done. Now I'm going to code BBB file. and I will fix AAA to call BBB to delete dump file at the end. Please let me know How can I call

Re: How to handle sockets - easily?

2011-02-16 Thread Jean-Paul Calderone
le your socket I/O asynchronously; but I don't enough about Python to > get the mixed behavior you'd want. > > I think that there's an asynchronous all-Python MySQL library, but I'm not > sure. Maybe one day I can open source my asynchronous MySQL C library. (I > always recommend people to use PostgreSQL, though; which is superior in > almost every way, especially the C client library and the wire protocol.) There's the very new <https://github.com/hybridlogic/txMySQL>. There's also <http://pypi.python.org/pypi/txpostgres>. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: return an object of a different class

2011-02-17 Thread Jean-Michel Pichavant
s...@uce.gov wrote: How can I do something like this in python: #!/usr/bin/python3.1 class MyNumbers: def __init__(self, n): self.original_value = n if n <= 100: self = SmallNumers(self) else: self = BigNumbers(self) class SmallNumbers: def __init__(self, n): se

Re: return an object of a different class

2011-02-17 Thread Jean-Michel Pichavant
Karim wrote: [snip] If you don't want to use a factory function I believe you can do this: class MyNumber(object): def __new__(cls, n): if n<= 100: cls = SmallNumbers else: cls = BigNumbers return object.__new__(cls, n) ... Chard.

Re: How to use Python well?

2011-02-17 Thread Jean-Michel Pichavant
snorble wrote: I use Python a lot, but not well. I usually start by writing a small script, no classes or modules. Then I add more content to the loops, and repeat. It's a bit of a trial and error learning phase, making sure I'm using the third party modules correctly, and so on. I end up with a

Re: return an object of a different class

2011-02-17 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Thu, 17 Feb 2011 12:02:28 +0100, Jean-Michel Pichavant wrote: Karim wrote: [snip] If you don't want to use a factory function I believe you can do this: class MyNumber(object): def __new__(cls, n): if n<= 100:

Re: reimport module every n seconds

2011-02-17 Thread Jean-Michel Pichavant
Santiago Caracol wrote: Hello, a server program of mine uses data which are compiled to a Python module for efficiency reasons. In some module of the server program I import the data: from data import data As the data often changes, I would like to reimport it every n (e.g. 10) seconds. Unfor

Re: interrupted system call w/ Queue.get

2011-02-18 Thread Jean-Paul Calderone
ends how and why it happens, and whether it prevents your application from working properly. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Making Line Graphs

2011-02-21 Thread Jean-Michel Pichavant
spam head wrote: I'm looking for an easy way to display simple line graphs generated by a python program in Windows. It could be done from within the program, or I could write the information out to a file and call an external program. Either is fine. Does anybody have any recommendations for

Re: return an object of a different class

2011-02-21 Thread Jean-Michel Pichavant
alex23 wrote: Jean-Michel Pichavant wrote: You simply don't return inconsistent types with a return statement. This is a general rule in programming that has probably exceptions but regarding what you're saying, you clearly don't want to do that. I don't think t

Re: return an object of a different class

2011-02-22 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 21 Feb 2011 14:23:10 +0100, Jean-Michel Pichavant wrote: What is not legit, is to return different objects for which the caller has to test the type to know what attributes he can use. Well, I don't know... I'm of two minds. On the one

Re: Python fails on math

2011-02-22 Thread Jean-Michel Pichavant
christian schulze wrote: Hey guys, I just found out, how much Python fails on simple math. I checked a simple equation for a friend. [code] from math import e as e from math import sqrt as sqrt 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) e has no accurate representation in computer science. Nei

Re: pass object or use self.object?

2010-04-06 Thread Jean-Michel Pichavant
Tim Arnold wrote: Hi, I have a few classes that manipulate documents. One is really a process that I use a class for just to bundle a bunch of functions together (and to keep my call signatures the same for each of my manipulator classes). So my question is whether it's bad practice to set thing

Re: Recommend Commercial graphing library

2010-04-06 Thread Jean-Michel Pichavant
Pablo Recio Quijano wrote: Why must be commercial, when there is open and free alternatives? Like GNU Plot. Gnuplot is ugly. I'm using it because I don't care if it's ugly but it clearly lacks of look & feel for presentations, as requested by the OP. You have http://matplotlib.sourceforge.ne

Re: class instance customization

2010-04-19 Thread Jean-Michel Pichavant
Alexander wrote: On 17.04.2010 18:32, Steven D'Aprano wrote: On Sat, 17 Apr 2010 13:09:43 +0400, Alexander wrote: Hi, list. I've some nontrivial class implementation MyClass and its instance my: my = MyClass(args) MyClass uses in internals some variable which is not defined in My

Re: [pylint] why pylint wants only capitals identifiers?

2010-04-19 Thread Jean-Michel Pichavant
Giacomo Boffi wrote: i have this code def example(a): return lambda b: a+b+1 fun = example(10) k_1 = fun(7) ... and pylint tells me [...] C: 4: Invalid name "fun" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$) C: 5: Invalid name "k_1" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$) [...]

Re: [pylint] why pylint wants only capitals identifiers?

2010-04-19 Thread Jean-Michel Pichavant
Giacomo Boffi wrote: Jean-Michel Pichavant writes: Giacomo Boffi wrote: i have this code def example(a): return lambda b: a+b+1 fun = example(10) k_1 = fun(7) ... and pylint tells me [...] C: 4: Invalid name "fun" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$) C:

Re: Code redundancy

2010-04-20 Thread Jean-Michel Pichavant
Alan Harris-Reid wrote: Hi, During my Python (3.1) programming I often find myself having to repeat code such as... class1.attr1 = 1 class1.attr2 = 2 class1.attr3 = 3 class1.attr4 = 4 etc. Is there any way to achieve the same result without having to repeat the class1 prefix? Before Python

Re: Code redundancy

2010-04-21 Thread Jean-Michel Pichavant
Alan Harris-Reid wrote: Jean-Michel Pichavant wrote: Alan Harris-Reid wrote: Hi, During my Python (3.1) programming I often find myself having to repeat code such as... class1.attr1 = 1 class1.attr2 = 2 class1.attr3 = 3 class1.attr4 = 4 etc. Is there any way to achieve the same result

Re: rfind bug ?

2010-04-21 Thread Jean-Michel Pichavant
Stef Mientki wrote: On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? No

Re: [ANN] pyjamas 0.7 released

2010-04-26 Thread Jean-Michel Pichavant
Luke Kenneth Casson Leighton wrote: [snip] Am I the only one getting this error ? easy_install --prefix /home/jeanmichel -m pyjamas Searching for pyjamas Reading http://pypi.python.org/simple/pyjamas/ Reading http://pyjs.org Best match: pyjamas 0.7 Downloading http://pypi.python.org/packag

Re: Advice requested on class design

2010-04-28 Thread Jean-Michel Pichavant
- "Alan Ristow" wrote: > Hi all, > > I am relatively new to Python, though not to programming in general, and > using Python 2.6. I have a design problem that I cannot quite decide how to > handle and I am hoping for some advice. > > I would like to have three classes, ClassA, ClassB,

Re: Remembering the context

2010-04-29 Thread Jean-Michel Pichavant
GZ wrote: Hi All, I am looking at the following code: def fn(): def inner(x): return tbl[x] tbl={1:'A', 2:'B'} f1 = inner # I want to make a frozen copy of the values of tbl in f1 tbl={1:'C', 2:'D'} f2 = inner return (f1,f2) f1,f2 = fn() f1(1) # output C f2

Re: array matching

2010-04-30 Thread Jean-Michel Pichavant
Bill Jordan wrote: Hey guys, I am sorry if this is not the right list to post some questions. I have a simple question please and would appreciate some answers as I am new to Python. I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] I want to arrang this array in different arrays so each on

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Jean-Michel Pichavant
Jabapyth wrote: At least a few times a day I wish python had the following shortcut syntax: vbl.=func(args) this would be equivalent to vbl = vbl.func(args) example: foo = "Hello world" foo.=split(" ") print foo # ['Hello', 'world'] and I guess you could generalize this to vbl.=[some text]

Re: Teaching Programming

2010-05-04 Thread Jean-Michel Pichavant
André wrote: To Samuel Williams:(and other interested ;-) If you want to consider Python in education, I would encourage you have a look at http://www.python.org/community/sigs/current/edu-sig/ I think you will find that there are quite a few resources available - perhaps more than you are

Re: how to import subprocess into my 'subprocess.py' file

2010-05-05 Thread Jean-Michel Pichavant
hiral wrote: Hi, I am doing following in my 'subprocess.py' file... 1 from __future__ import absolute_import 2 from subprocess import * 3 from subprocess import call as myCall 4 from subprocess import Popen as myPopen 5 6 def getProperCmd(cmd): 7 cmd += 'time' # this is just a

Re: importing modules

2010-05-07 Thread Jean-Michel Pichavant
Richard Lamboj wrote: Hello, I have a question about importing python modules. I have modul package, with submodules. So how can a submodul access a modul that is on level upper? Is there something like "import ../../blah"? I don't mean something like this: "import bla.blub.moep" Kind Re

Re: importing modules

2010-05-07 Thread Jean-Michel Pichavant
Richard Lamboj wrote: Am Friday 07 May 2010 13:50:15 schrieb Jean-Michel Pichavant: Richard Lamboj wrote: Hello, I have a question about importing python modules. I have modul package, with submodules. So how can a submodul access a modul that is on level upper? Is there something

Re: unable to get Hudson to run unit tests

2010-05-10 Thread Jean-Michel Pichavant
Stefan Behnel wrote: j vickroy, 07.05.2010 20:44: I apologize if this is not the appropriate forum for a question about Hudson (http://hudson-ci.org/), but I did not know where else to ask and my web searches have not been fruitful. Certainly nice to read something about Hudson in this forum,

Re: idiomatic way to collect and report multiple exceptions?

2010-05-10 Thread Jean-Michel Pichavant
Ben Cohen wrote: Apologies for the TABs -- I wrote that example for demonstration purposes in my mail client -- I'll copy and paste from a real code editor in the future. Ben There's nothing to apologies for. Be wary of those trying to get you out of the right path, they will lie to you st

Re: accessing superclass methods from subclass

2010-05-10 Thread Jean-Michel Pichavant
ben wrote: Ok, thanks for the info. What would be a better way to do this? What I'm trying to do is treat things in a reasonable OOP manner (all fairly new to me, esp. in Python). Here's a made-up example with a little more context. Let's say you're making a drawing program that can draw vari

Re: Kindly show me a better way to do it

2010-05-10 Thread Jean-Michel Pichavant
Oltmans wrote: On May 9, 1:53 am, superpollo wrote: add = lambda a,b: a+b for i in reduce(add,a): print i This is very neat. Thank you. Sounds like magic to me. Can you please explain how does that work? Many thanks again. shorter <> nicer IMO. Those alternatives are intere

Re: INCREF DECREF manually

2010-05-10 Thread Jean-Michel Pichavant
moerchendiser2k3 wrote: Hi, just a small question. Is it possible to change the refcount of a reference manually? For debugging / ... Thanks! moerchendiser2k3 Why don't you just create a global reference to the object ? Unless this one is removed, the object will be kept in memory. JM --

Re: unable to get Hudson to run unit tests

2010-05-10 Thread Jean-Michel Pichavant
j vickroy wrote: Stefan Behnel wrote: j vickroy, 07.05.2010 20:44: I apologize if this is not the appropriate forum for a question about Hudson (http://hudson-ci.org/), but I did not know where else to ask and my web searches have not been fruitful. Certainly nice to read something about Hu

Re: lame sphinx questions [Was: lame epydoc questions]

2010-05-11 Thread Jean-Michel Pichavant
Phlip wrote: On May 10, 1:51 pm, Phlip wrote: On May 10, 1:39 pm, Chris Rebert wrote: Sphinx is in vogue right now:http://sphinx.pocoo.org/ Okay, we have ten thousand classes to document. How to add them all to index.rst? I remember trying using Sphinx for auto documented

Re: how to import a module for global use in a library package ?

2010-05-11 Thread Jean-Michel Pichavant
Auré Gourrier wrote: [snip] My question is the following: I need to import an external package, say numpy, for use in various submodules. So far, I simply do an import numpy as _numpy where needed, say sub1module1 and sub2module2. This means that I import this package a number of times which d

Re: lame sphinx questions [Was: lame epydoc questions]

2010-05-11 Thread Jean-Michel Pichavant
Phlip wrote: On May 11, 3:54 am, Jean-Michel Pichavant wrote: I remember trying using Sphinx for auto documented APIs, but it was not suitable at that time. You can include API docs generated from the code, but you still need to write the docs around. If I'm correct, Sphinx is one o

Re: how to import a module for global use in a library package ?

2010-05-12 Thread Jean-Michel Pichavant
Terry Reedy wrote: On 5/11/2010 8:04 AM, Auré Gourrier wrote: I might make one submodule for imports and then do 'from rootlib.util import importmod as m' in the template. But I have no need now for such. Terry Jan Reedy We did that, and we so regret it. After 5 years of intensive dev on tha

Re: How to add callbacks that is the same function with different argument in Tkinter python26?

2010-05-12 Thread Jean-Michel Pichavant
chen zeguang wrote: code is in the end. I want to print different number when pressing different button. Yet the program outputs 8 no matter which button is pressed. I guess it's because the callback function is not established untill the button is pressed, and i has already reached to 8. then

Re: launching vi/vim from console

2010-05-24 Thread Jean-Michel Pichavant
adm wrote: I am newbie to python. Is there a way to launch vi/vim or any other editor from python console? I find editing in console very limiting. I can either have a console which launches vi and remembers it's content and then executes or invoke python interpreter from vim. Since I could not

Re: Email in 2.6.4

2010-05-24 Thread Jean-Michel Pichavant
dirknbr wrote: I am trying to run from email.mime.text import MIMEText but I get an ImportError: No module named mime.text Since email was pre-installed how do I fix this? Dirk Did you make sure you didn't hide the standard email module by one of your own. Check print email.__file__ /us

Re: Email in 2.6.4

2010-05-24 Thread Jean-Michel Pichavant
dirknbr wrote: I have now easy_installled email and I still get errors. It doesn't error on 'import email' but does on call to MimeText. import email msg = MIMEText('test') NameError: name 'MIMEText' is not defined What should I do? Using easy_install will not prevent the standard lib to b

Re: function that counts...

2010-05-24 Thread Jean-Michel Pichavant
Jerry Hill wrote: On Wed, May 19, 2010 at 3:58 PM, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: ... any suggestion for pythonizin' it? This is how I would do it: def prttn(m, n): """How many positive integers less than n hav

Re: Email in 2.6.4

2010-05-24 Thread Jean-Michel Pichavant
Dirk Nachbar wrote: Sorry guys, I had named my file email.py and hence the error. On 24 May 2010 15:22, Jean-Michel Pichavant <mailto:jeanmic...@sequans.com>> wrote: dirknbr wrote: I have now easy_installled email and I still get errors. It doesn't er

Re: function that counts...

2010-05-25 Thread Jean-Michel Pichavant
superpollo wrote: Jean-Michel Pichavant ha scritto: Jerry Hill wrote: On Wed, May 19, 2010 at 3:58 PM, superpollo wrote: ... how many positive integers less than n have digits that sum up to m: ... any suggestion for pythonizin' it? This is how I would do it: def pr

Re: if, continuation and indentation

2010-05-27 Thread Jean-Michel Pichavant
HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, r

Re: if, continuation and indentation

2010-05-27 Thread Jean-Michel Pichavant
MRAB wrote: HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit co

Re: if, continuation and indentation

2010-05-28 Thread Jean-Michel Pichavant
Jonathan Hartley wrote: On May 27, 1:57 pm, Jean-Michel Pichavant wrote: HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions

Re: Problems with relative imports and pep 366

2010-06-01 Thread Jean-Michel Pichavant
Gabriele Lanaro wrote: I've yet asked this question on SO, I'll copy the contents: I have a "canonical file structure" like that (I'm giving sensible names to ease the reading): mainpack/ __main__.py __init__.py - helpers/ __init__.py path.py - network/ __init__.py

Re: plac, the easiest command line arguments parser in the world

2010-06-02 Thread Jean-Michel Pichavant
Michele Simionato wrote: I would like to announce to the world the first public release of plac: http://pypi.python.org/pypi/plac Plac is a wrapper over argparse and works in all versions of Python starting from Python 2.3 up to Python 3.1. With blatant immodesty, plac claims to be the easie

Re: How to run a python script with a configuration file at command line ?

2010-06-03 Thread Jean-Michel Pichavant
Andreas Jung wrote: optparse is your friend. -aj 2010/6/3 steph_awk > I have been searching for quite some times without success. I have a python script that needs to start from command line and it should have a config file to fill out the

Re: great

2010-06-04 Thread Jean-Michel Pichavant
joblack wrote: Great - it works. Thanks a lot. Thread of the week :) JM -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing DLL in win98

2010-06-07 Thread Jean-Michel Pichavant
Spyder42 wrote: On Fri, 04 Jun 2010 14:03:48 -0400, Terry Reedy wrote: On 6/4/2010 9:08 AM, Spyder42 wrote: On Fri, 04 Jun 2010 14:50:28 +0200, Christian Heimes Python 2.6 is not supported on Windows 98 and earlier. You need at least Windows 2000 with a recent service pack. C

Python + vim + spaces vs tab

2010-06-07 Thread Jean-Michel Pichavant
Hello, Does anyone knows a way to configure vim so it automatically select to correct expandtab value depending on the current buffer 'way of doing' ? I need to edit different files, some are using spaces, others tabs. Those belong to different projects, and changing all spaces to tabs is not

Re: optparse: best way

2010-06-08 Thread Jean-Michel Pichavant
hiral wrote: Hi, I am using optparser to do following... Command syntax: myscript -o[exension] other_arguments where; extension can be 'exe', 'txt', 'pdf', 'ppt' etc. Now to parse this, I am doing following... parser.add_option("-oexe', dest=exe_file...) parser.add_option("-otxt', dest=t

Re: assign class variable in __init__

2010-06-08 Thread Jean-Michel Pichavant
Peter Otten wrote: Jason Scheirer wrote: On Jun 8, 9:37 am, Peter Otten <__pete...@web.de> wrote: Ross Williamson wrote: Hi Everyone, Just a quick question - Is it possible to assign class variables in the __init__() - i.e. somthing like: def __init__(self,se

Re: optparse: best way

2010-06-09 Thread Jean-Michel Pichavant
hiral wrote: On Jun 8, 3:03 pm, Jean-Michel Pichavant wrote: hiralwrote: Hi, I am using optparser to do following... Command syntax: myscript -o[exension] other_arguments where; extension can be 'exe', 'txt', 'pdf', 'ppt' e

Re: Python + vim + spaces vs tab

2010-06-09 Thread Jean-Michel Pichavant
Robin Becker wrote: On 07/06/2010 22:18, Hans Mulder wrote: Jean-Michel Pichavant wrote: Hello, Does anyone knows a way to configure vim so it automatically select to correct expandtab value depending on the current buffer 'way of doing' ? I need to edit different files, some

Re: GUIs - A Modest Proposal

2010-06-09 Thread Jean-Michel Pichavant
ant wrote: Most of those don't use a GUI. But whenever I write a program that someone else is going to use, it has to have a GUI. Is that not true for most people? In the industry, most of the people knows how to use a comand line. In my company, 99% of the applications written in p

Re: if, continuation and indentation

2010-06-09 Thread Jean-Michel Pichavant
Pete Forman wrote: HH writes: > I have a question about best practices when it comes to line > wrapping/ continuation and indentation, specifically in the case of > an if statement. There are several good suggestions for formatting but no-one has mentioned rewriting the code. Use a boolean

Re: regarding the dimensions in gui

2010-06-10 Thread Jean-Michel Pichavant
Chris Rebert wrote: On Thu, Jun 10, 2010 at 1:27 AM, Andreas Waldenburger wrote: On Thu, 10 Jun 2010 08:37:21 +0100 Simon Brunning wrote: On 10 June 2010 08:19, Shashwat Anand wrote: And please stop using 'sir' for heaven's sake. Not least because list list isn't ma

Re: passing environment variable path to open command

2010-06-11 Thread Jean-Michel Pichavant
Mahmood Naderan wrote: Hi, I am new to python so my question may be very basic. Suppose I have a file (sc_1.sh) which the path to that file is in system path: SOMETHING=/home/mahmood/scripts Now I want to open that file with respect to the environment variable: import os env = os.g

Re: GUIs - A Modest Proposal

2010-06-11 Thread Jean-Michel Pichavant
Andreas Waldenburger wrote: On Thu, 10 Jun 2010 23:00:37 -0700 (PDT) rantingrick wrote: On Jun 11, 12:17 am, ant wrote: I like the points about backwards compatibility. Presumably that reason alone is enough to keep Tkinter in the standard library for a long while. I don't se

Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-14 Thread Jean-Michel Pichavant
Andrew Philpot wrote: On 06/11/10 08:48, Elena wrote: On 10 Giu, 23:33, bolega wrote: I mean ordinary people, who may want to do things with their computers for scripting, tasks that python can do... Lisp is not for ordinary people, Python is. Python is for ordinary people. Lisp is for ext

Re: Good solutions for passing around large numbers of arguments in a layered architecture?

2010-06-14 Thread Jean-Michel Pichavant
Nathan Rice wrote: I've been running into a problem lately where I have an architecture like so: Main class -> facade/configuration class -> low level logic class. The main class is what the user interacts with. The facade/config class is responsible for loading and managing the lower level cl

<    12   13   14   15   16   17   18   19   20   >