Re: Organising packages/modules - importing functions from a common.py in a separate directory?

2013-10-28 Thread Jean-Michel Pichavant
- Original Message - > Hi, > > I have a collection of Python scripts I'm using to load various bits > of data into a database. > > I'd like to move some of the common functions (e.g. to setup loggers, > reading in configuration etc.) into a common file, and import them > from there. > >

Re: Organising packages/modules - importing functions from a common.py in a separate directory?

2013-10-29 Thread Jean-Michel Pichavant
- Original Message - > Hi, > > If I try to use: > > from .common.common_foo import setup_foo_logging > > I get: > > ValueError: Attempted relative import in non-package If you're using python 3, forget what I said about not using relative imports. I think they've implemented t

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-31 Thread Jean-Michel Pichavant
- Original Message - > From: "Terry Reedy" > To: python-list@python.org > Sent: Wednesday, 18 March, 2015 10:47:40 PM > Subject: Re: A simple single line, triple-quoted comment is giving syntax > error. Why? > > On 3/18/2015 3:53 PM, Thomas 'PointedEars' Lahn wrote: > > > I must strongl

Re: Logging Custom Levels?

2015-03-31 Thread Jean-Michel Pichavant
- Original Message - > From: "Didymus" > To: python-list@python.org > Sent: Tuesday, 31 March, 2015 5:20:52 PM > Subject: Logging Custom Levels? > > Hi, > > I've create a Python file called "log.py" and placed in the custom > levels: > > # Performance Debug... > logging.addLevelName(PDE

Re: Code critique please

2015-04-08 Thread Jean-Michel Pichavant
- Original Message - > From: "kai peters" > To: python-list@python.org > Sent: Wednesday, 8 April, 2015 12:43:23 AM > Subject: Code critique please > > I just wrote this bit (coming from Pascal) and am wondering how > seasoned Python programmers would have done the same? Anything > terrib

Re: A question on the creation of list of lists

2015-04-22 Thread Jean-Michel Pichavant
- Original Message - > From: "subhabrata banerji" > To: python-list@python.org > Sent: Wednesday, 22 April, 2015 6:18:30 PM > Subject: A question on the creation of list of lists > > Dear Group, > > I am trying to open a bunch of files from a directory and trying to > put the results in

Re: May I drop list bracket from list?

2015-04-23 Thread Jean-Michel Pichavant
- Original Message - > From: "Peter Otten" <__pete...@web.de> > To: python-list@python.org > Sent: Thursday, 23 April, 2015 12:26:41 PM > Subject: Re: May I drop list bracket from list? > > subhabrata.bane...@gmail.com wrote: > > > Dear Group, > > > > list1=[] > > for file in list_of_fil

Re: for...else

2015-06-02 Thread Jean-Michel Pichavant
- Original Message - > From: "acdr" > To: python-list@python.org > Sent: Tuesday, 2 June, 2015 1:26:42 PM > Subject: for...else > > Hi, > > Currently, in various places in my code, I have the equivalent of: > > for x in it: > if complicated_calculation_1(): > cleanup() >

Re: for...else

2015-06-02 Thread Jean-Michel Pichavant
- Original Message - > From: "acdr" > To: "Jean-Michel Pichavant" > Cc: python-list@python.org > Sent: Tuesday, 2 June, 2015 2:52:21 PM > Subject: Re: for...else > > That would work for my example, but it would only really work if all > th

Re: for...else

2015-06-02 Thread Jean-Michel Pichavant
- Original Message - > From: "acdr" > To: "Jean-Michel Pichavant" > Cc: python-list@python.org > Sent: Tuesday, 2 June, 2015 4:00:12 PM > Subject: Re: for...else > > The first solution in your e-mail (with a Cleanup exception) is > definitely

ctypes and byte order

2015-06-18 Thread Jean-Michel Pichavant
Hi list, I'm currently writing python code that writes a small binary file to be used by another device which code is written in C. The python code runs on a little endian CPU, and unfortunately, the other device is using a big endian MIPS. My problem is the following: I cannot make an array of

Re: ctypes and byte order

2015-06-18 Thread Jean-Michel Pichavant
- Original Message - > From: "Peter Otten" <__pete...@web.de> > becomes > > $ cat be2.py > import ctypes, sys > > iarray_be = ctypes.c_uint32.__ctype_be__*5 > > class Foo_be(ctypes.BigEndianStructure): > _fields_ = [('bar', iarray_be)] > > print sys.version > f_be = Foo_be((0,1,

Re: ctypes and byte order

2015-06-19 Thread Jean-Michel Pichavant
- Original Message - > From: "Terry Reedy" > To: python-list@python.org > Sent: Thursday, 18 June, 2015 7:02:16 PM > Subject: Re: ctypes and byte order > > On 6/18/2015 5:39 AM, Jean-Michel Pichavant wrote: > > > I'm currently writing python c

Re: Catching exceptions with multi-processing

2015-06-19 Thread Jean-Michel Pichavant
- Original Message - > From: "Fabien" > To: python-list@python.org > Sent: Friday, 19 June, 2015 4:01:02 PM > Subject: Catching exceptions with multi-processing > > Folks, > > I am developing a tool which works on individual entities (glaciers) > and > do a lot of operations on them. The

Re: Catching exceptions with multi-processing

2015-06-19 Thread Jean-Michel Pichavant
- Original Message - > From: "Oscar Benjamin" > A simple way to approach this could be something like: > > #!/usr/bin/env python3 > > import math > import multiprocessing > > def sqrt(x): > if x < 0: > return 'error', x > else: > return 'success', math.sqrt(x) >

Re: Python File as the Default PDF handler for Windows

2015-06-23 Thread Jean-Michel Pichavant
> Just to update, you are correct, Chris, the file short name is passed > into sys.argv. didn't need to add anything to the path. But a gotcha > -- Windows didn't like my .py, clicking on the pdf causes Windows to > complain about 'file x' is not a valid windows executable. I'm not an expert of w

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: pyWin build 216

2011-09-24 Thread Michel Claveau - MVP
Hi! Me, because some bugs in 216, I come back to 214... (215 has another bugs). @-salutations -- MCi -- http://mail.python.org/mailman/listinfo/python-list

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
ported pass Using this code allows you to import your library only if all conditions are met, preventing you from rolling back in case of error. Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list

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

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