[Tutor] tkinter message button questions

2011-11-30 Thread Cranky Frankie
Peter Otten __pete...@web.de wrote:
To: tutor@python.org
Subject: Re: [Tutor] tkinter message  button questions
Message-ID: jb38s2$9gg$1...@dough.gmane.org
Content-Type: text/plain; charset=ISO-8859-1

I've no experience with the place layout manager, but the following seems to
be what you want:

root = Tk()
win = Frame(root)
win.place(relheight=1, relwidth=1)

label_widget = Label(win, text=Welcome to Quote of the Day)
label_widget.pack(side=TOP, expand=YES, fill=BOTH)

msg_widget = Message(
   win, anchor=NW, justify=LEFT, width=1000, bd=2,
   bg=white, relief=SOLID, text=choose_quote())
msg_widget.pack(fill=BOTH)

next_button = Button(win, text=Next Quote, command=display_quote)
next_button.pack(side=LEFT)

quit_button = Button(win, text=QUIT, fg=red, command=quit)
quit_button.pack(side=RIGHT)

root.geometry(400x100)
root.mainloop()



Peter thanks again. The msg_widget is still resizing vertically
depending on the lenght of the quote, but at least now the horizontal
sizing is staying the same. Ideally the msg_widget would be the *same
size*, no matter what the quote length is, but since this program is
really just a learning exercise and to show database adminstrators a
simple Python GUI application I can live with it.

The syntax you used, like root.geometry(400x100), I have not seen
before, and I've done a lot of searching. Again, much of the tkinter
stuff I see seems to be based on Python 2.6. If there is a definitive
book or reference on using tkinter in Python 3.x I'd really like to
know about it.

Thanks again Peter, Wayne, and everyone else on the tutor list, you
guys are great.

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


Re: [Tutor] tkinter message button questions

2011-11-30 Thread Wayne Werner
On Wed, Nov 30, 2011 at 8:32 AM, Cranky Frankie cranky.fran...@gmail.comwrote:

 Peter Otten __pete...@web.de wrote:
 snipPeter thanks again. The msg_widget is still resizing vertically
 depending on the lenght of the quote, but at least now the horizontal
 sizing is staying the same. Ideally the msg_widget would be the *same
 size*, no matter what the quote length is, but since this program is
 really just a learning exercise and to show database adminstrators a
 simple Python GUI application I can live with it.


The whole purpose of the Message widget is that it *does* resize. If you
wanted something to be a static size, I think a Label would fit the bill -
though I haven't played around enough with that in recent time.



 The syntax you used, like root.geometry(400x100), I have not seen
 before, and I've done a lot of searching. Again, much of the tkinter
 stuff I see seems to be based on Python 2.6. If there is a definitive
 book or reference on using tkinter in Python 3.x I'd really like to
 know about it.


That's the great thing about Python - most of the syntax is identical, and
there should be only minor differences between Python 2.x and 3.x -
especially where Tkinter is concerned.

I would go ahead and look at 2.x tutorials/articles for Tkinter and just be
aware that you'll encounter some issues (probably mostly dealing with
Unicode strings, and occasionally something numeric - based on my
experience). With that preparation then you should be able to easily search
for answers to the problems you encounter.

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


Re: [Tutor] tkinter message button questions

2011-11-30 Thread Peter Otten
Cranky Frankie wrote:

 Peter thanks again. The msg_widget is still resizing vertically
 depending on the lenght of the quote, but at least now the horizontal
 sizing is staying the same. Ideally the msg_widget would be the *same
 size*, no matter what the quote length is, but since this program is
 really just a learning exercise and to show database adminstrators a
 simple Python GUI application I can live with it.

Well, you can place() everything yourself:

root = Tk()
win = Frame(root)
win.place(relheight=1, relwidth=1)

label_widget = Label(win, text=Welcome to Quote of the Day)
label_widget.place(width=300, height=20)

msg_widget = Message(
win, anchor=NW, justify=LEFT, width=1000, bd=2,
bg=white, relief=SOLID, text=choose_quote())
msg_widget.place(width=300, height=50, y=20)

next_button = Button(win, text=Next Quote, command=display_quote)
next_button.place(y=70)

quit_button = Button(win, text=QUIT, fg=red, command=quit)
quit_button.place(y=70, x=200)

root.geometry(400x100)
root.mainloop()

The disadvantage of that approach is of course that you have to place 
everything yourself ;)


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


Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-30 Thread Emile van Sebille

On 11/29/2011 4:44 PM Dave Angel said...


Any chance you were a customer or vendor of Wang? That 80mb drive,
dumbed down, for prices around $20k, rings a bell.


That was around 1980 as an ISV -- a Basic Four 610 -- we paid I think 
$50k? retailed at $70k. 8 user, 256k memory, two 35Mb drives that for 
$15k a piece you could get the tech to come out and clip the strap on 
the high order bit of the address space register which would double the 
usable space.  Kinda like getting a discount on a caddy but they deliver 
the car with the back doors welded shut.


Emile



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


Re: [Tutor] tkinter message button questions

2011-11-30 Thread Alan Gauld

On 30/11/11 14:32, Cranky Frankie wrote:


The syntax you used, like root.geometry(400x100), I have not seen
before, and I've done a lot of searching. Again, much of the tkinter
stuff I see seems to be based on Python 2.6. If there is a definitive
book or reference on using tkinter in Python 3.x I'd really like to
know about it.


For those times when help() fails to provide enough detail...
The definitive reference for Tkinter is usually the Tk documentation.
But that is expressed in terms of Tcl rather than Python - although they 
are trying to address that. But it does require some translation.


I usually look here first:

http://docs.python.org/py3k/library/tk.html

and

http://www.pythonware.com/library/tkinter/introduction/index.htm


For the Tk docs try:

http://www.tcl.tk/man/tcl8.5/TkLib/contents.htm

And finally this shows promise but is still under construction
:
http://www.tkdocs.com/index.html

It tries to cover other languages, including Python but its a bit patchy 
so far...


--
Alan G
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] plotting in python

2011-11-30 Thread stm atoc
Hi there,

I have a question regarding plotting with Python.

I have the following python script:

# coding: utf-8
from pylab import *
import numpy

filename='ourtest_out.list'

fh=open(filename)
line=fh.readline()
fh.close

z=array([ float(val) for val in line.split()[1:] ])


a = numpy.loadtxt(filename,skiprows=3)
N=100
t = a[:,0]
nu = a[0:,1:N+1]
#Conc = a[1:,N+1:]
Conc = a[1:,N+1:]

levels=arange(-10,1)
levels=levels[-3]-levels
t=t/360.

figure()
plot(Conc[0],z)

xlabel('C')
ylabel('z')
#show()
savefig('Conc.png')
close()

#nu
figure()
lw = 2.0 #linewidth
dpi = 96

levels=arange(-10,1)
levels=levels[-3]-levels
plot(nu[0],z)
xlabel('nu')
ylabel('z')
savefig('nu.png')
close()


However, once I run the program (run.py)

I have error like this:

---
ValueErrorTraceback (most recent call last)
/Users/…./run.py in module()
 24
 25 figure()
--- 26 plot(Conc[0],z)
 27
 28 xlabel('C')

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/pyplot.py
in plot(*args, **kwargs)
   2284 ax.hold(hold)
   2285 try:
- 2286 ret = ax.plot(*args, **kwargs)
   2287 draw_if_interactive()
   2288 finally:

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py
in plot(self, *args, **kwargs)
   3781 lines = []
   3782
- 3783 for line in self._get_lines(*args, **kwargs):
   3784 self.add_line(line)
   3785 lines.append(line)

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py
in _grab_next_args(self, *args, **kwargs)
315 return
316 if len(remaining) = 3:
-- 317 for seg in self._plot_args(remaining, kwargs):
318 yield seg
319 return

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py
in _plot_args(self, tup, kwargs)
292 x = np.arange(y.shape[0], dtype=float)
293
-- 294 x, y = self._xy_from_xy(x, y)
295
296 if self.command == 'plot':

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py
in _xy_from_xy(self, x, y)
232 y = np.atleast_1d(y)
233 if x.shape[0] != y.shape[0]:
-- 234 raise ValueError(x and y must have same first dimension)
235 if x.ndim  2 or y.ndim  2:
236 raise ValueError(x and y can be no greater than 2-D)

ValueError: x and y must have same first dimension


---So, What would you suggest?
Thanks in advance,
Sue
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Do loop in Python

2011-11-30 Thread stm atoc
Yes. Actually, I have changed it to this kine od script:
# == model loop ==

#Optione1
if True:
 z=zeros( (numlayers,) )
 thickness= (thickness*1.0)
 for l in layers:
   z = arange ((-thickness - h * l),0,dz)
##z= t -h * l
 nu = num+ (0.001*exp(-0.005*(z+200.))*dz)

#Option2
if False:
 thickness = range(-200 , 0, 10) # a list from -200 to 0 with step 10
(0, 10, 20, ..., 190, 200)
 layers = range(1,11) # a list from 1 to 10
 for t in thickness:
   for l in layers:
z = arange(( t + h * l ), 0, dz )
#zvalues = arange(-200.,0,dz)
 nu = num+ (0.001*exp(-0.005*(z+200.)))

plot(nu,z)


Then it seems it works.

it should have a trend to reducing values...
- Show quoted text -

On Tue, Nov 29, 2011 at 2:00 PM, Steven D'Aprano st...@pearwood.info wrote:
 stm atoc wrote:

 Thank you so much for your reply. It was very helpful information and
 I used it in order to improve the program

 Here is the new version of the program:

 zvalues = [-200]  # starting value
 hvalues = [10]  # starting value
 increments = [1, 1, 1, 1, 1, 1, 1, 1]
 for N in increments:
       h = hvalues[-1] - N
       hvalues.append(h)
       z = zvalues[-1] + h
       zvalues.append(z)
       height = arange((z)*dz,0,dz)
       for z,when in enumerate(height):
           nuh.append(0.001 * exp(-0.005*(z+200.0))*dz) #turbulence
 diffusivity m**2/s
           nu.append(num + nuh[z])



 I'm afraid I still don't know what the arange function is. Is that a
 function you have written yourself? However, I can see that it doesn't
 actually get used!

 You create an arange object, and call it height.

    height = arange((z)*dz,0,dz)

 You should insert a print statement after this line to see what value height
 is given, and check that it is what you expect it to be.

 Presumably height is some sort of list or sequence of values, because you
 next use it in a for-loop:

    for z,when in enumerate(height):
        ...

 So now we know that z takes on the values 0, 1, 2, 3, ... and when takes on
 the values from height, whatever they are. But in the rest of your code, you
 don't use when at all:

        nuh.append(0.001 * exp(-0.005*(z+200.0))*dz)

        nu.append(num + nuh[z])

 No when, hence the values from height aren't actually used. Strange.

 Also, what are dz and num? You use them both, but I can't see where they are
 defined or what value they have. Likewise nuh and nu, although I can guess
 they are probably lists because you append to them.

 Because I don't know what values to use, and I don't know what arange is, I
 can't run your code to see what it does. So I'm reduced to guessing.

 If I take a wild stab in the dark that dz is a small number, say, 0.01, I
 can see what values nuh gets:


 py from math import exp
 py dz = 0.01
 py nuh = []
 py for z in range(10):
 ...     nuh.append(0.001 * exp(-0.005*(z+200.0))*dz)
 ...
 py from pprint import pprint
 py pprint(nuh)
 [3.6787944117144236e-06,
  3.6604463480401533e-06,
  3.6421897957152333e-06,
  3.624024298324903e-06,
  3.6059494017307832e-06,
  3.587964654059516e-06,
  3.5700696056914737e-06,
  3.5522638092495153e-06,
  3.5345468195878014e-06,
  3.5169181937806692e-06]

 Is that the sort of behaviour you expect for nuh?

 Since the nuh values are changing, num+nuh[z] should also be changing, which
 implies nu should be changing.

 Unless num is so large that rounding error wipes out the nuh values.




 --
 Steven
 ___
 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] is there a better way to organise this code

2011-11-30 Thread Norman Khine
hello,

is there a better way to organise this code or optimise it.

http://pastie.org/2944797

thanks

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


Re: [Tutor] plotting in python

2011-11-30 Thread Wayne Werner
On Wed, Nov 30, 2011 at 3:08 PM, stm atoc stm.at...@googlemail.com wrote:

 Hi there,

 I have a question regarding plotting with Python.

 snip
 ValueError: x and y must have same first dimension


It looks like  something is wrong with the data that you're trying to plot.
Specifically, the data that you're trying to plot has the wrong dimensions
(like it says).

An example:

# 2d space:
x = [(1, 1), (2, 2), (3,3)]
y = [(1,1,1), (2,2,2), (3,3,3)]

x is a series of points in 2 dimensions, and y is a series in 3. If your
data really is supposed to look like that then you'll need to pad or trim
the data so you've got the correct dimensions.

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


Re: [Tutor] plotting in python

2011-11-30 Thread Emile van Sebille

On 11/30/2011 1:08 PM stm atoc said...

Hi there,

I have a question regarding plotting with Python.

I have the following python script:

# coding: utf-8
from pylab import *
import numpy

filename='ourtest_out.list'

fh=open(filename)
line=fh.readline()
fh.close

z=array([ float(val) for val in line.split()[1:] ])


a = numpy.loadtxt(filename,skiprows=3)
N=100
t = a[:,0]
nu = a[0:,1:N+1]
#Conc = a[1:,N+1:]
Conc = a[1:,N+1:]

levels=arange(-10,1)
levels=levels[-3]-levels
t=t/360.

figure()
plot(Conc[0],z)

xlabel('C')
ylabel('z')
#show()
savefig('Conc.png')
close()

#nu
figure()
lw = 2.0 #linewidth
dpi = 96

levels=arange(-10,1)
levels=levels[-3]-levels
plot(nu[0],z)
xlabel('nu')
ylabel('z')
savefig('nu.png')
close()


However, once I run the program (run.py)

I have error like this:

---
ValueErrorTraceback (most recent call last)
/Users/…./run.py inmodule()
  24
  25 figure()
---  26 plot(Conc[0],z)
  27
  28 xlabel('C')

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/pyplot.py
in plot(*args, **kwargs)
2284 ax.hold(hold)
2285 try:
-  2286 ret = ax.plot(*args, **kwargs)
2287 draw_if_interactive()
2288 finally:

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py
in plot(self, *args, **kwargs)
3781 lines = []
3782
-  3783 for line in self._get_lines(*args, **kwargs):
3784 self.add_line(line)
3785 lines.append(line)

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py
in _grab_next_args(self, *args, **kwargs)
 315 return
 316 if len(remaining)= 3:
--  317 for seg in self._plot_args(remaining, kwargs):
 318 yield seg
 319 return

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py
in _plot_args(self, tup, kwargs)
 292 x = np.arange(y.shape[0], dtype=float)
 293
--  294 x, y = self._xy_from_xy(x, y)
 295
 296 if self.command == 'plot':

/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py
in _xy_from_xy(self, x, y)
 232 y = np.atleast_1d(y)
 233 if x.shape[0] != y.shape[0]:
--  234 raise ValueError(x and y must have same first dimension)
 235 if x.ndim  2 or y.ndim  2:
 236 raise ValueError(x and y can be no greater than 2-D)

ValueError: x and y must have same first dimension


---So, What would you suggest?


Looking over the traceback and code, it would appear the error is saying 
that there is an inconsistency with the arguments expected vs the 
arguments passed, which appears in this case to relate to ...


plot(Conc[0],z)

... which derives its parameters from the two lines ...

z=array([ float(val) for val in line.split()[1:] ])

... and ...

a = numpy.loadtxt(filename,skiprows=3)


So, I'd conclude that I'd need a better understanding of how to use the 
functions plot, array and numpy.loadtext.  Neither plot nor array are 
python builtins nor defined within your script, so they're likely 
brought in from ...


from pylab import *

... which is generally not something you want to do except when first 
starting to experiment and learn a new module, and then I'd keep things 
to the interactive interpreter for testing and discovery.  This form of 
import is generally thought of as polluting the namespace and may allow 
library specific names to mask python builtins.  For example. suppose a 
module 'xyz' contains a special 'print' function.  Executing 'from xyz 
import *' would shadow the python builtin print function essentially 
making it inaccessible.  It's possible (although unlikely in the case of 
pylab specifically) that any python builtins that are used in your 
script have been replaced with pylab versions.  A better technique is to 
simply import pylab and refer to its functions as pylab.xyz so that no 
ambiguity is possible.


So, read up on pylab, find their support list [1], and follow up there. 
 We focus mainly on getting you far enough along with python basics and 
generally leave specific library support to the library authors and 
support groups.


HTH

Emile


[1] start at http://www.scipy.org/Mailing_Lists

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


Re: [Tutor] is there a better way to organise this code

2011-11-30 Thread Wayne Werner
On Wed, Nov 30, 2011 at 3:34 PM, Norman Khine nor...@khine.net wrote:

 hello,

 is there a better way to organise this code or optimise it.

 http://pastie.org/2944797


After glancing at it the only change that I would recommend (possibly)
making is lines 58 and 39 - you can wrap the dictionaries (line line 7) and
that will bring all your lines  80 characters. Other than that it looks
perfectly readable. You could add some docstrings for completeness.

As far as anything else - is this code too slow? If not, why bother trying
to optimise it? Obviously if you were doing something horribly inefficient
like a bubble sort (especially considering Python has a built-in sort),
then you would want to get rid of that, but I didn't really notice
anything. Though now that I took a few more seconds, it does look like
you're not using rows, aside from looping over it. If you only care about
the values and not the collection as a whole you could (and should) change
the list comprehension to a generator expression:

 [x for x in (1,2,3)]
[1, 2, 3]
 (x for x in (1,2,3))
generator object genexpr at 0x01BFB6C0

If you're not familiar with a generators, I highly recommend this set of
slides: http://www.dabeaz.com/generators/Generators.pdf

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


Re: [Tutor] is there a better way to organise this code

2011-11-30 Thread Steven D'Aprano

Norman Khine wrote:

hello,

is there a better way to organise this code or optimise it.
http://pastie.org/2944797


Is that a question? Because I get a syntax error in my brain when I parse it 
without the question mark. wink


Sorry to pick on you, but it astonishes me when people don't bother with basic 
English syntax, and yet try writing code where syntax is *much* more 
important. If they can't be bothered with writing correct English, that sends 
all the wrong signals about the quality of their code.


You should write as if you were coding, otherwise people will assume you code 
like you write.


Laziness is one of the cardinal virtues of the programmer, but it has to be 
the right sort of laziness. Don't reinvent the wheel, use an existing 
library is good laziness. Leave out required syntax elements and hope 
someone else will fix them is not.


Before worrying about optimising the code, how about checking whether it works?

(1) What is CSVFile? It appears to be a class, because you inherit from it, 
but it isn't defined anywhere and isn't a builtin. So your code fails on the 
very first line.


(2) You have a class WorldSchema with no methods, and a top-level function 
get_world that *looks* like a method because it has an argument self, but 
isn't. The indentation is wrong. See what I mean about syntax? Syntax is 
important. So is get_world a wrongly indented method, or a poorly written 
function?


(3) Since get_world doesn't use self at all, perhaps it should be a 
top-level function of no arguments? Or perhaps a static method of WorldSchema?


(4) You have a class called getCountries, which seems to be a poor name for 
a class. In general, classes should be *things*, not *actions*. Also I 
recommend that you follow PEP 8 for naming conventions. (Google PEP 8 if you 
don't know what I mean, and remember, it isn't compulsory, but it is 
recommended.) A better name might be CountryGetter.


(5) The use of classes appears on first reading to be a Java-ism. In Java, 
everything must be a class Just Because The Powers Who Be Said So. In Python, 
we are allowed, and encouraged, to mix classes and functions. Use the right 
tool for the job. But without any idea of the broader context, I have no idea 
if classes are appropriate or not.


(6) getCountries has a method called get_options. Based on the name, a 
reasonable reader would assume it returns some sort of list or dictionary of 
options, right? But according to the documentation, it actually returns a JSON 
ser, whatever that is. Server? Service? Serialization (of what)? Something else?


(7) Other problems:  Enumerate, MSG and iana_root_zone are used but not 
defined anywhere. Documentation is lacking, so I don't understand what the 
code is intended to do. Another class with a poor name, getRegions. There 
may be others, but I stopped reading around this point.





--
Steven

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


Re: [Tutor] is there a better way to organise this code

2011-11-30 Thread Dave Angel

On 11/30/2011 07:49 PM, Steven D'Aprano wrote:

Norman Khine wrote:

hello,

is there a better way to organise this code or optimise it.
http://pastie.org/2944797


Is that a question? Because I get a syntax error in my brain when I 
parse it without the question mark. wink


Sorry to pick on you, but it astonishes me when people don't bother 
with basic English syntax, and yet try writing code where syntax is 
*much* more important. If they can't be bothered with writing correct 
English, that sends all the wrong signals about the quality of their 
code.


You should write as if you were coding, otherwise people will assume 
you code like you write.


Laziness is one of the cardinal virtues of the programmer, but it has 
to be the right sort of laziness. Don't reinvent the wheel, use an 
existing library is good laziness. Leave out required syntax 
elements and hope someone else will fix them is not.


Before worrying about optimising the code, how about checking whether 
it works?


(1) What is CSVFile? It appears to be a class, because you inherit 
from it, but it isn't defined anywhere and isn't a builtin. So your 
code fails on the very first line.


(2) You have a class WorldSchema with no methods, and a top-level 
function get_world that *looks* like a method because it has an 
argument self, but isn't. The indentation is wrong. See what I mean 
about syntax? Syntax is important. So is get_world a wrongly indented 
method, or a poorly written function?


(3) Since get_world doesn't use self at all, perhaps it should be a 
top-level function of no arguments? Or perhaps a static method of 
WorldSchema?


(4) You have a class called getCountries, which seems to be a poor 
name for a class. In general, classes should be *things*, not 
*actions*. Also I recommend that you follow PEP 8 for naming 
conventions. (Google PEP 8 if you don't know what I mean, and 
remember, it isn't compulsory, but it is recommended.) A better name 
might be CountryGetter.


(5) The use of classes appears on first reading to be a Java-ism. In 
Java, everything must be a class Just Because The Powers Who Be Said 
So. In Python, we are allowed, and encouraged, to mix classes and 
functions. Use the right tool for the job. But without any idea of the 
broader context, I have no idea if classes are appropriate or not.


(6) getCountries has a method called get_options. Based on the name, a 
reasonable reader would assume it returns some sort of list or 
dictionary of options, right? But according to the documentation, it 
actually returns a JSON ser, whatever that is. Server? Service? 
Serialization (of what)? Something else?


(7) Other problems:  Enumerate, MSG and iana_root_zone are used but 
not defined anywhere. Documentation is lacking, so I don't understand 
what the code is intended to do. Another class with a poor name, 
getRegions. There may be others, but I stopped reading around this 
point.



I stopped looking at his pastie once the background turned black.  I'd 
have had to copy it elsewhere to even read it.



--

DaveA

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


Re: [Tutor] plotting in python

2011-11-30 Thread Asokan Pichai
On Thu, Dec 1, 2011 at 2:38 AM, stm atoc stm.at...@googlemail.com wrote:
 Hi there,

 I have a question regarding plotting with Python.

 I have the following python script:

[SNIPPED]
 plot(Conc[0],z)

[SNIPPED]
 ---So, What would you suggest?

What is the output of
print len(Conc[0]), len(z)

You may insert that line above the plot and see

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