Re: Pyserial again



Richie Hindle wrote:
A piece of that code has been chopped off by someone's newsreader - it's the
body of a method, and ser.readline() is the last line of that method.

I'm pretty sure that's true. Technically, however, it's still a guess, though at this point one I'm sure we're all comfortable making.

That's why I asked about code *after* that last line. He replied there was no code before, but I think we can be generous in interpreting that (through the language barrier) as "no code after".

Unfortunately, at this point we're getting into application design issues unless and until Luca can learn enough Python and other programming stuff to understand why "ser" is "going out of scope" because it's a "local variable" and is then being "garbage collected".

(Luca, if you're reading, you really either have to just do exactly what Grant tells you :-), or learn about these issues enough to understand. If you don't know about object construction and destruction, memory allocation and garbage collection, the concept of "scope" and the difference between things like local variables, global variables, and attributes, we're going to continue to have an exceptionally difficult and frustrating time helping you. Serial ports aren't trivial, and combining them with a GUI program written by a rookie is a pretty big order. You can learn enough to figure this out, but it will be lots of work and a challenge. If you're up to it, please go read that "how to ask smart questions" page thoroughly if you haven't already, realizing that we're not trying to be rude by asking you to read it, and pay attention when someone asks you to try out different things, such as posting a small program that reproduces the problem, or post all the code rather than just snippets. Good luck.)

-Peter

.



Relevant Pages

  • Re: To Hungarian or not to Hungarian
    ... prefix that denotes whether the item is a parameter, ... The type, but not the scope. ... I personally do not use prefixes for local variables. ... "Death is one of the few things that can be done as easily lying ...
    (borland.public.delphi.non-technical)
  • Re: VB 6.0 Desktop - Global Variables
    ... variables are not "slower" than local variables. ... wide scope", then this kind of variables only can live in a module. ... standard code module. ... without needing a reference to an object. ...
    (microsoft.public.vb.general.discussion)
  • Re: very strange effect with anonymous delegates (.net 2.0)
    ... > the view of the sourcecode since "PropertyInfo prop" is a readonly ... > they should at least throw a compiler error when a foreach iterator is ... at the outermost scope of the local variables that are used within the anon ... It obviously can't do it within the scope as the outermost one ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Garbage collection in VBA
    ... For local variables, Yes. ... > Set myRange = Something ... > Or is the memory allocated in the function returned to the heap when the ... > function goes out of scope? ...
    (microsoft.public.excel.programming)
  • Re: Local variables - quick question
    ... You can't use a variable which isn't in scope within ... You could declare an instance variable i, ... and after that I would like to use int i - new declaration. ... language is defined to prevent local variables from hiding each other. ...
    (microsoft.public.dotnet.languages.csharp)