Re: PythonWin debugger holds onto global logging objects too long

2012-02-07 Thread Jean-Michel Pichavant
Vinay Sajip wrote: On Jan 24, 2:52 pm, Rob Richardson wrote: I use PythonWin to debug the Python scripts we write. Our scripts often use the log2pyloggingpackage. When running the scripts inside the debugger, we seem to get oneloggingobject for every time we run the script. The result i

Re: ANN: Sarge, a library wrapping the subprocess module, has been released.

2012-02-17 Thread Jean-Michel Pichavant
Vinay Sajip wrote: Sarge, a cross-platform library which wraps the subprocess module in the standard library, has been released. What does it do? Sarge tries to make interfacing with external programs from your Python applications easier than just using subprocess alone. Sarge

Re: logging with logging.config.fileConfig

2012-02-20 Thread Jean-Michel Pichavant
MRAB wrote: On 19/02/2012 20:23, Herman wrote: I tried to use file to config my logger and I got a weird situation that each message is outputted twice... Here is my scenario: python: 2.6 file abc_logging.conf: [snip] [logger_abc] level=DEBUG handlers=consoleHandler qualname=abc Add this l

Re: [OT]: Smartphones and Python?

2012-02-20 Thread Jean-Michel Pichavant
Michael Torrie wrote: I do not understand what you are saying, or at least why you are saying this. But I don't understand most of your posts. It's a bot. Add it to your kill file. JM -- http://mail.python.org/mailman/listinfo/python-list

Re: HTTP logging

2012-02-20 Thread Jean-Michel Pichavant
Arnaud Delobelle wrote: On 20 February 2012 16:03, Jason Friedman wrote: I am logging to HTTP: logger.addHandler(logging.handlers.HTTPHandler(host, url)) Works great, except if my HTTP server happens to be unavailable: socket.error: [Errno 111] Connection refused Other than wrapping all

Re: Reset static variables or a workaround

2012-02-23 Thread Jean-Michel Pichavant
Nav wrote: Hi Guys, I have a custom user form class, it inherits my own custom Form class: class UserForm(Form): first_name = TextField(attributes={id='id_firstname'}) Now, everytime UserForm() is instantiated it saves the attributes of each form members and passes it on to the new instanc

Re: storing in list and retrieving.

2012-02-23 Thread Jean-Michel Pichavant
Smiley 4321 wrote: It requires concepts of 'python persistence' for the code to be designed . Else it simple. Looking for some flow?? Hi, Have a look at http://docs.python.org/library/pickle.html Cheers, JM -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace question

2012-02-24 Thread Jean-Michel Pichavant
xixiliguo wrote: c = [1, 2, 3, 4, 5] class TEST(): c = [5, 2, 3, 4, 5] def add( self ): c[0] = 15 a = TEST() a.add() print( c, a.c, TEST.c ) result : [15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5] why a.add() do not update c in Class TEST? but update c in main file A

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-27 Thread Jean-Michel Pichavant
Rick Johnson wrote: On Feb 25, 11:54 am, MRAB wrote: [...] That should be: if maxlength is not None and len(string) <= maxlength: Using "imaginary" infinity values defiles the intuitive nature of your code. What is more intuitive? def confine_length(string, maxlength=INFINITY): i

Re: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3

2012-02-27 Thread Jean-Michel Pichavant
Ben Finney wrote: Chris Angelico writes: On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: If you're pleased to announce their immediate availability, then please do that! Isn't it perfectly accurate to say that the RCs are now available? Yes. What's not reasonab

Re: Question about circular imports

2012-02-27 Thread Jean-Michel Pichavant
Frank Millman wrote: Hi all I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. Let me say at the outset that I don't think I can get rid of circular imports altogether. It is not uncommon for me to find that a method in Module A needs to ac

Re: exec

2012-03-01 Thread Jean-Michel Pichavant
Rolf Wester wrote: Hi, I would like to define methods using exec like this: class A: def __init__(self): cmd = "def sqr(self, x):\nreturn x**2\nself.sqr = sqr\n" exec cmd a = A() print a.sqr(a, 2) This works, but I have to call sqr with a.sqr(a, 2), a.sqr(2) does not wo

Re: RotatingFileHandler Fails

2012-03-05 Thread Jean-Michel Pichavant
nac wrote: The RotatingFileHandler running on win 7 64-bit; py 2.7 is failing when the script launches a process using subprocess.Popen. Works fine if the subprocess is not launched The exception thrown Traceback (most recent call last): File "C:\Python27\lib\logging\handlers.py", line 78, in

Re: Trying to understand 'import' a bit better

2012-03-05 Thread Jean-Michel Pichavant
Frank Millman wrote: Hi all I have been using 'import' for ages without particularly thinking about it - it just works. Now I am having to think about it a bit harder, and I realise it is a bit more complicated than I had realised - not *that* complicated, but there are some subtleties. I

Re: AttributeError: 'module' object has no attribute 'logger'

2012-03-05 Thread Jean-Michel Pichavant
youssef.mah...@hotmail.com wrote: hi all, when installing sage, there is a problem with emacs.py so, this screen appeared after rynning ./sage -- | Sage Version 4.4.2, Release Date: 2010-05-19 | | Type noteb

Re: Raise X or Raise X()?

2012-03-12 Thread Jean-Michel Pichavant
bvdp wrote: Which is preferred in a raise: X or X()? I've seen both. In my specific case I'm dumping out of a deep loop: try: for ... for ... for ... if match: raise StopInteration() else ... except StopInteration: print "found it" I prefer the r

Re: How to break long method name into more than one line?

2012-03-13 Thread Jean-Michel Pichavant
Chris Angelico wrote: Just never treat them as laws of physics (in Soviet Physics, rules break you!). ChrisA hum ... I wonder how this political message is relevant to the OP problem. JM -- http://mail.python.org/mailman/listinfo/python-list

Re: Python classes: Simplify?

2012-03-23 Thread Jean-Michel Pichavant
Steven Lehar wrote: It seems to me that the Python class system is needlessly confusing. Am I missing something? For example in the class Complex given in the documentation *class Complex:* *def __init__(self, realpart, imagpart):* *self.r = realpart* *self.i = imagpart* *

Re: Stream programming

2012-03-26 Thread Jean-Michel Pichavant
Kiuhnm wrote: [snip] numbers - push - avrg - 'med' - pop - filter(lt('med'), ge('med'))\ - ['same', 'same'] - streams(cat) - 'same' It reads as "take a list of numbers - save it - compute the average and named it 'med' - restore the flow - create two streams which have, respect., the num

Re: How to decide if a object is instancemethod?

2012-03-26 Thread Jean-Michel Pichavant
Jon Clements wrote: On Wednesday, 14 March 2012 13:28:58 UTC, Cosmia Luna wrote: class Foo(object): def bar(self): return 'Something' func = Foo().bar if type(func) == : # This should be always true pass # do something here What should type at ? Thanks Cosmia impor

Re: verbs in comments [OT]

2012-03-26 Thread Jean-Michel Pichavant
Kiuhnm wrote: Why do you write // Print the number of words... def printNumWords(): ... and not // Prints the number of words... def printNumWords(): ... where "it" is understood? Is that an imperative or a base form or something else? Kiuhnm http://www.python.org/dev/peps/pep-0257/ "

Re: help needed to understand an error message.

2012-03-26 Thread Jean-Michel Pichavant
Aloke Ghosh wrote: Hi, I am learning Python and do not have programming experience. I was following an exercise from http://learnpythonthehardway.org/book/ex2.html and made a mistake in entry : *Print"I like typing this."* and got the following error message: *In [2]: Print"I like typing t

Re: I look for a package to make some simple console "form"

2012-04-02 Thread Jean-Michel Pichavant
Stéphane Klein wrote: Hi, I look for a package to make some console "form". It's a standard stuff, I think there are a package to do that. Example : What is your name ? Select your lang [EN, FR, DE…] ? Do you want … [Y, N] ? Type of field : * textline * select choice * boolean question Tha

Re: Pythonect 0.1.0 Release

2012-04-02 Thread Jean-Michel Pichavant
Itzik Kotler wrote: Hi All, I'm pleased to announce the first beta release of Pythonect interpreter. Pythonect is a new, experimental, general-purpose dataflow programming language based on Python. It aims to combine the intuitive feel of shell scripting (and all of its perks like implicit

Re: I look for a package to make some simple console "form"

2012-04-02 Thread Jean-Michel Pichavant
Stéphane Klein wrote: Le 02/04/2012 15:54, Jean-Michel Pichavant a écrit : Stéphane Klein wrote: Hi, I look for a package to make some console "form". It's a standard stuff, I think there are a package to do that. Example : What is your name ? Select your lang [EN, FR, DE…

Re: weird behaviour: pygame plays in shell but not in script

2012-04-03 Thread Jean-Michel Pichavant
Mik wrote: Oh thanks alex! that's kind! PS: It looks like a party indeed: plenty of interesting discussions :-) On Mar 30, 4:33 am, alex23 wrote: On Mar 29, 10:41 pm, Mik wrote: What a nice way to introduce myself to the group!!! :-) Hey, don't beat yourself up, you: - su

Re: is this foolish?

2012-04-12 Thread Jean-Michel Pichavant
Cameron Simpson wrote: I've found myself using a Python gotcha as a feature. I've got a budding mail filter program which keeps rule state in a little class instance. Slightly paraphrased: class RuleState(object): def __init__(self, M, maildb_path, maildirs={}): [...]

Re: remainder of dividing by zero

2012-04-13 Thread Jean-Michel Pichavant
Ethan Furman wrote: Okay, so I haven't asked a stupid question in a long time and I'm suffering withdrawal symptoms... ;) 5 % 0 = ? It seems to me that the answer should be 5: no matter how many times we add 0 to itself, the remainder of the intermediate step will be 5. Is there a postulate

Re: Naming future objects and their methods

2012-04-16 Thread Jean-Michel Pichavant
Stefan Schwarzer wrote: Hello, I wrote a `Connection` class that can be found at [1]. A `Connection` object has a method `put_bytes(data)` which returns a "future" [2]. The data will be sent asynchronously by a thread attached to the connection object. The future object returned by `put_bytes`

Re: [newbie questions] if conditions - if isset - if empty

2012-04-16 Thread Jean-Michel Pichavant
Mahmoud Abdel-Fattah wrote: Hello, I'm coming from PHP background ant totally new to Python, I just started using scrapy, but has some generic question in python. 1. How can I write the following code in easier way in Python ? if len(item['description']) > 0: item['description'] =

Re: logging.config.fileConfig FileHandler configure to write to APP_DATA

2012-04-17 Thread Jean-Michel Pichavant
Jeffrey Britton wrote: I figured out what I was after. logfn = os.path.join(os.environ['APPDATA'], directory, filename) ensure_path(logfn) logging.config.fileConfig("logging.conf", defaults={'logfn': logfn}) In the config file use: [handler_fileHandler] class=FileHandler level=DEBUG formatter=s

Re: logging.config.fileConfig FileHandler configure to write to APP_DATA

2012-04-18 Thread Jean-Michel Pichavant
Jeffrey Britton wrote: Hi, An alternative is to subclass FileHandler with a handler customized for your app. class AppFileHandler(FileHandler): def __init__(filename): if not os.path.isabs(filename): filename = os.path.join(os.environ['APPDATA'], 'whateverdir', filename) Fil

Re: A case for "real" multiline comments

2012-04-19 Thread Jean-Michel Pichavant
Chris Angelico wrote: [snip] Since Python doesn't have multiline comments, triple-quoted strings are sometimes pressed into service. [snip] Chris Angelico Let the triple quotes where they're meant to be. Use your text editor, any decent one will allow you to comment uncomment a block of cod

Re: How do you refer to an iterator in docs?

2012-04-20 Thread Jean-Michel Pichavant
Jon Clements wrote: On Thursday, 19 April 2012 13:21:20 UTC+1, Roy Smith wrote: Let's say I have a function which takes a list of words. I might write the docstring for it something like: def foo(words): "Foo-ify words (which must be a list)" What if I want words to be the more genera

Re: Newbie, homework help, please.

2012-04-23 Thread Jean-Michel Pichavant
someone wrote: I have a professor who should be [*snip*] the best person I've ever met I hope he's (not) reading this list :o) Non python advise : be very careful on the internet. JM -- http://mail.python.org/mailman/listinfo/python-list

Re: Same code cause the different result.

2012-04-25 Thread Jean-Michel Pichavant
叶佑群 wrote: Hi, all I have code as: /pobj = subprocess.Popen (["smbpasswd", user], stdin =subprocess.PIPE) password += "\n" pobj.stdin.write (password) pobj.stdin.write (password)/ the command smbpasswd will change the samba user's passwor

Re: try/except in a loop

2012-05-03 Thread Jean-Michel Pichavant
Chris Kaynor wrote: On Wed, May 2, 2012 at 12:51 PM, J. Mwebaze wrote: I have multiple objects, where any of them can serve my purpose.. However some objects might not have some dependencies. I can not tell before hand if the all the dependencies exsit. What i want to is begin processing fro

Re: try/except in a loop

2012-05-03 Thread Jean-Michel Pichavant
Peter Otten wrote: Jean-Michel Pichavant wrote: Chris Kaynor wrote: On Wed, May 2, 2012 at 12:51 PM, J. Mwebaze wrote: I have multiple objects, where any of them can serve my purpose.. However some objects might not have some dependencies. I can not tell before hand if the

Re: docstrings for data fields

2012-05-03 Thread Jean-Michel Pichavant
Ulrich Eckhardt wrote: Hi! My class Foo exports a constant, accessible as Foo.MAX_VALUE. Now, with functions I would simply add a docstring explaining the meaning of this, but how do I do that for a non-function member? Note also that ideally, this constant wouldn't show up inside instances of t

Re: Is Python Lazy?

2012-05-09 Thread Jean-Michel Pichavant
Emeka wrote: Hello All, Could one say that generator expressions and functions are Python way of introducing Lazy concept? Regards, \Emeka -- /Satajanus Nig. Ltd / No. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with how to combine two csv files

2012-05-09 Thread Jean-Michel Pichavant
Sammy Danso wrote: Hello Experts, I am new to python and I have been trying to merge two csv files, and upon several hours of unsuccessful attempts, I have decided to seek for help. the format of the file is as follows. file A has columns a, b, c and values 1,2,3 for several rows. File B al

Re: How to get outer class name from an inner class?

2012-05-09 Thread Jean-Michel Pichavant
John Gordon wrote: I'm trying to come up with a scheme for organizing exceptions in my application. Currently, I'm using a base class which knows how to look up the text of a specific error in a database table, keyed on the error class name. The base class looks like this: class ApplicationExc

Re: Communication between C++ server and Python app

2012-05-09 Thread Jean-Michel Pichavant
kenk wrote: Hi, I've got a server process written in C++ running on Unix machine. On the same box I'd like to run multiple Python scripts that will communicate with this server. Can you please suggest what would be best was to achieve this ? Kind regards and thanks in advance! M. xmlrpc sh

Re: __doc__+= """Detailed description"""

2012-05-10 Thread Jean-Michel Pichavant
Pierre Asselin wrote: Hi. Started using python a few months back, still settling on my style. I write docstrings and I use "pydoc mymodule" to refresh my memory. Problem: if I just docstring my classes/methods/functions the output of pydoc more or less works as a reference manual, but if I get

Re: Dealing with the __str__ method in classes with lots of attributes

2012-05-11 Thread Jean-Michel Pichavant
Mark Lawrence wrote: On 11/05/2012 15:32, Andreas Tawn wrote: It's also helpful to not have to display every attribute, of which there may be dozens. Do I detect a code smell here? I think so, Murphy's law dictates that the attribute you're interested in will not be displayed anyway. JM -

Re: Remove root handler from logger

2012-05-14 Thread Jean-Michel Pichavant
Florian Lindner wrote: Hello, I configure my logging on application startup like that: logging.basicConfig(level = logging.DEBUG, format=FORMAT, filename = logfile) ch = logging.StreamHandler() ch.setFormatter(logging.Formatter(FORMAT)) logging.getLogger().addHandler(ch) In one module of my a

Re: Extracting DB schema (newbie Q)

2012-05-14 Thread Jean-Michel Pichavant
Steve Sawyer wrote: Brand-new to Python (that's a warning, folks) Trying to write a routine to import a CSV file into a SQL Server table. To ensure that I convert the data from the CSV appropriately, I"m executing a query that gives me the schema (data column names, data types and sizes) from th

Re: Newby Python Programming Question

2012-05-15 Thread Jean-Michel Pichavant
Coyote wrote: CM writes: I don't know Spyder IDE, but I don't think this should happen; could there just be a simple mistake? Because you first refer to the .py file as 'file_utils.py' but then you refer to the file as 'pwd.py'...which is also the name of your function. Room for confusion..

Re: Sharing Data in Python

2012-05-15 Thread Jean-Michel Pichavant
raunakgu...@gmail.com wrote: I have some Pickled data, which is stored on disk, and it is about 100 MB in size. When my python program is executed, the picked data is loaded using the cPickle module, and all that works fine. If I execute the python multiple times using python main.py for exam

Re: Unexpected exception thrown in __del__

2012-05-22 Thread Jean-Michel Pichavant
Charles Hixson wrote: On 05/21/2012 08:29 AM, Charles Hixson wrote: message excerpt: flush: sql = insert or replace into persists (id, name, data, rdCnt, rdTim, wrCnt, wrTim, deprecation) values (?, ?, ?, ?, ?, ?, ?, ?) Exception TypeError: "'NoneType' object is not callable" in method Shelve2

Re: Advantages of logging vs. print()

2012-05-22 Thread Jean-Michel Pichavant
Giampaolo Rodolà wrote: Hi all, I'm currently working on 1.0.0 release of pyftpdlib module. This new release will introduce some backward incompatible changes in that certain APIs will no longer accept bytes but unicode. While I'm at it, as part of this breackage I was contemplating the possibili

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-22 Thread Jean-Michel Pichavant
Fayaz Yusuf Khan wrote: ***TRIVIAL ISSUE***, but this has been irking me for a while now. The main logging.Handler class' __init__ accepts a level argument while none of its children do. The poor minions seem to be stuck with the setLevel method which considerably lengthens the code. In short

Re: Please use the Python Job Board for recruiting

2012-05-23 Thread Jean-Michel Pichavant
Dan Stromberg wrote: On Tue, May 22, 2012 at 3:20 PM, Ben Finney mailto:ben+pyt...@benfinney.id.au>> wrote: Python Recruiter mailto:ro...@omniumit.com>> writes: > Can any one help? I am looking for a Senior Python Developer Yes, please use the Python Job Board for this purpo

Re: append method

2012-05-23 Thread Jean-Michel Pichavant
wrote: >>> s=[1,2,3] >>> s.append(5) >>> s [1, 2, 3, 5] >>> s=s.append(5) >>> s >>> print s None why can't s=s.append(5) ,what is the reason? Because the append method returns None, not the object. It modifies the object in place, and does not create any copy. You can still write s

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Jean-Michel Pichavant
Fayaz Yusuf Khan wrote: Jean-Michel Pichavant wrote: Meanwhile you can shorten the code this way: root.addHandler(FileHandler('debug.log')) root.handlers[-1].setLevel(DEBUG) Eh? Readability was the aim. I fail to see how it's not readable, code is short and no mag

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Jean-Michel Pichavant
Peter Otten wrote: Jean-Michel Pichavant wrote: Fayaz Yusuf Khan wrote: Jean-Michel Pichavant wrote: Meanwhile you can shorten the code this way: root.addHandler(FileHandler('debug.log')) root.handlers[-1].setLevel(DEBUG) Eh? Readability w

Re: Scoping Issues

2012-05-25 Thread Jean-Michel Pichavant
Andrew Berg wrote: On 5/24/2012 8:59 PM, Dave Angel wrote: so I fixed that, and got inconsistent use of tabs and spaces in indentation because you mistakenly used tabs for indentation. Not to start another tabs-vs.-spaces discussion, Too late, the seeds of war have been planted

Re: setup(**config); rookie

2012-05-28 Thread Jean-Michel Pichavant
cate wrote: I going thru a 101 and came upon this (http:// learnpythonthehardway.org/book/ex46.html) try: from setuptools import setup except ImportError: from distutils.core import setup config = { 'description': 'My Project', 'author': 'My Name', 'url': 'URL to get it at.'

Re: Functions vs OOP

2011-09-05 Thread Jean-Michel Pichavant
William Gill wrote: Not to split hairs, but syntactically f(x) is a function in many programming paradigms. As I understand it functional programming places specific requirements on functions, i.e.referential transparency. So f(x) may or may not be "functional". x.f() is also a function,

Re: Python encoding question

2011-02-25 Thread Jean-Michel Pichavant
Marc Muehlfeld wrote: Hi, I'm doing my first steps with python and I have a problem with understanding an encoding problem I have. My script: import os os.environ["NLS_LANG"] = "German_Germany.UTF8" import cx_Oracle connection = cx_Oracle.Connection("username/password@SID") cursor = connectio

Re: subclass urllib2

2011-03-01 Thread Jean-Michel Pichavant
monkeys paw wrote: I'm trying to subclass urllib2 in order to mask the version attribute. Here's what i'm using: import urllib2 class myURL(urllib2): def __init__(self): urllib2.__init__(self) self.version = 'firefox' I get this> Traceback (most recent call last): File ""

Re: how to properly pass literal strings python code to be executed using python -c

2011-03-01 Thread Jean-Michel Pichavant
jmoons wrote: I need some help figuring out how to execute this python code from python -c I am have trouble formatting python so that it will execute for another app in cmd I understand there maybe other ways to do what I am doing but I am limited by the final execution using cmd python -c so pl

Re: Checking against NULL will be eliminated?

2011-03-03 Thread Jean-Michel Pichavant
Steven Howe wrote: If an item is None: if ( type(x) == types.NoneType ): Bye the way, the beauty of python is that "If an item is None" translates into "If item is None". JM -- http://mail.python.org/mailman/listinfo/python-list

Re: question about endswith()

2011-03-04 Thread Jean-Michel Pichavant
Matt Funk wrote: Hi Grant, first of all sorry for the many typos in my previous email. To clarify, I have a python list full of file names called 'files'. Every single filename has extension='.hdf' except for one file which has an '.hdf5' extension. When i do (and yes, this is pasted): f

Re: questions about multiprocessing

2011-03-07 Thread Jean-Michel Pichavant
Vincent Ren wrote: Hello, everyone, recently I am trying to learn python's multiprocessing, but I got confused as a beginner. [SNIP] httplib.InvalidURL: nonnumeric port: '' Regards Vincent It's a mistake many beginners do, I don't understand why, but it's a very common thing. RTFM should

Re: changing to function what works like a function

2011-03-07 Thread Jean-Michel Pichavant
Victor Paraschiv wrote: Well, thank you all for being honest ☺ What I conclude is that you, the programmers, don’t really care about those who are new to programming: for most people out of the programming world, I think it is simpler to be able to write: real(z), just as you write: sin(z

python cmd.Cmd auto complete feature

2011-03-08 Thread Jean-Michel Pichavant
Hello folks, I'm trying to autoexpand values as well as arguments using the builtin cmd.Cmd class. I.E. Consider the following command and arguments: > sayHello target=Georges 'Hello Georges !' I can easily make 'tar' expand into 'target=' however I'd like to be able to expand the value as

Re: python cmd.Cmd auto complete feature

2011-03-09 Thread Jean-Michel Pichavant
Peter Otten wrote: Jean-Michel Pichavant wrote: I'm trying to autoexpand values as well as arguments using the builtin cmd.Cmd class. I.E. Consider the following command and arguments: > sayHello target=Georges 'Hello Georges !' I can easily make 'tar' expan

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread Jean-Michel Pichavant
bukzor wrote: We've been doing a fair amount of Python scripting, and now we have a directory with almost a hundred loosely related scripts. It's obviously time to organize this, but there's a problem. These scripts import freely from each other and although code reuse is generally a good thing

Re: Compile time evaluation of dictionaries

2011-03-14 Thread Jean-Michel Pichavant
Gerald Britton wrote: Today I noticed that an expression like this: "one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two": "can be as bad as one"} could be evaluated at compile time, but is not: dis(compile( ... '"one:%(one)s two:%(two)s" % {"one": "is the lonelies

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: The removal of cmp from the sort method of lists is probably the most disliked change in Python 3. On the python-dev mailing list at the moment, Guido is considering whether or not it was a mistake. If anyone has any use-cases for sorting with a comparison function that

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 14 Mar 2011 12:10:27 +0100, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: The removal of cmp from the sort method of lists is probably the most disliked change in Python 3. On the python-dev mailing list at the moment, Guido is consideri

Re: argparse, tell if arg was defaulted

2011-03-15 Thread Jean-Michel Pichavant
Neal Becker wrote: Robert Kern wrote: On 3/15/11 9:54 AM, Neal Becker wrote: Is there any way to tell if an arg value was defaulted vs. set on command line? No. If you need to determine that, don't set a default value in the add_argument() method. Then just check for None and r

Re: Bounds checking

2011-03-18 Thread Jean-Michel Pichavant
Martin De Kauwe wrote: Hi, if one has a set of values which should never step outside certain bounds (for example if the values were negative then they wouldn't be physically meaningful) is there a nice way to bounds check? I potentially have 10 or so values I would like to check at the end of e

Re: class error

2011-03-21 Thread Jean-Michel Pichavant
monkeys paw wrote: OK, i overlooked that and the error was not very enlightening. Thanks very much. "module.__init__() takes at most 2 arguments (3 given)" Are you sure about the clueless error message ? :) JM -- http://mail.python.org/mailman/listinfo/python-list

Re: Bounds checking

2011-03-21 Thread Jean-Michel Pichavant
Martin De Kauwe wrote: Sorry, are you trying to say that it is not practical to write correct code that isn't buggy? Well, you're honest, at least, still I can't help but feel that you're admitting defeat before even starting. No. What I am saying is the code is written has been well teste

Re: Bounds checking

2011-03-21 Thread Jean-Michel Pichavant
Martin De Kauwe wrote: On Mar 21, 9:43 pm, Jean-Michel Pichavant wrote: Martin De Kauwe wrote: Sorry, are you trying to say that it is not practical to write correct code that isn't buggy? Well, you're honest, at least, still I can't help but feel that you're adm

Re: dynamic assigments

2011-03-24 Thread Jean-Michel Pichavant
Seldon wrote: Hi, I have a question about generating variable assignments dynamically. I have a list of 2-tuples like this ( (var1, value1), (var2, value2), .. , ) where var1, var2, ecc. are strings and value1, value2 are generic objects. Now, I would like to use data contained in this list

Re: dynamic assigments

2011-03-25 Thread Jean-Michel Pichavant
Seldon wrote: On 03/25/2011 12:05 AM, Steven D'Aprano wrote: On Thu, 24 Mar 2011 19:39:21 +0100, Seldon wrote: Hi, I have a question about generating variable assignments dynamically. [...] Now, I would like to use data contained in this list to dynamically generate assignments of the form "

Re: dynamic assigments

2011-03-25 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Seldon wrote: On 03/25/2011 12:05 AM, Steven D'Aprano wrote: On Thu, 24 Mar 2011 19:39:21 +0100, Seldon wrote: Hi, I have a question about generating variable assignments dynamically. [...] Now, I would like to use data contained in this list to dynami

Re: Guido rethinking removal of cmp from sort method

2011-03-29 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Fri, 25 Mar 2011 10:21:35 +0100, Antoon Pardon wrote: On Thu, Mar 24, 2011 at 11:49:53PM +, Steven D'Aprano wrote: On Thu, 24 Mar 2011 17:47:05 +0100, Antoon Pardon wrote: However since that seems to be a problem for you I will be more detailed. T

Re: delete namespaces

2011-03-30 Thread Jean-Michel Pichavant
monkeys paw wrote: How do i delete a module namespace once it has been imported? I use import banner Then i make a modification to banner.py. When i import it again, the new changes are not reflected. Is there a global variable i can modify? It depends on what you want to achieve. 1/ if you

Re: Alias for an attribute defined in a superclass

2011-04-01 Thread Jean-Michel Pichavant
Raymond Hettinger wrote: On Mar 31, 3:14 pm, Ben Finney wrote: Howdy all, I want to inherit from a class, and define aliases for many of its attributes. How can I refer to “the attribute that will be available by name ‘spam’ once this class is defined”? class Foo(object): def s

Re: Do UART require data structure/format for serial communication?

2011-04-11 Thread Jean-Michel Pichavant
VGNU Linux wrote: Hi All, I have two chips one understands Python and the other embedded C.I have connected both chips using UART serial communication channel, however I have no idea how data communication must be achieved between this 2 chips. As for example send using C chip string "Hello Py

Re: Help Amigos

2011-04-11 Thread Jean-Michel Pichavant
Gabriel Novaes wrote: Hello community My name is Gabriel. I'am from Brazil. 27. I finished last year Degree in Computer Engineering and I would go to the U.S.A to learn the local language. I wonder how is the market for developers, which city ​​is best for this? I program for 5 years PHP (MVC) a

Re: Nested inner classes and inheritance -> namespace problem

2011-04-13 Thread Jean-Michel Pichavant
Larry Hastings wrote: The problem: if you're currently in a nested class, you can't look up variables in the outer "class scope". For example, this code fails in Python 3: class Outer: class Inner: class Worker: pass class InnerSubclass(Inner): clas

Re: Python IDE/text-editor

2011-04-18 Thread Jean-Michel Pichavant
Alec Taylor wrote: Good Afternoon, I'm looking for an IDE which offers syntax-highlighting, code-completion, tabs, an embedded interpreter and which is portable (for running from USB on Windows). Here's a mockup of the app I'm looking for: http://i52.tinypic.com/2uojswz.png Which would you rec

Re: is there a difference between one line and many lines

2011-04-21 Thread Jean-Michel Pichavant
vino19 wrote: Sure, I understand that "is" is not "==", cause "is" just compares id(a)==id(b). I have a win32 CPython and the range of "singletons" is from -5 to 256 on my machine. I am asking about what happens in Python interpreter? Why is there a difference between running one line like "

Re: A question about Python Classes

2011-04-21 Thread Jean-Michel Pichavant
chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I never created an instance of BaseHandler? Cha

Re: A question about Python Classes

2011-04-22 Thread Jean-Michel Pichavant
MRAB wrote: On 21/04/2011 18:12, Pascal J. Bourguignon wrote: chad writes: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHa

Re: Pairwise frequency count from an incidence matrix of group membership

2011-04-22 Thread Jean-Michel Pichavant
Shafique, M. (UNU-MERIT) wrote: Hi, I have a number of different groups g1, g2, … g100 in my data. Each group is comprised of a known but different set of members (m1, m2, …m1000) from the population. The data has been organized in an incidence matrix: g1 g2 g3 g4 g5 m1 1 1 1 0 1 m2 1 0 0 1 0

Re: sockets: bind to external interface

2011-04-26 Thread Jean-Michel Pichavant
Hans Georg Schaathun wrote: Is there a simple way to find the external interface and bind a socket to it, when the hostname returned by socket.gethostname() maps to localhost? What seems to be the standard ubuntu configuration lists the local hostname with 127.0.0.1 in /etc/hosts. (I checked th

Re: How to concatenate unicode strings ???

2011-04-26 Thread Jean-Michel Pichavant
Chris Rebert wrote: On Tue, Apr 26, 2011 at 8:58 AM, Ariel wrote: Hi everybody, how could I concatenate unicode strings ??? What I want to do is this: unicode('this an example language ') + unicode('español') but I get an: Traceback (most recent call last): File "", line 1, in UnicodeDe

Re: Development tools and practices for Pythonistas

2011-04-26 Thread Jean-Michel Pichavant
snorble wrote: I'm not a Pythonista, but I aspire to be. My current tools: Python, gvim, OS file system My current practices: When I write a Python app, I have several unorganized scripts in a directory (usually with several named test1.py, test2.py, etc., from random ideas I have tested), an

Re: Development tools and practices for Pythonistas

2011-04-27 Thread Jean-Michel Pichavant
Ben Finney wrote: Mercurial – are the ones to choose from. Anoyone recommending a VCS tool that has poor merging support (such as Subversion or, heaven help us, CVS) is doing the newcomer a disservice. True enough. But the modern crop of first-tier VCSen – Bazaar, Git, For a single user, there

Re: Development tools and practices for Pythonistas

2011-04-27 Thread Jean-Michel Pichavant
Chris Angelico wrote: On Wed, Apr 27, 2011 at 7:24 PM, Jean-Michel Pichavant wrote: For a single user, there would be no merge issue. And svn is very simple to use. That would not be a such bad advice for a beginner with VCS systems. As someone who for years had "nightly backup

Re: Development tools and practices for Pythonistas

2011-04-27 Thread Jean-Michel Pichavant
Anssi Saari wrote: Jean-Michel Pichavant writes: For a single user, there would be no merge issue. Really? What about a single user with many computers and environments? I find myself merging files on occasion because I edited them separately and forgot to check in changes before

Re: Need your help

2011-04-28 Thread Jean-Michel Pichavant
1011_wxy wrote: Hi friends: Here I need some help. #encoding="utf-8" #moudle a.py def a(): print " function a!" #encoding="utf-8" #moudle b.py def b(): print " function b!" #encoding="utf-8" #moudle c.py import a import b def c(): a.a() b.b() Here in function c,How ca

Re: 回复: Re: Need your help

2011-04-28 Thread Jean-Michel Pichavant
1011_wxy wrote: Hi JM: *python c.py > afile.log* could you pls give me the whole example? I am so sorry that I am a beginner in Python. Your module a and b that you cannot modify given your original description, are printing data using the print statement. That means these module only

Re: Read-write lock for Python

2011-04-28 Thread Jean-Michel Pichavant
Geoff Bache wrote: Hi all, I currently find myself needing a Python read-write lock. I note that there is none in the standard library, but googling "python read-write lock" quickly produced 6 different competing examples, including two languishing patch proposals for the standard library. I ca

<    1   2   3   4   5   6   7   8   9   10   >