Re: [Tutor] Fwd: Learning python using Michael Dawson's book

2010-05-19 Thread Andre Engels
On Tue, May 18, 2010 at 5:14 AM, Luke Paireepinart
 wrote:
> Forwarding. Peter use reply-all don't reply offlist please.
>
> -- Forwarded message --
> From: Peter 
> Date: Mon, 17 May 2010 10:08:47 -0400
> Subject: Re: [Tutor] Learning python using Michael Dawson's book
> To: Luke Paireepinart 
>
> Hi,
> The result in the book has lettering like the following:
> ___    __       __
> |    |    |    |     |    |
> |    |__|    |     |    |
> |    __     |      |    |
> |    |    |    |     |    |
> |__|    |__|     |__|

Well, that's definitely not what the code would be producing, nor does
it seem to be related to what the example claims to be doing...
Perhaps instead of

print(
   """
   """
   )

which is a very strange idiom (though valid), you should write:

print(
   """
 _____   __
 |||| ||
 ||__|| ||
 |__ |  ||
 |||| ||
 |__||__| |__|
  """
   )

or perhaps you are looking at one example and the explanation of another?



-- 
André Engels, andreeng...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PYTHON 3.1

2010-05-19 Thread Dipo Elegbede
Thanks Alan, I'm on it.
Regards.

On 5/18/10, Alan Gauld  wrote:
>
> "Dipo Elegbede"  wrote
>
>> please confirm this is a new syntax for print.
>> thank you.
>>
>> i will put up morte concerns as they arrive.
>
> Please read the Whats New in Python v3 documents first.
> Version 3 of Python is a major change in the language with
> many big changes. Do not just try stuff and send it here
> every time something breaks.
>
> Read the documents first so you know what to expect.
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise
Application Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PYTHON 3.1

2010-05-19 Thread Dipo Elegbede
Hi Alan.
I was looking through your page "http://www.alan-g.me.uk/l2p/index.htm";
Covering the topic: Looping - Or the art of repeating oneself!
Under for loop, Note 3:
...*You can prove that by typing   print( list( range(1,13) )*..
The print statement above seem to be incomplete, I think a single
parenthesis is missing. it should be six in all.
Please confirm and effect the correction on the web page.
Thanks.

On 5/19/10, Dipo Elegbede  wrote:
> Thanks Alan, I'm on it.
> Regards.
>
> On 5/18/10, Alan Gauld  wrote:
>>
>> "Dipo Elegbede"  wrote
>>
>>> please confirm this is a new syntax for print.
>>> thank you.
>>>
>>> i will put up morte concerns as they arrive.
>>
>> Please read the Whats New in Python v3 documents first.
>> Version 3 of Python is a major change in the language with
>> many big changes. Do not just try stuff and send it here
>> every time something breaks.
>>
>> Read the documents first so you know what to expect.
>>
>> --
>> Alan Gauld
>> Author of the Learn to Program web site
>> http://www.alan-g.me.uk
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
> --
> Elegbede Muhammed Oladipupo
> OCA
> +2348077682428
> +2347042171716
> www.dudupay.com
> Mobile Banking Solutions | Transaction Processing | Enterprise
> Application Development
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise
Application Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unit testing command-line options from argparse or optparse

2010-05-19 Thread Dave Angel

Serdar Tumgoren wrote:

Hello all,

Does anyone have advice for writing unit tests against variables set by
command-line options?

I have a program I'd like to run in either "debug" or "live" mode, with
various settings associated with each. Below is some pseudo-code that shows
what I'd like to do:

<>
mode = p.parse_args() #always set to either --debug or --live

if mode.live:
recipients = ['jsm...@email.com', 'jane...@email.com']
# set logging to a file
elif mode.debug:
recipients = ['ad...@admin.com']
# log to stdout

The "live" and "debug" attributes are set by command-line flags passed to
the argparse module. What I'd like to do is write tests that check whether
various settings (recipients, logging, etc.) are configured properly based
on the command-line options.

But if "mode" is not set until runtime, I clearly can't import it into my
suite of unit tests, right? Is there some standard testing approach to this
problem (perhaps mocking?) that you all can recommend?

I'd greatly appreciate it.
Serdar

  
I don't see the problem.  If 'mode' is a global in module  doit.py, then 
just use

   import doit
and later,
   if doit.mode.debug

The only tricky thing is to make sure that the initialization code has 
been run before you actually use the latter code.


And, presuming mode is an object of a special class made for the 
purpose, you could go a bit further.  You could create the object (with 
default attributes) in the top-level code of doit.py.  That way it 
already exists when the import is finished.  And you could then use

   from doit import mode

Now, change the semantics of parse_args() so that it takes the mode 
object as a parameter, and modifies it according to the arguments.  As 
long as you don't reassign mode itself, the test code could continue to 
use its own "variable".  But once again, don't use the mode.debug until 
the initialization has been done.


DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Learning python using Michael Dawson's book

2010-05-19 Thread Joseph Gulizia
I posted this two days ago (I thought to the list...but apparently not).
I'm hopeful it helps in some way.



I have the same book.

Using a text editor and the underscore and dash keys and a few others...the
program example is creating an ASCII art version on the words "Game Over".

Type it manually probably means to type it out...NOT use copy and paste.

Can't get it to work probably meansit doesn't display properly (as the
book shows).

What needs to be done is he needs to play with the spacing of the characters
and different keys to get the "letters" drawn to display closer to the
book's example.


"""
  ___
  |__   ___|   _ _
  |  |  /   __\   /  ___  \
 _   |  | |   |||  |  |___|  |
|  |_|  | |   |__||  |  /_
\/ \__/  \__|

"""

On Wed, May 19, 2010 at 2:38 AM, Andre Engels  wrote:

> On Tue, May 18, 2010 at 5:14 AM, Luke Paireepinart
>  wrote:
> > Forwarding. Peter use reply-all don't reply offlist please.
> >
> > -- Forwarded message --
> > From: Peter 
> > Date: Mon, 17 May 2010 10:08:47 -0400
> > Subject: Re: [Tutor] Learning python using Michael Dawson's book
> > To: Luke Paireepinart 
> >
> > Hi,
> > The result in the book has lettering like the following:
> > _____   __
> > |||| ||
> > ||__|| ||
> > |__ |  ||
> > |||| ||
> > |__||__| |__|
>
> Well, that's definitely not what the code would be producing, nor does
> it seem to be related to what the example claims to be doing...
> Perhaps instead of
>
> print(
>   """
>   """
>   )
>
> which is a very strange idiom (though valid), you should write:
>
> print(
>   """
>  _____   __
>  |||| ||
>  ||__|| ||
>  |__ |  ||
>  |||| ||
>  |__||__| |__|
>  """
>   )
>
> or perhaps you are looking at one example and the explanation of another?
>
>
>
> --
> André Engels, andreeng...@gmail.com
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Learning python using Michael Dawson's book

2010-05-19 Thread Peter
Thank you for the responses to my question. This was my first posting 
and future questions will be made "clearer" to the group.


Joseph,
I have a feeling you are correct about the spacing.  I will try that.
Its easy to just load the code file and see the result, but I will learn 
more if I type out what I see in the book then see a result.

Thank much,
Peter

On 5/19/2010 7:11 AM, Joseph Gulizia wrote:
I posted this two days ago (I thought to the list...but apparently 
not).  I'm hopeful it helps in some way.




I have the same book.

Using a text editor and the underscore and dash keys and a few 
others...the program example is creating an ASCII art version on the 
words "Game Over".


Type it manually probably means to type it out...NOT use copy and paste.

Can't get it to work probably meansit doesn't display properly (as 
the book shows).


What needs to be done is he needs to play with the spacing of the 
characters and different keys to get the "letters" drawn to display 
closer to the book's example.



"""
  ___
  |__   ___|   _ _
  |  |  /   __\   /  ___  \
 _   |  | |   |||  |  |___|  |
|  |_|  | |   |__||  |  /_
\/ \__/  \__|

"""

On Wed, May 19, 2010 at 2:38 AM, Andre Engels > wrote:


On Tue, May 18, 2010 at 5:14 AM, Luke Paireepinart
mailto:rabidpoob...@gmail.com>> wrote:
> Forwarding. Peter use reply-all don't reply offlist please.
>
> -- Forwarded message --
> From: Peter mailto:cyclesp...@windstream.net>>
> Date: Mon, 17 May 2010 10:08:47 -0400
> Subject: Re: [Tutor] Learning python using Michael Dawson's book
> To: Luke Paireepinart mailto:rabidpoob...@gmail.com>>
>
> Hi,
> The result in the book has lettering like the following:
> _____   __
> |||| ||
> ||__|| ||
> |__ |  ||
> |||| ||
> |__||__| |__|

Well, that's definitely not what the code would be producing, nor does
it seem to be related to what the example claims to be doing...
Perhaps instead of

print(
  """
  """
  )

which is a very strange idiom (though valid), you should write:

print(
  """
 _____   __
 |||| ||
 ||__|| ||
 |__ |  ||
 |||| ||
 |__||__| |__|
 """
  )

or perhaps you are looking at one example and the explanation of
another?



--
André Engels, andreeng...@gmail.com 
___
Tutor maillist  - Tutor@python.org 
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
   
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unit testing command-line options from argparse or optparse

2010-05-19 Thread Serdar Tumgoren
Ah, okay -- both of those options make sense. I'll try my hand at Jan's
first and will report back if I have any problems.

Many thanks as always!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Learning python using Michael Dawson's book

2010-05-19 Thread Alan Gauld
I thought I had posted a reply on this but I don't see 
it in the archive...


You should make sure your font is set to a mono-spaced 
variety for this kind of thing otherwise it gets very difficult 
to align everything...



--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to convert short name to fqdn

2010-05-19 Thread Sterba_Robert
I have a likely simple question, that for some reason is not working as 
expected.
 
I need to take a servers shortname and convert it to fully qualified.  These 
servers reside in various subdomains, so simply appending a suffix will not 
work.
 
my hope was that socket.getfqdn('servername') would do this, however this only 
appears to work if the connection specific domain suffix is the same as the 
server I'm looking up.  If it's different, it just returns the client name.
 
example.  my workstation is on   subdomaina.domain.com
   client is on  subdomainb.domain.com
   any short name I put in on subdmainA comes back correctly, but 
if i put in a short name that resolves to any other subdomain, it just returns 
the shortname.  This is the intended behaviour if socket.getfqdn() cann't 
resolve the name, however I don't see why it can't resolve the name.
 
from nslookup, I can resolve the client to fqdn just fine there is only one 
entry for it, so it is not a resolution issue, but appears to be specific to 
the way the socket.getfqdn() works.  
 
Is there something I'm missing, or is there an easy way to do this?
 
Thanks, 
Rob
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] SetTopWindow

2010-05-19 Thread Gary Koskenmaki
I have what is a noob's confusion about this that will lead to bigger
problems for me later on if I don't clear it up.

In wxPython what a user normally refers to as a "window" is known as a
frame.  And what is known in wxPython as a window is an object such as a
TextCtrl object.  At least that is what I take from "wxPython in
Action".

Now, wxApp has a method called SetTopWindow and you normally pass your
wxframe object to it so that it knows what is to be top object. 

class MyApp(wx.App):

def OnInit(self):
frame = MyFrame(blah, blah, blah, blah)
frame.Show()
frame.SetTopWindow(frame)
return True

class MyFrame(wx.Frame):

def __init__(self, blah, blah, blah):
wx.Frame.__init__(self, blah,blah,blah)
 

My question, and it's probably a stupid question, is why is
SetTopWindow, in how it is named, referring to a window object rather
than a frame object?  Isn't SetTopWindow saying which frame should be
the top frame object?  The naming of it seems really ambiguous to me.
Why isn't it named something like SetTopFrame?

What am I missing?  



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SetTopWindow

2010-05-19 Thread Alan Gauld

"Gary Koskenmaki"  wrote

I have what is a noob's confusion about this that will lead to bigger
problems for me later on if I don't clear it up.


Don't worry, this kind of confusion abounds in GUI toolkits of all
kinds not just wxPython.

In wxPython what a user normally refers to as a "window" is known as 
a
frame.  And what is known in wxPython as a window is an object such 
as a

TextCtrl object.  At least that is what I take from "wxPython in
Action".


Correct, and the latter usage is common parlance in most GUI 
frameworks.
A window is any visible area of the screen, including widgets. The 
name

for the top level object varies from toolkit to toolkit.

Now, wxApp has a method called SetTopWindow and you normally pass 
your

wxframe object to it so that it knows what is to be top object.


I think this is historic since many early toolkits had some kind of
setTopWindow method (Microsoft and Borland, and at least one X windows
toolkit all did). The name in wxPython is simply a reflection of the 
underlying

C++ wxWidgets which, I think, simply reflects the historical legacy.


Why isn't it named something like SetTopFrame?
What am I missing?


Nothing, it's just one of the many accidents of programming legacy.
Like why does Lisp use "car" to get the first item off a list? Because
that's the machine instruction that did it on the computer they built
the first Lisp on... There are a lot of these historical accidents 
that

creep into programming languages. Learn to love them! :-)

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor