[Tutor] Importing packages

2011-01-21 Thread arun kumar
Hi,

I'm trying to program with gdata
(http://code.google.com/p/gdata-python-client/) using python
library.I'm having problem in writing import statements.

The source directory content is like this:

atom(folder): this folder contains some files with the .py extension
gdata (folder):this folder contains some folders and as well as some
files with the .py extension. Also each of the folders contain a
__init__.py file.

I want to use the classes and functions of the gdata and its inner
folders' classes and functions.

please  tell me how write the import statements

-- 
Thank you

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


Re: [Tutor] not understanding a recursion example

2011-01-21 Thread Peter Otten
Bill Allen wrote:

> I am not understanding the following code (I did not write it).  It
> demonstrates walking a tree-like data structure using recursion.  It does
> run and produces reasonable output.  I particularly do not understand the
> "traverse.level" statements.  Can anyone give me an idea how this is
> working
> and the principles?  I would like understand recursive calls in Python
> better as I have not used the technique previously.

> def traverse(data):
> print(' ' * traverse.level + data['text'])
> for kid in data['kids']:
> traverse.level += 1
> traverse(kid)
> traverse.level -= 1
> 
> if __name__ == '__main__':
> traverse.level = 1
> traverse(data)


Functions are objects in python; you can tuck arbitrary attributes onto 
them, and the above uses a function attribute instead of a global variable.
A more standard way to write the above would be

def traverse(data):
global level
print(' ' * level + data['text'])
for kid in data['kids']:
level += 1
traverse(kid)
level -= 1

if __name__ == '__main__':
level = 1
traverse(data)

What it does: 
* call traverse with the outermost dictionary
* print the data["text"] value indented by the current global level.
* iterate over the data["kids"] list of dictionaries
* for each entry in that list
- increment indentation level
- invoke traverse which will print the data["text"] value.
  (Remember that traverse was called with the current value of kid, so
   in terms of the outer traverse() the inner traverse() is printing
   kid["text"]) Process the kid's kids in the same way.
- decrement the indentation level

However using global variables is generally a bad practice. 
It is easy to leave them in an inconsistent state, and if you are using 
multiple threads (i. e. invoke traverse() a second time while the first call 
hasn't finished) you'll end up with a big mess.

I would therefore write the traverse function as

def traverse(data, level):
print(' ' * level + data['text'])
for kid in data['kids']:
traverse(kid, level+1)

if __name__ == "__main__":
traverse(data, 1)

which I think may also be easier to understand.

Peter

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


Re: [Tutor] Importing packages

2011-01-21 Thread Pacific Morrowind

Hi;

On 21/01/2011 1:10 AM, arun kumar wrote:

Hi,

I'm trying to program with gdata
(http://code.google.com/p/gdata-python-client/) using python
library.I'm having problem in writing import statements.

The source directory content is like this:

atom(folder): this folder contains some files with the .py extension
gdata (folder):this folder contains some folders and as well as some
files with the .py extension. Also each of the folders contain a
__init__.py file.

I want to use the classes and functions of the gdata and its inner
folders' classes and functions.

please  tell me how write the import statements
Without knowing the exact names/format of those folders can't be 100% 
exact but you'd want to say something along the lines of


import gdata.example.funky
to import the module gdata/example/funky.py
or
import gdata.example2
to import the package gdata/example2 (__init__.py) - just a quick method 
to say the same thing as import gdata.example2.__init__ basically and 
logically is clear that that is the base fuctions/info etc. for that 
package (example2).

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


Re: [Tutor] How to plot graph?

2011-01-21 Thread tee chwee liong

hi,
 
i'm using python 2.5 and windows xp. 
my sample data is as below. i intend to plot EyVt and EyHt on the Y-axis and 
Lane as the X-axis.
Platform: PC
Tempt : 25
TAP0 :0
TAP1 :1
+
Port Chnl Lane EyVt EyHt
+
0  1  1   75  55
0  1  2   10 35
0  1 325 35 
0  1 435 25
0  1 5   10 20
+
Time: 20s
 
thanks
 
> Date: Wed, 19 Jan 2011 22:54:53 -0500
> Subject: Re: [Tutor] How to plot graph?
> From: smokefl...@gmail.com
> To: tc...@hotmail.com
> CC: st...@pearwood.info; tutor@python.org
> 
> actually i just want to plot a simple x and y graph. any suggestion?
> how about using excel to plot? any sample code that i can follow to:
> 1) launch excel
> 2) read x-y from a text file
> 3) plot graph
> 
> thanks
> 
> x,y is simple in many modules(beyond is more computational. What
> version of python, platform and modules are you using?
> 
> 
> -- 
> The lawyer in me says argue...even if you're wrong. The scientist in
> me... says shut up, listen, and then argue. But the lawyer won on
> appeal, so now I have to argue due to a court order.
> 
> Furthermore, if you could be a scientific celebrity, would you want
> einstein sitting around with you on saturday morning, while you're
> sitting in your undies, watching Underdog?...Or better yet, would
> Einstein want you to violate his Underdog time?
> 
> Can you imagine Einstein sitting around in his underware? Thinking
> about the relativity between his cotton nardsac, and his Fruit of the
> Looms?
  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Importing packages

2011-01-21 Thread arun kumar
hi,

I am not understanding what you are saying. I included those modules
in the sys.path. i want  to know how to write the import statement for
the modules and packages. I downloaded the gdata client library and
extracted it. It contained a scr directory which contained two
directories:
1)atom
2)gdata

gdata again has some 31 directories and some .py files.These 31
directories contains files with .py extension.

Where as the atom directory no further dirrectories. It contained only
files with .py extension

I want to write the import statementt for the files in gdata directory
and also for the files in the 31 directories of the gdata.


On 1/21/11, Pacific Morrowind  wrote:
> Hi;
>
> On 21/01/2011 1:10 AM, arun kumar wrote:
>> Hi,
>>
>> I'm trying to program with gdata
>> (http://code.google.com/p/gdata-python-client/) using python
>> library.I'm having problem in writing import statements.
>>
>> The source directory content is like this:
>>
>> atom(folder): this folder contains some files with the .py extension
>> gdata (folder):this folder contains some folders and as well as some
>> files with the .py extension. Also each of the folders contain a
>> __init__.py file.
>>
>> I want to use the classes and functions of the gdata and its inner
>> folders' classes and functions.
>>
>> please  tell me how write the import statements
> Without knowing the exact names/format of those folders can't be 100%
> exact but you'd want to say something along the lines of
>
> import gdata.example.funky
> to import the module gdata/example/funky.py
> or
> import gdata.example2
> to import the package gdata/example2 (__init__.py) - just a quick method
> to say the same thing as import gdata.example2.__init__ basically and
> logically is clear that that is the base fuctions/info etc. for that
> package (example2).
> Pacific
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
Thank you

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


Re: [Tutor] not understanding a recursion example

2011-01-21 Thread Bill Allen
Peter,

Thank you very much for the explanation.   I understand this much better
now.   You are correct, the implementation you show is easier for me to
understand.



--Bill









On Fri, Jan 21, 2011 at 03:43, Peter Otten <__pete...@web.de> wrote:

> Bill Allen wrote:
>
> > I am not understanding the following code (I did not write it).  It
> > demonstrates walking a tree-like data structure using recursion.  It does
> > run and produces reasonable output.  I particularly do not understand the
> > "traverse.level" statements.  Can anyone give me an idea how this is
> > working
> > and the principles?  I would like understand recursive calls in Python
> > better as I have not used the technique previously.
>
> > def traverse(data):
> > print(' ' * traverse.level + data['text'])
> > for kid in data['kids']:
> > traverse.level += 1
> > traverse(kid)
> > traverse.level -= 1
> >
> > if __name__ == '__main__':
> > traverse.level = 1
> > traverse(data)
>
>
> Functions are objects in python; you can tuck arbitrary attributes onto
> them, and the above uses a function attribute instead of a global variable.
> A more standard way to write the above would be
>
> def traverse(data):
>global level
>print(' ' * level + data['text'])
> for kid in data['kids']:
> level += 1
>traverse(kid)
> level -= 1
>
> if __name__ == '__main__':
> level = 1
>traverse(data)
>
> What it does:
> * call traverse with the outermost dictionary
> * print the data["text"] value indented by the current global level.
> * iterate over the data["kids"] list of dictionaries
> * for each entry in that list
>- increment indentation level
>- invoke traverse which will print the data["text"] value.
>  (Remember that traverse was called with the current value of kid, so
>   in terms of the outer traverse() the inner traverse() is printing
>   kid["text"]) Process the kid's kids in the same way.
>- decrement the indentation level
>
> However using global variables is generally a bad practice.
> It is easy to leave them in an inconsistent state, and if you are using
> multiple threads (i. e. invoke traverse() a second time while the first
> call
> hasn't finished) you'll end up with a big mess.
>
> I would therefore write the traverse function as
>
> def traverse(data, level):
>print(' ' * level + data['text'])
> for kid in data['kids']:
> traverse(kid, level+1)
>
> if __name__ == "__main__":
>traverse(data, 1)
>
> which I think may also be easier to understand.
>
> Peter
>
> ___
> 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] Importing packages

2011-01-21 Thread Jerry Hill
On Fri, Jan 21, 2011 at 4:10 AM, arun kumar  wrote:
> Hi,
>
> I'm trying to program with gdata
> (http://code.google.com/p/gdata-python-client/) using python
> library.I'm having problem in writing import statements.

Have you read the Getting Started document linked from their wiki?
Particularly, there's a section on the right way to install the
library, then some example of it's use (including the import
statements) here:
http://code.google.com/apis/gdata/articles/python_client_lib.html#library

You haven't said what you tried or what error messages you've gotten,
so if those docs don't help, you'll have to give us more information.
Particularly: what version of python are you running?  What Operating
System?  How have you manipulated your sys.path, where did you install
the gdata libraries, and what is the folder structure there?

You may also find the part of the python tutorial about modules and
packages useful in figuring out what's going on:
http://docs.python.org/tutorial/modules.html

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


[Tutor] list of tutors for python

2011-01-21 Thread bruce
Hi guys.

Please don't slam me!! I'm working on a project, looking for a pretty
good number of pythonistas. Trying to find resources that I should
look to to find them, and thought I would try here for suggestions.

Any comments would be appreciated.

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


Re: [Tutor] list of tutors for python

2011-01-21 Thread Emile van Sebille

On 1/21/2011 12:57 PM bruce said...

Hi guys.

Please don't slam me!! I'm working on a project, looking for a pretty
good number of pythonistas. Trying to find resources that I should
look to to find them, and thought I would try here for suggestions.

Any comments would be appreciated.



You're looking for what exactly?

Emile



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


Re: [Tutor] list of tutors for python

2011-01-21 Thread Steven D'Aprano

bruce wrote:

Hi guys.

Please don't slam me!! I'm working on a project, looking for a pretty
good number of pythonistas. Trying to find resources that I should
look to to find them, and thought I would try here for suggestions.


I'm sorry, I don't understand what your question is.

If you're looking for Python resources where people can go and get 
advice, this mailing list is one.


The "official" mailing lists run by python.org can be found here:

http://www.python.org/community/lists/
http://mail.python.org/mailman/listinfo

It includes this mailing list, as well as python-l...@python.org which 
is also available on Usenet as comp.lang.python.


You can also look at Reddit and StackOverflow:

http://reddit.com/r/python/
http://stackoverflow.com/questions/tagged/python

There are probably many other places on the internet -- google is your 
friend.


If you are looking for a list of *people*, there is no such list.




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


[Tutor] unable to build python-2.7.1

2011-01-21 Thread brian.sheely
I would have thought that building python-2.7.1 would be pretty straightforward - even on an SGI Altix. There were no issues when I ran configure. However, running make results in the following compile error:   Objects/floatobject.c(2603): remark #810: conversion from "int" to "unsigned char" may lose significant bits  sign = (*p >> 7) & 1;   ^   (0): internal error: backend signals   compilation aborted for Objects/floatobject.c (code 4)   make: *** [Objects/floatobject.o] Error 4The compiler instructions were:   icc -pthread -c -fno-strict-aliasing -Olimit 1500 -g -O2 -DNDEBUG -g  -O3 -Wall -Wstrict-prototypes  -I. -IInclude    -I./Include   -DPy_BUILD_CORE -o Objects/floatobject.o Objects/floatobject.cDoes anyone have any ideas what the problem might be? Thanks in advance.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter in classes...why?

2011-01-21 Thread Alan Gauld

Elwin Estle"  wrote


I have some experience in Tcl\Tk, and so far,
Tkinter is striking me as harder to use that Tk
in it's "native" environment.


They are actually very similar although Tkinter is a little more 
verbose.
Remember that Tk uses objects too, its just that they are less 
visible.

When you create Tk widgets you define them using a tree of objects
rooted at '.'

But there are good reasons to use OOP in building GUIs regardless
of the Framework - and even many Tcl/Tk programmers use tools
like [incr Tcl] to build OOP GUIs using Tk...


But, the tutorials I have encountered all mentioned that it is
supposed to be a good idea to put one's GUI stuff in a class,
then create an instance of the class (which I don't entirely
understand, since I thought the whole "class" thing was for
stuff that you were gonna have a lot of,


Not necessarily a lot of but things you may want to reuse.
And Guis are full of things you can reuse like Forms, Dialogs,
composite widgets etc. By packaging them as a class based
on a Frame its as easy to reuse them as just adding a new
Frame to your app. And you bring in all the entries, radio buttons
,labels etc that you need for free. As well as the event handlers
for the class. (This is also the main reason you should try to
keep app logic out of your GUI event handlers!)


use the class like a factory to spit out little copies of itself.


Yep, lots of nreuase of login widgets, file editing widgets etc etc.
Much easier to reuse than writing GUI functions in Tk and trying
to import them into another project.

Also, visually its an easy mapping to make in your head to see
a widget or panel on screen and associate it with the class
code behind it. GUI widgets are conceptually objects so we
might as well make them software objects too.


I still don't have a handle on all the "self.this's & self.that's",


Yeah OOOP does take a little getting used too. But you had
to get used to TK's arcane naming tree too, once mastered
its all pretty logical.


Why not just grid stuff right into the window, instead of
making a frame and gridding widgets into that.


Because a Frame is a container that allows you to reuse
that whole panel. packing(or gridding if you prefer) loses
you the reuseability.


Is the (self, master) thing in the __init__ section a convention,


Its the Tkinter equivalent of using '.' to start your naming tree
in Tk. The master is passed to a hideen attribute inside the
widget which maintains the links up the tree. Tk just does
that explicitly via the name.


or is the use of the "master" a requirement?
Can you call it something else?


You can call it whatever you like in most cases - its a bit like
self in a class definition. You can change it if you want but
I don't recommend it - you will confuse anyone reading the
code (including, possibly yourself!) but I have seen "parent"
used in some programs.


What is the purpose of doing an __init__ with a frame
after having done __init__ with (self, master)?


The self,master is usually to the superclass. The rest of init
is about the current object. If that makes no sense you need
to go back to the OOP primers because its no different in
Tkinter than elsewhere in that regard.


All this in Tcl\Tk seems to me, in comparison, just dead
nuts simple...but Tkinter...seems to have made unnecessarily
complicated.


You can write Tkinter code exactly like Tk but you lose
the reuse and logical organisation advantages that OOP
brings. But Tkinter works just fine without OOP.

But using OOP with Tkinter will make the jump to other,
more powerful, GUI frameworks later, much, much easier
because they all use OOP, almost without exception
(unless you count raw Win32!).

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


Re: [Tutor] list of tutors for python

2011-01-21 Thread Alan Gauld

"bruce"  wrote

Please don't slam me!! I'm working on a project, looking for a 
pretty

good number of pythonistas. Trying to find resources that I should
look to to find them, and thought I would try here for suggestions.


OK, This list is not a recruiting forum for Python tutors.
It is a mailing list where people(specifically Pythonic newbies)
post questions about Python and get answers.

As such it won't help you find recruits for your project, but it may
answer a lot of the questions for which you want to recruit those
experts... In effect you get the entire membership of the list for
free.

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


Re: [Tutor] unable to build python-2.7.1

2011-01-21 Thread Wayne Werner
On Fri, Jan 21, 2011 at 12:17 PM,  wrote:

> I would have thought that building python-2.7.1 would be pretty
> straightforward - even on an SGI Altix. There were no issues when I ran
> configure. However, running make results in the following compile error:
>
>Objects/floatobject.c(2603): remark #810: conversion from "int" to
> "unsigned char" may lose significant bits
>   sign = (*p >> 7) & 1;
>^
>(0): internal error: backend signals
>compilation aborted for Objects/floatobject.c (code 4)
>make: *** [Objects/floatobject.o] Error 4
>
> The compiler instructions were:
>
>icc -pthread -c -fno-strict-aliasing -Olimit 1500 -g -O2 -DNDEBUG -g
> -O3 -Wall -Wstrict-prototypes  -I. -IInclude-I./Include
> -DPy_BUILD_CORE -o Objects/floatobject.o Objects/floatobject.c
>
> Does anyone have any ideas what the problem might be? Thanks in advance.
>

This mailing list is really targeted at the python programming language, not
so much building python. You may get better results somewhere like
stackoverflow. However, if I had to guess, the problem is likely in the code
that is converting an int to an unsigned char - icc is probably set to die
on the warning. However, I'm not familiar enough with C code or the compiler
flags to tell you how to fix/ignore it.

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