Re: Two Questions about Python on Windows

2014-04-05 Thread Tim Roberts
maxerick...@gmail.com wrote: > >You can also edit the PATHEXT environment variable to include .py/.pyw, >making the python source files executable (as long as the types are >properly registered with Windows; if double clicking runs them they >should be properly registered). Let me clarify that ju

Re: Two Questions about Python on Windows

2014-04-03 Thread Mark Lawrence
On 03/04/2014 23:41, Ian Kelly wrote: On Thu, Apr 3, 2014 at 2:15 PM, Mark Lawrence wrote: On 03/04/2014 18:54, Ian Kelly wrote: On Apr 3, 2014 11:12 AM, "Walter Hurry" mailto:walterhu...@gmail.com>> wrote: > > Normally my Python development is done on FreeBSD and Linux. I know that on *

Re: Two Questions about Python on Windows

2014-04-03 Thread Ian Kelly
On Thu, Apr 3, 2014 at 2:15 PM, Mark Lawrence wrote: > On 03/04/2014 18:54, Ian Kelly wrote: >> >> >> On Apr 3, 2014 11:12 AM, "Walter Hurry" > > wrote: >> > >> > Normally my Python development is done on FreeBSD and Linux. I know >> that on *ix I simply have to mak

Re: Two Questions about Python on Windows

2014-04-03 Thread Mark Lawrence
On 03/04/2014 18:54, Ian Kelly wrote: On Apr 3, 2014 11:12 AM, "Walter Hurry" mailto:walterhu...@gmail.com>> wrote: > > Normally my Python development is done on FreeBSD and Linux. I know that on *ix I simply have to make foo.py executable (the shebang line is present, of course) to make it ru

Re: Two Questions about Python on Windows

2014-04-03 Thread Ethan Furman
On 04/03/2014 10:54 AM, Ian Kelly wrote: On Apr 3, 2014 11:12 AM, "Walter Hurry" wrote: Secondly, on *ix, if there's an up-to-date .pyc in the right place and I run foo.py, Python will automagically use foo.pyc. I don't believe this is exactly correct. Python will only use a .pyc automatica

Re: Two Questions about Python on Windows

2014-04-03 Thread Terry Reedy
On 4/3/2014 1:06 PM, Walter Hurry wrote: Normally my Python development is done on FreeBSD and Linux. I know that on *ix I simply have to make foo.py executable (the shebang line is present, of course) to make it runnable. For my son's school assignment, I have to help him with Python for Wind

Re: Two Questions about Python on Windows

2014-04-03 Thread Ian Kelly
On Apr 3, 2014 11:12 AM, "Walter Hurry" wrote: > > Normally my Python development is done on FreeBSD and Linux. I know that on *ix I simply have to make foo.py executable (the shebang line is present, of course) to make it runnable. > > For my son's school assignment, I have to help him with Pytho

Re: Two Questions about Python on Windows

2014-04-03 Thread maxerickson
On Thursday, April 3, 2014 1:06:29 PM UTC-4, Walter Hurry wrote: > Normally my Python development is done on FreeBSD and Linux. I know that on > *ix I simply have to make foo.py executable (the shebang line is present, of > course) to make it runnable. > > For my son's school assignment, I have

Two Questions about Python on Windows

2014-04-03 Thread Walter Hurry
Normally my Python development is done on FreeBSD and Linux. I know that on *ix I simply have to make foo.py executable (the shebang line is present, of course) to make it runnable. For my son's school assignment, I have to help him with Python for Windows. As I understand it, on Windows a .py

Re: Problems on these two questions

2012-11-20 Thread Neil Cerutti
On 2012-11-19, Dennis Lee Bieber wrote: > On Sun, 18 Nov 2012 17:52:35 -0800 (PST), su29090 > <129k...@gmail.com> declaimed the following in > gmane.comp.python.general: > >> >> I all of the other problems but I have issues with these: >> >> 1.Given a positive integer n , assign True to is_pri

Re: Problems on these two questions

2012-11-19 Thread Ian Kelly
On Mon, Nov 19, 2012 at 4:15 PM, Dennis Lee Bieber wrote: > On Sun, 18 Nov 2012 17:52:35 -0800 (PST), su29090 <129k...@gmail.com> > declaimed the following in gmane.comp.python.general: > >> >> I all of the other problems but I have issues with these: >> >> 1.Given a positive integer n , assign T

Re: Problems on these two questions

2012-11-19 Thread Dave Angel
On 11/19/2012 06:16 PM, Dennis Lee Bieber wrote: > On Sun, 18 Nov 2012 21:18:19 -0500, Dave Angel declaimed > the following in gmane.comp.python.general: > > >> if is_a_prime(n): >> is_prime = True >> >> Now all you have to do is write is_a_prime(). if you get stuck, please >> show us what yo

Re: Problems on these two questions

2012-11-18 Thread Dave Angel
On 11/18/2012 09:15 PM, su29090 wrote: > > I'm using Python 3.2 In Python 3.2, xrange has been renamed to range. So have you tried to solve problem #2 yet? -- DaveA -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems on these two questions

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 12:52 PM, su29090 <129k...@gmail.com> wrote: > 1.Given a positive integer n , assign True to is_prime if n has no factors > other than 1 and itself. (Remember, m is a factor of n if m divides n > evenly.) > > 2.An arithmetic progression is a sequence of numbers in

Re: Problems on these two questions

2012-11-18 Thread su29090
On Sunday, November 18, 2012 8:52:35 PM UTC-5, su29090 wrote: > I did all of the other problems but I have issues with these: > > > > 1.Given a positive integer n , assign True to is_prime if n has no factors > other than 1 and itself. (Remember, m is a factor of n if m divides n > eve

Re: Problems on these two questions

2012-11-18 Thread Dave Angel
On 11/18/2012 08:52 PM, su29090 wrote: > I all of the other problems but I have issues with these: > > 1.Given a positive integer n , assign True to is_prime if n has no factors > other than 1 and itself. (Remember, m is a factor of n if m divides n > evenly.) if is_a_prime(n): is_p

Re: Problems on these two questions

2012-11-18 Thread Mark Lawrence
On 19/11/2012 01:52, su29090 wrote: I all of the other problems but I have issues with these: 1.Given a positive integer n , assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) 2.An arithmetic progression is a se

Problems on these two questions

2012-11-18 Thread su29090
I all of the other problems but I have issues with these: 1.Given a positive integer n , assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) 2.An arithmetic progression is a sequence of numbers in which the distan

Re: Subprocess puzzle and two questions

2012-11-16 Thread Nobody
On Thu, 15 Nov 2012 20:07:38 -0500, Roy Smith wrote: >>> gethostbyname() and getaddrinfo() use the NSS (name-service switch) >> mechanism, which is configured via /etc/nsswitch.conf. Depending upon >> configuration, hostnames can be looked up via a plain text file >> (/etc/hosts), Berkeley DB file

Re: Subprocess puzzle and two questions

2012-11-15 Thread Roy Smith
In article , Nobody wrote: > That's because the high-level routines aren't tied to DNS. This is true. >> gethostbyname() and getaddrinfo() use the NSS (name-service switch) > mechanism, which is configured via /etc/nsswitch.conf. Depending upon > configuration, hostnames can be looked up via a

Re: Subprocess puzzle and two questions

2012-11-15 Thread Nobody
On Wed, 14 Nov 2012 20:49:19 -0500, Roy Smith wrote: >> I'm slightly surprised that there's no way with the Python stdlib to >> point a DNS query at a specific server > > Me too, including the "only slightly" part. The normal high-level C > resolver routines (getaddrinfo/getnameinfo, or even t

DNS from Python (was Re: Subprocess puzzle and two questions)

2012-11-14 Thread Aahz
In article , Chris Angelico wrote: >On Thu, Nov 15, 2012 at 3:20 AM, Roy Smith wrote: >> >> My first thought to solve both of these is that it shouldn't be too >> hard to hand-craft a minimal DNS query and send it over UDP. Then, I >> hunted around a bit and found that somebody had already don

Re: Subprocess puzzle and two questions

2012-11-14 Thread Kushal Kumaran
Chris Angelico writes: > On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith wrote: >> In article , >> Chris Angelico wrote: >> >>> I'm slightly surprised that there's no way with the Python stdlib to >>> point a DNS query at a specific server >> >> Me too, including the "only slightly" part. The nor

Re: Subprocess puzzle and two questions

2012-11-14 Thread Dave Angel
On 11/14/2012 09:21 PM, Chris Angelico wrote: > On Thu, Nov 15, 2012 at 1:10 PM, Roy Smith wrote: >> In article , >> Chris Angelico wrote: >> >>> Indeed. But Python boasts that the batteries are included, and given >>> the wealth of other networking facilities that are available, it is a >>> bit

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 1:10 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> Indeed. But Python boasts that the batteries are included, and given >> the wealth of other networking facilities that are available, it is a >> bit of a hole that you can't run DNS queries in this way.

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
In article , Chris Angelico wrote: > Indeed. But Python boasts that the batteries are included, and given > the wealth of other networking facilities that are available, it is a > bit of a hole that you can't run DNS queries in this way. Think of the socket and struct modules as a pile of carbo

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> I'm slightly surprised that there's no way with the Python stdlib to >> point a DNS query at a specific server > > Me too, including the "only slightly" part. The normal high-level C > resolver routin

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
In article , Chris Angelico wrote: > I'm slightly surprised that there's no way with the Python stdlib to > point a DNS query at a specific server Me too, including the "only slightly" part. The normal high-level C resolver routines (getaddrinfo/getnameinfo, or even the old gethostbyname se

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 3:20 AM, Roy Smith wrote: > I wrote: >>> Oh, my. You're using DNS as a replacement for ping? Fair enough. In >>> that case, all you really care about is that you can connect to port 53 >>> on the server... >>> >>> s = socket.socket() >>> s.connect(('8.8.8.8', 53)) > > In

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
I wrote: >> Oh, my. You're using DNS as a replacement for ping? Fair enough. In >> that case, all you really care about is that you can connect to port 53 >> on the server... >> >> s = socket.socket() >> s.connect(('8.8.8.8', 53)) In article , Chris Angelico wrote: >That assumes that (a) the

Re: Subprocess puzzle and two questions

2012-11-14 Thread wrw
On Nov 14, 2012, at 9:22 AM, Roy Smith wrote: > In article , > William Ray Wing wrote: > >> On Nov 13, 2012, at 11:41 PM, Roy Smith wrote: >> >>> In article , >>> w...@mac.com wrote: >>> I need to time the operation of a command-line utility (specifically nslookup) from within a p

Re: Subprocess puzzle and two questions

2012-11-14 Thread Chris Angelico
On Thu, Nov 15, 2012 at 1:22 AM, Roy Smith wrote: > Oh, my. You're using DNS as a replacement for ping? Fair enough. In > that case, all you really care about is that you can connect to port 53 > on the server... > > import socket > import time > s = socket.socket() > t0 = time.time() > s.conne

Re: Subprocess puzzle and two questions

2012-11-14 Thread Roy Smith
In article , William Ray Wing wrote: > On Nov 13, 2012, at 11:41 PM, Roy Smith wrote: > > > In article , > > w...@mac.com wrote: > > > >> I need to time the operation of a command-line utility (specifically > >> nslookup) from within a python program I'm writing. > > > > Ugh. Why are you d

Re: Subprocess puzzle and two questions

2012-11-13 Thread Tim Roberts
w...@mac.com wrote: >... >However, if I try the same operation in the python interpreter using >subprocess.Popen like so: > import subprocess result = subprocess.Popen(['time', 'nslookup', 'www.es.net', '8.8.4.4'], shell = False, stdout = subprocess.PIPE, stderr = subprocess.

Re: Subprocess puzzle and two questions

2012-11-13 Thread Kushal Kumaran
w...@mac.com writes: > I need to time the operation of a command-line utility (specifically > nslookup) from within a python program I'm writing. I don't want to use > python's timeit function because I'd like to avoid python's subprocess > creation overhead. That leads me to the standard UNI

Re: Subprocess puzzle and two questions

2012-11-13 Thread William Ray Wing
On Nov 13, 2012, at 11:41 PM, Roy Smith wrote: > In article , > w...@mac.com wrote: > >> I need to time the operation of a command-line utility (specifically >> nslookup) from within a python program I'm writing. > > Ugh. Why are you doing this? Shelling out to nslookup is an incredibly > s

Re: Subprocess puzzle and two questions

2012-11-13 Thread Roy Smith
In article , w...@mac.com wrote: > I need to time the operation of a command-line utility (specifically > nslookup) from within a python program I'm writing. Ugh. Why are you doing this? Shelling out to nslookup is an incredibly slow and clumsy way of doing name translation. What you really

Subprocess puzzle and two questions

2012-11-13 Thread wrw
I need to time the operation of a command-line utility (specifically nslookup) from within a python program I'm writing. I don't want to use python's timeit function because I'd like to avoid python's subprocess creation overhead. That leads me to the standard UNIX time function. So for examp

Re: Two questions about logging

2012-01-15 Thread Vinay Sajip
On Jan 12, 2:19 am, Matthew Pounsett wrote: > First, I'd like to be able to permit users to do more typical log > rotation, based on their OS's log rotation handler, rather than > rotating logs from inside an application.  This is usually handled by > signalling an application with a HUP, whereup

Re: Two questions about logging

2012-01-14 Thread Matthew Pounsett
On Jan 12, 8:03 pm, K Richard Pixley wrote: > Here's the confusion.  Each log named __name__ is under the root logger. >   If you want them all, then catch them all with the root logger. Thanks! I knew I was missing something obvious. Between you and Jean- Michael Pichavant I've figured out wha

Re: Two questions about logging

2012-01-12 Thread K Richard Pixley
On 1/11/12 18:19 , Matthew Pounsett wrote: Second, I'm trying to get a handle on how libraries are meant to integrate with the applications that use them. The naming advice in the advanced tutorial is to use __name__ to name loggers, and to allow log messages to pass back up to the using applica

Re: Two questions about logging

2012-01-12 Thread Jean-Michel Pichavant
Matthew Pounsett wrote: [snip] Second, I'm trying to get a handle on how libraries are meant to integrate with the applications that use them. The naming advice in the advanced tutorial is to use __name__ to name loggers, and to allow log messages to pass back up to the using application's logg

Re: Two questions about logging

2012-01-11 Thread Matthew Pounsett
On Jan 11, 9:34 pm, Roy Smith wrote: > What I would do is log to syslog (logging.handlers.SysLogHandler) and > let syslog worry about rotating log files.  Why reinvent the wheel? Syslog is fine for an application run by an administrator, but isn't an option for a user. -- http://mail.python.org/

Re: Two questions about logging

2012-01-11 Thread Roy Smith
In article <7dabf43f-3814-47b6-966a-1439f5654...@i6g2000vbk.googlegroups.com>, Matthew Pounsett wrote: > First, I'd like to be able to permit users to do more typical log > rotation, based on their OS's log rotation handler, rather than > rotating logs from inside an application. This is usual

Two questions about logging

2012-01-11 Thread Matthew Pounsett
I'm trying to figure out a couple of things with the logging module, and I'm hoping someone can provide some pointers. I've read through the module docs on python.org, the basic and advanced tutorials, and the cookbook post, but a couple of things still elude me. First, I'd like to be able to per

Re: Two questions ( Oracle and modules )

2009-12-07 Thread Terry Reedy
Gabor Urban wrote: Hi guys, 2. We have tp write a module that will be imported a couple of places. Though we must be sure, this module's initialization is performed only once. How can we implement this? I do not know what to google for. There are two ways to have one file executed twice

Re: Two questions ( Oracle and modules )

2009-12-07 Thread Michael Crute
On Mon, Dec 7, 2009 at 6:57 AM, Gabor Urban wrote: > 1. I have choice to introduce Python to my new employee. We are to > write and application that uses databases stored partially in Oracle > 10 and partially in Oracle 11. We have to execute standard SQL > commands and stored procedures as well.

Two questions ( Oracle and modules )

2009-12-07 Thread Gabor Urban
Hi guys, I have two questions. 1. I have choice to introduce Python to my new employee. We are to write and application that uses databases stored partially in Oracle 10 and partially in Oracle 11. We have to execute standard SQL commands and stored procedures as well. Which is best conection

Re: Two questions about style and some simple math

2009-01-20 Thread Rhodri James
On Tue, 20 Jan 2009 02:11:24 -, Mensanator wrote: On Jan 19, 7:44 pm, "Rhodri James" wrote: Surely in any case you don't want an expression based on the difference, since that would give you the same chance of having the first attack no matter what the levels of courage actually were, whi

Re: Two questions about style and some simple math

2009-01-20 Thread J Kenneth King
Spoofy writes: > .. .. > > 2. > > For maintaining the character attributes I creates a seperate class. I > wonder weather this is an "overuse" of OO (instead of just making the > attributes plain variables of the Char class) and if the way I wrote > this is OK (somehow this looks cool to me but

Re: Two questions about style and some simple math

2009-01-19 Thread John Machin
On Jan 20, 12:15 pm, Spoofy wrote: > Hello everybody! > > Though I'm a hobby programmer for years now (mainly small hackery > things) I still have big problems getting "real" things to work. > > I'm currently trying to write a simple RPG and have problems with > the following: > > 1. > > Character

Re: Two questions about style and some simple math

2009-01-19 Thread Mensanator
On Jan 19, 7:44 pm, "Rhodri James" wrote: > On Tue, 20 Jan 2009 01:15:47 -, Spoofy wrote: > > Hello everybody! > > > Though I'm a hobby programmer for years now (mainly small hackery   > > things) I still have big problems getting "real" things to work. > > > I'm currently trying to write a s

Re: Two questions about style and some simple math

2009-01-19 Thread MRAB
Spoofy wrote: Hello everybody! Though I'm a hobby programmer for years now (mainly small hackery things) I still have big problems getting "real" things to work. I'm currently trying to write a simple RPG and have problems with the following: 1. Characters have a "courage" attribute that

Re: Two questions about style and some simple math

2009-01-19 Thread Rhodri James
On Tue, 20 Jan 2009 01:15:47 -, Spoofy wrote: Hello everybody! Though I'm a hobby programmer for years now (mainly small hackery things) I still have big problems getting "real" things to work. I'm currently trying to write a simple RPG and have problems with the following: 1. Cha

Two questions about style and some simple math

2009-01-19 Thread Spoofy
Hello everybody! Though I'm a hobby programmer for years now (mainly small hackery things) I still have big problems getting "real" things to work. I'm currently trying to write a simple RPG and have problems with the following: 1. Characters have a "courage" attribute that basically deter

[EMAIL PROTECTED]: Re: overriding methods - two questions]

2007-11-19 Thread J. Clifford Dyer
On Mon, Nov 19, 2007 at 04:33:39PM +0100, Bruno Desthuilliers wrote regarding Re: overriding methods - two questions: > > J. Clifford Dyer a ?crit : > > On Mon, Nov 19, 2007 at 01:41:46PM +0100, Bruno Desthuilliers wrote > > regarding Re: overriding methods - two questions: &g

Re: overriding methods - two questions

2007-11-19 Thread Bruno Desthuilliers
J. Clifford Dyer a écrit : > On Mon, Nov 19, 2007 at 01:41:46PM +0100, Bruno Desthuilliers wrote regarding > Re: overriding methods - two questions: >> Steven D'Aprano a ?crit : >>> On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: >>> >>&

Re: overriding methods - two questions

2007-11-19 Thread George Sakkis
On Nov 19, 7:44 am, Bruno Desthuilliers wrote: > George Sakkis a écrit : > > > > > On Nov 16, 5:03 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > >> On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: > Question 1: > Given that the user of the API ca

Re: overriding methods - two questions

2007-11-19 Thread J. Clifford Dyer
On Mon, Nov 19, 2007 at 01:41:46PM +0100, Bruno Desthuilliers wrote regarding Re: overriding methods - two questions: > > Steven D'Aprano a ?crit : > > On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: > > > >>> Question 1: > >>> >

Re: overriding methods - two questions

2007-11-19 Thread Bruno Desthuilliers
George Sakkis a écrit : > On Nov 16, 5:03 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: > >> On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: Question 1: Given that the user of the API can choose to override foo() or not, how can I control the sig

Re: overriding methods - two questions

2007-11-19 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: > >>> Question 1: >>> >>> Given that the user of the API can choose to override foo() or not, how >>> can I control the signature that they use? >> While technically possible (using inspect.getargspec), tryi

Re: overriding methods - two questions

2007-11-17 Thread Steven D'Aprano
On Fri, 16 Nov 2007 18:30:28 -0800, George Sakkis wrote: > On Nov 16, 5:03 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: > >> On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: >> >> Question 1: >> >> >> Given that the user of the API can choose to override foo()

Re: overriding methods - two questions

2007-11-17 Thread Steven D'Aprano
On Sat, 17 Nov 2007 12:19:07 +0200, Donn Ingle wrote: >> BTW, it is a convention for method names to be lower case, and classes >> to be Title case. Seeing something like obj.Draw, most(?) Python >> developers will expect that the Draw attribute of obj is itself a >> class: > Thanks, I'm pretty da

Re: overriding methods - two questions

2007-11-17 Thread Donn Ingle
Thanks, good tips all-round. I have it working okay at the moment with all the suggestions. It may break in future, but that's another day :) /d -- http://mail.python.org/mailman/listinfo/python-list

Re: overriding methods - two questions

2007-11-17 Thread Donn Ingle
> *not* being called by the user but *by* my API (in a timeout loop). > > You don't know that. How can you possibly guarantee that the user won't > find some other use for the draw() method Well, as per your good examples, I would answer that as the parameters passed to draw() grow in number, so

Re: overriding methods - two questions

2007-11-17 Thread Peter Otten
Donn Ingle wrote: >> I am curious as to why you want to go through such contortions.  What >> do you gain. > for obj in list: > if obj has a foo() method: > a = something > b = figureitout ( ) > object.foo ( a, b ) > > I am accepting objects of any class on a stack. Depending on their na

Re: overriding methods - two questions

2007-11-17 Thread Steven D'Aprano
On Sat, 17 Nov 2007 06:47:18 +0200, Donn Ingle wrote: >>> While technically possible (using inspect.getargspec), trying to make >>> your code idiot-proof is a lost fight and a pure waste of time. > >> Worse: it's actually counter-productive! The whole idea of being able >> to subclass a class me

Re: overriding methods - two questions

2007-11-17 Thread Gabriel Genellina
En Sat, 17 Nov 2007 01:56:22 -0300, Donn Ingle <[EMAIL PROTECTED]> escribió: > for obj in list: > if 'foo' in obj.__class__.__dict__: > etc. > > Although I am concerned that it's a loop ('in') and so may be slower than > some other way to detect foo(). 'in' for dictionaries is fast and runs

Re: overriding methods - two questions

2007-11-17 Thread Donn Ingle
> This is strictly a documentation matter, in my mind. Python does not > offer any means to enforce the calling sequence of an "override method". Yes, I hear you. > You might be able to wrap YOUR calling code with a try/except block > to trap errors if the callback doesn't like the "documented AP

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
> I am curious as to why you want to go through such contortions.  What > do you gain. for obj in list: if obj has a foo() method: a = something b = figureitout ( ) object.foo ( a, b ) I am accepting objects of any class on a stack. Depending on their nature I want to call certain methods

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
>> While technically possible (using inspect.getargspec), trying to make >> your code idiot-proof is a lost fight and a pure waste of time. > Worse: it's actually counter-productive! > The whole idea of being able to subclass a class means that the user > should be able to override foo() *includi

Re: overriding methods - two questions

2007-11-16 Thread George Sakkis
On Nov 16, 5:03 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: > >> Question 1: > > >> Given that the user of the API can choose to override foo() or not, how > >> can I control the signature that they use? > > > W

Re: overriding methods - two questions

2007-11-16 Thread Steven D'Aprano
On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote: >> Question 1: >> >> Given that the user of the API can choose to override foo() or not, how >> can I control the signature that they use? > > While technically possible (using inspect.getargspec), trying to make > your code idiot-pr

Re: overriding methods - two questions

2007-11-16 Thread [EMAIL PROTECTED]
On Nov 16, 11:35 am, Donn Ingle <[EMAIL PROTECTED]> wrote: > >This may help (on an old Python version): > class Sam: pass > class Judy: > > ...def foo(self): pass > > ... > children = [Sam(), Judy(), Sam()] > for child in children: hasattr(child, "foo") > > ... > > False > >

Re: overriding methods - two questions

2007-11-16 Thread Bruno Desthuilliers
Donn Ingle a écrit : >> for child in self.childrens: >> if 'foo' in child.__class__.__dict__: >> child.foo() > Bruno, you're the man! I really must take the time to look into all those > under-under score things! Knowing Python's object model can help, indeed !-) Now while this kind of stuff is

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
> for child in self.childrens: > if 'foo' in child.__class__.__dict__: > child.foo() Bruno, you're the man! I really must take the time to look into all those under-under score things! Thanks. /d -- http://mail.python.org/mailman/listinfo/python-list

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
>This may help (on an old Python version): class Sam: pass class Judy: > ...def foo(self): pass > ... children = [Sam(), Judy(), Sam()] for child in children: hasattr(child, "foo") > ... > False > True > False That's not what my tests are showing. While Sam has no foo, it's

Re: overriding methods - two questions

2007-11-16 Thread Bruno Desthuilliers
Donn Ingle a écrit : > Hi, > Here's a framework for the questions: > > --- In a module, part of an API --- > class Basis ( object ): > def foo ( self, arg ): > pass > > --- In user's own code --- > class Child ( Basis ): > def foo ( self, not, sure ): > ... > > > Question 1: > > Given th

Re: overriding methods - two questions

2007-11-16 Thread bearophileHUGS
Donn Ingle: > Say I am in class Basis, doing a loop and I have a list of Child objects. I > want to run the foo() method for each one that *has* a foo() method. This may help (on an old Python version): >>> class Sam: pass ... >>> class Judy: ... def foo(self): pass ... >>> children = [Sam()

Re: overriding methods - two questions

2007-11-16 Thread Donn Ingle
> Actually, Python is complaining about your user's poor choice of > argument names. 'not' is a reserved keyword. My example was poor, but my actual test code did't use 'not'. Python simply checks the use of foo() to the local sig of foo() and does not go up the chain. This is understandable and

Re: overriding methods - two questions

2007-11-16 Thread Paul McGuire
On Nov 16, 11:03 am, Donn Ingle <[EMAIL PROTECTED]> wrote: > Hi, > Here's a framework for the questions: > > --- In a module, part of an API --- > class Basis ( object ): > def foo ( self, arg ): > pass > > --- In user's own code --- > class Child ( Basis ): > def foo ( self, not, sure ): > .

overriding methods - two questions

2007-11-16 Thread Donn Ingle
Hi, Here's a framework for the questions: --- In a module, part of an API --- class Basis ( object ): def foo ( self, arg ): pass --- In user's own code --- class Child ( Basis ): def foo ( self, not, sure ): ... Question 1: Given that the user of the API can choose to override foo() or

Re: C API -- Two questions

2007-07-27 Thread beginner
On Jul 27, 1:23 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Fri, 27 Jul 2007 00:34:22 +, beginner wrote: > > 2) How can I make the arguments less picky without writing a lot of > > type conversion code? My function really needs a tuple as its > > argument. For example, f( (1,2,

Re: C API -- Two questions

2007-07-26 Thread Marc 'BlackJack' Rintsch
On Fri, 27 Jul 2007 00:34:22 +, beginner wrote: > 2) How can I make the arguments less picky without writing a lot of > type conversion code? My function really needs a tuple as its > argument. For example, f( (1,2,3) ) would work. However, in order to > make it easy to use, I am thinking that

C API -- Two questions

2007-07-26 Thread beginner
Hi Everyone, I am writing a C extension and encountered two problems. 1) How can I include a description of the arguments? I can include a description string. No problem. But whenever I say help(my_func) it shows the arguments are "... ". However, if a function is defined in python, I will defini

Re: two questions about thread

2006-01-16 Thread Bryan Olson
Kevin wrote: > The best way to do this is by using a flag or event that the child-threads > monitor each loop (or multiple times per loop if it's a long loop). If the > flag is set, they exit themselves. > > The parent thread only has to set the flag to cause the children to die. Doesn't work, b

Re: two questions about thread

2006-01-15 Thread Kevin
The best way to do this is by using a flag or event that the child-threads monitor each loop (or multiple times per loop if it's a long loop). If the flag is set, they exit themselves. The parent thread only has to set the flag to cause the children to die. Kevin. "Bryan Olson" <[EMAIL PROTECT

Re: two questions about thread

2006-01-14 Thread Bryan Olson
iclinux wrote: > a. how to exit the whole process in a thread? > b. when thread doing a infinite loops, how to terminate the process?: As others noted, the threading module offers Thread.setDaemon. As the doc says: "The entire Python program exits when no active non-daemon threads are left." Py

Re: two questions about thread

2006-01-14 Thread Diez B. Roggisch
iclinux wrote: > hi there, > > I'm new to python, and have two questions: > > a. how to exit the whole process in a thread? sys.exit() Works only if Thread.setDaemon(True) is invoked on all threads. > b. when thread doing a infinite loops, how to terminate the proces

two questions about thread

2006-01-14 Thread iclinux
hi there, I'm new to python, and have two questions: a. how to exit the whole process in a thread? b. when thread doing a infinite loops, how to terminate the process?: it seems that the follow doesn't work, in my Windows XP: thread.start() thread.join(

Re: Two questions on PyDev for Eclipse

2005-09-20 Thread Fabio Zadrozny
Fabio Zadrozny wrote: >Hi, > >for 2: as far as I know, eclipse must have 'local', or at least >'emulated' local access, so, if you have samba access, it should do what >you want. > >for 1... I use it a LOT without any problems for some really big >projects ( with about 2.000 python modules -- n

Re: Two questions on PyDev for Eclipse

2005-09-20 Thread Fabio Zadrozny
Hi, for 2: as far as I know, eclipse must have 'local', or at least 'emulated' local access, so, if you have samba access, it should do what you want. for 1... I use it a LOT without any problems for some really big projects ( with about 2.000 python modules -- not counting the python install

Two questions on PyDev for Eclipse

2005-09-19 Thread Kenneth McDonald
The first is general; what are users' experience with PyDev for Eclipse. It looks pretty good to me right now, but I've only started playing with it. Converting to Eclipse is a major effort, and if there are problems which would prevent pydev from being useful right now, I'd certainly appre

Re: Two questions on lambda:

2005-06-24 Thread Terry Reedy
"Xavier Décoret" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I cannot find the way to do generic lambda functions using the lambda > syntax in python. I am probably missing a point. Thinking of lambda args: expression as more or less abbreviati

Re: Two questions on lambda:

2005-06-24 Thread Sean McIlroy
def PRINT(x): print x f = lambda: PRINT("hello") ### def let(x,y): globals()[x] = y return True f = lambda x: let('y',x*x) and y+y -- http://mail.python.org/mailman/listinfo/python-list

Re: Two questions on lambda:

2005-06-24 Thread Christophe Delord
hello, On Fri, 24 Jun 2005 14:48:16 +0200, Xavier Décoret wrote: > Hi, > > In the same spirit, how can I do to compute intermediary values in the > > body of a lambda function. Let's say (dummy example): > > f = lambda x : y=x*x,y+y > > > In languages like Caml, you can do: > > let f = func

Re: Two questions on lambda:

2005-06-24 Thread John Roth
"Xavier Décoret" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I cannot find the way to do generic lambda functions using the lambda > syntax in python. I am probably missing a point. You are. Lambda is restricted to a _single expression_. Your first example is a stateme

Re: Two questions on lambda:

2005-06-24 Thread Duncan Booth
Xavier Décoret wrote: > Is there a particular syntax for lambda that I am missing > or is it simply limited and I cannot do what I want with lambda. Lambda is deliberately limited. Just define a function. The only downside to defining a function is that you have to think of a name for it, but

Re: Two questions on lambda:

2005-06-24 Thread Kristian Zoerhoff
On 6/24/05, Xavier Décoret <[EMAIL PROTECTED]> wrote: > > For example, the code > > # f = lambda : print "hello" > # f() > does not compile, although: > > # def f(): > # print "hello" > # f() > > does compile. Is there a particular syntax for lambda that I am missing > or is it simply lim

Two questions on lambda:

2005-06-24 Thread Xavier Décoret
Hi, I cannot find the way to do generic lambda functions using the lambda syntax in python. I am probably missing a point. For example, the code # f = lambda : print "hello" # f() does not compile, although: # def f(): # print "hello" # f() does compile. Is there a particular syntax fo

  1   2   >