Re: any author you find very good has written a book on Python?

2022-09-07 Thread TheSeeker
On Monday, September 5, 2022 at 9:23:04 PM UTC-5, Meredith Montgomery wrote:
> I never read a book on Python. I'm looking for a good one now. I just 
> searched the web for names such as Charles Petzold, but it looks like he 
> never wrote a book on Python. I also searched for Peter Seibel, but he 
> also never did. I also tried to search for Richard Heathfield. (I took 
> a look at his ``C Unleashed'' once and I liked what I saw.) This is how 
> I search for books --- I go through the authors first. Charles Petzold, 
> for instance, anything he writes is worth reading it. (Have you given 
> his Annotated Turing a shot? It's a very nice read.) 
> 
> So that's my request --- any author you find very good has written a 
> book on Python? 
> 
> It could be for in a certain specific context. For instance, I also 
> searched for Hadley Wickham in the hope that he could have written a 
> data-science-type of book using Python. I like his writing a lot, but 
> he also only seems to have written only for the R language. 
> 
> Thank you!

Mike Driscoll (https://www.blog.pythonlibrary.org/about/) as written a number 
of books for different Python experience levels, which I have found useful.

-Duane Kaufman
-- 
https://mail.python.org/mailman/listinfo/python-list


Problems with pip (Windows 10)

2018-05-03 Thread TheSeeker
Dear All,

Within the past week I have run into a problem with pip on my work machine 
(Windows 10, x64, Python 3.6) where pip errors like so:

C:\>c:\Python36\Scripts\pip install --trusted-host pypi.org --trusted-host 
pypi.python.org --trusted-host files.pythonhosted.org --no-color 
--default-timeout=100 pint
Collecting pint
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
Could not install packages due to an EnvironmentError: 
HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries 
exceeded with url: 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
 (Caused by ProtocolError('Connection aborted.', ConnectionResetError(10054, 
'An existing connection was forcibly closed by the remote host', None, 10054, 
None)))

C:\>c:\Python36\Scripts\pip --version
pip 10.0.1 from c:\python36\lib\site-packages\pip-10.0.1-py3.6.egg\pip (python 
3.6)

The only thing I have changed is I upgraded to Windows 10 version 1803. 
pip had been working before that point, but my place of work might have changed 
things as well from a network perspective.

Has anyone else seen something like this?

Sincerely,
Duane
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Validating regexp

2017-08-09 Thread TheSeeker
On Tuesday, August 8, 2017 at 11:38:34 AM UTC-5, larry@gmail.com wrote:
> Anyone have any code or know of any packages for validating a regexp?
> 
> I have an app that allows users to enter regexps for db searching.
> When a user enters an invalid one (e.g. 'A|B|' is one I just saw) it
> causes downstream issues. I'd like to flag it at entry time.

Hello,

IIRC, there is a built-in regexp builder/tester in Boa Constructor:
http://boa-constructor.sourceforge.net/

I used this a long time ago.

Duane
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to pretty mathematical formulas in Python? Similar to Mathematica formats.

2015-06-11 Thread TheSeeker
On Thursday, June 11, 2015 at 1:33:12 PM UTC-5, Sebastian M Cheung wrote:
> How to pretty mathematical formulas in Python? Similar to Mathematica formats.
> 
> Are there good packages to prettify mathematica formulas in Python?

Sympy (http://www.sympy.org/en/index.html) has some capabilities to 
pretty-print mathematics.

Duane
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Smallest/cheapest possible Python platform?

2012-05-26 Thread TheSeeker
On Saturday, May 26, 2012 10:34:19 AM UTC-5, Roy Smith wrote:
> What's the smallest/cheapest/lowest-power hardware platform I can run 
> Python on today?  I'm looking for something to use as a hardware 
> controller in a battery-powered device and want to avoid writing in C 
> for this project.
> 
> Performance requirements are minimal.  I need to monitor a few switches, 
> control a couple of LEDs and relays, and keep time over about a 30 
> minute period to 1/10th second accuracy.  Nice-to-have (but not 
> essential) would be a speech synthesizer with a vocabulary of maybe 50 
> words.
> 
You might take a look at the work being done by Dean Hall (with others) on the 
python-on-a-chip project:
http://code.google.com/p/python-on-a-chip/

Many platforms have been ported to, including Arduino Mega, RedBee EconoTAG, 
Teensy++ 2.0, Microchip PIC24/dsPIC, among others

This route may be more work than others, but considering budget may be 
attractive.


> The Rasberry Pi certainly looks attractive, but isn't quite available 
> today.  Can you run Python on an Arduino?  Things like 
> http://www.embeddedarm.com/products/board-detail.php?product=TS-7250 are 
> more than I need, and the $129 price probably busts my budget.



On Saturday, May 26, 2012 10:34:19 AM UTC-5, Roy Smith wrote:
> What's the smallest/cheapest/lowest-power hardware platform I can run 
> Python on today?  I'm looking for something to use as a hardware 
> controller in a battery-powered device and want to avoid writing in C 
> for this project.
> 
> Performance requirements are minimal.  I need to monitor a few switches, 
> control a couple of LEDs and relays, and keep time over about a 30 
> minute period to 1/10th second accuracy.  Nice-to-have (but not 
> essential) would be a speech synthesizer with a vocabulary of maybe 50 
> words.
> 
> The Rasberry Pi certainly looks attractive, but isn't quite available 
> today.  Can you run Python on an Arduino?  Things like 
> http://www.embeddedarm.com/products/board-detail.php?product=TS-7250 are 
> more than I need, and the $129 price probably busts my budget.



On Saturday, May 26, 2012 10:34:19 AM UTC-5, Roy Smith wrote:
> What's the smallest/cheapest/lowest-power hardware platform I can run 
> Python on today?  I'm looking for something to use as a hardware 
> controller in a battery-powered device and want to avoid writing in C 
> for this project.
> 
> Performance requirements are minimal.  I need to monitor a few switches, 
> control a couple of LEDs and relays, and keep time over about a 30 
> minute period to 1/10th second accuracy.  Nice-to-have (but not 
> essential) would be a speech synthesizer with a vocabulary of maybe 50 
> words.
> 
> The Rasberry Pi certainly looks attractive, but isn't quite available 
> today.  Can you run Python on an Arduino?  Things like 
> http://www.embeddedarm.com/products/board-detail.php?product=TS-7250 are 
> more than I need, and the $129 price probably busts my budget.



On Saturday, May 26, 2012 10:34:19 AM UTC-5, Roy Smith wrote:
> What's the smallest/cheapest/lowest-power hardware platform I can run 
> Python on today?  I'm looking for something to use as a hardware 
> controller in a battery-powered device and want to avoid writing in C 
> for this project.
> 
> Performance requirements are minimal.  I need to monitor a few switches, 
> control a couple of LEDs and relays, and keep time over about a 30 
> minute period to 1/10th second accuracy.  Nice-to-have (but not 
> essential) would be a speech synthesizer with a vocabulary of maybe 50 
> words.
> 
> The Rasberry Pi certainly looks attractive, but isn't quite available 
> today.  Can you run Python on an Arduino?  Things like 
> http://www.embeddedarm.com/products/board-detail.php?product=TS-7250 are 
> more than I need, and the $129 price probably busts my budget.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Porting Python to an embedded system

2012-03-04 Thread TheSeeker
On Sunday, March 4, 2012 4:58:50 AM UTC-6, Justin Drake wrote:
> I am working with an ARM Cortex M3 on which I need to port Python
> (without operating system). What would be my best approach? I just
> need the core Python and basic I/O.

The python-on-a-chip project (p14p) (http://code.google.com/p/python-on-a-chip/)
might be something worth looking into.

Thanks,
Duane
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor 0.2.2

2010-11-10 Thread TheSeeker
On Nov 10, 7:51 am, Kruptein  wrote:
> On Nov 10, 12:49 pm, TheSeeker  wrote:
>
>
>
>
>
>
>
>
>
> > On Nov 9, 10:04 am, Kruptein  wrote:
>
> > > On Nov 8, 3:01 pm, Jean-Michel Pichavant 
> > > wrote:
>
> > > > TheSeeker wrote:
> > > > > On Nov 6, 7:06 am, Kruptein  wrote:
>
> > > > >> Hey,
>
> > > > >> I released version 0.2.2 of my pythonic text-editor  Deditor.
> > > > >> It adds the use of projects, a project is a set of files which you 
> > > > >> can
> > > > >> open all at once to make development much faster and easier.
>
> > > > >> For more information visit launchpad:http://launchpad.net/deditor
>
> > > > >> I also uploaded a video to introduce you to 
> > > > >> deditor:http://www.youtube.com/watch?v=hS8xBu-39VI
> > > > >> (note: youtube is still processing the file so you might have to wait
> > > > >> a bit to see it)
>
> > > > > Hi,
> > > > > I might have missed this, but it seems deditor requires Python above
> > > > > 2.5?
>
> > > > > It would be nice to mention the requirements on the home page
> > > > > somewhere.
>
> > > > > Thanks,
> > > > > Duane
>
> > > > I already point that on the last release. You should really just
> > > > consider writing the requirements (python & wx).
>
> > > > JM
>
> > > I'm going todo that right now! I alswyas forget it :p
>
> > Hi,
>
> > In addition, on Debian Lenny, with Python 2.5:
>
> > deditor.py:429: Warning: 'with' will become a reserved keyword in
> > Python 2.6
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "deditor.py", line 429
> >     with open(cf,"wb") as configf:
> >             ^
> > SyntaxError: invalid syntax
>
> > So I don't think Python 2.5 works .
>
> > Thanks,
> > Duane
>
> that's possible, I was only able to test it with version 2.7, I'm
> going to change the dependencies then. thanks to point that out, 2.6
> should work though?
>
> and the windows wxpython version and the linux version are different
> which causes some stupid bugs... :s

Hi,

Unfortunately, the wxPython bug precludes me seeing if Python 2.6
works (in Windows, at least).

Maybe someone else can answer whether Python 2.6 works.

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


Re: Deditor 0.2.2

2010-11-10 Thread TheSeeker
On Nov 9, 10:04 am, Kruptein  wrote:
> On Nov 8, 3:01 pm, Jean-Michel Pichavant 
> wrote:
>
>
>
>
>
>
>
>
>
> > TheSeeker wrote:
> > > On Nov 6, 7:06 am, Kruptein  wrote:
>
> > >> Hey,
>
> > >> I released version 0.2.2 of my pythonic text-editor  Deditor.
> > >> It adds the use of projects, a project is a set of files which you can
> > >> open all at once to make development much faster and easier.
>
> > >> For more information visit launchpad:http://launchpad.net/deditor
>
> > >> I also uploaded a video to introduce you to 
> > >> deditor:http://www.youtube.com/watch?v=hS8xBu-39VI
> > >> (note: youtube is still processing the file so you might have to wait
> > >> a bit to see it)
>
> > > Hi,
> > > I might have missed this, but it seems deditor requires Python above
> > > 2.5?
>
> > > It would be nice to mention the requirements on the home page
> > > somewhere.
>
> > > Thanks,
> > > Duane
>
> > I already point that on the last release. You should really just
> > consider writing the requirements (python & wx).
>
> > JM
>
> I'm going todo that right now! I alswyas forget it :p

Hi,

In addition, on Debian Lenny, with Python 2.5:


deditor.py:429: Warning: 'with' will become a reserved keyword in
Python 2.6
Traceback (most recent call last):
  File "", line 1, in 
  File "deditor.py", line 429
with open(cf,"wb") as configf:
^
SyntaxError: invalid syntax

So I don't think Python 2.5 works .

Thanks,
Duane
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor 0.2.2

2010-11-09 Thread TheSeeker
On Nov 9, 10:04 am, Kruptein  wrote:
> On Nov 8, 3:01 pm, Jean-Michel Pichavant 
> wrote:
>
>
>
>
>
>
>
>
>
> > TheSeeker wrote:
> > > On Nov 6, 7:06 am, Kruptein  wrote:
>
> > >> Hey,
>
> > >> I released version 0.2.2 of my pythonic text-editor  Deditor.
> > >> It adds the use of projects, a project is a set of files which you can
> > >> open all at once to make development much faster and easier.
>
> > >> For more information visit launchpad:http://launchpad.net/deditor
>
> > >> I also uploaded a video to introduce you to 
> > >> deditor:http://www.youtube.com/watch?v=hS8xBu-39VI
> > >> (note: youtube is still processing the file so you might have to wait
> > >> a bit to see it)
>
> > > Hi,
> > > I might have missed this, but it seems deditor requires Python above
> > > 2.5?
>
> > > It would be nice to mention the requirements on the home page
> > > somewhere.
>
> > > Thanks,
> > > Duane
>
> > I already point that on the last release. You should really just
> > consider writing the requirements (python & wx).
>
> > JM
>
> I'm going todo that right now! I alswyas forget it :p

Hi,

I was wondering if there was any reason deditor will not work under
Windows? I tried to run it and got the following (Python 2.6, wxPython
2.8):

Traceback (most recent call last):
  File "C:\junk\deditor-0.2.2\deditor.py", line 910, in 
deditor = DEDITOR(None, -1, "")
  File "C:\junk\deditor-0.2.2\deditor.py", line 101, in __init__
self.initialize()
  File "C:\junk\deditor-0.2.2\deditor.py", line 342, in initialize
self.menu.SetLabel(4,self.menu.GetLabel(4).strip("_")
+"\t"+"+".join(self.get
_base_config("keys", "ctab").split(",")))
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 1136
6, in GetLabel
return _core_.MenuBar_GetLabel(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "item" failed at ..\..\src
\common\menuc
mn.cpp(1125) in wxMenuBarBase::GetLabel(): wxMenuBar::GetLabel(): no
such item


Thanks,
Duane
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor 0.2.2

2010-11-08 Thread TheSeeker
On Nov 6, 7:06 am, Kruptein  wrote:
> Hey,
>
> I released version 0.2.2 of my pythonic text-editor  Deditor.
> It adds the use of projects, a project is a set of files which you can
> open all at once to make development much faster and easier.
>
> For more information visit launchpad:http://launchpad.net/deditor
>
> I also uploaded a video to introduce you to 
> deditor:http://www.youtube.com/watch?v=hS8xBu-39VI
> (note: youtube is still processing the file so you might have to wait
> a bit to see it)

Hi,
I might have missed this, but it seems deditor requires Python above
2.5?

It would be nice to mention the requirements on the home page
somewhere.

Thanks,
Duane
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Float precision and float equality

2009-12-06 Thread TheSeeker
On Dec 6, 4:54 pm, Carl Banks  wrote:
> On Dec 6, 11:34 am, Anton81  wrote:
>
> > I do some linear algebra and whenever the prefactor of a vector turns
> > out to be zero, I want to remove it.
>
> > I'd like to keep the system comfortable. So basically I should write a
> > new class for numbers that has it's own __eq__ operator?
> > Is there an existing module for that?
>
> I highly recommend against it; among other things it invalidates the
> transitive property of equality:
>
> "If a == b and b == c, then a == c."
>
> It will also make the number non-hashable, and have several other
> negative consequences.    What numbers are close enought to be condidered 
> "equal"
> depends on the calculations.
>
> (I remember once struggling in a homework assignment over seemingly
> large discrepancies in a calculation I was doing, until i realized
> that the actual numbers were on the scale of 10**11, and the
> difference was around 10**1, so it really didn't matter.)
>
> Carl Banks

Maybe it's the gin, but
"Plus, it's not something that's never foolproof.'

+1 QOTW

Cheers,
TheSeeker
-- 
http://mail.python.org/mailman/listinfo/python-list


Examples of Python driven Microsoft UI Automation wanted

2009-07-09 Thread TheSeeker
Hi,

I am embarking on teaching myself Microsoft UI Automation using Python
as the scripting language.

I have asked some questions in the IronPython users group, but have
yet to get a response, so I thought I would broaden the audience by
asking here.

Specifically, I have a WinForms application I will be wanting to
automate. Does anyone have some Python examples of driving Microsoft
UI Automation they could share with me to get me started? The
structure of the UI automation classes etc. seem quite convoluted, and
I am having difficulty getting my brain wrapped around it.

Alternatives to Microsoft's UI Automation are welcome too, but I have
tried using winguiauto and watsup (along with AutoIt), and there seems
to be severe limitations when using these tools with WinForm
applications.

Thanks in advance,
Duane
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best 3d graphics kit for CAD program???

2009-02-09 Thread TheSeeker
On Feb 9, 2:08 pm, r  wrote:
> On Feb 9, 1:33 pm, Stef Mientki  wrote:
>
> > Maya ?
> > Blender ?
> > I forgot:
> > pySoy
> > Intensity
>
> Thanks Stef,
> I actually got OpenGL to install(finally) and now i am thinking ?
> maybe? i should just go with OpenGL using the wxglcanvas. I have been
> also "messing" around with Bender but i think i want a stand alone
> application here. I don't know anything about Maya however?
>
> Thanks for the info and feel free to offer more.

Hi,

Have you considered OpenCascade:
http://www.opencascade.org/

Along with its python bindings, it might be a good alternative:
http://www.pythonocc.org/

Just a thought,
Duane
--
http://mail.python.org/mailman/listinfo/python-list


Re: win32gui

2009-01-09 Thread TheSeeker
On Jan 9, 7:34 am, Gandalf  wrote:
> Hi, everyone
> I'm searching the win32gui lib to find a way to get the text under the
> user cursor.
> so far I managed to find only the controller ID which under the cursor
> this way
>
> cursorID = win32gui.WindowFromPoint(win32gui.GetCursorPos())
>
> their is function called GetWindowText I tried to use but it doesn't
> work in most of the time
>
> someone know a way to do this?
>
> thank you!

One app that might be of help with your endeavors is called AutoIt
(http://www.autoitscript.com/autoit3/)

This suite of apps has a nice window browser, which shows most (if mot
all) information available from a Windows window. Sometimes not all
text in a window is available, depending on the window. It even comes
with a COM component, so it can be scripted from Python...

No affiliation, other than a contented user.

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


Re: Adding Microsoft objects in Boa Constuctor Palette

2008-08-07 Thread TheSeeker
On Aug 6, 5:59 pm, Sid K <[EMAIL PROTECTED]> wrote:
> This is what I wanted to do:
>
> Add Microsoft Active objects like Excel sheets and Word files to the
> Palette in Boa Constructor. There is a User tab in the GUI builder
> menu, but I'm not sure how to use/enable it.
>
> 1. Does anyone know how to do this?
> 2. Is anyone aware of any work that is currently going on to support
> adding Microsoft objects in Boa.
> 3. Does any other Python GUI creator/editor exist out there that can
> do this?
> 4. How would one add an excel sheet to a wx.Panel in general w/ or w/o
> Boa?
>
> Looking forward to replies...
>
> -SK

Hi,

You might get a response by trying the wxPython list: wxPython-
[EMAIL PROTECTED] or the Boa list: boa-constructor-
[EMAIL PROTECTED]

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


Re: how to create GUI dynamically

2008-07-21 Thread TheSeeker
On Jul 21, 8:19 am, [EMAIL PROTECTED] wrote:
> Hi;
>
> i m working on a project where i need  run time creation of GUI.
>
> i have some no. of entities for which i want checkboxes in front of
> them which can be checked/ unchecked by user.
>
> But the problem is that the number and name of entities is not fixed
> and it depends on the file which is used as input.
>
> So is there any way to tackle this problem.
>
> By the way ; i use Boa constructor (zope editor) for GUI now.
>
> regards
> pawan pundir

Hi,

Boa constructor can be used for the main part of the application, but
you'll probably need to 'roll your own' builder of the dynamic portion
(which isn't very hard).

A wonderful list for these kinds of questions is:
https://lists.sourceforge.net/lists/listinfo/boa-constructor-users

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


Re: Accessing a URL file Remotely

2007-11-29 Thread TheSeeker
On Nov 29, 3:13 pm, mcl <[EMAIL PROTECTED]> wrote:
> I have been given a url of CSV file (http://hostname/dir/file.csv),
> which when I put the full URL in a web browser shows the contents of
> the file.
>
> I want to be able to use the CSV module to read that file, which I
> have successfully used with a local CSV file.
>
> Any examples anywhere would be appreciated.
>
> My basic research suggests URLLIB, but I can not find a suitable
> example.
>
> I do not understand what additional information, needs to be given to
> the remote site in order for it to expose the contents of the file as
> though I was reading it locally.
>
> Do I need to copy it to my local machine or can I read it directly
> from the remote site.
>
> As you can probably tell, I have never done anything like this, so any
> help will be gratefully received.
>
> Thanks
>
> Richard

-untested--

import urllib, csv

fp_page = urllib.urlopen("http://URL_of_file";)
reader = csv.reader(fp_page)
for row in reader:
print row

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


Re: Set operations on object attributes question

2007-10-23 Thread TheSeeker
Hi,

Thanks for the response! (See below for more discussion)

On Oct 23, 10:39 am, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> [Duane]
>
> > LoTuples1 = [(1,1,0),(1,2,1),(1,3,3)]
> > Set1=set(LoTuples1)
> > LoTuples2 = [(2,1,3),(2,2,4),(2,3,2)]
> > Set2=set(LoTuples2)
>
> > What I would like to be able to do is:
>
> > Set3 = Set1union(Set2)
> > Set3.intersection(Set2, )
>
> > to return:
> > set([(2,1,3), (1,3,3)])
>
> > How can one do this operation?
>
> Conceptually, there is more than one operation going on. First,
> finding the attributes shared in both sets:
>ca = set(t[2] for t in LoTuples1) & set(t[2] for t in LoTuples2)
> which gives:
>set([3])

In my use case, I already know object[2] is the key I wish to use, so
I could do this without the first step.
I am thinking of object[n] as the 'key' I wish to operate on, and the
other items in the tuple are useful attributes
I'll need in the end.

>
> Second, find any tuple which has that attribute (including multiple
> results for the same attribute):
>set(t for t in (LoTuples1 + LoTuples2) if t[2] in ca)
> which returns:
>set([(2, 1, 3), (1, 3, 3)])
>
> Wanting multiple results for the same attribute value (i.e. both
> (2,1,3) and (1,3,3) have 3 in the second position) is why multiple
> steps are needed; otherwise, the behavior of intersection() is to
> return a single representative of the equivalence class.
>
This second operation is really much like what I cam up with before I
started looking into exploiting the power of sets
(this same operation can be done strictly with lists, right?)

Since what I _really_ wanted from this was the intersection of the
objects (based on attribute 2), I was looking for a set-based
solution,
kinda like a decorate -  - undecorate pattern. Perhaps
the problem does not fall into that category.

Thanks for your help,
Duane

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


Set operations on object attributes question

2007-10-23 Thread TheSeeker
Hi,

I have run into something I would like to do, but am not sure how to
code it up. I would like to perform 'set-like' operations (union,
intersection, etc) on a set of objects, but have the set operations
based on an attribute of the object, rather than the whole object.

For instance, say I have (pseudo-code):

LoTuples1 = [(1,1,0),(1,2,1),(1,3,3)]
Set1=set(LoTuples1)
LoTuples2 = [(2,1,3),(2,2,4),(2,3,2)]
Set2=set(LoTuples2)

What I would like to be able to do is:

Set3 = Set1union(Set2)
Set3.intersection(Set2, )

to return:
set([(2,1,3), (1,3,3)])

How can one do this operation?

Thanks,
Duane

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


Re: Python Wrapper for C# Com Object

2006-12-29 Thread TheSeeker
Hi,

A question. Why in your C-version are your doing:

X_com_ptr->SetID(10);

and in the Python version:

interface.SetID()  ?

I don't know anything of your COM object, but does SetID require a
parameter?

Duane


[EMAIL PROTECTED] wrote:
> [EMAIL PROTECTED] skrev:
>
> > [EMAIL PROTECTED] skrev:
> >
> > > Hi,
> > >
> > > I wish to write a Python wrapper for my C# COM object but am unsure
> > > where to start. I have a dll and a tlb file, and I can use this object
> > > in C via the following code -
> > >
> > > // ConsolApp.cpp : Defines the entry point for the console application.
> > > //
> > > #include "stdafx.h"
> > > #include "windows.h"
> > > #include "stdio.h"
> > > #import "C:\Documents and Settings\X\Mina dokument\Visual Studio
> > > 2005\Projects\X_COMObject\X_COMObject\bin\Debug\X_COMObject.tlb"
> > > using namespace X_COMObject;
> > >
> > > int _tmain(int argc, _TCHAR* argv[])
> > > {
> > >   CoInitialize(NULL);
> > >
> > >   X_COMObject::XCOM_InterfacePtr p(__uuidof(X_COMObject::XCOM_Class));
> > >   XCOM_Interface *X_com_ptr ;
> > >   X_com_ptr = p ;
> > >   X_com_ptr->SetID(10);
> > >   int x = X_com_ptr->GetID();
> > >   printf("%d",x);
> > >   getchar();
> > >
> > >   return 0;
> > > }
> > >
> > > Can anyone offer me some tips as to how to do this in Python?
> > >
> > > Thanks very much for your help,
> > >
> > > Barry.
> >
> > This is what I've done so far, but I know I'm not doing this correctly.
> > Can anyone help me out?
> >
> > #import pythoncom
> > #pythoncom.CoInitialize()
> >
> > from comtypes.client import GetModule, CreateObject
> >
> > module = GetModule("C:\\Documents and Settings\\X\\Mina
> > dokument\\Visual Studio
> > 2005\\Projects\\X_COMObject\\X_COMObject\\bin\\Debug\\X_COMObject.tlb")
> >
> > dir(module)
> >
> > interface = module.XCOM_Interface()
> >
> > dir(interface)
> >
> > interface.SetID()
> >
> > #pythoncom.CoUnitialize()
> >
> >
> > Traceback (most recent call last):
> >   File "C:/Python25/test.py", line 14, in 
> > interface.SetID()
> > TypeError: Expected a COM this pointer as first argument
> 
> Can anyone help me with this?
> 
> Thanks,
> 
> Barry.

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


Re: intercepting keypresses, mouse movements, joystick movements.

2006-10-09 Thread TheSeeker

bryan rasmussen wrote:
> Hi,
>
> I've been looking at autohotkey to do some different usability hacks
> for windows http://www.autohotkey.com/
> one of the benefits of this language is it allows one to catch
> keyboard usage, joystick usage, and mouse usage inputs very easily at
> a global level or at application levels by watching applications for
> events within the applications.
>
> I was wondering if there were any python libraries that provided
> similar functionality before I went ahead with the project though.
>
> Cheers,
> Bryan Rasmussen

You might take a look at pyHook:
http://sourceforge.net/project/showfiles.php?group_id=65529&package_id=92632

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


Re: A cross platform systray icon

2006-09-11 Thread TheSeeker

Nick Craig-Wood wrote:
> Does anyone have some hints / tips / experience with making a cross
> platform systray icon?  It should work on Windows, Gnome and KDE at
> minimum.
>
> I've seen the win32all code which is very similar to the C code I've
> written before for Windows.  It would be a small irritation to have to
> integrate its event loop with whichever GUI framework I'm using for
> the rest of it though.
> 
You might do a search for TaskBarIcon in the wxPython toolkit.

Duane

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


Re: Watching serial port activity.

2006-05-30 Thread TheSeeker
Hi,

Have you looked into slsnif
(http://www.dakotacom.net/~ymg/software.html)

Duane

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


Re: Problem with wrapping GNU Units

2006-04-04 Thread TheSeeker
Hi,

Perhaps in another revision, as utilizing Unum, while cool, would be
quite a change to my code.

Could it be that the readline library used by GNU Units can detect the
difference between a 'real' tty and a pipe? If so, how can I trick it?

Thanks,
Duane

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


Problem with wrapping GNU Units

2006-04-03 Thread TheSeeker
Hi,
As part of a larger project, I am trying to use the GNU Units program
to provide unit conversions between quantities.

My first iteration, which worked OK, was to simply use units as a
command-line app, and capture its output. The larger program however,
calls the conversion routine many times, and the overhead of starting
units for every call made things too slow.

I then re-formulated my use of units to open it using popen2, and do
conversions with it through stdin and stdout (Windows XP). This too
works OK, at least up to the point I want to stop the program, which is
where I am having problems.

If I simply try to exit my app, python.exe hangs, and units.exe keeps
running, according to the Task Manager. If I try sending Control-D, as
the on-line help suggests, the program hangs too.

Does anyone have any ideas on how to control this app?

Here is some of my code:

# Functions for driving GNU Units (if installed)
GNU_Units_stdin = None
GNU_Units_stdout = None

def SetupGNU_Units():
import time, os, sys
# Initialization routine to set up pipe to running GNU Units
process
# Start GNU Units as a child and feed and read through stdin and
stdout
global GNU_Units_stdin, GNU_Units_stdout
CurrentDir = os.getcwd()
# Hack to find correct directory
if not 'units.exe' in os.listdir(os.getcwd()):
UnitsDir = os.path.join(CurrentDir, 'GNU_Units')
else:
UnitsDir = CurrentDir
print "CurrentDir ", CurrentDir
os.chdir(UnitsDir)
(GNU_Units_stdin, GNU_Units_stdout) = os.popen2('units.exe -f
.\units.dat')
time.sleep(0.5)
print 'First initialization read: ', GNU_Units_stdout.readline()
time.sleep(0.5)
print 'Second initialization read: ', GNU_Units_stdout.readline()
time.sleep(0.5)
print 'Units initialization complete.'

def ShutdownGNU_Units():
global GNU_Units_stdin, GNU_Units_stdout
# From the GNU Units help, to quit the program from the interactive
prompt
#(which is how we are using it), one needs to feed it Control-D
GNU_Units_stdin.write(chr(4))
# ResponseLine1 = GNU_Units_stdout.readline()
GNU_Units_stdin = None
GNU_Units_stdout = None

def ConvertUnits(Value, FromUnitStr, ToUnitStr):
import os, sys
global GNU_Units_stdin, GNU_Units_stdout
# Sanity check on the numerical portion of the input
try:
dummy=float(Value)
except ValueError:
raise ConvertUnitsError('ConvertUnits: non-numeric input')
return 0
if not GNU_Units_stdin:
# Initialize pipes to GNU Units
SetupGNU_Units()
FromStr = str(Value)
FromStr += ' ' + FromUnitStr + '\r'
ToStr = ToUnitStr + '\r'
GNU_Units_stdin.write(FromStr)
GNU_Units_stdin.write(ToStr)
ResponseLine1 = GNU_Units_stdout.readline()
ResponseLine2 = GNU_Units_stdout.readline()
ReadBackLine = GNU_Units_stdout.readline()
ReadBackLine2 = GNU_Units_stdout.readline()
if 'conformability error' == ReadBackLine.strip():
raise ConvertUnitsError('ConvertUnits: conformability error')
AnswerElement = ReadBackLine.strip()
return float(AnswerElement.split()[1])

Thanks in advance,
Duane

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


Re: wxPython Notebook crash when pressing alt key

2005-09-21 Thread TheSeeker
Hi,

Works for me:

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
wxPython 2.6.1.0

Duane

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