Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Chris Warrick
[Forwarding your message to the mailing list — please use the Reply
All (or Reply to List) button in the future]

On 25 December 2015 at 05:02, Aaron Christensen
 wrote:
> Hi Chris,
>
> Thank you for your response and information.  I enjoy doing Python on my
> free time so when I get closer to some kind of web application, then I can
> provide more information.
>
> Thanks for pointing me in the right direction so far.  I will replace any
> shelve usage with the database.  I also started looking at WSGI servers and
> just found a great deal of information on fullstackpython.com.

Full Stack Python is a good resource, which teaches many things
considered best practices in the Python web world (I personally
recommend uWSGI instead of Gunicorn, but that’s mainly just my
preference)

> I have some experience in PHP (which is why I mentioned it).  I am
> unfamiliar with Django, Flask, or Pyramid.  I am looking into Django, but am
> a little hesitant because of all the time I spent learning PHP.

I’m sorry, but you wasted your time. PHP is an awful language with
multiple problems and bad design decisions. Here’s some laughing
stock:

http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
http://reddit.com/r/lolphp
http://phpsadness.com/

On the other hand, Python web frameworks are really fun and easy to
learn, even though their general design is a bit different from PHP’s:

https://docs.djangoproject.com/en/1.9/intro/tutorial01/
http://tutorial.djangogirls.org/en/

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread oneman
> On 25 December 2015 at 05:02, Aaron Christensen
>  wrote:
>> Hi Chris,
>> 
>> Thank you for your response and information.  I enjoy doing Python on my
>> free time so when I get closer to some kind of web application, then I can
>> provide more information.
>> 
>> Thanks for pointing me in the right direction so far.  I will replace any
>> shelve usage with the database.  I also started looking at WSGI servers and
>> just found a great deal of information on fullstackpython.com.
> 
> Full Stack Python is a good resource, which teaches many things
> considered best practices in the Python web world (I personally
> recommend uWSGI instead of Gunicorn, but that’s mainly just my
> preference)
> 
>> I have some experience in PHP (which is why I mentioned it).  I am
>> unfamiliar with Django, Flask, or Pyramid.  I am looking into Django, but am
>> a little hesitant because of all the time I spent learning PHP.
> 
> I’m sorry, but you wasted your time. PHP is an awful language with
> multiple problems and bad design decisions. Here’s some laughing
> stock:
> 
> http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
> http://reddit.com/r/lolphp
> http://phpsadness.com/
> 
> On the other hand, Python web frameworks are really fun and easy to
> learn, even though their general design is a bit different from PHP’s:
> 
> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
> http://tutorial.djangogirls.org/en/

If you want to get a good overview of what it means to use a python web 
framework, try Miguel Grinberg’s great flask tutorial [1]. It’s based on flask, 
a more lightweight web framework compared to django, but the basic principles 
are the same. He covers about anything you need to know in easy to follow 
lessons. Only basic python knowledge is required.

[1] 
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world

my 2 cts,

oneman

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Aaron Christensen
Hi Jason,

What gives you that idea?
On Dec 25, 2015 12:23 AM, "Jason Friedman"  wrote:

> > I am not sure if this is the correct venue for my question, but I'd like
> to
> > submit my question just in case.  I am not a programmer but I do have an
> > incredible interest in it, so please excuse my lack of understanding if
> my
> > question isn't very thorough.
> >
> > As an example, a website backend is developed using Python.  Users can
> > submit their input through the website and PHP (or some other language)
> > transfers the user input from the website fields to a database such as
> > MySQL.  There is a main script called main_script.py which extracts the
> > user data from MySQL, processes it, stores output in MySQL and sends
> output
> > to the user (via webpage and email).
> >
> > About main_script.py
> > # main_script.py extracts user input from MySQL, processes it, stores
> > output in MySQL and send output to user (via webpage and email).
> > # Inputs: User personal information such as age, dob, nationality,
> hobbies,
> > and 20 or 30 other fields
> > # Output: main_script.py is going to do something with it such as access
> > the database and some shelve files or other py scripts. I have no clue
> what
> > it's going to do, but my point is that the processing of the input to
> > output will take longer than simply a print('Hello, %r!' %user_name).
> >
> > My question:  I am curious to know how Python handles something like
> this.
> > Let's say that there are 10, 20, 50, or even 1000 users accessing the
> > website.  They all put in their 20 to 30 pieces of input and are waiting
> on
> > some fancy magic output.  How exactly does that work?  Can multiple users
> > access the same script?  Does the Python programmer need to code in a
> > manner that supports this?  Are requests to the script handled serially
> or
> > in parallel?
>
> I have a hunch that you do not want to write the program, nor do you
> want to see exactly how a programmer would write it?
>
> The question is more like asking a heart surgeon how she performs
> heart surgery:  you don't plan to do it yourself, but you want a
> general idea of how it is done?  How do you keep the patient from
> bleeding to death?  Does the heart stop while performing the surgery,
> and if yes, how does the patient stay alive?
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Aaron Christensen
Great thank you!  I will look into it. I watched some tutorials on Django
last night. It appears to be somewhat of a bootstrap but for the backend.
I'm not sure if my opinion is correct.
On Dec 25, 2015 5:27 AM,  wrote:

> > On 25 December 2015 at 05:02, Aaron Christensen
> >  wrote:
> >> Hi Chris,
> >>
> >> Thank you for your response and information.  I enjoy doing Python on my
> >> free time so when I get closer to some kind of web application, then I
> can
> >> provide more information.
> >>
> >> Thanks for pointing me in the right direction so far.  I will replace
> any
> >> shelve usage with the database.  I also started looking at WSGI servers
> and
> >> just found a great deal of information on fullstackpython.com.
> >
> > Full Stack Python is a good resource, which teaches many things
> > considered best practices in the Python web world (I personally
> > recommend uWSGI instead of Gunicorn, but that’s mainly just my
> > preference)
> >
> >> I have some experience in PHP (which is why I mentioned it).  I am
> >> unfamiliar with Django, Flask, or Pyramid.  I am looking into Django,
> but am
> >> a little hesitant because of all the time I spent learning PHP.
> >
> > I’m sorry, but you wasted your time. PHP is an awful language with
> > multiple problems and bad design decisions. Here’s some laughing
> > stock:
> >
> > http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
> > http://reddit.com/r/lolphp
> > http://phpsadness.com/
> >
> > On the other hand, Python web frameworks are really fun and easy to
> > learn, even though their general design is a bit different from PHP’s:
> >
> > https://docs.djangoproject.com/en/1.9/intro/tutorial01/
> > http://tutorial.djangogirls.org/en/
>
> If you want to get a good overview of what it means to use a python web
> framework, try Miguel Grinberg’s great flask tutorial [1]. It’s based on
> flask, a more lightweight web framework compared to django, but the basic
> principles are the same. He covers about anything you need to know in easy
> to follow lessons. Only basic python knowledge is required.
>
> [1]
> http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
>
> my 2 cts,
>
> oneman
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Aaron Christensen
LOL. Thanks!  PHP was definitely not very easy to pick up and I'm still
having some issues. Last night I watched some tutorials on Django and plan
on reading all of the links on the docs page of Django.  I will also look
at your recommendation.  I think that will give me a good understanding.
Hopefully Django isn't a copy/paste kinda "put your website together" like
WordPress because my objective is to actually learn Python.
On Dec 25, 2015 3:59 AM, "Chris Warrick"  wrote:

> [Forwarding your message to the mailing list — please use the Reply
> All (or Reply to List) button in the future]
>
> On 25 December 2015 at 05:02, Aaron Christensen
>  wrote:
> > Hi Chris,
> >
> > Thank you for your response and information.  I enjoy doing Python on my
> > free time so when I get closer to some kind of web application, then I
> can
> > provide more information.
> >
> > Thanks for pointing me in the right direction so far.  I will replace any
> > shelve usage with the database.  I also started looking at WSGI servers
> and
> > just found a great deal of information on fullstackpython.com.
>
> Full Stack Python is a good resource, which teaches many things
> considered best practices in the Python web world (I personally
> recommend uWSGI instead of Gunicorn, but that’s mainly just my
> preference)
>
> > I have some experience in PHP (which is why I mentioned it).  I am
> > unfamiliar with Django, Flask, or Pyramid.  I am looking into Django,
> but am
> > a little hesitant because of all the time I spent learning PHP.
>
> I’m sorry, but you wasted your time. PHP is an awful language with
> multiple problems and bad design decisions. Here’s some laughing
> stock:
>
> http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
> http://reddit.com/r/lolphp
> http://phpsadness.com/
>
> On the other hand, Python web frameworks are really fun and easy to
> learn, even though their general design is a bit different from PHP’s:
>
> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
> http://tutorial.djangogirls.org/en/
>
> --
> Chris Warrick 
> PGP: 5EAAEA16
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-25 Thread Nicky Mac
thanks again for continuing to address my problem.
all those files are present as required.
This is a hard slog.
Maybe I should give up and fallback to my now working win 7 system
until a resolution crops up via an update/upgrade.
Have  a happy and peaceful Christmas


On 24 December 2015 at 22:17, eryk sun  wrote:

> On Thu, Dec 24, 2015 at 3:29 PM, Nicky Mac  wrote:
> >
> > C:\Users\Nick>python -m idlelib
> > ** IDLE can't import Tkinter.
> > Your Python may not be configured for Tk. **
>
> In the 3.5 installation directory, ensure that tkinter is installed in
> Lib/tkinter. There should be an "__init__.py" and several other files
> such as "filedialog.py". Also ensure that the DLLs  directory has the
> extension module "_tkinter.pyd" and dependent DLLs "tcl86t.dll" and
> "tk86t.dll".
>



-- 
Nick "Mac" McElwaine
-- 
https://mail.python.org/mailman/listinfo/python-list


Python compiling with third party tools

2015-12-25 Thread Ping Liu
I am developing an open source software for optimization purpose. We have
interface to a list of solvers or solver interfaces like Openopt, Cylp,
GLPK, CBC, SCip, Cplex, etc. Now the sponsor asks us to compile the python
code, and wrap all the third party tools with it so that they do not need
to install any of those tools or even python itself. Does anyone know how
to do this?

Any advice is appreciated.

Ping
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Jason Friedman
>> I have a hunch that you do not want to write the program, nor do you
>> want to see exactly how a programmer would write it?
>>
>> The question is more like asking a heart surgeon how she performs
>> heart surgery:  you don't plan to do it yourself, but you want a
>> general idea of how it is done?  How do you keep the patient from
>> bleeding to death?  Does the heart stop while performing the surgery,
>> and if yes, how does the patient stay alive?

> What gives you that idea?

You said:  I am not a programmer but I do have an incredible interest in it.

Many people say:  I am not a programmer but I want to become one.

I just wanted to make sure your actual question was being answered.
Sounds like it is.

Also, the general practice is to put your response at the bottom of your reply.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Chris Warrick
On 25 December 2015 at 13:15, Aaron Christensen
 wrote:
> LOL. Thanks!  PHP was definitely not very easy to pick up and I'm still
> having some issues. Last night I watched some tutorials on Django and plan
> on reading all of the links on the docs page of Django.  I will also look at
> your recommendation.  I think that will give me a good understanding.
> Hopefully Django isn't a copy/paste kinda "put your website together" like
> WordPress because my objective is to actually learn Python.

That’s not what WordPress is. WordPress is a blog engine that can be
used as a general-purpose CMS, full stop. You don’t need any coding
skills to build a website with WordPress. Many people have done that —
especially on wordpress.com or shared hosting services with one-click
WP installers; and even without an installer, setting up WordPress on
shared hosting requires a FTP client and reading comprehension
anyways.

On the other hand, Django is nothing like this. Django can do anything
you tell it to, and you need to write code. While Django handles some
things for you (eg. the admin panel or the ORM), you still need to
write models, views, URL configuration, etc. yourself. You need an
understanding of relational databases, HTTP, HTML/CSS, the template
engine, and you do need to write actual code.

And while there are tons of ready-made blog applications for Django
that you can install and use, you can (and should!) write your own in
an hour or two.  And it’s a lot more fun to do that than lazily
downloading something.

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Aaron Christensen
On Dec 25, 2015 12:22 PM, "Jason Friedman"  wrote:
>
> >> I have a hunch that you do not want to write the program, nor do you
> >> want to see exactly how a programmer would write it?
> >>
> >> The question is more like asking a heart surgeon how she performs
> >> heart surgery:  you don't plan to do it yourself, but you want a
> >> general idea of how it is done?  How do you keep the patient from
> >> bleeding to death?  Does the heart stop while performing the surgery,
> >> and if yes, how does the patient stay alive?
>
> > What gives you that idea?
>
> You said:  I am not a programmer but I do have an incredible interest in
it.
>
> Many people say:  I am not a programmer but I want to become one.
>
> I just wanted to make sure your actual question was being answered.
> Sounds like it is.
>
> Also, the general practice is to put your response at the bottom of your
reply.

Understood.  I say I'm not a programmer because my degrees and day job are
not programing.  Thanks for making sure my question was answered!  My
question was answered but it also made me think of several other different
things.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and multiple user access via super cool fancy website

2015-12-25 Thread Aaron Christensen
On Dec 25, 2015 12:38 PM, "Chris Warrick"  wrote:
>
> On 25 December 2015 at 13:15, Aaron Christensen
>  wrote:
> > LOL. Thanks!  PHP was definitely not very easy to pick up and I'm still
> > having some issues. Last night I watched some tutorials on Django and
plan
> > on reading all of the links on the docs page of Django.  I will also
look at
> > your recommendation.  I think that will give me a good understanding.
> > Hopefully Django isn't a copy/paste kinda "put your website together"
like
> > WordPress because my objective is to actually learn Python.
>
> That’s not what WordPress is. WordPress is a blog engine that can be
> used as a general-purpose CMS, full stop. You don’t need any coding
> skills to build a website with WordPress. Many people have done that —
> especially on wordpress.com or shared hosting services with one-click
> WP installers; and even without an installer, setting up WordPress on
> shared hosting requires a FTP client and reading comprehension
> anyways.
>
> On the other hand, Django is nothing like this. Django can do anything
> you tell it to, and you need to write code. While Django handles some
> things for you (eg. the admin panel or the ORM), you still need to
> write models, views, URL configuration, etc. yourself. You need an
> understanding of relational databases, HTTP, HTML/CSS, the template
> engine, and you do need to write actual code.
>
> And while there are tons of ready-made blog applications for Django
> that you can install and use, you can (and should!) write your own in
> an hour or two.  And it’s a lot more fun to do that than lazily
> downloading something.
>
> --
> Chris Warrick 
> PGP: 5EAAEA16
> --
> https://mail.python.org/mailman/listinfo/python-list

That's excellent news. I am looking forward to learning and working with
Django. I imagine that I will have Django related questions in a few weeks
or so.  I appreciate your lengthy responses and explanations!

Thank you,
Aaron
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to open IDLE for Python3.50rc1 on windows10 64bit AMD

2015-12-25 Thread Nicky Mac
problem solved :_
I upgraded to 3.5.1 just released, and it works fine!
(except pillow and pygame installs still dont work, but that's not your
problem)
Enjoy the holidays

On 25 December 2015 at 14:12, Nicky Mac  wrote:

> thanks again for continuing to address my problem.
> all those files are present as required.
> This is a hard slog.
> Maybe I should give up and fallback to my now working win 7 system
> until a resolution crops up via an update/upgrade.
> Have  a happy and peaceful Christmas
>
>
> On 24 December 2015 at 22:17, eryk sun  wrote:
>
>> On Thu, Dec 24, 2015 at 3:29 PM, Nicky Mac  wrote:
>> >
>> > C:\Users\Nick>python -m idlelib
>> > ** IDLE can't import Tkinter.
>> > Your Python may not be configured for Tk. **
>>
>> In the 3.5 installation directory, ensure that tkinter is installed in
>> Lib/tkinter. There should be an "__init__.py" and several other files
>> such as "filedialog.py". Also ensure that the DLLs  directory has the
>> extension module "_tkinter.pyd" and dependent DLLs "tcl86t.dll" and
>> "tk86t.dll".
>>
>
>
>
> --
> Nick "Mac" McElwaine
>



-- 
Nick "Mac" McElwaine
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread Gregory Ewing

Grant Edwards wrote:

And don't get me started on those people who use those "integrated
circuits" instead of transistors, relays, and tubes...


Transistors? You don't know how good you had it.
In my day we had to poke the dopant atoms into
the silicon one at a time with the point of a
needle.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Recursively listing the contents of a package?

2015-12-25 Thread jeanbigboute
As an occasional Python user, I'd like to be able to get for myself a 
high-level overview of a package's capabilities.  I can do this after a fashion 
interactively in IPython using tab completes.  

e.g.
import numpy as np
np. ---> Big list of capabilities, highlight one item
np.array --> Nothing in the dropdown
np.random. --> ~~75 items in dropdown
np.random.test --> 3 items in dropdown

For big packages like numpy, matplotlib, etc., this is slow.  

My web searches have resulted in pointers to dir, help, inspect, getattr,  
hasattr, pydoc, and so on.  As far as I can tell, these will give you 
information if you know what you are seeking.  99% of the time, I don't know 
what I don't know.

Is there a way to determine if a method/function/correct term has items 
underneath it?

If such a thing exists, I think I could write the code to descend through a 
package's functions/methods, make a list of nodes and edges, send it to 
networkx, and create a graph of a package's capabilities.

Thanks,

JBB
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread princeudo52
#my solution is:
def manipulate_data(dic,dict_data = {'name':'prince','age':21,'sex':'male'}):
  return dict_data.keys()

def manipulate_data( alist, list_data = [2,8,16,23,14]):
  return list_data.reverse()

def manipulate_data(aset, set_data = {"bee","cee","dee"}):
  set_data = {"bee","cee","dee"}
  set_data.update("ANDELA","TIA","AFRICA")
  return dictionary_data
#please what is wrong with my code
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread princeudo52
i have gotten the answer of that problem
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread princeudo52
Create a function manipulate_data that does the following
Accepts as the first parameter a string specifying the data structure to be 
used "list", "set" or "dictionary"
Accepts as the second parameter the data to be manipulated based on the data 
structure specified e.g [1, 4, 9, 16, 25] for a list data structure
Based off the first parameter

return the reverse of a list or
add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
resulting set
return the keys of a dictionary.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread Erik

Hi,

I appreciate that you've made an effort this time to write some code, 
but have you attempted to try to _execute_ any of this? [I can see that 
the answer must be "no"]


On 25/12/15 23:09, [email protected] wrote:
> #my solution is:
> def manipulate_data(dic,dict_data = 
{'name':'prince','age':21,'sex':'male'}):

>return dict_data.keys()
>
> def manipulate_data( alist, list_data = [2,8,16,23,14]):
>return list_data.reverse()
>
> def manipulate_data(aset, set_data = {"bee","cee","dee"}):
>set_data = {"bee","cee","dee"}
>set_data.update("ANDELA","TIA","AFRICA")
>return dictionary_data
> #please what is wrong with my code

If you try to execute it (by writing a test that calls the functions), 
you will get errors. Those errors will help you to fix it. If you get to 
the point where there is an error you really can't work out for yourself 
then you can ask a specific question related to what it is you don't 
understand about the error.


It looks like you're just typing in something and sending it to the list 
first rather than the Python interpreter.


If you want to learn how to program well, then you need to learn how to 
interpret the compiler/parser error messages or exceptions you get and 
work out what is wrong for yourself. You can only do that by running 
your code.


I'll give you a hint - read the words of your assignment very carefully. 
It says "a function" (not "several functions") that "Accepts as the 
first parameter a string". Look at what it then says about the second 
parameter, based on that first parameter.


Work on it from there and when you get really stuck, post the code and 
the Python error you get and why you don't understand it (saying what 
you _think_ it means but why that doesn't help you would also be good).


E.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Recursively listing the contents of a package?

2015-12-25 Thread Terry Reedy

On 12/25/2015 6:01 PM, [email protected] wrote:

As an occasional Python user, I'd like to be able to get for myself a 
high-level overview of a package's capabilities.  I can do this after a fashion 
interactively in IPython using tab completes.

e.g.
import numpy as np
np. ---> Big list of capabilities, highlight one item
np.array --> Nothing in the dropdown
np.random. --> ~~75 items in dropdown
np.random.test --> 3 items in dropdown

For big packages like numpy, matplotlib, etc., this is slow.

My web searches have resulted in pointers to dir, help, inspect, getattr,  
hasattr, pydoc, and so on.  As far as I can tell, these will give you 
information if you know what you are seeking.  99% of the time, I don't know 
what I don't know.

Is there a way to determine if a method/function/correct term has items 
underneath it?

If such a thing exists, I think I could write the code to descend through a 
package's functions/methods, make a list of nodes and edges, send it to 
networkx, and create a graph of a package's capabilities.


IDLE has a module browser (called a Class Browser. , because that is 
what is started as), that displays a tree of module objects.  Just like 
a directory tree, nodes can be expanded or not.



--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread Cameron Simpson

On 25Dec2015 15:05, [email protected]  wrote:

i have gotten the answer of that problem


Please include some context when posting to the list; there are many 
discussions and it is best to include a little more than the subject line in 
such things. It is also polite to post your working solution for the benefit of 
those who have assisted you, or for others with a similar problem.


Then two more messages in quick succession: this list is not an instant 
messaging system. Please try to post a single message, with your question and 
also what code you have already.


Regarding your actual question, commentry below the quoted text follows...

On 25Dec2015 15:08, [email protected]  wrote:

Create a function manipulate_data that does the following
Accepts as the first parameter a string specifying the data structure to be used "list", 
"set" or "dictionary"
Accepts as the second parameter the data to be manipulated based on the data 
structure specified e.g [1, 4, 9, 16, 25] for a list data structure
Based off the first parameter

   return the reverse of a list or
   add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
resulting set
   return the keys of a dictionary.

#my solution is:
def manipulate_data(dic,dict_data = {'name':'prince','age':21,'sex':'male'}):
 return dict_data.keys()

def manipulate_data( alist, list_data = [2,8,16,23,14]):
 return list_data.reverse()

def manipulate_data(aset, set_data = {"bee","cee","dee"}):
 set_data = {"bee","cee","dee"}
 set_data.update("ANDELA","TIA","AFRICA")
 return dictionary_data
#please what is wrong with my code


The most obvious thing that is wrong it that you have 3 functions here with the 
same name. In Python that means: define the first function and bind it to the 
name "manipulate_data". Then define the second and bind it to the same name as 
the first, discarding the first function. The define the third and bind it to 
the same name again, discarding the second function.


Your task is asking for a _single_ function which behaves differently according 
to a parameter which tells it what kind of data is has been given, so you want 
a function which starts like this:


 def manipulate_data(kind, data):

and you are supposed to pass in the string "list", "set" or dictionary for the 
first parameter, and some corresponding list, set or dictionary as the second 
parameter. There should _not_ be default values for either of these.


Instead, your function should examine the "kind" parameter and decide what to 
do. So it would reasonably look like this (untested):


 def manipulate_data(kind, data):
   if kind == 'list':
 ... do stuff with data using it as a list ...
   elif kind == 'set':
 ... do stuff with data using it as a set ...
   if kind == 'dictionary':
 ... do stuff with data using it as a dictionary ...
   else:
 raise ValueError("invalid kind %r, expected 'list', 'set' or 'dictionary'" 
% (kind,))

Try starting with that and see how you go.

Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Recursively listing the contents of a package?

2015-12-25 Thread Steven D'Aprano
On Sat, 26 Dec 2015 10:01 am, [email protected] wrote:

> As an occasional Python user, I'd like to be able to get for myself a
> high-level overview of a package's capabilities.

Best way to do that is to read the package's documentation on the web.


[...]
> Is there a way to determine if a method/function/correct term has items
> underneath it?
> 
> If such a thing exists, I think I could write the code to descend through
> a package's functions/methods, make a list of nodes and edges, send it to
> networkx, and create a graph of a package's capabilities.

Let's say you want to analyse package aardvark.

First thing is to determine whether it is an actual package, or a single
module, or a "namespace package". Namespace packages are new, and I don't
know anything about them, so you're on your own with them. But for the
others:


import aardvark
if aardvark.__package__ in (None, ''):
print("regular module")
else:
print("package")


If it is a regular module, you can use dir() to get a list of names in the
module:


dir(aardvark)
=> returns ['spam', 'eggs', 'Cheese', ...]

For each name, get the actual attribute and inspect what it is:


import inspect
obj = getattr(aardvark, 'spam')
if inspect.isfunction(obj):
print("it is a function")
elif inspect.isclass(obj):
print("it is a class")
else:
print("it is a %s" % type(obj).__name__)


Or, instead of dir() and getattr(), you can use vars() and get a dict of
{name: object}.


vars(aardvark)
=> returns {'spam': , 
'eggs': ,
'Cheese': ,
...}


Do the same for classes:


vars(aardvark.Cheese)
=> returns a dict of methods etc.


You can build a tree showing how classes are related to each other by
looking at the class.__mro__, but I believe that Python already has a
class-browser:

import pyclbr

if you can work out how to get useful results out of it. (Frankly, I suspect
it is rubbish, but maybe I just don't understand what it is for or how to
use it.)


If aardvark is a package, it probably contains more than one module, but
they aren't automatically imported when the main module is imported. That
means you can't introspect them from the main module. Instead, look in the
directory where the package exists to get a list of file names:


import os
assert aardvark.__package__
directory = aardvark.__path__[0]
os.listdir(directory)
=> returns ['__init__.py', 'spam.py', 'spam.pyc', 'foo.txt', 'subdir', ...]


Or use os.walk to enter into the subdirectories as well.

That gives you a list of modules in the package:

aardvark  # corresponds to directory/__init__.py
aardvark.spam  # directory/spam.py or spam.pyc


Valid module extensions depend on the version of Python and the operating
system used, but you can expect any of the following will be valid:

.py   # Python source code
.pyc  # pre-compiled byte-code
.pyo  # pre-compiled optimized byte-code
.pyw  # only on Windows
.so   # extension module 
.dll  # extension module?


Any other file extensions may be data files and can probably be ignored.


One complication: a package may be embedded in a zip file, rather than a
directory. I don't know all the details on that -- it isn't well
documented, but I think it is as simple as taking the usual package tree
and zipping it into a .zip file.


I think this more or less gives you the details you need to know to
programmatically analyse a package.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recursively listing the contents of a package?

2015-12-25 Thread jeanbigboute
On Friday, December 25, 2015 at 4:07:43 PM UTC-8, Terry Reedy wrote:
> On 12/25/2015 6:01 PM, [email protected] wrote:
> > As an occasional Python user, I'd like to be able to get for myself a 
> > high-level overview of a package's capabilities.  I can do this after a 
> > fashion interactively in IPython using tab completes.
> ...
> IDLE has a module browser (called a Class Browser. , because that is 
> what is started as), that displays a tree of module objects.  Just like 
> a directory tree, nodes can be expanded or not.


Thanks, I will look into IDLE. I'm currently working mostly with Notebooks.

--- JBB
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recursively listing the contents of a package?

2015-12-25 Thread jeanbigboute
On Friday, December 25, 2015 at 4:14:56 PM UTC-8, Steven D'Aprano wrote:
> On Sat, 26 Dec 2015 10:01 am, [email protected] wrote:
> 
> > As an occasional Python user, I'd like to be able to get for myself a
> > high-level overview of a package's capabilities.
> 
> Best way to do that is to read the package's documentation on the web.

I certainly do so.  Some packages are very well documented, others less so.
 
> 
> [...]
> > Is there a way to determine if a method/function/correct term has items
> > underneath it?
> > 
> > If such a thing exists, I think I could write the code to descend through
> > a package's functions/methods, make a list of nodes and edges, send it to
> > networkx, and create a graph of a package's capabilities.
> 
> Let's say you want to analyse package aardvark.

[ Detailed description]

> I think this more or less gives you the details you need to know to
> programmatically analyse a package.

This is very helpful, thank you for the time in laying out the path.  I will 
try to implement what you've described.  It will be a good way for me to 
sharpen my Python skills.

--- JBB
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread princeudo52
#i have worked over 2hours only to get this: some-one help please
manipulate_data = []
item = {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45}
manipulate_data.append(item)
for i in  reversed(manipulate_data):
new = {"ANDELA", "TIA", "AFRICA"}
def list_append(manipulate_data, new):
manipulate_data.append(new)
return new
return dict.keys()
   

 print manipulate_data
#this is the instruction:
Create a function manipulate_data that does the following
Accepts as the first parameter a string specifying the data structure to be 
used "list", "set" or "dictionary"
Accepts as the second parameter the data to be manipulated based on the data 
structure specified e.g [1, 4, 9, 16, 25] for a list data structure
Based off the first parameter

return the reverse of a list or
add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
resulting set
return the keys of a dictionary.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread princeudo52
thank you God bless you moore...
-- 
https://mail.python.org/mailman/listinfo/python-list


A newbie quesiton: local variable in a nested funciton

2015-12-25 Thread jfong
As a tranditional language programmer like me, the result is really weird.

Here is the test codes in file test1.py:

def outerf():
counter = 55
def innerf():
print(counter)
#counter += 1
return innerf

myf = outerf()


the result is:

>>> import test1
>>> test1.myf()
55
>>>


that's OK. But if I un-comment the line "counter += 1", then it gives me this:

>>> import test1
>>> test1.myf()
Traceback (most recent call last):
  File "", line 1, in 
  File "D:\Work\Python34\test1.py", line 41, in innerf
print(counter)
UnboundLocalError: local variable 'counter' referenced before assignment
>>> 


In the first situation, the local variable 'counter' can be referenced 
correctly. But in the second, why a statement added after the print() statement 
can makes this variable "disappear", even the print() won't do the right thing. 
Isn't it wired? please help!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie quesiton: local variable in a nested funciton

2015-12-25 Thread Ben Finney
[email protected] writes:

> In the first situation, the local variable 'counter' can be referenced
> correctly. But in the second, why a statement added after the print()
> statement can makes this variable "disappear", even the print() won't
> do the right thing. Isn't it wired? please help!

The Python FAQ answers this, even using an example the same as yours
https://docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value>.

-- 
 \  “… a Microsoft Certified System Engineer is to information |
  `\ technology as a McDonalds Certified Food Specialist is to the |
_o__)   culinary arts.” —Michael Bacarella |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie quesiton: local variable in a nested funciton

2015-12-25 Thread Chris Angelico
On Sat, Dec 26, 2015 at 2:06 PM,   wrote:
> As a tranditional language programmer like me, the result is really weird.

By "traditional", I'm guessing you mean that you know C-like languages
(Java, ECMAScript/JavaScript, etc). In C, and in many languages
derived from or inspired by it, variable scoping is defined by
declarations that say "here begins a variable".

> Here is the test codes in file test1.py:
> 
> def outerf():
> counter = 55
> def innerf():
> print(counter)
> #counter += 1
> return innerf
>
> myf = outerf()

Pike is semantically very similar to Python, but it uses C-like
variable scoping. Here's an equivalent, which might help with
comprehension:

function outerf()
{
int counter = 55;
void innerf()
{
write("%d\n", counter);
int counter;
counter += 1;
}
return innerf;
}

Based on that, I think you can see that having a variable declaration
in the function turns things into nonsense. What you're actually
wanting here is to NOT have the "int counter;" line, such that the
name 'counter' refers to the outerf one.

In Python, assignment inside a function creates a local variable,
unless you declare otherwise. To make your example work, all you need
is one statement:

nonlocal counter

That'll cause the name 'counter' inside innerf to refer to the same
thing as it does in outerf.

Hope that helps!

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread Larry Hudson via Python-list

On 12/25/2015 06:04 PM, [email protected] wrote:

#i have worked over 2hours only to get this: some-one help please
manipulate_data = []

[snip other incorrect nonsense...]


#this is the instruction:
Create a function manipulate_data that does the following

[snip...]

Let's start with your first mistake (because the rest is wrong because of this):

READ YOUR INSTRUCTIONS!
It says "Create a function..."

Your 'solution' creates a list.
A list is NOT a function.

 -=- Larry -=-

--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread jeanbigboute
On Sunday, December 20, 2015 at 3:29:30 AM UTC-8, Chris Angelico wrote:
[... much instruction deleted]

> There is a half-and-half possibility, too; sometimes a course will
> give you a challenge, and *then* introduce you to the techniques
> necessary for solving it (after letting you have a shot at it on your
> own). I don't like that style, myself, but it does exist, so it may be
> worth skimming forward a few sections in the course to see what it
> teaches next.
> 
> But frankly, I doubt that's what's going on here.

It sounds to me like the one or or more about the course may be true: 
a) It is being offered in a country where English is not the native language
b) It may not have provided the needed background 
c) It suggests that students get help by posting to public discussion groups

I found these sites useful when I was learning about classes in Python.  
Perhaps it will help these students:

https://www.jeffknupp.com/blog/2014/06/18/improve-your-python-python-classes-and-object-oriented-programming/

http://anandology.com/python-practice-book/object_oriented_programming.html

-- 
https://mail.python.org/mailman/listinfo/python-list