Re: [Tutor] method, type?

2016-01-07 Thread Steven D'Aprano
On Fri, Jan 08, 2016 at 12:02:44PM +1100, Cameron Simpson wrote: > On 08Jan2016 00:18, ALAN GAULD wrote: > >My only point of difference here, I think, is the definition > >of a constructor. I consider a constructor to be the creator > >of object instances, which makes the only default Python > >co

Re: [Tutor] Syntax error

2016-01-07 Thread Cameron Simpson
On 07Jan2016 13:15, Sarah Rasco wrote: Alan - I realized I did that right after I sent this email. However, I can't run it in the windows or python prompts. Here is my document: [image: Inline image 1] When I try to run it in the windows prompt I get: [image: Inline image 2] [...] Hi Sarah,

Re: [Tutor] Syntax error

2016-01-07 Thread Sarah Rasco
Alan - I realized I did that right after I sent this email. However, I can't run it in the windows or python prompts. Here is my document: [image: Inline image 1] When I try to run it in the windows prompt I get: [image: Inline image 2] Or in the python prompt: [image: Inline image 3] And the fi

Re: [Tutor] method, type?

2016-01-07 Thread Cameron Simpson
On 08Jan2016 00:18, ALAN GAULD wrote: My only point of difference here, I think, is the definition of a constructor. I consider a constructor to be the creator of object instances, which makes the only default Python constructor the __new__() since the __init__() is only an initializer. Me too

Re: [Tutor] method, type?

2016-01-07 Thread Cameron Simpson
On 08Jan2016 10:19, Steven D'Aprano wrote: [...] "factory" methods (typically called '.from_*') can be: Maybe I should have said "often" instead of "typically", if I said "typically". I think they read well that way and there are several stdlib functions named this way as a precedent. I'm

Re: [Tutor] basic threading question

2016-01-07 Thread Alan Gauld
On 08/01/16 00:23, Alan Gauld wrote: > Just another thought. Have you looked at asyncore yet? It seems > ideally suited to your usecase and avoids all the threading > problems (or more accurately lets Python deal with it invisibly) OK, I just saw another message in another thread that says you ar

Re: [Tutor] basic threading question

2016-01-07 Thread Alan Gauld
On 07/01/16 19:26, richard kappler wrote: > The brief version, I am reading and parsing a data stream through a socket, > several actually. Each new connection spawns a thread that reads and > parses. Should the client close, I want the thread to terminate. Just another thought. Have you looked

Re: [Tutor] method, type?

2016-01-07 Thread Alan Gauld
On 07/01/16 23:19, Steven D'Aprano wrote: > "Factory methods" just means a method which you, the creator or author, > thinks of as a factory. What's a factory? A function or method which > takes a bunch of arguments and creates something useful. In classic OOP a factory method is more specific

Re: [Tutor] method, type?

2016-01-07 Thread Steven D'Aprano
On Thu, Jan 07, 2016 at 11:42:18AM -0800, Alex Kleider wrote: > Thank you to all who contributed to this thread. > It has helped me immensely and I enjoyed some of the spirited > discussion. > > Some of my notes follow (in case corrections are in order:-) > > my_notes = """ > > @staticm

Re: [Tutor] basic threading question

2016-01-07 Thread Cameron Simpson
On 07Jan2016 14:26, richard kappler wrote: See previous posts on 'looping generator' for details about the code and project. The brief version, I am reading and parsing a data stream through a socket, several actually. Each new connection spawns a thread that reads and parses. Should the client

Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
On 07Jan2016 17:22, richard kappler wrote: On Thu, Jan 7, 2016 at 5:07 PM, Cameron Simpson wrote: Just a few followup remarks: This is all Python 3, where bytes and strings are cleanly separated. You've got a binary stream with binary delimiters, so we're reading binary data and returning t

Re: [Tutor] reading an input stream

2016-01-07 Thread richard kappler
On Thu, Jan 7, 2016 at 5:07 PM, Cameron Simpson wrote: > > Just a few followup remarks: > > This is all Python 3, where bytes and strings are cleanly separated. > You've got a binary stream with binary delimiters, so we're reading binary > data and returning the binary XML in between. We separate

Re: [Tutor] basic threading question

2016-01-07 Thread Alan Gauld
On 07/01/16 19:26, richard kappler wrote: > several actually. Each new connection spawns a thread that reads and > parses. First question. Do you need to read AND parse in the thread. Could you not read the raw data and send that to a parsing thread? Usually reading the data won't be a problem (

Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
On 08Jan2016 08:52, Cameron Simpson wrote: [...] Instead, gather the data progressively and emit XML chunks. You've got a TCP stream - the TCPServer class will do an accept and handle you an _unbuffered_ binary stream file from which you can just .read(), ignoring any arbitrary "packet" sizes.

Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
On 07Jan2016 12:14, richard kappler wrote: On Thu, Jan 7, 2016 at 12:07 PM, James Chapman wrote: From an architectural POV I'd have a few listener threads that upon receipt would spawn (or take from a pool is a better approach) a worker thread to process the received data. As would I. That

Re: [Tutor] method, type?

2016-01-07 Thread Alex Kleider
Thank you to all who contributed to this thread. It has helped me immensely and I enjoyed some of the spirited discussion. Some of my notes follow (in case corrections are in order:-) my_notes = """ @staticmethod def s_method(param_but_no_self_or_cls): # An ordinary functi

Re: [Tutor] looping generator

2016-01-07 Thread Alan Gauld
On 07/01/16 18:31, richard kappler wrote: > Alan, have you ever actually been guilty of 'missing something'? :-) Actually quite often. Usually when its late at night(tired) or early morning(no coffee) or I'm rushing to go someplace. But it happens quite a lot, Usually Steven or Peter or someone w

Re: [Tutor] looping generator

2016-01-07 Thread Martin A. Brown
Hi there Richard, >I have a stream of incoming xml data. I can receive the data, parse >the data, etc, so long as I don't get fancy and I have a miniscule >delay in between each message. If I get rid of the time delay, >which I need to, I need the script to continuously process the >incoming

Re: [Tutor] Syntax error

2016-01-07 Thread richard kappler
Hi Sarah! instead of 'python hello.py', try >>>import hello.py using python hello.py works from the Linux command line (presumably Windows as well) and it starts python then runs the hello.py script. From within the python interpreter, you import the file and it executes. HTH, Richard On Thu,

Re: [Tutor] Syntax error

2016-01-07 Thread Alan Gauld
On 07/01/16 13:40, Sarah Rasco wrote: > In IDLE, I typed print ("Hello, world!") and hit enter, and it returned the > message. I saved the file as hello.py in C:\python. Then, when I tried to > run it in IDLE, I got a syntax error and it highlighted the '5' in the > prompt 'python 3.5.1'. I suspe

[Tutor] Syntax error

2016-01-07 Thread Sarah Rasco
Hello, I'm new to programming and was told that Python would be a good language to start with. I downloaded version 3.5.1, and I have Windows 10. In IDLE, I typed print ("Hello, world!") and hit enter, and it returned the message. I saved the file as hello.py in C:\python. Then, when I tried to r

Re: [Tutor] reading an input stream

2016-01-07 Thread James Chapman
Hi Richard There are a number of considerations you need to take into account here. Raw sockets is almost never the right solution, while a basic socket to socket connection is easy enough to program, handling failure and concurrency can very quickly make the solution a lot more complex than it n

Re: [Tutor] help with existing code

2016-01-07 Thread Peter Otten
Brianna McGee wrote: > I am a new to programming and have started out with modifying existing > code to suit my purposes in my Developmental Psychology lab. The script > worked fine previous to my fiddling with it, but now that I am trying to > modify the x and y locations based upon a text file w

[Tutor] wx.CallLater doesn't work in subprocess

2016-01-07 Thread Katsuyoshi Takahashi
Hello everyone, I'm trying make a the Simple Game program with GUI using wxPython. I used multiprocessing library in Python version 3.4. But, wx.CallLater Class doesn't work in subprocess. classLOCthink(object): def__init__(self): super(LOCthink,self).__init__() defengine_thi