Re: Problems with Python 2.5 installer.

2006-10-13 Thread paw
> > Could this happen if c:\python does not exists and creating it fails for
> > some reason, or if permissions are incorrect?
>
> Are you installing it as a "normal" user or as an Administrator? I have
> occasionally had problems (not when installing Python) as a "normal"
> user not being allowed to create a folder at the C:\ level.
>
> I'd suggest this;
> (1) log on as as administrator (i.e. with full rights)
> (2) do an "all users" installation
> (3) You haven't come up with a good reason for doing otherwise, so read
> my lips: *** use the default installation folder C:\Python25 *** you'll
> be happy you did, when Python 2.6 comes out and you want to have both
> installed.

It turns out the domain admin took away my local admin rights
mistakenly.  Once I got those back everything worked fine.

The only 'logic' for my not installing to a directory with the version
is that I don't keep more than one version of Python on my system at
any given time.  When the new version comes out and is stable I remove
the old one, this forces me to check any programs against the latest
version.

Thanks for all of the help,

Wayne

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


Problems with Python 2.5 installer.

2006-09-25 Thread paw
I have ran the MSI installer for Python 2.5 several times attempting to
install to C:
Python, however all of the files are placed in C:\ .  The installer is
told to only install files for me, beyond that I have only chosen the
defaults.

If I copy the files after installation, then uninstall Python, I can
still use the application.  However I am unable to install py2exe since
it does not see Python in the registry, py2exe refuses to install when
the Python files are in C:\ .

The system in am installing on is WinXP SP 2 and I have enough admin
rights on the machine to install software.

Google turned up nothing useful that I could find, is anyone else
seeing this problem?

Thanks,

Wayne

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


Re: Problems with Python 2.5 installer.

2006-09-29 Thread paw

John Machin wrote:
> paw wrote:
> > I have ran the MSI installer for Python 2.5 several times attempting to
> > install to C:
> > Python, however all of the files are placed in C:\ .  The installer is
> > told to only install files for me, beyond that I have only chosen the
> > defaults.
>
> What do you mean by "install to C:  Python"? Can you tell us
> (unambiguously, on one line) what directory you chose? Is there any
> good reason why you didn't take the default, which is
> C:\Python25
> ?

The  should have been \ , the keyboard I am using sucks and
places the backslash below Enter vs. above like I am used to.  I just
didn't catch that when posting.

I really don't know why I always change the directory, I've just always
installed Python on MS Windows into C:\Python.  No practical reason, I
do the same with other programs.

> > Google turned up nothing useful that I could find, is anyone else
> > seeing this problem?
>
> There's been no mention that I've noticed.

I'm thinking this is a local issue.  I came in today and used the same
MSI installer as before and there were no problems.

I'm looking through the local logs to see if there has been any change
on this system in the past day or two right now.

Wayne

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


Re: How can I make a program automatically run once per day?

2011-07-14 Thread monkeys paw

On 7/9/2011 10:01 PM, John Salerno wrote:

Thanks everyone! I probably should have said something like "Python,
if possible and efficient, otherwise any other method" ! :)

I'll look into the Task Scheduler. Thanks again!


You could use the below code. time.sleep(# seconds in a day)
where i == 30 would run once a day for a month

import time
i=0
while (1):
print 'hello'
time.sleep(2)   # Change this to number of seconds in a day
if (i == 3):# make this 30 for a month
break
i = i + 1


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


urlopen returns forbidden

2011-02-27 Thread monkeys paw

I have a working urlopen routine which opens
a url, parses it for  tags and prints out
the links in the page. On some sites, wikipedia for
instance, i get a

HTTP error 403, forbidden.

What is the difference in accessing the site through a web browser
and opening/reading the URL with python urllib2.urlopen?
--
http://mail.python.org/mailman/listinfo/python-list


subclass urllib2

2011-02-28 Thread monkeys paw

I'm trying to subclass urllib2 in order to mask the
version attribute. Here's what i'm using:

import urllib2

class myURL(urllib2):
def __init__(self):
urllib2.__init__(self)
self.version = 'firefox'

I get this>
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

I don't see where i am supplying 3 arguments. What am i
missing?

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


auto increment

2011-03-03 Thread monkeys paw

Does python have an analogy to c/perl incrementer?

e.g.

i = 0
i++

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


Re: auto increment

2011-03-04 Thread monkeys paw

On 3/4/2011 12:07 AM, Chris Rebert wrote:

On Thu, Mar 3, 2011 at 9:05 PM, Dan Stromberg  wrote:

On Thu, Mar 3, 2011 at 8:48 PM, Chris Rebert  wrote:

On Thu, Mar 3, 2011 at 8:41 PM, monkeys paw  wrote:

Does python have an analogy to c/perl incrementer?

e.g.

i = 0
i++


i += 1

If you're doing this for a list index, use enumerate() instead.


There's been discussion of adding i++ to python, but it was felt that the
small number of saved keystrokes didn't justify the resulting bugs.  I
agree.


Out of curiosity, what resulting bugs?

Cheers,
Chris

no bugs, just less keystrokes than: i = i + 1

This is in interger form, BTW.
--
http://mail.python.org/mailman/listinfo/python-list


class error

2011-03-18 Thread monkeys paw

I have the following file:

FileInfo.py:

import UserDict

class FileInfo(UserDict):
"store file metadata"
def __init__(self, filename=None):
UserDict.__init__(self)
self["name"] = filename



When i import it like so:

import FileInfo


i get this error:

Traceback (most recent call last):
  File "", line 1, in 
  File "FileInfo.py", line 3, in 
class FileInfo(UserDict):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

What is causing the error?
--
http://mail.python.org/mailman/listinfo/python-list


Re: class error

2011-03-18 Thread monkeys paw

On 3/18/2011 4:43 PM, Alexander Kapps wrote:

On 18.03.2011 21:13, monkeys paw wrote:

I have the following file:

FileInfo.py:

import UserDict


After this import statement, the name "UserDict" refers to the module.


class FileInfo(UserDict):


Here you are trying to subclass the module. What you need instead is:

class FileInfo(UserDict.UserDict):


OK, i overlooked that and the error was not very enlightening.
Thanks very much.



Alternatively, import the UserDict class from the UserDict module like so:

from UserDict import UserDict

Note, that the UserDict class is obsolete, you can subclass the dict
type directly:

class FileInfo(dict):
"store file metadata"
def __init__(self, filename=None):
dict.__init__(self)
self["name"] = filename


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


os.utime

2011-03-20 Thread monkeys paw

I used os.uname to succesfully change the access and mod times of
a file. My question is, is there any other date store for a file that
indicates the creation time, or is it impossible to detect that a file
with an older mod/access time is actually a 'new' file?

os.utime('sum.py', (time.time(),time.time())
--
http://mail.python.org/mailman/listinfo/python-list


file print extra spaces

2011-03-22 Thread monkeys paw

When i open a file in python, and then print the
contents line by line, the printout has an extra blank
line between each printed line (shown below):

>>> f=open('authors.py')
>>> i=0
>>> for line in f:
print(line)
i=i+1
if i > 14:
break


author_list = {

  '829337' : {

'author_name' : 'Carter, John',

'count' : 49,

'c2' : '0.102040816326531',

How can i print the file out without having an extra newline between
printed lines?

Thanks for the help all.
--
http://mail.python.org/mailman/listinfo/python-list


delete namespaces

2011-03-29 Thread monkeys paw

How do i delete a module namespace once it has been imported?

I use

import banner

Then i make a modification to banner.py. When i import it again,
the new changes are not reflected. Is there a global variable i can
modify?
--
http://mail.python.org/mailman/listinfo/python-list


shell access

2010-01-11 Thread monkeys paw

How do you access the command line from the
python interpreter?

on unix:

type python

>>> print 'hey'
'hey'
>>>   # I want to access the shell here, how do i do that?
--
http://mail.python.org/mailman/listinfo/python-list


import data structure

2010-01-15 Thread monkeys paw

I want to store data in a file like show below. Then
i want to import the data in, but am having trouble.
I'm trying:

import sfdata

for x in author_list:
print x



FILE: sfdata.py (i'm trying to import it)
==

author_list = {
 '829337' : {
   'author_name' : 'Carter, John',
   'count' : 49,
   'c2' : '0.102040816326531',
   'author_party' : 'R',
   'f1' : '0.102040816326531',
   'f2' : '0.102040816326531',
   'author_entry_name' : 'Carter',
   'c1' : '0.122448979591837'
 },
 '825522' : {
   'author_name' : 'Stark, Fortney',
   'count' : 171,
   'c2' : '0.0116959064327485',
   'author_party' : 'D',
   'f1' : '0.0233918128654971',
   'f2' : '0.0116959064327485',
   'author_entry_name' : 'Stark',
   'c1' : '0.0233918128654971'
 },
}
--
http://mail.python.org/mailman/listinfo/python-list


Re: Last M digits of expression A^N

2010-02-06 Thread monkeys paw

mukesh tiwari wrote:

Hello everyone. I am kind of new to python so pardon me if i sound
stupid.
I have to find out the last M digits of expression.One thing i can do
is (A**N)%M but my  A and N are too large (10^100) and M is less than
10^5. The other approach   was  repeated squaring and taking mod of
expression. Is there any other way to do this in python more faster
than log N.


How do you arrive at log N as the performance number?



def power(A,N,M):
ret=1
while(N):
if(N%2!=0):ret=(ret*A)%M
A=(A*A)%M
N=N//2
return ret

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


new python install

2010-02-14 Thread monkeys paw

Upon invoking python, it hangs
until Ctrl^C is typed, and then the
>>> interactive shell begins.

Like so:

joemoney% python
Python 2.4.6 (#1, Dec 13 2009, 23:45:11) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
# Hangs ^^^ at this point until ^C is typed
^C

>>>


I've seen this in other new installs and wondered if there is
a common problem that would cause this? It's on a sun os box
--
http://mail.python.org/mailman/listinfo/python-list


python dowload

2010-02-23 Thread monkeys paw

I used the following code to download a PDF file, but the
file was invalid after running the code, is there problem
with the write operation?

import urllib2
url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
a = open('adobe.pdf', 'w')
for line in urllib2.urlopen(url):
a.write(line)
--
http://mail.python.org/mailman/listinfo/python-list


Re: python dowload

2010-02-23 Thread monkeys paw

On 2/23/2010 3:17 PM, Tim Chase wrote:

monkeys paw wrote:

I used the following code to download a PDF file, but the
file was invalid after running the code, is there problem
with the write operation?

import urllib2
url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
a = open('adobe.pdf', 'w')


Sure you don't need this to be 'wb' instead of 'w'?


'wb' does the trick. Thanks all!

Here is the final working code, i used an index(i)
to see how many reads took place, i have to assume there is
a default buffer size:

import urllib2
a = open('adobe.pdf', 'wb')
i = 0
for line in 
urllib2.urlopen('http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'):

i = i + 1
a.write(line)

print "Number of reads: %d" % i
a.close()


NEW QUESTION if y'all are still reading:

Is there an integer increment operation in Python? I tried
using i++ but had to revert to 'i = i + 1'




for line in urllib2.urlopen(url):
a.write(line)


I also don't know if this "for line...a.write(line)" loop is doing
newline translation. If it's a binary file, you should use .read()
(perhaps with a modest-sized block-size, writing it in a loop if the
file can end up being large.)

-tkc




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


write to remote ile

2010-03-07 Thread monkeys paw

I can xfer a file from a remote server using:

import urllib2 as u
x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl')

for line in x:
print line


How can i write a file to the remote server?

I tried:

x = u.url.open('http://joemoney.net/somefile.txt', 'w')

but that does not work
--
http://mail.python.org/mailman/listinfo/python-list


Re: write to remote ile

2010-03-07 Thread monkeys paw

On 3/7/2010 9:20 PM, Martin P. Hellwig wrote:

On 03/08/10 02:10, monkeys paw wrote:

I can xfer a file from a remote server using:

import urllib2 as u
x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl')

for line in x:
print line


How can i write a file to the remote server?

I tried:

x = u.url.open('http://joemoney.net/somefile.txt', 'w')

but that does not work


How do you normally (i.e. without python) put files on a remote server?


Using FTP, i'm really having a brain cramp here, but i'm new to python
--
http://mail.python.org/mailman/listinfo/python-list


Re: write to remote ile

2010-03-08 Thread monkeys paw

On 3/7/2010 9:53 PM, Martin P. Hellwig wrote:

On 03/08/10 02:51, monkeys paw wrote:

On 3/7/2010 9:20 PM, Martin P. Hellwig wrote:

On 03/08/10 02:10, monkeys paw wrote:

I can xfer a file from a remote server using:

import urllib2 as u
x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl')

for line in x:
print line


How can i write a file to the remote server?

I tried:

x = u.url.open('http://joemoney.net/somefile.txt', 'w')

but that does not work


How do you normally (i.e. without python) put files on a remote server?


Using FTP, i'm really having a brain cramp here, but i'm new to python


We all been there, in some for or other ;-), anyway you might want to
have a look at this:
http://docs.python.org/library/ftplib.html



Tried this, the storlines doesn't work, everything else OK

from ftplib import FTP
ftp = FTP('joemoney.net')
ftp.login('secret','pw')
ftp.retrlines('LIST') # list directory contents
ftp.storlines('STOR', 'sf.xml')   # Is this incorrect, it throws error>

  File "ftp.py", line 5, in 
ftp.storlines('STOR', 'sf.xml')
  File "C:\Python26\lib\ftplib.py", line 470, in storlines
conn = self.transfercmd(cmd)
  File "C:\Python26\lib\ftplib.py", line 356, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python26\lib\ftplib.py", line 327, in ntransfercmd
resp = self.sendcmd(cmd)
  File "C:\Python26\lib\ftplib.py", line 243, in sendcmd
return self.getresp()
  File "C:\Python26\lib\ftplib.py", line 218, in getresp
raise error_perm, resp
ftplib.error_perm: 501 No file name


The file exists in the same directory as ftp.py
--
http://mail.python.org/mailman/listinfo/python-list


pattern matching

2011-02-23 Thread monkeys paw


if I have a string such as '01/12/2011' and i want
to reformat it as '20110112', how do i pull out the components
of the string and reformat them into a DDMM format?

I have:

import re

test = re.compile('\d\d\/')
f = open('test.html')  # This file contains the html dates
for line in f:
if test.search(line):
# I need to pull the date components here
--
http://mail.python.org/mailman/listinfo/python-list


reduce in loop

2010-04-04 Thread monkeys paw

Why does the following fail with the Traceback?

def add(x,y): return x+y
for rrr in range(1,20):
reduce(add, range(1, r))

Traceback (most recent call last):
  File "", line 2, in 
TypeError: reduce() of empty sequence with no initial value
--
http://mail.python.org/mailman/listinfo/python-list


lambda with floats

2010-04-06 Thread monkeys paw

I have the following acre meter which works for integers,
how do i convert this to float? I tried

return float ((208.0 * 208.0) * n)

>>> def s(n):
... return lambda x: (208 * 208) * n
...
>>> f = s(1)
>>> f(1)
43264
>>> 208 * 208
43264
>>> f(.25)
43264
--
http://mail.python.org/mailman/listinfo/python-list


Re: lambda with floats

2010-04-08 Thread monkeys paw

On 4/7/2010 1:08 PM, Peter Pearson wrote:

On Tue, 06 Apr 2010 23:16:18 -0400, monkeys paw  wrote:

I have the following acre meter which works for integers,
how do i convert this to float? I tried

return float ((208.0 * 208.0) * n)


def s(n):

... return lambda x: (208 * 208) * n
...

f = s(1)
f(1)

43264

208 * 208

43264

f(.25)

43264


The expression "lambda x: (208 * 208) * n" is independent of x.
Is that what you intended?




Seems i should have done this:
g = lambda x: 208.0 * 208.0 * x
g(1)
43264.0
--
http://mail.python.org/mailman/listinfo/python-list


Re: lambda with floats

2010-04-08 Thread monkeys paw

On 4/8/2010 7:19 PM, Patrick Maupin wrote:

On Apr 8, 6:06 pm, monkeys paw  wrote:

On 4/7/2010 1:08 PM, Peter Pearson wrote:




On Tue, 06 Apr 2010 23:16:18 -0400, monkeys pawwrote:

I have the following acre meter which works for integers,
how do i convert this to float? I tried



return float ((208.0 * 208.0) * n)



def s(n):

...return lambda x: (208 * 208) * n
...

f = s(1)
f(1)

43264

208 * 208

43264

f(.25)

43264



The expression "lambda x: (208 * 208) * n" is independent of x.
Is that what you intended?


Seems i should have done this:
g = lambda x: 208.0 * 208.0 * x
g(1)
43264.0


Yes, but then what is the 'n' for.  When you do that, you are not
using it, and it is still confusing.

Regards,
Pat


I was going from example and looking for something useful from
the lambda feature. I come from C -> Perl -> Python (recent). I
don't find lambda very useful yet.
--
http://mail.python.org/mailman/listinfo/python-list


Re: lambda with floats

2010-04-08 Thread monkeys paw

On 4/7/2010 12:15 AM, Patrick Maupin wrote:

On Apr 6, 11:10 pm, Patrick Maupin  wrote:

On Apr 6, 11:04 pm, Patrick Maupin  wrote:




On Apr 6, 10:16 pm, monkeys paw  wrote:



I have the following acre meter which works for integers,
how do i convert this to float? I tried



return float ((208.0 * 208.0) * n)



  >>>  def s(n):
... return lambda x: (208 * 208) * n
...
  >>>  f = s(1)
  >>>  f(1)
43264
  >>>  208 * 208
43264
  >>>  f(.25)
43264



Not sure why you are returning a lambda (which is just a function that
does not have a name) from an outer function.



A function that does this multiplication would simply be:



def s(n):
 return 208.0 * 208.0 * n



Regards,
Pat


I realized I didn't show the use.  A bit different than what you were
doing:


def s(n):


... return 208.0 * 208.0 * n
...>>>  s(1)
43264.0

s(0.5)

21632.0

s(3)


129792.0

I'm not sure exactly what you mean by "acre meter" though; this
returns the number of square feet in 'n' acres.

Regards,
Pat


I should stop making a habit of responding to myself, BUT.  This isn't
quite an acre in square feet.  I just saw the 43xxx and assumed it
was, and then realized it couldn't be, because it wasn't divisible by
10.  (I used to measure land with my grandfather with a 66 foot long
chain, and learned at an early age that an acre was 1 chain by 10
chains, or 66 * 66 * 10 = 43560 sqft.)
That's an exact number, and 208 is a poor approximation of its square
root.

Regards,
Pat


You are absolutely right Pat, so here is the correct equate which also 
utilizes my original question of using floats in a lambda, perfectly...


g = lambda x: 208.71 * 208.71 * x
g(1)
43559.86410006

but truly the easiest to remember is based on your chain:

g = lambda x: 660 * 66 * x
g(1)
43560

Now back to python...
--
http://mail.python.org/mailman/listinfo/python-list


Re: lambda with floats

2010-04-09 Thread monkeys paw

On 4/9/2010 3:43 AM, Bas wrote:

On Apr 7, 6:15 am, Patrick Maupin  wrote:

I should stop making a habit of responding to myself, BUT.  This isn't
quite an acre in square feet.  I just saw the 43xxx and assumed it
was, and then realized it couldn't be, because it wasn't divisible by
10.  (I used to measure land with my grandfather with a 66 foot long
chain, and learned at an early age that an acre was 1 chain by 10
chains, or 66 * 66 * 10 = 43560 sqft.)
That's an exact number, and 208 is a poor approximation of its square
root.


There is no need to remember those numbers for the imperially
challenged people:

In [1]: import scipy.constants as c


scipy.constants ??

doesn't work for me.



In [2]: def acre2sqft(a):
...: return a * c.acre / (c.foot * c.foot)
...:

In [3]: acre2sqft(1)
Out[3]: 43560.0


Cheers,
Bas


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


Re: lambda with floats

2010-04-09 Thread monkeys paw

On 4/9/2010 2:40 PM, Patrick Maupin wrote:

On Apr 9, 1:22 pm, monkeys paw  wrote:

On 4/9/2010 3:43 AM, Bas wrote:


On Apr 7, 6:15 am, Patrick Maupinwrote:

I should stop making a habit of responding to myself, BUT.  This isn't
quite an acre in square feet.  I just saw the 43xxx and assumed it
was, and then realized it couldn't be, because it wasn't divisible by
10.  (I used to measure land with my grandfather with a 66 foot long
chain, and learned at an early age that an acre was 1 chain by 10
chains, or 66 * 66 * 10 = 43560 sqft.)
That's an exact number, and 208 is a poor approximation of its square
root.



There is no need to remember those numbers for the imperially
challenged people:



In [1]: import scipy.constants as c


scipy.constants ??

doesn't work for me.




In [2]: def acre2sqft(a):
 ...: return a * c.acre / (c.foot * c.foot)
 ...:



In [3]: acre2sqft(1)
Out[3]: 43560.0



Cheers,
Bas





Basically, he's saying that, instead of remembering the very simple
"66" and "10" values, you can download and install a multi-megabyte
gzipped tar file for the scipy project. ;-)

(Of course, you get a few nice functions thrown in for free along with
your constants, but downloading scipy for its constants is like
choosing a sports car for its cupholders.)


yea, the 66 foot chain story is a good one, i cant forget that. 
Appreciate the help, i just looked up the SciPY Project download,

it is 40 MB. I'm gonna check it out none the less...
--
http://mail.python.org/mailman/listinfo/python-list