Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Question regarding local and global variables
Post: RE: Question regarding local and global variables

Ok thanks all for your explanations. I have a lot more to learn obviously. It just stood out to me why one type of object (integer, list) is referred to differently inside and outside a function.
donmerch General Coding Help 12 5,119 Apr-12-2020, 03:09 PM
    Thread: Question regarding local and global variables
Post: RE: Question regarding local and global variables

So if I do this I see the inside and outside id of a & b are different even though I declared a & b global inside. a = 20 b = 30 c = [1, 2, 3] print(id(a),a, id(b),b, id(c),c) def demo(): ...
donmerch General Coding Help 12 5,119 Apr-12-2020, 02:44 PM
    Thread: Question regarding local and global variables
Post: RE: Question regarding local and global variables

(Apr-12-2020, 02:24 PM)TomToad Wrote: Before you can subscript a variable, the variable must already exist. So when you do c[0] = 5, it first will search the local scope for c, and not finding it, ...
donmerch General Coding Help 12 5,119 Apr-12-2020, 02:33 PM
    Thread: Question regarding local and global variables
Post: Question regarding local and global variables

I'm relatively new to learning Python. I've been reading "Mastering Python". In chapter 2 on Variables it provides an example similar to this: a = 20 b = 30 c = [1, 2, 3] def demo(): a = 21 b...
donmerch General Coding Help 12 5,119 Apr-12-2020, 02:02 PM
    Thread: How do I convert this string back to a list of integers?
Post: RE: How do I convert this string back to a list of...

Ok you've convinced me... I'll try json. Thanks all.
donmerch General Coding Help 6 3,735 Apr-05-2020, 06:43 PM
    Thread: How do I convert this string back to a list of integers?
Post: RE: How do I convert this string back to a list of...

(Apr-05-2020, 05:36 PM)buran Wrote: please, show real code, don't explain what you have or what you expect. As of now it's not clear neither what you have, or what you want. From what i get - the wa...
donmerch General Coding Help 6 3,735 Apr-05-2020, 05:48 PM
    Thread: How do I convert this string back to a list of integers?
Post: How do I convert this string back to a list of int...

Let's say I have this list where val1, etc are all integers such as val1 = 1, val2 = 15, val3 = 240 values = [val1, val2, val3] so now values = [1, 15, 240] And I store it to a file named values.txt...
donmerch General Coding Help 6 3,735 Apr-05-2020, 03:53 PM
    Thread: SyntaxError: unexpected EOF while parsing
Post: SyntaxError: unexpected EOF while parsing

I'm using Python 3.6.6 and I don't understand what I need to do to correct this code error. Here's my code: # First import the library import pyrealsense2 as rs try: # Create a context object. T...
donmerch General Coding Help 2 7,060 Oct-14-2018, 11:52 PM
    Thread: Need help with SQLite data input
Post: RE: Need help with SQLite data input

Perhaps I need to ask the question in a different way- why will it let me store a row (record) using a single digit or letter in first column but not multiple digits or letters? It will store multiple...
donmerch General Coding Help 4 5,773 Feb-06-2018, 10:09 AM
    Thread: Need help with SQLite data input
Post: RE: Need help with SQLite data input

Actually I did store something in the database. If you look at the error message you can see that I entered 1 then my name and it was stored. I then ran it again and entered 1 and it printed my messag...
donmerch General Coding Help 4 5,773 Feb-06-2018, 03:06 AM
    Thread: Need help with SQLite data input
Post: Need help with SQLite data input

My code checks if an account number exists and if so just prints a statement saying so, else if not then it asks for a name and then stores the new account number and name. I have defined the data ty...
donmerch General Coding Help 4 5,773 Feb-06-2018, 02:26 AM
    Thread: Problem with serial data. How do I ignor incorrect data?
Post: RE: Problem with serial data. How do I ignor incor...

Okay here's what I've gotten to work thus far. I'd still like to know how I might ignore the "None" return and still get 5 full readings. Here's what I came up with : from serial import Serial import ...
donmerch General Coding Help 1 2,936 Jul-11-2017, 01:55 AM
    Thread: Problem with serial data. How do I ignor incorrect data?
Post: Problem with serial data. How do I ignor incorrect...

I'm reading data via USB serial @ 57600 baud. I'm trying to take 5 readings and then get the average. Occasionally I get an error and I don't know how to get around it. Here's my code: from serial i...
donmerch General Coding Help 1 2,936 Jul-10-2017, 11:39 PM
    Thread: Help with code to access USB port
Post: Help with code to access USB port

So I have 2 different Maxbotix USB sensors connected to a USB hub. They enumerate as /dev/ttyUSB0 and /dev/ttyUSB1. I'm trying to cycle through both sensors using this code: #!/usr/bin/python3 # sampl...
donmerch General Coding Help 2 8,567 Jun-27-2017, 02:48 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020