Re: Python's sad, unimaginative Enum

2013-05-13 Thread Jean-Michel Pichavant
- Original Message - > That's the title of this little beast > http://www.acooke.org/cute/Pythonssad0.html if anybody's interested. > > -- > If you're using GoogleCrap™ please read this > http://wiki.python.org/moin/GoogleGroupsPython. > > Mark Lawrence > > -- > http://mail.python.org/ma

Re: global variable not working inside function. Increment

2013-05-13 Thread Jean-Michel Pichavant
> Thank You for setting that straight. I'm just learning Python and > NONE of the tutorials I read said anything about that . In fact they > all say a global can be called from inside a Function. If possible > please contact the ppl that write these things.I've heard of > Ocam's razor but not H

Re: Python's sad, unimaginative Enum

2013-05-14 Thread Jean-Michel Pichavant
- Original Message - > On Mon, 13 May 2013 13:00:36 +0200, Jean-Michel Pichavant wrote: > > > - Original Message - > >> That's the title of this little beast > >> http://www.acooke.org/cute/Pythonssad0.html if anybody's > >&g

Re: Unicode humor

2013-05-15 Thread Jean-Michel Pichavant
> >> >> This reflects a lack of understanding of Unicode. > >> > >> >> jmf > >> > >> > And this reflects a lack of a sense of humor. :) > >> > >> Isn't that a crime in the UK? > >> > >> ChrisA > > > > The problem with English humour (as against standard humor) is that > > its not unicode compliant

Re: Unicode humor

2013-05-15 Thread Jean-Michel Pichavant
- Original Message - > On 15/05/2013 14:19, Jean-Michel Pichavant wrote: > >> >> >> This reflects a lack of understanding of Unicode. > >> >> > >> >> >> jmf > >> >> > >> >> > A

Re: Unicode humor

2013-05-15 Thread Jean-Michel Pichavant
- Original Message - > On Wed, 15 May 2013 15:19:00 +0200 (CEST) > Jean-Michel Pichavant wrote: > > > British humour includes "double entendre", which is not > > > French-compliant. > > > > I didn't get that one. Which possibly confirm

Re: python 2.7 vs 2.5

2013-05-16 Thread Jean-Michel Pichavant
- Original Message - >I am using python 2.7 to write > the cgi file and my web server is using python 2.5. The answer lies in your question. JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the inten

Re: Debugging parallel nose tests?

2013-06-12 Thread Jean-Michel Pichavant
- Original Message - > In article , > Dave Angel wrote: > > > On 05/23/2013 09:09 AM, Roy Smith wrote: > > > > > > > > > > > > nosetests --process-timeout=60 --processes=40 test_api.py > > > > > > > Do you have a 40-processor system? > > No, but many of the tests are I/O bound.

Python - remote object protocols and security

2013-07-15 Thread Jean-Michel Pichavant
Hello everyone, I'd like to exchange some simple python objects over the internet. I initially planned to use Pyro, after reading http://pythonhosted.org/Pyro4/security.html I'm still puzzled. I don't mind encrypting data, if someone wants to sniff what I'm sending, he's welcome. What I

Re: Python - remote object protocols and security

2013-07-15 Thread Jean-Michel Pichavant
In text format... sorry for my previous html post Hello everyone, I'd like to exchange some simple python objects over the internet. I initially planned to use Pyro, after reading http://pythonhosted.org/Pyro4/security.html I'm still puzzled. I don't mind encrypting data, if someone wants to

Re: Python - remote object protocols and security

2013-07-15 Thread Jean-Michel Pichavant
- Original Message - > > I don't mind encrypting data, if someone wants to sniff what I'm > > sending, he's welcome. > > > > I don't think the word you need there is "mind," but I get the idea. You're right, I wanted to state actually the opposite, I don't want to encrypt data because

Re: Python - remote object protocols and security

2013-07-15 Thread Jean-Michel Pichavant
- Original Message - > > What I think I need to care about, is malicious code injections. > > Because > > both client/server will be in python, would someone capable of > > executing > > code by changing one side python source ? > > > > How do I prevent this and still provide the source to

Re: Python - remote object protocols and security

2013-07-15 Thread Jean-Michel Pichavant
- Original Message - > On 15-7-2013 13:17, Dave Angel wrote: > > On 07/15/2013 06:20 AM, Jean-Michel Pichavant wrote: > >> In text format... sorry for my previous html post > >> > >> Hello everyone, > >> > >> I'd like to ex

Re: Understanding other people's code

2013-07-16 Thread Jean-Michel Pichavant
- Original Message - > Thanks for all the suggestions, I'm afraid I didn't get a chance to > view them over the weekend but I will get started with them this > morning. I'm currently using sublime 2 for my text editor and tried > to create a UML diagram using Pylint to try and get a map ove

Re: Conditional decoration

2012-06-19 Thread Jean-Michel Pichavant
Roy Smith wrote: Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view gets decorated with @login_required(). @login_required() def my_view(request): pass Hi, def my_view(request):

Re: fastest method

2012-06-21 Thread Jean-Michel Pichavant
david.gar...@gmail.com wrote: I am looking for the fastest way to parse a log file. currently I have this... Can I speed this up any? The script is written to be a generic log file parser so I can't rely on some predictable pattern. def check_data(data,keywords): #get rid of duplicates

Re: tiffany 0.6 released

2012-06-26 Thread Jean-Michel Pichavant
Christian Tismer wrote: Abour tiffany... On 6/25/12 3:46 AM, Christian Tismer wrote: Tiffany - Read/Write Multipage-Tiff with PIL without PIL Tiffany stands for any tiff. The tiny module solves a large set of problems, has no dependencie

Re: Slow output

2012-06-27 Thread Jean-Michel Pichavant
MRAB wrote: On 27/06/2012 18:33, subhabangal...@gmail.com wrote: Dear Group, I am Sri Subhabrata Banerjee writing from India. I am running a small program which exploits around 12 1 to 2 KB .txt files. I am using MS Windows XP Service Pack 3 and Python 2.6 where IDLE is GUI. The text is plain AS

Re: Deditor 0.4.0

2012-07-09 Thread Jean-Michel Pichavant
Kruptein wrote: Hey I released a new version of my python-focused text-editor. you can download it at http://launchpad.net/deditor What is it? Deditor is aimed to be a text-editor which can be used as a basic text-editor as gedit or with the right plugins become a full-feature ide. I focus on m

Re: Deditor 0.4.0

2012-07-09 Thread Jean-Michel Pichavant
Kruptein wrote: Op maandag 9 juli 2012 13:05:58 UTC+2 schreef Jean-Michel Pichavant het volgende: Kruptein wrote: Hey I released a new version of my python-focused text-editor. you can download it at http://launchpad.net/deditor What is it? Deditor is aimed to be a text-editor which

Re: Python Interview Questions

2012-07-10 Thread Jean-Michel Pichavant
Tim Chase wrote: On 07/09/12 19:27, Roy Smith wrote: prefer folks that know which features to check availability for deployment. Heh. Tell me, when did strings get methods? :-) IIRC, ~2.0? I'm cognizant of the shift happening from the string module to string methods, but I wo

Re: Python Interview Questions

2012-07-10 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Tue, 10 Jul 2012 11:29:24 +0200, Jean-Michel Pichavant wrote: Why would you want to hire someone that knows something pointless as the version where feature X has been introduced ? Just tell him that feature X has been introducted in version Y, costless 2

Mocked object returning another Mocked object

2012-07-13 Thread Jean-Michel Pichavant
Greetings Fellow Group, I'd need your help to fix some issues I have with my unitary tests. I'm trying to bring them to the next level by Mocking equipments controlled by my application. Despite me reading http://www.voidspace.org.uk/python/mock/index.html I cannot figure out how to do the f

Re: Intermediate Python user needed help

2012-08-06 Thread Jean-Michel Pichavant
Ethan Furman wrote: ~Ethan~ P.S. The scale I am accustomed to is Novice -> Intermediate -> Advanced -> Master Are there scales out there that would put these types of questions in the "intermediate" category? Troll -> Novice -> Intermediate -> Advanced Trolls are quite specific, they're

Re: I thought I understood how import worked...

2012-08-08 Thread Jean-Michel Pichavant
Roy Smith wrote: So, it appears that you *can* import a module twice, if you refer to it by different names! This is surprising. It means that having non-idempotent code which is executed at import time is a Bad Thing. Not exactly, it means that one module is different from another if its

Re: Is there a clever way to pass arguments

2012-08-09 Thread Jean-Michel Pichavant
bruceg113...@gmail.com wrote: Is there a way in Python to pass arguments without listing each argument? For example, my program does the following: testData (z[0], z[1], z[2], z[3], z[4], z[5], z[6], z[7]) Is there a clever way to pass arguments in a single statement knowing that each argu

Re: Is there a clever way to pass arguments

2012-08-09 Thread Jean-Michel Pichavant
Chris Angelico wrote: On Thu, Aug 9, 2012 at 7:05 PM, Jean-Michel Pichavant wrote: bruceg113...@gmail.com wrote: I cannot change the function definition. or better (imo) testData(z) and make testData handle a list (8 parameters, that's a lot of parameters). He

Re: Sharing code between different projects?

2012-08-14 Thread Jean-Michel Pichavant
andrea crotti wrote: I am in the situation where I am working on different projects that might potentially share a lot of code. I started to work on project A, then switched completely to project B and in the transiction I copied over a lot of code with the corresponding tests, and I started to

Re: something about split()???

2012-08-14 Thread Jean-Michel Pichavant
Ramchandra Apte wrote: (Much) more Pythonic solution: >>> filter(None,"|".split("|")) On 14 August 2012 15:14, Andreas Tawn > wrote: > I have a question about the split function? surpose a = "|",and when I use a.split("|") , I got the list > ['"",""

Re: Sharing code between different projects?

2012-08-16 Thread Jean-Michel Pichavant
andrea crotti wrote: 2012/8/14 Cameron Simpson : Having just skimmed this thread, one thing I haven't quite seen suggested is this: Really do make a third "utilities" project, and treat "the project" and "deploy" as separate notions. So to actually run/deploy project A's code you'd have a sh

Re: [ANNC] pybotwar-0.8

2012-08-16 Thread Jean-Michel Pichavant
Lee Harr wrote: pybotwar is a fun and educational game where players write computer programs to control simulated robots. http://pybotwar.googlecode.com/ The focus of this release is making all functionality available from the PyQt interface and making PyQt the default interface. pybotwar use

Re: Why doesn't Python remember the initial directory?

2012-08-20 Thread Jean-Michel Pichavant
kj wrote: 99.99% of Python programmers will find that there's nothing wrong with behavior [snip] Pardon my cynicism, but the general vibe from the replies I've gotten to my post (i.e. "if Python ain't got it, it means you don't need it") [snip] Don't you find there's something wrong in a

Re: How to convert base 10 to base 2?

2012-08-20 Thread Jean-Michel Pichavant
gianpy...@gmail.com wrote: On Monday, August 20, 2012 9:50:53 AM UTC+2, (unknown) wrote: Hi, as you can argue from the subject, i'm really,really new to python. What is the best way to achieve that with python? Because the syntax int('30',2) doesn't seem to work! Thank you all for t

Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)

2012-08-20 Thread Jean-Michel Pichavant
Zero Piraeus wrote: : On 17 August 2012 21:43, Steven D'Aprano wrote: There are cultures that marry five year old girls to sixty year old men, cultures that treat throwing acid in the faces of women as acceptable behaviour, cultures that allow war heroes to die of hunger and cold homeless i

Re: What do I do to read html files on my pc?

2012-08-27 Thread Jean-Michel Pichavant
mikcec82 wrote: [snip] CODE CHECK : NOT PASSED Depending on this check I have to fill a cell in an excel file with answer: NOK (if Not passed or is present), or OK (if Not passed and are not present). Thanks again for your help (and sorry for my english) Html is not a

Re: Looking for an IPC solution

2012-09-03 Thread Jean-Michel Pichavant
Laszlo Nagy wrote: There are just so many IPC modules out there. I'm looking for a solution for developing a new a multi-tier application. The core application will be running on a single computer, so the IPC should be using shared memory (or mmap) and have very short response times. But there

Re: Defining features in a list

2012-09-07 Thread Jean-Michel Pichavant
M Whitman wrote: Good Morning, I have been recently trying to define all of the features in a list but have been running into errors. I would like to define the features similar to the following print statement. Any advice would be appreciated. I'm trying to transition my output from a tex

Re: Division help in python

2012-09-07 Thread Jean-Michel Pichavant
Ramyasri Dodla wrote: Hi All, I am brand new to python. checking over basic stuff. I came across the problem while doing so. If any body aware of the problem, kindly respond me. >>> 5/10 0 >>> - 5/10 -1 The second case also should yield a 'zero' but it is giving a -1 Why should it yield '

Re: how to run python2.6 module with absolute imports stand alone

2012-09-10 Thread Jean-Michel Pichavant
Gelonida N wrote: On 09/08/2012 02:13 AM, Mark Lawrence wrote: [snip] I hope this helps http://stackoverflow.com/questions/3616952/how-to-properly-use-relative-or-absolute-imports-in-python-modules It seems the safest bet seems to be to not use relative imports. That's what I figured as

Re: AttributeError: 'list' object has no attribute 'lower'

2012-09-10 Thread Jean-Michel Pichavant
Token Type wrote: In fact, I'm guessing that's your problem. I think you're ending up with a list of lists of strings, when you think you're getting a list of strings. Thanks. You guess right. It turns out that lemma_list is a list of list, as I tested in the previous post. I of

Re: main and dependent objects

2012-09-13 Thread Jean-Michel Pichavant
- Original Message - > I am in a situation where I have a class Obj which contains many > attributes, and also contains logically another object of class > Dependent. > > This dependent_object, however, also needs to access many fields of > the > original class, so at the moment we did som

Re: main and dependent objects

2012-09-13 Thread Jean-Michel Pichavant
- Original Message - > 2012/9/13 Jean-Michel Pichavant : > > > > Nothing shocking right here imo. It looks like a classic > > parent-child implementation. > > However it seems the relation between Obj and Dependent are 1-to-1. > > Since Dependent need to a

Re: subprocess call is not waiting.

2012-09-13 Thread Jean-Michel Pichavant
- Original Message - > I have a subprocess.call which tries to download a data from a remote > server using HTAR. I put the call in a while loop, which tests to > see if the download was successful, and if not, loops back around up > to five times, just in case my internet connection has a

Re: Python presentations

2012-09-13 Thread Jean-Michel Pichavant
- Original Message - > I have to give a couple of Python presentations in the next weeks, > and > I'm still thinking what is the best approach. > > In one presentation for example I will present decorators and context > managers, and my biggest doubt is how much I should show and explain >

Re: Decorators not worth the effort

2012-09-14 Thread Jean-Michel Pichavant
- Original Message - > On Sep 14, 3:54 am, Jean-Michel Pichavant > wrote: > > I don't like decorators, I think they're not worth the mental > > effort. > > Because passing a function to a function is a huge cognitive burden? > -- > http://mail

Re: Decorators not worth the effort

2012-09-14 Thread Jean-Michel Pichavant
- Original Message - > Jean-Michel Pichavant wrote: > > > I wrote the following one, used to decorate any function that > > access > > an equipment, it raises an exception when the timeout expires. The > > timeout is adapted to the platform, ASIC of FPGA s

Re: Decorators not worth the effort

2012-09-14 Thread Jean-Michel Pichavant
- Original Message - > On Fri, 14 Sep 2012 15:22:26 +0200, Jean-Michel Pichavant wrote: > > > Here's Steven example: > > > > # Untested! > > def timeout(t=15): > > # Decorator factory. Return a decorator to actually do the > > work.

Re: Decorators not worth the effort

2012-09-17 Thread Jean-Michel Pichavant
- Original Message - > Jean-Michel Pichavant wrote: [snip] > One minor note, the style of decorator you are using loses the > docstring > (at least) of the original function. I would add the > @functools.wraps(func) > decorator inside your decorator. Is there a wa

Re: How to use __getattr__ to the current module, for automatically add attributes of the real-time

2012-09-18 Thread Jean-Michel Pichavant
- Original Message - > Want to work so: > > import sys > class Foo(object): > def __getattr__(self, t): >print 'use __getattr__ - ', t >return type(t, (object,), {}) > def funct1(self): pass > def funct2(self): pass > > sys.modules[__name__] = Foo() > ttt('yy')

Re: Decorators not worth the effort

2012-09-19 Thread Jean-Michel Pichavant
- Original Message - > Jean-Michel Pichavant writes: > > > - Original Message ----- > >> Jean-Michel Pichavant wrote: > > [snip] > >> One minor note, the style of decorator you are using loses the > >> docstring > >>

Re: keeping information about players around

2012-09-24 Thread Jean-Michel Pichavant
- Original Message - > ytHello all: > I've asked for a couple code reviews lately on a mud I've been > working > on, to kind of help me with ideas and a better design. > > I have yet another design question. > In my mud, zones are basically objects that manage a collection of > rooms; For

Re: keeping information about players around

2012-09-24 Thread Jean-Michel Pichavant
- Original Message - > >Pickle everything, use sqllite for your database. When you get > >things > working, then you can start measuring your performances and think > >about > clever implementation > That was a bunch of information; sorry about that. what do you mean > by > using sqlite for

Re: keeping information about players around

2012-09-25 Thread Jean-Michel Pichavant
- Original Message - > PHPMyAdmin? Might I ask why? This is a mud, so it's all command > based, > so that's not even a question, but I'm kind of curious how PHPMyAdmin > factors in there. It's a database creation tool from all I've ever > seen > of it, to define tables. Also, using it requi

Re: Who's laughing at my responses, and who's not?

2012-09-25 Thread Jean-Michel Pichavant
- Original Message - > On 9/24/2012 10:43 PM, Dwight Hutto wrote: > > It sounds pretentious, but over the past several days, I've been > > slammed on every post almost. All because of an argument over me > > not > > posting a little context in a conversation, that seemed short and > > cha

Re: How to export a logging level?

2012-09-25 Thread Jean-Michel Pichavant
- Original Message - > In my application I import a module and I want to set the same > logging > level > as the main app to this module. > > I've tried this code > > main.py > > import logging > logger = logging.getLogger(__name__) > lvl = logging.DEBUG > LOG_FORMAT = "%(asctime)-6s %(l

Re: Fastest template engine

2012-09-26 Thread Jean-Michel Pichavant
- Original Message - > > The post has been updated with the following template engines added > (per community request): > > 1. chameleon > 2. django > 3. web2py > > Here is a link: > > http://mindref.blogspot.com/2012/07/python-fastest-template.html > > Comments or suggestions are welc

Re: Fastest template engine

2012-09-26 Thread Jean-Michel Pichavant
- Original Message - > - Original Message - > > > > The post has been updated with the following template engines added > > (per community request): > > > > 1. chameleon > > 2. django > > 3. web2py > > > > Here is a link: > > > > http://mindref.blogspot.com/2012/07/python-fast

Re: How to get progress in python script.

2012-09-28 Thread Jean-Michel Pichavant
- Original Message - > Hi all, > > Please, I need you suggest me a way to get statistics about a > progress > of my python script. My python script could take a lot of time > processing a file, so I need a way that an external program check the > progress of the script. My first idea was t

Re: design question:game skill system

2012-10-03 Thread Jean-Michel Pichavant
- Original Message - > Hello all: > I'm looking at a skill/perk system, where the player builds up his > char > by using perk points to add abilities. > Each perk is under a category, and generally costs go up as you > increase > the perk. > So I'm trying to figure something out; first, I

Generating C++ code

2012-10-09 Thread Jean-Michel Pichavant
Greetings, I'm trying to generate C++ code from an XML file. I'd like to use a template engine, which imo produce something readable and maintainable. My google search about this subject has been quite unsuccessful, I've been redirected to template engine specific to html mostly. Does anybody k

Re: Generating C++ code

2012-10-10 Thread Jean-Michel Pichavant
- Original Message - > On Tue, 09 Oct 2012 20:55:48 +0100 > Andrea Crotti wrote: > > > On 10/09/2012 05:00 PM, Jean-Michel Pichavant wrote: > > > Greetings, > > > > > > I'm trying to generate C++ code from an XML file. I'd like to use

Re: Generating C++ code

2012-10-10 Thread Jean-Michel Pichavant
> sorry but i don't get what you mean with a "MIPS on a SOC". Is not > Python well supported on MIPS ? Sorry, SOC means system on chip. The binary runs on the MIPS, there's no file system, no operanding system, except for one very basic task scheduler. That's why everything is done at compile t

Re: Generating C++ code

2012-10-10 Thread Jean-Michel Pichavant
- Original Message - > On 2012-10-10, Etienne Robillard wrote: > > On Wed, 10 Oct 2012 11:59:50 +0200 (CEST) > > Jean-Michel Pichavant wrote: > > > >> Well, the C++ code will end up running on a MIPS on a SOC, > >> unfortunately, python is not an op

Re: how to insert random error in a programming

2012-10-15 Thread Jean-Michel Pichavant
- Original Message - > how to insert random error in a programming? > -- > http://mail.python.org/mailman/listinfo/python-list > Here's an example from random raise Except(randome.randinteger(0,10,'error']): return -- http://mail.python.org/mailman/listinfo/python-list

Re: how to insert random error in a programming

2012-10-15 Thread Jean-Michel Pichavant
- Original Message - [snip a huge list of advices example and insights] > Then list the description on the homework > assignment. > > -- > > DaveA Like the youngsters write: "/bow" JM -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the tidy/elegant way to protect this against null/empty parameters?

2012-10-16 Thread Jean-Michel Pichavant
- Original Message - > I want to fix an error in some code I have installed, however I don't > really want to just bodge it. > > The function producing the error is:- > > def get_text(self, idx): # override ! > node = self.items[idx] > > a= [ >

Re: OT Questions

2012-10-16 Thread Jean-Michel Pichavant
- Original Message - [snip a link to a 1980's personal gif based homepage] > Now having said all of that, if this is a troll, I feel rather > foolish. Search deep inside your heart, and you'll realize you already know the answer to that question :o) JM -- http://mail.python.org/mailma

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Jean-Michel Pichavant
- Original Message - > On 2012-10-18, Zero Piraeus wrote: > > > What are people's preferred strategies for dealing with lines that > > go > > over 79 characters? A few I can think of off the bat: > > I try to do what's easiest to read and understand. Sometimes that > means using a line

Re: A desperate lunge for on-topic-ness

2012-10-19 Thread Jean-Michel Pichavant
- Original Message - [snipe 80 char line discussion] > And, quite frankly, people who care more about the readability of > their > code than about squeezing in as much processing into a single line of > text as possible. > As usual Steven, you take someone's argument, you add a little

Re: can we append a list with another list in Python ?

2012-10-23 Thread Jean-Michel Pichavant
- Original Message - > Thankyou.. but my problem is different than simply joining 2 lists > and it is done now :) A lot of people though you were asking for joining lists, you description was misleading. I'll take a guess: you want to flatten a list of list. "Nested" list comprehe

Re: ANN: Urwid 1.1.0 - Usability and Documentation

2012-10-28 Thread Jean-Michel Pichavant
- Original Message - > Announcing Urwid 1.1.0 > -- > > Urwid home page: > http://excess.org/urwid/ > > Manual: > http://excess.org/urwid/docs/ > > Package: > http://pypi.python.org/pypi/urwid/1.1.0 > > [snip] Hi, I just had a look at it. Amazing job. JM

Re: Immutability and Python

2012-10-29 Thread Jean-Michel Pichavant
- Original Message - > I have a philosofical doubt about immutability, that arised while > doing > the SCALA functional programming course. > > Now suppose I have a simple NumWrapper class, that very stupidly > does: > > class NumWrapper(object): > def __init__(self, number): >

Re: Immutability and Python

2012-10-29 Thread Jean-Michel Pichavant
- Original Message - > 2012/10/29 Jean-Michel Pichavant : > > > > "return NumWrapper(self.number + 1) " > > > > still returns a(nother) mutable object. > > > > So what's the point of all this ? > > > > JM > > > &

Re: calling one staticmethod from another

2012-10-30 Thread Jean-Michel Pichavant
- Original Message - [snip] > I haven't figured out the justification for staticmethod, http://en.wikipedia.org/wiki/Namespace + "Namespaces are one honking great idea -- let's do more of those!" Someone may successfully use only modules as namespaces, but classes can be used as well.

Passing functions as parameter (multiprocessing)

2012-11-13 Thread Jean-Michel Pichavant
Fellows, I'm having problems understanding an issue with passing function as parameters. I'm sending some functions to the multiprocessing module (python 2.5 with the proper backport). I'm iterating on a list of functions, however it seems that only the last function implementation is used for

Re: Passing functions as parameter (multiprocessing)

2012-11-13 Thread Jean-Michel Pichavant
- Original Message - > Oscar Benjamin wrote: > > > I don't know if this is to do with the way that the code was > > simplified before posting but this subproc function wrapper does > > nothing (even after Peter fixed it below). This code is needlessly > > complicated for what it does. > >

Re: Python-list Digest, Vol 110, Issue 106

2012-11-15 Thread Jean-Michel Pichavant
- Original Message - > Hi, > I have a question about Django. I easy_installed Django1.4 and > psycopg2, and python manage.py syncdb. And gave me a error; No > module named psycopg2.extensions. posgre9.1 is installed. > It works fine on my MAC but not my Windows. Does anyone know about > t

Re: Python Interview Questions

2012-11-20 Thread Jean-Michel Pichavant
- Original Message - > Use a set when you want to represent a collection of items and the > order > is not important: An important feature of sets is that their items are unique. set(list(...)) is a good shortcut to remove duplicate in a list. JM -- IMPORTANT NOTICE: The contents of

Re: amazing scope?

2012-11-30 Thread Jean-Michel Pichavant
- Original Message - > I wrote a script, refactored it and then introducing a bug as below: > > def record_things(): > out.write("Hello world") > > if __name__ == '__main__': > with open('output', 'w') as out: > record_things() > > > but the shocking thing is that it did

Re: amazing scope?

2012-11-30 Thread Jean-Michel Pichavant
- Original Message - > 2012/11/30 andrea crotti : > > Already changing it to: > > def record_things(): > out.write("Hello world") > > def main(): > with open('output', 'w') as out: > record_things() > > if __name__ == '__main__': > main() > > makes it stops workin

Re: amazing scope?

2012-11-30 Thread Jean-Michel Pichavant
- Original Message - > Well I knew that this works fine, even if I feel a bit guilty to do > this, and better is: > > foo = 'bar' if some_condition else 'baz' > > Anyway for me the suprise is that something that is defined *later* > at > the module scope is found in a function which is de

Re: New tutorials

2012-12-03 Thread Jean-Michel Pichavant
- Original Message - > Hi everyone, I'm making a series of python tutorials and I've just > finished the introductory part: http://lightbird.net/larks/intro.html > > Feedback is appreciated.. - mitya > > -- > http://mail.python.org/mailman/listinfo/p

Re: Working with classes

2012-12-04 Thread Jean-Michel Pichavant
- Original Message - > Hello, I've been working on this program for a long time but can't > seem to get it to work.. The first array is the input file, then a > class, another class and the actual program. Could anyone see what > is wrong? I'm sorry if the program doesn't make any sense at

Re: New tutorials

2012-12-06 Thread Jean-Michel Pichavant
- Original Message - > On 12/02/2012 09:54 AM, Mitya Sirenef wrote: > > Hi everyone, I'm making a series of python tutorials and I've just > > finished the introductory part: > > http://lightbird.net/larks/intro.html > > > > Feedback is appreciated.. - mitya > >

Re: A question about readability

2012-12-10 Thread Jean-Michel Pichavant
- Original Message - > On Dec 7, 6:46 pm, Marco wrote: > > Hi all, do you think this code: > > > > $ more myscript.py > > for line in open('data.txt'): > >      result = sum(int(data) for data in line.split(';')) > >      print(result) > > > > that sums the elements of the lines of this

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

2012-12-11 Thread Jean-Michel Pichavant
- Original Message - > Thesaurus: A different way to call a dictionary. > > Thesaurus is a new a dictionary subclass which allows calling keys as > if they are class attributes and will search through nested objects > recursively when __getitem__ is called. > > You will notice that the

Re: forking and avoiding zombies!

2012-12-11 Thread Jean-Michel Pichavant
- Original Message - > So I implemented a simple decorator to run a function in a forked > process, as below. > > It works well but the problem is that the childs end up as zombies on > one machine, while strangely > I can't reproduce the same on mine.. > > I know that this is not the per

Re: PyWart: Module access syntax

2013-01-15 Thread Jean-Michel Pichavant
> > Please explain how this is a problem. As Steven said, there is NO > > > > useful difference. I don't *care* whether it's a package, a module, > > or > > > > whatever. Module with class with static member? Fine. Package with > > > > module with class? Also fine. Imported special object that u

Any built-in ishashable method ?

2013-01-18 Thread Jean-Michel Pichavant
Hello people, Is there any built-in way to know if an object is a valid dictionary key ? From what I know, the object must be hashable, and from the python doc, an object is hashable if it has the __hash__ and (__cmp__ or __eq__) methods. http://docs.python.org/2/glossary.html#term-hashable I

Re: Any built-in ishashable method ?

2013-01-18 Thread Jean-Michel Pichavant
> So I'm guessing you had a key where > > key1 == key2 did not imply hash(key1) == hash(key2) > > I don't see a way to avoid that problem in a look-before-you-leap > test. > > -- > http://mail.python.org/mailman/listinfo/python-list > You guessed right. But it took me a lot of time before ju

Re: Any built-in ishashable method ?

2013-01-18 Thread Jean-Michel Pichavant
> The flaw would be key1 == key2 and hash(key1) != hash(key2). Then the > set/dict could store equal items multiple times in different places > (unless it did a linear search of all members, which would make > hashing > pointless!). > > -- > Terry Jan Reedy My understanding of a hash function was

Re: Understanding while...else...

2013-01-23 Thread Jean-Michel Pichavant
- Original Message - > Several people have trouble understanding Python's while-else and > for-else constructs. It is actually quite simple agreed on the last part. [snip long story] Did you just try to make it simple by showing the compiled code ? I'm quite not sure about that... JM

Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Jean-Michel Pichavant
- Original Message - > > - Original Message - > > > In the code below I am trying to read 2 files f1 and f2 , extract > > some data from them and then trying to write them into a single > > file > > that is 'nf'. > > [snip code] > > > I think my code is not so correct , as I am

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Jean-Michel Pichavant
- Original Message - > why [os.path.join(r'E:\Python', name) for name in []] returns [] ? > please explain it in detail ! > -- > http://mail.python.org/mailman/listinfo/python-list > You're mapping an empty list. "for name in []" JM -- IMPORTANT NOTICE: The contents of this email an

Re: Distributing methods of a class across multiple files

2012-01-25 Thread Jean-Michel Pichavant
lh wrote: Is this possible please? I have done some searching but it is hard to narrow down Google searches to this question. What I would like to do is, for example: 1) define a class Foo in file test.py... give it some methods 2) define a file test2.py which contains a set of methods that are

Re: import fails in non-interactive interpreter

2012-01-26 Thread Jean-Michel Pichavant
Brian wrote: I've been banging my head against this for the past hour, and I'm hoping someone here can set me straight. [Snip] but, using the same same python, I'm able to import the module from the interactive interpreter. The PATH and PYTHONPATH environment variables are identical in both

Re: import fails in non-interactive interpreter

2012-01-26 Thread Jean-Michel Pichavant
lib/python2.7 directory. Thanks again, Brian On Thu, Jan 26, 2012 at 5:58 AM, Jean-Michel Pichavant wrote: Brian wrote: I've been banging my head against this for the past hour, and I'm hoping someone here can set me straight. [Snip] but, using the s

Re: Disable use of pyc file with no matching py file

2012-01-31 Thread Jean-Michel Pichavant
Terry Reedy wrote: On 1/30/2012 4:30 PM, Roy Smith wrote: Every so often (typically when refactoring), I'll remove a .py file and forget to remove the corresponding .pyc file. If I then import the module, python finds the orphaned .pyc and happily imports it. Usually leading to confusing and ha

Re: Disable use of pyc file with no matching py file

2012-01-31 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Tue, 31 Jan 2012 11:26:10 +0100, Jean-Michel Pichavant wrote: Terry Reedy wrote: On 1/30/2012 4:30 PM, Roy Smith wrote: Every so often (typically when refactoring), I'll remove a .py file and forget to remove the corresponding .pyc file.

Re: Disable use of pyc file with no matching py file

2012-02-01 Thread Jean-Michel Pichavant
Terry Reedy wrote: On 1/31/2012 9:19 AM, Jean-Michel Pichavant wrote: A: "My wheel is flat" B: "Buy a new car" A better analogy would be Q. "How do I make my old model car do something (it cannot do)?" A. "Get the free new model that has that feature add

  1   2   3   4   5   6   7   8   9   10   >