Re: [Tutor] Accessing query results html frame :The solution

2011-02-15 Thread Karim
On 02/14/2011 01:41 PM, Karim wrote: Hello, As I get no response from the tutor python list, I am continuing to investigate my problem. In fact the issue is that there are 2 forms in the interactive page and my request does nothing instead I get the interactive page not the submission I ask

Re: return an object of a different class

2011-02-15 Thread Ben Finney
s...@uce.gov writes: > > Perhaps you want those classes to inherit from your base class. Have > > you done the Python tutorial? It covers inheritance and how to use > > it. > > Yes, I have done subclasing before, and yes ThingyTypeA and B should > be subclassing Thingy Then your example still giv

Re: return an object of a different class

2011-02-15 Thread spam
I didn't explain my problem, chose a terrible example. This is more what I'm trying to do: Basically the subclass I want to use is based on some of the data I extract from a blob of data. If I use a function to extract the data before I create the objects, then I need to do a bunch of assignme

Re: Is this a bug of str.join?

2011-02-15 Thread Stefan Behnel
fireinice, 16.02.2011 07:32: On Feb 16, 1:24 am, fireinice wrote: Hi, all I'm just working around to generate some fake file for parsing. and I notice some weired thing happen. time = str(random.randint(1000, )) s_id = str(random.randint(1000, 9

Re: Is this a bug of str.join?

2011-02-15 Thread Stefan Behnel
fireinice, 16.02.2011 07:24: Hi, all I'm just working around to generate some fake file for parsing. and I notice some weired thing happen. time = str(random.randint(1000, )) s_id = str(random.randint(1000, )) p_id = str(rando

Re: Is this a bug of str.join?

2011-02-15 Thread fireinice
On Feb 16, 1:24 am, fireinice wrote: > Hi, all > I'm just working around to generate some fake file for parsing. and I > notice some weired thing happen. >     time = str(random.randint(1000, )) >     s_id = str(random.randint(1000, )) >    

Python GUI Tkinter Button arrangement

2011-02-15 Thread Ganesh Kumar
Hi.. I am new to python , i have creating one application user agreement..using Tkinter, The Content of the agreement will reading one file...Agree button will click means enable next button. And activate script, Quit button for exit the program,, Dis agree means one warning message will show up

Is this a bug of str.join?

2011-02-15 Thread fireinice
Hi, all I'm just working around to generate some fake file for parsing. and I notice some weired thing happen. time = str(random.randint(1000, )) s_id = str(random.randint(1000, )) p_id = str(random.randint(1000, 99

Python-GUI Button arrangement Help

2011-02-15 Thread Bugcy 013
Dear all, I am new to python programming, I am developing some small application, user agreement using Tkinter , totally my application having four buttons AGREE, DISAGREE , QUIT ,NEXT. AGREE--->>Enable the Next Button DISAGREE--->> One Waring message will show up yes are no QUIT >> Quit the ap

Re: return an object of a different class

2011-02-15 Thread Ben Finney
s...@uce.gov writes: > I didn't explain my problem, chose a terrible example. This is more > what I'm trying to do: Unfortunately, it's still very contrived, and the names don't give any suggestion as to what you're trying to achieve. Can you improve on that? > class ThingyTypeA: > def __init_

Re: floating point woes

2011-02-15 Thread Mel
Hans-Peter Jansen wrote: > Hi, > > while I usually cope with the woes of floating point issues, this is > one, that I didn't expect: > round(2.385, 2) > 2.3799 > > Doesn't the docs say, it's rounded up for this case? > > > Values are rounded to the closest multiple of 10 to t

Re: Missing SIGCHLD

2011-02-15 Thread Adam Skutt
On Feb 15, 1:28 pm, Dan Stromberg wrote: > *ix signals have historically been rather unreliable and troublesome > when used heavily. > > There are BSD signals, SysV signals, and POSIX signals - they all try > to solve the problems in different ways. No, there are just signals[1]. There are sever

Re: return an object of a different class

2011-02-15 Thread spam
I didn't explain my problem, chose a terrible example. This is more what I'm trying to do: class thingy: def __init__(self, athingy): self.basic_extract() if self.typeof = A .../... def basic_extract(self): # complicated logic to extract data out of the thingy here

Re: return an object of a different class

2011-02-15 Thread spam
On 11-02-15 07:45 PM, alex23 wrote: Firstly, does MyNumbers _have_ to be a class? Or would a function acting as a class factory be sufficient? Yes it does. I didn't explain my problem, chose a terrible example. This is more what I'm trying to do: class thingy: def __init__(self, athingy):

Re: return an object of a different class

2011-02-15 Thread Richard Thomas
On Feb 16, 2:23 am, s...@uce.gov wrote: > How can I do something like this in python: > > #!/usr/bin/python3.1 > > class MyNumbers: >    def __init__(self, n): >      self.original_value = n >      if n <= 100: >        self = SmallNumers(self) >      else: >        self = BigNumbers(self) > > clas

unicode shutil.copy() changes a file name during copy?

2011-02-15 Thread dave
i'm on windows, using active python 2.7.1 i've written a script to copy a folder of files to dest folder.. one if the files in this folder has the section symbol (§, '\x15') as part of the file name shutil.copy(src_file, dst_file) "can't find the file specified" when it does the os.chmod() part,

Re: floating point woes

2011-02-15 Thread Grant Edwards
On 2011-02-16, Hans-Peter Jansen wrote: > Thanks for the explanation, Benjamin. Not that I like it, but anyway. > If I hadn't quitted smoking a long time ago, I would go and ask, what > these engineers smoked during the course of inventing this sh*t. Like most tools, IEEE floating point works br

Re: floating point woes

2011-02-15 Thread Grant Edwards
On 2011-02-16, Ian Kelly wrote: > On Tue, Feb 15, 2011 at 4:49 PM, Hans-Peter Jansen wrote: >> >> while I usually cope with the woes of floating point issues, this is >> one, that I didn't expect: >> > round(2.385, 2) >> 2.3799 >> >> Doesn't the docs say, it's rounded up for this

Re: interleave string

2011-02-15 Thread alex23
Andrea Crotti wrote: > At the moment I have this ugly inliner >         interleaved = ':'.join(orig[x:x+2] for x in range(0, len(orig), 2)) I actually prefer this over every other solution to date. If you feel its too much behaviour in one line, I sometimes break it out into separate values to pr

Re: logging module -- better timestamp accuracy on Windows

2011-02-15 Thread Ross Ridge
benhoyt wrote: >This works, but as you can see, it's a bit hacky. Is there a better way to = >fix it? (I'd like the fix to affect all loggers, including the root logger.= >) A simpler solution would be to caclulate the time it takes to the handle the request using time.clock() and include it in

Re: return an object of a different class

2011-02-15 Thread aitilang
er I think you need a NumberFactory that makes SmallNumber and BigNumber according to the initial value. ?? 2011-2-16 10:23, s...@uce.gov : How can I do something like this in python: #!/usr/bin/python3.1 class MyNumbers: def __init__(self, n): self.original_value =

Re: return an object of a different class

2011-02-15 Thread alex23
alex23 wrote: >     self.__class__ = BigNumbers if n > 100 else SmallThing That should, of course, be SmallNumbers :) -- http://mail.python.org/mailman/listinfo/python-list

Re: return an object of a different class

2011-02-15 Thread alex23
On Feb 16, 12:23 pm, s...@uce.gov wrote: > How can I do something like this in python: > > #!/usr/bin/python3.1 > > class MyNumbers: >    def __init__(self, n): >      self.original_value = n >      if n <= 100: >        self = SmallNumers(self) >      else: >        self = BigNumbers(self) > > cla

Re: return an object of a different class

2011-02-15 Thread Ben Finney
s...@uce.gov writes: > How can I do something like this in python: > > #!/usr/bin/python3.1 > > class MyNumbers: > def __init__(self, n): > self.original_value = n > if n <= 100: > self = SmallNumers(self) > else: > self = BigNumbers(self) A class defines a type of objec

Re: return an object of a different class

2011-02-15 Thread MRAB
On 16/02/2011 02:23, s...@uce.gov wrote: How can I do something like this in python: #!/usr/bin/python3.1 class MyNumbers: def __init__(self, n): self.original_value = n if n <= 100: self = SmallNumers(self) else: self = BigNumbers(self) class SmallNumbers: def __in

return an object of a different class

2011-02-15 Thread spam
How can I do something like this in python: #!/usr/bin/python3.1 class MyNumbers: def __init__(self, n): self.original_value = n if n <= 100: self = SmallNumers(self) else: self = BigNumbers(self) class SmallNumbers: def __init__(self, n): self.size = 'small' cl

Re: floating point woes

2011-02-15 Thread Hans-Peter Jansen
On Wednesday 16 February 2011, 01:24:59 Chris Rebert wrote: > On Tue, Feb 15, 2011 at 4:09 PM, Chris Rebert wrote: > > On Tue, Feb 15, 2011 at 3:49 PM, Hans-Peter Jansen wrote: > >> Hi, > >> > >> while I usually cope with the woes of floating point issues, this > >> is > >> > >> one, that I did

Re: floating point woes

2011-02-15 Thread Hans-Peter Jansen
On Wednesday 16 February 2011, 01:06:08 Benjamin Kaplan wrote: > On Tue, Feb 15, 2011 at 6:49 PM, Hans-Peter Jansen wrote: > > Hi, > > > > while I usually cope with the woes of floating point issues, this > > is > > > > one, that I didn't expect: > round(2.385, 2) > > > > 2.3799

Re: floating point woes

2011-02-15 Thread Chris Rebert
On Tue, Feb 15, 2011 at 4:09 PM, Chris Rebert wrote: > On Tue, Feb 15, 2011 at 3:49 PM, Hans-Peter Jansen wrote: >> Hi, >> >> while I usually cope with the woes of floating point issues, this is >> one, that I didn't expect: >> > round(2.385, 2) >> 2.3799 >> >> Doesn't the docs sa

Re: floating point woes

2011-02-15 Thread Chris Rebert
On Tue, Feb 15, 2011 at 3:49 PM, Hans-Peter Jansen wrote: > Hi, > > while I usually cope with the woes of floating point issues, this is > one, that I didn't expect: > round(2.385, 2) > 2.3799 > > Doesn't the docs say, it's rounded up for this case? > > > Values are rounded to th

Re: floating point woes

2011-02-15 Thread Ian Kelly
On Tue, Feb 15, 2011 at 4:49 PM, Hans-Peter Jansen wrote: > Hi, > > while I usually cope with the woes of floating point issues, this is > one, that I didn't expect: > round(2.385, 2) > 2.3799 > > Doesn't the docs say, it's rounded up for this case? > > > Values are rounded to th

Re: floating point woes

2011-02-15 Thread Benjamin Kaplan
On Tue, Feb 15, 2011 at 6:49 PM, Hans-Peter Jansen wrote: > Hi, > > while I usually cope with the woes of floating point issues, this is > one, that I didn't expect: > round(2.385, 2) > 2.3799 > > Doesn't the docs say, it's rounded up for this case? > > > Values are rounded to th

Re: floating point woes

2011-02-15 Thread Westley Martínez
On Wed, 2011-02-16 at 00:49 +0100, Hans-Peter Jansen wrote: > Hi, > > while I usually cope with the woes of floating point issues, this is > one, that I didn't expect: > > >>> round(2.385, 2) > 2.3799 > > Doesn't the docs say, it's rounded up for this case? > > > Values are rounde

Re: Extending classes __init__behavior for newbies

2011-02-15 Thread Westley Martínez
On Tue, 2011-02-15 at 14:16 -0800, rantingrick wrote: > On Feb 14, 9:44 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: > > On Tue, 15 Feb 2011 09:47:54 +1000, James Mills wrote: > > > On Tue, Feb 15, 2011 at 9:32 AM, rantingrick > > > wrote: > > >> Those who write code bases should "

Re: floating point woes

2011-02-15 Thread André Roberge
On Tuesday, February 15, 2011 7:49:34 PM UTC-4, Hans-Peter Jansen wrote: > Hi, > > while I usually cope with the woes of floating point issues, this is > one, that I didn't expect: > > >>> round(2.385, 2) > 2.3799 > > Doesn't the docs say, it's rounded up for this case? The problem

Map vs. List Comprehensions (was "lint warnings")

2011-02-15 Thread Gerald Britton
Generally, I prefer map() over list comprehensions since they are more succinct and run faster for non-trivial examples. However, I've been considering another use case related to functions in the operator module. Here are some examples: [x.method() for x in data] [x[0] for x in data] [x.attr fo

floating point woes

2011-02-15 Thread Hans-Peter Jansen
Hi, while I usually cope with the woes of floating point issues, this is one, that I didn't expect: >>> round(2.385, 2) 2.3799 Doesn't the docs say, it's rounded up for this case? Values are rounded to the closest multiple of 10 to the power minus n; if two multiples are equally

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Chris Rebert
On Tue, Feb 15, 2011 at 1:29 PM, Emile van Sebille wrote: > On 2/15/2011 10:19 AM Chris Rebert said... >> On Tue, Feb 15, 2011 at 7:17 AM, Jorge Vargas >>  wrote: >>> I have the following situation. In a big project that involves many >>> dependencies (and sadly some sys.module hacks) we have a b

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread python
Jorge, It's been a while since I felt the need to use a Python debugger, but I could swear that most (all?) Python debuggers allow you to watch a specific variable. Check out the debuggers on the following page: http://wiki.python.org/moin/PythonDebuggers Malcolm -- http://mail.python.org/mailm

Re: Extending classes __init__behavior for newbies

2011-02-15 Thread rantingrick
On Feb 15, 4:16 pm, rantingrick wrote: > # In Code form. > if (dev.design_time + dev.test_time) < dev.write_time: >     print('Good Job Skippy!') > else: >     raise ScriptKiddieError Oops, you see what i mean!!! :-) if (dev.design_time + dev.test_time) > dev.write_time:     print('Good Job Sk

Re: Extending classes __init__behavior for newbies

2011-02-15 Thread rantingrick
On Feb 14, 9:44 pm, Steven D'Aprano wrote: > On Tue, 15 Feb 2011 09:47:54 +1000, James Mills wrote: > > On Tue, Feb 15, 2011 at 9:32 AM, rantingrick > > wrote: > >> Those who write code bases should "design-in" practicality, re- > >> usability, and extendability as a forethought and NOT an aftert

Re: Problem w/ MySQLdb

2011-02-15 Thread Victor Subervi
It's been too long since I've worked on this. Yep, I forgot to commit. Thanks, Beno On Tue, Feb 15, 2011 at 5:21 PM, Jerry Hill wrote: > On Tue, Feb 15, 2011 at 3:24 PM, Victor Subervi > wrote: > > It builds the table but fails from the first insertion. Trying to insert > > using that code dire

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Mel
Emile van Sebille wrote: > Out of curiosity, if it's immutable, what approach might you try to > capture/trace reassignment? I've got a toy tracer that breaks with > simple assignment: AFAIK you'd have to replace the namespace dictionaries with dictionary-like things that would react to rebindi

Re: How can I define __getattr__ to operate on all items of container and pass arguments?

2011-02-15 Thread Jeremy
On Tuesday, February 15, 2011 1:44:55 PM UTC-7, Chris Rebert wrote: > On Tue, Feb 15, 2011 at 12:29 PM, Jeremy wrote: > > I have a container object.  It is quite frequent that I want to call a > > function on each item in the container.  I would like to do this whenever I > > call a function on

Re: lint warnings

2011-02-15 Thread Steven D'Aprano
On Tue, 15 Feb 2011 14:32:13 +, Duncan Booth wrote: > >> Also, as already shown, the map version is faster. > > In most cases the list comprehension is faster. Try timing it. For an extremely specialised and minimal definition of "most cases". > C:\Python27>python.exe lib\timeit.py -s "de

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Emile van Sebille
On 2/15/2011 10:19 AM Chris Rebert said... On Tue, Feb 15, 2011 at 7:17 AM, Jorge Vargas wrote: Hello, I have the following situation. In a big project that involves many dependencies (and sadly some sys.module hacks) we have a bug, and it will really help if i could monitor all changes made t

Re: Problem w/ MySQLdb

2011-02-15 Thread Jerry Hill
On Tue, Feb 15, 2011 at 3:24 PM, Victor Subervi wrote: > It builds the table but fails from the first insertion. Trying to insert > using that code directly in MySQL does indeed work. Why? In what way does it fail? Does it give you a stack trace, and if so, what does it say? Does it create the

Re: Extending classes __init__behavior for newbies

2011-02-15 Thread James Mills
On Tue, Feb 15, 2011 at 1:44 PM, Steven D'Aprano wrote: > I don't. If you (generic you) have separate "write the code" and "test > the code" phases, your project is in trouble. You can probably get away > with it if it's a tiny throw-away script, but for anything more > substantial, you should be

Re: How can I define __getattr__ to operate on all items of container and pass arguments?

2011-02-15 Thread Steven D'Aprano
On Tue, 15 Feb 2011 12:29:36 -0800, Jeremy wrote: > def __getattr__(self, name): > for I in self.items: > # How can I pass arguments to I.__dict__[name]? > I.__dict__[name] The same way you would pass arguments to any other function: with function call syntax.

Re: How can I define __getattr__ to operate on all items of container and pass arguments?

2011-02-15 Thread MRAB
On 15/02/2011 20:29, Jeremy wrote: I have a container object. It is quite frequent that I want to call a function on each item in the container. I would like to do this whenever I call a function on the container that doesn't exist, i.e., the container would return an attribute error. For e

Re: Problem w/ MySQLdb

2011-02-15 Thread MRAB
On 15/02/2011 20:24, Victor Subervi wrote: Hi; I have a function that calls the following class: #!/usr/bin/python import sys,os sys.path.append(os.getcwd()) import MySQLdb from login import login import re, string def buildTableColorShortOptions(): user, passwd, db, host = login() datab

Re: How can I define __getattr__ to operate on all items of container and pass arguments?

2011-02-15 Thread Chris Rebert
On Tue, Feb 15, 2011 at 12:29 PM, Jeremy wrote: > I have a container object.  It is quite frequent that I want to call a > function on each item in the container.  I would like to do this whenever I > call a function on the container that doesn't exist, i.e., the container > would return an att

logging module -- better timestamp accuracy on Windows

2011-02-15 Thread benhoyt
The Python logging module calls time.time() in LogRecord.__init__ to fetch the timestamp of the log record. However, time.time() isn't particularly accurate on Windows. We're logging start and end of our requests in our web server, which can be milliseconds apart, and the log timestamps often sh

Re: file find skips first letter

2011-02-15 Thread Tim Chase
On 02/15/2011 12:32 PM, Wanderer wrote: if f.find(fileBase)> 0: .find() returns "-1" on failure, not 0. You want ">=" instead of just ">", or even more readably if fileBase in f: -tkc -- http://mail.python.org/mailman/listinfo/python-list

How can I define __getattr__ to operate on all items of container and pass arguments?

2011-02-15 Thread Jeremy
I have a container object. It is quite frequent that I want to call a function on each item in the container. I would like to do this whenever I call a function on the container that doesn't exist, i.e., the container would return an attribute error. For example class Cont(object): def _

Problem w/ MySQLdb

2011-02-15 Thread Victor Subervi
Hi; I have a function that calls the following class: #!/usr/bin/python import sys,os sys.path.append(os.getcwd()) import MySQLdb from login import login import re, string def buildTableColorShortOptions(): user, passwd, db, host = login() database = MySQLdb.connect(host, user, passwd, db)

Displaying SVG in tkinter using cairo and rsvg

2011-02-15 Thread Martin P. Hellwig
Hi all, Information on using tkinter for displaying an svg image seems a bit low spread on the Internet. I recently played around with pygame and svg and realized, hold on this can be done with tk too. So I thought I post a little example for future generations :-) (and also have stored at ht

Re: file find skips first letter

2011-02-15 Thread MRAB
On 15/02/2011 18:48, Mel wrote: Wanderer wrote: I'm using code def getFiles(self, fileBase): """return a list of the filenames in a director containing a base word """ allFiles = os.listdir(self.resultDir) baseFiles = [] for f in allFiles:

Re: newbie question about PYTHONPATH

2011-02-15 Thread Alexander Kapps
On 15.02.2011 19:12, Panupat Chongstitwattana wrote: Panupat, please don't top-post, it messes the the natural order of the discussion. Thanks. I think the command line should look something along this line export PYTHONPATH=$HOME/foo/prog/learning_python/: with a colon at the end. Nope,

Re: file find skips first letter

2011-02-15 Thread Miki Tebeka
> def getFiles(self, fileBase): > """return a list of the filenames in a director containing a > base word > """ > ... Have a look at the glob module, it does what you want. HTH -- Miki Tebeka http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-li

Re: file find skips first letter

2011-02-15 Thread Alexander Kapps
On 15.02.2011 19:32, Wanderer wrote: I'm using code def getFiles(self, fileBase): """return a list of the filenames in a director containing a base word """ allFiles = os.listdir(self.resultDir) baseFiles = [] for f in allFiles: if

Re: file find skips first letter

2011-02-15 Thread Mel
Wanderer wrote: > I'm using code > > def getFiles(self, fileBase): > """return a list of the filenames in a director containing a > base word > """ > > allFiles = os.listdir(self.resultDir) > baseFiles = [] > for f in allFiles: > if f.find(

file find skips first letter

2011-02-15 Thread Wanderer
I'm using code def getFiles(self, fileBase): """return a list of the filenames in a director containing a base word """ allFiles = os.listdir(self.resultDir) baseFiles = [] for f in allFiles: if f.find(fileBase) > 0: baseFile

Re: Missing SIGCHLD

2011-02-15 Thread Dan Stromberg
On Tue, Feb 15, 2011 at 2:57 AM, Dinh wrote: > Hi, > > I currently build a process management system which is able to fork child > processes (fork()) and keep them alive (waitpid() ). > > if pid in self.current_workers: > os.waitpid(pid, 0) > > If a child process dies

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Chris Rebert
On Tue, Feb 15, 2011 at 7:17 AM, Jorge Vargas wrote: > Hello, > > I have the following situation. In a big project that involves many > dependencies (and sadly some sys.module hacks) we have a bug, and it > will really help if i could monitor all changes made to that variable. > Is there a way to

Re: newbie question about PYTHONPATH

2011-02-15 Thread Panupat Chongstitwattana
I think the command line should look something along this line export PYTHONPATH=$HOME/foo/prog/learning_python/: with a colon at the end. On Wed, Feb 16, 2011 at 12:49 AM, Tim Hanson wrote: > I am to the point in _Learning_Python_  where functions are introduced. > > I decided to experiment by

newbie question about PYTHONPATH

2011-02-15 Thread Tim Hanson
I am to the point in _Learning_Python_ where functions are introduced. I decided to experiment by putting a function into a file and importing it into Idle. Of course, Idle couldn't find it, so I executed the following command in Bash: PYTHONPATH=/home/foo/prog/learning_python export PYTHONP

Re: Non-linear regression help in Python

2011-02-15 Thread sturlamolden
On 15 Feb, 05:24, Akand Islam wrote: > Dear Sturlamolden, > Thanks for reply. I will follow-up if I need further assistance. > > -- Akand You should rather use the SciPy user mailing list than comp.lang.python for this. Sturla -- http://mail.python.org/mailman/listinfo/python-list

[ANN] Oktest 0.8.0 released - a new-style testing library

2011-02-15 Thread Makoto Kuwata
I released Oktest 0.8.0. http://pypi.python.org/pypi/Oktest/ http://packages.python.org/Oktest/ Oktest is a new-style testing library for Python. :: from oktest import ok, NG ok (x) > 0 # same as assert_(x > 0) ok (s) == 'foo'# same as assertEqual(s, 'foo')

lint warnings

2011-02-15 Thread Gerald Britton
>> I find: >> >> map(func, iterable) >> >> to be "neater" than: >> >> [func(item) for item in iterable] >> >> If nothing else, the "map" version is shorter. >That's only true if you wanted to call an existing function. If you wanted >to do something involving a more complex expression that

How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Jorge Vargas
Hello, I have the following situation. In a big project that involves many dependencies (and sadly some sys.module hacks) we have a bug, and it will really help if i could monitor all changes made to that variable. Is there a way to trace those changes ? -- http://mail.python.org/mailman/listinfo

Re: interleave string

2011-02-15 Thread MRAB
On 15/02/2011 09:53, Andrea Crotti wrote: Just a curiosity not a real problem, I want to pass from a string like xxaabbddee to xx:aa:bb:dd:ee so every two characters insert a ":". At the moment I have this ugly inliner interleaved = ':'.join(orig[x:x+2] for x in range(0, len(orig), 2))

Re: Extending classes __init__behavior for newbies

2011-02-15 Thread Westley Martínez
On Tue, 2011-02-15 at 08:36 +, Duncan Booth wrote: > Westley Martínez wrote: > > >> In the end i promise they will respect you more for your honesty. And > >> it will not be a respect forged from fear, no, it will be something > >> greater! A respect forged from collaboration. A respect of co

Re: lint warnings

2011-02-15 Thread Duncan Booth
Gerald Britton wrote: > I find: > > map(func, iterable) > > to be "neater" than: > > [func(item) for item in iterable] > > If nothing else, the "map" version is shorter. That's only true if you wanted to call an existing function. If you wanted to do something involving a more compl

lint warnings

2011-02-15 Thread Gerald Britton
I find: map(func, iterable) to be "neater" than: [func(item) for item in iterable] If nothing else, the "map" version is shorter. More importantly, in the 2.x series (which I am often limited to for compatibility reasons), the variable used in the list comprehension leaks to the follow

Re: interleave string

2011-02-15 Thread Alex Willmer
On Feb 15, 10:09 am, Wojciech Muła wrote: > import re > > s = 'xxaabbddee' > m = re.compile("(..)") > s1 = m.sub("\\1:", s)[:-1] One can modify this slightly: s = 'xxaabbddee' m = re.compile('..') s1 = ':'.join(m.findall(s)) Depending on one's taste this could be clearer. The more general answe

[ANN] Data Plotting Library DISLIN 10.1

2011-02-15 Thread Helmut Michels
Dear Python users, I am pleased to announce version 10.1 of the data plotting software DISLIN. DISLIN is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as

Re: Question on Creating exe file with py2exe

2011-02-15 Thread aspineux
On 13 fév, 06:20, joy99 wrote: > On Feb 13, 1:29 am, aspineux wrote: > > > > > > > Hi > > > I'm releasing a .exe made with py2exe myself an got this problem too. > > 99% of the time the required DLL is already installed by another > > application and you don't need to care about it. > > The 1% is

Missing SIGCHLD

2011-02-15 Thread Dinh
Hi, I currently build a process management system which is able to fork child processes (fork()) and keep them alive (waitpid() ). if pid in self.current_workers: os.waitpid(pid, 0) If a child process dies, it should trigger a SIGCHLD signal and a handler is install

Re: interleave string

2011-02-15 Thread Valentin Baciu
Hello, How about this: >>> str = 'xxaabbddee' >>> ':'.join(map(''.join, zip(str[::2], str[1::2]))) In my example, it should not matter that the letters are repeating. On Tue, Feb 15, 2011 at 11:53 AM, Andrea Crotti wrote: > Just a curiosity not a real problem, I want to pass from a string like

Re: interleave string

2011-02-15 Thread Wojciech Muła
On Tue, 15 Feb 2011 10:53:56 +0100 Andrea Crotti wrote: > Just a curiosity not a real problem, I want to pass from a string like > > xxaabbddee > to > xx:aa:bb:dd:ee > > so every two characters insert a ":". > At the moment I have this ugly inliner > interleaved = ':'.join(orig[x:x+2] f

interleave string

2011-02-15 Thread Andrea Crotti
Just a curiosity not a real problem, I want to pass from a string like xxaabbddee to xx:aa:bb:dd:ee so every two characters insert a ":". At the moment I have this ugly inliner interleaved = ':'.join(orig[x:x+2] for x in range(0, len(orig), 2)) but also something like this would work [''

Re: generating .zip including __main__.py file in top root using distutils

2011-02-15 Thread alain.spineux
I answer myself to put my question on top of the list again. On Feb 12, 7:47 pm, aspineux wrote: > Python 2.6 can run a zip file, searching for __main__.py in the root > of the zip archive and running it. > How can I create such an archive using distutils (and not > setuptools) ? > > If I use >

Re: lint warnings

2011-02-15 Thread Andrea Crotti
Il giorno 15/feb/2011, alle ore 04.10, Ben Finney ha scritto: > Andrea Crotti writes: > The ‘map’ builtin is deprecated; using a list comprehension is neater > and more efficient. Ok well it depends, map(int, biglist) is better than: [int(x) for x in biglist] at least for me. Efficiency is pro

Re: Extending classes __init__behavior for newbies

2011-02-15 Thread Duncan Booth
Westley Martínez wrote: >> In the end i promise they will respect you more for your honesty. And >> it will not be a respect forged from fear, no, it will be something >> greater! A respect forged from collaboration. A respect of comrades in >> arms. This is the future i bring to c.l.py! > HEIL D