[Tutor] Windows printing

2010-09-22 Thread Rance Hall
I'm using this page as a reference: http://timgolden.me.uk/python/win32_how_do_i/print.html I'm able to print to the default printer ok, but I can't seem to find out how to get to pick the printer I want to use. This is from a CLI app, so there is no gui. win32print seems like it has everything

Re: [Tutor] Help-Embedding Python in C#

2010-09-22 Thread ranjan das
Hi Wayne, Thanks for your reply. The problem is a bit more specific. I have come across ironpython and I ran a test file and it works fine as far as the wrapping is concerned. What I want to do is write my code completely in Python (as gainst iron python), copy it to the visual studio editor and

Re: [Tutor] Dict of function calls

2010-09-22 Thread Steven D'Aprano
On Thu, 23 Sep 2010 09:21:27 am Pete wrote: > > (3) There's no need to keep the instances floating around as > > independent names, unless you need direct access to them. > > > > Putting these together, we get: > > > > dispatch_table = { 'foo': foo().do, 'bar': bar().do } [...] > I see. And are th

Re: [Tutor] Dict of function calls

2010-09-22 Thread Pete
On 2010-09-22, at 5:50 PM, Steven D'Aprano wrote: > On Thu, 23 Sep 2010 06:07:21 am Pete wrote: >> For a plugin mechanism, I'm populating a dict with calls to the >> implemented plugins. > [...] >> Now I get that I need to instantiate foo and bar first before I can >> refer to them in the dict. >

Re: [Tutor] Test Drive Development, DocTest, UnitTest

2010-09-22 Thread Steven D'Aprano
On Wed, 22 Sep 2010 09:44:17 pm Tino Dai wrote: > > The *primary* purpose of doctests are to be executable examples. > > When you write documentation, including example code is the most > > natural thing in the world. doctest lets you execute those > > examples, to ensure that they work. They're ce

Re: [Tutor] Dict of function calls

2010-09-22 Thread Steven D'Aprano
On Thu, 23 Sep 2010 06:07:21 am Pete wrote: > For a plugin mechanism, I'm populating a dict with calls to the > implemented plugins. [...] > Now I get that I need to instantiate foo and bar first before I can > refer to them in the dict. > > so something like > > foo_instance = foo() > bar_instance

Re: [Tutor] class function problem

2010-09-22 Thread Steven D'Aprano
On Thu, 23 Sep 2010 05:55:36 am Steven D'Aprano wrote: > You will find the divmod() function useful. divmod(a, b) returns > two numbers: > > a/b as a whole number, any remainder left only Arggh! Of course I meant any reminder left OVER. -- Steven D'Aprano _

[Tutor] Dict of function calls

2010-09-22 Thread Pete
For a plugin mechanism, I'm populating a dict with calls to the implemented plugins. Consider this: >>> class foo: ... def do(self): ... print 'do foo' ... >>> class bar: ... def do(self): ... print 'do bar' ... >>> list = { 'foo': foo.do(), 'bar': bar.do() } T

Re: [Tutor] class function problem

2010-09-22 Thread Steven D'Aprano
On Thu, 23 Sep 2010 01:17:59 am Roelof Wobben wrote: > Sorry. I don't get it. > When I have 62 seconds that's 1 minutes and 2 seconds. > I have no clue how I can this with a division. If you have 60 seconds, you have one minute. If you have 120 minutes, you have two minutes. Can you get from 120

Re: [Tutor] list.append(x) but at a specific 'i'

2010-09-22 Thread Steven D'Aprano
On Wed, 22 Sep 2010 08:30:09 am Norman Khine wrote: > hello, how do i extend a python list but from a given [i], Do you mean to modify the list in place, like append() and extend() do, or do you mean to create a new list, like + does? > for example: > >>> a = ['a', 'b', 'e'] > >>> b = ['c',

Re: [Tutor] how to create a persistent dictionary w/ cpickle?

2010-09-22 Thread Carter Danforth
Dave, Steve, and Alan: late reply here, but thanks a lot guys - really appreciate the feedback. I had no idea what I was doing w/ that class in the addressbook, needed to read up more, and I got the dictionary figured out w/ cpickle and now it's all working. Thanks again, this input's really helpi

Re: [Tutor] class function problem

2010-09-22 Thread Hugo Arts
On Wed, Sep 22, 2010 at 5:17 PM, Roelof Wobben wrote: >> >> That's very clever. But you might argue that recursion is technically >> still a loop, albeit an implicit one. There is a simpler way to do >> this, without loops entirely. >> >> Hint: repeated subtraction while your number is greater tha

Re: [Tutor] class function problem

2010-09-22 Thread Roelof Wobben
> From: hugo.yo...@gmail.com > Date: Wed, 22 Sep 2010 16:16:45 +0200 > Subject: Re: [Tutor] class function problem > To: rwob...@hotmail.com > CC: tutor@python.org > > On Wed, Sep 22, 2010 at 9:10 AM, Roelof Wobben wrote: >> >> >> HEllo, >> >> I have this

[Tutor] Best practice for API design handeling collections and single objects

2010-09-22 Thread Knacktus
Hi all, I've got a question for you about how to best design an API that has to handle requests for single objects and collections of those objects. My naming conventions are: Plural nouns for collections, singular nouns for single objects. "Key_to_value"-style for dictionaries. So I normaly

Re: [Tutor] class function problem

2010-09-22 Thread Hugo Arts
On Wed, Sep 22, 2010 at 9:10 AM, Roelof Wobben wrote: > > > HEllo, > > I have this exercise : > > 3.Rewrite the increment function so that it doesn’t contain any loops. > > The increment function looks like this : > > def increment(time, seconds): >    time.seconds = time.seconds + seconds >    wh

Re: [Tutor] Help-Embedding Python in C#

2010-09-22 Thread Wayne Werner
On Wed, Sep 22, 2010 at 7:55 AM, ranjan das wrote: > > Please Advise: > > I need to run/execute python module in C#. I am using python 2.6 and > visual studio 10 > You should check out IronPython http://www.ironpython.com/ HTH, Wayne

[Tutor] Help-Embedding Python in C#

2010-09-22 Thread ranjan das
Please Advise: I need to run/execute python module in C#. I am using python 2.6 and visual studio 10 Ranjan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Test Drive Development, DocTest, UnitTest

2010-09-22 Thread Tino Dai
On Wed, Sep 22, 2010 at 3:53 AM, Walter Prins wrote: > You might also have a look at some of the other popular testing frameworks > e.g. Nose (http://somethingaboutorange.com/mrl/projects/nose/0.11.2/) and > py.test (http://wiki.python.org/moin/PyTest) Both of these have the > advantage that the

Re: [Tutor] Test Drive Development, DocTest, UnitTest

2010-09-22 Thread Tino Dai
> > The *primary* purpose of doctests are to be executable examples. When > you write documentation, including example code is the most natural > thing in the world. doctest lets you execute those examples, to ensure > that they work. They're certainly not meant as an exhaustive test of > every sin

Re: [Tutor] Test Drive Development, DocTest, UnitTest

2010-09-22 Thread Walter Prins
You might also have a look at some of the other popular testing frameworks e.g. Nose (http://somethingaboutorange.com/mrl/projects/nose/0.11.2/) and py.test (http://wiki.python.org/moin/PyTest) Both of these have the advantage that they're discovery based, so they'll go and sniff out tests from yo

[Tutor] class function problem

2010-09-22 Thread Roelof Wobben
HEllo, I have this exercise : 3.Rewrite the increment function so that it doesn’t contain any loops. The increment function looks like this : def increment(time, seconds): time.seconds = time.seconds + seconds while time.seconds>= 60: time.seconds = time.seconds - 60