Introduction to Python Masterclass, May 11-13, 2009 in Chicago

2009-03-14 Thread David Beazley
* * Introduction to Python Masterclass * * May 11-13, 2009 Chicago, Illinois with David Beazley, author Python Essential Reference http://www.dabeaz.com/chicago Take your Python programming skills to

Re: Subprocess module: running an interactive shell

2009-03-14 Thread Karthik Gurusamy
On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez ro...@rs-labs.com wrote: Hi, I'm experimenting with Python and I need a little help with this. What I'd like is to launch an interactive shell, having the chance to send first several commands from python. I've written the following code:

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-14 Thread Raymond Hettinger
[Lie Ryan] My proposition is: make the format specifier a simpler API to locale aware You do know that we already have one, right? That's what the existing n specifier does. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find in in the documentation

2009-03-14 Thread Tim Golden
Colin J. Williams wrote: Piet van Oostrum wrote: tinn...@isbd.co.uk (t) wrote: t I've had this trouble before, how do I find the details of how in t works in the documentation. E.g. the details of:- t if string in bigstring: t It gets a mention in the if section but not a lot.

Re: python book for a C programmer

2009-03-14 Thread Chris Rebert
On Fri, Mar 13, 2009 at 10:29 PM, Paul Rubin http wrote: Saurabh nirkh...@gmail.com writes: Hi all, I am an experienced C programmer, I have done some perl code as well. But while thinking about large programs,I find perl syntax a hinderance. I would say read the online tutorial, then

Integer arithmetic in hardware descriptions

2009-03-14 Thread Jan Decaluwe
I am the author of MyHDL, a Python package that turns Python into a hardware description language (HDL). Integer arithmetic is very important in hardware design, but with traditional HDLs such as Verilog and VHDL it is complicated and confusing. MyHDL has a better solution, inspired by Python's

Re: Threads and temporary files

2009-03-14 Thread Lawrence D'Oliveiro
In message 302dd4f5-e9b3-4b0a-b80c- ae43810d8...@e18g2000yqo.googlegroups.com, aiwarrior wrote: I recently am meddling with threads and wanted to make a threaded class that instead of processing anything just retrieves data from a file and returns that data to a main thread that takes all the

Re: __import__ with dict values

2009-03-14 Thread alex goretoy
I don't get *why* someone would like to write that. Does it look cool? Is it some kind of Look, ma, I know those hidden names! syndrome? Is it contagious? I think thats what it is. It does look cool, thats for telling me about the fact that prevents the interpreter from doing many

Re: __import__ with dict values

2009-03-14 Thread alex goretoy
I'm actually still getting to this section of my code, I've been working a logging,stdout colors lately, Although I am going to need __import__ in several places in this program -Alex Goretoy http://www.goretoy.com On Sat, Mar 14, 2009 at 3:05 AM, alex goretoy aleksandr.gore...@gmail.comwrote:

Re: __import__ with dict values

2009-03-14 Thread alex goretoy
I can show you people more code if you want :) I like to learn -Alex Goretoy http://www.goretoy.com On Sat, Mar 14, 2009 at 3:09 AM, alex goretoy aleksandr.gore...@gmail.comwrote: I'm actually still getting to this section of my code, I've been working a logging,stdout colors lately,

Re: finally successful in ods with python, just one help needed.

2009-03-14 Thread Krishnakant
On Thu, 2009-03-12 at 14:49 -0700, John Machin wrote: I see that you haven't had the evil spirits exorcised from your mail/ news client ... it's hijacked a thread again :-( don't worry, won't happen this time. It seams I did some thing wrong with the settings and it drops out mails. Now the

Re: __import__ with dict values

2009-03-14 Thread alex goretoy
This is a chunk of what its starting to look like now, thanks from colors import _available_colors as _ck from has_colors import _has_colors as _ha from log import _brush as _er class stdout_colors(object): def __init__(self,colors_active=1,output_caller=1,caller_color=red,default=1,

Re: tkinter: loading file before entering mainloop

2009-03-14 Thread Peter Otten
Peter Billam wrote: I've got this tkinter program which allows you to load a file with File/LoadFile or Ctrl-L or from the Alt-F menu, as usual. But I'd also like to be able to invoke it with: shellprompt midimix x.mid and have it invoke its usual loadFile method on x.mid But with the

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-14 Thread Hendrik van Rooyen
John Nagle na...@animats.com wrote: Yes. In COBOL, one writes PICTURE $999,999,999.99 which is is way ahead of most of the later approaches. That was fixed width. For zero suppression: PIC ,$$$,$99.99 This will format 1000 as $1,000.00 For fixed width zero suppression: PIC

String to sequence

2009-03-14 Thread mattia
How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'] Thanks a lot, Mattia --

Re: String to sequence

2009-03-14 Thread Frank Pan
a = eval([%s] % 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC','EGC','SXF','BZR','BIQ','BLL','BHX','BLQ') a ['AAR', 'ABZ', 'AGA', 'AHO', 'ALC', 'LEI', 'AOC', 'EGC', 'SXF', 'BZR', 'BIQ', 'BLL', 'BHX', 'BLQ'] On Sat, Mar 14, 2009 at 5:09 PM, mattia ger...@gmail.com wrote: How can I convert the

Re: tkinter: loading file before entering mainloop

2009-03-14 Thread Peter Billam
Peter Billam wrote: window = MainWindow(application) if (len(sys.argv) 1) and os.path.exists(sys.argv[1]): window.loadFile(sys.argv[1]) application.mainloop() File ./midimix, line 465, in loadFile space0.grid(row=grid_row,

Re: String to sequence

2009-03-14 Thread Ulrich Eckhardt
mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'] import string string.split(a,b,c, ',')

Re: String to sequence

2009-03-14 Thread Vlastimil Brom
2009/3/14 mattia ger...@gmail.com: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'] Thanks a lot, Mattia

Re: String to sequence

2009-03-14 Thread Peter Otten
mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'] s =

Re: String to sequence

2009-03-14 Thread mattia
Il Sat, 14 Mar 2009 10:24:38 +0100, Ulrich Eckhardt ha scritto: mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC',

Re: tkinter: loading file before entering mainloop

2009-03-14 Thread Peter Otten
Peter Billam wrote: Peter Billam wrote: window = MainWindow(application) if (len(sys.argv) 1) and os.path.exists(sys.argv[1]): window.loadFile(sys.argv[1]) application.mainloop() File ./midimix, line 465, in loadFile space0.grid(row=grid_row,

Re: Subprocess module: running an interactive shell

2009-03-14 Thread Roman Medina-Heigl Hernandez
Karthik Gurusamy escribió: On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez ro...@rs-labs.com wrote: Hi, I'm experimenting with Python and I need a little help with this. What I'd like is to launch an interactive shell, having the chance to send first several commands from python. I've

Re: c++ extension, problem passing argument

2009-03-14 Thread Matteo
On 14 Mar, 02:08, Aaron Brady castiro...@gmail.com wrote: On Mar 13, 5:42 pm, Matteo tadweles...@gmail.com wrote: On 13 Mar, 22:35, Aaron Brady castiro...@gmail.com wrote: On Mar 13, 1:34 pm, Matteo tadweles...@gmail.com wrote: hmmm... looks like SWIG has a problem with double

SWIG, c++ to Python: array of pointers (double pointer) not working

2009-03-14 Thread Matteo
Re-posting in more simple and precise terms from a previous thread http://groups.google.it/group/comp.lang.python/browse_thread/thread/6dd7bd9a09b8a011/5119cf15ebfa38b8 Problem: SWIG doesn't properly wrap c++ arrays of pointers, therefore when you try to call a c++ function which requires them, a

Re: String to sequence

2009-03-14 Thread mattia
Il Sat, 14 Mar 2009 10:30:43 +0100, Vlastimil Brom ha scritto: 2009/3/14 mattia ger...@gmail.com: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC',

Re: String to sequence

2009-03-14 Thread Lie Ryan
mattia wrote: Il Sat, 14 Mar 2009 10:30:43 +0100, Vlastimil Brom ha scritto: 2009/3/14 mattia ger...@gmail.com: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence:

Re: String to sequence

2009-03-14 Thread Peter Otten
mattia wrote: Il Sat, 14 Mar 2009 10:30:43 +0100, Vlastimil Brom ha scritto: 2009/3/14 mattia ger...@gmail.com: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence:

Re: String to sequence

2009-03-14 Thread mattia
Il Sat, 14 Mar 2009 10:35:59 +0100, Peter Otten ha scritto: mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC',

Re: How to find in in the documentation

2009-03-14 Thread jkn
On Mar 14, 7:00 am, Tim Golden m...@timgolden.me.uk wrote: Well, this may not solve the OP's problem, but the current (2.7a0) .chm file has a much better index for operators and keywords. And in is in there. If you're interested in comparing, there's a copy here:

Re: PythonWin, python thread and PostQuitMessage?

2009-03-14 Thread aloonstra
On 13 mrt, 23:30, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Fri, 13 Mar 2009 17:59:34 -0200, aloons...@gmail.com escribió: On 12 mrt, 18:43, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 12 Mar 2009 07:21:35 -0200, arn...@sphaero.org escribió: I'm not so much

Re: How to find in in the documentation

2009-03-14 Thread tinnews
Colin J. Williams c...@ncf.ca wrote: Piet van Oostrum wrote: tinn...@isbd.co.uk (t) wrote: t I've had this trouble before, how do I find the details of how in t works in the documentation. E.g. the details of:- t if string in bigstring: t It gets a mention in the if

Re: String to sequence

2009-03-14 Thread Peter Otten
mattia wrote: Il Sat, 14 Mar 2009 10:35:59 +0100, Peter Otten ha scritto: mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC',

Re: String to sequence

2009-03-14 Thread mattia
Il Sat, 14 Mar 2009 12:13:31 +0100, Peter Otten ha scritto: mattia wrote: Il Sat, 14 Mar 2009 10:35:59 +0100, Peter Otten ha scritto: mattia wrote: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into

multiprocessing.sharedctypes and built-in locks

2009-03-14 Thread Ahmad Syukri bin Abdollah
I'm trying this on Python 3.0.1 Consider the following code: import multiprocessing as mp def jambu(b,i,gl): for n in range(10): with gl[i]: b[i]+=2 with gl[3-i]: b[3-i]-=1 def main(): b = mp.RawArray('i',4) gl = [] proc = [] for i

Re: How to find in in the documentation

2009-03-14 Thread Tim Golden
jkn wrote: On Mar 14, 7:00 am, Tim Golden m...@timgolden.me.uk wrote: Well, this may not solve the OP's problem, but the current (2.7a0) .chm file has a much better index for operators and keywords. And in is in there. If you're interested in comparing, there's a copy here:

Re: question on msvcrt.dll versioning

2009-03-14 Thread rogerdpack
Thanks much. -=roger Yet more specifically: if the extension module or Python host opens a file with fopen(), and passes it to PyRun_{Any|Simple}File[Ex][Flags], Python will crash. HTH, Martin P.S. There may be more cases in which you get crashes - the list above includes just the known

Compute working days

2009-03-14 Thread Gonsolo
I found no solution on the net so I am posting my solution here. It can be called with python cwd 1-1-2009 14-3-2009 from dateutil.rrule import * from dateutil.parser import * from datetime import * from sys import * start = parse( argv[1] ) #end = datetime.now() end = parse( argv[2] ) workdays

Re: python book for a C programmer

2009-03-14 Thread Saurabh
On Mar 14, 12:04 pm, Chris Rebert c...@rebertia.com wrote: On Fri, Mar 13, 2009 at 10:29 PM, Paul Rubin http wrote: Saurabh nirkh...@gmail.com writes: Hi all, I am an experienced C programmer, I have done some perl code as well. But while thinking about large programs,I find perl syntax a

Re: /a is not /a ?

2009-03-14 Thread Steve Holden
Gary Herron wrote: Robert Kern wrote: On 2009-03-06 14:23, Gary Herron wrote: Robert Kern wrote: On 2009-03-06 13:46, Gary Herron wrote: Emanuele D'Arrigo wrote: Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. *Do

Re: /a is not /a ?

2009-03-14 Thread Steve Holden
Paul Rubin wrote: Steven D'Aprano st...@pearwood.info writes: It is never correct to avoid using is when you need to compare for identity. When is it ever necessary to compare for identity? For example when providing a unique sentinel value as a function argument. The parameter must be

Re: /a is not /a ?

2009-03-14 Thread Steve Holden
Carl Banks wrote: On Mar 8, 5:32 am, Lie Ryan lie.1...@gmail.com wrote: Mel wrote: wrote: Steven D'Aprano st...@pearwood.info writes: It is never correct to avoid using is when you need to compare for identity. When is it ever necessary to compare for identity? Ho-hum. MUDD game. def

Re: Get pixel colors from images in Python 3

2009-03-14 Thread Tino Wildenhain
Daniel Fetchinson wrote: I've noticed that Pygame has some similar implementation. It's a little harder to use, but efficient. And i think it depends on PIL too. And Pygame is Python 2.x too... ... When I asked about it there I was told that some work already has started on porting PIL to

Re: Neatest way to do a case insensitive in?

2009-03-14 Thread Tino Wildenhain
tinn...@isbd.co.uk wrote: ... But I was wondering if there's a neater/easier way? How is if stringA.lower() in stringB.lower(): complex/messy? Well I guess I was just looking for incase a bit like strcasecmp in C. Which locales case folding do you want to have applied? Tino smime.p7s

Re: 2.6.1 - simple division

2009-03-14 Thread Steve Holden
farsi...@gmail.com wrote: Thanks all, that's very helpful, sorry to waste your time with a common question. I have tried the decimal module and will definitely keep using it if I need to do this kind of calculation again. I have 1 more question that the floating point article that was linked

Re: Compute working days

2009-03-14 Thread John Machin
On Mar 15, 12:13 am, Gonsolo gons...@gmail.com wrote: I found no solution on the net so I am posting my solution here. It can be called with python cwd 1-1-2009 14-3-2009 from dateutil.rrule import * from dateutil.parser import * from datetime import * from sys import * H ... I wonder

Re: Special keyword argument lambda syntax

2009-03-14 Thread Nick Craig-Wood
Beni Cherniavsky beni.cherniav...@gmail.com wrote: This proposal outrageously suggests a special syntax for in-line functions passed as keyword arguments:: sorted(range(9), key(n)=n%3) [0, 3, 6, 1, 4, 7, 2, 5, 8] The claim is that such specialization hits a syntax sweet

Re: converting a string to a function parameter

2009-03-14 Thread alex goretoy
My new class I've been working on might help you. It does what you are asking without eval (I'm still working on it) Anyone have any ideas aswell along with the OP, thank you #!/usr/bin env python # # -*- coding: UTF-8 -*- # # PyNutButter BETA Version 0.1.0.1 # # Copyright 2009 - Infinity by Alex

Re: How to find in in the documentation

2009-03-14 Thread Colin J. Williams
Tim Golden wrote: Colin J. Williams wrote: Piet van Oostrum wrote: tinn...@isbd.co.uk (t) wrote: t I've had this trouble before, how do I find the details of how in t works in the documentation. E.g. the details of:- t if string in bigstring: t It gets a mention in the if section

Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object): def __init__(self): self.some_value = 0 self.another_value = None Similar effect can be achieved by

ElementTree: How to return only unicode?

2009-03-14 Thread Torsten Bronger
Hallöchen! I parse an XML file with ElementTree and get the contets with the .attrib, .text, .get etc methods of the tree's nodes. Additionally, I use the find and findtext methods. My problem is that if there is only ASCII, these methods return ordinary strings instead of unicode. So sometimes

don't understand behaviour of recursive structure

2009-03-14 Thread Dan Davison
I'm new to python. Could someone please explain the following behaviour of a recursive data structure? def new_node(id='', daughters=[]): return dict(id=id, daughters=daughters) n0 = new_node(id='n0') n1 = new_node(id='n1') ## Seems OK so far: n0 # {'id':

Re: Style question - defining immutable class data members

2009-03-14 Thread MRAB
Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object): def __init__(self): self.some_value = 0 self.another_value = None Similar effect

Re: don't understand behaviour of recursive structure

2009-03-14 Thread Miles
On Sat, Mar 14, 2009 at 12:31 PM, Dan Davison wrote: I'm new to python. Could someone please explain the following behaviour of a recursive data structure? def new_node(id='', daughters=[]):    return dict(id=id, daughters=daughters) This is something of a FAQ:

Re: don't understand behaviour of recursive structure

2009-03-14 Thread MRAB
Dan Davison wrote: I'm new to python. Could someone please explain the following behaviour of a recursive data structure? def new_node(id='', daughters=[]): return dict(id=id, daughters=daughters) n0 = new_node(id='n0') n1 = new_node(id='n1') [snip] See

Re: Compute working days

2009-03-14 Thread Casey Webster
How about: from datetime import date, timedelta # Define the weekday mnemonics to match the date.weekday function (MON, TUE, WED, THU, FRI, SAT, SUN) = range(7) def workdays(start_date, end_date, whichdays=(MON,TUE,WED,THU,FRI)): ''' Calculate the number of working days between two

Re: don't understand behaviour of recursive structure

2009-03-14 Thread bieffe62
On 14 Mar, 17:31, Dan Davison davi...@stats.ox.ac.uk wrote: I'm new to python. Could someone please explain the following behaviour of a recursive data structure? def new_node(id='', daughters=[]):     return dict(id=id, daughters=daughters) Most probably, here is the problem : try this

Re: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 12:50 PM, MRAB goo...@mrabarnett.plus.com wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object):    def __init__(self):

multiprocessing module - isn't it a bug?

2009-03-14 Thread dmitrey
# THIS WORKS OK from multiprocessing import Pool N = 400 K = 800 processes = 2 def costlyFunction2(z): r = 0 for k in xrange(1, K+2): r += z ** (1 / k**1.5) return r class ABC: def __init__(self): pass def testParallel(self): po = Pool(processes=processes)

Re: finally successful in ods with python, just one help needed.

2009-03-14 Thread David Bolen
Krishnakant hackin...@gmail.com writes: However when I apply the same elements and attributes to the one I am creating with odfpy, I get attribute not allowed errors. If some one is interested to look at the code, please let me know, I can send an attachment off the list so that others are

Re: Special keyword argument lambda syntax

2009-03-14 Thread Beni Cherniavsky
On Mar 14, 5:30 pm, Nick Craig-Wood n...@craig-wood.com wrote: BeniCherniavskybeni.cherniav...@gmail.com wrote:  This proposal outrageously suggests a special syntax for in-line  functions passed as keyword arguments::       sorted(range(9), key(n)=n%3)      [0, 3, 6, 1, 4, 7, 2, 5, 8]

PyWin32 for Python 3.x

2009-03-14 Thread John Nagle
Any idea when PyWin32 will be available for Python 3.x? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question - defining immutable class data members

2009-03-14 Thread bearophileHUGS
Maxim Khitrov: When the types are immutable, there is no difference. But you may want different instances to have different immutable data. Generally if the data (immutable or not) is the same for all the instances, use class attributes, otherwise use instance attributes. Bye, bearophile --

Re: Style question - defining immutable class data members

2009-03-14 Thread Gary Herron
Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object): def __init__(self): self.some_value = 0 self.another_value = None Similar effect

Re: How to find in in the documentation

2009-03-14 Thread Tim Golden
Colin J. Williams wrote: Tim Golden wrote: Colin J. Williams wrote: Piet van Oostrum wrote: tinn...@isbd.co.uk (t) wrote: t I've had this trouble before, how do I find the details of how in t works in the documentation. E.g. the details of:- t if string in bigstring: t It gets a

Re: python book for a C programmer

2009-03-14 Thread Sridhar Ratnakumar
On 3/13/2009 10:29 PM, Paul Rubin wrote: Saurabhnirkh...@gmail.com writes: Hi all, I am an experienced C programmer, I have done some perl code as well. But while thinking about large programs,I find perl syntax a hinderance. I would say read the online tutorial, then Python in a

Re: PyWin32 for Python 3.x

2009-03-14 Thread Tim Golden
John Nagle wrote: Any idea when PyWin32 will be available for Python 3.x? John Nagle Release 213 is out already: http://sourceforge.net/project/showfiles.php?group_id=78018package_id=79063release_id=661475 I think it's still considered a little bit beta. There have been a

Re: Integer arithmetic in hardware descriptions

2009-03-14 Thread John Nagle
Jan Decaluwe wrote: I am the author of MyHDL, a Python package that turns Python into a hardware description language (HDL). Integer arithmetic is very important in hardware design, but with traditional HDLs such as Verilog and VHDL it is complicated and confusing. MyHDL has a better solution,

Re: Style question - defining immutable class data members

2009-03-14 Thread Terry Reedy
Maxim Khitrov wrote: On Sat, Mar 14, 2009 at 12:50 PM, MRAB goo...@mrabarnett.plus.com wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object):

Re: multiprocessing module - isn't it a bug?

2009-03-14 Thread Terry Reedy
dmitrey wrote: # THIS WORKS OK from multiprocessing import Pool N = 400 K = 800 processes = 2 def costlyFunction2(z): r = 0 for k in xrange(1, K+2): r += z ** (1 / k**1.5) return r class ABC: def __init__(self): pass def testParallel(self): po =

Re: don't understand behaviour of recursive structure

2009-03-14 Thread MRAB
bieff...@gmail.com wrote: On 14 Mar, 17:31, Dan Davison davi...@stats.ox.ac.uk wrote: I'm new to python. Could someone please explain the following behaviour of a recursive data structure? def new_node(id='', daughters=[]): return dict(id=id, daughters=daughters) Most probably, here is

Re: multiprocessing module - isn't it a bug?

2009-03-14 Thread Christian Heimes
dmitrey wrote: This doesn't work for costlyFunction2 = lambda x: 11 as well; and it doesn't work for imap, apply_async as well (same error). So, isn't it a bug, or it can be somehow fixed? Thank you in advance, D. It's not a bug but a limitation of the pickle protocol. Pickle can't handle

Re: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 2:07 PM, Gary Herron gher...@islandtraining.com wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object):    def

Re: converting a string to a function parameter

2009-03-14 Thread alex goretoy
This is a file that is going into the new version of python-stdout-colors project location: http://code.google.com/p/python-stdout-colors/ -Alex Goretoy http://www.goretoy.com On Sat, Mar 14, 2009 at 10:45 AM, alex goretoy aleksandr.gore...@gmail.comwrote: My new class I've been working

Re: Guidance on writing a top-like console

2009-03-14 Thread Aahz
In article mailman.922.1235774125.11746.python-l...@python.org, Tim Chase python.l...@tim.thechases.com wrote: I am interested in writing an application that functions like a Unix or Linux top in the way it displays data. It should be command-line based but dynamically refreshing. You might

Re: Threads and temporary files

2009-03-14 Thread aiwarrior
On Mar 14, 3:01 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Fri, 13 Mar 2009 19:07:46 -0200, aiwarrior zube...@yahoo.com.br   escribió: I recently am meddling with threads and wanted to make a threaded class that instead of processing anything just retrieves data from a file

Re: Style question - defining immutable class data members

2009-03-14 Thread David Stanek
On Sat, Mar 14, 2009 at 12:32 PM, Maxim Khitrov mkhit...@gmail.com wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object):    def __init__(self):        

Re: don't understand behaviour of recursive structure

2009-03-14 Thread Dan Davison
bieff...@gmail.com writes: On 14 Mar, 17:31, Dan Davison davi...@stats.ox.ac.uk wrote: I'm new to python. Could someone please explain the following behaviour of a recursive data structure? def new_node(id='', daughters=[]):     return dict(id=id, daughters=daughters) Most probably, here

Re: String to sequence

2009-03-14 Thread Tim Chase
How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'] Though several other options have come through: s =

Re: Style question - defining immutable class data members

2009-03-14 Thread Gary Herron
Maxim Khitrov wrote: On Sat, Mar 14, 2009 at 2:07 PM, Gary Herron gher...@islandtraining.com wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class

Re: Style question - defining immutable class data members

2009-03-14 Thread Terry Reedy
Maxim Khitrov wrote: Perhaps a different example would help explain what I'm trying to do: class Case1(object): def __init__(self): self.count = 0 self.list = [] def inc(self): self.count += 1

little question speed encondings

2009-03-14 Thread Linos
I know that this can be evident for most of the people but i would like to know the reply and the reasoning if possible: Should my python application have a difference in speed of execution after change the encoding header of the file from nothing (ascii) to latin-1 or utf-8? If yes, only when

Re: finally successful in ods with python, just one help needed.

2009-03-14 Thread Krishnakant
Hi David, based on your code snippid I added a couple of lines to actually center align text in the merged cell in first row. Please note in the following code that I have added ParagraphProperties in the imports and created one style with textalign=center as an attribute. *** code follows ***

Re: multiprocessing.sharedctypes and built-in locks

2009-03-14 Thread Aaron Brady
On Mar 14, 7:11 am, Ahmad Syukri bin Abdollah syoc...@gmail.com wrote: I'm trying this on Python 3.0.1 Consider the following code: import multiprocessing as mp def jambu(b,i,gl):     for n in range(10):        with gl[i]:             b[i]+=2        with gl[3-i]:            

Re: little question speed encondings

2009-03-14 Thread MRAB
Linos wrote: I know that this can be evident for most of the people but i would like to know the reply and the reasoning if possible: Should my python application have a difference in speed of execution after change the encoding header of the file from nothing (ascii) to latin-1 or utf-8? If

tkinter: start window without window managers frame (linux,KDE)

2009-03-14 Thread Ekkard Gerlach
Hi, is tkinter able to start a windows without the frame of the according window manager? (only needed for Linux, KDE desktop) The window should only be closed by click on a button within the window! I should not be moved, it should not be close, ... and so on. The solution would be: start

Re: Style question - defining immutable class data members

2009-03-14 Thread Matthew Woodcraft
Gary Herron gher...@islandtraining.com writes: But now you are not listening to what people are telling you. It has *nothing* to do with the mutability/immutability of the integer and the list your two classes create. No! Did you run the code he posted? The immutability makes all the

Re: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 4:31 PM, Gary Herron gher...@islandtraining.com wrote: Perhaps a different example would help explain what I'm trying to do: class Case1(object):        def __init__(self):                self.count = 0                self.list  = []        def inc(self):          

Re: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 5:38 PM, Matthew Woodcraft matt...@woodcraft.me.uk wrote: Gary Herron gher...@islandtraining.com writes: I think this code is in poor taste: it's clear that it will confuse people (which is what Maxim was asking about in the first place). Yes, I see that now, thanks :)

Re: Style question - defining immutable class data members

2009-03-14 Thread Torsten Bronger
Hallöchen! Maxim Khitrov writes: [...] The advantage of doing this is that the assignments are evaluated once and thus the creation of that class is a bit faster. Access is still performed through self.some_value and self.another_value. Is there a reason to prefer the first style over the

Re: ElementTree: How to return only unicode?

2009-03-14 Thread Torsten Bronger
Hallöchen! Stefan Behnel writes: Torsten Bronger wrote: [...] My problem is that if there is only ASCII, these methods return ordinary strings instead of unicode. So sometimes I get str, sometimes I get unicode. Can one change this globally so that they only return unicode? That's a

Re: ElementTree: How to return only unicode?

2009-03-14 Thread Stefan Behnel
Torsten Bronger wrote: I parse an XML file with ElementTree and get the contets with the .attrib, .text, .get etc methods of the tree's nodes. Additionally, I use the find and findtext methods. My problem is that if there is only ASCII, these methods return ordinary strings instead of

Re: finally successful in ods with python, just one help needed.

2009-03-14 Thread David Bolen
Krishnakant hackin...@gmail.com writes: based on your code snippid I added a couple of lines to actually center align text in the merged cell in first row. Sorry, guess I should have verified handling all the requirements :-) I think there's two issues: * I neglected to add the style I

how to repeat function definitions less

2009-03-14 Thread alex goretoy
I'm doing this in my code, how to make it define all this functions for me with lambda, I've been up for a while and cant seem to figure it out, whats the most efficient way to do it? with lambda? how? thx def red(self,value,color='red',level='INFO'): self.write(value,color,level)

TypeError when creating frozenset with no hash

2009-03-14 Thread andrew cooke
I was going to file a bug report for this, but then I wondered if it was considered normal behaviour. Am I wrong in thinking there should be a better error message? class NoHash: ... def __hash__(self): ... pass ... frozenset([NoHash()]) Traceback (most recent call last): File stdin,

Re: tkinter: start window without window managers frame (linux,KDE)

2009-03-14 Thread Martin P. Hellwig
Ekkard Gerlach wrote: Hi, is tkinter able to start a windows without the frame of the according window manager? (only needed for Linux, KDE desktop) The window should only be closed by click on a button within the window! I should not be moved, it should not be close, ... and so on. The

Re: how to repeat function definitions less

2009-03-14 Thread skip
I'm doing this in my code, how to make it define all this functions for me with lambda, I've been up for a while and cant seem to figure it out, whats the most efficient way to do it? with lambda? how? thx def red(self,value,color='red',level='INFO'):

Re: tkinter: start window without window managers frame (linux,KDE)

2009-03-14 Thread Ekkard Gerlach
Martin P. Hellwig schrieb: Try a google search on: tkinter overrideredirect thx! That's it! -- http://mail.python.org/mailman/listinfo/python-list

Re: how to repeat function definitions less

2009-03-14 Thread Daniel Neuhäuser
I would suggest using functools.partial like this from functools import partial class Foo(object): #... red = partial(color='red') -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question - defining immutable class data members

2009-03-14 Thread Gary Herron
Maxim Khitrov wrote: On Sat, Mar 14, 2009 at 4:31 PM, Gary Herron gher...@islandtraining.com wrote: Perhaps a different example would help explain what I'm trying to do: class Case1(object): def __init__(self): self.count = 0 self.list = [] def

  1   2   >