Re: building a web interface

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

regexp matching end of line or comma

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

Re: regexp matching end of line or comma

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

Re: How do I get the URL of the active tab in Firefox/IE/Chrome?

2010-11-28 Thread Michel Claveau - MVP
;): print instance," URL :",instance.LocationURL @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Change one list item in place

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

Re: Change one list item in place

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

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

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

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

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

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

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

is id(self) constant over an object lifetime ?

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

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

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

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

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

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

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

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

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

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

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

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

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

Re: class browser

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

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

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

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

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

Re: run a function in another processor in python

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

Re: Proposed changes to logging defaults

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

Re: printing error message from an Exception

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

Re: Python critique

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

Re: decouple copy of a list

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

Re: decouple copy of a list

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

Re: Proposed changes to logging defaults

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

Re: Python critique

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

Re: default argument in method

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

Re: while True or while 1

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

string identity and comparison

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

Re: string identity and comparison

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

Re: string identity and comparison

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

Re: string identity and comparison

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

Re: If/then style question

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

Re: If/then style question

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

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

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

Re: Convert arbitrary function inputs to string

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

Re: Rewriting __getattr__

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

Re: Rewriting __getattr__

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

Re: Rewriting __getattr__

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

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: Printing RTF file under win32

2011-01-21 Thread Michel Claveau - MVP
Hi! Try this line: "C:\Program Files\Windows NT\Accessories\wordpad.exe" /p D:\data\fil.rtf (change the path if you have a windows 64 bits) @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

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: 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: 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: 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: 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: Python 32-bit on Windows 64-bit

2011-02-11 Thread Michel Claveau - MVP
Hi! Python 32 bits (& Pywin32) limits are: 2 GB on win.7_32 bits 4 GB on win.7_64 bits That's what I found in my tests. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

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: 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: 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: Pickle compatibility between Python 2.7 and python 3.2

2011-02-22 Thread Michel Claveau - MVP
Hi! I am, also, very interested in the answers. Thank you for asking this question. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

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: Download Visual Studio Express 2008 now

2010-04-13 Thread Michel Claveau - MVP
Hi! Thanks for this idea. Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

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: DLLs loading in interpreter but not with direct run on Windows

2010-04-24 Thread Michel Claveau - MVP
Hi! AMHA (IMO), it is PyQT4 who change the DLL loader... @+ -- MCI -- http://mail.python.org/mailman/listinfo/python-list

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: Default if none

2010-04-29 Thread Michel Claveau - MVP
Hi! > print x or y or z > If none of the potential values are considered boolean false But : a=None b=False c=None print a or b or c > None @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Default if none

2010-04-29 Thread Michel Claveau - MVP
Re! Look also : >>> print False or None None >>> print None or False False -- MCI -- http://mail.python.org/mailman/listinfo/python-list

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,

<    4   5   6   7   8   9   10   11   12   13   >