How to read from serial port?

2016-04-26 Thread David Aldrich
Hi I have written a very simple program to read and print data from the serial port using pyserial: #!/usr/bin/python3 import serial ser=serial.Serial('COM1',115200) while True: out = ser.read() print('Receiving...'+out) When I run it and send data for it to read I get: C:\SVNProj\Rag

RE: Problem working with subprocess.check_call

2015-10-29 Thread David Aldrich
Thanks for all your answers. David -- https://mail.python.org/mailman/listinfo/python-list

RE: Problem working with subprocess.check_call

2015-10-29 Thread David Aldrich
> Try this > subprocess.check_call(["bash", "-O", "extglob", "-c", cmd]) That worked. Thanks very much! David -- https://mail.python.org/mailman/listinfo/python-list

Problem working with subprocess.check_call

2015-10-29 Thread David Aldrich
Hi I am working on Linux with Python 3.4. I want to do a bash diff on two text files and show just the first 20 lines of diff's output. So I tried: >>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')' >>> subprocess.check_call(cmd, shell=True) The command contained in cmd works ok from th

Automating Sphinx generated documentation

2015-09-17 Thread David Aldrich
Hi I have setup Sphinx for my Python project. We keep all our code and documentation in Subversion. So, following changes to the Python code, I need to regenerate and commit the Sphinx generated documentation. I just wondered how people manage this. I'm thinking of using Jenkins (a continuous

RE: kivy editable multicolumn list

2015-09-15 Thread David Aldrich
> Not sure if this is the place to ask about kivy ... Try the kivy users list here: https://groups.google.com/forum/#!forum/kivy-users Best regards David -- https://mail.python.org/mailman/listinfo/python-list

A basic dictionary question

2015-06-11 Thread David Aldrich
Hi I am fairly new to Python. I am writing some code that uses a dictionary to store definitions of hardware registers. Here is a small part of it: import sys register = { 'address' : 0x3001c, 'fields' : { 'FieldA' : { 'range' : (31,20), }, 'FieldB

RE: What sort of data structure to use?

2015-06-03 Thread David Aldrich
; Sent: 03 June 2015 11:59 > To: python-list@python.org > Subject: Re: What sort of data structure to use? > > David Aldrich wrote: > > > Hi > > > > I have written a Python utility that performs a certain activity on > > some predefined sets of files. Here

What sort of data structure to use?

2015-06-03 Thread David Aldrich
Hi I have written a Python utility that performs a certain activity on some predefined sets of files. Here is the outline of what I have written: # File Set A pathA = 'pathA' fileListA = ['fileA1.txt', 'fileA2.txt'] # File Set B pathB = 'pathB' fileListB = ['fileB1.txt', 'fileB2.txt', 'fileB3.

Problem running Python 2.7 on Ubuntu 10.04

2015-04-20 Thread David Aldrich
Hi I wonder if someone could help me with this problem please? On an Ubuntu 10.04 platform, I want to run the latest version of Meld, which is a Python program. Ubuntu 10.04 runs Python 2.6 as standard. Meld requires Python 2.7. So I have installed Python 2.7 under /usr/local/bin and Python

RE: Python shell: Arrow keys not working in PuTTY

2015-02-24 Thread David Aldrich
> >> BUT do *not* run `make install` as that will overwrite your system > >> Python and Bad Things will happen. Instead, run `make altinstall`. Thanks for all the warnings. We did use `make altinstall`, so all is ok. Recompiling, with readline installed, fixed the arrow keys. -- https://mail.pyt

RE: Python shell: Arrow keys not working in PuTTY

2015-02-23 Thread David Aldrich
Thanks for your replies, I will give readline a try. > PS: and you mention being on CentOS but running apt-get. I believe CentOS > and other Red-Hat based distros use "yum" instead of "apt-get" Yes, I think I need to use: yum install readline-devel Best regards David -- https://mail.python.o

Python shell: Arrow keys not working in PuTTY

2015-02-23 Thread David Aldrich
Hi I want to use the Python 3.4 interpreter interactively, via a PuTTY ssh session. Python is running on Centos 5. Currently, the arrow keys do not work: $ /usr/local/bin/python3.4 Python 3.4.2 (default, Feb 11 2015, 15:06:33) [GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux Type "help", "copy

RE: A question about a list and subprocess.check_call()

2015-02-17 Thread David Aldrich
>It's also possible to do it the other around using shlex.split. I prefer that >version because >I can easily copy/paste the command from code to the shell, it's also more >readable IMO: > cmd = """python3 -O -c "import sys; print(sys.argv[1:])" foo bar "spam egg" > """ > print(cmd) > subproc

RE: A question about a list and subprocess.check_call()

2015-02-16 Thread David Aldrich
Hi Peter Thanks very much for your reply. I have added one more question below. > The straightforward approach is to pass a list or tuple: > > def build(build_options=()): > subprocess_check_call(("make",) + build_options) > > build(("flagA=true", "flagB=true")) This looks fine - I am tryi

A question about a list and subprocess.check_call()

2015-02-16 Thread David Aldrich
Hi I wonder if someone could help me with this problem please. I am writing a Python script that builds and tests a C++ program on Linux. The build options depend on the test, so I have encapsulated the 'make' call in a Python function: def build(build_options=''): if len(build_option

RE: Beginner question - class definition error

2015-01-28 Thread David Aldrich
> Unindent the 'if' statement. Currently, it's indented inside the class > definition, so MyApp isn't defined yet. Thanks very much. That fixed it. Best regards David -- https://mail.python.org/mailman/listinfo/python-list

Beginner question - class definition error

2015-01-28 Thread David Aldrich
Hi I am just getting started with Python 3.3.3 and Kivy 1.8. I am using the Kivy development environment on Windows (open a command prompt and call kivy.bat). With this minimal code: import kivy kivy.require('1.8.0') from kivy.app import App from kivy.uix.label import Label class MyApp(App)

A question about setup.py

2014-12-04 Thread David Aldrich
Hi I'm trying to install the path.py package under Python 2.7 on Windows. I installed it using: easy_install path.py That worked but it didn't install path.py which is needed by my PTVS IDE for code completion (Intellisense). I then tried downloading path.py-7.0.zip. I unzipped it and ran: p

RE: Where is path.py?

2014-11-27 Thread David Aldrich
> The only confusing bit here is that instead of "sys" and "argv", you have > "path" and "path", the same name twice. But it's the same thing happening. Thanks very much for all replies I received for my question. It's clearer now. By the way, for Windows users, I do recommend Microsoft's PTVS (P

RE: Where is path.py?

2014-11-27 Thread David Aldrich
> The syntax: >from import > will import the name from the module , so: > from path import path > will import the name 'path' (a class) from the module 'path'. Thanks. But I don't quite understand. If I use sys: import sys args = sys.argv[1:] I don't need to use 'from'. What i

Where is path.py?

2014-11-27 Thread David Aldrich
Hi I am running Python 2.7 on Windows 8.1. Today I installed path.py using easy_install: easy_install path.py The example code that I've seen imports path.py as follows: from path import path I am fairly new to Python and have a few questions about this: 1) Why is 'from path'

Missing python27.dll on Win 7 64-bit

2011-06-17 Thread David Aldrich
Hi I am building a 32-bit C++ application using Visual C++ Express 2008 on 64-bit Windows 7. The application links to Python, so I installed 32-bit Python 2.7.2 by running python-2.7.2.msi. When I run my app, I get error: ... python27.dll is missing from your computer ... and, indeed, it is

Missing python27.dll on Win 7 64-bit

2011-06-16 Thread David Aldrich
Hi I am building a 32-bit C++ application using Visual C++ Express 2008 on 64-bit Windows 7. The application links to Python, so I installed 32-bit Python 2.7.2 by running python-2.7.2.msi. When I run my app, I get error: ... python27.dll is missing from your computer ... and, indeed, it is