Re: [Tutor] leastsquares.py

2004-12-29 Thread Jason Child
mdcooper wrote:
Hello all,
I am trying to use a least squares method (the one written by Konrad Hinsen), 
but I do not want the method to be able to generate negative values. Is there 
a way to stop least squares programs from doing so?

I have probably not included enough information but I am not sure what people 
need so I will wait for a response.

Thanks,
Matt
mdcooper at uvic dot ca
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
 

i seem to recal a recent thread about this
the short answer (imo):
check for negitive values in the output:
##
if output < 0:   #is it a neg num?
   print 'err: output would be negitive!' #if so, then display some 
sort of error msg
else:#otherwise its 
a valid value
   print str(output)   #and we convert to a 
string and display
##

now, I am not sure what you are doing with the code, or what it looks 
like. a simple if check should let you do something with negitive 
numbers (at the least show an err msg). I guess another (retarded) 
option would be to abs(output) and get the non-signed version (if abs() 
is the absolute-value func...never used it myself)

--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Polish translation of my tutor

2004-12-27 Thread Jason Child
Pawel Kraszewski wrote:
Dnia piątek, 17 grudnia 2004 20:59, Alan Gauld napisał:
|Are there any Polish speakers on the tutor list who would like
|to check a new version of my tutorial? There are no formal links
|to it yet as there are only a few pages but it can be found at:
 

Wish I spoke Polish. I had the opertunity to work with some Polish folks 
this past summer. After 3 months of work all I could pick up were some 
choice words (that I dont think are appropriate to list here) and some 
fairly easy expressions.

--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] O.T.

2004-12-27 Thread Jason Child
Jacob S. wrote:
I hate to sound weird...
But who are you all, what are you're ages, what do you do, marriage status,
etc?
You obviously don't have to answer, I'm just curious who I'm boldly sending
emails to.
Jacob Schmidt
P.S.
I'm a student. 14 years. Play the piano better than I write scripts. Single.
etc.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
 

I am a premed student, 23, do web programming (CGI)/tech support/VOIP 
installation/what-ever-the-boss-wants-the-geek-to-do, single. As for 
piano? Well, lets just say that I couldnt play my way outta a cardboard 
box. Get me behind a pair of turntables however...

--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] happy holidays!

2004-12-24 Thread Jason Child
John Purser wrote:
And I got my Christmas wish when UPS delivered my very own RS/6000!
Happiness is being root on your very own 'nix box!
 

No, happiness is being root on someone else's *nix box *grin*.
--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] happy holidays!

2004-12-24 Thread Jason Child
Just wanted to extend warm feelings to all the list members! Have a safe 
and happy season.

--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] silly question

2004-12-22 Thread Jason Child
Ok, I guess my question (now) is:
how do I change global variables within a function:
##
VAR = "TEST"
def m():
   VAR="no test"
##
when I do this (from the interactive editor):
##
>>>print VAR
TEST
>>>m()
>>>
>>>print VAR
TEST
>>>
##
any advice?
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] silly question

2004-12-22 Thread Jason Child
sorry everyone, I figured it out on my own ;)

Jason Child wrote:
Alan Gauld wrote:
oops, I forgot to add the s = 1 and s=0 lines to the example code i 
posted...
   

OK, To save us guessing, why don't you post it with the s=1/0 and 
also the actual output pattern you get?

Seeing the error is a very powerful technique for guessing what may 
be at fault. A second hand description is never as precise.

Alan G
 

I've got a silly question.
###
P1 = "prefix1"
P2 = "prefix2"
def my_func(list, items):
   s = 0
   out = ""
   for i in range(len(list)):
   if s == 0:
   p = P1
   s = 1
   else:
   p = P2
   s = 0
   for j in range(len(items)):
   out += p +items[j]
   return out

If my input was:
list = ["car list 1","car list 2"]
items = ["torino","mustang","elantra"]
for output I get:
prefix1torinoprefix1mustangprefix1elantraprefix1torinoprefix1mustangprefix1elantra
when I expect:
prefix1torinoprefix1mustangprefix1elantra*prefix2*torino*prefix2*mustang*prefix2*elantra
--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
 


___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
 


--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] silly question

2004-12-22 Thread Jason Child




Alan Gauld wrote:

  
oops, I forgot to add the s = 1 and s=0 lines to the example code i 
posted...

  
  
OK, To save us guessing, why don't you post it with the s=1/0 and 
also the actual output pattern you get?

Seeing the error is a very powerful technique for guessing what may 
be at fault. A second hand description is never as precise.

Alan G

  

I've got a silly question.

###

P1 = "prefix1"

P2 = "prefix2"


def my_func(list, items):

   s = 0

   out = ""

   for i in range(len(list)):

   if s == 0:

   p = P1

   s = 1
   else:

   p = P2
   s = 0
   for j in range(len(items)):

   out += p +items[j]

   return out




If my input was:
list = ["car list 1","car list 2"]
items = ["torino","mustang","elantra"]

for output I get:
prefix1torinoprefix1mustangprefix1elantraprefix1torinoprefix1mustangprefix1elantra

when I expect:
prefix1torinoprefix1mustangprefix1elantraprefix2torinoprefix2mustangprefix2elantra


-- 
Jason Christopher Child

Computer Network Service Professionals
VOZ Online



___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] silly question

2004-12-22 Thread Jason Child
Jason Child wrote:
I've got a silly question.
###
P1 = "prefix1"
P2 = "prefix2"
def my_func(list, items):
   s = 0
   out = ""
   for i in range(len(list)):
   if s == 0:
   p = P1
   else:
   p = P2
   for j in range(len(items)):
   out += p +items[j]
   return out

now what i was expecting was the output to alternate prefixes for each 
item set in list. so:

list = ["set1","set2"]
items = ["car","truke",skateboard"]
would yield:
prefix1carprefix1truckprefix1skateboardprefix2carprefix2truckprefix2skateboard 

but i am not getting that. I do feel stupid for this, as I usually 
have an easy time picking up programming languages...

 
oops, I forgot to add the s = 1 and s=0 lines to the example code i 
posted...

--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


[Tutor] silly question

2004-12-22 Thread Jason Child
I've got a silly question.
###
P1 = "prefix1"
P2 = "prefix2"
def my_func(list, items):
   s = 0
   out = ""
   for i in range(len(list)):
   if s == 0:
   p = P1
   else:
   p = P2
   for j in range(len(items)):
   out += p +items[j]
   return out

now what i was expecting was the output to alternate prefixes for each 
item set in list. so:

list = ["set1","set2"]
items = ["car","truke",skateboard"]
would yield:
prefix1carprefix1truckprefix1skateboardprefix2carprefix2truckprefix2skateboard
but i am not getting that. I do feel stupid for this, as I usually have 
an easy time picking up programming languages...

  

--
Jason Christopher Child
Computer Network Service Professionals
VOZ Online
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] least squares

2004-12-16 Thread Jason Child
well, not sure if there is a module with the function you are looking 
for, but...

#sloppy as hell method:
#...
if str(my_returned_value).find("-") != -1:
   return my_returned_value #or whatever you want to do with it
#...
#slightly less sloppy as hell method:
if my_returned_value < 0:
   return my_returned_value

mdcooper wrote:
Hi there,
I am trying to run a least squares program (written by Konrad Hinsen) but I 
would like to only have positive values returned. Can anyone help is altering 
the code to do this?

Thanks,
matthew
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
 

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] removedirs ?

2004-12-16 Thread Jason Child
Ertl, John wrote:
I am trying to remove a directory that has other directories and files in
it.  I thought removedirs was supposed to do a recursive remove of files and
directories.
When I try it I get 

 

os.removedirs("DAF")
   

Traceback (most recent call last):
 File "", line 1, in -toplevel-
   os.removedirs("DAF")
 File "/home/ertlj/ertljVersion/lib/python2.3/os.py", line 167, in
removedirs
   rmdir(name)
OSError: [Errno 17] File exists: 'DAF'
Thanks,
John Ertl
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
 

it seems to me that if its on a *nix box you could use the shell command 
rm -rf 
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] removedirs ?

2004-12-16 Thread Jason Child
is this what you want to do?
import os
from os.path import join
# Delete everything reachable from the directory named in 'top'.
# CAUTION: This is dangerous! For example, if top == '/', it
# could delete all your disk files.
for root, dirs, files in os.walk(top, topdown=False):
   for name in files:
   os.remove(join(root, name))
   for name in dirs:
os.rmdir(join(root, name))
I cant take credit for the code, as I found it when I was trying to hack 
together a recirsive file remover script. It was in the help files for 
the os module, under walk(). Go figure; when you try to do things the 
"hard way" python keeps it simple!

Peace
Jason
Ertl, John wrote:
Jason,
I could...That is the exact feature I am trying to replicate, but I would
just like to do it in Python if I can (in a simple way).  I am writing this
code in Python to avoid some funny scripting that I would need to do. To go
back to combing shell and Python again would be a bit deflating...but the
straight forward path might be the best.
Thanks,
John Ertl 

-----Original Message-
From: Jason Child [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 16, 2004 12:36
Cc: [EMAIL PROTECTED]
Subject: Re: [Tutor] removedirs ?
Ertl, John wrote:
 

I am trying to remove a directory that has other directories and files in
it.  I thought removedirs was supposed to do a recursive remove of files
   

and
 

directories.
When I try it I get

   

os.removedirs("DAF")
 

 

Traceback (most recent call last):
File "", line 1, in -toplevel-
  os.removedirs("DAF")
File "/home/ertlj/ertljVersion/lib/python2.3/os.py", line 167, in
removedirs
  rmdir(name)
OSError: [Errno 17] File exists: 'DAF'
Thanks,
John Ertl
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

   

it seems to me that if its on a *nix box you could use the shell command
rm -rf 
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
 

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] hello i need help

2004-12-16 Thread Jason Child
alex biggerstaff wrote:
is it possible 2 write a script for wordpad or something, i only 
started so i dont know much
i do know a little about if ($1 == hi)  && (£2 == m8)
but im not sure how 2 make this apply to other programs. i can only 
write scripts on a thing called mIRC.
ne help would b great
thnxs

* ALL-NEW Yahoo! Messenger * 
 * - 
all new features - even more fun!* * *


___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
 

I do not belive that Notepad supports scripting. Take a look at: 
http://www.python.org/moin/PythonEditors

in particular you may want to look at JeXt, Syn or Zues.
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


[Tutor] test

2004-12-09 Thread Jason Child
test

Jason Christopher Child

Computer Network Services Professionals
Tech Support 
505-986-1669
1-877-321-9165
[EMAIL PROTECTED]

VOZ Online
VOIP Install Tech
505-428-7500
1-877-428-7550

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


[Tutor] PDF and Python

2004-12-09 Thread Jason Child
Hey there. Does anyone know of a way to output PDFs with python? I have some
data that I have processed from a series of textfiles that I would like to
provide PDF format reports for..

Jason Christopher Child

Computer Network Services Professionals
Tech Support
505-986-1669
1-877-321-9165
[EMAIL PROTECTED]

VOZ Online
VOIP Install Tech
505-428-7500
1-877-428-7550

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


RE: [Tutor] embedding python in a C app on a linux box...

2004-12-07 Thread Jason Child
thanks.

i got the linker to work, and with your -I switch the include works. thanks
again!

Jason Christopher Child

Computer Network Services Professionals
Tech Support
505-986-1669
1-877-321-9165
[EMAIL PROTECTED]

VOZ Online
VOIP Install Tech
505-428-7500
1-877-428-7550


-Original Message-
From: Danny Yoo [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 12:18 PM
To: Jason Child
Cc: [EMAIL PROTECTED]
Subject: Re: [Tutor] embedding python in a C app on a linux box...




On Tue, 7 Dec 2004, Jason Child wrote:

> Ok, so I have a decent grasp of python and have coded quite a few
> scripts. I must say that the language rocks. I would like to embed
> python into a C app to provide some scripting support.


Hi Jason,

We have to first mention that most of us here are beginning Python
programmers; few of us have done Python/C integration, so we're probably
not the best people to ask for help.  You may want to ask your
extension-building questions on comp.lang.python; I'm sure the experts
there will be happy to help you.  That being said, we'll do what we can.


> It would seem that my problem lies with not understanding the
> environment (linux) well enough. First off, I must include the Python.h
> header escplicitly (via #include "/usr/include/python2.3/Python.h"). How
> do I add the correct dir to the search path for the <> format?

This is controlled by adding a '-I/usr/include/python2.3' flag argument to
gcc, so that gcc adds that as part of its include path search.


 Second, when I call Py_Initialize() I get:
>
> /tmp/ccXZxNHZ.o(.text+0x11): In function `main':
> : undefined reference to `Py_Initialize'
> collect2: ld returned 1 exit status
>
> Now, I think it is because the linker isnt finding the right lib to
> attach. Is there a switch to use for gcc for make it? -L /path/to/libs
> perhaps?

You'll probably need '-lpython' so that it links Python to your
executable.  The uppercase '-L' flag is something else: it controls where
gcc looks for additional libraries, and I think it automatically include
'/usr/lib' by default.



You may find the stuff near the bottom of:

http://docs.python.org/ext/building.html

useful: it shows an example 'gcc' call that has all the flags that one
needs to get an extension built in Linux.


There's also an example of an embedded application that's in the Python
source tree.  It's under the Demo/embed directory, and may be a good
starting-off point.


But again, try asking your question on comp.lang.python.  I have to admit
that I haven't done embedding much, so there may be a better way to infer
those 'gcc' flags without hardcoded them in some kind of Makefile.

Good luck to you!

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


[Tutor] embedding python in a C app on a linux box...

2004-12-07 Thread Jason Child
Ok, so I have a decent grasp of python and have coded quite a few scripts. I
must say that the language rocks. I would like to embed python into a C app
to provide some scripting support. It would seem that my problem lies with
not understanding the environment (linux) well enough. First off, I must
include the Python.h header escplicitly (via #include
"/usr/include/python2.3/Python.h"). How do I add the correct dir to the
search path for the <> format? Second, when I call Py_Initialize() I get:

/tmp/ccXZxNHZ.o(.text+0x11): In function `main':
: undefined reference to `Py_Initialize'
collect2: ld returned 1 exit status

Now, I think it is because the linker isnt finding the right lib to attach.
Is there a switch to use for gcc for make it? -L /path/to/libs perhaps?

Any and all advice/help is welcome.

flames >/dev/null

Jason Christopher Child

Computer Network Services Professionals
Tech Support
505-986-1669
1-877-321-9165
[EMAIL PROTECTED]

VOZ Online
VOIP Install Tech
505-428-7500
1-877-428-7550

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


[Tutor] test

2004-12-07 Thread Jason Child


Jason Christopher Child

Computer Network Services Professionals
Tech Support 
505-986-1669
1-877-321-9165
[EMAIL PROTECTED]

VOZ Online
VOIP Install Tech
505-428-7500
1-877-428-7550

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor