Printing the name of a variable

2010-09-09 Thread Stephen Boulet
Does an arbitrary variable carry an attribute describing the text in
its name? I'm looking for something along the lines of:

x = 10
print x.name
>>> 'x'

Perhaps the x.__getattribute__ method? Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Photo layout

2005-06-26 Thread Stephen Boulet
Is there a python solution that someone could recommend for the following:

I'd like to take a directory of photos and create a pdf document with
four photos sized to fit on each (landscape) page.

Thanks.

Stephen
-- 
http://mail.python.org/mailman/listinfo/python-list


Help configuring visual studio to compile python extensions

2015-01-09 Thread stephen . boulet
I've installed Microsoft Visual Studio 10.0. Here are the steps I've been 
taking.

My python version is Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:16:31) 
[MSC v.1600 64 bit (AMD64)] on win32.

(Sorry for the long output.)

>cd "c:\Program Files (x86)\Microsoft Visual Studio 10.0"\vc
>vcvarsall.bat
>
>SET VS90COMNTOOLS=%VS100COMNTOOLS%
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>pip install scandir
Collecting scandir
  Using cached scandir-0.9.tar.gz
Installing collected packages: scandir
  Running setup.py install for scandir
building '_scandir' extension
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c 
/nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\Python34\include -Ic:\Python34\include 
/Tc_scandir.c /Fobuild\temp.win-amd64-3.4\Release
\_scandir.obj
_scandir.c
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL 
/nologo /INCREMENTAL:NO /LIBPATH:c:\Python34\libs 
/LIBPATH:c:\Python34\PCbuild\amd64 /EXPORT:PyInit__scandir build\temp.win
-amd64-3.4\Release\_scandir.obj /OUT:build\lib.win-amd64-3.4\_scandir.pyd 
/IMPLIB:build\temp.win-amd64-3.4\Release\_scandir.lib 
/MANIFESTFILE:build\temp.win-amd64-3.4\Release\_scandir.pyd.manifest
   Creating library build\temp.win-amd64-3.4\Release\_scandir.lib and 
object build\temp.win-amd64-3.4\Release\_scandir.exp
_scandir.obj : error LNK2001: unresolved external symbol _PyObject_SelfIter
_scandir.obj : error LNK2001: unresolved external symbol 
_PyObject_GenericGetAttr
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyErr_WarnEx referenced in function _win32_warn_bytes_api
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyExc_DeprecationWarning referenced in function _win32_warn_bytes_api
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyErr_Occurred referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyBytes_FromObject referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol __imp__PyErr_Clear 
referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyExc_ValueError referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyUnicode_AsUnicodeAndSize referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyUnicode_FromObject referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyErr_Format referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyExc_TypeError referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol 
__imp___Py_NoneStruct referenced in function _path_converter
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyLong_FromUnsignedLong referenced in function _find_data_to_statresult
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyFloat_FromDouble referenced in function _find_data_to_statresult
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyLong_FromUnsignedLongLong referenced in function 
_find_data_to_statresult
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyLong_FromLong referenced in function _find_data_to_statresult
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyStructSequence_New referenced in function _find_data_to_statresult
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyEval_RestoreThread referenced in function __fi_close
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyEval_SaveThread referenced in function __fi_close
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__Py_BuildValue referenced in function __fi_next
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyErr_SetFromWindowsErr referenced in function __fi_next
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyErr_NoMemory referenced in function __fi_next
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyErr_SetNone referenced in function __fi_next
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyExc_StopIteration referenced in function __fi_next
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyObject_Free referenced in function _fi_dealloc
_scandir.obj : error LNK2019: unresolved external symbol 
__imp___PyObject_New referenced in function __iterfile
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyArg_ParseTupleAndKeywords referenced in function _scandir_helper
_scandir.obj : error LNK2019: unresolved external symbol 
__imp__PyStructSequence_InitType referenced in function _PyInit__scandir
_scandir.obj : error LNK2019: unresolved ext

Re: Help configuring visual studio to compile python extensions

2015-01-09 Thread stephen . boulet
This page helped me sort everything out: 
http://www.falatic.com/index.php/120/a-guide-to-building-python-2-x-and-3-x-extensions-for-windows.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-09 Thread stephen . boulet
On Wednesday, December 31, 2014 at 4:24:50 PM UTC-6, André Roberge wrote:
> EasyGUI_Qt version 0.9 has been released.  This is the first announcement 
> about EasyGUI_Qt on this list.
> 
> Like the original EasyGUI (which used Tkinter), 
> EasyGUI_Qt seeks to provide simple GUI widgets
> that can be called in a procedural program. 
> 
> EasyGUI_Qt is NOT event-driven: all GUI interactions are invoked by simple 
> function calls.
> 
> The archetype is get_string(message)
> which pops a box whose purpose is exactly the same as Python's input(prompt),
> that is, present the user with a question/prompt, have the user enter an
> answer, and return the provided answer as a string.  Thus
> easygui_qt.get_string() can be used as a drop-in replacement for
> input().
> 
> Similarly, instead of using a print() function to display a message,
> show_message() is used which pops a message window.
> 
> EasyGUI_Qt requires PyQt4 and is really targeted for Python 3.3+ - although 
> it can work (possibly with some unicode problems ...) using Python 2.7.
> 
> More information can be found at 
> http://easygui-qt.readthedocs.org/en/latest/index.html
> 
> Feedback is most welcome, including reporting bugs to 
> https://github.com/aroberge/easygui_qt/issues
> 
> Happy 2015 everyone,
> 
> André Roberge

Very nice, thanks.

One issue is the format returned for the calendar selection. For today, the 
string returned is "Fri Jan 9 2015". My script needs to convert the date to a 
datetime.date, and having the month returned as a string instead of an integer 
makes this harder.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help configuring visual studio to compile python extensions

2015-01-09 Thread stephen . boulet
On Friday, January 9, 2015 at 8:58:59 AM UTC-6, stephen...@gmail.com wrote:
> I've installed Microsoft Visual Studio 10.0. Here are the steps I've been 
> taking.
> 
> My python version is Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 
> 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32.
> 
> (Sorry for the long output.)
> 
> >cd "c:\Program Files (x86)\Microsoft Visual Studio 10.0"\vc
> >vcvarsall.bat
> >
> >SET VS90COMNTOOLS=%VS100COMNTOOLS%
> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>pip install scandir
> Collecting scandir
>   Using cached scandir-0.9.tar.gz
> Installing collected packages: scandir
>   Running setup.py install for scandir
> building '_scandir' extension
> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c 
> /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\Python34\include -Ic:\Python34\include 
> /Tc_scandir.c /Fobuild\temp.win-amd64-3.4\Release
> \_scandir.obj
> _scandir.c
> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL 
> /nologo /INCREMENTAL:NO /LIBPATH:c:\Python34\libs 
> /LIBPATH:c:\Python34\PCbuild\amd64 /EXPORT:PyInit__scandir build\temp.win
> -amd64-3.4\Release\_scandir.obj /OUT:build\lib.win-amd64-3.4\_scandir.pyd 
> /IMPLIB:build\temp.win-amd64-3.4\Release\_scandir.lib 
> /MANIFESTFILE:build\temp.win-amd64-3.4\Release\_scandir.pyd.manifest
>Creating library build\temp.win-amd64-3.4\Release\_scandir.lib and 
> object build\temp.win-amd64-3.4\Release\_scandir.exp
> _scandir.obj : error LNK2001: unresolved external symbol 
> _PyObject_SelfIter
> _scandir.obj : error LNK2001: unresolved external symbol 
> _PyObject_GenericGetAttr
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyErr_WarnEx referenced in function _win32_warn_bytes_api
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyExc_DeprecationWarning referenced in function _win32_warn_bytes_api
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyErr_Occurred referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyBytes_FromObject referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyErr_Clear referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyExc_ValueError referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyUnicode_AsUnicodeAndSize referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyUnicode_FromObject referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyErr_Format referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyExc_TypeError referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp___Py_NoneStruct referenced in function _path_converter
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyLong_FromUnsignedLong referenced in function _find_data_to_statresult
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyFloat_FromDouble referenced in function _find_data_to_statresult
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyLong_FromUnsignedLongLong referenced in function 
> _find_data_to_statresult
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyLong_FromLong referenced in function _find_data_to_statresult
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyStructSequence_New referenced in function _find_data_to_statresult
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyEval_RestoreThread referenced in function __fi_close
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyEval_SaveThread referenced in function __fi_close
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__Py_BuildValue referenced in function __fi_next
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyErr_SetFromWindowsErr referenced in function __fi_next
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyErr_NoMemory referenced in function __fi_next
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyErr_SetNone referenced in function __fi_next
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyExc_StopIteration referenced in function __fi_next
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp__PyObject_Free referenced in function _fi_dealloc
> _scandir.obj : error LNK2019: unresolved external symbol 
> __imp___PyObject_New referenced in function __iterfile
> _scandir.obj : error LNK2019: unresolved external symbol 
> __im

Re: [ANN] EasyGUI_Qt version 0.9

2015-01-13 Thread stephen . boulet
I found a solution that I'm happy with.

from datetime import datetime
from easygui_qt import *

datestring = get_date()
mydate = datetime.strptime(datestring, '%b %d %Y')

On Saturday, January 10, 2015 at 1:02:30 AM UTC, André Roberge wrote:
> On Friday, 9 January 2015 19:09:15 UTC-4, stephen...@gmail.com  wrote:
> > On Wednesday, December 31, 2014 at 4:24:50 PM UTC-6, André Roberge wrote:
> > > EasyGUI_Qt version 0.9 has been released.  This is the first announcement 
> > > about EasyGUI_Qt on this list.
> > > 
> > > Like the original EasyGUI (which used Tkinter), 
> > > EasyGUI_Qt seeks to provide simple GUI widgets
> > > that can be called in a procedural program. 
> > > 
> > > EasyGUI_Qt is NOT event-driven: all GUI interactions are invoked by 
> > > simple function calls.
> > > 
> > > The archetype is get_string(message)
> > > which pops a box whose purpose is exactly the same as Python's 
> > > input(prompt),
> > > that is, present the user with a question/prompt, have the user enter an
> > > answer, and return the provided answer as a string.  Thus
> > > easygui_qt.get_string() can be used as a drop-in replacement for
> > > input().
> > > 
> > > Similarly, instead of using a print() function to display a message,
> > > show_message() is used which pops a message window.
> > > 
> > > EasyGUI_Qt requires PyQt4 and is really targeted for Python 3.3+ - 
> > > although it can work (possibly with some unicode problems ...) using 
> > > Python 2.7.
> > > 
> > > More information can be found at 
> > > http://easygui-qt.readthedocs.org/en/latest/index.html
> > > 
> > > Feedback is most welcome, including reporting bugs to 
> > > https://github.com/aroberge/easygui_qt/issues
> > > 
> > > Happy 2015 everyone,
> > > 
> > > André Roberge
> > 
> > Very nice, thanks.
> > 
> > One issue is the format returned for the calendar selection. For today, the 
> > string returned is "Fri Jan 9 2015". My script needs to convert the date to 
> > a datetime.date, and having the month returned as a string instead of an 
> > integer makes this harder.
> 
> Would today's date be represented as the string "09.01.2015" useful to you? 
> (I found out how to do this.)  If so, I could perhaps add an argument like 
> numeric_format = True.
> 
> André
-- 
https://mail.python.org/mailman/listinfo/python-list


Help understanding list operatoins inside functions in python 3

2015-01-13 Thread stephen . boulet
I'm a bit confused why in the second case x is not [1,2,3]:

x = []

def y():
x.append(1)

def z():
x = [1,2,3]

y()
print(x)
z()
print(x)

Output:
[1]
[1]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-14 Thread stephen . boulet
On Tuesday, January 13, 2015 at 8:30:13 PM UTC, André Roberge wrote:
> On Tuesday, 13 January 2015 08:23:30 UTC-4, stephen...@gmail.com  wrote:
> > I found a solution that I'm happy with.
> > 
> > from datetime import datetime
> > from easygui_qt import *
> > 
> > datestring = get_date()
> > mydate = datetime.strptime(datestring, '%b %d %Y')
> 
> I'm thinking of having the new version return a datetime object automatically.
> 
> André

That's probably a cleaner solution.

> > On Saturday, January 10, 2015 at 1:02:30 AM UTC, André Roberge wrote:
> > > On Friday, 9 January 2015 19:09:15 UTC-4, stephen...@gmail.com  wrote:
> > > > On Wednesday, December 31, 2014 at 4:24:50 PM UTC-6, André Roberge 
> > > > wrote:
> > > > > EasyGUI_Qt version 0.9 has been released.  This is the first 
> > > > > announcement about EasyGUI_Qt on this list.
> > > > > 
> > > > > Like the original EasyGUI (which used Tkinter), 
> > > > > EasyGUI_Qt seeks to provide simple GUI widgets
> > > > > that can be called in a procedural program. 
> > > > > 
> > > > > EasyGUI_Qt is NOT event-driven: all GUI interactions are invoked by 
> > > > > simple function calls.
> > > > > 
> > > > > The archetype is get_string(message)
> > > > > which pops a box whose purpose is exactly the same as Python's 
> > > > > input(prompt),
> > > > > that is, present the user with a question/prompt, have the user enter 
> > > > > an
> > > > > answer, and return the provided answer as a string.  Thus
> > > > > easygui_qt.get_string() can be used as a drop-in replacement for
> > > > > input().
> > > > > 
> > > > > Similarly, instead of using a print() function to display a message,
> > > > > show_message() is used which pops a message window.
> > > > > 
> > > > > EasyGUI_Qt requires PyQt4 and is really targeted for Python 3.3+ - 
> > > > > although it can work (possibly with some unicode problems ...) using 
> > > > > Python 2.7.
> > > > > 
> > > > > More information can be found at 
> > > > > http://easygui-qt.readthedocs.org/en/latest/index.html
> > > > > 
> > > > > Feedback is most welcome, including reporting bugs to 
> > > > > https://github.com/aroberge/easygui_qt/issues
> > > > > 
> > > > > Happy 2015 everyone,
> > > > > 
> > > > > André Roberge
> > > > 
> > > > Very nice, thanks.
> > > > 
> > > > One issue is the format returned for the calendar selection. For today, 
> > > > the string returned is "Fri Jan 9 2015". My script needs to convert the 
> > > > date to a datetime.date, and having the month returned as a string 
> > > > instead of an integer makes this harder.
> > > 
> > > Would today's date be represented as the string "09.01.2015" useful to 
> > > you? (I found out how to do this.)  If so, I could perhaps add an 
> > > argument like numeric_format = True.
> > > 
> > > André
-- 
https://mail.python.org/mailman/listinfo/python-list


Open file in default app and exit in Windows

2015-01-28 Thread stephen . boulet
I am using the following to open a file in its default application in Windows 7:

from subprocess import call

filename = 'my file.csv'
call('"%s"' % filename, shell=True)

This still leaves a python process hanging around until the launched app is 
closed. Any idea how to get around?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Open file in default app and exit in Windows

2015-01-28 Thread stephen . boulet
On Wednesday, January 28, 2015 at 10:07:25 AM UTC-6, Tim Golden wrote:
> On 28/01/2015 15:50, stephen...@gmail.com wrote wrote:
> > I am using the following to open a file in its default application in
> > Windows 7:
> > 
> > from subprocess import call
> > 
> > filename = 'my file.csv' call('"%s"' % filename, shell=True)
> > 
> > This still leaves a python process hanging around until the launched
> > app is closed. Any idea how to get around?
> > 
> 
> This is somewhat clumsy. The built-in way is:
> 
> import os
> os.startfile("my file.csv")
> 
> TJG

Thank you. That is what I was looking for.
-- 
https://mail.python.org/mailman/listinfo/python-list


Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread stephen . boulet
I have an excel file. When I select cells, copy from excel, and then use 
win32clipboard to get the contents of the clipboard, I have a 131071 character 
string.

When I save the file as a text file, and use the python 3.3 open command to 
read its contents, I only have 80684 characters.

Excel (and  other programs too) appends a bunch of b'\x00' (or similar) 
characters.

Is there a pythonic way to strip these out?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread stephen . boulet
Hi Steven. Here is my code:

import win32clipboard, win32con

def getclipboard():
win32clipboard.OpenClipboard()
s = win32clipboard.GetClipboardData(win32con.CF_TEXT)
win32clipboard.CloseClipboard()
return s

I use this helper function to grab the text on the clipboard and do useful 
things with it.

Sorry about the description; I have stuff to learn about strings and python 3.3.

To get the string length, I just do len(s). There were 10 columns and 700+ rows 
of data, so len(s) returned 80684 from an excel spreadsheet saved as a text 
file.

>From the clipboard contents copied from the spreadsheet, the characters 
>s[:80684] were the visible cell contents, and s[80684:] all started with 
>"b'\x0" and lack any useful info for what I'm trying to accomplish.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread stephen . boulet
On Thursday, September 12, 2013 10:43:46 PM UTC-5, Neil Hodgson wrote:
> Stephen Boulet:
> 
> 
> 
> >  From the clipboard contents copied from the spreadsheet, the characters 
> > s[:80684] were the visible cell contents, and s[80684:] all started with 
> > "b'\x0" and lack any useful info for what I'm trying to accomplish.
> 
> 
> 
> Looks like Excel is rounding up its clipboard allocation to the next 
> 
> 64K. There used to be good reasons for trying to leave some extra room 
> 
> on the clipboard and avoid reallocating the block but I thought that was 
> 
> over a long time ago.
> 
> 
> 
> To strip NULs off the end of the string use s.rstrip('\0')

Hm, that gives me a "Type str doesn't support the buffer API" message.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread stephen . boulet
On Friday, September 13, 2013 9:31:45 AM UTC-5, stephen...@gmail.com wrote:
> On Thursday, September 12, 2013 10:43:46 PM UTC-5, Neil Hodgson wrote:
> 
> > Stephen Boulet:
> 
> > 
> 
> > 
> 
> > 
> 
> > >  From the clipboard contents copied from the spreadsheet, the characters 
> > > s[:80684] were the visible cell contents, and s[80684:] all started with 
> > > "b'\x0" and lack any useful info for what I'm trying to accomplish.
> 
> > 
> 
> > 
> 
> > 
> 
> > Looks like Excel is rounding up its clipboard allocation to the next 
> 
> > 
> 
> > 64K. There used to be good reasons for trying to leave some extra room 
> 
> > 
> 
> > on the clipboard and avoid reallocating the block but I thought that was 
> 
> > 
> 
> > over a long time ago.
> 
> > 
> 
> > 
> 
> > 
> 
> > To strip NULs off the end of the string use s.rstrip('\0')
> 
> 
> 
> Hm, that gives me a "Type str doesn't support the buffer API" message.

Aha, I need to use str(s, encoding='utf8').rstrip('\0').
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-17 Thread stephen . boulet
On Thursday, September 12, 2013 6:01:20 PM UTC-5, stephen...@gmail.com wrote:
> I have an excel file. When I select cells, copy from excel, and then use 
> win32clipboard to get the contents of the clipboard, I have a 131071 
> character string.
> 
> 
> 
> When I save the file as a text file, and use the python 3.3 open command to 
> read its contents, I only have 80684 characters.
> 
> 
> 
> Excel (and  other programs too) appends a bunch of b'\x00' (or similar) 
> characters.
> 
> 
> 
> Is there a pythonic way to strip these out?

Odd behavior from excel. It seems as though the clipboard contents will vary 
according to the clipboard size. For example, in my 13 column row I select 2023 
rows, copy to the clipboard, and 

def getclipboard():
win32clipboard.OpenClipboard()
s = win32clipboard.GetClipboardData(win32con.CF_TEXT)
win32clipboard.CloseClipboard()
return s

s = getclipboard()

len(s) gives me 16298.

If I select one additional row, len(s) balloons to 32767.

In the first case, s[-10:] is b'0.032573\r\n'.

In the second case, s[-10:] is b'\x008\x008\x000\x005\x00\t'

Does anyone know what is going on with that?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread stephen . boulet
Thanks to everyone for their help. Using everyone's suggestions, this seems to 
work:

import win32clipboard, win32con

def getclipboard():
win32clipboard.OpenClipboard()
s = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)
win32clipboard.CloseClipboard()
if '\0' in s:
s = s[:s.index('\0')]
return s
-- 
https://mail.python.org/mailman/listinfo/python-list


input() on python 2.7.5 vs 3.3.2

2013-12-12 Thread stephen . boulet
Can someone explain? Thanks.

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> x = input()
Hello there
>>> print(x)
Hello there

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> x = input()
Hello there
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1
Hello there
  ^
SyntaxError: unexpected EOF while parsing
-- 
https://mail.python.org/mailman/listinfo/python-list