Re: Python Newbie

2013-02-22 Thread Jean-Michel Pichavant
- Original Message - > Hi Chris, > > Thanks for this. Regarding ambiguity, you will never find me write > ambiguous code. I don't sabotage my own work. But the reality is > that in addition to writing my own code, I have to maintain > existing. I find it incredibly confusing then I see a s

Re: Issues a longer xpath expression

2013-02-22 Thread Jean-Michel Pichavant
- Original Message - > I am having issues with the urllib and lxml.html modules. > Here is my original code: import urllib import lxml . html > down = 'http://v.163.com/special/visualizingdata/' file = urllib . > urlopen ( down ). read () root = lxml . html . document_fromstring ( > file

Re: Python Newbie

2013-02-26 Thread Jean-Michel Pichavant
- Original Message - > Hi guys, > > Question. Have this code > > intX = 32 # decl + init int var > intX_asString = None # decl + init with NULL string var > > intX_asString = intX.__str__ ()# convert int to string > > What are these ugly under

Re: "Daemonizing" an application.

2013-02-27 Thread Jean-Michel Pichavant
- Original Message - > Hello, > > Sorry for the obscure title, but I can't make short to explain what > I'm searching for. :) > > I made an app (kind of proxy) that works without UI within it's > process. So far, so good. > > Now I need to change "live" some controls of this application,

Re: Nuitka now supports Python 3.2

2013-02-27 Thread Jean-Michel Pichavant
- Original Message - > On 02/26/2013 05:18 AM, Steven D'Aprano wrote: > > Nuitka now supports Python 3.2 syntax and compiles the full CPython > > 3.2 > > test suite. > > Interestingly, GvR seemed to be quite critical of it in his comment > at > the end of this post: > https://ep2013.europy

Re: Project Based python tutorials

2013-02-28 Thread Jean-Michel Pichavant
- Original Message - > On Wednesday, February 27, 2013 2:31:11 AM UTC-6, Alvin Ghouas wrote: > > > So, I desided to start learning programming a few months > > ago and by now i feel pretty confident about the basics of > > the python language, and programming in general. > > Variables, l

Re: How would you do this?

2013-03-01 Thread Jean-Michel Pichavant
- Original Message - > How would you find the slope, y intercept, and slope-intercept form > equation for a line in python? > -- > http://mail.python.org/mailman/listinfo/python-list > See http://docs.scipy.org/doc/scipy/reference/interpolate.html -- IMPORTANT NOTICE: The contents o

Re: Store a variable permanently

2013-03-01 Thread Jean-Michel Pichavant
- Original Message - > So i have a variable called funds that i want to store the value of > even after the program is exited. My funds variable holds the total > value of funds i have. I add a certain number of funds each time i > run the program by entering how much i want to add. How wou

Re: Do you feel bad because of the Python docs?

2013-03-01 Thread Jean-Michel Pichavant
[snip hostile replies] It's somehow funny to read such posts on a thread about someone complaining about the community python being hostile. I think we should really try to resist the urge of answering trolls because no matter how many times we slap them, they'll stay trolls and probably get eve

Re: Store a variable permanently

2013-03-11 Thread Jean-Michel Pichavant
- Original Message - > On Fri, 01 Mar 2013 11:19:22 +0100, Jean-Michel Pichavant wrote: > > > - Original Message - > >> So i have a variable called funds that i want to store the value > >> of > >> even after the program is exited.

Re: Advice regarding multiprocessing module

2013-03-11 Thread Jean-Michel Pichavant
- Original Message - > Dear all, > I need some advice regarding use of the multiprocessing module. > Following is the scenario: > * I am running gradient descent to estimate parameters of a pairwise > grid CRF (or a grid based graphical model). There are 106 data > points. Each data po

Re: comment récupérer les valeurs de canvas dans python

2013-03-11 Thread Jean-Michel Pichavant
- Original Message - > comment récupérer la couleur d'un canvas ou id d'un canvas? > -- > http://mail.python.org/mailman/listinfo/python-list Hello, I'll take my chance : http://effbot.org/tkinterbook/canvas.htm JM PS : write in english, or frenglish like I do, something that has a c

Re: Store a variable permanently

2013-03-12 Thread Jean-Michel Pichavant
- Original Message - > On Mon, 11 Mar 2013 11:19:49 +0100, Jean-Michel Pichavant wrote: > > [...] > > While your point about security is fair, the others aren't. Pickle > > uses > > by default an ascii representation of the data, it's readable and

Re: Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Jean-Michel Pichavant
- Original Message - > For example: > a=[-15,-30,-10,1,3,5] > I want to find a negative and a positive minimum. > example: negative > print(min(a)) = -30 > positive > print(min(a)) = 1 > -- > http://mail.python.org/mailman/listinfo/python-list min(a) and min([e for e in a if e >=0]

Re: Store a variable permanently

2013-03-13 Thread Jean-Michel Pichavant
- Original Message - > On Tue, 12 Mar 2013 12:54:11 +0100, Jean-Michel Pichavant wrote: > > >> > import pickle > >> > a = 758 > >> > pickle.dump(a, open('test.pickle', 'w')) > >> > !cat test.pickle > >> &g

Re: Sphinx highlighting

2013-03-14 Thread Jean-Michel Pichavant
- Original Message - > What controls the yellow highlight bar that Sphinx sometimes puts in > the > documentation? > E.g.: > .. py:function:: basic_parseStrTest () > generates bold-face text, where > .. py:function:: basicParseStrTest () > generates text with a yellow bar highlight. > > I

Re: editing a HTML file

2013-03-14 Thread Jean-Michel Pichavant
- Original Message - > Hi all, > > I'would like to make a script that automatically change some text in > a > html file. > > I need to make some changes in the text of tags > > My question is: there is a way to just "update/substitute" the text > in > the html tags or do i have to make

Re: how to couper contenier of a canvas in an outer canvas???

2013-03-15 Thread Jean-Michel Pichavant
- Original Message - > > I dont usually bother about spelling/grammar etc. And I think it > silly > to do so on a python list. > > However with this question: > > On Mar 14, 5:16 pm, olsr.ka...@gmail.com wrote: > > how to couper all the obejcts in a canvas in an auther canvas? > > "obej

Re: how to couper contenier of a canvas in an outer canvas???

2013-03-15 Thread Jean-Michel Pichavant
- Original Message - > On Sat, Mar 16, 2013 at 1:52 AM, Jean-Michel Pichavant > > couper is probably a french word, I've seen some of the OP's > > threads written in french. > > > > It means "cut". > > > > He probably want

Re: "eval vs operator.methodcaller" - which is better?

2013-03-18 Thread Jean-Michel Pichavant
- Original Message - > Hi, > > I have a program that picks module and method name from a > configuration file and executes the method. I have found two ways to > achieve this. > > Apporach 1: > --- > moduleName = 'mymodule'#These two variables are read from con

Re: What are some other way to rewrite this if block?

2013-03-18 Thread Jean-Michel Pichavant
- Original Message - > This simple script is about a public transport, here is the code: > > def report_status(should_be_on, came_on): > if should_be_on < 0.0 or should_be_on > 24.0 or came_on < 0.0 or > came_on > 24.0: > return 'time not in range' > elif should_be_on == ca

Re: Writing Python framework for declarative checks?

2013-03-19 Thread Jean-Michel Pichavant
- Original Message - > HI, > > NB: I've posted this question on Reddit as well (but didn't get many > responses from Pythonistas) - hope it's ok if I post here as well. > > We currently use a collection of custom Python scripts to validate > various things in our production environment/co

Re: Help me pick an API design (OO vs functional)

2013-03-26 Thread Jean-Michel Pichavant
- Original Message - > notepad_1 = start("Notepad") > notepad_2 = start("Notepad") > notepad_1.write("Hello World!") > notepad_1.press(CTRL + 'a', CTRL + 'c') > notepad_2.press(CTRL + 'v') > > The problem with this design is that it effectively duplicates our

Re: Help me pick an API design (OO vs functional)

2013-03-26 Thread Jean-Michel Pichavant
- Original Message - > On Tuesday, March 26, 2013 11:07:45 AM UTC+1, Jean-Michel Pichavant > wrote: > > - Original Message - > > > notepad_1 = start("Notepad") > > > notepad_2 = start("Notepad") > > > notepad_1.wri

Re: No errors displayed but i blank scren nstead.

2013-03-29 Thread Jean-Michel Pichavant
> I am trying my best with the little knowledge i have and i expect no > help from you. You are more inclinded to criticize that to actually > help. And if i pay someone that certainly not gonna be you. > > And i told you about gethostbyaddr, tht its not an issue its because > the script bein ru

Re: python mock Requests and the response

2013-04-02 Thread Jean-Michel Pichavant
- Original Message - > I am a beginner to using mock in python and trying to use > http://www.voidspace.org.uk/python/mock. > > Please tell me the basic calls to get me working in below scenario. I > am using python's Requests module > (http://docs.python-requests.org/en/latest/) . > > In

Re: mock django cache

2013-04-08 Thread Jean-Michel Pichavant
- Original Message - > In my settings.py , I have specified my cache as : > CACHES = { > 'default': { > .. > } > } > > In my views.py, I have > > import requests > from django.core.cache import cache, get_cache > > def aview(): > #check cache > if not get_ca

Re: CSV to matrix array

2013-04-12 Thread Jean-Michel Pichavant
- Original Message - > Hello! > > I have a CSV file with 20 rows and 12 columns and I need to store it > as a matrix. I already created an array with zeros, but I don't know > how to fill it with the data from the csv file. I have this script: > > import numpy > from numpy import array >

Re: Efficient way of looging in python

2013-04-25 Thread Jean-Michel Pichavant
- Original Message - > Hi, > > I need an efficient way of logging using python. > My problem statemnt: > 1. I have multiple processes using the same logging file. > I need solutions to the following: > a) If multiple processes are trying to write to the same file, I need > to prevent that.

Import and absolute file names, sys.path including ''... or not

2009-05-19 Thread Jean-Michel Pichavant
Hi fellows, I spent quite a time on a malicious issue. I found out that there is a slight difference on the sys.path content when either executing code from a shell or from within a script. This difference is the '' item, which is present in the shell form of sys.path. For instance, let's wr

Re: sqlite3, qmarks, and NULL values

2009-05-20 Thread Jean-Michel Pichavant
I fall into the same issue when using postgres. Your main concern is that NULL = NULL will return False. Could seems strange but it has much advantages sometimes, however this is not the purpose. I found your solution quite acceptable. Just replace 'if y:' by 'if y is None:', add a comment to po

Re: sqlite3, qmarks, and NULL values

2009-05-20 Thread Jean-Michel Pichavant
Erratum: please read 'if y is *not* None:'. (think that if y = 0, you won't execute the proper code block with 'if y:'). JM Jean-Michel Pichavant wrote: I fall into the same issue when using postgres. Your main concern is that NULL = NULL will return False. Could

Re: Import and absolute file names, sys.path including ''... or not

2009-05-20 Thread Jean-Michel Pichavant
n a python shell ('' + '/home/jeanmichel/test.py' is a valid path), but the "python.exe anotherTest2.py" form will fail as it will try for '/home/jeanmichel' +'/home/jeanmichel/test.py' which is not a valid path. So my question is: "why the shell

Re: which database is suitable for small applications

2009-05-26 Thread Jean-Michel Pichavant
Kalyan Chakravarthy wrote: Hi All, can any one suggest me which database I can use for my small application(to store user names ,passwords, very few other data.. ) I am using Python, Google Apps and guide me how to connect to database, I am very new to these technologies Please help

Re: What text editor is everyone using for Python

2009-05-26 Thread Jean-Michel Pichavant
Why buy an IDE when you just need a text editor ? I don't get it. Anyway gvim (aka vim aka vi) and emacs are the most powerful editors for years. Both have Windows and Linux version and most important, they both are very effective at editing any file type (python, C, latex, love letters...) Ema

Re: Inheritance and Design Question

2009-05-28 Thread Jean-Michel Pichavant
imageguy wrote: I have an object the I would like to use as a base class. Some of the methods I would like to override completely, but others I would simply like to call the base class method and use the return value in the child method. The purpose here is to eliminate the duplication of valua

Re: Global variables from a class

2009-05-29 Thread Jean-Michel Pichavant
Kless wrote: I usually use a class to access to global variables. So, which would be the correct way to set them --since the following classes--: class Foo: var = 'lala' class Bar: def __init__(self): self.var = 'lele' Or is it the same?

Re: NameError function not found

2009-06-01 Thread Jean-Michel Pichavant
Cameron Pulsford wrote: Hey everyone, I am extremely stumped on this. I have 2 functions.. def _determinant(m): return m[0][0] * m[1][1] - m[1][0] * m[0][1] def cofactor(self): """Returns the cofactor of a matrix.""" newmatrix = [] for i, minor in enumerate(self.minors()): ne

Re: Class Methods help

2009-06-01 Thread Jean-Michel Pichavant
FYI, same without decorators, if you python version does not support it. class MyClass: def some_func(x): return x+2 some_func = staticmethod(some_func) JM bd satish wrote: Thanks to Tim Chase & Lie Ryan !! That was exactly what I was looking for !! It's time for me to now rea

Messing up with classes and their namespace

2009-06-05 Thread Jean-Michel Pichavant
Hello world, I had recently a very nasty bug in my python application. The context is quite complex, but in the end the problem can be resume as follow: 2 files in the same directory : lib.py: >import foo >foo.Foo.BOOM='lib' foo.py: >class Foo: >BOOM = 'F' > >if __name__=='__main__':

Re: Creating a local variable scope.

2009-11-30 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 30 Nov 2009 02:11:12 +0100, Alf P. Steinbach wrote: I think if one could somehow declare names as const (final, readonly, whatever) then that would cover the above plus much more. Having real constants is one feature that I miss. Because Python doesn't

Re: Exec Statement Question

2009-11-30 Thread Jean-Michel Pichavant
Victor Subervi wrote: if which == '': i = 0 all = '' while i < len(meanings): table = '%s\n' % meanings[i] table += "\n \n align='center'>%s\n " % names[i] j = 0 for elt in code: if (j + 8) % 8 == 0: table += ' \n' table += ' %s\

Re: getattr problem

2009-12-01 Thread Jean-Michel Pichavant
Victor Subervi wrote: Hi; I have the following code that execute without a problem: import sys,os sys.path.append(os.getcwd()) import options storesTables = [] junkStores = string.join(addStore(), ', ') for table in optionsTables(): if table not in ('particulars', junkStores): storesTables

Re: Python without wrapper script

2009-12-02 Thread Jean-Michel Pichavant
eric.frederich wrote: Is there a way to set up environment variables in python itself without having a wrapper script. The wrapper script is now something like #!/bin/bash export LD_LIBRARY_PATH="/some/thing/lib:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="/another/thing/lib:$LD_LIBRARY_PATH"

Re: Declaring a class level nested class?

2009-12-03 Thread Jean-Michel Pichavant
cmckenzie wrote: Hi. I'm new to Python, but I've managed to make some nice progress up to this point. After some code refactoring, I ran into a class design problem and I was wondering what the experts thought. It goes something like this: class module: nestedClass def __init__():

Re: Declaring a class level nested class?

2009-12-03 Thread Jean-Michel Pichavant
Chris Rebert wrote: On Wed, Dec 2, 2009 at 8:55 PM, cmckenzie wrote: Hi. I'm new to Python, but I've managed to make some nice progress up to this point. After some code refactoring, I ran into a class design problem and I was wondering what the experts thought. It goes something like this:

Re: testing command line scripts that use optparse

2009-12-04 Thread Jean-Michel Pichavant
Peter wrote: Hi I have a script like this: def doit(input, output): parser = OptionParser() parser.add_option("-a", "--accounts", dest="accounts", default="all", help="list available accounts") ... (options, args) = parser.parse_args() # main driver if __name__ == "__mai

Re: subprocess kill

2009-12-07 Thread Jean-Michel Pichavant
luca72 wrote: On 5 Dic, 03:06, Carl Banks wrote: On Dec 4, 3:44 pm, luca72 wrote: On 5 Dic, 00:14, luca72 wrote: On 5 Dic, 00:03, luca72 wrote: On 4 Dic, 23:23, Mike Driscoll wrote: On Dec 4, 3:50 pm, luca72 wrote: Hello i'm using sub

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Jean-Michel Pichavant
Victor Subervi wrote: global printTree = , allTrees = [{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, 'presCat2': {}}] /var/www/html/angrynates.com/cart/catTree.py in printTree(allTrees=[{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, 'presCat2

Re: postgresql_autodoc in Python?

2009-12-07 Thread Jean-Michel Pichavant
Wolfgang Keller wrote: Hello, has anyone ever implemented something similar to postgresql_autodoc in Python? TIA, Sincerely, Wolfgang If by postgresql_autodoc you mean tools for generating html documentation from python code, yes. Starting from the ugliest: - pydoc - epydoc - sphinx

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Mon, Dec 7, 2009 at 7:14 AM, Jean-Michel Pichavant mailto:jeanmic...@sequans.com>> wrote: Victor Subervi wrote: global printTree = , allTrees = [{'prodCat1': {}, 'prodCat2': {}}, {'presCat1': {}, &#x

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Jean-Michel Pichavant
Victor Subervi wrote: printTree(aTree[name], level + 1) ... print aTree([name], level + 1) ... Traceback (most recent call last): File "", line 4, in ? TypeError: 'dict' object is not callable >>> Be cautious, you are now executing the same code ! Again, read carefully th

accessing local variables from the pdb debugger

2009-12-10 Thread Jean-Michel Pichavant
Guys, I have some problem changing method locals with pdb: import pdb def test(): foo = 'foo' pdb.set_trace() test() --Return-- > /home/jeanmichel/trunk/tnt/test.py(5)test()->None -> pdb.set_trace() (Pdb) print foo foo (Pdb) foo = 'bar' (Pdb) print foo foo (Pdb) I tried us

Re: accessing local variables from the pdb debugger

2009-12-10 Thread Jean-Michel Pichavant
Diez B. Roggisch wrote: Jean-Michel Pichavant wrote: Guys, I have some problem changing method locals with pdb: import pdb def test(): foo = 'foo' pdb.set_trace() test() --Return-- > /home/jeanmichel/trunk/tnt/test.py(5)test()->None -> pdb.set_trace() (Pdb)

Re: accessing local variables from the pdb debugger

2009-12-11 Thread Jean-Michel Pichavant
Lie Ryan wrote: On 12/11/2009 12:37 AM, Jean-Michel Pichavant wrote: Diez B. Roggisch wrote: By just inserting the print foo statement right after changing foo's value, I've rolled back the value to 'foo' ??? A hell of a wtf pdb feature ! Apparently it's fixed in

Re: [ANN] pylint 0.19 / astng 0.19.2

2009-12-18 Thread Jean-Michel Pichavant
Sylvain Thénault wrote: Hi, I'm very pleased to announce the release of pylint 0.19 / astng 0.19.2 release! More information / download on http://www.logilab.org/project/pylint/0.19.0. This is a "community" release, including the work we've done during the pylint bug day [1] and patches mostl

Re: [ANN] pylint 0.19 / astng 0.19.2

2009-12-18 Thread Jean-Michel Pichavant
Jerry Hill wrote: On Fri, Dec 18, 2009 at 12:24 PM, Jean-Michel Pichavant > File "/opt/tools/python/python2.3/site-packages/logilab_astng-0.19.2-py2.5.egg/logilab/astng/infutils.py", line 28, in from logilab.astng._nodes import Proxy_, List, Tuple, Function, If, TryExcept Im

Re: [ANN] pylint 0.19 / astng 0.19.2

2009-12-21 Thread Jean-Michel Pichavant
Sylvain Thénault wrote: On 18 décembre 18:24, Jean-Michel Pichavant wrote: Sylvain Thénault wrote: Hi, I'm very pleased to announce the release of pylint 0.19 / astng 0.19.2 release! More information / download on http://www.logilab.org/project/pylint/0.19.0. This is a "

Re: How to validate the __init__ parameters

2009-12-21 Thread Jean-Michel Pichavant
Denis Doria wrote: Hi; I'm checking the best way to validate attributes inside a class. Of course I can use property to check it, but I really want to do it inside the __init__: class A: def __init__(self, foo, bar): self.foo = foo #check if foo is correct self.bar = bar Al

Re: RotatingFileHandler key error when parsing a logging config file

2009-12-22 Thread Jean-Michel Pichavant
jordilin wrote: Hi, I've a config for logging where I set up a file rotation with handlers.RotatingFileHandler and when the app parses the logging config it says keyError when trying to parse that section ('RotatingFileHandler' is not defined). Curiously enough, I can do import logging and from

Re: more efficient?

2009-12-22 Thread Jean-Michel Pichavant
Zubin Mithra wrote: I have the following two implementation techniques in mind. def myfunc(mystring): check = "hello, there " + mystring + "!!!" print check OR structure = ["hello, there",,"!!!"] def myfunc(mystring): structure[2] = mystring output = ''.join(mystring) i heard

Re: code review

2009-12-23 Thread Jean-Michel Pichavant
Zubin Mithra wrote: Hello, I`m pretty new to developing applications using python and i would like advance on this script i recently created which helps linux programmers on the linux terminal. The code is very simple to understand(i hope) and serves a simple purpose; however i am not sure if my

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Jean-Michel Pichavant
lordofcode wrote: Hi All Not an expert in Python, so sorry if this sounds like a silly question. I went through other few threads in the mailing list but they are not helping me much. I have run into a problem related to dynamically loading and unloading a module. I need to dynamically load a mo

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: lordofcode wrote: Hi All Not an expert in Python, so sorry if this sounds like a silly question. I went through other few threads in the mailing list but they are not helping me much. I have run into a problem related to dynamically loading and unloading a module

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: But believe me, you don't want to mess up with the python import mechanism. Unless you understand how it works. Let me quote the OP: 'Not an expert in Python' I was j

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: 3/ if you really need to unload the previous module, it's a little bit tedious. import mod1 del mod1 sys.modules['mod1'] = None Assigning sys.modules[name] to None is not

Re: Problem with Dynamically unloading a module

2009-12-24 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 23 Dec 2009 15:31:53 +0100, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: But believe me, you don't want to mess up with the python i

Re: Another Sets Problem

2009-12-29 Thread Jean-Michel Pichavant
Matt Nordhoff wrote: Victor Subervi wrote: On Mon, Dec 28, 2009 at 1:41 PM, MRAB mailto:pyt...@mrabarnett.plus.com>> wrote: DON'T USE BARE EXCEPTS! (There are 2 in your code.) There are times when they are *necessary*. No, there aren't. Even if there were, this is not o

Re: Bare Excepts

2009-12-30 Thread Jean-Michel Pichavant
Victor Subervi wrote: Hi; I'll trouble-shoot bare excepts as I work on new code. I'll trouble-shoot the others that don't (seem to) cause problems later. Here's a new one: for optionsStore, storeOptions in ourOptions().iteritems(): if store == optionsStore: for option in sto

Re: Bare Excepts

2009-12-30 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Wed, Dec 30, 2009 at 9:09 AM, Victor Subervi mailto:victorsube...@gmail.com>> wrote: Anyway, you should definitely use a coding rule checker, like pylint or pyckeck. It would sometimes point you into the correct direction. For instance, pylint will tell you

Re: TypeError: can only concatenate list (not "tuple") to list

2010-01-04 Thread Jean-Michel Pichavant
Gabriel Genellina wrote: En Mon, 04 Jan 2010 05:24:56 -0300, David Williams escribió: py> [1,2,3] + (4,5) Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "tuple") to list In-place addition += does work: py> a = [1,2,3] py> a += (4,5) py

Re: Recommended "new" way for config files

2010-01-07 Thread Jean-Michel Pichavant
Peter wrote: Hi There seems to be several strategies to enhance the old ini-style config files with real python code, for example: 1) the documentation tool sphinx uses a python file conf.py that is exefile(d) , but execfile is suppressed in Python 3 2) there is a module cfgparse on sourcefo

Re: Transforming a List of elements into a List of lists of elements

2010-01-08 Thread Jean-Michel Pichavant
tiago almeida wrote: Hello all, I'd like to ask how you'd implement a function /f/ that transforms a list of elements into a list of lists of elements by grouping contiguous elements together. Examples: a=[1,2,3,4,5] print( f(a, 2) ) # -> [ [1, 2], [3, 4], [5] ] print( f(a, 3) ) # -> [ [

Re: getfirst and re

2010-01-08 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Fri, Jan 8, 2010 at 1:26 PM, Steve Holden > wrote: MRAB wrote: > Victor Subervi wrote: > [snip] >> >> Code snippet: >> >> def cgiFieldStorageToDict(fieldStorage): Fur

Re: How to validate the __init__ parameters

2010-01-11 Thread Jean-Michel Pichavant
Aahz wrote: In article , Jean-Michel Pichavant wrote: class A: def __init__(self, foo = None, bar = None): if len(foo) > 5: raise ValueError('foo cannot exceed 5 characters') Bad Idea -- what happens when foo is None? You're rig

Re: Easy Q

2010-01-11 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron mailto:gher...@islandtraining.com>> wrote: Victor Subervi wrote: Hi; I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable may be a list or a

Re: Interesting (?) problem

2010-01-11 Thread Jean-Michel Pichavant
mk wrote: Incidentally, it *seems* that list comprehension preserves order: hostips_limited = [ h for h in hostips if h in thread_results ] Empirically speaking it seems to work (I tested it on real ips), but please correct me if that's wrong. Regards, mk Sounds good to me. List are *o

Re: Interesting (?) problem

2010-01-11 Thread Jean-Michel Pichavant
mk wrote: mk wrote: Hello everyone, I have two lists of IP addresses: hostips = [ 'a', 'b', 'c', 'd', 'e' ] thread_results = [ 'd', 'b', 'c' ] I need to sort thread_results in the same order as hostips. P.S. One clarification: those lists are actually more complicated (thread_result is a

Re: Writing a string.ishex function

2010-01-14 Thread Jean-Michel Pichavant
Phlip wrote: MRAB wrote: BTW, ishex('') should return False. So should int('')! Did you mean isint('') ? JM -- http://mail.python.org/mailman/listinfo/python-list

Re: Author of a Python Success Story Needs a Job!

2010-01-14 Thread Jean-Michel Pichavant
Paul Rubin wrote: a...@pythoncraft.com (Aahz) writes: Incidentally, my company has had a fair amount of difficulty finding Python programmers -- anyone in the SF area looking for a job near Mountain View? I'm surprised there aren't a ton of Python programmers there, given that's where

Re: Changing var names

2010-01-15 Thread Jean-Michel Pichavant
Victor Subervi wrote: Hi; Well it took me *less than a day* to fix the following problems: -- bare excepts (accidentally left a couple I think) -- sql injection attacks -- recreating tables to make them more reasonable ** "Programming is an ITERATIVE proce

Re: Changing var names

2010-01-18 Thread Jean-Michel Pichavant
Victor Subervi wrote: On Fri, Jan 15, 2010 at 3:15 PM, Adam Tauno Williams mailto:awill...@opengroupware.us>> wrote: On Fri, 2010-01-15 at 13:27 -0400, Victor Subervi wrote: > Hi; > Well it took me *less than a day* to fix the following problems: > -- bare excepts (accidentally

Proper display of XMLRPCserver exceptions

2010-01-18 Thread Jean-Michel Pichavant
To all using xmlrpclib, I had trouble getting a proper display of my exceptions occuring on the server. Basically, xmlrpclib only display the exception itself without any traceback, on the client side. Something like :2"> Ok then there's a key error, but how the hell am I supposed to know w

Re: not and is not problem

2010-01-18 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 18 Jan 2010 16:43:25 +0100, superpollo wrote: hi: #!/usr/bin/env python data = "seq=123" name , value = data.split("=") print name print value if not name == "seq": print "DOES NOT PRINT OF COURSE..." if name is not "seq": print "WTF! WHY DOES IT PRI

using super

2010-01-18 Thread Jean-Michel Pichavant
class SubClass(Base): colour = "Red" def parrot(self): """docstring for Subclass""" return super(Subclass, self).parrot() I'm not a big fan of super, but I'm still wondering if >>> return super(self.__class__, self).parrot() would have made it. What if Subclass has mo

Re: using super

2010-01-18 Thread Jean-Michel Pichavant
Duncan Booth wrote: Jean-Michel Pichavant wrote: class SubClass(Base): colour = "Red" def parrot(self): """docstring for Subclass""" return super(Subclass, self).parrot() I'm not a big fan of super, but I&

Re: using super

2010-01-19 Thread Jean-Michel Pichavant
Gabriel Genellina wrote: I see. Then is there a reason why return super(Subclass, self).parrot() would be prefered over the "classic" return Base.parrot(self) ? Or is it just a matter of preference ? For a longer explanation, see: James Knight: Python's Super Considered Harmful http://fuhm

Re: how to check if a module is importable?

2010-01-20 Thread Jean-Michel Pichavant
Robert P. J. Day wrote: finally getting back to clawing my way thru the python 3 book so probably a number of newbie questions coming up. first one -- can i check if a module is importable (equivalently, exists on sys.path, i assume) without trying to import it first? i can see that i can u

Re: why the super class can access the subclass's attribute

2010-01-21 Thread Jean-Michel Pichavant
yousay wrote: I have sees aprogram like this ,i confusing why super class can access the subclass's attribute ,this is the program,thanks in advance: class MyThread(threading.Thread): def join(self): super(MyThread,self).join() return self.result class Worker(MyThread): i

Re: deleting, then re-importing a class method

2010-01-21 Thread Jean-Michel Pichavant
Robert P. J. Day wrote: (once again, never ashamed to ask the dumb questions.) still playing with python3, and testing whether i can delete/unimport a specific method, then re-import it: import sys print(sys.__doc__) ... blah blah blah ... del(sys.__doc__) print(sys.__doc_

Re: Symbols as parameters?

2010-01-21 Thread Jean-Michel Pichavant
Martin Drautzburg wrote: Hello all, When passing parameters to a function, you sometimes need a paramter which can only assume certain values, e.g. def move (direction): ... If direction can only be "up", "down", "left" or "right", you can solve this by passing strings,

Re: Symbols as parameters?

2010-01-22 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: (3) Then somone suggested to tie the constants to the function itself, as in def move(direction): print "moving %s" % direction move.UP = 'up' move.DOWN = 'down' This is quite nice. I would call it a horrible, horrible, horrible code smell. A stench in fact.

Re: Symbols as parameters?

2010-01-22 Thread Jean-Michel Pichavant
Ben Finney wrote: Jean-Michel Pichavant writes: Steven D'Aprano wrote: I would call it a horrible, horrible, horrible code smell. A stench in fact. […] As soon as it is properly documented, as a public interface should be, it becomes an acceptable design

Re: [2.5.1.1/dictionary] Change sorting order?

2010-01-22 Thread Jean-Michel Pichavant
Gilles Ganault wrote: Hello I use a dictionary to keep a list of users connected to a web site. To avoid users from creating login names that start with digits in order to be listed at the top, I'd like to sort the list differently every minute so that it'll start with the next letter, eg. disp

Re: [2.5.1.1/dictionary] Change sorting order?

2010-01-22 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Gilles Ganault wrote: Hello I use a dictionary to keep a list of users connected to a web site. To avoid users from creating login names that start with digits in order to be listed at the top, I'd like to sort the list differently every minute so that it

Re: [2.5.1.1/dictionary] Change sorting order?

2010-01-22 Thread Jean-Michel Pichavant
Gilles Ganault wrote: On Fri, 22 Jan 2010 14:09:43 +0100, Jean-Michel Pichavant wrote: Sorry, the code I provided produce this output: ['1a', 'a', 'ac', 'av', 'b', 'c'] ['a', 'ac', 'av', 'b&#

Re: [2.5.1.1/dictionary] Change sorting order?

2010-01-22 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Gilles Ganault wrote: On Fri, 22 Jan 2010 14:09:43 +0100, Jean-Michel Pichavant wrote: Sorry, the code I provided produce this output: ['1a', 'a', 'ac', 'av', 'b', 'c'] ['a', 'ac

Re: Sikuli: the coolest Python project I have yet seen...

2010-01-25 Thread Jean-Michel Pichavant
Ron wrote: Sikuli is the coolest Python project I have ever seen in my ten year hobbyist career. An MIT oepn source project, Sikuli uses Python to automate GUI tasks (in any GUI or GUI baed app that runs the JVM) by simply drag and dropping GUI elements into Python scripts as function arguments.

Re: ANN: Urwid 0.9.9.1 - Console UI Library

2010-01-25 Thread Jean-Michel Pichavant
Ian Ward wrote: Announcing Urwid 0.9.9.1 Urwid home page: http://excess.org/urwid/ Screen shots: http://excess.org/urwid/examples.html Tarball: http://excess.org/urwid/urwid-0.9.9.1.tar.gz About this release: === This maintenance release fixes

Re: Sikuli: the coolest Python project I have yet seen...

2010-01-26 Thread Jean-Michel Pichavant
Terry Reedy wrote: On 1/25/2010 9:14 AM, Javier Collado wrote: I think the site is under maintenance. I tried a couple of hours ago and it worked fine. As an alternative, I found that this link also worked: http://www.sikuli.org/ This just redirects to the link below http://sikuli.csail.mi

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