Re: [Tutor] sockets and networking

2013-02-11 Thread eryksun
On Mon, Feb 11, 2013 at 11:27 PM, richard kappler wrote: > I've read the socket docs and admit I find them quite confusing. Can someone > point me to a/some good beginner tutorials on sockets/networking for me to > look at? Try Doug Hellmann's Python Module of the Week: http://www.doughellmann.c

[Tutor] sockets and networking

2013-02-11 Thread richard kappler
I want to be able to communicate between a raspberry pi and a laptop running ubuntu, transferring text from the pi to the laptop. Specifically the Pi would be running poscketsphinx speech rec and would send the generated text through the crossover between the two ethernet ports to a python program

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread Alan Gauld
On 12/02/13 01:34, Steven D'Aprano wrote: If the class keeps a list of all instances, then the class method could walk the list and operate on each instance in turn. (But why would you do that?) Because its how classes work in some languages (like smalltalk). The class object represents all in

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread Steven D'Aprano
On 12/02/13 10:16, Alan Gauld wrote: On 11/02/13 22:49, neubyr wrote: is right approach to implement 'list_by_author' function as a class method is typically used as an alternative constructor. Not at all that is only one use case for class methods. A class method is *any* method that operate

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread neubyr
On Mon, Feb 11, 2013 at 6:58 PM, Steven D'Aprano wrote: > On 11/02/13 16:14, neubyr wrote: > >> I have a text file with each line in following format: >> >> Book Name, Author Name, Genre, Publication Date >> >> I would like to perform following queries on this file: >> * Get all books written by

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread Steven D'Aprano
On 11/02/13 16:14, neubyr wrote: I have a text file with each line in following format: Book Name, Author Name, Genre, Publication Date I would like to perform following queries on this file: * Get all books written by an author * Remove all books of an author * Get information about a bo

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread neubyr
On Mon, Feb 11, 2013 at 5:16 PM, Alan Gauld wrote: > On 11/02/13 22:49, neubyr wrote: > > is right approach to implement 'list_by_author' function as a class >> method is typically used as an alternative constructor. >> > > Not at all that is only one use case for class methods. > A class method

Re: [Tutor] calling and returning functions.

2013-02-11 Thread Alan Gauld
On 11/02/13 20:07, Pravya Reddy wrote: def conversion(inch,cm): """returns the value in cm and in.""" return (2.54 * float(inches)) return (float(cm) / 2.54) return exits the function so the second return statement never gets executed. def GetInt(prompt): """Returns a n

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread Alan Gauld
On 11/02/13 22:49, neubyr wrote: is right approach to implement 'list_by_author' function as a class method is typically used as an alternative constructor. Not at all that is only one use case for class methods. A class method is *any* method that operates on the whole class of objects - i.e

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread neubyr
On Mon, Feb 11, 2013 at 12:36 PM, Dave Angel wrote: > On 02/11/2013 01:19 PM, Alan Gauld wrote: > >> On 11/02/13 05:14, neubyr wrote: >> >>> >>> >>> >>> >> * How do I associate/relate Book and Author classes so that it will help >>> me in getting information like 'get list of books written by a

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread neubyr
Thank you for your inputs Dave. That's really helpful. Reply in-line below: On Sun, Feb 10, 2013 at 11:56 PM, Dave Angel wrote: > On 02/11/2013 12:14 AM, neubyr wrote: > >> I have a text file with each line in following format: >> >> Book Name, Author Name, Genre, Publication Date >> >> I would

Re: [Tutor] Additional help

2013-02-11 Thread Ahmet Can KEPENEK
Hello, I used regular expression module of python. I checked binary and denary numbers. If input is invalid i ask again. I edited your code. Code is below follow as . import re def show_menu(): print("===") print("1-binary to denary") print("2-denary to binary") print("3-e

Re: [Tutor] calling and returning functions.

2013-02-11 Thread Dave Angel
On 02/11/2013 03:07 PM, Pravya Reddy wrote: Can you please complete the code. #!/usr/bin/env python """ One function receives a value in inches and returns the equivalent value in cms like cm = 2.54 * in.The other function receives a value in cms and returns the equivalent value in inches like i

[Tutor] calling and returning functions.

2013-02-11 Thread Pravya Reddy
Can you please complete the code. #!/usr/bin/env python """ One function receives a value in inches and returns the equivalent value in cms like cm = 2.54 * in.The other function receives a value in cms and returns the equivalent value in inches like in = cm / 2.54.""" def conversion(inch,cm):

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread Dave Angel
On 02/11/2013 01:19 PM, Alan Gauld wrote: On 11/02/13 05:14, neubyr wrote: * How do I associate/relate Book and Author classes so that it will help me in getting information like 'get list of books written by an author'? Data attribute? I woudn't have a separate Author class but, if you

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread Alan Gauld
On 11/02/13 05:14, neubyr wrote: I have a text file with each line in following format: Book Name, Author Name, Genre, Publication Date I would like to perform following queries on this file: * Get all books written by an author * Remove all books of an author * Get information about a b

[Tutor] temp conversion problem was: Re: (no subject)

2013-02-11 Thread Alan Gauld
Please always provide a meaningful subject line, it helps us find related posts more easily in future and will stimulate more focused responses than a no subject message (which implies we are dealing with a newbie with no net experience and therefore requiring a lot of time/effort to help)...

Re: [Tutor] Code to open a website

2013-02-11 Thread Alan Gauld
On 11/02/13 01:14, Steven D'Aprano wrote: exit() and quit() (as added by the site.py module) are for interactive use. aha! They're mostly there for the benefit of newbies. Experienced developers (at least in the Unix/Linux world) usually know to exit interactive terminal apps with Ctrl-D. I

Re: [Tutor] How to log process handles and GDI objects in python

2013-02-11 Thread Alan Gauld
On 11/02/13 04:25, Pai, Yogesh M wrote: Hi Alan, Here are the additional details: Python version: 2.7.3 OS version: Windows 7 -64 bit I have an application that has a automation layer built in python. During every subsequent runs, I want to log the process threads and GDI objects > ( the one y

Re: [Tutor] help with inch to cms conversion .

2013-02-11 Thread Danny Yoo
On Mon, Feb 11, 2013 at 9:06 AM, Pravya Reddy wrote: > Can you please help me with the code. > > #!/usr/bin/env python > """ > inchtocm.py > > """ > > def Inchtocm(inches): > """Returns 2.54 * inches""" > return (2.54 * float(inches_number1)) I don't know if your curriculum talks about w

Re: [Tutor] help with inch to cms conversion .

2013-02-11 Thread Dave Angel
On 02/11/2013 11:06 AM, Pravya Reddy wrote: Can you please help me with the code. #!/usr/bin/env python """ inchtocm.py """ First, remove that try/except until the code is free of obvious bugs. It's masking where the error actually occurs. Alternatively, include a variable there, and print

Re: [Tutor] Which pip for Ubuntu 12.04

2013-02-11 Thread Jim Byrnes
On 02/11/2013 09:31 AM, Jim Byrnes wrote: On 02/10/2013 01:10 PM, Joel Goldstick wrote: On Sun, Feb 10, 2013 at 1:53 PM, Timo wrote: Op 10-02-13 17:01, Jim Byrnes schreef: On 02/09/2013 05:46 AM, Albert-Jan Roskam wrote: - Original Message - From: Jim Byrnes To: tutor@python

Re: [Tutor] (no subject)

2013-02-11 Thread Joel Goldstick
First, pick a good subject header. By having caught excep ValueError in your mainline code you lose the opportunity to find out where it came from. If you comment it out you will see that the function inchtocm(inches) uses inches_number1 in its code. So you are ignoring the inches that you passe

[Tutor] help with inch to cms conversion .

2013-02-11 Thread Pravya Reddy
Can you please help me with the code. #!/usr/bin/env python """ inchtocm.py """ def Inchtocm(inches): """Returns 2.54 * inches""" return (2.54 * float(inches_number1)) inches = None while True: try: inches_number1 = input(input("How many inches you want to convert: "))

[Tutor] (no subject)

2013-02-11 Thread Pravya Reddy
Can you please help me with the code. #!/usr/bin/env python """ inchtocm.py """ def Inchtocm(inches): """Returns 2.54 * inches""" return (2.54 * float(inches_number1)) inches = None while True: try: inches_number1 = input(input("How many inches you want to convert: "))

[Tutor] (no subject)

2013-02-11 Thread Pravya Reddy
Can You Plaese help me with the code. #converts temperature to fahrenheit or celsius def print_options(): print ("Options:") print (" 'p' print options") print (" 'c' convert from celsius") print (" 'f' convert from fahrenheit") print (" 'q' quit the program") def celsius_to_

Re: [Tutor] Which pip for Ubuntu 12.04

2013-02-11 Thread Jim Byrnes
On 02/10/2013 01:10 PM, Joel Goldstick wrote: On Sun, Feb 10, 2013 at 1:53 PM, Timo wrote: Op 10-02-13 17:01, Jim Byrnes schreef: On 02/09/2013 05:46 AM, Albert-Jan Roskam wrote: - Original Message - From: Jim Byrnes To: tutor@python.org Cc: Sent: Saturday, February 9, 2013

Re: [Tutor] Truncated urlopen

2013-02-11 Thread Joel Goldstick
On Mon, Feb 11, 2013 at 10:00 AM, Válas Péter wrote: > 2013/2/11 Dave Angel > >> I'd suggest splitting that expression into two separate statements, one >> that does the read, and the other that decodes. Then you can print the >> byte-string, and see if it also is truncated, or whether that hap

Re: [Tutor] Truncated urlopen

2013-02-11 Thread Válas Péter
2013/2/11 Dave Angel > I'd suggest splitting that expression into two separate statements, one > that does the read, and the other that decodes. Then you can print the > byte-string, and see if it also is truncated, or whether that happened > during the decoding. > > Also, if you use print( repr

Re: [Tutor] Truncated urlopen

2013-02-11 Thread Dave Angel
On 02/11/2013 05:58 AM, Válas Péter wrote: Hi tutors, aboard again after a long time. Welcome back. http://..._export.php?mehet=1 is a link which exports me some data in CSV correctly when I click on it in my browser. (It contains personal data, that's why I dotted.) I want to process it dir

Re: [Tutor] How to log process handles and GDI objects in python

2013-02-11 Thread eryksun
On Sun, Feb 10, 2013 at 11:25 PM, Pai, Yogesh M wrote: > I want to log the process threads and GDI objects (the one you see in > the Windows task manager) in my python code- The idea is to use this > data to generate a plot to check if the application leaks memory in a > long run. Although I can u

[Tutor] Truncated urlopen

2013-02-11 Thread Válas Péter
Hi tutors, aboard again after a long time. http://..._export.php?mehet=1 is a link which exports me some data in CSV correctly when I click on it in my browser. (It contains personal data, that's why I dotted.) I want to process it directly from Python, excluding the browser phase. The following