meta language to define forms

2014-03-27 Thread Sells, Fred
I'm trying to use python classes and members to define complex data entry forms 
as a meta language

The idea is to use a nice clean syntax like Python to define form content, then 
render it as HTML but only as a review tool for users,  The actual rendering 
would go into a database to let a vendor's tool generate the form in a totally 
non-standard syntax that's really clunky.

I don't have a lot of time or management support to do something elegant like 
XML and then parse it, I'm thinking more like

Class  FyFormNumber001(GeneralForm):
Section1 = Section(title="Enter Patient Vital Signs")
Question1 = NumberQuestion(title="Enter pulse rate", 
format="%d3")
Question2 = Dropdown(title="Enter current status")
Question2.choices = [ (1, "Alive and Kicking"), (2, 
"Comatose"), (3, "Dead"), ...]


Of course this is not quite legal python and I have a lot of flexibility in my 
"meta" language.  The basic model is that a single file would define a form 
which would have one or more sections,  each section would have one or more 
questions of various types (i.e. checkbox, radio button, text, etc).  Sections 
cannot be nested.

I don't have to have a perfect layout, just close enough to get the end users 
to focus on what they are asking for before we generate the actual code.  I 
tried an HTML WYSIWYG editor but that was too slow and I lost information that 
I need to retain when the actual form is generated.

The biggest problem (to me) is that I have to maintain the order; i.e. the 
order in which they are coded should be the order in which they are displayed.

I'm looking to do about 200 forms, so it is reasonable to invest some time up 
front to make the process work; meanwhile management wants results yesterday, 
so I have a trade-off to make.

Is there anything out there that would be close or do you have any suggestions.

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


RE: noobie needs help with ctypes

2013-12-10 Thread Sells, Fred
Mucho apologies for rich text, I think I picked that up when replying to a post 
without properly checking.  Thanks for heads up.

Fred.

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


RE: noobie needs help with ctypes

2013-12-09 Thread Sells, Fred
My management requires that we stick with the version that comes with CentOs 
which is 2.6.   I know that it’s possible to have multiple versions co-resident 
with or without virtualenv, but policy is policy ☹



From: Python-list 
[mailto:python-list-bounces+frsells=adventistcare@python.org] On Behalf Of 
Joel Goldstick
Sent: Monday, December 09, 2013 3:22 PM
To: Terry Reedy
Cc: python-list@python.org
Subject: Re: noobie needs help with ctypes

On Mon, Dec 9, 2013 at 3:15 PM, Terry Reedy 
mailto:tjre...@udel.edu>> wrote:
On 12/9/2013 2:24 PM, Sells, Fred wrote:
I'm using python 2.6 on Linux/CentOs 6.x

I would use the latest 2.7 (or 3.3) for a new project if at all possible.

I seem to recall that Centos needs 2.6 as default python for its own purposes, 
so you need to install another version without messing with 2.6.  VirtualEnv 
might help.

I'm getting ctypes to work, but getting stuck on the use of  .argtypes.  Can 
someone point out what I'm doing.  This is my first use of ctypes and it looks 
like I'm getting different definitions in stackoverflow that may correspond to 
different version of python.

In particular, I am sure that there have been bugfixes for ctypes.


--
Terry Jan Reedy

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



--
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


noobie needs help with ctypes

2013-12-09 Thread Sells, Fred
I'm using python 2.6 on Linux/CentOs 6.x

I'm getting ctypes to work, but getting stuck on the use of  .argtypes.  Can 
someone point out what I'm doing.  This is my first use of ctypes and it looks 
like I'm getting different definitions in stackoverflow that may correspond to 
different version of python.

Here is my code.  Without the restype/argtypes it works, but I cannot figure 
out how to define argtypes to match the data.  
mylibrary = ctypes.CDLL(LIBRARY_PATH)
mdsconvert = mylibrary.RugVersionConverter
mdsconvert.restype = ctypes.c_int
mdsconvert.argtypes = [ charptr, #flat buffer of mds 3.0 data
ctypes.c_buffer, #computed flat buffer of mds 2.0 data
ctypes.c_buffer  #version set to "1.00.4" in c++, never 
used
]

def convertMds2to3(mds30buffer):
mds20 = ctypes.create_string_buffer('\000'*3000)
t = ctypes.create_string_buffer('\000'*30)
success = mdsconvert(mds30buffer,  ctypes.byref(mds20), ctypes.byref(t) )
print 'convert %s to %s success=%s version=%s' % (len(mds30buffer), 
len(mds20.value), success, t.value)
return mds20.value

--- C++ code looks like this 
---
extern "C"
   int RugVersionConverter( char * sInputRecord, char * MDS2_Rec, char * 
Version );

where sInputRecord is input and MDS2_Rec and Version are output.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Shebang line on Windows?

2013-02-25 Thread Sells, Fred
When moving from windows to unix you need to run "dos2unix"   on any programs 
that use shebang (at least with python 2.6)   that is installed on some 
platforms but must be installed on others like CentOs but it is in their 
repository.

-Original Message-
From: Python-list 
[mailto:python-list-bounces+frsells=adventistcare@python.org] On Behalf Of 
James Harris
Sent: Friday, February 22, 2013 5:53 PM
To: python-list@python.org
Subject: Re: Shebang line on Windows?

On Feb 22, 6:40 pm, Zachary Ware 
wrote:

> On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry  
> wrote:

> > I use FreeBSD or Linux, but my son is learning Python and is using 
> > Windows.
>
> > My question is this: Would it be good practice for him to put 
> > #!/usr/bin/ env python at the top of his scripts, so that if made 
> > executable on *nix they will be OK? As I understand it this will 
> > have no effect on Windows itself.
>
> Adding the shebang line on Windows would be excellent practice.

A word of warning unless this has since been resolved: Whenever I have tried 
adding the shebang line on Windows and running it on Unix the latter has 
complained about the carriage return at the end of the line. This means that 
Unix does not work when invoked as follows.
(And, yes, the file has had chmod +x applied.)

  ./program.py

It is, of course, OK when run as

  python program.py

but that removes some of the benefit of the shebang line.

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

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


derived class name in python 2.6/2.7

2013-01-30 Thread Sells, Fred
This is simple, but I just cannot find it after quite a bit of searching

I have this basic design

class  A:
def __init__(self):
print 'I am an instance of ', self.__class__.name

class B(A):
pass


X = B
I would like this to print "I am an instance of B"  but I keep getting A.  Can 
someone help me out here.

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


RE: New in Python , Need a Mentor

2013-01-02 Thread Sells, Fred
The need for a "python-aware" editor is the commonly held opinion, although the 
debate about which editor is endless.  I use Eclipse + PyDev only because I 
found it first and like it.

The only suggestion I would offer is to separate the business logic completely 
from the HTML request/response handler.  It makes it much easier to debug.  

Other than that, ditto to everyone else's response.

Fred.



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


RE: Object Models - decoupling data access - good examples ?

2012-08-07 Thread Sells, Fred
Given that "the customer is always right": In the past I've dealt with this 
situation by creating one or more "query" classes and one or more edit classes. 
 I found it easier to separate these.

I would then create basic methods like EditStaff.add_empooyee(**kwargs)  inside 
of which I would drop into (in my case) MySQLdb.  In retrospect, I'm not sure 
that the generick use of **kwargs was a good solution in that it masked what I 
was passing in, requiring me to go back to the calling code when debugging.  
OTOH it allowed me to be pretting generic by using
Sql = sql_template % kwargs

On the query side. I would convert the returned list of dictionaries to a list 
of objects using something like

Class DBrecord:
Def __init__(self, **kwargs):
Self.__dict__.update(kwargs)

So that I did not have to use the record['fieldname'] syntax but could use 
record.fieldname.

I would describe myself as more of a survivalist programmer, lacking some of 
the sophisticated techniques of others on the mailing list so take that into 
account.

Fred.

-Original Message-
From: python-list-bounces+frsells=adventistcare@python.org 
[mailto:python-list-bounces+frsells=adventistcare@python.org] On Behalf Of 
shearich...@gmail.com
Sent: Saturday, August 04, 2012 11:26 PM
To: python-list@python.org
Subject: Re: Object Models - decoupling data access - good examples ?

 
> 
> Just out of curiosity, why do you eschew ORMs?
> 
Good question !

I'm not anti-ORM (in fact in many circs I'm quite pro-ORM) but for some time 
I've been working with a client who doesn't want ORMs used (they do have quite 
good reasons for this although probably not as good as they think). 

I was interested to know, given that was the case, how you might - in Python, 
go about structuring an app which didn't use an ORM but which did use a RDBMS 
fairly intensively.

I take your point about having "rolled my own ORM" - lol - but I can assure you 
what's in that 'bardb' is a pretty thin layer over the SQL and nothing like 
the, pretty amazing, functionality of, for instance, SQLAlchemy.



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

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


RE: Diagramming code

2012-07-16 Thread Sells, Fred
You leave many relevant questions unanswered.

1. Is the original developer/team available or have you been left with
the code and little or no doc's?

2. How big is big in terms of the number of files/modules in the
project?  

3. Is there a reasonable structure to the project in terms of
directories and a meaningful hierarchy

4. Does the project currently work and you just have to maintain/enhance
it or was it "abandoned" by the original team in an unknown state and
you have to save a sinking ship?

5. Are you an experienced Python programmer or a beginner.

6. Is the original code "pythonic" (i.e. clean and simple with brief,
well organized methods) or do you have functions over 50 lines of code
with multiple nested control statements and meaningless variable names?

7. Is there any documentation that defines what it should do and how it
should do it.  i.e. how do you know when it's working?

These issues are not really Python specific, but if you've been given a
"broken" project that has 200 poorly organized modules and little or no
documentation and no access to the original team, a good first step
would be to update your resume ;)

OK then, let me ask, how do you guys learn/understand large projects ?

hamilton

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

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


RE: Overlayong PDF Files

2012-05-02 Thread Sells, Fred
Assuming your form has actual PDF data entry fields.  I export the form to a 
.fdf file, run a little script to replace fieldnames with %(fieldname)s  and 
save this as a staic template.  At run time I'll merge the template with a 
python dictionary using the % operator and shell down to pdftk to merge the two 
files and create a filled in PDF.  This way you don't have to worry about exact 
placement of data.

I have been looking for an api that would let me do this without the .fdf step, 
but to no avail.


-Original Message-
From: python-list-bounces+frsells=adventistcare@python.org 
[mailto:python-list-bounces+frsells=adventistcare@python.org] On Behalf Of 
Adam Tauno Williams
Sent: Thursday, April 26, 2012 8:25 AM
To: python-list@python.org
Subject: Re: Overlayong PDF Files

On Wed, 2012-04-25 at 13:36 -0500, Greg Lindstrom wrote:
> I would like to take an existing pdf file which has the image of a 
> health care claim and overlay the image with claim data (insured name, 
> address, procedures, etc.).  I'm pretty good with reportlab -- in 
> fact, I've created a form close to the CMS 1500 (with NPI), but it's 
> not close enough for scanning.  I'd like to read in the "official"
> form and add my data.  Is this possible?

I 'overlay' PDF documents  using pypdf.

Example


--
Adam Tauno Williams 
System Administrator, OpenGroupware Developer, LPI / CNA Fingerprint 8C08 209A 
FBE3 C41A DD2F A270 2D17 8FA4 D95E D383
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Using the Python Interpreter as a Reference

2011-12-02 Thread Sells, Fred
Steven, that's probably the most elegant explanation of the "pythonic"
way I've ever seen.  I'm saving it for the next time upper management
want to use Java again.

-Original Message-
From: python-list-bounces+frsells=adventistcare@python.org
[mailto:python-list-bounces+frsells=adventistcare@python.org] On
Behalf Of Steven D'Aprano
Sent: Thursday, December 01, 2011 7:43 PM
To: python-list@python.org
Subject: Re: Using the Python Interpreter as a Reference

On Thu, 01 Dec 2011 10:03:53 -0800, DevPlayer wrote:

[...]
> Well, that may be a little hyperbolic. But with 2 spaces you can
> encourage coders to get very deep, indentially, and still fit 80
chars.

Why would you want to encourage coders to write deeply indented code?

In my opinion, if your code is indented four or more levels, you should 
start to think about refactorising your code; if you reach six levels, 
your code is probably a mess.

class K:
def spam():
if x:
for a in b:
# This is about as deep as comfortable
while y:
# Code is starting to smell
try:
# Code smell is now beginning to reek
with z as c:
# And now more of a stench
try:
# A burning, painful stench
if d:
# Help! I can't breathe!!!
for e in f:
# WTF are you thinking?
try:
# DIE YOU M***ER!!!
while g:
# gibbers quietly
...


The beauty of languages like Python where indentation is significant is 
that you can't hide from the ugliness of this code. 

class K: {
  # Code looks okay to a casual glance.
  def spam():{
   if x: { for a in b:{
 while y:{ try:{ with z as c:{
   try:{ if d:{ for e in f:{ try:{
 while g:{ ... 
   
 

Deeply indented code *is* painful, it should *look* painful.


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

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


RE: Py and SQL

2011-12-01 Thread Sells, Fred
I find it easier to code like this

 

Sql = ‘’’select yadda, yadda, yadda

FROM a,b,c

Where this=that

ORDER BY deudderting’’’

 

With the appropriate %s(varname)  and  % against a dictionary rather than 
positional args, but that’s just me.

 

From: python-list-bounces+frsells=adventistcare@python.org 
[mailto:python-list-bounces+frsells=adventistcare@python.org] On Behalf Of 
Jerry Hill
Sent: Wednesday, November 30, 2011 5:15 PM
To: Verde Denim
Cc: Python list
Subject: Re: Py and SQL

 

On Wed, Nov 30, 2011 at 3:30 PM, Verde Denim  wrote:

dbCursor1.execute('select lpad(' ', 2*level) || c "Privilege, Roles and Users" 
from ( select null p, name c from system_privilege_map where name like 
upper(\'%&enter_privliege%\') union select granted_role p, grantee c from 
dba_role_privs union select privilege p, grantee c from dba_sys_privs) start 
with p is null connect by p = prior c')


I think this is your problem.  Your string is delimited with single quotes on 
the outside ('), but you also have a mix of single and double quotes inside 
your string.  If you were to assign this to a variable and print it out, you 
would probably see the problem right away. 

You have two options.  First, you could flip the outer quotes to double quotes, 
then switch all of the quotes inside the string to single quotes (I think that 
will work fine in SQL).  Second, you could use a triple-quoted string by 
switching the outer quotes to ''' or """.  Doing that would let you mix 
whatever kinds of quotes you like inside your string, like this (untested):

sql = '''select lpad(' ', 2*level) || c "Privilege, Roles and Users" from ( 
select null p, name c from system_privilege_map where name like 
upper(\'%&enter_privliege%\') union select granted_role p, grantee c from 
dba_role_privs union select privilege p, grantee c from dba_sys_privs) start 
with p is null connect by p = prior c'''

dbCursor1.execute(sql)

Once you do that, I think you will find that the "&enter_priviliege" bit in 
your SQL isn't going to do what you want.  I assume you're expecting that to 
automatically pop up some sort of dialog box asking the user to enter a value 
for that variable?  That isn't going to happen in python.  That's a function of 
the database IDE you use.  You'll need to use python to ask the user for the 
privilege level, then substitute it into the sql yourself.

-- 
Jerry

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


RE: Using the Python Interpreter as a Reference

2011-11-25 Thread Sells, Fred
I'm looking at a variation on this theme.  I currently use
Flex/ActionScript for client side work, but there is pressure to move
toward HTML5+Javascript and or iOS.  Since I'm an old hand at Python, I
was wondering if there is a way to use it to model client side logic,
then generate the javascript and ActionScript.  I don't see an issue
using custom python objects to render either mxml, xaml or html5 but I'm
not aware if anyone has already solved the problem of converting Python
(byte code?) to these languages?  Any suggestions.

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


RE: webapp development in pure python

2011-10-25 Thread Sells, Fred
Quixote may be what you want, but it's been years since I've used it and
I don't know if it is still alive and kicking.  It was from MEMS if I
remember correctly.

Using django and Flex is one way to avoid html and javascript and it
works great for datagrids.

Fred.

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


RE: Community Involvement

2011-08-05 Thread Sells, Fred
After the completion of most training courses, the students are not yet
ready to make a meaningful contribution to the community.  

 

Yet your goal of getting them involved in the community is worthwhile.
I would think learning to use the community as a resource to solve a
problem that is not based on the standard modules would be a good one.

 

I liked the recipe suggestion as well, but I think you would need to
post a list of  items to choose and remove the item when the recipe has
been posted.  Otherwise you could get a gazillion examples of sorting a
dictionary...

 

Just my 2 cents FWIW

 

Fred Sells

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


RE: Selecting unique values

2011-07-26 Thread Sells, Fred
The set module or function (depends on which python version) will do
this if you make each record a tuple.

-Original Message-
From: python-list-bounces+frsells=adventistcare@python.org
[mailto:python-list-bounces+frsells=adventistcare@python.org] On
Behalf Of Peter Otten
Sent: Tuesday, July 26, 2011 5:04 AM
To: python-list@python.org
Subject: Re: Selecting unique values

Kumar Mainali wrote:

> I have a dataset with occurrence records of multiple species. I need
to
> get rid of multiple listings of the same occurrence point for a
species
> (as you see below in red and blue typeface). How do I create a dataset
> only with unique set of longitude and latitude for each species?
Thanks in
> advance.
> 
> Species_name Longitude Latitude
> Abies concolor -106.601 35.868
> Abies concolor -106.493 35.9682
> Abies concolor -106.489 35.892
> Abies concolor -106.496 35.8542
> Accipiter cooperi -119.688 34.4339
> Accipiter cooperi -119.792 34.5069
> Accipiter cooperi -118.797 34.2581
> Accipiter cooperi -77.38333 39.68333
> Accipiter cooperi -77.38333 39.68333
> Accipiter cooperi -75.99153 40.65
> Accipiter cooperi -75.99153 40.65

>>> def uniquify(items):
... seen = set()
... for item in items:
... if item not in seen:
... seen.add(item)
... yield item
...
>>> import sys
>>> sys.stdout.writelines(uniquify(open("species.txt")))
Species_name Longitude Latitude
Abies concolor -106.601 35.868
Abies concolor -106.493 35.9682
Abies concolor -106.489 35.892
Abies concolor -106.496 35.8542
Accipiter cooperi -119.688 34.4339
Accipiter cooperi -119.792 34.5069
Accipiter cooperi -118.797 34.2581
Accipiter cooperi -77.38333 39.68333
Accipiter cooperi -75.99153 40.65

If you need to massage the lines a bit:

>>> def uniquify(items, key=None):
... seen = set()
... for item in items:
... if key is None:
... keyval = item
... else:
... keyval = key(item)
... if keyval not in seen:
... seen.add(keyval)
... yield item
...

Unique latitudes:

>>> sys.stdout.writelines(uniquify(open("species.txt"), key=lambda s: 
s.rsplit(None, 1)[-1]))
Species_name Longitude Latitude
Abies concolor -106.601 35.868
Abies concolor -106.493 35.9682
Abies concolor -106.489 35.892
Abies concolor -106.496 35.8542
Accipiter cooperi -119.688 34.4339
Accipiter cooperi -119.792 34.5069
Accipiter cooperi -118.797 34.2581
Accipiter cooperi -77.38333 39.68333
Accipiter cooperi -75.99153 40.65

Unique species names:

>>> sys.stdout.writelines(uniquify(open("species.txt"), key=lambda s: 
s.rsplit(None, 2)[0]))
Species_name Longitude Latitude
Abies concolor -106.601 35.868
Accipiter cooperi -119.688 34.4339

Bonus: open() is not the built-in here:

>>> from StringIO import StringIO
>>> def open(filename):  
... return StringIO("""Species_name Longitude Latitude
... Abies concolor -106.601 35.868
... Abies concolor -106.493 35.9682   
... Abies concolor -106.489 35.892
... Abies concolor -106.496 35.8542   
... Accipiter cooperi -119.688 34.4339
... Accipiter cooperi -119.792 34.5069
... Accipiter cooperi -118.797 34.2581
... Accipiter cooperi -77.38333 39.68333  
... Accipiter cooperi -77.38333 39.68333  
... Accipiter cooperi -75.99153 40.65 
... Accipiter cooperi -75.99153 40.65 
... """)  
...   


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

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


RE: reading zipfile; problem using raw buffer

2011-07-26 Thread Sells, Fred
Thanks all,  adding the 'rb' and 'wb' solved that test case.

The reason I read the file "the hard way" is that I'm testing why I
cannot unzip a buffer passed in a file upload using django.

While not actually using a file, pointing out the need for the binary
option gave me the clue I needed to upload the file

All is good and moving on to the next crisis ;)

Fred.


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


reading zipfile; problem using raw buffer

2011-07-26 Thread Sells, Fred
I'm tring to unzip a buffer that is uploaded to django/python.  I can
unzip the file in batch mode just fine, but when I get the buffer I get
a "BadZipfile exception.  I wrote this snippet to try to isolate the
issue but I don't understand what's going on.  I'm guessing that I'm
losing some header/trailer somewhere?

def unittestZipfile(filename):
buffer = ''
f = open(filename)
for i in range(22):
block = f.read()
if len(block) == 0: 
break
else:
buffer += block

print len(buffer)
tmp = open('tmp.zip', 'w')
tmp.write(buffer)
tmp.close()
zf = zipfile.ZipFile('tmp.zip')
print dir(zf)
for name in zf.namelist():
print name
print zf.read(name)

2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
Traceback (most recent call last):
  File
"C:\all\projects\AccMDS30Server\mds30\app\uploaders\xmitzipfile.py",
line 162, in 
unittestZipfile('wk1live7.8to7.11.zip')
  File
"C:\all\projects\AccMDS30Server\mds30\app\uploaders\xmitzipfile.py",
line 146, in unittestZipfile
print zf.read(name)
  File "C:\alltools\python26\lib\zipfile.py", line 837, in read
return self.open(name, "r", pwd).read()
  File "C:\alltools\python26\lib\zipfile.py", line 867, in open
raise BadZipfile, "Bad magic number for file header"
zipfile.BadZipfile: Bad magic number for file header

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


RE: Refactor/Rewrite Perl code in Python

2011-07-25 Thread Sells, Fred
Sometimes it's worth asking Why?

I assume there would be no need to rewrite if the existing code did most
of what was needed.  It may be easier to ask the customer what he really
wants rather than to re-engineer a crappy solution to an obsolete
problem.

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


newbie needs help with cookielib

2011-05-04 Thread Sells, Fred
I'm using Python 2.4 and 2.7 for different apps.  I'm happy with a
solution for either one.

I've got to talk to a url that uses a session cookie.  I only need to
set this when I'm developing/debugging so I don't need a robust
production solution and I'm somewhat confused by the docs on cookielib.
I can use urllib2 without cookielib just fine, but need the cookie to
add some security.

I'm normally using Firefox 4.0 to login to the server and get the
cookie.  After that I need some way to set the same cookie in my python
script.  I can do this by editing my code, since I only need it while
defeloping from my test W7 box.


I was hoping to find something like

...set_cookie('mycookiename', 'myvalue', 'mydomain.org')

I've googled this most of the morning and found everything but what I
need, or I just don't understand the basic concept.  Any pointers would
be greatly appreciated.  One of my false starts looks like this. But I
get a 

...
  File "C:\alltools\python26\lib\urllib2.py", line 518, in
http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Access Deinied

def test1():
cj = cookielib.MozillaCookieJar()
cj.load('C:/Users/myname/Desktop/cookies.txt')
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
r = opener.open("http://daffyduck.mydomain.org/wsgi/myapp.wsgi";)   
print r.read() 
return

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


RE: What was your strategy?

2010-11-16 Thread Sells, Fred
It helps to try to solve a real (to you) problem, that way you discover
what you don't know.  If your code ends up nested 3 levels or your
methods are more than 10 lines, ask for help.

-Original Message-
From: python-list-bounces+frsells=adventistcare@python.org
[mailto:python-list-bounces+frsells=adventistcare@python.org] On
Behalf Of Jorge Biquez
Sent: Sunday, November 14, 2010 5:32 PM
To: python-list@python.org
Subject: What was your strategy?

Hello all.
Quick question. I know some of you are with Python since started, 
some other maybe later.

I was wondering if you can share what was the strategy you followed 
to master Python (Yes I know I have to work hard study and practice a 
lot). I mean did you use special books, special sites, a plan to 
learn each subject in a special way. I would like to know, if 
possible, comments specially from some of you who in the past had 
other languages, frameworks and platforms and left (almost) all of 
them and stayed with Python.

Thanks in advance

Jorge Biquez

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

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


RE: { '0':'c->c->a' ,'1':'a->b->a' .........}

2010-11-09 Thread Sells, Fred
Since your keys are not unique, I would think that you would want a list
of values for the object corresponding to each key.  Something like

Mydict = {}

Mydict.setdefault(mykey, []).append(avalue)

-Original Message-
From: python-list-bounces+frsells=adventistcare@python.org
[mailto:python-list-bounces+frsells=adventistcare@python.org] On
Behalf Of Peter Otten
Sent: Sunday, November 07, 2010 4:01 PM
To: python-list@python.org
Subject: Re: { '0':'c->c->a' ,'1':'a->b->a' .}

chris wrote:
> have anybody a hint , how i get a dict from non unique id's and their
> different related values.
> 
> Thanks for advance
> Chris
> 
> ###random data #
> a=range(10)*3
> def seqelem():
> i=random.randint(0,2)
> elem=['a','b','c'][i]
> return elem
> 
> s=[seqelem() for t in  range(30)]
> print zip(a,s)
> 
> ## favored result:
> { '0':'c->c->a' ,'1':'a->b->a' .}

>>> import random
>>> from collections import defaultdict
>>> a = range(10)*3
>>> s = [random.choice("abc") for _ in a]
>>> d = defaultdict(list)
>>> for k, v in zip(a, s):
... d[k].append(v)
...
>>> d
defaultdict(, {0: ['b', 'a', 'a'], 1: ['c', 'a', 'c'], 2:
['c', 
'c', 'c'], 3: ['c', 'a', 'a'], 4: ['b', 'c', 'a'], 5: ['b', 'c', 'c'],
6: 
['c', 'a', 'b'], 7: ['b', 'b', 'a'], 8: ['a', 'c', 'c'], 9: ['b', 'a', 
'b']})
>>> dict((k, "->".join(v)) for k, v in d.iteritems())
{0: 'b->a->a', 1: 'c->a->c', 2: 'c->c->c', 3: 'c->a->a', 4: 'b->c->a',
5: 
'b->c->c', 6: 'c->a->b', 7: 'b->b->a', 8: 'a->c->c', 9: 'b->a->b'}

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

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


RE: Generating PDF file in Python

2010-10-27 Thread Sells, Fred
I just shell down and use pdftk to merge fdf and pdf

-Original Message-
From: python-list-bounces+frsells=adventistcare@python.org
[mailto:python-list-bounces+frsells=adventistcare@python.org] On
Behalf Of Steve Piercy - Web Site Builder
Sent: Wednesday, October 27, 2010 8:24 AM
To: python-list@python.org
Subject: Re: Generating PDF file in Python

On 10/26/10 at 8:38 AM, gher...@islandtraining.com (Gary Herron)
pronounced:

>Try a package named reportlab.  It's very comprehensive, opensource,
>written in Python and is cross-platform:
>
>http://www.reportlab.com/software/opensource/

It appears that the open source version of ReportLab does not 
offer the ability to merge FDF data into an existing PDF form.  
Instead ReportLab Plus is required, and commercial license costs 
at least GBP1100 per year for up to 30,000 pages.

Is that correct?

I found this option:
http://stackoverflow.com/questions/1890570/how-can-i-auto-populate-a-pdf
-form-in-django-python

Has anyone else tried this route?

--steve

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
-- --
Steve Piercy   Web Site Builder   
Soquel, CA
  

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

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


RE: Processing XML File

2010-01-29 Thread Sells, Fred
Google is your friend.  Elementtree is one of the better documented
IMHO, but there are many modules to do this.

> -Original Message-
> From: python-list-bounces+frsells=adventistcare@python.org
> [mailto:python-list-bounces+frsells=adventistcare@python.org] On
> Behalf Of Stefan Behnel
> Sent: Friday, January 29, 2010 2:25 PM
> To: python-list@python.org
> Subject: Re: Processing XML File
> 
> jakecjacobson, 29.01.2010 18:25:
> > I need to take a XML web resource and split it up into smaller XML
> > files.  I am able to retrieve the web resource but I can't find any
> > good XML examples.  I am just learning Python so forgive me if this
> > question has been answered many times in the past.
> >
> > My resource is like:
> >
> > 
> >  ...
> >  ...
> > 
> > 
> >  ...
> >  ...
> > 
> 
> Is this what you get as a document or is this just /contained/ in the
> document?
> 
> Note that XML does not allow more than one root element, so the above
is
> not XML. Each of the two ... parts form an XML
> document by themselves, though.
> 
> 
> > So in this example, I would need to output 2 files with the contents
> > of each file what is between the open and close document tag.
> 
> Are the two files formatted as you show above? In that case, you can
> simply
> iterate over the lines and cut the document when you see "".
Or,
> if you are sure that "" only appears as top-most elements
and
> not
> inside of the documents, you can search for "" in the
content (a
> string, I guess) and split it there.
> 
> As was pointed out before, once you have these two documents, use the
> xml.etree package to work with them.
> 
> Something like this might work:
> 
> import xml.etree.ElementTree as ET
> 
> data = urllib2.urlopen(url).read()
> 
> for part in data.split(''):
> document = ET.fromstring(''+part)
> print(document.tag)
> # ... do other stuff
> 
> Stefan
> --
> http://mail.python.org/mailman/listinfo/python-list

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


RE: How to run python script in emacs

2009-10-13 Thread Sells, Fred
Here is the .emacs file I place at c:\ on xp.  I don't understand it and
cannot explain it.  It was developed by a few guys I worked with 20
years ago and still does the job.  Probably quite obsolete by now, but
if it ain't broke...
In response to your "what do you mean"
With the cursor in a python buffer (and the mode must say python).  Hold
down the control key and hit the "c" key twice.  
--
(setq initial-major-mode 'c-mode)
(setq text-mode-hook 'turn-on-auto-fill)
(setq-default indent-tabs-mode nil)
(global-set-key "\C-z" 'narten-suspend-emacs)
(global-set-key "\C-_" 'help-command)
(setq help-char 31)
(define-key global-map "\C-h" 'backward-delete-char-untabify)
(global-set-key "\C-x\C-e" 'compile)
(global-set-key "\C-x1" 'my-delete-other-windows)
(setq manual-program "man")
(setq manual-formatted-dir-prefix (list "/usr/man/cat"
"/usr/local/X11R4/man"))
(setq manual-formatted-dirlist (list
"/usr/man/cat1" "/usr/man/cat2" "/usr/man/cat3" "/usr/man/cat4"
"/usr/man/cat5" "/usr/man/cat6" "/usr/man/cat7" "/usr/man/cat8"
"/usr/man/catl" "/usr/man/catn" "/usr/local/X11R4/man/catn"
"/usr/local/X11R4/man/cat3" ))
(global-set-key "\em" 'manual-entry)
(global-set-key "\eg" 'goto-line)
(global-set-key "\C-xb" 'my-switch-to-buffer)
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key "\C-q" 'electric-buffer-list)
(global-set-key "\C-x\C-b" 'buffer-menu)
(global-set-key "\C-x\C-y" 'cd)
(global-set-key "\es" 'shell)
(global-set-key "\C-xd" 'display-filename)
(global-set-key "\C-i" 'narten-do-a-tab)
(global-set-key "\C-x\C-b" 'buffer-menu)
(global-set-key "\C-_\C-_" 'help-for-help)
(global-set-key "\C-_\C-a" 'apropos)
(global-unset-key "\C-_\C-c")
(global-unset-key "\C-_\C-d")
(global-unset-key "\C-_\C-n")
(global-unset-key "\C-_\C-w")
(defun my-delete-other-windows ()
  (interactive)
  (delete-other-windows)
  (recenter))
(defun narten-suspend-emacs ()
  (interactive)
  (save-all-buffers)
  (suspend-emacs))
(defun narten-do-a-tab ()
  (interactive)
  (cond ((looking-at "^") 
 (progn (delete-horizontal-space)
(indent-relative)))
((looking-at "[ \t]*")
 (tab-to-tab-stop)))
  (let ((beg (point)))
(re-search-backward "[^ \t]")
(tabify (point) beg))
  (re-search-forward "[ \t]+"))
(defun display-filename ()
  (interactive)
  (message buffer-file-name))
(defun save-all-buffers ()
  (interactive)
  (save-some-buffers 1)
  (message "done!"))
(defun my-switch-to-buffer () 
  "switch to buffer, using completion to prevent bogus buffer names from
being given"
  (interactive)
  (switch-to-buffer (read-buffer "Switch to buffer: " (other-buffer)
"t")))
;;;
;;; GNUS stuff
;;;
(setq gnus-nntp-server "astro")
(setq gnus-your-domain "sunrise.com")
(setq gnus-your-organization "Sunrise Software International")

(setq display-time-day-and-date t)
(setq display-time-no-load t)
(setq display-newmail-beep t)
(display-time)
;;(setq-default tab-width 4 )fred

(put 'narrow-to-region 'disabled nil)


(put 'narrow-to-page 'disabled nil)

(put 'insert-file 'disabled nil)

(autoload 'python-mode "python-mode" "" t)
(setq auto-mode-alist
  (cons '("\\.py$" . python-mode) auto-mode-alist))
;;(my-delete-other-windows)
;;(electric-buffer-list)

;;(cond (window-system
;;   (setq hilit-mode-enable-list  '(not text-mode)
;; hilit-background-mode   'light
;; hilit-inhibit-hooks nil
;; hilit-inhibit-rebinding nil)
;;
;;   (require 'hilit19)
;;   ))

;;
;; Hilit stuff
;;
;;(cond (window-system
;;   (setq hilit-mode-enable-list  '(not text-mode)
;; hilit-background-mode   'light
;; hilit-inhibit-hooks nil
;; hilit-inhibit-rebinding nil)
;;
;;   (require 'hilit19)
;;   ))
;;(require 'paren)

(setq-default transient-mark-mode t)

;;(electric-buffer-menu-mode)
(my-delete-other-windows)


(put 'erase-buffer 'disabled nil)

(put 'upcase-region 'disabled nil)

--
[**CONFIDENTIALITY NOTICE**]: The information contained in this message may be 
privileged and / or confidential and protected from disclosure. If the reader 
of this message is not the intended recipient, you are hereby notified that any 
dissemination, distribution or copying of this communication is strictly 
prohibited. If you have received this communication in error, please notify the 
sender immediately by replying to this message and deleting the material from 
any computer.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to run python script in emacs

2009-10-07 Thread Sells, Fred
Hitting ctrl-c, twice quickly works for me.

> -Original Message-
> From: python-list-bounces+frsells=adventistcare@python.org
> [mailto:python-list-bounces+frsells=adventistcare@python.org] On
> Behalf Of OdarR
> Sent: Wednesday, October 07, 2009 12:02 PM
> To: python-list@python.org
> Subject: Re: How to run python script in emacs
> 
> On 26 sep, 17:54, devilkin  wrote:
> > I'm just starting learning python, and coding inemacs. I usually
> > splitemacswindow into two, coding in one, and run script in the
> > other, which is not very convenient. anyone can help me with it? is
> > there any tricks likeemacsshort cut?
> >
> > also please recommand someemacsplug-ins for python programming, i'm
> > also beginner inemacs.currently i'm only using python.el. Are any
> > plugins supply code folding and autocomplete?
> >
> > BTW, I'm not a english native speaker, any grammer mistakes, please
> > correct them. :)
> 
> hello,
> 
> I was not so long ago in the same situation.
> I switch to emacs too, why ?
> probably because the movement is more natural than in vi (used for 12+
> years),
> python-mode automatically starts on the machines I'm using, this is
> very convenient for *re-indentation* .
> Python could be difficult to maintain if you don't have a flexible
> text editor.
> if you want, i can suggest you some lines for the init file .emacs,
> in order to keep the text indented with 4 spaces, no tab at all (very
> important).
> 
> I also suggest you to have a look on ipython shell, which is a super
> shell you keep side the text editor.
> once you discover it, you'll understand.
> 
> I didn't hear for an autocompletion in emacs.
> but ipython has a autocompletion. It can sound weird to auto-complete
> outside your editor, but I like it.
> you can test little code snippets in ipython, discover the
> documentation and methods, and try them.
> I discover this clever advice in
http://oreilly.com/catalog/9780596515829/
> 
> currently I work with Mac (Aquamacs), and I was recently on Solaris or
> XP as well.
> PS: emacs on Mac Terminal with a french keyboard is a bit of a
> nightmare considering the META key...:-(
> Aquamacs solves this finally.
> 
> 
> Olivier
> --
> http://mail.python.org/mailman/listinfo/python-list

--
[**CONFIDENTIALITY NOTICE**]: The information contained in this message may be 
privileged and / or confidential and protected from disclosure. If the reader 
of this message is not the intended recipient, you are hereby notified that any 
dissemination, distribution or copying of this communication is strictly 
prohibited. If you have received this communication in error, please notify the 
sender immediately by replying to this message and deleting the material from 
any computer.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Introducing Python to others

2009-04-02 Thread Sells, Fred
When doing the same thing, I like
Using a dictionary to return a function or a class definition based on a
msg id and let that returned value "handle" the message that contained
the id.  Something like
Class XYZ:
...

MyHandlers = {42:XYZ, ...

Message = read_from_somewhere_else()
HandlerDefn = MyHandlers[Message.id]
Handler = HandlerDefn(Message)
Handler.processMessage()

As opposed to a switch statement in other languages.

I get my fellow codes to install Eclipse+PyDev as I find it easier to
comprehend that IDLE.  It's nice to just hit F9; although ^c^c is cool
for emacs folks.

I prefer turbogears over Django because it is simpler (and thus less
robust) but it sure is cool to edit your server side code, save it and
watch the server reload it automatically.  Of couse I hate HTML and use
Flex for the client side and turbogears JSON or my own XML converter
make Flex a joy.
Good luck
Fred.

> -Original Message-
> From: python-list-bounces+frsells=adventistcare@python.org
> [mailto:python-list-bounces+frsells=adventistcare@python.org] On
> Behalf Of Paddy O'Loughlin
> Sent: Thursday, March 26, 2009 5:36 AM
> To: python-list@python.org
> Subject: Introducing Python to others
> 
> Hi,
> As our resident python advocate, I've been asked by my team leader to
> give a bit of a presentation as an introduction to python to the rest
> of our department.
> It'll be less than an hour, with time for taking questions at the end.
> 
> There's not going to be a whole lot of structure to it. First, I'm
> going to open up a python terminal and show them how the interpreter
> works and a few basic syntax things and then a file .py files (got to
> show them that python's indenting structure is not something to be
> afraid of :P). I think I'll mostly show things in the order that they
> appear in the python tutorial (http://docs.python.org/tutorial/).
> 
> My question to you, dear python-list, is what suggestions do you have
> for aspects of python that I should show them to make them maybe think
> that python is better than what they are using at the moment.
> All of the audience will be experienced (4+ years) programmers, almost
> all of them are PHP developers (2 others, plus myself, work in C, know
> C#, perl, java, etc.).
> Because of this, I was thinking of making sure I included exceptions
> and handling, the richness of the python library and a pointing out
> how many modules there were out there to do almost anything one could
> think of.
> Anything else you think could make PHP developers starting think that
> python is a better choice?
> If I were to do a (very) short demonstration one web framework for the
> PHP devs, what should I use? CherryPy (seems to be the easiest),
> Django (seems to be the "biggest"/most used), or something else?
> 
> Any other suggestions for a possible "wow" reaction from an audience
like
> that?
> 
> Thanks,
> Paddy
> 
> --
> "Ray, when someone asks you if you're a god, you say YES!"
> --
> http://mail.python.org/mailman/listinfo/python-list
---[Notification]
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
--

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


RE: Python Apache Handler

2009-01-09 Thread Sells, Fred
Mod_python works, but if you are doing anything significant look into
one of the many frameworks like turbogears or django.  More structure to
learn but less code when all is said and done.

> -Original Message-
> From: python-list-bounces+frsells=adventistcare@python.org
> [mailto:python-list-bounces+frsells=adventistcare@python.org] On
> Behalf Of Scooter
> Sent: Friday, January 09, 2009 9:37 AM
> To: python-list@python.org
> Subject: Python Apache Handler
> 
> Does anyone have any good examples, or links thereto for using python
> as an Apache handler? And I should qualify all of this by saying I'm a
> python newbie, and while having experience with Apache, I've never
> done anything outside whats "in the box" .
> 
> What I'm looking for is how one might use Python not from the CGI/
> presentation side but more on the backend...i.e. for each page Apache
> serves up examine the request and update some headers, or add a cookie
> to the response. Or possibly use Python for writing a custom Apache
> logger. I've searched the web but typically end up with pages for
> mod_python and writing CGI scripts.
> 
> And if you feel this is better posted in an Apache group vs. here, let
> me apologize up front.
> 
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list

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


RE: Python advocacy . HELP!

2008-12-24 Thread Sells, Fred
Prof. Kanabar  (kanabar.bu.edu) is planning to offer a python course
there soon.  Perhaps he could help.  Tell him you got his name from me
(Fred Sells).

> -Original Message-
> From: python-list-bounces+frsells=adventistcare@python.org
> [mailto:python-list-bounces+frsells=adventistcare@python.org] On
> Behalf Of Michael_D_G
> Sent: Thursday, December 04, 2008 1:52 AM
> To: python-list@python.org
> Subject: Python advocacy . HELP!
> 
> 
> I am a faculty member of a cs department. We currently teach C++ in
> our intro to programming course. I am teaching this class and it seems
> to me that we would be much better served teaching python in the intro
> course, C++ for Data structures, as we do now, and Java in object
> oriented programming, as we do now.
> Some of my colleagues agree with me but some still see python as a
> niche language and don't understand
> how we could teach anything beyond C, C++ or Java.
> 
> I have looked at several interesting academic papers, on doing just
> this approach. I have also looked through the
> python web page to get examples of industry players using python in a
> non-trivial way. Yes, I know, Google,
> Microsoft, Sun, CIA website running on Plone, NOAA, NASA. If anyone
> has any recent articles,
> or if anyone on the list is at a fortune 500 company, how do I refute
> the notion that Python
> is a "marginal" language because according to TOBIE it only less than
> a  6% market share.
> 
> -michael
> --
> http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list


RE: Django or TurboGears or Pylons? for python web framework.

2008-11-07 Thread Sells, Fred
I use Flex (from adobe) for the client side and turbogears for the
server side and pass xml or json in between.  It gives you a Flash
client which is very Sexy and browser independent and very simple
turbogears code in Python.
Flex is essentially open source, but the IDE is about $295, although
there are multiple ways of getting it for free, including a 30 day eval.
The IDE is an Eclipse plugin, and is well worth the $$$ if you decide to
go that way.



> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Aspersieman
> Sent: Wednesday, November 05, 2008 5:54 AM
> To: 3000 billg; python-list@python.org
> Subject: Re: Django or TurboGears or Pylons? for python web framework.
> 
> On Wed, 05 Nov 2008 08:35:23 +0200, 3000 billg
<[EMAIL PROTECTED]>
> wrote:
> 
> > Hi Senior,
> 
> Hi
> 
> > There was a case for web site that will be public to Internet for
me. I
> > like
> > python so I do not consider the use of Ruby on Rails.
> 
> Excellent choice :)
> 
> > I searched more web framework of python from Google. The good
solution
> > just
> > only there are Django, TurboGears and Pylons.
> 
> I would recommend web2py [1].
> 
> > Just from my preferences, I want to use Django but the AJAX support
will
> > be
> > a problem. Also I need to select a JavaScript framework and lean it,
> > maybe
> > JQuery, mootools or other. And I can not write python as it is
written
> in
> > general javascript. I need to learn a different syntax.
> 
> It supports (and comes with) jquery, has awesome ajax integration.
> 
> > TurboGears or Pylons, I am worried that the issue of performance
because
> > CherryPy.
> 
> I have read (somewhere - I can't find the link now, you can probably
> google it) that it runs as fast or faster than django (and some other
> frameworks).
> 
> > Could everybody give me a hand for your select? Django or Turbegears
or
> > Pylons? and Why?
> 
> For Django VS web2py see [2]
> For Turbogears VS web2py see [3]
> 
> > If Django, how to do Ajax support for you? and why?
> 
> For info on web2py and ajax see [4].
> 
> Also web2py supports SQLite, MySQL, PostgreSQL, MSSQL, FireBird and
Oracle
> databases - which is very cool for me as I often need to work on
different
> RDBMS's. Internationalisation is also a cinch. Plus - you can run the
> whole framework from a USB drive and it includes a administrative
> interface with a text editor so you can code your project *entirely*
in a
> web browser. It also runs on almost anything that supports python :
> windows, unix/linux, OS X etc. I also has a very active and helpful
> mailing list
> 
> I have tried a couple of other frameworks but only web2py gave me that
> 'just right' feel. Don't, however take only my word for it - and try
other
> frameworks to find the one that works for you. One is, fortunately,
spoilt
> for choice with all the cool python frameworks these days. :)
> 
> > thanks eveybody first.
> 
> HTH
> 
> Nicol
> 
> [1] http://www.web2py.com/
> [2] http://mdp.cti.depaul.edu/AlterEgo/default/show/101
> [3] http://mdp.cti.depaul.edu/AlterEgo/default/show/102
> [4] http://mdp.cti.depaul.edu/AlterEgo/default/show/80
> 
> --
> Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo
> --
> http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list


RE: swig or ctypes , under the gun and need help

2008-08-25 Thread Sells, Fred
Diez wrote...
> I don't know swig, but if all you have is a real C-API, try & 
> use ctypes.
> It's much easier to create bindings for, keeps you fully in 
> the warm and
> cozy womb of python programming and doesn't need no 
> compilation to create
> the actual binding.
> 
You're right the ctypes does seem more pythonesque; however I'm still stuck 
trying return all these parameters
that the c api uses.  my ctypes code is below.  It just quits running when I 
try to print 
one of the args I did a pass byref on, no error out, nothing.  admittedly I'm a 
newbie to ctypes and not much of a c programmer
but I could sure use some help.  my ctypes test code follows...

from ctypes import *

'''
create shared object file like so.
gcc -shared -o rug520.so  rug520.c

the c api I want to call is like this.
int RugCalc( char * sMdsRecord, 
 char * sRehabType, 
 char * sModel, 
 int iQuarterlyFlag, 
 double nCmiArray[], 
  char * sRugHier,
 char * sRugMax, 
 int * iRugHier,
 int * iRugMax, 
 double * nCmiValueHier,
 double * nCmiValueMax, 
 int * iAdlSum,
 int * iCpsCode, 
 char * sRugsVersion,
 char * sDllVersion, 
 int * iError );
'''
libc = CDLL("rug520.so")

CmiArrayDef = c_double * 59

ZeroCmi = CmiArrayDef( )  #this is a table used internally, but 0.0 should work 
until I figure out the rest.



def getrug(mds):
#print mds
sMdsRecord = c_char_p()
sRehabType = c_char_p()
sModel = c_char_p()
iQuarterlyFlag = c_int()
sRugHier  = c_char_p()
sRugMax = c_char_p()
iRugHier = c_int()
iRugMax = c_int()
nCmiValueHier = c_double()
nCmiValueMax  = c_double()
iAdlSum = c_int()
iCpsCode = c_int()
sRugsVersion = c_char_p()
sDllVersion = c_char_p()
iError = c_int()
sMdsRecord.value = mds
sRehabType = 'mcare'
sModel = '34'

results = libc.RugCalc(sMdsRecord, sRehabType, sModel, iQuarterlyFlag, 
 ZeroCmi,
 byref(sRugHier),
 byref(sRugMax), 
 byref(iRugHier),
 byref(iRugMax), 
 byref(nCmiValueHier),
 byref(nCmiValueMax), 
 byref(iAdlSum),
 byref(iCpsCode), 
 byref(sRugsVersion),
 byref(sDllVersion), 
 byref(iError ))
print 'results', results
print iQuarterlyFlag.value
print 'sRugMax', sRugMax  #this print causes an exit, tried .value with 
same results
print 'return'  #I never see this print.

datafile = open('mdsdata.txt')
for d in datafile:
if d[0]=='B':
getrug(d)
break

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


swig double[], under the gun and need help

2008-08-24 Thread Sells, Fred
I'm using python 2.4 under linux (centos 5.1).
I need to pass an array of doubles to a c function
but am getting an error, shown near the bottom of
this post.

my swig interface file looks like this

* File: rug520.i */
%module rug520
%include "typemaps.i"
%include "carrays.i"
%array_class(double, doubleArray);
%{
#define SWIG_FILE_WITH_INIT
#include "rug520.h"
extern double[] nCmiArray;
%}


%apply int *OUTPUT { char *sRugHier,
 char * sRugMax, 
 int * iRugHier,
 int * iRugMax, 
 double * nCmiValueHier,
 double * nCmiValueMax, 
 int * iAdlSum,
 int * iCpsCode, 
 char * sRugsVersion,
 char * sDllVersion, 
 int * iError };


int RugCalc( char * sMdsRecord, 
 char * sRehabType, 
 char * sModel, 
 int iQuarterlyFlag, 
 double nCmiArray[], 

  char * sRugHier,
 char * sRugMax, 
 int * iRugHier,
 int * iRugMax, 
 double * nCmiValueHier,
 double * nCmiValueMax, 
 int * iAdlSum,
 int * iCpsCode, 
 char * sRugsVersion,
 char * sDllVersion, 
 int * iError );

-- 
my test code looks like this:
import sys, os, rug520
cmi=[0.0] *59

def getrug(mds):
results = rug520.RugCalc(mds, 'mcare', '34', 0, cmi)
print 'results', results

datafile = open('mdsdata.txt')
for d in datafile:
if d[0]=='B':
getrug(d)

I get this error message
File "testrug520.py", line 11, in ?
getrug(d)
  File "testrug520.py", line 5, in getrug
results = rug520.RugCalc(mds, 'mcare', '34', 0, cmi)
TypeError: in method 'RugCalc', argument 5 of type 'double []'

--

I'm guessing that I am not passing a double array to the c code.  I cannot 
change
the c code due to politics.  I could write a c "wrapper" if I had to, but would 
rather
stay within python or the swig interface definitions if possible/practical.

I'm not much of a c programmer; mostly java and python with a little c++.  
I've looked in the swig docs and tried google, but either have not found
it or just don't understand what they are telling me here.
 
---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
--
http://mail.python.org/mailman/listinfo/python-list


RE: need ldap windows binary and/or installation help

2008-07-15 Thread Sells, Fred
well, duh ;)  as my granny used to say "If it had been a snake it would a bit 
ya".  I could probably come up with some lame excuse why I didn't see the msi 
on osuch.org, but it would be lame and an excuse.

anyway.  Thanks!

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Michael Ströder
> Sent: Tuesday, July 15, 2008 2:46 PM
> To: python-list@python.org
> Subject: Re: need ldap windows binary and/or installation help
> 
> 
> Tim Golden wrote:
> > Sells, Fred wrote:
> >> I'm running python 2.5 (or 2.4) in an XP environment.
> >> I downloaded and installed the .dll's from 
> >> OpenLDAP-2.4.8+OpenSSL-0.9.8g-Win32.zip and copied the .dll's in 
> >> c:/windows/system32 as instructed
> >> now I get this error.  Is there anyway to avoid building the 
> >> python_ldap binaries?
> > 
> > Disclaimer. I know nothing about python-ldap. I simply
> > Googled for it and came to:
> >   http://python-ldap.sourceforge.net/download.shtml
> > which led me to
> >   http://www.osuch.org/python-ldap
> > from which I downloaded and ran the .msi
> >   http://www.osuch.org/python-ldap-2.3.5.win32-py2.5.msi
> > and Bob was at that point my uncle.
> 
> When reading the original posting I wondered how to make 
> python-ldap's 
> web pages even more clear. Thanks that you pointed out that 
> it seems not 
> necessary. :-)
> 
> Ciao, Michael.
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
--
http://mail.python.org/mailman/listinfo/python-list


need ldap windows binary and/or installation help

2008-07-15 Thread Sells, Fred
I'm running python 2.5 (or 2.4) in an XP environment.

I downloaded and installed the .dll's from 
OpenLDAP-2.4.8+OpenSSL-0.9.8g-Win32.zip and copied the .dll's in 
c:/windows/system32 as instructed

now I get this error.  Is there anyway to avoid building the python_ldap 
binaries?  Apart from being lazy, I've got a secure system policy issue if I 
start compiling apps.  I could give up and just start running in linux, but my 
xp environment is much friendlier to develop in.  I've googled a lot, but all 
the links I've found talk to Unix or to compiling from source.

Even if I build from source, will the mingw compiler mentioned in most posts 
produce something that is compatible with "Python was built with Visual Studio 
2003".

c:\all>easy_install python_ldap
Searching for python-ldap
Reading http://pypi.python.org/simple/python_ldap/
Reading http://pypi.python.org/simple/python-ldap/
Reading http://python-ldap.sourceforge.net/
Reading http://python-ldap.sourceforge.net/download.shtml
Reading 
http://sourceforge.net/project/showfiles.php?group_id=2072&package_id=2011
Best match: python-ldap 2.3.5
Downloading 
http://downloads.sourceforge.net/python-ldap/python-ldap-2.3.5.tar.gz?modtime=1215364319&big_mirror=0
Processing python-ldap-2.3.5.tar.gz
Running python-ldap-2.3.5\setup.py -q bdist_egg --dist-dir c:\documents and 
settings\frsells\local settings\temp\easy_install-uczq5i\python-ld
extra_compile_args:
extra_objects:
include_dirs: /usr/local/openldap-2.3/include /usr/include/sasl
library_dirs: /usr/local/openldap-2.3/lib
libs: ldap_r lber sasl2 ssl crypto
file Lib\ldap.py (for module ldap) not found
file Lib\ldap\schema.py (for module ldap.schema) not found
warning: no files found matching 'Makefile'
warning: no files found matching 'Modules\LICENSE'
file Lib\ldap.py (for module ldap) not found
file Lib\ldap\schema.py (for module ldap.schema) not found
file Lib\ldap.py (for module ldap) not found
file Lib\ldap\schema.py (for module ldap.schema) not found
error: Setup script exited with error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
--
http://mail.python.org/mailman/listinfo/python-list


imaplib -- can't read body

2008-07-11 Thread Sells, Fred
I'm trying to read mail using the imaplib module.  I can get the subject and 
date, but not the body, have not found any example on how to do that and I 
don't know much about imap.  Here's what I have, working as noted...

If anyone can show me what I'm missing in order to get the body of a mail 
message, that would be greatly appreciated,

Fred
--- code starts below---

import imaplib, sys, os, re, rfc822

OK = "OK"

FETCHTHIS = '(BODY[HEADER.FIELDS (SUBJECT FROM)])'

### got inemsg from the web, works up to the last line; msg.fp has no read and 
readline returns empty string.
class inemsg:
def __init__(self,msg):
(self.msgfromname, self.msgfrom) = msg.getaddr('from')
self.msgto = msg.getaddr('to')
self.msgsubject = msg.getheader('subject')
self.msgdate = msg.getheader('date')
self.msgtext = msg.fp.read()


class msg: # a file-like object for passing a string to rfc822.Message
def __init__(self, text):
self.lines = text.split('\015\012')
self.lines.reverse()
def readline(self):
try: return self.lines.pop() + '\n'
except: return ''


class MailReader:
def __init__(self, mailserver, user, password):
self.M = imaplib.IMAP4(mailserver)
self.M.login(user, password)
result, message = self.M.select(readonly=1)
print ( 'constructor', result, message)
if result != OK: raise Exception, message

def getMessages(self, *mailboxes):
if mailboxes:
filter = '(%s)' % ' '.join(list(mailboxes))
else:
filter = '(UNSEEN UNDELETED)'
mtype, data = self.M.search(None, filter )
print ('getMessages', mtype, data)
for num in data[0].split():
f = self.M.fetch(num, FETCHTHIS)
print ('fetch', f)
m = rfc822.Message(msg(f[1][0][1]), 0)
subject = m['subject']
fromaddr = m.getaddr('from')
if fromaddr[0]=='': n = fromaddr[1]
else: n=fromaddr[0]
print (subject, fromaddr) 
return None   #no reason to return until I can get the message 
content/body.   


if __name__=='__main__':
x = MailReader("myserver", "myuser", "mypassword")
messages = x.getMessages()
print messages

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
--
http://mail.python.org/mailman/listinfo/python-list


RE: PyDev multiple source files?

2008-05-30 Thread Sells, Fred
the short answer is

a file is a module; therefore to 'include' access to 'myclass' in file xyz.py 
from another file called 'abc.py'  you would put this in abc.py

import xyz  #note no '.py'
x = xyz.myclass()
or
from xyz import myclass  #if you're lazy use ... import *
x = myclass()

see the basic tutorial on modules and importing

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of RossGK
> Sent: Friday, May 30, 2008 2:10 PM
> To: python-list@python.org
> Subject: PyDev multiple source files?
> 
> 
> Newbie questions on PyDev project setup.   Things are going fine -
> writing python code in eclipse/pydev and running them with various
> imports etc, doing wxpython stuff blah, blah, blah. My .py code is in
> a module, in a package, in a project. It runs fine.
> 
> Now I want to be able to break my single source file up into multiple
> files to segregate functions, divide up with others, etc, but I don't
> know how to configure it. I pulled one simple class definition out of
> my single source file and created a new .py file with just that in
> there. But now I'm stalled...
> 
> What is the equivalent of an 'include' statement. I assume there's
> something I put into one .py file to say I'm using stuff in another
> local .py file.   I tried using "import" but it doesn't seem to work -
> ie code doesn't know about the class in the other file.
> 
> Also, how about global vars that are needed across multiple .py files?
> Where do I declare them to be understood in all the files that use
> that global.
> 
> I suspect there is something I do in __init__.py - perhaps the
> equivalent of 'include' statements in there with all my globals
> stuffed in there too???   I'm lost here, but will continue to play
> with it.  Any hints appreciated.  Surely all python developers don't
> cram everything into one huge file (I hope).
> 
> Ross.
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
--
http://mail.python.org/mailman/listinfo/python-list


RE: adobe flex; return xml via turbogears/django

2008-05-29 Thread Sells, Fred
Diez wrote: 
> Why don't you create KID-template like this:
> 
> ${root}
> 
> and in the controller say
> 
> @expose("thexmltemplate")
> def ...
>return dict(root=myElementTreeRoot)
> 
sounds good.  Does that "py:strip" remove the  and anything outside it.  
I'll be doing a flex style ajax call and it wants just the xml data tree.

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


adobe flex; return xml via turbogears/django

2008-05-29 Thread Sells, Fred
please excuse slightly off-topic; cannot access turbogears mailing list at the 
moment.

There was an excellent video by James Ward that showed using turbogears to 
return json data to adoble's flex UI.  It simply used

@expose("JSON")
def ():
...
return dict(x=1, ...)

Is there any equivalent for xml, such as
@expose("XML")
def 
return myElementTreeRoot

I need to have more attribute data (for a grid) than I can cleanly do in json 
and while pyamf might do the trick, It adds a layer of "magic code" that I 
cannot sell to my team.  Also with xml and json, I can do my UI design with the 
url pointing to a test data file, then build the backend to match.

any ideas?

thanks

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
--
http://mail.python.org/mailman/listinfo/python-list


RE: do you fail at FizzBuzz? simple prog test

2008-05-20 Thread Sells, Fred
or
for i in range(1,100):
  print ('fizz','','')[i%3] + ('buzz','','','','')[i%5] or i

> > 
> > "Write a program that prints the numbers from 1 to 100. But for
> > multiples of three print "Fizz" instead of the number and for the
> > multiples of five print "Buzz". For numbers which are multiples of
> > both three and five print "FizzBuzz".
> > 
> > for i in range(1,101):
> > if i%3 == 0 and i%5 != 0:
> > print "Fizz"
> > elif i%5 == 0 and i%3 != 0:
> > print "Buzz"
> > elif i%5 == 0 and i%3 == 0:
> > print "FizzBuzz"
> > else:
> > print i
> > 
> > 
> > is there a better way than my solution? is mine ok?
> 
> 
--
http://mail.python.org/mailman/listinfo/python-list


RE: Newbie In Python

2008-05-20 Thread Sells, Fred
get a python-aware editor.  I vary between emacs and Eclipse, depending on my 
mood and the size of the project.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Bruno Desthuilliers
> Sent: Tuesday, May 20, 2008 6:25 AM
> To: python-list@python.org
> Subject: Re: Newbie In Python
> 
> 
> [EMAIL PROTECTED] a écrit :
> > I have Heard About "Python" its a OOD Language. 
> 
> 'OOD' => 'object oriented ???' ?
> 
> > i have to Learn it
> > where from i should start it.
> 
> Err... What about reading the docs on python.org - possibly starting 
> with the tutorial:
> http://docs.python.org/tut/tut.html
> 
> You'll find other tutorial etc here:
> http://www.python.org/doc/
> 
> 
> > i have python compiler
> 
> Just for the record, "python" is also the name of a compiler for CMU 
> Common Lisp (totally unrelated to the Python language), so make sure 
> that what you have is the CPython language install.
> 
> HTH
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
--
http://mail.python.org/mailman/listinfo/python-list


RE: Newbie to python --- why should i learn !

2008-05-09 Thread Sells, Fred
write working programs

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of [EMAIL PROTECTED]
> Sent: Thursday, May 08, 2008 6:25 AM
> To: python-list@python.org
> Subject: Newbie to python --- why should i learn !
> 
> 
> Hi,
> 
> i was reading/learning some hello world program in python.
> I think its very simillar to Java/C++/C#. What's different (except
> syntax) ?
> 
> what can i do easily with python which is not easy in c++/java !?
> 
> Tnx,
> Raxit
> www.mykavita.com
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
--
http://mail.python.org/mailman/listinfo/python-list


Need Python alternative to Request-Tracker help desk software

2008-04-29 Thread Sells, Fred
I've been tasked with either implementing Request-Tracker to upgrade our help 
desk issue tracking system or finding a Python equivalent (both in terms of 
functionality and wide spread use).  Request-Tracker uses Apache and MySQL, 
which would also be appropriate to Python.

I would prefer to go the Python route, especially since Request-Tracker is 
written in Perl (which I don't know).

My initial attempts with Google were not useful due to the general nature of 
the keywords.

Are there any suggestions.

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
--
http://mail.python.org/mailman/listinfo/python-list


need help to upload file to webserver

2008-04-08 Thread Sells, Fred
I am automating the client side of a simple web interface.  I need to upload a 
file to a webserver that requires authentication.  I've got the authentication 
working with urllib2 (see below), but the only examples I've found to upload 
files use httplib without authentication.  I'm competent with Python but no 
whiz with web api's.  Could I get a little help please.

-the form I'm trying to simulate looks like this--




 
--my code follows-
import urllib2, urllib, socket, base64, cookielib
import webtools # from 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306
STANDARD_HEADERS = {'User-agent':'Mozilla/5.0 (compatible; MSIE 5.5; Windows 
NT)'}
COOKIEFILE = 'cokies.lwp'
socket.setdefaulttimeout(30)

HTTP = "http://";
HTTPS = "https://";
#IP, UNAME, PW = "." #deleted for security
top_level_url = "http://...";


PasswordManager = urllib2.HTTPPasswordMgrWithDefaultRealm()
PasswordManager.add_password(None, top_level_url, UNAME, PW)
AuthenticationHandler = urllib2.HTTPBasicAuthHandler(PasswordManager)
opener = urllib2.build_opener(AuthenticationHandler)
urllib2.install_opener(opener)


class MyConnection:
def __init__(self, ipaddr="192.168.1.0", uname=None, password=None):
self.SERVER_AND_PORT = "%s:81" % ipaddr
self.UNAME = uname


def getPage(self, url, kwargs, headers=None):
headers = headers or STANDARD_HEADERS
request = urllib2.Request(url, urllib.urlencode(kwargs), headers)
handle = urllib2.urlopen(request)
page = handle.read()
handle.close()
return  page

def getValidationReportsPage(self):  this works
self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/listrpts.exe",{})

def login(self): #this works
try:print 
self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/mainhtml.exe",{})
except: print 'login failed'

def uploadFile(self, filepath):  #? need help here
buffer = open(filepath).read()
headers = dict(STANDARD_HEADERS)  #make a copy
parms = ('file', filepath, buffer )
contenttype, body = webtools.encode_multipart_formdata([], [parms])
headers['Content-Type']= contenttype
data = {'file':body}
self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/upload.exe",data,headers)
   
  

def unittest():
print 'start unittest of '+ __file__
X = MyConnection(uname=UNAME, password=PW)
X.login()
X.uploadFile('testdata/MouseMds.txt')
  
if __name__ == "__main__":
unittest()

 



You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost. 

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Can I run a python program from within emacs?

2008-03-25 Thread Sells, Fred
I use a .emacs file (attached) that some associates gave me nearly 20 years 
ago.  Some of it is OBE now, but it still works for me on both windows and 
Linux.  With this file I can cntrl-c cntrl-c  (i.e. ^c twice to run the current 
buffer).  Don't ask me to explain it, it just works.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Jeff Schwab
> Sent: Thursday, March 20, 2008 11:29 AM
> To: python-list@python.org
> Subject: Re: Can I run a python program from within emacs?
> 
> 
> Grant Edwards wrote:
> > On 2008-03-20, jmDesktop <[EMAIL PROTECTED]> wrote:
> > 
> >> Hi, I'm trying to learn Python.  I using Aquamac an emac
> >> implementation with mac os x.  I have a program.  If I go to the
> >> command prompt and type pythong myprog.py, it works.  Can 
> the program
> >> be run from within the editor or is that not how 
> development is done?
> >> I ask because I was using Visual Studio with C# and, if you're
> >> familiar, you just hit run and it works.  On Python do I use the
> >> editor for editing only and then run the program from the command
> >> line?
> > 
> > http://www.google.com/search?q=emacs+python
> 
> Or achieve a similar (more flexible (IMO), but less smoothly 
> integrated) 
> effect with Vim and GNU Screen.  Until recently, you had to 
> patch Screen 
> if you wanted vertical splits, but now it's in the main line.
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 


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

RE: Looking for very light weight template library (not framework)

2008-03-11 Thread Sells, Fred
As I recall Quixote allowed you to embed html in python.  was actually pretty 
cool.  Havenot tried it in a long time.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Malcolm Greene
> Sent: Thursday, March 06, 2008 8:56 PM
> To: python-list@python.org
> Subject: Looking for very light weight template library (not 
> framework)
> 
> 
> New to Python and looking for a template library that allows Python
> expressions embedded in strings to be evaluated in place. In 
> other words
> something more powerful than the basic "%(variable)s" or "$variable"
> (Template) capabilities.
> 
> I know that some of the web frameworks support this type of template
> capability but I don't need a web framework, just a library that
> supports embedded expression evaluation.
> 
> Use case:
> 
> myOutput = """\
> 
> The total cost is {{invoice.total}}.
> 
> This order will be shipped to {{invoice.contact}} at the following
> address:
> 
> {{invoice.address}}
> 
> This order was generated at {{some date/time expression}}
> """
> 
> Any suggestions appreciated.
> 
> Malcolm
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python web frameworks + adobe flex

2007-11-21 Thread Sells, Fred
slight shift of topic here.

I'm a newbie at standard web stuff.  Mostly java webstart and a little 
mod_python.

I experimented with Adobe Flex and really loved it for doing the front end.  
The backend needs to provide xml, json or AMF (an adobe proprietary binary 
format). For prototyping, I was able to put xml or json responses in text files 
and used that to work out the UI and do some cool demos.  But I never got past 
prototyping, getting stuck in the "which python webfamework is best" mobius 
loop.

My Question: Does anyone have experience with Flex+Python and especially with 
Adobe's AMF.  I've got some time to try to setup a "standard" and am a bit 
short on hands-on experinece.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python web frameworks

2007-11-21 Thread Sells, Fred

-snip--
> 
> Thanks everyone for the response. From the posts I understand that
> Django and pylons are the best. By searching the net earlier I got the
> same information that Django is best among the frameworks so I
> downloaded it and I found it very difficult to configure. I referred
> the djangobook. Is pylons better in terms of performance and ease of
> study compared to Django.
> -- 
I too was confused by the setup, but I got help from the django site and found 
it was worth the effort.  I'm also not too experienced at web "stuff" with 
python FWIW. 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: newbie Q: sequence membership

2007-11-19 Thread Sells, Fred
> >>> a, b = [], []
> >>> a.append(b)
> >>> b.append(a)
did you perhaps mean a.append('b'); b.append('a'); otherwise this seems pretty 
advanced for a newbie


> >>> b in a
> True
> >>> a in a
> Traceback (most recent call last):
>   File "", line 1, in 
> RuntimeError: maximum recursion depth exceeded in cmp
> >>>
> >>> a is a[0]
> False
> >>> a == a[0]
> Traceback (most recent call last):
>   File "", line 1, in 
> RuntimeError: maximum recursion depth exceeded in cmp
> 
> --
> 
> I'm a little new to this language so my mental model on whats going on
> may need to be refined.
> 
> I expect "a in a" to evaluate to "False". Since it does not it may be
> that while checking equality it uses "==" and not "is". If that is the
> reason then  the question becomes why doesn't "a == a[0]" evaluate to
> "False"? As a side, and if that is the reason, is there a version of
> "in" that uses "is"? "a is in a" does not work.
> 
> Thankx,
> Trivik
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Anyone knows how to use xemacs with ipython or python on WinXP? [phishing][html-removed]

2007-11-19 Thread Sells, Fred
you did remember to "byte-compile" the python-mode.el file?

> I am struggling to make the ipython or python works in 
> xemacs. I have been seraching on the internet for a solution 
> for one day. I have put python-mode.el and ipython.el in the 
> load-path and in the xemacs I type: M-x load library ipython. 
> Then M-x py-shell. However, I could not get the ipython 
> command window. emacs only creates a python window. If I exit 
> the xemacs, it will say an active process exit, do you want 
> to kill it? It seems the process is running but it could not 
> display the command window.
>  
> My ipython version is 0.8.1 and python-mode version is 4.76.
>  
> Thanks
>  
> Frank
> _
> 10??1?2???
> http://keyword.jp.msn.com/default.aspx
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Using Python To Change The World :)

2007-11-14 Thread Sells, Fred
It sounds as if this project is a major task based on your current level of 
experience.  That being said, all we "pythonistas" encourage and support anyone 
who is trying to learn/apply python.

Break the problem into 2 parts:
--simulation math of what you're trying to do
--cool visual display (2D is sufficient) to make it interesting and so others 
can grasp what you did

Then the math drives the display, but you can build and test the math using 
text output.

pygame and pysim are good candidates.  There is also www.vpython.org.  Make 
sure you find some tutorial on object oriented programming "OOP" because that's 
the way to build this critter.

I'm assuming you have a fairly powerful PC,  if so you need a decent 
development environment.  google for python IDE or check at python.org.  I use 
Eclipse + PyDev (both free) although there is a wide difference of opinion on 
IDE's.

Remember to eat the elephant one byte at a time. i.e. small steps.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Ant
> Sent: Wednesday, November 14, 2007 6:48 AM
> To: python-list@python.org
> Subject: Re: Using Python To Change The World :)
> 
> 
> On Nov 14, 3:09 am, [EMAIL PROTECTED] wrote:
> ...
> > so here is MY question:
> > how would you replicate a street intersection in python? and
> > furthermore, how would you do you have the cars move up and 
> down those
> > "streets".
> 
> I've never used it, but I'd have thought that pygame would satisfy the
> graphical side of things.
> 
> --
> Ant
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Pyro: ActiveState (wind32) to Unix

2007-10-11 Thread Sells, Fred
I'm using ActiveState python on a windows box to talk to ACtive Directory.  I'm 
running a Pyro Server on the same box.

The client is Linux running std Python 2.4.

It works just fine until the server codes calls some win32com.client api;  then 
I get 


Traceback (most recent call last):
  File "C:\All\projects\AccAdminTools\src\demo002\client\client.py", line 25, 
in ?
unittest()  
  File "C:\All\projects\AccAdminTools\src\demo002\client\client.py", line 21, 
in unittest
properties = ad.getProperties()
  File 
"c:\all\tools\python24\lib\site-packages\Pyro-3.7-py2.4-win32.egg\Pyro\core.py",
 line 390, in __call__
return self.__send(self.__name, args, kwargs)
  File 
"c:\all\tools\python24\lib\site-packages\Pyro-3.7-py2.4-win32.egg\Pyro\core.py",
 line 468, in _invokePYRO
return self.adapter.remoteInvocation(name, 
constants.RIF_VarargsAndKeywords, vargs, kargs)
  File 
"c:\all\tools\python24\lib\site-packages\Pyro-3.7-py2.4-win32.egg\Pyro\protocol.py",
 line 416, in remoteInvocation
answer = pickle.loads(answer)
ImportError: No module named pywintypes

the offending code is 
def getProperties(self):
def getProperties(self):
  attr_dict={}
  adobj=win32com.client.GetObject(self.LdapPath)  #<<

RE: RMI with Pyro et al -- thanks for help

2007-10-11 Thread Sells, Fred
thanks, that should do it

Diez wrote:
> Go install cygwin (but not it's included python-interpreter, 
> or at least
> make sure you have your python path properly under control) 
> and then simply
> start the script from the command-line. And hit C-c if you 
> need it to stop,
> and restart it. Only start it as service if it's deployed.
> 
> Diez
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Problem with MySQL cursor

2007-10-11 Thread Sells, Fred
I don't think you can substitute the table name and column names in the
execute, just values ( I could be wrong)

try building it like this:
sql = "INSERT INTO %s %s VALUES " % (taablename,  columnstuple, '(%s)')
cursor.execute(sql, values)

> Hello,
> I have a function that executes a SQL statement with MySQLdb:
> 
> def executeSQL(sql,  *args):
> print sql % args
> cursor = conn.cursor()
> cursor.execute(sql, args)
> cursor.close()
> 
> it's called like that:
> 
> sql = "INSERT INTO %s (%s) VALUES (%s)"
> executeSQL(sql,  DOMAIN_TABLE, DOMAIN_FIELD, domainname)
> 
> The statement that is printed looks ok (missing quotes, but AFAIK
> cursor.execute does that):
> 
> INSERT INTO domains (domain) VALUES (xgm.de)
> 
> but MySQL prints an error:
> 
> Traceback (most recent call last):
>   File "manage.py", line 90, in ?
> addDomain(domainName)
>   File "manage.py", line 27, in addDomain
> executeSQL(sql,  DOMAIN_TABLE, DOMAIN_FIELD, domainname)
>   File "manage.py", line 22, in executeSQL
> cursor.execute(sql, args)
>   File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", 
> line 163, in
> execute
> self.errorhandler(self, exc, value)
>   File 
> "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 35,
> in defaulterrorhandler
> raise errorclass, errorvalue
> _mysql_exceptions.ProgrammingError: (1064, "You have an error 
> in your SQL
> syntax; check the manual that corresponds to your MySQL 
> server version for
> the right syntax to use near ''domains' ('domain') VALUES 
> ('xgm.de')' at
> line 1")
> 
> I see the error: 2 opening quotes but only 1 closing around 
> domains. But
> where do they come from?
> 
> Note that there are no quotes at print sql % args.
> 
> Thanks,
> 
> Florian
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: RMI with Pyro et al

2007-10-11 Thread Sells, Fred
Diez B. Roggisch wrote 
. Why do you want that (hot deploy)
> anyway? Does startuptime of a script really bother you? 
> shouldn't take 
> more than a few seconds.

My primary need is development/debug.  I'm a Pyro newbie and I add a
feature and then test.  The only way I've found to kill the Pyro server
on XP is to open the task manager and kill the python task (hopefully
the right one).

 

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


RMI with Pyro et al

2007-10-10 Thread Sells, Fred
I need a simple client/server architecture with clients on linux and servers on 
windows.  There is no UI in this part, just business rules and access control.

Pyro seems pretty cool for this due to it's simplicity.  I'm just starting with 
it and have not been able to get the server side to "see" changes to a module.  
The only way I can stop the server is with the Task Manager.  Can anyone offer 
some insight into
1. stopping/starting the server - perhaps as a windows service.
2. getting the server to recognize new modules "on the fly", i.e. when the .py 
file is changed.

I'm not doing any UI stuff, so I don't want to deal with HTTP and a webserver.  
I also do not have any RDBMS involved. I like the idea of passing objects the 
way pyro does it.

If anyone thinks there is a better python tool for doing this, I would like to 
know.

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Mysqldb printing sql and params ... NEVER MIND

2007-10-02 Thread Sells, Fred
el stupido here "accidently" put a couple of print statements into a
mysqldb module when eclipse opened it from the link in the stacktrace;

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


Mysqldb printing sql and params no matter what I do

2007-10-02 Thread Sells, Fred
I had some code originally that printed the sql and params when I called
the .execute method.  I removed it but it still prints.  I rebooted and
renamed files and still it prints.  I am totally stumped; I tried google
but perhaps didn't use the right search; got a lot of hits but no clues.

I'm using MySQLdb 1.2.2 and python 2.4.4 on XP

here is a snipppet that shows problem.
import MySQLdb
from datetime import *

DBSERVER='localhost'
DBSCHEMA='mds81'
sql = '''SELECT aid  from assessments WHERE xmitdate  between %s AND %s
LIMIT 9'''


class _record:
def __init__(self, adict):self.__dict__=adict

class CaptainQuery:
def __init__(self, host, schema):
self.Connection = MySQLdb.connect (host=host, db=schema)
self.dictcursor =
self.Connection.cursor(cursorclass=MySQLdb.cursors.DictCursor)
print '--before execute'
self.dictcursor.execute(sql, (20070201, 20070630) )
print 'after execute---'
records = self.dictcursor.fetchall()
for r in records: print r

 
Q = CaptainQuery(DBSERVER, DBSCHEMA )

- the output is below-

--before execute
SELECT aid  from assessments WHERE xmitdate  between %s AND %s LIMIT 9
(20070201, 20070630)
after execute---
{'aid': 16711L}
{'aid': 16712L}
{'aid': 16713L}
{'aid': 16715L}
{'aid': 16845L}
{'aid': 16849L}
{'aid': 16850L}
{'aid': 16851L}
{'aid': 16852L}

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to Start

2007-09-14 Thread Sells, Fred
I like eclipse+pydev; although I did pay my dues learning the basics of
eclipse. F9 saves file and runs it.

If you're an emacs dude, emacs + python mode is pretty good.  ctrl-c
ctrl-c runs the active buffer.  Of course if you don't already know
emacs, avoid it like the plague.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Michael R. Copeland
> Sent: Thursday, September 13, 2007 6:00 PM
> To: python-list@python.org
> Subject: How to Start
> 
> 
>I've decided that Python is a language/environment I'd 
> like to learn 
> (I've been a professional programmer for 45+ years), but I 
> really don't 
> know where and how to start!  I have a number of books - and 
> am buying 
> some more - but because of the bewildering number of after-market 
> packages, environments, and add-ons, I am really quite 
> perplexed about 
> starting.  8<{{
>Yes, I could fire up the interactive mode and play with some 
> statements...but I consider that sort of thing for 
> programming neophytes 
> or experimenting with specific issues.  First, I want to develop a 
> simple Windows application, and because of the plethora of 
> "stuff" the 
> Python world offers, I don't know where to begin.  
>For example, what basic, easy-to-use interface might I 
> start with to 
> build a simple text file parsing and analysis program?  That is, I'd 
> like to start with a simple Windows shell that prompts for a 
> file name, 
> processes it, and then displays some result.
>I am certainly impressed with the apparent experience and 
> openness of 
> the regular players here, but the discussions here (and in 
> c.l.p.announce) truly presume knowledge and experience with Python I 
> don't yet have.  Yes, for even a very experienced programmer, 
> entering 
> the Python world is very daunting - but I want to get started.
>Please advise.  TIA
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Filemaker interactions

2007-08-28 Thread Sells, Fred
filemaker 8.0 (Pro I think) has a web page generator.  That's all I
know, since I didn't really need it.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of M.-A. Lemburg
> Sent: Saturday, August 25, 2007 4:36 PM
> To: Ian Witham
> Cc: python-list@python.org
> Subject: Re: Filemaker interactions
> 
> 
> On 2007-08-01 23:41, Ian Witham wrote:
> > Hello,
> > 
> > I'm hoping someone here can put me on the right track with 
> some broad
> > concepts here.
> > 
> > What I am hoping to achieve is a simple HTML page to be served over
> > our company LAN, into which the users (Real Estate Agents) 
> can enter a
> > property address or reference number.
> > 
> > My next thought was to have a Python CGI script query our filemaker
> > database of property listings, construct a PDF from the relevant
> > information, and finally return this PDF to the user.
> > 
> > At no stage do I want the user to have unfettered access to the
> > database or the ability to alter/delete records.
> > 
> > My question is: what is the most appropriate way for my script to
> > interact with Filemaker? Can this be done with Filemaker Pro 6?
> > 
> > According to the Filemaker Help, the "Local Data Access Companion"
> > shares the FileMaker Pro database with ODBC-compliant 
> applications on
> > the same computer. Is this the right option?
> > 
> > Can my CGI script be an ODBC client? How? Would it need to be
> > Filemaker specific code or does ODBC have a standardised format?
> > 
> > I'm grateful for any advice and a nudge in the right direction.
> 
> You could try our mxODBC extension for Python which will
> likely just work out of the box:
> 
> https://www.egenix.com/products/python/mxODBC/
> 
> with the Filemaker ODBC driver.
> 
> Or give this module a try (if you have more time at hand
> and can do without a DB-API interface):
> 
> http://www.lfd.uci.edu/~gohlke/code/filemaker.py.html
> 
> It uses Filemaker's XML interface.
> 
> -- 
> Marc-Andre Lemburg
> eGenix.com
> 
> Professional Python Services directly from the Source  (#1, 
> Aug 25 2007)
> >>> Python/Zope Consulting and Support ...
> http://www.egenix.com/
> >>> mxODBC.Zope.Database.Adapter ... 
> http://zope.egenix.com/
> >>> mxODBC, mxDateTime, mxTextTools ...
> http://python.egenix.com/
> __
> __
> 
>  Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for 
> free ! 
> 
> 
>eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>Registered at Amtsgericht Duesseldorf: HRB 46611
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


best SOAP module

2007-07-18 Thread Sells, Fred
I need to talk to a vendor side via SOAP,  Googling is overwhelming and many
hits seem to point to older attempts.

Can someone tell me which SOAP module is recommended.  I'm using Python 2.4.

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


python app to emulate terminal to dialup bulletin board

2007-07-03 Thread Sells, Fred
We need to automate the download of data that is now done manually via a
terminal session to a dialup bulletin board.  The user uses this to upload
and download files.  Hard to believe in this day and age, but true.

I've tried google, but the terms are just too common; all I get is clutter.

So I need a python module (or snippets) that:
1. setup and execute a standard dialup with appropriate parity,
stop-bits, etc
2. can emulate hyperterm including sending and receiving files

I know anything worth doing has already been done in python by someone, but
I have not had much luck finding it.  Perhaps I just don't know the best
words to put into google.

can I get a few helpful links for y'all.

thanks.



---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: MySQL -->Python-->XML for JSviz

2007-07-03 Thread Sells, Fred
Sometimes sneaky is better than elegant.  You could shell down to a command
line invocation of mysql and specify -xml as the output format.  I'm not
sure how close that format is to what you need or how much you could
leverage views (if using mysql 5.0). You could also use a command line xslt
processor to then redefine your xml output.  That way your data extraction
is one task and you could have many xsl files to convert as needed.

I have used parts of this technique and found it easy to create and debug;
but I have not used the xml output option of mysql.

I'm sure others will point out many excellent xml modules.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Picio
> Sent: Tuesday, July 03, 2007 10:08 AM
> To: python-list@python.org
> Subject: MySQL -->Python-->XML for JSviz
> 
> 
> Hello all, I need some advice to choose an xml generator for jsviz a
> tool in javascript to create some wonderful graphs (SnowFlake or Force
> directed).
> 
> Starting from a SQL table (mysql) I need to create a XML file with a
> structure like this:
> 
>   
>   
>   
>   
>   
>   
> 
> 
> Where nodes attributes are the MySQL table fields (the PK will be the
> attribute).
> I know there are a lot of good tools to do this in pyhton (some maybe
> is already shipped with pyton itself), but since I need a lot of
> flexibility for the future I'd like to use an Object relational mapper
> like SQLAlchemy or SQLObject todo the job. When I say flexibility, I
> have in mind a solution to have multiple formats coming outside of the
> ORM:
> json, csv, plain text etc...
> Am I wrong?
> Can someone advice something?
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Evolution of a pythonistas!

2007-06-28 Thread Sells, Fred
this one is fun: http://www.vpython.org/

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of swordofrue
> Sent: Thursday, June 28, 2007 1:50 PM
> To: python-list@python.org
> Subject: Re: Evolution of a pythonistas!
> 
> 
> Thanks everyone for your responses. I am really loving this. Installed
> Pygame and playing some of those games. It just amazes me how much
> effort some of these games take. I am reading the source and am just
> amazed by the effort and organizational ability of the authors.
> Perhaps one day I will such mad skills :)
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Evolution of a pythonistas!

2007-06-28 Thread Sells, Fred
> 
> Wow Fred! You're awesome! How did you get 20 years in of Python when
> it was created in 1991? 

You're right, programming skills exceed basic math.  I think I started
around 1990 with version 0.92 beta.

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


RE: Evolution of a pythonistas!

2007-06-28 Thread Sells, Fred
concur 100%.  You can breeze through the fist half of the online tutorial in
a about 2 cups of coffee but you don't know what you don't know until you
try to do something real.

Even with 20 years of working with Python, I find goodies in the cookbook
for each new project.

Get a python aware editor.  I use Eclipse+PyDev for big jobs, but still use
Emacs with python-mode for quickies.  Although I would never recommend Emacs
to someone who does not already know how to use it.  IDLE is ok, for
beginning but I find it distracting.  Eclipse can be intimidating at first,
but if you go through the PyDev howto's, You'll learn all you need.

Forget about typing stuff interactively, It is better to work in a file so
you can see your work evolve.

Finally, I have never had a project in the last 5 years that someone hasn't
already done.  Google is your friend.  Many of the hits are misleading or
too much code to fit what I need, but I often find a snippet that I can use.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of BartlebyScrivener
> Sent: Thursday, June 28, 2007 8:18 AM
> To: python-list@python.org
> Subject: Re: Evolution of a pythonistas!
> 
> 
> On Jun 28, 6:46 am, swordofrue <[EMAIL PROTECTED]> wrote:
> > Hello everyone,
> >
> > How does a pythonistas evolve?
> >
> 
> Get the Python Cookbook 2d, pick a useful looking project, and adapt
> it for your own needs. Learn by doing. Some people enjoy just doing
> the tutorials with the interpreter open, testing code line by line.
> That works, too. But often the most gratifying is to solve a problem,
> or make a useful script that does something you need, which saves you
> time--time you can invest in learning more Python. :)
> 
> rd
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Help With Better Design

2007-06-25 Thread Sells, Fred
> IMHO ... untested
> 
> class LightBulb:
>   def __init__(self, on=False): self.IsOn = on
> 
>   def turnOn(self): self.switchIt(True)
>   def turnOff(self):self.switchIt(False)
> 
>   def switchIt(self, turnon):
>   if self.isOn==turnon: print "The Switch is Already %s" %
(["ON", "OFF"][self.isOn])
>   else: self.isOn = turnon #or alternatively =!self.isOn
> 
>   def __repr__(self): return ["ON", "OFF"][self.IsOn]
> 
> 
> 
> > --- [EMAIL PROTECTED] wrote:
> > > 
> > > ON  = "ON"
> > > OFF = "OFF"
> > > 
> > > class LightBulb:
> > > def __init__(self, initial_state):
> > > self.state = initial_state
> > > 
> > > def TurnOn(self):
> > > if self.state == OFF:
> > > self.state = ON
> > > else:
> > > print "The Bulb Is Already ON!"
> > > 
> > > def TurnOff(self):
> > > if self.state == ON:
> > > self.state = OFF
> > > else:
> > > print "The Bulb Is Aleady OFF!"
> > > 
> > 
> > I've written code that looks a lot like that, and it's
> > a perfectly acceptable pattern IMHO.  I don't bother
> > with the variables ON and OFF, though, as they add no
> > clarity to simply using 'ON' and 'OFF' for the states.
> > 
> > 
> > > [...]
> > > The test portion of the code is actually longer than
> > > the class
> > > itself :-) 
> > 
> > That's usually a good thing!  It means your code is
> > concise, and your tests are exhaustive.  (But that
> > doesn't mean you can't also refactor your tests.)
> > 
> > 
> > 
> >
> > __
> > __
> > Be a better Globetrotter. Get better travel answers from 
> > someone who knows. Yahoo! Answers - Check it out.
> > http://answers.yahoo.com/dir/?link=list&sid=396545469
> > -- 
> > http://mail.python.org/mailman/listinfo/python-list
> > 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: pydev help

2007-06-20 Thread Sells, Fred
uncheck mylar and it should work.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Christopher L Judd
> Sent: Tuesday, June 19, 2007 9:00 AM
> To: Danyelle Gragsone
> Cc: python-list@python.org
> Subject: Re: pydev help [html-removed]
> 
> 
> Its called mylyn now.  You can get it from here:
> http://www.eclipse.org/mylyn/dl.php
> 
> Best,
> Chris
> 
> On 6/19/07, Danyelle Gragsone <[EMAIL PROTECTED]> wrote:
> >
> > My first post!
> >
> > Greetings all,
> >
> > I am trying to get pydev up and running in linux.  I have it up and
> > running in windows but for some strange reason not here.  I did
> > install pydev a few months ago on my windows machine so that may be
> > the reason why..
> >
> > I followed this guide: 
> http://www.fabioz.com/pydev/manual_101_install.html
> >
> > When I get to about the middle of the page where it 
> seemingly loading
> > everything and I get this: Pydev Mylar Integration (0.2.0) requires
> > plug-in "org.eclipse.mylar (2.0.0.v20070403-1300)", or 
> later version."
> >
> > Where do I get that module from?
> >
> > Thanks,
> > Danyelle
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Beginning Python

2007-06-06 Thread Sells, Fred
I find 3 elements contribute significantly to becoming competent in python

1.  a decent IDE so you can see the big picture (multiple files and
directories). I use Eclipse + PyDev because Eclipse supports other goodies
like CVS.  I'm sure other IDE's are as good if not better, but who has time
to check them all out.

2.  Looking at others examples especially when solving real-world problems.
I've learned much from the Python Cookbook even though I've used Python for
15 years.

3.  Building a real-world application where you cannot change the
requirements to fit your current knowledge.

of course that's just my opinion, I could be wrong :)

---snip---
> 
> Seriously, there is no way for anyone to predict how long it will  
> take you to learn something.  In this case, that something (Python)  
> is a moving target -- there are a few things I use daily that 
> weren't  
> even part of the language when I started.
> 
> I do believe that it takes about three years to get reasonably  
> competent at anything.  And about ten years to get really 
> good at it.  
> And probably another ten years to be a master (I'm only guessing  
> though -- because I haven't been doing anything for twenty years  
> yet).  Of course, by my metrics I guess even Guido wouldn't be a  
> master at Python so perhaps I'm full of crap :-)
> 
> Hope this helps,
> Michael
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Graph plotting module

2007-06-05 Thread Sells, Fred
www.vpython.org might be overkill, but it was easy to do simple 2d charts.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Behalf Of Grant Edwards
> Sent: Monday, June 04, 2007 11:23 AM
> To: python-list@python.org
> Subject: Re: Graph plotting module
> 
> 
> On 2007-06-04, Viewer T. <[EMAIL PROTECTED]> wrote:
> 
> > Is there a python module anywhere out there that can plot straight
> > line graphs, curves (quadratic, etc). If anyone knows where I can
> > download one, please let me know.
> 
> gnuplot-py
> matplotlib
> 
> -- 
> Grant Edwards   grante Yow! BARRY 
> ... That was
>   at   the most 
> HEART-WARMING
>visi.comrendition 
> of "I DID IT MY
>WAY" I've 
> ever heard!!
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: MySQLdb insert fails on one table

2007-06-01 Thread Sells, Fred
thank you! that was it.

I created the table using a create table (select from

which must have defaulted to InnoDb, now I just create it in a script.

> -Original Message-
> From: Carsten Haese [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 01, 2007 8:56 AM
> To: Sells, Fred
> Cc: python-list@python.org
> Subject: Re: MySQLdb insert fails on one table
> 
> 
> On Fri, 2007-06-01 at 11:48 -0400, Sells, Fred wrote:
> > INSERT INTO valid_individuals (fname,lname,alias,email) 
> VALUES (%s,%s,%s,%s)
> > [['', '', 'z', 'aa']]
> > 
> > this function works fine for several other tables, but on 
> this one I get no
> > errors and there is nothing in the table.  If I run the 
> equivalent insert on
> > the command line, it's just fine.
> 
> This usually indicates that the table is transaction-aware 
> (e.g. storage
> mechanism InnoDB versus MyISAM) and you're not committing your
> transaction, so the transaction gets rolled back when your 
> connection is
> closed.
> 
> HTH,
> 
> -- 
> Carsten Haese
> http://informixdb.sourceforge.net
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


MySQLdb insert fails on one table

2007-06-01 Thread Sells, Fred
I have this table

mysql> describe valid_individuals;
+---+--+--+-+-+---+
| Field | Type | Null | Key | Default | Extra |
+---+--+--+-+-+---+
| fname | varchar(30)  | YES  | | NULL|   |
| lname | varchar(30)  | YES  | | NULL|   |
| alias | varchar(30)  | YES  | | NULL|   |
| email | varchar(100) | YES  | | NULL|   |
+---+--+--+-+-+---+


I call this function

def insertRecords(self, tablename, columnnames, values, clear=True):
cursor = self.Connection.cursor()
sql = "INSERT INTO %s (%s) VALUES (%s)"  % (tablename,
','.join(columnnames), ','.join(['%s' for x in columnnames]))
print >>sys.stderr, sql, values[:3]
cursor.executemany(sql, values)
cursor.close()
which prints:
INSERT INTO valid_individuals (fname,lname,alias,email) VALUES (%s,%s,%s,%s)
[['', '', 'z', 'aa']]

this function works fine for several other tables, but on this one I get no
errors and there is nothing in the table.  If I run the equivalent insert on
the command line, it's just fine.

I'm lost here; Python 2.4.4 and latest MySQLdb for 2.4.4;  anyone got a
clue?

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python Web Programming - looking for examples of solidhigh-tr affic sites

2007-05-21 Thread Sells, Fred
I just started using flex (flex.org) from Adobe for the front end and am
quite amazed at what it can do.  Good docs.  Clean client/server api if you
like xml.  It's relatively new so you still have to turn over some rocks and
kiss some frogs to figure out how to get exactly the behavior you want in
some cases.

of couse the end result is that you're running flash on the client, but if
you don't use the extensive special effects, you may be ok.  If flash is
politically correct, you don't have to worry about server variants.

Still use python on the server side.

I might even consider writing python classes to generate their http://mail.python.org/mailman/listinfo/python-list


RE: Fortran vs Python - Newbie Question

2007-03-26 Thread Sells, Fred
1. Python is fun!
2. Python is cool!
3. Most of the time you can google a solution, i.e. somebody has already
done nearly everything you can think of.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Monday, March 26, 2007 8:21 AM
To: python-list@python.org
Subject: Fortran vs Python - Newbie Question


OK...
I've been told that Both Fortran and Python are easy to read, and are
quite useful in creating scientific apps for the number crunching, but
then Python is a tad slower than Fortran because of its a high level
language nature, so what are the advantages of using Python for
creating number crunching apps over Fortran??
Thanks
Chris

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

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


RE: Choosing Python

2007-03-19 Thread Sells, Fred
glad to hear it.  Those of us who would like to introduce it in reluctant
schools elsewhere could benefit from a post-semester evaluation, including
student comments and some sample, running projects.  

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Sunday, March 18, 2007 9:22 PM
To: python-list@python.org
Subject: Choosing Python


The choice is made.   The school where I teach has finally
made its decision to teach Python first.For several years,
we have been teaching Java first, and before that, C++.

I introduced Python in one of my courses and got a lot of
flak from some of the other faculty.  I also introduced Ruby,
and got even more flak.   In my course, the students loved
Python for its simplicity, its power, and its flexibility.

It is clear that Python is not the ultimate, one-size-fits-all
language.  No language is.  However, for a beginner's
language it is nearly ideal.   Further, it is a great language
for a wide range of serious programming problems.

For large-scale, safety-critical software, I still prefer Eiffel
or Ada.   Java could vanish tomorrow and, with Python
and Ruby available, no one would miss Java at all.  As for
C++, for any serious software systems, it should always be
the language of last resort.   C++, as an object-oriented
assembler, is pretty much its own virus.

Already, students are turning in really good projects in Python,
and some in Ruby.   Not all the professors are on-board with
this decision, but in time I think they will be.

Richard Riehle 


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

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


RE: Need help with apack compression code

2007-03-16 Thread Sells, Fred
try google: "python apack" found several 

in general, always google first; python has so many devotees that someone
has generally solved most problems already.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of priya kale
Sent: Thursday, March 15, 2007 11:33 PM
To: python-list@python.org
Subject: Need help with apack compression code [html-removed]


I need to code for decompressing the file which is compressed using Apack, I
am supposed to code it in visual c++, Plz help me finding algorithm
compatible to Widows based C or c++.

Regards,
 Priya Kale
(Pune)
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Mocking OpenOffice in python?

2007-03-14 Thread Sells, Fred
I currently use Java to generate a 150 page PDF from about 50 .odt files,
including replacing occurrances of about 10 "place-holder" phrases from data
in our system.  I do not use the OOo database/mailmerge features, just UNO.
This process takes about 20 seconds on my 2 year old XP laptop and about 10
seconds on our Linux doc server.

So the key problem may be your approach to generating the OO being to slow,
rather than needing a way to speed up testing.

I use a std java property file/url to define the search/replace pairs and to
contol insert of the conditional documents.

FWIW the internal .odt is XML once it is unzipped.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of PaoloB
Sent: Wednesday, March 14, 2007 9:11 AM
To: python-list@python.org
Subject: Re: Mocking OpenOffice in python?


On 14 Mar, 14:48, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Wed, 2007-03-14 at 01:39 -0700, PaoloB wrote:
> > Hi everyone,
>
> > during our development, we need to write some unit tests that interact
> > with OpenOffice through pyUno.
>
> > Is there anyone who has got any experience on it? As OpenOffice is
> > quite a large beast, and interaction is rather complex, I would like
> > to know if there is someone who is willing to share experience (and,
> > possibly, code).
>
> I have some experience with pyuno, but your question is very open-ended.
> It would be helpful if you asked specific questions or gave more
> background on what kind of interaction you're trying to achieve.
>
> The generic answer to your request for code examples is that there's a
> tutorial with example code
athttp://udk.openoffice.org/python/python-bridge.html, and then there's
> the API documentation
athttp://api.openoffice.org/DevelopersGuide/DevelopersGuide.html.
>
> -Carsten

Hi Carsten,

basically, our project (PAFlow) is an application for producing
documents in public administrations.

We create templates using OpenOffice, that are filled automatically
using data from the application itself.

Now, interacting with OpenOffice is slow, and our tests get a lot of
time to be executed automatically.

We are trying to mock OpenOffice, so that we can run our tests without
using a true OpenOffice for our tests, except when we express test the
filling of data and production of document.

Ciao

PaoloB


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


RE: i can`t get python working on the command line (linux)

2007-03-13 Thread Sells, Fred
looks like it is expecting command line agrs that are not there.

put this at the top of your code to see what's going on

import sys
print sys.argv

remembering that the first element printed is sys.argv[0]



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of Mark
Sent: Tuesday, March 13, 2007 10:04 AM
To: python-list@python.org
Subject: i can`t get python working on the command line (linux)
[html-removed]


Hey,

first of all: sorry for the 100% n00b question
i`m brand new to python and i seem to start off with the biggest problem of
all.. not even getting python to work.
i`m running Fedora core 7 test 2 and all the python based applications are
working fine (like pirut, pipet, and some other yum related tools)

but when i try to run this script:

#!/usr/bin/python
#
# python script tel.py
# gevonden door Jan Mooij 24 september 2000
#
from sys import *
from string import *

 # Create an empty dictionary.
count = {}

for line in open(argv[1], 'r').readlines():
for word in split(line):
if count.has_key(word):
count[word] = count[word] + 1
else:
count[word] = 1
words = count.keys()
words.sort()
for word in words:
print "%15s\t%10d" % (word, count[word])


and i`ve put it in tel.py (just the same as in the sample) than chmod
it to 777 (just to make sure it isn`t a permission issue) and than i
run it with: ./tel.py
now this is the error that i get:

Traceback (most recent call last):
  File "./tel.py", line 12, in 
for line in open(argv[1], 'r').readlines():
IndexError: list index out of range

also i`m not even getting the most simple sample code to work.. "Hello
World".
everything works fine when i first enter the python console by typing
python. than i have the  >>> things
than print "Hello World" gives me the expected result but that`s not
what i want.. i want to do it from a file..

the solution is probable extremely simple but i have no idea as a
complete n00b in python. i do have alot php experience.
hope someone could help me out with this.

o and any function that i use in python gives me "command not found:
print/whatever function i use"
(probable just a simple yum install command that i need to do to get
this working.. just try to figure that out with no python knowledge)

Thanx alot in favor.
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Eric on XP for Newbie

2007-02-28 Thread Sells, Fred
I've been using Eclipse with the PyDev extension.  it's not bad, although
you need a reasonably powerful computer to handle the bloat of Eclipse.

For short programs, I still like emacs, but I'm old school.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of SPE - Stani's Python Editor
Sent: Wednesday, February 28, 2007 1:38 PM
To: python-list@python.org
Subject: Re: Eric on XP for Newbie


On Feb 28, 6:15 pm, [EMAIL PROTECTED] wrote:
> On Feb 28, 4:27 pm, Alan Franzoni
>
> <[EMAIL PROTECTED]> wrote:
> > Il 28 Feb 2007 08:13:42 -0800, [EMAIL PROTECTED] ha scritto:
>
> > [cut]
>
> > Forget the tars.
>
> >http://www.quadgames.com/download/pythonqt/
>
> > Get the two EXEs here. BTW, I don't think Eric3 is a really good IDE on
> > Windows (yet). Try something likeSPE, or Scite, or any other editor like
> > UltraEdit32.
>
> Thanks
>
> I've installedSPE. But what now? How do I run it? It doesn't appear
> in "all programs" and ther's no .exe file that I can find

Which installer did you use? If you used the python25 installer, use
the python24 installer instead. (It will also work as it is not
specific to 2.4 I have removed the python25 installer.) Than the
shortcuts should appear in your "All Programs".

Stani

PS. A new version is about to released: http://pythonide.stani.be

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

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


RE: Testers please

2007-02-13 Thread Sells, Fred
cool product, I'll test depending on schedule at the time.

one (more) suggestion (from those of us who arn't doing the work ;) is to
put this in eclipse, rather than apache, since many developers work with it.
Please no IDE wars, I like emacs too, but when I'm trying to teach to
newbies I use elcipse.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of martien friedeman
Sent: Monday, February 12, 2007 8:38 PM
To: python-list@python.org
Subject: Testers please


I have written this tool that allows you to look at runtime data and  
code at the same time.
And now I need people to test it.

The easiest way to see what I mean is to look at some videos:
http://codeinvestigator.googlepages.com/codeinvestigator_videos

It requires Apache and Sqlite.

It works for me with a Firefox browser on Linux. 
  
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How can I access data from MS Access?

2007-02-05 Thread Sells, Fred
Peter, I sadly admit that I was wrong. "Doesn't seem to work" is 
effectivly even more useless than "doesn't work". I give up.

Years ago we used to get our FORTRAN card decks back from the DP center
with a piece of scrap paper saysing "She No Work".  top that.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python tools to manipulate JARs ?

2007-01-31 Thread Sells, Fred
I have not tried this, but...
Assuming jython is out of the question
You might want to try a simple java command line program you could run from
popen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of Andy Dingley
Sent: Wednesday, January 31, 2007 11:11 AM
To: python-list@python.org
Subject: Python tools to manipulate JARs ?


I run build processes for a Java shop using Python (and some Ant).

Would anyone care to suggest favoured tools for manipulating the
innards of JARs? Or do I just treat them as plain zipfiles and get
stuck right in there?

Mainly I'm trying to query lists of classes and their embedded
versions and do some library dependency reporting. Performance speed
is starting to be an issue, as there's 1500+ classes in this bucket
and it's an interactive query.

Thanks for any suggestions

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


OpenOffice 2.0 UNO update Links; need help

2007-01-21 Thread Sells, Fred
I've got a ~100 page document I assemble from ~30 OOo .odt files with some
search and replace functions.  I then produce a PDF.  So far so good.

Now I need to get a barcode from our internal website and insert that.  The
barcode will vary based on some parameters.  Our internal site provides a
.jpg image (or .gif) based on those parameters.

Can anyone provide a snippet or some pointers on how to do this.  I've
googled it to death and checked the OOo DevGuide to no avail.

Either python or java solution is acceptable.


---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Async callback in python

2006-12-06 Thread Sells, Fred
the standard print gets "delayed" somewhere inside python, however if you
use

print >>sys.stderr, "whatever", 3, 4 5

that prints immediately, or so it seems to me.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of Linan
Sent: Monday, December 04, 2006 11:18 PM
To: python-list@python.org
Subject: Async callback in python


Hi,

In javascript, code could be written like this:

...

var _p=XMLHttpRequest();
_p.open('GET',url,true);
_p.send(null);
_p.onreadystateChange=function(){
if(_p.readyState==4)
cb(_p.responseText);
}
...

This basic AJAX code allows function to be called when it's invoked,
without blocking the main process. There is same library asyncore in
python. However, I can't validate it's asynchronous through code:
class T(asyncore.dispatcher):
def __init__(self,host,url):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect((host,80))
self.url='GET %s HTTP/1.0\r\n\r\n' % url

def handle_connect(self):
pass

def handle_close(self):
self.close()

def handle_read(self):
print 'READING.'
print self.recv(256)

def handle_write(self):
sent=self.send(self.url)
self.url=self.url[sent:]

t=T('aVerySlowSite','/')
asyncore.loop()
for i in range(0,10):
print '%d in main process' % i
time.sleep(1)

Suppose it's asynchronous, couple of '%d in main process' lines should
be mixed in the output of T.handle_read(), right? But I found that
actually main process was blocked at asyncore.loop(), until the the
socket was closed. My questions:
1, Did I do anything wrong?
2, Is it real asynchronous?
3, If not, where to get the real one(s)?

Any comment is welcome :)

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


RE: python vs java eclipse

2006-12-02 Thread Sells, Fred
If you're in the PyDev perspective, F9 runs the current script while
ctrl-F11 reruns the last script run.  I have found that certain types of
operations just plain don't work this way and must be run from a
conventional shell window.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of krishnakant Mane
Sent: Friday, December 01, 2006 6:19 AM
To: python-list@python.org
Subject: Re: python vs java eclipse


just used the py dev plugin for eclipse.
it is great.
auto indentation and intellisence.
and all other things.
so now how does it look from this end?
python + productivity and eclipse + productivity = double productivity!
only problem with the plugin is that I find it difficult to manage the
script running.
I open a command prompt and run the scripts manually.
any suggestion for this.
for example I had name = raw_input("please enter your name") and the
moment I type the first letter on the keyboard the code execution
moves over to the next statement.  should it not wait for the return
key as it always does?
Krishnakant.
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python work in UK

2006-11-29 Thread Sells, Fred
The technical director of Cabletron used to write applications in Python,
then give the working product/code to the development group to convert.
Perhaps you could build stuff in Python and outsource the conversion to
India?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of Steven Wayne
Sent: Friday, November 24, 2006 10:42 AM
To: python-list@python.org
Subject: Re: Python work in UK


On Thu, 23 Nov 2006 19:28:26 +, Will McGugan
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'd love to work in Python, for the sake of my blood pressure, but there 
> doesnt seem to be that many jobs that look for Python as the main skill. 
> I use Python at work from time to time, and occasionaly get to spend 
> several days on a Python project but the majority of the time I use C++. 
> How can I make that leap to working with Python? There doesn't seem to 
> be many UK positions on the jobs section of Python.org or the usual jobs 
> sites. Any recommended jobs sites or tips? (I have googled)
>
> In the off chance that a potential empolyer is reading this, I'm looking 
> for something in web development, applications, graphics or other 
> interesting field. Here is a copy of my CV.
>
> http://www.willmcgugan.com/cvwillmcgugan.pdf
>
> Regards,
>
> Will McGugan

www.riverhall.co.uk are looking.

Steven
-- 
 .''`.
: :'  :
`. `'`
  `-
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: CGI Tutorial

2006-10-06 Thread Sells, Fred
content is great, my comments are editorial.

I prefer PDF with bookmarks rather than HTML. 
1. easy to print the whole thing and read offline.
2. easy to find a secion from bookmarks, rather that chasing links
3. easy to save on my local "doc" folder so I can be sure It will always be
there.  (i.e. I don't have to try to find it when you change servers)

Of course that's just my opinion, I could be wrong ;)

If you choose to go the PDF route, I've found OpenOffice 2.0 pretty good at
generating PDF with bookmarks.  Just don't get too complex or OO may hose
you.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Where is Python in the scheme of things?

2006-10-05 Thread Sells, Fred
Every C++ and Java programmer that I know, who have done a moderate sized
project in Python (thus requiring learning it's strengths) states that they
hope to never go back to C++ or Java.

I cannot comment on VB programmers, since I don't speak to them ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: CGI -> mod_python

2006-10-03 Thread Sells, Fred
I'm confused.

is WSGI only a specification, or are there implementations, and if so which
ones
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: ideas for programs?

2006-05-31 Thread Sells, Fred
to regurgitate what others have said.

trying to solve a real-world problem is significantly more educational that
writing toy programs and class assignments.

Solving a real-world problem will generate more interest in your potential
ability that knowing any language.

Pick a problem that you and others you know would like to have solved, then
you can get support, feedback and motivation to keep going.

good luck!

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


pyuno and PDF output

2006-05-04 Thread Sells, Fred
I can use java to output a PDF file using uno, but when I try to do it in
python, I get an IO Exception with no added information.   The relevant code
snippet follows:

from com.sun.star.beans import PropertyValue
PDF= PropertyValue( "FilterName" , 0 , "writer_pdf_Export", 0 )
doc2.storeAsURL("file:///C:/alleclipse/OpenOffice/test2.pdf", (PDF,) )

if I don't specify any properties, it writes an "odt" file just fine, but
when I specify (PDF,) it breaks.





Traceback (most recent call last):
  File "oomerge.py", line 137, in ?
test1()
  File "oomerge.py", line 74, in test1
doc2.storeAsURL("file:///C:/alleclipse/OpenOffice/test2.pdf", (PDF,) )
__main__.com.sun.star.task.ErrorCodeIOException

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


pyuno and oootools with OpenOffice 2.0

2006-05-04 Thread Sells, Fred
I'm using windows xp and OpenOffice 2.0 and doing my first project with
pyuno.

I've got the basics to work,.  An example I googled at
http://blogs.nuxeo.com/sections/aggregators/openoffice_org/blogaggregator_vi
ew?b_start:int=0 imported an ootools module.  When I try to import it, it
does not exist,  

Does anyone know where this exists, or why I cannot import it.  

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


OpenOffice UNO export PDF help needed

2006-04-29 Thread Sells, Fred
I've geen googling for 3 days now, and cannot find out how to do this.

I'm trying to use OpenOffice 2.0 and UNO to generate PDF documents.  I'm
using windows, but will have to make it work under Linux for production.
I've been able to set the parameters and call the exportToPdf method, but
the exported file is not PDF but an .odt document,  I can change suffix from
pdf to odt and double click on it and open it as openoffice.  The project is
sort of a custom mail-merge, but there is little data used to produce a
lengthy contract and attachments.  The whole thing needs to be done via a
cgi script or a servlet.

below is a java code snippet, submitted with apologies,  I'm using that
rather than python because I found better examples and my java IDE helps me
out.  I originally started out to do python, and will eventually shift back
to it once I get this working


 public void writePDF(XTextDocument doc, String stringUrl) {
String stringConvertType ="PDF Creator";// args[ 1 ];
 PropertyValue propertyvalueHidden[] = new PropertyValue[ 0 ];
 XStorable xstorable =( XStorable ) UnoRuntime.queryInterface(
XStorable.class, doc );

   // Preparing properties for converting the document
   PropertyValue propertyvalue[] = new PropertyValue[ 2 ];
   propertyvalue[ 0 ] = new PropertyValue();
   propertyvalue[ 0 ].Name = "Overwrite";
   propertyvalue[ 0 ].Value = new Boolean(true);
   propertyvalue[ 1 ] = new PropertyValue();
   propertyvalue[ 1 ].Name = "Filter";
   propertyvalue[ 1 ].Value = "writer_pdf_Export";
   //propertyvalue[ 1 ].Value = "impress_pdf_Export";  //also tried
"PDF Creator"
   xstorable.storeToURL( stringUrl+".pdf", propertyvalue );  //also
tried storeAsUrl, same result

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


need SOAPpy help

2006-03-22 Thread Sells, Fred
I've just been asked to do a soap client for some vendor software.  I'm able
to load the WSDL and discover the methods, but when I go to call a method it
doesn't see it.  I should be passing in a string that is named "testValue"

I've been working from the soap demoes with soappy 0.12.0.  I've found so
much via google that I don't know where to start or what matches this
version of soappy and what is based on older releases.  

I would appreciate some links or code snippets that illustrate using soap
0.12.0.  

I apologize for not including my code, but I'm on a different computer
tonight.

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


ldap passwd need help

2006-01-18 Thread Sells, Fred
I've got the python-ldap version 2.0.11 with python 2.4 under Linux

I've got the ldap stuff working for groups, but now I'm trying to use it to
change a user password.  I get a return of 2 and no error messages but it
does not change ldap.

I've tried it with uid = 'joeblow' and with oldpw=whatever it was with the
same result.

Anyone know what I'm missing?

class LdapUser:
def __init__(self, uri=uri, binddn=BINDDN, password=""):
self.ldap = ldap.initialize(uri)
self.ldap.simple_bind(binddn, password)

def chg_pw(self,uid,oldpw,newpw):
print self.ldap.passwd_s(uid,oldpw,newpw)


if __name__=="__main__":
Ldap = LdapUser(password="secret")
Ldap.chg_pw("uid=joeblow,ou=abc,ou=def,dc=ghi,dc=org","", "new.pass")

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


ldap .passwd method, need help

2006-01-13 Thread Sells, Fred
I've got the python-ldap version 2.0.11 with python 2.4 under Linux

I've got the ldap stuff working for groups, but now I'm trying to use it to
change a user password.  I get a return of 2 and no error messages but it
does not change ldap.

I've tried it with uid = 'joeblow' and with oldpw=whatever it was with the
same result.

Anyone know what I'm missing?

class LdapUser:
def __init__(self, uri=uri, binddn=BINDDN, password=""):
self.ldap = ldap.initialize(uri)
self.ldap.simple_bind(binddn, password)

def chg_pw(self,uid,oldpw,newpw):
print self.ldap.passwd_s(uid,oldpw,newpw)


if __name__=="__main__":
Ldap = LdapUser(password="secret")
Ldap.chg_pw("uid=joeblow,ou=abc,ou=def,dc=ghi,dc=org","", "new.pass")


---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: UDP socket, the solution

2006-01-04 Thread Sells, Fred
import socket, threading, time, binascii, struct
from Configure import Debug
thanks to all, here's my final code that works, if it helps anyone


import socket, threading, time, binascii, struct
from Configure import Debug

ZERO = chr(0)

class Udp:

def __init__(self, my_address, destination_address, timeout=2.0,
log=None):
self.MyAddress = my_address  #(ip,port)
self.Destination = destination_address #(ip,port)
self.Socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.Socket.settimeout(timeout)
self.Socket.bind(self.MyAddress)
self.log = log

def sendto(self, msg):
nsent = self.Socket.sendto(msg, self.Destination)
if Debug.Udp: print >>Debug.Log, '\t\t\t\t   ==>', self.format(msg,
send=True)
return nsent

def recvfrom(self, size=4096):
data, addr = self.Socket.recvfrom(size)
if self.log: print >>self.log, '\t\t\t\t<==   ', self.format(data,
send=False)
return data

def format(self, x, send):
first = struct.unpack('>BBI', x[:6])
tmp = ' ctrl=%02x %02x n=%08x  ' % first
if len(x)>6:
if x[-1]==ZERO:
tmp += '  data="%s x00"' % x[6:-1]
else:
tmp += '  data="%s"' % x[6:]
return tmp


if __name__=='__main__':
syncmsg = struct.pack('>BBI', 8, 0x4a, 0xaabbccdd)
S = Udp( ('192.168.201.171', 1201) , ('192.168.201.72', 1202))
response = S.sendto(syncmsg)
x = S.recvfrom()
print x


---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


UDP socket, need help setting sending port

2005-12-19 Thread Sells, Fred
I'm using MSW XP Pro with Python 2.4 to develop but production will be Linux
with Python 2.3.  (could upgrade to 2.4 if absolutely necessary) I can also
switch to Linux for development if necessary.

I am writing some python to replace proprietary software that talks to a
timeclock via UDP.

The timeclock extracts the sending port from the UDP header and uses that
for all response messages.

I cannot find out how to set the sending port in the header.  Windows XP
appears to set an arbitrary port.  I've been using ethereal to analyze
network traffic and it seems that if I can set the sending port, I should be
OK.

I have been googling various combinations of "python udp ..." for the last
two hours and have not found anything that addresses how to set the sending
port.  I'm guessing that this may be in setsockopt but don't see any
parameters that "click".

Any help would be greatly appreciated.

Fred Sells
fred at adventistcare dott org


---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Auto Install Linux Rpm's

2005-11-16 Thread Sells, Fred
We would like to use Python to automatically deploy new rpm's (assuming we
first edit a file to require a new version).  I've just starting looking a
the rpm module.  I can build this from scratch, but was wondering if anyone
is/has solved some or all of this problem or could point me to some
"goodies" that would help.  

tia

Fred

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: HTML generation vs PSP vs Templating Engines

2005-11-16 Thread Sells, Fred
If this is your first try, use cgi, cgitb and html % dictionary as suggested
in this thread.  If your db is mysql, you can actually use os.popen() (or
equivalent) to run a  'mysql -html -e "select * from yaddayadda" to return
html.  you can make that look prettier with css.
here's a quick and dirty I just did.
===snip=
===
#!/usr/bin/python
import os, string, sys, time, cgi, cgitb
cgitb.enable(display=1)
import ezcgi
HTML = """

   table {cell-padding:2; cell-spacing:2; font-family:Arial;}
   th { background-color: lightblue; cell-padding:5; cell-spacing:5;}
   td { background-color: lightgray; padding:5; spacing:5;
font-size:mediumm;}

Snapshot of Administrative Bed Holds



Current Administrative Bed Holds at all
Facilities
%s

%s

Copyright (C) 1996-2005, Adventist Care Centers, Inc.  For Internal Use
Only
http://acc.sunbelt.org";>Home|
http://acc.sunbelt.org/rwb?P001=logout";>Logout
"""

COMMAND = ['mysql --host=acaredb --user=acare --password=acare -D census -H
-e ', 
   '"SELECT facility,wrb Room,description Reason,startdate, note
Explanation',
   'FROM admin_bed_holds h, abhreasons r '
   'WHERE h.reason=r.id   ',
   ' ORDER BY facility;"']
COMMAND = ' '.join(COMMAND)

def select_holds():
x = os.popen(COMMAND)
table = x.read(6000)
return HTML % ('', table)

def execute():
if ezcgi.is_authenticated():
print ezcgi.HTML_CONTENT_TYPE
print select_holds()
else: 
ezcgi.authenticate_user()

if __name__=='__main__':
#print ezcgi.PLAIN_CONTENT_TYPE
#print COMMAND
execute()
===snip=
=
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 16, 2005 11:32 AM
To: python-list@python.org
Subject: HTML generation vs PSP vs Templating Engines


Hello everybody,

I am in the process of writing my very first web application in Python,
and I need a way to
generate dynamic HTML pages with data from a database.  I have to say I
am overwhelmed
by the plethora of different frameworks, templating engines, HTML
generation tools etc that
exist. After some thought I decided to leave the various frameworks
aside for the
time being and use mod_python.publisher along with some means of
generating HTML on
the fly.
Could someone that has used all the different ways mentioned above for
dynamic HTML
content, suggest what the pros and cons of the different methods are?

  Thank you very much in advance

  Panos

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

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Is Python worth it??

2005-11-15 Thread Sells, Fred
I second what others have said about the tutorials.  I have not read "how to
think like a ..." but from other posting here I have reservations about it
as a starting point.

-Original Message-
From: Simon Brunning [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 15, 2005 4:42 AM
To: john boy
Cc: python-list@python.org
Subject: Re: Is Python worth it??


On 14/11/05, john boy <[EMAIL PROTECTED]> wrote:
> I have started out trying to learn Python for my first programming
language.
>  I am starting off with the book "how to think like a computer scientist."
> I spend about 4-5 hrs a day trying to learn this stuff.  It is certainly
no
> easy task.  I've been at it for about 1-2 weeks now and have a very
> elementary picture of how Python works.  I am teaching myself from home
and
> only recieve help from this forum.  Can anybody give me a timeframe as to
> how long it usually takes to pick something like this up, so I can maybe
> figure out a way to pace myself?  I can dedicate a good amount of time to
it
> everyday.  Any advice on what is the best way to learn Python?  I am a
> fairly educated individual with a natural sciences degree (forestry), so I
> also have a decent math background.  Are there any constraints
> mathematically or logic "wise" that would prevent me from building a firm
> grasp of this language?

Keep at it.

Everyone is different, so don't worry about how long it takes you vs.
how long others might take. If you have no programming background,
there's a lot to learn. Using Python is a good choice, I think, 'cos
it gets a lot of extranious crud that many other languages insist on
out of your way, but there's still a lot to learn.

The best way to learn? Go through the tutorials - but if you get an
idea for a mini-project of your own, don't be afraid to dive off and
give it a go. Try to solve you own problems for a while, 'cos that's a
valuable skill, but don't get to the point of frustration. Ask for
help here or on the tutor mailing list[1].

And have fun.

[1] http://mail.python.org/mailman/listinfo/tutor

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >