Re: xml, minidom, ElementTree

2011-12-13 Thread Stefan Behnel
Terry Reedy, 14.12.2011 06:01: On 12/13/2011 6:21 PM, Ethan Furman wrote: In the near future I will need to parse and rewrite parts of a xml files created by a third-party program (PrintShopMail, for the curious). It contains both binary and textual data. There has been some strong debate about

Re: AttributeError in "with" statement (3.2.2)

2011-12-13 Thread Terry Reedy
On 12/14/2011 1:05 AM, Eric Snow wrote: On Tue, Dec 13, 2011 at 10:42 PM, Steve Howell wrote: I'm using Python 3.2.2, and the following program gives me an error that I don't understand: class Foo: pass foo = Foo() foo.name = "Steve" def add_goodbye_function(obj): def goodbye(): prin

Re: AttributeError in "with" statement (3.2.2)

2011-12-13 Thread Eric Snow
On Tue, Dec 13, 2011 at 10:42 PM, Steve Howell wrote: > I'm using Python 3.2.2, and the following program gives me an error > that I don't understand: > > class Foo: >  pass > > foo = Foo() > foo.name = "Steve" > > def add_goodbye_function(obj): >  def goodbye(): >    print("goodbye " + obj.name)

AttributeError in "with" statement (3.2.2)

2011-12-13 Thread Steve Howell
I'm using Python 3.2.2, and the following program gives me an error that I don't understand: class Foo: pass foo = Foo() foo.name = "Steve" def add_goodbye_function(obj): def goodbye(): print("goodbye " + obj.name) obj.goodbye = goodbye add_goodbye_function(foo) foo.goodbye() # output

Re: xml, minidom, ElementTree

2011-12-13 Thread Terry Reedy
On 12/13/2011 6:21 PM, Ethan Furman wrote: In the near future I will need to parse and rewrite parts of a xml files created by a third-party program (PrintShopMail, for the curious). It contains both binary and textual data. There has been some strong debate about the merits of minidom vs Elemen

% is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-13 Thread Steven D'Aprano
On Mon, 12 Dec 2011 09:29:11 -0800, Eelco wrote: [quoting Jussi Piitulainen ] >> They recognize modular arithmetic but for some reason insist that there >> is no such _binary operation_. But as I said, I don't understand their >> concern. (Except the related concern about some programming language

Re: pyside dynamic buttons

2011-12-13 Thread Vincent Vande Vyvre
Le 13/12/11 20:46, Richard a écrit : Hi, We are making a screen with data driven buttons. I can add buttons but can't redraw the buttons for new values. The buttuns are placed in a frame. I draw the buttons on the screen in a for loop: def drawS1Butons(self): n=

Re: boolean from a function

2011-12-13 Thread Steven D'Aprano
On Tue, 13 Dec 2011 16:24:05 +, Andrea Crotti wrote: > I'm not sure for how long I had this bug, and I could not understand the > problem. > > I had a function which would return a boolean > > def func_bool(): > if x: > return True > else: return False x is a global? Poor

xml, minidom, ElementTree

2011-12-13 Thread Ethan Furman
In the near future I will need to parse and rewrite parts of a xml files created by a third-party program (PrintShopMail, for the curious). It contains both binary and textual data. There has been some strong debate about the merits of minidom vs ElementTree. Recommendations? ~Ethan~ -- http:

Re: icmp and raw sockets in python

2011-12-13 Thread Martin P. Hellwig
On 13/12/2011 16:50, Sagy Drucker wrote: hello Hi i am relatively new to python, so please be considerate... As I am only responding to one of your questions, perhaps it would be best if you don't get any other more helpful replies to split your questions up and post them separately. i'm im

Re: change a file with a context manager

2011-12-13 Thread Terry Reedy
On 12/13/2011 9:21 AM, Andrea Crotti wrote: Another possible option is to just add to the path everything contained in that correct easy_install.pth file. Or is there a way to reload the path settings? If you are talking about sys.path, you can certainly copy, mutate or replace, and restore s

Re: Fixing the XML batteries

2011-12-13 Thread ru...@yahoo.com
On Dec 13, 1:21 pm, Stefan Behnel wrote: > ru...@yahoo.com, 13.12.2011 20:37: > > > On Dec 13, 5:32 am, Stefan Behnel wrote: > >> In Python 2.7/3.2, ElementTree has support for C14N serialisation, just > >> pass the option method="c14n". > > > Where does one find information in the Python document

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On Dec 13, 7:15 pm, Ian Kelly wrote: > On Tue, Dec 13, 2011 at 1:44 AM, Eelco wrote: > > 'for i in llist' is not quite going to fly is it? Thats probably the > > reason noone ever uses that construct; its not a proper sequence type. > > Not really a problem, because fortunately Python makes it su

Re: Overriding a global

2011-12-13 Thread Joshua Landau
On 13 December 2011 19:54, Ian Kelly wrote: > On Tue, Dec 13, 2011 at 12:43 PM, Joshua Landau > wrote: > > On 13 December 2011 19:34, Ian Kelly wrote: > >> > >> On Tue, Dec 13, 2011 at 1:34 AM, Joshua Landau > >> wrote: > >> >> No, there is another difference, the reason for rebinding the name

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On Dec 13, 8:11 pm, Cameron Simpson wrote: > On 13Dec2011 00:30, Eelco wrote: > | On Dec 13, 1:27 am, alex23 wrote: > | > On Dec 13, 3:12 am, Eelco wrote: > | > > But to relate it to the topic of this thread: no, the syntax does not > | > > allow one to select the type of the resulting sequence

Re: Fixing the XML batteries

2011-12-13 Thread Stefan Behnel
ru...@yahoo.com, 13.12.2011 20:37: On Dec 13, 5:32 am, Stefan Behnel wrote: In Python 2.7/3.2, ElementTree has support for C14N serialisation, just pass the option method="c14n". Where does one find information in the Python documentation about this? Hmm, interesting. I though it had, but no

Re: Fixing the XML batteries

2011-12-13 Thread ru...@yahoo.com
On Dec 13, 5:32 am, Stefan Behnel wrote: ... > In Python 2.7/3.2, ElementTree has support for C14N serialisation, just > pass the option method="c14n". Where does one find information in the Python documentation about this? -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding a global

2011-12-13 Thread Ian Kelly
On Tue, Dec 13, 2011 at 12:43 PM, Joshua Landau wrote: > On 13 December 2011 19:34, Ian Kelly wrote: >> >> On Tue, Dec 13, 2011 at 1:34 AM, Joshua Landau >> wrote: >> >> No, there is another difference, the reason for rebinding the name. >> >> In a subclass, you would rebind a class attribute be

Re: Fixing the XML batteries

2011-12-13 Thread ru...@yahoo.com
On Dec 13, 5:32 am, Stefan Behnel wrote: ... > In Python 2.7/3.2, ElementTree has support for C14N serialisation, just > pass the option method="c14n". Where in the Python docs can one find information about this? [previous post disappeared, sorry if I double posted or replied to author inadvert

pyside dynamic buttons

2011-12-13 Thread Richard
Hi, We are making a screen with data driven buttons. I can add buttons but can't redraw the buttons for new values. The buttuns are placed in a frame. I draw the buttons on the screen in a for loop: def drawS1Butons(self): n=0 for self.S1 in self.Org.getVpuChilds(self.Focus):

Re: Overriding a global

2011-12-13 Thread Joshua Landau
On 13 December 2011 19:34, Ian Kelly wrote: > On Tue, Dec 13, 2011 at 1:34 AM, Joshua Landau > wrote: > >> No, there is another difference, the reason for rebinding the name. > >> In a subclass, you would rebind a class attribute because that > >> particular attribute, which you need to change,

Re: Fixing the XML batteries

2011-12-13 Thread Stefan Behnel
Serhiy Storchaka, 13.12.2011 19:57: 13.12.11 16:59, Stefan Behnel написав(ла): It matches my opinion though. I would be glad to divide your intentions, however ElementTree looks less documented than minidom It's certainly a lot smaller, which makes its API easier to learn and remember. an

Re: Overriding a global

2011-12-13 Thread Ian Kelly
On Tue, Dec 13, 2011 at 1:34 AM, Joshua Landau wrote: >> No, there is another difference, the reason for rebinding the name. >> In a subclass, you would rebind a class attribute because that >> particular attribute, which you need to change, is used and expected >> by external code, either in the

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Cameron Simpson
On 13Dec2011 00:30, Eelco wrote: | On Dec 13, 1:27 am, alex23 wrote: | > On Dec 13, 3:12 am, Eelco wrote: | > > But to relate it to the topic of this thread: no, the syntax does not | > > allow one to select the type of the resulting sequence. It always | > > constructs a list. | > | > So by thi

Re: Overriding a global

2011-12-13 Thread Joshua Landau
On 13 December 2011 13:30, Jean-Michel Pichavant wrote: > > writing > > x = 1 > > def spam(): > x = 2 > > is in general a bad idea. That was my point. Why? I have a few (probably wrong) guesses. Because you expect it to be the same every time you use it? Well, then this should be "in general a

Re: Fixing the XML batteries

2011-12-13 Thread Serhiy Storchaka
13.12.11 16:59, Stefan Behnel написав(ла): It matches my opinion though. I would be glad to divide your intentions, however ElementTree looks less documented than minidom, and is not full replacement. For example, I haven't found how to get XML encoding. Also, at use of ElementTree instead o

Re: boolean from a function

2011-12-13 Thread Ethan Furman
Andrea Crotti wrote: I'm not sure for how long I had this bug, and I could not understand the problem. I had a function which would return a boolean def func_bool(): if x: return True else: return False Now somewhere else I had if func_bool: # do something I could not qu

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Ian Kelly
On Tue, Dec 13, 2011 at 1:44 AM, Eelco wrote: > 'for i in llist' is not quite going to fly is it? Thats probably the > reason noone ever uses that construct; its not a proper sequence type. Not really a problem, because fortunately Python makes it super-easy to create custom iterators. def listi

Re: text to html

2011-12-13 Thread Grant Edwards
On 2011-12-13, Pedro Henrique Guedes Souto wrote: > On Tue, Dec 13, 2011 at 3:22 PM, prakash jp wrote: > >> Want to publish a log file as a web page, is there a parser to retain >> the format of the text as is and then convert to html. Please provide >> the relevant pointers > > > Hey, You can us

Re: boolean from a function

2011-12-13 Thread Duncan Booth
Andrea Crotti wrote: > I'm not sure for how long I had this bug, and I could not understand > the problem. > > I had a function which would return a boolean > > def func_bool(): > if x: > return True > else: return False > > Now somewhere else I had > > if func_bool: >

Re: text to html

2011-12-13 Thread Pedro Henrique Guedes Souto
On Tue, Dec 13, 2011 at 3:22 PM, prakash jp wrote: > > Hi All, > > Want to publish a log file as a web page, is there a parser to retain the > format of the text as is and then convert to html. Please provide the > relevant pointers Hey, You can use this: http://txt2tags.org/ Att; Pedro Henri

Re: boolean from a function

2011-12-13 Thread Grant Edwards
On 2011-12-13, Andrea Crotti wrote: > Now somewhere else I had > > if func_bool: > # do something > > I could not quite understand why it was always true, until I finally > noticed that the () were missing. Is there some tool to avoid these > stupid mistakes? (pylint doesn't warn me on that)

text to html

2011-12-13 Thread prakash jp
Hi All, Want to publish a log file as a web page, is there a parser to retain the format of the text as is and then convert to html. Please provide the relevant pointers Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Using methodcaller in a list sort - any examples anywhere?

2011-12-13 Thread Tim Chase
On 12/13/11 09:48, tinn...@isbd.co.uk wrote: I want to sort a list of 'things' (they're fairly complex objects) by the contents of one of the fields I can extract from the 'things' using a Python function. So I have a list L which is a list of objects of some sort. I can output the contents of

Re: Using methodcaller in a list sort - any examples anywhere?

2011-12-13 Thread tinnews
Peter Otten <__pete...@web.de> wrote: > tinn...@isbd.co.uk wrote: > > > I want to sort a list of 'things' (they're fairly complex objects) by > > the contents of one of the fields I can extract from the 'things' > > using a Python function. > > > > So I have a list L which is a list of objects of

Re: logging issues

2011-12-13 Thread Andrea Crotti
And by the way suppose I have a script which takes as input the log level and a list of possible filters. In another file I have a couple of functions as below which are called in that order. Is that supposed to work? In theory I'm getting both times the same logger. The set_verbosity seems to do

icmp and raw sockets in python

2011-12-13 Thread Sagy Drucker
hello i am relatively new to python, so please be considerate... i'm implementing a server and a client via raw_sockets. i have the necessary privileges. now, the server i defined so: host = socket.gethostbyname(socket.gethostname()) address = (host, 4) sockSer = socket.socket(socket.AF_INET,

Re: Getting the current directory path and the path where python script is saved

2011-12-13 Thread Thomas Bach
gialloporpora writes: > I would like to know how to obtain the path where script is executed > and the path where the file script is stored. Does this help: In [16]: import os In [19]: os.getcwd() Out[19]: '/home/vince' In [21]: os.__file__ Out[21]: '/home/vince/src/pyramid_install/lib/python

Re: Signature-preserving decorators

2011-12-13 Thread Ian Kelly
On Tue, Dec 13, 2011 at 6:36 AM, Henrik Faber wrote: > Hi group, > > when decorating a method in Python3, by use of the > functools.update_wrapper function, it can be achieved that the docstring > and name of the original function is preseverved. > > However, the prototype is lost: When looking in

Re: Getting the current directory path and the path where python script is saved

2011-12-13 Thread Neil Cerutti
On 2011-12-13, gialloporpora wrote: > Dear all, > I would like to create a little script to rename my files, I think to > use argparse module to create it. > I would like to know how to obtain the path where script is executed and > the path where the file script is stored. > > For example, if I

boolean from a function

2011-12-13 Thread Andrea Crotti
I'm not sure for how long I had this bug, and I could not understand the problem. I had a function which would return a boolean def func_bool(): if x: return True else: return False Now somewhere else I had if func_bool: # do something I could not quite understand why it

Re: logging issues

2011-12-13 Thread Andrea Crotti
On 12/13/2011 04:11 PM, Jean-Michel Pichavant wrote: Not really, if you use the classic way, your subloggers should be created an never configured. Their default behavior is to raise any log event to its parent. That way, all event logs end up being handled by the root logger. Ok thanks now

Re: Using methodcaller in a list sort - any examples anywhere?

2011-12-13 Thread Peter Otten
tinn...@isbd.co.uk wrote: > I want to sort a list of 'things' (they're fairly complex objects) by > the contents of one of the fields I can extract from the 'things' > using a Python function. > > So I have a list L which is a list of objects of some sort. I can > output the contents of a field

Re: logging issues

2011-12-13 Thread Jean-Michel Pichavant
Andrea Crotti wrote: I think is simple but I can't get it to work as I wish. Suppose I have a big application, my idea is that the running script sets a global logging level and then all the imported modules would act consequently. In my codebase, however, unless I set the level for each of the

Using methodcaller in a list sort - any examples anywhere?

2011-12-13 Thread tinnews
I want to sort a list of 'things' (they're fairly complex objects) by the contents of one of the fields I can extract from the 'things' using a Python function. So I have a list L which is a list of objects of some sort. I can output the contents of a field in the list as follows:- for k in

logging issues

2011-12-13 Thread Andrea Crotti
I think is simple but I can't get it to work as I wish. Suppose I have a big application, my idea is that the running script sets a global logging level and then all the imported modules would act consequently. In my codebase, however, unless I set the level for each of the loggers I don't get th

Re: Fixing the XML batteries

2011-12-13 Thread Stefan Behnel
Serhiy Storchaka, 13.12.2011 15:27: 13.12.11 14:32, Stefan Behnel написав(ла): I stripped my name from the quoted context because I didn't say this. I am glad to hear this. ;) It matches my opinion though. I use xml.dom.minidom for XML canonization and convertion: Do you mean "canonicali

Re: Fixing the XML batteries

2011-12-13 Thread Serhiy Storchaka
13.12.11 14:32, Stefan Behnel написав(ла): I stripped my name from the quoted context because I didn't say this. I am glad to hear this. ;) I use xml.dom.minidom for XML canonization and convertion: Do you mean "canonicalisation"? I.e. C14N? That's not what the code below is doing, not at al

Re: Dynamic variable creation from string

2011-12-13 Thread 88888 Dihedral
On Tuesday, December 13, 2011 9:35:52 AM UTC+8, Steven D'Aprano wrote: > On Mon, 12 Dec 2011 15:45:06 -0800, alex23 wrote: > > > On Dec 12, 10:49 pm, 8 Dihedral > > wrote: > >> This is the way to write an assembler or to roll out a script language > >> to be included in an app by users. > >

Re: change a file with a context manager

2011-12-13 Thread Andrea Crotti
On 12/13/2011 10:59 AM, Andrea Crotti wrote: So I have the following problem, I need something to copy a file to a certain position and restore it after. So I wrote this simple context manager: class WithCorrectEasyInstall(object): def __enter__(self): import pkg_resources

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On 13 dec, 14:14, Chris Angelico wrote: > On Tue, Dec 13, 2011 at 11:47 PM, Eelco wrote: > >> def f(*args) *constructs* a tuple, it > >> doesn't perform a type-check. > > > I am talking about type constraints... A type-check is something > > along the lines of type(args)==list, a runtime thing an

Signature-preserving decorators

2011-12-13 Thread Henrik Faber
Hi group, when decorating a method in Python3, by use of the functools.update_wrapper function, it can be achieved that the docstring and name of the original function is preseverved. However, the prototype is lost: When looking into the Python help, I have lots of entries that look like: getfoo

Re: Overriding a global

2011-12-13 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Tue, 13 Dec 2011 10:54:51 +0100, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Mon, 12 Dec 2011 12:13:33 +0100, Jean-Michel Pichavant wrote: Using the same name for 2 different objects is a bad idea in general. We have na

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Chris Angelico
On Tue, Dec 13, 2011 at 11:47 PM, Eelco wrote: >> def f(*args) *constructs* a tuple, it >> doesn't perform a type-check. > > I am talking about type constraints... A type-check is something > along the lines of type(args)==list, a runtime thing and something > completely different. I havnt mention

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On 13 dec, 12:13, Steven D'Aprano wrote: > On Tue, 13 Dec 2011 01:15:46 -0800, Eelco wrote: > > On Dec 13, 3:43 am, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote: > >> On Mon, 12 Dec 2011 04:21:15 -0800, Eelco wrote: > >> >> No more, or less, explicit than the difference between "==" a

Re: automate commands to an .exe console program through python

2011-12-13 Thread Chris Angelico
On Tue, Dec 13, 2011 at 11:35 PM, Juan Perez wrote: > My problem is thinking in windows console somewhat like linux shell, and do > same things I did with pipes in C programming. But it seems not to be the > case. It is (at least, it supports the basics of pipes and redirection); but what you're

Re: automate commands to an .exe console program through python

2011-12-13 Thread Juan Perez
Thank you for your responses, My problem is thinking in windows console somewhat like linux shell, and do same things I did with pipes in C programming. But it seems not to be the case. At a glance I dare say that sendkeys module is useful enough, but if I've understood well, you only can send me

Re: Fixing the XML batteries

2011-12-13 Thread Stefan Behnel
Serhiy Storchaka, 13.12.2011 13:17: 09.12.11 17:09, Dirkjan Ochtman wrote: An at least somewhat informed +1 from me. The ElementTree API is a very good way to deal with XML from Python, and it deserves to be promoted over the included alternatives. Let's deprecate the NiCad batteries and try to

Re: Fixing the XML batteries

2011-12-13 Thread Serhiy Storchaka
09.12.11 17:09, Dirkjan Ochtman wrote: On Fri, Dec 9, 2011 at 09:02, Stefan Behnel wrote: An at least somewhat informed +1 from me. The ElementTree API is a very good way to deal with XML from Python, and it deserves to be promoted over the included alternatives. Let's deprecate the NiCad batte

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On 13 dec, 12:28, Steven D'Aprano wrote: > On Tue, 13 Dec 2011 02:46:13 -0800, Eelco wrote: > > With all this being said, I must say that the notion of indtroducing > > type constraints into Python is quite a radical one*, > > Not that radical. Here's the creator of Python musing about adding > op

Re: Fixing the XML batteries

2011-12-13 Thread Serhiy Storchaka
09.12.11 17:09, Dirkjan Ochtman wrote: On Fri, Dec 9, 2011 at 09:02, Stefan Behnel wrote: An at least somewhat informed +1 from me. The ElementTree API is a very good way to deal with XML from Python, and it deserves to be promoted over the included alternatives. Let's deprecate the NiCad batte

Re: automate commands to an .exe console program through python

2011-12-13 Thread Tim Golden
On 13/12/2011 11:21, Juan Perez wrote: Well, if developers have to change something to the code, I'd continue with autoit, since is closer to real enviroment. You are right, autoit work by send parametres to GUI focused, but really I don't think it's something necessary for my purposes as I need

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Steven D'Aprano
On Tue, 13 Dec 2011 02:46:13 -0800, Eelco wrote: > With all this being said, I must say that the notion of indtroducing > type constraints into Python is quite a radical one*, Not that radical. Here's the creator of Python musing about adding optional type checks to Python: http://www.artima.c

Re: automate commands to an .exe console program through python

2011-12-13 Thread Chris Angelico
On Tue, Dec 13, 2011 at 10:21 PM, Juan Perez wrote: > Well, if developers have to change something to the code, I'd continue with > autoit, since is closer to real enviroment. You are right, autoit work by > send parametres to GUI focused, but really I don't think it's something > necessary for my

Re: automate commands to an .exe console program through python

2011-12-13 Thread Juan Perez
Well, if developers have to change something to the code, I'd continue with autoit, since is closer to real enviroment. You are right, autoit work by send parametres to GUI focused, but really I don't think it's something necessary for my purposes as I need only send parameters to a windows cmd con

Re: Overriding a global

2011-12-13 Thread Steven D'Aprano
On Tue, 13 Dec 2011 10:54:51 +0100, Jean-Michel Pichavant wrote: > Steven D'Aprano wrote: >> On Mon, 12 Dec 2011 12:13:33 +0100, Jean-Michel Pichavant wrote: >> >> >>> Using the same name for 2 different objects is a bad idea in general. >>> >>> >> We have namespaces precisely so you don

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Steven D'Aprano
On Tue, 13 Dec 2011 01:15:46 -0800, Eelco wrote: > On Dec 13, 3:43 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Mon, 12 Dec 2011 04:21:15 -0800, Eelco wrote: >> >> No more, or less, explicit than the difference between "==" and >> >> "is". >> >> > == may be taken to mean iden

NumPy book review copies

2011-12-13 Thread Jitesh
Hi, As a part of our reviewing program, we are giving away limited number of copies (print & electronic) of our recent publication NumPy 1.5 Beginner's Guide to people interested in reviewing the book. Book-link: http://link.packtpub.com/sibctR You need to publish your review/feedback on either

change a file with a context manager

2011-12-13 Thread Andrea Crotti
So I have the following problem, I need something to copy a file to a certain position and restore it after. So I wrote this simple context manager: class WithCorrectEasyInstall(object): def __enter__(self): import pkg_resources from shutil import copyfile easy_insta

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
With all this being said, I must say that the notion of indtroducing type constraints into Python is quite a radical one*, and one that should not be taken lightly, so I understand the general conservative vibe the notion is getting. It probably has implications beyond just collection types, and if

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On 13 dec, 11:15, Arnaud Delobelle wrote: > On 13 December 2011 09:50, Eelco wrote: > > >> To answer that question: for the same reasons. The conversion is > >> wasteful; allowing python to do the right thing based on a > >> typeconstraint is not. Plus, it is less code, and more readable code; >

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Arnaud Delobelle
On 13 December 2011 09:50, Eelco wrote: >> To answer that question: for the same reasons. The conversion is >> wasteful; allowing python to do the right thing based on a >> typeconstraint is not. Plus, it is less code, and more readable code; >> the only rule you have to learn is quite general, wh

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
> To answer that question: for the same reasons. The conversion is > wasteful; allowing python to do the right thing based on a > typeconstraint is not. Plus, it is less code, and more readable code; > the only rule you have to learn is quite general, which is that :: is > a type constraint annotat

Re: Outputting raw MIDI in realtime on Linux

2011-12-13 Thread Peter Billam
On 2011-12-12, alex23 wrote: > On Dec 12, 12:14 pm, Nick Irvine wrote: >> What do people use to output live MIDI on Linux, assuming it's >> possible? > I've yet to try this myself although it's long been on my to-do list. > There are a couple of packages on PyPI that emit MIDI: > http://pypi.pyth

Re: Overriding a global

2011-12-13 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 12 Dec 2011 12:13:33 +0100, Jean-Michel Pichavant wrote: Using the same name for 2 different objects is a bad idea in general. We have namespaces precisely so you don't need to care about making names globally unique. I don't get your point, name

Re: PyDev and multithreaded application debug

2011-12-13 Thread Fabio Zadrozny
On Mon, Dec 12, 2011 at 2:30 PM, Massi wrote: > Hi everyone, I've just started to use pydev to develop my python > application and I'm encountering some problems to debug it. The > application I'm dealing with is a multithreaded application; when I > try to debug it with pydev, it seems not to be

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
> > Python users generally follow the rule "explicit is better than > > implicit".  Setting a general constraint and letting the language "do > > the right thing" is a kind of black magic that feels off because it > > tends to break that rule.  But that's not to say that black magic > > never wins

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On Dec 13, 3:43 am, Steven D'Aprano wrote: > On Mon, 12 Dec 2011 04:21:15 -0800, Eelco wrote: > >> No more, or less, explicit than the difference between "==" and "is". > > > == may be taken to mean identity comparison; 'equals' can only mean one > > thing. > > Nonsense. "Equals" can be taken to m

Re: Overriding a global

2011-12-13 Thread Antoon Pardon
On 12/10/2011 09:47 PM, Roy Smith wrote: I've got a code pattern I use a lot. In each module, I create a logger for the entire module and log to it all over: logger = logging.getLogger('my.module.name') class Foo: def function(self): logger.debug('stuff') logger.debug('other

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On Dec 13, 2:41 am, Ian Kelly wrote: > On Mon, Dec 12, 2011 at 4:40 PM, Eelco wrote: > >> For a linked list, no *target and no copying is needed: > > >> head, tail = llist > > > I have no idea what this means. > > Each node of a linked list consists of a data member and a "next" > member, that ho

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On Dec 13, 1:34 am, Ian Kelly wrote: > On Mon, Dec 12, 2011 at 11:51 AM, Eelco wrote: > > Either way, its not hard to add some detail to the semantics to allow > > all this. Even this function definition: > > > def func(Foo(args), Foo(kwargs)) > > > ...could even be defined unambigiously by overl

Re: Verbose and flexible args and kwargs syntax

2011-12-13 Thread Eelco
On Dec 13, 1:27 am, alex23 wrote: > On Dec 13, 3:12 am, Eelco wrote: > > > But to relate it to the topic of this thread: no, the syntax does not > > allow one to select the type of the resulting sequence. It always > > constructs a list. > > So by this argument, _every_ function that returns a li

Re: Overriding a global

2011-12-13 Thread Joshua Landau
On 13/12/2011, Ian Kelly wrote: > On Mon, Dec 12, 2011 at 4:48 PM, Joshua Landau > wrote: >> Rebinding logger locally in a function is really no >> different to a subclass rebinding a variable from its main class using >> that >> class' value. The only difference is that, in that case, you have a