suggestion for python function calling

2009-03-14 Thread alex goretoy
hi i have a suggestion, surely this wont wonk, and is merely a suggestion to aedd this type of syntax to python This is an insperation from peps 318 > def foo(self): > perform method operation > foo = classmethod(foo) > > where it says perform mthod operation, why not have that be an actual s

Re: how to repeat function definitions less

2009-03-14 Thread alex goretoy
sweet, I've been wondering how those work. I've read some stuff about them and still doesn't make sense to me. Why would I want to use itPlease explain, thank you -Alex Goretoy http://www.goretoy.com On Sun, Mar 15, 2009 at 1:05 AM, Michele Simionato < michele.simion...@gmail.com> wrote: >

Re: how to repeat function definitions less

2009-03-14 Thread Michele Simionato
On Mar 15, 12:09 am, s...@pobox.com wrote: >     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,co

Creating a python extension that works with multiprocessing.Queue

2009-03-14 Thread Travis Miller
I am very new to the python C API, and have written a simple type called SU2 that has 4 members that are all doubles. Everything seems to work fine (can import my module and instantiate the new type and act on it with various methods I have defined), except for when I attempt to use my new type wi

Re: how to repeat function definitions less

2009-03-14 Thread alex goretoy
I would imagine that I could do this with a generator and setattr, but I am still learning how to do that kinda of codingmaybe if I had a dictionary like this and then loaded it d={ "site_name":["s","site",'sites','site_name','site_names'], "jar_name":["j","jar",'jars','jar_name','jar_

Re: how to repeat function definitions less

2009-03-14 Thread alex goretoy
Nice, this is good code. Thank you. Seeing as we are still on the same subject, how would I do it on sysarg values from getopt? I have a main method defined like so def main(self): #XXX """ 1 #get site_name: prepend to curl get/post requests

Re: why cannot assign to function call

2009-03-14 Thread Terry Reedy
Aahz wrote: In article , wrote: I think this is the key point. I am an experienced Python programmer, and I had to think long and hard about what you were saying, Mark, in order to understand how it applied to Python. I think this means that your model and/or your level of abstraction is not

Re: TypeError when creating frozenset with no hash

2009-03-14 Thread Terry Reedy
andrew cooke wrote: 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

Re: Subprocess module: running an interactive shell

2009-03-14 Thread Karthik Gurusamy
On Mar 14, 3:03 am, Roman Medina-Heigl Hernandez wrote: > Karthik Gurusamy escribió: > > > > > On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez > > 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

Re: why cannot assign to function call

2009-03-14 Thread Aahz
In article , wrote: > >I think this is the key point. I am an experienced Python programmer, >and I had to think long and hard about what you were saying, Mark, in >order to understand how it applied to Python. I think this means that >your model and/or your level of abstraction is not "natural

Re: how to repeat function definitions less

2009-03-14 Thread MRAB
alex goretoy wrote: 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

Re: Special keyword argument lambda syntax

2009-03-14 Thread Rhodri James
On Fri, 13 Mar 2009 15:33:26 -, MRAB wrote: Rhodri James wrote: On Fri, 13 Mar 2009 14:49:17 -, Beni Cherniavsky wrote: Specification = Allow keyword arguments in function call to take this form: NAME ( ARGUMENTS ) = EXPRESSION which is equivallent to the foll

Re: Special keyword argument lambda syntax

2009-03-14 Thread Rhodri James
On Fri, 13 Mar 2009 16:39:16 -, Scott David Daniels wrote: The original proposal was initially appealing to me until I saw this comment. That means a relatively "invisible typo" would turn into good syntax. Possibley this is exactly what Rhodri James is talking about, but just to be exp

pyparse

2009-03-14 Thread aditya shukla
Hello guys i am trying to make a simple sql parser and i found pyparse , my question here is does it return a data structure like an abstract syntax tree of the sql query.Any help is appreciated Aditya -- 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 5:38 PM, Matthew Woodcraft wrote: Gary Herron 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). Careful now -- I didn't write that. (Although I ag

Re: how to repeat function definitions less

2009-03-14 Thread andrew cooke
is this what you want (python 3.0)? >>> class Colours: ... def __init__(self): ... for colour in ['red', 'blue']: ... setattr(self, colour, lambda value, c=colour: self.write(value, c)) ... def write(self, value, colour): ... print(value, colour) ... >>> c = Colours() >>> c.red(

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 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): s

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: 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 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'): self.write(value,color

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 soluti

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 ""

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)

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

2009-03-14 Thread David Bolen
Krishnakant 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 created to the document

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 unicod

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

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 > ov

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 wrote: > Gary Herron 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 :) - Max -- http://mail.python.org/mailman/listin

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 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): >>                sel

Re: Style question - defining immutable class data members

2009-03-14 Thread Matthew Woodcraft
Gary Herron 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 difference. > The difference

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 with

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 y

Re: multiprocessing.sharedctypes and built-in locks

2009-03-14 Thread Aaron Brady
On Mar 14, 7:11 am, Ahmad Syukri bin Abdollah 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]: >             b[3-i]-=1

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 ***

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 th

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 self.list.append(sel

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 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__(se

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: don't understand behaviour of recursive structure

2009-03-14 Thread Dan Davison
bieff...@gmail.com writes: > On 14 Mar, 17:31, 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) >> > > Most probably, here is the

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 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 >    

Re: Threads and temporary files

2009-03-14 Thread aiwarrior
On Mar 14, 3:01 am, "Gabriel Genellina" wrote: > En Fri, 13 Mar 2009 19:07:46 -0200, aiwarrior   > 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 and returns that data to a main th

Re: Guidance on writing a top-like console

2009-03-14 Thread Aahz
In article , Tim Chase 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 look at the sourcecode for "iotop"[1] which would make >a good example (i

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 wrote: > My new class I've been working on might help you. It doe

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 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): >>    

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 han

Re: don't understand behaviour of recursive structure

2009-03-14 Thread MRAB
bieff...@gmail.com wrote: On 14 Mar, 17:31, 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) Most probably, here is the problem : try this

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 = Pool(processe

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 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): se

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, i

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=78018&package_id=79063&release_id=661475 I think it's still considered a little bit beta. There have been

Re: python book for a C programmer

2009-03-14 Thread Sridhar Ratnakumar
On 3/13/2009 10:29 PM, Paul Rubin wrote: Saurabh 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 Nutshell". That

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 g

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: 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 -- ht

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: Special keyword argument lambda syntax

2009-03-14 Thread Beni Cherniavsky
On Mar 14, 5:30 pm, Nick Craig-Wood wrote: > BeniCherniavsky 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 spec

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

2009-03-14 Thread David Bolen
Krishnakant 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 not forced to >

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: Style question - defining immutable class data members

2009-03-14 Thread Maxim Khitrov
On Sat, Mar 14, 2009 at 12:50 PM, MRAB 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): >>        se

Re: don't understand behaviour of recursive structure

2009-03-14 Thread bieffe62
On 14 Mar, 17:31, 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) > Most probably, here is the problem : try this instead: def new_no

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 dates

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 http://www.python.org/doc/faq/gene

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: http://effbot.org/zone/de

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

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': 'n0'

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 someti

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 defi

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"

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: Special keyword argument lambda syntax

2009-03-14 Thread Nick Craig-Wood
Beni Cherniavsky 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 spot, and > that thi

Re: Compute working days

2009-03-14 Thread John Machin
On Mar 15, 12:13 am, Gonsolo 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 what the

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 li

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.p

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 py

Re: "/a" is not "/a" ?

2009-03-14 Thread Steve Holden
Carl Banks wrote: > On Mar 8, 5:32 am, Lie Ryan wrote: >> Mel wrote: >>> wrote: Steven D'Aprano 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 broadcas

Re: "/a" is not "/a" ?

2009-03-14 Thread Steve Holden
Paul Rubin wrote: > Steven D'Aprano 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 tested for i

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

Re: python book for a C programmer

2009-03-14 Thread Saurabh
On Mar 14, 12:04 pm, Chris Rebert wrote: > On Fri, Mar 13, 2009 at 10:29 PM, Paul Rubin wrote: > > Saurabh 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 wo

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] ) workday

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 th

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 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: http://timgolden.me.uk/python/downloa

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','B

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',

Re: How to find "in" in the documentation

2009-03-14 Thread tinnews
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 ment

Re: PythonWin, python thread and PostQuitMessage?

2009-03-14 Thread aloonstra
On 13 mrt, 23:30, "Gabriel Genellina" wrote: > En Fri, 13 Mar 2009 17:59:34 -0200, escribió: > > > > > On 12 mrt, 18:43, "Gabriel Genellina" wrote: > >> En Thu, 12 Mar 2009 07:21:35 -0200, escribió: > > >> > I'm not so much involved in any Windows programming however I needed > >> > to write a

Re: How to find "in" in the documentation

2009-03-14 Thread jkn
On Mar 14, 7:00 am, Tim Golden 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: > > http://timgolden.me.uk/python/downloads/

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', >> E

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 : >>> 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'

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 : 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','S

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 : >> 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', >>

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: c++ extension, problem passing argument

2009-03-14 Thread Matteo
On 14 Mar, 02:08, Aaron Brady wrote: > On Mar 13, 5:42 pm, Matteo wrote: > > > > > On 13 Mar, 22:35, Aaron Brady wrote: > > > > On Mar 13, 1:34 pm, Matteo wrote: > > > > > hmmm... looks like SWIG has a problem with double pointers. I googled > > > > around a bit and found: > > > > >http://osdir

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 > 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 th

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, >> pady

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: 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 = "'AAR','ABZ','AGA','AHO'

Re: String to sequence

2009-03-14 Thread Vlastimil Brom
2009/3/14 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 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: 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, > pady=round(0.5*(ymid[track_num]-y

  1   2   >