Re: Noob in Python. Problem with fairly simple test case

2015-07-17 Thread Jean-Michel Pichavant
- Original Message - > From: "Steven D'Aprano" > 75% or 90% is not a "vast majority". Vast majority implies more than > 99%. You could not be more wrong. More than 99% is a stupendous majority, while within 95 to 99% is a tremendous majority. >From the official "Majority rating" 2015 ed

Re: line error on no. 7

2015-07-29 Thread Jean-Michel Pichavant
- Original Message - > From: "ltc hotspot" > To: "python-list@python.org" > Sent: Tuesday, 28 July, 2015 10:21:59 PM > Subject: line error on no. 7 > Hi Everyone, > I'm writing python code to read a data text file, split the file into > a list of words using the split(function) and to pr

Re: Help Command Question

2015-07-29 Thread Jean-Michel Pichavant
- Original Message - > From: "ltc hotspot" > To: "python-list@python.org" > Sent: Tuesday, 28 July, 2015 6:59:13 PM > Subject: Help Command Question > Hi Everyone, > I'm trying to print a command of list options by using the help > command in the iPython interpreter. Read captured cop

Re: Python 3 May Become Relevant Now

2015-08-03 Thread Jean-Michel Pichavant
- Original Message - > From: "Mark Lawrence" > To: python-list@python.org > Sent: Monday, 3 August, 2015 2:25:08 AM > Subject: Python 3 May Become Relevant Now > > rr should have a field day with this one > http://nafiulis.me/python-3-may-become-relevant-now.html > > -- > My fellow Pytho

Re: Optimal solution for coloring logging output

2015-08-03 Thread Jean-Michel Pichavant
Original Message - > From: "c buhtz" > To: python-list@python.org > Sent: Monday, 3 August, 2015 11:13:37 AM > Subject: Optimal solution for coloring logging output > > I don't want to ask how to do this because there are so many > "solutions" about it. >

Re: Most Pythonic way to store (small) configuration

2015-08-04 Thread Jean-Michel Pichavant
- Original Message - > From: "Cecil Westerhof" > To: python-list@python.org > Sent: Sunday, 2 August, 2015 12:11:28 PM > Subject: Most Pythonic way to store (small) configuration > > There are a lot of ways to store configuration information: > - conf file > - xml file > - database > - js

Re: Best strategy for testing class and subclasses in pytest?

2015-08-25 Thread Jean-Michel Pichavant
> From: "C.D. Reimer" > Greetings, > > I'm writing a chess engine to learn about Python classes and > inheritance, and using pytest for the unit test. [snip] > I tried to create a separate class and/or module to import the common > tests for each class and subclass. My attempts often ended in fa

Re: [a,b,c,d] = 1,2,3,4

2015-08-25 Thread Jean-Michel Pichavant
- Original Message - > From: "ast" > To: python-list@python.org > Sent: Tuesday, 25 August, 2015 4:16:17 PM > Subject: [a,b,c,d] = 1,2,3,4 > > >>> [a,b,c,d] = 1,2,3,4 > >>> a > 1 > >>> b > 2 > >>> c > 3 > >>> d > 4 > > I have never seen this syntax before. Is it documented. > Is there a

Re: [a,b,c,d] = 1,2,3,4

2015-08-26 Thread Jean-Michel Pichavant
- Original Message - > From: "Joel Goldstick" > its called list unpacking or packing (?) > > the right side is considered a tuple because of the commas > >>> a = 1,2,3 > >>> a > (1, 2, 3) > >>> a[1] > 2 To add to Joel's answer, the right side can be *any* sequence, and is not restricted

Re: [a,b,c,d] = 1,2,3,4

2015-08-26 Thread Jean-Michel Pichavant
- Original Message - > From: "Chris Angelico" > Cc: python-list@python.org > Sent: Wednesday, 26 August, 2015 3:04:05 PM > Subject: Re: [a,b,c,d] = 1,2,3,4 > > On Wed, Aug 26, 2015 at 12:59 AM, Jean-Michel Pichavant > wrote: > > To add to Joel

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Jean-Michel Pichavant
- Original Message - > From: "Ben Finney" > > The contents of this email and any attachments are confidential and > > may also be privileged. If you are not the intended recipient, > > please > > notify the sender immediately and do not disclose the contents to > > any > > other person, us

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Jean-Michel Pichavant
- Original Message - > From: "Chris Angelico" > Cc: python-list@python.org > Sent: Wednesday, 26 August, 2015 6:11:51 PM > Subject: Re: Please don't make unfounded legalistic demands (was: [a, b, c, > d] = 1, 2, 3, 4) > > On Thu, Aug 27, 2015 at 1:09 AM, Terry Reedy > wrote: > > How abo

Re: [RELEASE] Nevow 0.11.1

2014-06-23 Thread Jean-Michel Pichavant
- Original Message - > Hello, > > I'm pleased to announce the release of Nevow 0.11.1. > > Nevow is a web application construction kit written in Python and > based > on Twisted. It is designed to allow the programmer to express as much > of > the view logic as desired in Python, and incl

Re: Keeping python code and database in sync

2014-08-29 Thread Jean-Michel Pichavant
- Original Message - > From: "Roy Smith" > > Yeah, schema migration is an ugly problem. There's a number of tools > to > help here, most of which reduce the suckitude, but don't eliminate it > completely. Some things you might want to look at: > > * SQLAlchemy Migrate > * South (djan

Re: Class Inheritance from different module

2014-09-22 Thread Jean-Michel Pichavant
> class User(Inheritance from API): > def __init__(self, ID): > steamapi.core.APIConnection(api_key = KEY) > super( " Inheritance SteamUser" (ID)) # creates the user using the > API > > > [...] > > > So that in my code when I need to create a new user, I just call 'usr > = User("XXX")' ins

Re: Class Inheritance from different module

2014-09-22 Thread Jean-Michel Pichavant
- Original Message - > From: "Jean-Michel Pichavant" > To: "Juan Christian" > Cc: "Python" > Sent: Monday, 22 September, 2014 1:37:41 PM > Subject: Re: Class Inheritance from different module > > > > cl

Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Jean-Michel Pichavant
- Original Message - > From: "Chris Angelico" > Cc: python-list@python.org > Sent: Saturday, 20 September, 2014 4:58:44 PM > Subject: Re: Love to get some feedback on my first python app!!! [snip] > > #search API > rawData = > > urllib.urlopen('http://ajax.googleapis.com/ajax

Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Jean-Michel Pichavant
- Original Message - > From: "Chris Angelico" > Cc: python-list@python.org > Sent: Monday, 22 September, 2014 4:50:15 PM > Subject: Re: Love to get some feedback on my first python app!!! > > On Tue, Sep 23, 2014 at 12:32 AM, Jean-Michel Pichavan

Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Jean-Michel Pichavant
Original Message - > From: "Chris Angelico" > Cc: python-list@python.org > Sent: Monday, 22 September, 2014 6:04:43 PM > Subject: Re: Love to get some feedback on my first python app!!! > > On Tue, Sep 23, 2014 at 1:52 AM, Jean-Michel Pichavant > wrote:

Re: how to write a html to automatically display the dictionary?

2014-09-24 Thread Jean-Michel Pichavant
- Original Message - > From: "luofeiyu" > To: "Joel Goldstick" , python-list@python.org > Sent: Wednesday, 24 September, 2014 1:06:25 AM > Subject: Re: how to write a html to automatically display the dictionary? > > > how can i create the proper html file with Jinjia 2 or other temple?

Re: Flask and Python 3

2014-09-26 Thread Jean-Michel Pichavant
- Original Message - > From: "Chris Angelico" > Cc: "Python" > Sent: Friday, 26 September, 2014 1:55:51 AM > Subject: Re: Flask and Python 3 > > On Fri, Sep 26, 2014 at 4:35 AM, Juan Christian > wrote: > > when I say video tutorial, it's implied that every video that I > > talked about

Re: PyCli : Need some reference to good books or tutorials on pycli

2014-09-26 Thread Jean-Michel Pichavant
- Original Message - > From: vijna...@gmail.com > To: python-list@python.org > Sent: Friday, 26 September, 2014 2:54:48 PM > Subject: PyCli : Need some reference to good books or tutorials on pycli > > Hi Folks, > > I need to develop a CLI (PyCli or similar)on Linux. > To be more specific

Python code in presentations

2014-09-30 Thread Jean-Michel Pichavant
Hello list, I'm currently writing a presentation to help my co-workers ramp up on new features of our tool (written in python (2.7)). I have some difficulties presenting code in an efficient way (with some basic syntax highlights). I need to be catchy about the code I'm presenting otherwise th

Re: Python code in presentations

2014-09-30 Thread Jean-Michel Pichavant
- Original Message - > From: "Joel Goldstick" > Cc: python-list@python.org > Sent: Tuesday, 30 September, 2014 3:01:38 PM > Subject: Re: Python code in presentations > > I'm a little at a loss that you are concentrating on showing code to > users. Are you also showing how your tool works

Re: Python code in presentations

2014-10-01 Thread Jean-Michel Pichavant
- Original Message - > From: "Wolfgang Keller" > To: python-list@python.org > Sent: Wednesday, 1 October, 2014 11:42:34 AM > Subject: Re: Python code in presentations > > > Right now the method I'm using is write the code in notepad++, use > > a > > plugin (NppExport) to copy paste code i

Re: virtualenv question: include just a few site packages

2014-10-09 Thread Jean-Michel Pichavant
- Original Message - > From: "Gelonida N" > To: python-list@python.org > Sent: Thursday, 9 October, 2014 12:09:50 AM > Subject: virtualenv question: include just a few site packages > > virtualenv has the switch > --system-site-packages (including all system site pacgaes) > and the switch

Re: virtualenv question: include just a few site packages

2014-10-10 Thread Jean-Michel Pichavant
- Original Message - > From: "Gelonida N" > To: python-list@python.org > Sent: Thursday, 9 October, 2014 5:55:44 PM > Subject: Re: virtualenv question: include just a few site packages > > You could build a virtual machine, installing only your VIP > > modules, and create virtual environme

Re: CLI framework using python

2014-10-10 Thread Jean-Michel Pichavant
- Original Message - > From: vijna...@gmail.com > > Hi, > > I need to develop a python CLI framework. > [snip] > 3. There are other such commands for which i will be using python > scripts. I came across pyCLI, but it doesn't have much > documentation, so couldn't figure out how to move

Re: Permissions on files installed by pip?

2014-10-17 Thread Jean-Michel Pichavant
- Original Message - > From: "Adam Funk" > To: python-list@python.org > Sent: Thursday, 16 October, 2014 9:29:46 PM > Subject: Permissions on files installed by pip? > > I've been using the python-nltk package on Ubuntu, but I need ntlk > 3.0 > now. I used 'sudo aptitude purge python-nlt

Re: (test) ? a:b

2014-10-22 Thread Jean-Michel Pichavant
- Original Message - > From: "ast" > To: python-list@python.org > Sent: Wednesday, 22 October, 2014 10:29:43 AM > Subject: (test) ? a:b > > Hello > > Is there in Python something like: > > j = (j >= 10) ? 3 : j+1; > > as in C language ? > > thx j = 3 if j >=10 else j+1 Cheers JM

Re: (-1)**1000

2014-10-22 Thread Jean-Michel Pichavant
- Original Message - > From: "ast" > To: python-list@python.org > Sent: Wednesday, 22 October, 2014 10:27:34 AM > Subject: (-1)**1000 > > Hello > > If i am writing (-1)**1000 on a python program, will the > interpreter do (-1)*(-1)*...*(-1) or something clever ? > > In fact i have (-1)*

Re: extending class

2011-09-23 Thread Jean-Michel Pichavant
Andrea Crotti wrote: On 09/23/2011 10:31 AM, Peter Otten wrote: Inside __getattribute__() you ask for self.first_var which triggers another __getattribute__() call that once again trys to determine the first_var attribute before it returns... Try using __getattr__() instead which is only tri

Re: Advise on using logging.getLogger needed.

2011-10-03 Thread Jean-Michel Pichavant
Steven W. Orr wrote: I hope I don't sound like I'm ranting :-( I have created a module (called xlogging) which sets up logging the way I want it. I found out that if I set up my logger without a name, then it gets applied to every logger that is referenced by every module that ever gets imported

Re: A tuple in order to pass returned values ?

2011-10-06 Thread Jean-Michel Pichavant
faucheuse wrote: Hi, (new to python and first message here \o/) I was wondering something : when you do : return value1, value2, value3 It returns a tuple. So if I want to pass these value to a function, the function have to look like : def function(self,(value1, value2, value3)) #self because

Re: A tuple in order to pass returned values ?

2011-10-07 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: Jean-Michel Pichavant wrote: In a general manner, ppl will tend to use the minimum arguments required. However, do not pack values into tuple if they are not related. How would you return multiple values if not in a tuple? Tuples are *the* mechanis

Re: 1/2 evaluates to 0

2011-10-12 Thread Jean-Michel Pichavant
Laurent Claessens wrote: Hi all This is well known : >>> 1/2 0 This is because the division is an "integer division". My question is : how can I evaluate 1/2 to 0.5 ? Is there some non integer division operator ? Up to now I workarounded writing float(1)/2. Is there an other way ? My Zen

Re: Problem with inheritance

2011-10-21 Thread Jean-Michel Pichavant
Sverre wrote: I have to classes a and b class a(object): def __init__(self,x): self.x = x self.build() def build(self): return class b(a): def __init__(self,x): a.__init__(self,x) self.y = 0 # ??? def build(self): # do somethi

Re: logging: warn() methods and function to be deprecated.

2011-10-24 Thread Jean-Michel Pichavant
Vinay Sajip wrote: I think that is a real shame - it seems to be gratuitous breakage for almost zero benefit. That issue shows that Trac makes heavy use of .warn, I've use .warn almost exclusively for many years, and code.google.com shows it is used extensively in the wild. Ok

Re: Data acquisition

2011-10-25 Thread Jean-Michel Pichavant
spintronic wrote: Dear friends, I have a trouble with understanding the following. I have a very short script (shown below) which works fine if I "run" step by step (or line by line) in Python shell (type the first line/command -> press Enter, etc.). I can get all numbers (actually, there are no

Re: __init__ with multiple list values

2011-11-02 Thread Jean-Michel Pichavant
Gnarlodious wrote: Initializing a list of objects with one value: class Order: def __init__(self, ratio): self.ratio=ratio def __call__(self): return self.ratio ratio=[1, 2, 3, 4, 5] Orders=[Order(x) for x in ratio] But now I want to __init__ with 3 values: class Order: def __init__(s

Re: parsing text from "ethtool" command

2011-11-02 Thread Jean-Michel Pichavant
extraspecialbitter wrote: I'm still trying to write that seemingly simple Python script to print out network interfaces (as found in the "ifconfig -a" command) and their speed ("ethtool "). The idea is to loop for each interface and print out its speed. I'm looping correctly, but have some issu

Re: python-based downloader (youtube-dl) missing critical feature ...

2011-11-04 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Fri, 04 Nov 2011 11:48:02 +, lbrt chx _ gemale wrote: python-based youtube-dl ~ http://rg3.github.com/youtube-dl/ ~ is sorely missing a flag in order to indicate the maximum file length of the data feed it would download (well, unless, for some reason, it is

Re: logging: handle everything EXCEPT certain loggers

2011-11-07 Thread Jean-Michel Pichavant
Gábor Farkas wrote: hi, is there a way to setup log-handlers in a way that they log logs from every logger, exept certain ones? basically i want the handler to handle everything, except log-records that were generated by loggers from "something.*" can this be done? i tried to create filters, b

Re: Extracting elements over multiple lists?

2011-11-07 Thread Jean-Michel Pichavant
JoeM wrote: Thanks guys, I was just looking for a one line solution instead of a for loop if possible. Why do you consider [x.remove(x[0]) for x in [a,b,c]] cheating? It seems compact and elegant enough for me. Cheers This is a one liner, but since you asked something *pythonic*, John's

Re: Help catching error message

2011-11-08 Thread Jean-Michel Pichavant
Gnarlodious wrote: What I say is this: def SaveEvents(self,events): try: plistlib.writePlist(events, self.path+'/Data/Events.plist') # None if OK except IOError: return "IOError: [Errno 13] Apache can't write Events.plist file" Note that success returns"None" while failure ret

Re: Help catching error message

2011-11-08 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Gnarlodious wrote: What I say is this: def SaveEvents(self,events): try: plistlib.writePlist(events, self.path+'/Data/Events.plist') # None if OK except IOError: return "IOError: [Errno 13] Apache can't write Events.plist file

Re: Execute a command on remote machine in python

2011-11-15 Thread Jean-Michel Pichavant
Martin P. Hellwig wrote: On 11/15/11 12:04, Roark wrote: Hi, I am first time trying my hands on python scripting and would need some guidance from the experts on my problem. I want to execute a windows command within python script from a client machine on a remote target server, and would want

Re: suppressing import errors

2011-11-15 Thread Jean-Michel Pichavant
David Riley wrote: On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote: On 15 November 2011 17:24, Chris Kaynor wrote: As with any Python code, you can wrap the import into a try: except block. try: import badModule except: pass # Or otherwise handle the exception - possibly importing

Re: Got some problems when using logging Filter

2011-11-16 Thread Jean-Michel Pichavant
sword wrote: The logging cookbook gives an Filter example, explainning how to add contextural info to log. I can't figure out how to filter log from it. Suppose I have 3 file, a.py, b.py and main.py #file: a.py import logging logger=logging.getLogger(__name__) def print_log(): logger.debug(

Re: Dynamically Generate Methods

2011-11-18 Thread Jean-Michel Pichavant
GZ wrote: Hi, I have a class Record and a list key_attrs that specifies the names of all attributes that correspond to a primary key. I can write a function like this to get the primary key: def get_key(instance_of_record): return tuple(instance_of_record.__dict__[k] for k in key_attrs) Ho

Re: Got some problems when using logging Filter

2011-11-21 Thread Jean-Michel Pichavant
sword wrote: On Nov 16, 7:40 pm, Jean-Michel Pichavant wrote: sword wrote: The logging cookbook gives an Filter example, explainning how to add contextural info to log. I can't figure out how to filter log from it. Suppose I have 3 file, a.py, b.py and main.py #file:

Re: Is there any way to unimport a library

2011-11-21 Thread Jean-Michel Pichavant
Gelonida N wrote: I wondered whether there is any way to un-import a library, such, that it's occupied memory and the related shared libraries are released. My usecase is following: success = False try: import lib1_version1 as lib1 import lib2_version1 as lib2 success = True exce

Re: Is there any way to unimport a library

2011-11-21 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Gelonida N wrote: I wondered whether there is any way to un-import a library, such, that it's occupied memory and the related shared libraries are released. My usecase is following: success = False try: import lib1_version1 as lib1 import lib2_ver

Re: Automatic import of submodules

2011-11-25 Thread Jean-Michel Pichavant
Massi wrote: Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | --

Re: Pragmatics of the standard is() function

2011-11-28 Thread Jean-Michel Pichavant
candide wrote: In which cases should we use the is() function ? The is() function compares identity of objects rather than values so I was wondering in which circumstances comparing identities of objects is really vital. Examining well reputated Python source code, I realize that is() functio

Re: Cursor.fetchall

2011-11-28 Thread Jean-Michel Pichavant
Jayron Soares wrote: Hi Felipe, I did, however I got this error: Traceback (most recent call last): File "/home/jayron/Downloads/grafos.py", line 48, in g, e = ministro_lei() File "/home/jayron/Downloads/grafos.py", line 34, in ministro_lei for i in G.degree(): TypeError: 'int' obj

Re: Proper way to delete/kill a logger?

2011-11-28 Thread Jean-Michel Pichavant
cassiope wrote: I've been trying to migrate some code to using the standard python logging classes/objects. And they seem quite capable of doing what I need them to do. Unfortunately there's a problem in my unit tests. It's fairly common to have to create quite a few entities in the course of a

Re: Cursor.fetchall

2011-11-28 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: PS : Try to code & document in English, it's much better especially when asking for help on this list, mixing spanish and english has few benefits since you may bother both spanish and english ppl :o) Actually it is english mixed with portuguese, s

Re: platform issues?

2011-12-01 Thread Jean-Michel Pichavant
Adrian Powell wrote: I'm new to python and I'm trying to get a twitter client running on a new machine but it keeps on failing. I tracked the problem down to an issue opening URLs and wrote this little test case: import urllib2 url = 'http://www.google.com/' opener = urllib2.build_opener() url

Re: Scope of variable inside list comprehensions?

2011-12-05 Thread Jean-Michel Pichavant
Roy Smith wrote: Consider the following django snippet. Song(id) raises DoesNotExist if the id is unknown. try: songs = [Song(id) for id in song_ids] except Song.DoesNotExist: print "unknown song id (%d)" % id Is id guaranteed to be in scope in the print statement? I

Re: Scope of variable inside list comprehensions?

2011-12-06 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 05 Dec 2011 19:57:15 +0100, Jean-Michel Pichavant wrote: The proper way to propagate information with exceptions is using the exception itself: try: songs = [Song(_id) for _id in song_ids] except Song.DoesNotExist, exc: print exc I&

Re: Misleading error message of the day

2011-12-08 Thread Jean-Michel Pichavant
Roy Smith wrote: I just spent a while beating my head against this one. # Python 2.6 a, b = 'foo' Traceback (most recent call last): File "", line 1, in ValueError: too many values to unpack The real problem is that there's too *few* values to unpack! It should have been a,

Re: Misleading error message of the day

2011-12-08 Thread Jean-Michel Pichavant
Roy Smith wrote: On Thursday, December 8, 2011 10:03:38 AM UTC-5, Jean-Michel Pichavant wrote: string are iterable, considering this, the error is correct. Yes, I understand that the exception is correct. I'm not saying the exception should be changed, just that we hav

Re: Misleading error message of the day

2011-12-09 Thread Jean-Michel Pichavant
Ethan Furman wrote: Jean-Michel Pichavant wrote: You have to opportunity to not use unpacking anymore :o) There is a recent thread were the dark side of unpacking was exposed. Unpacking is a cool feautre for very small applications but should be avoided whenever possible otherwise. Which

Re: Overriding a global

2011-12-12 Thread Jean-Michel Pichavant
Roy Smith wrote: MRAB wrote: or use 'globals': def function(self): logger = globals()['logger'].getChild('function') logger.debug('stuff') logger.debug('other stuff') Ah-ha! That's precisely what I was looking for. Much appreciated. Using the sa

Re: Overriding a global

2011-12-13 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 12 Dec 2011 12:13:33 +0100, Jean-Michel Pichavant wrote: Using the same name for 2 different objects is a bad idea in general. We have namespaces precisely so you don't need to care about making names globally unique. I don't

Re: Overriding a global

2011-12-13 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Tue, 13 Dec 2011 10:54:51 +0100, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Mon, 12 Dec 2011 12:13:33 +0100, Jean-Michel Pichavant wrote: Using the same name for 2 different objects is a bad idea in general.

Re: logging issues

2011-12-13 Thread Jean-Michel Pichavant
Andrea Crotti wrote: I think is simple but I can't get it to work as I wish. Suppose I have a big application, my idea is that the running script sets a global logging level and then all the imported modules would act consequently. In my codebase, however, unless I set the level for each of the

Re: Overriding a global

2011-12-14 Thread Jean-Michel Pichavant
Joshua Landau wrote: On 13 December 2011 13:30, Jean-Michel Pichavant mailto:jeanmic...@sequans.com>> wrote: writing x = 1 def spam(): x = 2 is in general a bad idea. That was my point. Why? I have a few (probably wrong) guesses. Because you expect it to be th

Re: Overriding a global

2011-12-14 Thread Jean-Michel Pichavant
Chris Angelico wrote: On Wed, Dec 14, 2011 at 9:14 PM, Jean-Michel Pichavant wrote: The problem makes little sense when using names like x or func1. Besides namespace issues, naming 2 *different objects* with the same meaningful name is usually a bad idea and points the fact that your names

Re: Overriding a global

2011-12-14 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 14 Dec 2011 13:05:19 +0100, Jean-Michel Pichavant wrote: Bad ideas : i = 5 def spam(): for i,v in enumerate([1,2,3,4]): for i,v in enumerate(['a','b', 'c']): print i, v print i,v # bad surprise The b

Re: Property Abuse

2011-12-14 Thread Jean-Michel Pichavant
Ian Kelly wrote: On Wed, Dec 14, 2011 at 1:28 AM, Felipe O wrote: Hi All, I was wondering what everyone's thought process was regarding properties. Lately I find I've been binging on them and have classes with > 10 properties. While pylint doesn't complain (yet), it tends to be picky about k

Re: Overriding a global

2011-12-14 Thread Jean-Michel Pichavant
Joshua Landau wrote: [snip] Using currentLogger is just padding, in my opinion. *Every *value is "current". Not always. I try to keep names on the same object because that object is supposed to be named that way. I can change one of the object attribute, but the object named that way keep bein

Re: can a subclass method determine if called by superclass?

2012-01-05 Thread Jean-Michel Pichavant
Peter wrote: Situation: I am subclassing a class which has methods that call other class methods (and without reading the code of the superclass I am discovering these by trial and error as I build the subclass - this is probably why I may have approached the problem from the wrong viewpoint :-))

Re: can a subclass method determine if called by superclass?

2012-01-05 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Peter wrote: Situation: I am subclassing a class which has methods that call other class methods (and without reading the code of the superclass I am discovering these by trial and error as I build the subclass - this is probably why I may have approached the

Re: Calling a variable inside a function of another class

2012-01-10 Thread Jean-Michel Pichavant
Yigit Turgut wrote: class test(test1): def __init__(self, device): . . . def _something(self, x=1) self.dt = data if __name__ == "__main__": test.something.dt ??? I am trying to call a variable located in a function of a class from main but couldn't succeed

Re: your feedback to my first project please

2012-01-10 Thread Jean-Michel Pichavant
patr...@bierans.de wrote: Thanks for the feedback! I took the time reading and understanding it and to let it getting into my bones. And I also lost time on reading more of this freaky and interesting documentation and was testing a lot of different stuff with my enviroment. My current code can

Re: Two questions about logging

2012-01-12 Thread Jean-Michel Pichavant
Matthew Pounsett wrote: [snip] Second, I'm trying to get a handle on how libraries are meant to integrate with the applications that use them. The naming advice in the advanced tutorial is to use __name__ to name loggers, and to allow log messages to pass back up to the using application's logg

Re: Zealotry

2012-01-13 Thread Jean-Michel Pichavant
Ben Finney wrote: Steven D'Aprano writes: On Thu, 12 Jan 2012 18:50:13 -0800, alex23 wrote: Tamer Higazi wrote: So, instead of making yourself continuously headache for an outdated OS I advise [...] Please don't recommend people use another OS when they ask an expl

Re: copy on write

2012-01-13 Thread Jean-Michel Pichavant
Eduardo Suarez-Santana wrote: El 13/01/12 11:33, Eduardo Suarez-Santana escribió: I wonder whether this is normal behaviour. Even simpler: $ python Python 2.7.2 (default, Oct 31 2011, 11:54:55) [GCC 4.5.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> r=

Re: Zealotry

2012-01-13 Thread Jean-Michel Pichavant
Chris Angelico wrote: On Fri, Jan 13, 2012 at 9:34 PM, Jean-Michel Pichavant wrote: Recommending an OS to solve one python package installation is zealotry. At least, advise to use a virtual machine software to try it out, there are some VM softwares for free working with windows. If

Re: First python project : Tuner

2012-01-17 Thread Jean-Michel Pichavant
Jérôme wrote: Hi all. Like others before me, I'd like to show you my first python attempt, in the hope in can get advices on how to improve my coding. I started learning python and pyGTK last november. I had had a short experience of GTK with C, but had given up as I lacked time and I found it

Re: verify the return value of a function

2012-01-20 Thread Jean-Michel Pichavant
Jabba Laci wrote: Hi, In a unit test, I want to verify that a function returns a cookielib.LWPCookieJar object. What is the correct way of doing that? 1) First I tried to figure out its type with type(return_value) but it is 2) return_value.__class__ .__name__ gives 'LWPCookieJar', which is b

Re: Opinion on best practice...

2013-02-05 Thread Jean-Michel Pichavant
- Original Message - > I need to pick up a language that would cover the Linux platform. I > use Powershell for a scripting language on the Windows side of > things. Very simple copy files script. Is this the best way to do > it? > > import os > > objdir = ("C:\\temp2") > colDi

Re: Best Practice Question

2013-02-05 Thread Jean-Michel Pichavant
- Original Message - > On 02/04/2013 11:23 PM, Anthony Correia wrote: > > Just started learning Python. I just wrote a simple copy files > > script. I use Powershell now as my main scripting language but I > > wanted to extend into the linux platform as well. Is this the > > best way to

Re: Best Practice Question

2013-02-06 Thread Jean-Michel Pichavant
- Original Message - > > [...] > > By the way, did someone ever notice that r'\' fails ? I'm sure > > there's a > > reason for that... (python 2.5) Anyone knows ? > > > > r'\' > > SyntaxError: EOL while scanning single-quoted string > > > > > "Even in a raw string, string quotes can be e

Re: How to improve writing code in python?

2013-02-06 Thread Jean-Michel Pichavant
- Original Message - > Hi, > I have a problem with learning Python. My code is really bad and I > can't solve many problems. I really want to improve it. Do you know > any website which helps me to learn python effectively (for > beginners)? This is my first programming language and I am s

Re: Plotting syntax

2013-02-07 Thread Jean-Michel Pichavant
- Original Message - > Hi Python experts, > I am working with an array of data and am trying to plot several > columns of data which are not continuous; i.e. I would like to plot > columns 1:4 and 6:8, without plotting column 5. The syntax I am > currently using is: > oplot (t,d[:,0:4])

Re: Logging within a class

2013-02-11 Thread Jean-Michel Pichavant
- Original Message - > Within __init__ I setup a log with self.log = > logging.getLogger('foo') then add a > console and filehandler which requires the formatting to be > specified. There a few > methods I setup a local log object by calling getChild against the > global log object. > > >

Re: LangWart: Method congestion from mutate multiplicty

2013-02-12 Thread Jean-Michel Pichavant
> Yeah, this is, pardon the french, just batshit crazy. huh ? :) JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the conten

Re: Logwatch python

2013-02-12 Thread Jean-Michel Pichavant
- Original Message - > In article <1de56e5b-4f9b-477d-a1d4-71e7222a2...@googlegroups.com>, > Cleuson Alves wrote: > > > Hello, I am trying to run this code, but I get an answer incorrect > > arguments > > numbers. someone could put an example of arguments for me to use in > > the / var

Re: Struggling with program

2013-02-18 Thread Jean-Michel Pichavant
- Original Message - > I'm trying to do this assignment and it not working, I don't > understand why... > > This is what I have to do: > > Write the definition of a class Player containing: > An instance variable name of type String , initialized to the empty > String. > An instance va

Re: Struggling with program

2013-02-18 Thread Jean-Michel Pichavant
> So your assignment is a bit misleading when it says a constructor is > not > required, because if you want to initialize some instance attributes, > it > has to be done in a method, usually the constructor, which in Python > is > __init__. By constructor, he may actually refer to the __new__ met

Re: Python-list Digest, Vol 113, Issue 111

2013-02-18 Thread Jean-Michel Pichavant
- Original Message - > Hi, I don't know if I should ask this on here, or in the tutor > section, but I heard that http://www.lighttable.com was an > innovative IDE, so I was wondering if it works for python since I'm > learning python over time. Thanks Hi, Please do not use html f

Re: Python trademark - A request for civility

2013-02-18 Thread Jean-Michel Pichavant
- Original Message - > Folks, > > It seems that people have been sending threats and abuse to the > company > claiming a trademark on the name "Python". And somebody, somewhere, > may > have launched a DDOS attack on their website. > > The Python Software Foundation has asked the communit

Re: python mail box

2013-02-18 Thread Jean-Michel Pichavant
- Original Message - > I want to display mail to django apps from my google accout. > and when the fetch all unread message,i want to replay them from my > apps so i need replay option also. > by point: > 1. First Fetch all unread mail from google account. > 2. If replay from apps it's repl

Instances as dictionary key, __hash__ and __eq__

2013-02-18 Thread Jean-Michel Pichavant
Greetings, I opened something like a month ago a thread about hash functions and how I could write classes which instances can be safely used as dictionary keys. I though I had it but when I read back my code, I think I wrote yet another bug. Consider the following simple (buggy) class, python 2

Re: Instances as dictionary key, __hash__ and __eq__

2013-02-19 Thread Jean-Michel Pichavant
> > Additionally, If I'm making things much more complicated than they > > need to be, let me know. > > You are. There are ways to achieve what you want, but it requires a > lot more setup and discipline. The simplest way is probably to have > a _equal_fields() method that subclasses override, r

Re: Making unhashable object

2013-02-19 Thread Jean-Michel Pichavant
- Original Message - > I am trying to define a class whose instances should not be hashable, > following: > http://docs.python.org/2/reference/datamodel.html#object.__hash__ > > class A: > def __init__(self,a): > self.value=a > __hash__=None > > > Then: > > >>> a=A(3

Re: subclassable types

2013-02-22 Thread Jean-Michel Pichavant
- Original Message - > Dear all, > I am wondering what the rules are that determine whether a built-in > type is > subclassable or not. > As examples, why can you base your classes on int or set, > but not on bool or range? > Also: can you use introspection to find out whether a type is val

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