Re: Python SOAP library

2012-05-10 Thread John

W dniu 2012-05-02 17:35, Alec Taylor pisze:

Would you recommend: http://code.google.com/p/soapbox/

Or suggest another?


I am having lots of fun and positive experience with
https://github.com/arskom/rpclib

Awesome doc and example code and, most importantly, it works! :)

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


Django/AppEngine DevSoup

2011-05-07 Thread John
Sooo I have a windows box... which I like to think is the reason I'm a
django/appengine mess right now.

There's eclipse, pydev, django non-rel, mediagenerator, etc

Would it be stupid of me to just use the simple, clean notepad++ &
django with aims to port into appengine after I finish in a week? I
don't want to deal with all of the other stuff. Will this come back to
haunt me in 7 days?

Yours frazzled,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


How do I automatically download files from a pop up dialog using selenium-python?

2016-09-09 Thread John
Please help.  Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


python list index - an easy question

2016-12-17 Thread John
Hi, 

   I am new to Python, and I believe it's an easy question. I know R and Matlab.


>>> x=[1,2,3,4,5,6,7]
>>> x[0]
1
>>> x[1:5]
[2, 3, 4, 5]
*

My question is: what does x[1:5] mean? By Python's convention, the first 
element of a list is indexed as "0". Doesn't x[1:5] mean a sub-list of x, 
indexed 1,2,3,4,5? If I am right, it should print [2,3,4,5,6]. Why does it 
print only [2,3,4,5]?

   Thanks!!

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


FS: PC Doctor

2005-01-03 Thread john

Bought from http://www.PCbeginner.com two weeks ago. Now my computer
got fixed and I do not need it any more. Asking $15 only. I will ship
to you by first class mail.
Email: [EMAIL PROTECTED]

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


FS: PC Doctor

2005-01-03 Thread john

Bought from http://www.PCbeginner.com two weeks ago. Now my computer
got fixed and I do not need it any more. Asking $15 only. I will ship
to you by first class mail.
Email: [EMAIL PROTECTED]

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


Python HTTP digest authentication woes...

2005-07-16 Thread john
I'm trying to access the XML version of my Tivo now playing list with 
python. It uses auth digest HTTP authentication. I could really use 
some help!

I'm able to get this page using curl:
curl --dump-header tivoHeaders --insecure --anyauth --user tivo:808 
"https://192.168.1.102/TiVoConnect?Command=QueryContainer&Container=%2FNowPlaying&Recurse=Yes";

But 

when I use my python script, I get rejected:
https://192.168.1.102/TiVoConnect?Container=%2FNowPlaying&Command=QueryContainer&Recurse=Yes
Error 

401
Server: tivo-httpd-1:7.1b-01-2:140
Set-Cookie: sid=DEC2D78EABF48A6D; path=/; expires="Saturday, 
16-Feb-2013 00:00:00 GMT";
WWW-Authenticate: Digest realm="TiVo DVR", nonce="FD08EF226909CA85", qop="auth"
Content-Length: 31
Content-Type: text/html
Connection: close

Digest realm="TiVo DVR", nonce="FD08EF226909CA85", qop="auth"

I've scrounged for examples out there and the couple that I've found 
just don't seem to work for me..

Here's one way I've tried:
=
import urllib2

theurl = 
"192.168.1.102/TiVoConnect?Container=%2FNowPlaying&Command=QueryContainer&Recurse=Yes"
print 

theurl

protocol = 'https://'
username = 'tivo'
password = '808'

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, theurl, username, password)
authhandler = urllib2.HTTPDigestAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
try:
pagehandle = urllib2.urlopen(protocol + theurl)
except IOError, e:
if hasattr(e, 'code'):
if e.code != 401:
print 'We got another error'
print e.code
else:
print "Error 401"
print e.headers
print e.headers['www-authenticate']
===

I get 401 every time!
This was taken from an example online almost verbatim, the only major 
thing I changed was HTTPBasicAuthHandler --> HTTPDigestAuthHandler. Any 
ideas or help would be greatly appreciated!

Thanks,
-John

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


socket + file i/o question

2005-08-07 Thread John
I am sending a file on a tcp socket using the following code


while 1:
buf = os.read(fd, 4096)
if not buf: break
print total, len(buf)
conn.send(buf)

The recieving code looks like

while 1:
if recvbytes == filesize:
print 'Transfer done. Size = %d' % recvbytes
break
buf = s.recv(4096)
if not buf:
print 'EOF received'
raise Exception()
print recvbytes, len(buf)
os.write(fd, buf)
recvbytes = recvbytes + len(buf)


My problem is that the first time the client uploads a file
to the server, the code works. But then when the server wants
to download a file to the client, the same code breaks down!

The problem seems to be the socket. The send part sends exactly the
amount of data it reads from the file. But the recv part gets one
more byte than the size of the file?? It seems to me that this
extra one byte is coming inside the send/recv calls. Anyone has
any comments on where this extra one byte is coming from?

Thanks a lot for your help,
--j

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


Re: socket + file i/o question

2005-08-07 Thread John
Here is what the send and recieved number of bytes show up as:

Filesize being sent = 507450
Server sending file to client...
(total size sent , buffer size)
...
491520 4096
495616 4096
499712 4096
503808 3642
./server.py: (107, 'Transport endpoint is not connected')

On the client side, the bytes recieved shows one extra byte!
(Bytes recieved, buffer size)
...
504256 1400
504256 1400
505656 1400
505656 1400
507056 1400
507056 395
507451 395
EOF received
./client.py: An unknown error occurred.

Note that on the client there was an extra byte??
507451 ??

Hope this helps in explaining my question better,
--j

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


Re: socket + file i/o question

2005-08-07 Thread John
I found the problem. There was a recv that was not from an open
socket...

Sorry abt the trouble,
--j

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


zipped socket

2005-08-07 Thread John


Is there anyway open a socket so that every send/listen/recv
goes thru a zipping/unzipping process automatically?

Thanks,
--j

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


client server question

2005-08-11 Thread John

I have a simple script that runs a server where one client can connect.
I would like to make it so that many clients can connect to one server
on the same port. Where can I find how to do this?

Thanks,
--j

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


Re: client server question

2005-08-14 Thread John
Thanks a lot,
I think I could modify this to get my work done.
--j

Chris Curvey wrote:
> import threading
> import logging
>
> ##
> class Reader(threading.Thread):
> def __init__(self, clientsock):
>   threading.Thread.__init__(self)
>   self.logger = logging.getLogger("Reader")
>
> #-
> def run(self):
> self.logger.info("New child %s" %
> (threading.currentThread().getName()))
> self.logger.info("Got connection from %s" %
> (clientsock.getpeername()))
>
> 
> # set up a socket to listen for incoming connections from our clients
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> s.bind((host, port))
> s.listen(1)
>
> while True:
> try:
> clientsock, clientaddr = s.accept()
> except KeyboardInterrupt:
> raise
> except:
> traceback.print_exc()
>   continue
>
> client = Reader(clientsock)
> client.setDaemon(1)
> client.start()

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


sizeof(long) from python

2005-09-04 Thread John

I want to know the sizeof(long) / sizeof(int) ... in C from python.
(This is to read a set of numbers output from a C Code
and can be machine dependent).

Is there an easy way except writing a C program and parsing its output?

Thanks,
--j

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


Re: sizeof(long) from python

2005-09-04 Thread John
Thanks a lot, That solved my problem.
--j

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


help in simplification of code [string manipulation]

2005-09-13 Thread John

How could I simplify the code to get libs out of LDFLAGS
or vice versa automatically in the following python/scons code?

if sys.platform[:5] == 'linux':
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LDFLAGS  = '-lglut -lGLU -lGL -lm')
env.Append(CPPPATH=['include', 'include/trackball'])
libs = ['glut', 
'GLU',
'GL',
'm',]


Thanks,
--j

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


Re: help in simplification of code [string manipulation]

2005-09-13 Thread John

Thanks for your replies...
Solved my problem.
--j

Christophe wrote:
> John a écrit :
> > How could I simplify the code to get libs out of LDFLAGS
> > or vice versa automatically in the following python/scons code?
> >
> > if sys.platform[:5] == 'linux':
> > env.Append (CPPFLAGS = '-D__LINUX')
> > env.Append (LDFLAGS  = '-lglut -lGLU -lGL -lm')
> > env.Append(CPPPATH=['include', 'include/trackball'])
> > libs = ['glut',
> > 'GLU',
> > 'GL',
> > 'm',]
> >
> >
> > Thanks,
> > --j
> >
>
> Why don't you use the LIBS var in the environment instead of the LDFLAGS
> ? And what use would be the libs var for you ?
>
> if sys.platform[:5] == 'linux':
>   libs = ['glut',
>   'GLU',
>   'GL',
>   'm',]
>   env.Append (CPPFLAGS = '-D__LINUX')
>   env.Append (LIBS = Split(libs))
>   env.Append(CPPPATH=['include', 'include/trackball'])

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


Re: help in simplification of code [string manipulation]

2005-09-14 Thread John

But ur previous solution worked on my machine...
although a friend tried it on his machine and the libraries
were not found even if they existed! (Even the -lm was not found)

Can you explain a bit why the previous solution worked?

Thanks for ur help,
--j

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


Re: difference between class methods and instance methods

2005-02-17 Thread John
Steven Bethard wrote:
John M. Gabriele wrote:
1. Are all of my class's methods supposed to take 'self' as their
first arg?

If by "class's methods" you mean methods on which you called 
classmethod, then no, they shouldn't take a 'self' parameter, they 
should take a 'cls' parameter because the first argument to the function 
will be the class:

class C(object):
@classmethod
def f(cls, *args):
# do stuff
Sorry -- I'm not as far along as you suspect. :) I've
never yet seen this "@classmethod" syntax. I'm supposing that
it's part of this so-called "new-style" class syntax.
When I ask "are all my class's methods...", I mean, when
I'm writing a class statement and the def's therein -- are
all those def's supposed to take 'self' as their first arg.
From your reply, I gather that, unless I'm using this special
syntax (@classmethod or @staticmethod), all my def's are supposed
to take 'self' as their first arg.
Undecorated methods (e.g. those that are not wrapped with classmethod or 
staticmethod) should, on the other hand, take a 'self' parameter.
Ok. Check.
So then, are all def's -- that take 'self' as their first --
argument -- in a class statement, instance methods?

2. Am I then supposed to call them with MyClass.foo() or instead:
bar = MyClass()
bar.foo()

Classmethods should be called from the class.  Python allows you to call 
them from the instance, but this almost never does what you want, e.g.:

py> d = {}
py> d.fromkeys(range(4))
{0: None, 1: None, 2: None, 3: None}
py> d
{}
Note that 'd' is not updated -- I called a classmethod, not an 
instancemethod.  If I had called dict.fromkeys instead, this would have 
been clearer.
Right. An important lesson in C++ as well.

3. Is "bound method" a synonym for instance method?
4. Is "unbound method" a synonym for class method?

No.  To simplify things a little[1], a "bound method" is an instance 
method that has been associated with a specific instance, and an 
"unbound method" is an instance method that has not been associated with 
a specific instance. 
Ok! Now I'm making some headway. *This* is getting
at the crux of the biscuit.

Consider the difference between str.join and ''.join:
py> str.join

>
py> ', '.join

>
Hmm... weird.
py> str.join(['a', 'b', 'c'])
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: descriptor 'join' requires a 'str' object but received a 'list'
>
Right -- 'cause there's no actual instance of a string
to do the joining. Check.
py> ', '.join(['a', 'b', 'c'])
'a, b, c'
Check.
py> str.join(', ', ['a', 'b', 'c'])
'a, b, c'
Ack! Now you're creeping me out. Looking at the doc for str.join:
| py> help( str.join )
| Help on method_descriptor:
|
| join(...)
| S.join(sequence) -> string
|
| Return a string which is the concatenation of the strings in the
| sequence.  The separator between elements is S.
|
It says that you didn't call that method correctly. Yet
it works anyway!? What's happening here?

In the example above, you can see that str.join is an "unbound method" 
-- when I try to call it without giving it an instance, it complains. On 
the other hand, ', '.join is a "bound method" because it has been bound 
to a specific instance of str (in this case, the instance ', '). When I 
call it without an instance, it doesn't complain because it's already 
been bound to an instance.
Ok. I see that distinction. Thanks.

Where do the so-called "static methods" fit into all this?
By the name of them, it sounds like the same thing as class
methods...

Staticmethods, like classmethods, are associated with the class object, 
not the instance objects. 
That makes sense.
The main difference is that when a 
staticmethod is called, no additional arguments are supplied, while when 
a classmethod is called, a first argument, the class, is inserted in the 
argument list:

py> class C(object):
... @classmethod
... def f(*args):
... print args
... @staticmethod
... def g(*args):
... print args
...
py> C.f(1, 2, 3)
(, 1, 2, 3)
py> C.g(1, 2, 3)
(1, 2, 3)
STeVe
Thanks for that nice example. It looks like you're always
supposed to call both class and static methods via the class
name (rather than an instance name). I'll read up on what
this new @classmethod and @staticmethod syntax means.
[1] Technically, I think classmethods could also considered to be "bound 
methods" because in this case, the method is associated with a specific 
instance of 'type' (the class in which it resides) -- you can see this 
in the first argument that is supplied to the argument list of a 
classmethod.

--
--- remove zees if replying via email ---
--
http://mail.python.org/mailman/listinfo/python-list


Re: difference between class methods and instance methods

2005-02-17 Thread John
Duncan Booth wrote:
John M. Gabriele wrote:

I've done some C++ and Java in the past, and have recently learned
a fair amount of Python. One thing I still really don't get though
is the difference between class methods and instance methods. I
guess I'll try to narrow it down to a few specific questions, but
any further input offered on the subject is greatly appreciated:

I'll try not to cover the same ground as Steven did in his reply.
Thanks for taking the time to reply Duncan.

1. Are all of my class's methods supposed to take 'self' as their
first arg?
consider this:
  class Demo(object):
def foo(self, x):
print self, x
@classmethod
def clsmethod(cls, x):
print cls, x
@staticmethod
def stmethod(x):
print x

instance = Demo()
Calling a bound method, you don't pass an explicit self parameter, but the 
method receives a self parameter:

bound = instance.foo
bound(2)
<__main__.Demo object at 0x00B436B0> 2
>
Note that it doesn't matter whether you call instance.foo(2) directly, or 
bind instance.foo to a variable first. Either will create a *new* bound 
method object, and the correct instance is used for the call.
Za! What do you mean, "create a new bound method object"? I *already*
created that method when I def'd it inside the 'class Demo' statement,
no?
This is 
significantly different from languages such as C++ and Javascript which are 
a real pain if you want to use a method as a callback.

Calling an unbound method, you pass a self parameter explicitly (and it 
must be an instance of the class, *or an instance of a subclass*:

unbound = Demo.foo
unbound(instance, 2)
<__main__.Demo object at 0x00B436B0> 2
A! See, coming from C++, the first thing I thought
when I saw what you just wrote was, "whoops, he shouldn't be
calling that instance method via the class name -- it's a bad
habit". Now I think I see what you mean: you may call an
instance method in two ways: via an instance where you don't
pass in anything for 'self', and via the class name, where
you must supply a 'self'.
Again is doesn't matter whether you do this in one step or two. The usual 
case for using an unbound method is when you have overridden a method in a 
derived class and want to pass the call on to a base class. e.g.
Ok. Interesting.
class Derived(Demo):
def foo(self, x):
 Demo.foo(self, x)
A class method is usually called through the class rather than an instance, 
and it gets as its first parameter the actual class involved in the call:

Demo.clsmethod(2)
 2
Derived.clsmethod(2)
 2
Check.
You can call a class method using an instance of the class, or of a 
subclass, but you still the get class passed as the first parameter rather 
than the instance:

d = Derived
d.clsmethod(2)
 2
Ok, so it looks like it may lead to confusion if you do that.
I wonder why the language allows it...

A common use for class methods is to write factory functions. This is 
because you can ensure that the object created has the same class as the 
parameter passed in the first argument. Alternatively you can use class 
methods to control state related to a specific class (e.g. to count the 
number of instances of that exact class which have been created.)

There is no equivalent to a class method in C++.
Right. I see -- because in Python, a reference the actual class
object is implicitly passed along with the method call. Whereas,
C++ doesn't even have "class objects" to begin with.
Static methods are like static methods in C++. You can call them through 
the class or a subclass, or through an instance, but the object used in the 
call is not passed through to the method:

Demo.stmethod(2)
2
instance.stmethod(2)
2
Derived.stmethod(2)
2
d.stmethod(2)
2

2. Am I then supposed to call them with MyClass.foo() or instead:
   bar = MyClass()
   bar.foo()
?

If you have an instance then use it. If the class method is a factory then 
you might want to create a new object of the same type as some existing 
object (but not a simple copy since you won't get any of the original 
object's state). Mostly though you know the type of the object you want to 
create rather than having an existing instance lying around.


3. Is "bound method" a synonym for instance method?

Close but not quite. It is a (usually transient) object created from an 
unbound instance method for the purposes of calling the method.
... hmm... bound methods get created each time you make
a call to an instance method via an instance of the given class?

4. Is "unbound method" a synonym for class method?

Definitely not.
Right. :)

And if anyone's *really* daring:
Where do the so-called "static methods" fit into all this?
By the name of them, it sounds like the same thing as class
methods...

See above.

--
--- remove zees if replying via email ---
--
http://mail.python.org/mailman/listinfo/python-list


Re: difference between class methods and instance methods

2005-02-17 Thread John
Diez B. Roggisch wrote:
John wrote:
... hmm... bound methods get created each time you make
a call to an instance method via an instance of the given class?

No, they get created when you create an actual instance of an object. So
only at construction time. Creating them means taking the unbound method
and binding the created object as first argument to the method. Thus each
instance of a class Foo with a method bar has its own instance of bar - the
bound method bar. But only one per object. 


O. Unlike C++, where methods are not first class objects
and you only have *one* that gets shared by all instances.
I'm getting it. Thanks for the reply. :)
---J
--
--- remove zees if replying via email ---
--
http://mail.python.org/mailman/listinfo/python-list


Re: difference between class methods and instance methods

2005-02-17 Thread John
Duncan Booth wrote:
[snip]
Bound methods get created whenever you reference a method of an instance. 
If you are calling the method then the bound method is destroyed as soon as 
the call returns. You can have as many different bound methods created from 
the same unbound method and the same instance as you want:

inst = C()
f1 = inst.foo
f2 = inst.foo
f1, f2
(>, >)

I just wanted to interject, although those two hex
numbers in the above line are the same, calling
id() on f1 and f2 produces two *different* numbers,
which agrees with the point you made.
f1 is f2
False
f1 is inst.foo
False
Every reference to inst.foo is a new bound method.

--
--- remove zees if replying via email ---
--
http://mail.python.org/mailman/listinfo/python-list


Re: having troubleing finding package for Twisted 1.3 for Mac OS X 10.3.x

2005-02-18 Thread John
fuzzylollipop wrote:
just got a Powerbook and need to do twisted development on it, but I
can't find a simple straight foward instructions on installing Twisted
1.3 on it.
Also the package manager at undefined.org has 1.1.0 and it doesn't work
with 10.3.x ( pre-installed Python )
any help is welcome
I'm pretty sure the package manager at undefined.org had
lapsed into disrepair. IIRC, the author has not updated
it in a long time and doesn't plan to.
Have you tried building from source? It should just be
a simple './configure', 'make', and 'sudo make install',
no?
---J
--
--- remove zees if replying via email ---
--
http://mail.python.org/mailman/listinfo/python-list


running a python script in drpython

2005-03-13 Thread john
Haveing problems writeing a program then running it in python 2.3.5 
interpreter.  Called the program test.py used chmod to make it 
executable in linux
#! /usr/bin/python
print 2** 8
print 'the bright side ' + 'of life'
>>> python test.py
  File "", line 1
python test.py
  ^
SyntaxError: invalid syntax
how do you run a script you create in the python interpreter?
Thanks
John
--
http://mail.python.org/mailman/listinfo/python-list


Re: running a python script in drpython

2005-03-13 Thread john
john wrote:
Haveing problems writeing a program then running it in python 2.3.5 
interpreter.  Called the program test.py used chmod to make it 
executable in linux

#! /usr/bin/python
print 2** 8
print 'the bright side ' + 'of life'

 >>> python test.py
  File "", line 1
python test.py
  ^
SyntaxError: invalid syntax
how do you run a script you create in the python interpreter?
Thanks
John
You have to import the script into the interpreter.
>>> import test
256
the bright side of life
--
http://mail.python.org/mailman/listinfo/python-list


Re: Delphi underrated, IDE clues for Python

2004-11-30 Thread John
"Caleb Hattingh" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
PROTECTED]>...
> thx, I already have and use PythonForDelphi (and am on the mailing list).
> 
> It works very well indeed, my impression is that Python-Delphi connection  
> is even easier than Python-C integration (e.g. via SWIG, etc), due once  
> again to the Delphi IDE.  Drag-n-drop in the IDE gets you python code in  
> your delphi code, or delphi units/objects accessible in python.
> 
> However, Delphi is not platform indpendent (which is important for me as I  
> use a different OS at work and at home), and I don't know if  
> PythonForDelphi supports Kylix.  I am fairly sure it doesn't support  
> Lazarus, which IS platform independent, but not as feature-rich as Delphi.
> 
> Btw, on the SHOOTOUT page, you'll see that the Delphi rank for LOC is 28.   
> This number is pretty meaningless in practice because the IDE does a lot  
> of code generation for you.  More interesting would have been to see the  
> rank for LOC you have to type yourself...
> 
> On 27 Nov 2004 05:17:38 -0800, bearophile <[EMAIL PROTECTED]> wrote:
> 
> > Delphi is a very good language, and quite fast too:
> > http://dada.perl.it/shootout/delphi.html
> >
> >
> > Caleb Hattingh>STILL...Having a Delphi-like IDE for Python would make me  
> > giddy.
> >
> > Maybe here you can find a way to use both at the same time:
> > http://www.atug.com/andypatterns/pythonDelphiTalk.htm
> > http://membres.lycos.fr/marat/delphi/python.htm
> >
> > Bearophile

Python + Delphi is pretty much the Zen of programming  for me, for
now. Both excel in what they try to accomplish, stand at opposite ends
of the spectrum, yet compliment each other beautifully.
PythonForDelphi is the only language embedding I have done without any
stress recently.

When I make GUI software, I only do it for MS Windows. So portability
is not an issue. I have not moved to Delphi.NET because Python gives
everything missing from Delphi and I can have best of both the worlds
while still having a fast, very rich (thanks to all those VCL
freeware) and responsive GUI and under 2-3 MB distribution. For same
reasons, I never really made a full blown GUI app with any Python
bindings. It's just too easy to design a GUI with Delphi and write
Windows specific code.

I wish Borland focussed more in this direction. Bruce Eckel has been
saying for quite a while that Borland should bring their IDE expertise
to make a Python IDE.

I think Python For Delphi module is grossly under rated like Delphi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Chrooted Python problem

2004-12-05 Thread John



Hello to all
 
I lately installed the python 2.3 and mod_python 
2.7.10
 
My apache runs in a chrooted enviroment so i want 
to chroot pyton and mod_python as well.
 
I have copy the
 
 /usr/local/apache/libexec/mod_python.so -> 
/chroot /usr/local/apache/libexec/mod_python.so 
 
/usr/local/lib/python2.3 -> 
/chroot/usr/local/lib/python2.3
 
/usr/local/bin/python -> 
/chroot/usr/local/bin/python
 
And some .so files in the /chroot/lib directory 
that the 
 
ldd /usr/local/bin/python 
and
ldd 
/usr/local/apache/libexec/mod_python.so
indicated
 
 
The problem is that i can start the apache in the 
chrooted enviroment but its childs (or children) processes (of apache) 
increasing and increasing until the
apache crashes (160-200 apache 
process).
 

When i disable the loading of mod_pyton.so in the 
httpd.conf then everything works well like it used to.
 
 
Do you know any cure about that 
problem?
 
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Chrooted Python problem

2004-12-05 Thread John



        

  - Original Message - 
  From: 
  John 
  To: [EMAIL PROTECTED] 
  Sent: Sunday, December 05, 2004 9:10 
  PM
  Subject: Chrooted Python problem
  
  Hello to all
   
  I lately installed the python 2.3 and mod_python 
  2.7.10
   
  My apache runs in a chrooted enviroment so i want 
  to chroot pyton and mod_python as well.
   
  I have copy the
   
   /usr/local/apache/libexec/mod_python.so 
  -> /chroot /usr/local/apache/libexec/mod_python.so 
   
  /usr/local/lib/python2.3 -> 
  /chroot/usr/local/lib/python2.3
   
  /usr/local/bin/python -> 
  /chroot/usr/local/bin/python
   
  And some .so files in the /chroot/lib directory 
  that the 
   
  ldd /usr/local/bin/python 
  and
  ldd 
  /usr/local/apache/libexec/mod_python.so
  indicated
   
   
  The problem is that i can start the apache in the 
  chrooted enviroment but its childs (or children) processes (of apache) 
  increasing and increasing until the
  apache crashes (160-200 apache 
  process).
   
  
  When i disable the loading of mod_pyton.so in the 
  httpd.conf then everything works well like it used to.
   
   
  Do you know any cure about that 
  problem?
   
   
   
  
  

  
  -- http://mail.python.org/mailman/listinfo/python-list
   
   
   
  Does anybody 
know?
-- 
http://mail.python.org/mailman/listinfo/python-list

My code won't work if I double click the saved file

2015-07-29 Thread john
I have windows 8 running on my computer and I think I downloaded python 2 and 3 
simultaneously or I think my computer has built in python 2 and I downloaded 
python 3. And now when I ran my code in IDLE, the code works fine but when I 
save my program and double click the save file, it will run but it doesn't 
worked like it used to work in IDLE.

Can someone explain the possible problem I'm currently facing?

I just want my program to run perfectly in both IDLE and when I double click 
the saved file.

I posted my question in stackoverflow but I didn't find an answer.

http://stackoverflow.com/questions/31692156/i-think-my-computer-has-built-in-python-2-and-i-installed-python-3
-- 
https://mail.python.org/mailman/listinfo/python-list


py2app dependency determination?

2014-06-21 Thread john
Hi, trying to get py2app to work. It keeps saying that we need Pillow-PIL, 
which is wrong. And, anyways, Pillow-PIL fails to install.

The program works fine as a normal python script, and it doesn't use Pillow-
PIL. Any ideas?

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


Re: py2app dependency determination?

2014-06-25 Thread john
Steven D'Aprano wrote:

> On Sat, 21 Jun 2014 16:50:22 -0800, john wrote:
> 
>> Hi, trying to get py2app to work. It keeps saying that we need
>> Pillow-PIL, which is wrong. And, anyways, Pillow-PIL fails to install.
>> 
>> The program works fine as a normal python script, and it doesn't use
>> Pillow- PIL. Any ideas?
> 
> Yes.
> 
> (1) Since this is specifically a py2app issue, you may have better
> results from asking on a dedicated py2app mailing list.
> 
> (2) Is it possible that Pillow or PIL is a dependency of py2app, and the
> error has nothing to do with your script at all? What happens if you run
> py2app on a minimal script like this?
> 
> # hello.py
> print("hello world")
> 
> (3) If not, please post a minimal set of steps that demonstrates the
> problem, and the *exact* error message generated (if possible). For
> example:
> 
> Download py2app version 1.3 from http://some.place.com
> 
> Run the py2app installer.
> 
> Create a minimal script hello.py (as above)
> 
> Run py2app hello.py
> 
> The result is ... [whatever actually happens]
> 
> 
> 

We will try that, thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stackoverflow and c.l.py

2011-09-15 Thread john
On Sep 14, 4:58 pm, Steven D'Aprano  wrote:
> memilanuk wrote:
> > On 09/14/2011 05:47 AM, Chris Angelico wrote:
> >> The SNR here isn't bad either. Most of the spam gets filtered out, and
> >> even stuff like Ranting Rick posts can be of some amusement when it's
> >> a slow day...
>
> > I subscribe to the list via Gmane, and if 'most of the spam' gets
> > filtered out, I'd hate to see how much gets submitted as I still see 2-5
> > minimum blatant spam per day on here.
>
> 2-5 spam posts is nothing. (Well, I know any spam is too much spam, but
> still.) Since nearly all of it is obvious, it's easy to filter out of your
> mail client, news client, or if all else fails, your attention. The hard
> ones to ignore are the ones that look like they might be legitimate, but
> fortunately most spammers are too lazy or stupid to bother with even the
> most feeble disguise.
>
> Either way, I don't consider half a dozen spam posts a day to be anything
> more than a minor distraction.
>
> Commercial spam is annoying, but otherwise harmless because it is so easy to
> filter. What's really the problem is crackpots, trollers and griefers,
> because there is a terrible temptation to engage them in debate: "someone
> is wrong on the Internet!". If you want to see a news group gone bad, go to
> something like sci.math. You can't move for the cranks "disproving"
> Cantor's Diagonal Theorem and Special Relativity and proving that 10**603
> is the One True Actual Infinity (I'm not making that last one up!).
>
> --
> Steven

And, all this time, I'd thought it was ((10**603) - 1) that was the
highest.  Oh, well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-12-18 Thread John
David Schwartz wrote:
> "Aragorn" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
> 
>>>>>>Wrong. The only obligation Microsoft has is to their shareholders.
> 
> 
>>>>>If you genuinely believe that, you are a psychopath.
> 
> 
>>A psychopath is someone who lacks ethics and/or the ability to respect
>>his fellow human being.  They are quite often narcissistic and perverse
>>individuals.  They make good dictators and successful businessmen.
> 
> 
> You have provided an excellent refutation. A psychopath would say that 
> Microsoft's executives only obligations are to themselves. A psychopath 
> would not consider obligations to fellow human beings important. Believe it 
> or not, from the point of view of a Microsoft executive, shareholders are 
> fellow human beings.
> 
> DS
> 
> 
In my humble, poorly informed opinion,

Microsoft SUCKS ASS!!! Their business practices are, in my opinion, a 
clinic in power mania. They refuse to rewrite their kluged, swiss cheese 
OS, for fear of a temporary hit to their bottom line. So the world is 
polluted with this insecure, bomb prone OS. Could anyone not suicidal 
imagine trying to run the ISS, or a manned Lunar Base on MS Windows? Of 
course not.

Humbly,

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


filling forms automatically generated using javascript

2006-11-21 Thread John

Is there an automatic way of filling forms that have been generated
using javascript?
I tried to use python+mechanize but am having trouble with javascript
forms.

This is the way the form is created:





Thanks in advance for your help,
--j

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


cache line length of a machine

2007-01-04 Thread John

How do I find out the cache line length of a machine in python?

Thanks,
--j

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


testing for existence of compilers/executables

2006-03-05 Thread John
I am working with my build system using scons. I would like
to test the existence of 'doxygen' or any other compiler/executable
in the path (like gcc/icc/...)

What is the most efficient way to find this out using python? using
scons?
Is there a way to list all C/C++/fortran compilers available on a
machine
using python so that I can give my user an option to select one?

Thanks a lot for your help,
--j

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


descriptor dilemma

2005-05-04 Thread john
Hello,

I was wondering if someone could explain the following situation to me
please:

>>> class C(object):
def f(self):
pass
>>> c = C()
>>> c.f
>
>>> C.__dict__['f'].__get__(c,C)
>
>>> c.f == C.__dict__['f'].__get__(c,C)
True
>>> c.f is C.__dict__['f'].__get__(c,C)
False

Why do c.f and C.__dict__['f'].__get__(c,C) compare as equal under ==
but not under *is*  ?

Thanks,

John

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


High resolution sleep (Linux)

2007-05-04 Thread John

The table below shows the execution time for this code snippet as
measured by the unix command `time':

for i in range(1000):
time.sleep(inter)

inter   execution time  ideal
0 0.02 s0 s
1e-44.29 s0.1 s
1e-34.02 s1 s
2e-34.02 s2 s
5e-38.02 s5 s

Hence it seems like the 4 s is just overhead and that the time.sleep
method treats values below approximately 0.001 as 0.

Is there a standard way (or slick trick) to get higher resolution? If
it is system dependent it's acceptable but not very nice :)

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


Re: High resolution sleep (Linux)

2007-05-10 Thread John
On 9 Maj, 03:23, John Nagle <[EMAIL PROTECTED]> wrote:
> Hendrik van Rooyen wrote:
> >  "Tim Roberts" <[EMAIL PROTECTED]> wrote"
> > It is also possible to keep the timer list sorted by "expiry date",
> > and to reprogram the timer to interrupt at the next expiry time
> > to give arbitrary resolution, instead of implementing a regular 'tick'.
>
>  Yes, and that's a common feature in real-time operating systems.
> If you're running QNX, you can expect that if your high priority
> task delays to a given time, you WILL get control back within a
> millisecond of the scheduled time.   Even tighter timing control
> is available on some non-x86 processors.
>
>  Some CPUs even have hardware support for a sorted event list.
> The Intel 8061, which ran the engines of most Ford cars in the 1980s,
> had that.
>
>  But no way are you going to get consistent timing resolution like that
> from Python.  It's an interpreter with a garbage collector, after all.
>
> John Nagle


The application the original poster (i.e. me) was interested in was a
program that sends ethernet packets at a loosely specified rate. A
loop that sends all packets with no sleep in between will send them at
a too high rate. Using the default sleep in my Python interpreter
sleeps to long, since even a few microseconds add up when you send
hundreds of thousands of packets.

If the process scheduler deals with another process now and then, it
doesn't matter. If it switches to another application between each
packet is beeing sent, that's a problem.

Anyways, what I need is high resolution sleep, not high resolution
timing. Installing a real time OS seems like overkill.

(Yes I know, one can also send, say, 50 packets at a time, and then
sleep, send 50 more packets, and so on.)

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


Re: Call for advice on how to start PyOpenGL!

2007-08-21 Thread John
On Aug 20, 1:53 am, math2life <[EMAIL PROTECTED]> wrote:
> I work with python for two years, are familiar with image processing,
> but beginner on PyOpenGL and OpenGL.
>
> Any advice appreciated!

Here's a little "hello world" PyOpenGL program I had lying around that
might be useful:

http://www.milliwatt-software.com/jmg/files/pyopengl_template.py

---John

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


Is numeric keys of Python's dictionary automatically sorted?

2007-03-07 Thread John
I am coding a radix sort in python and I think that Python's dictionary may 
be a choice for bucket.

The only problem is that dictionary is a mapping without order. But I just 
found that if the keys are numeric, the keys themselves are ordered in the 
dictionary.

part of my code is like this:
radix={}
for i in range(256):
radix[i]=[]

I checked and found that it is ordered like: {1:[], 2:[], 3[],...}

So I can just print out the contents of the dictionary in the desired order 
without additional code.
I also tried adding new numeric keys and found that the dictionary's keys 
are still ordered.

However, I am not sure whether it is always like this. Can anybody confirm 
my finding?
 


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


Re: Is numeric keys of Python's dictionary automatically sorted?

2007-03-07 Thread John
Then is there anyway to sort the numeric keys and avoid future implemetation 
confusion?


"Ant" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Mar 7, 8:18 pm, "John" <[EMAIL PROTECTED]> wrote:
> ...
>> However, I am not sure whether it is always like this. Can anybody 
>> confirm
>> my finding?
>
>>From the standard library docs:
>
> "Keys and values are listed in an arbitrary order which is non-random,
> varies across Python implementations, and depends on the dictionary's
> history of insertions and deletions."
>
> i.e. the behaviour you have discovered is an implementation detail,
> and could change in future versions.
> 


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


any better code to initalize a list of lists?

2007-03-08 Thread John
For my code of radix sort, I need to initialize 256 buckets. My code looks a 
little clumsy:

radix=[[]]
for i in range(255):
radix.append([])

any better code to initalize this list? 


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


Re: any better code to initalize a list of lists?

2007-03-08 Thread John
I want to radix sort non-negative integers that can fit into 32-bits. That 
will take 4 passes, one for each byte. So, I will need 256 "buckets"
The list radix of 256 elements of list is good for this purpose.

Your code is much shorter, works and probably takes less time.

Thanks!

John


"Paul Rubin" <http://[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "John" <[EMAIL PROTECTED]> writes:
>> For my code of radix sort, I need to initialize 256 buckets. My code 
>> looks a
>> little clumsy:
>>
>> radix=[[]]
>> for i in range(255):
>> radix.append([])
>>
>> any better code to initalize this list?
>
> Typically you'd say
>   radix = [[] for i in xrange(256)]
>
> but what are you really doing?  This plan to implement radix sorting
> sounds a little bit odd, unless it's just an exercise.
>
> You could also consider using a dictionary instead of a list,
> something like:
>
>   radix = defaultdict(list) 


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


How to calculate a file of equations in python

2007-03-19 Thread John
Hi,
I have a text file which contains math expression, like this
134
+234
+234

(i.e. an operation (e.g. '+) and then a number and then a new line).

Can you please tell me what is the easiest way to calculate that file?
for example the above example should be = 134 + 234 + 234 = 602.

Thank you.

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


Video sharing social network Teenwag seeks great Python hackers we ll wear Python T-shirts at startupschool

2007-03-23 Thread John
Video sharing social network Teenwag seeks great Python hackers we ll
wear Python T-shirts at startup school $100K $5K sign on $2k
referral


http://www.teenwag.com/showvideo/352

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


how to check the 'content/type' using urlopen

2007-04-15 Thread John

i have the following code to open a URL address, but can you please
tell me how can I check the content type of the url response?

Thank you.

  try:
req = Request(url, txdata, txheaders)
handle = urlopen(req)
except IOError, e:
print e
print 'Failed to open %s' % url
return 0;

else:
data = handle.read()

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


unittest assertRaises Problem

2007-04-16 Thread john
All:

Hi. I am an experienced developer (15 yrs), but new to Python and have
a question re unittest and assertRaises. No matter what I raise,
assertRaises is never successful. Here is the test code:


class Foo:
def testException(self):
   raise ValueError

class FooTestCase(unittest.TestCase):

   testTryThis(self):
  f = Foo()
  self.assertRaises(ValueError, f.testException())

This fails --- unittest reports the following:
FAILED (errors=1)

This seems like the most basic thing in the world. I am running Python
2.5 on Windows XP using Eclipse and PyDev

Any help appreciated.

Thanks,
John

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


Re: unittest assertRaises Problem

2007-04-16 Thread john
On Apr 16, 6:35 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On 16 Apr 2007 15:13:42 -0700, john <[EMAIL PROTECTED]> wrote:
>
>
>
> >All:
>
> >Hi. I am an experienced developer (15 yrs), but new to Python and have
> >a question re unittest and assertRaises. No matter what I raise,
> >assertRaises is never successful. Here is the test code:
>
> >class Foo:
> >def testException(self):
> >   raise ValueError
>
> >class FooTestCase(unittest.TestCase):
>
> >   testTryThis(self):
> >  f = Foo()
> >  self.assertRaises(ValueError, f.testException())
>
> The 2nd argument to assertRaises should be a callable.  assertRaises
> will call it (so that it can do exception handling), so you shouldn't:
>
> self.assertRaises(ValueError, f.testException)
>
> Jean-Paul

Steven, Jean-Paul:

Thank you both for your answers - worked like a charm!

Best,
John

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


Cross platform way of finding number of processors on a machine?

2007-10-04 Thread John

Is there a way to find the number of processors on a machine (on linux/
windows/macos/cygwin) using python code (using the same code/cross
platform code)?

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


Re: setuptools without unexpected downloads

2007-10-07 Thread John
On Sep 27, 11:42 am, Istvan Albert <[EMAIL PROTECTED]> wrote:
> On Sep 26, 2:09 am, Ben Finney <[EMAIL PROTECTED]> wrote:
>
> > behaviour with a specific invocation of 'setup.py'. But how can I
> > disallow this from within the 'setup.py' program, so my users don't
> > have to be aware of this unexpected default behaviour?
>
> I don't have the answer for this, but I can tell you that I myself
> dislike the auto-download behavior and I wish it worked differently.
>
> I've given up on setuptools/easy-install altogether. It is most
> annoying to end up with half a dozen unexpected packages.
>
> The default behavior should be to pop a question with a list of
> packages that will be downloaded (and have a flag that bypasses this).
> And of course being able to turn off this feature from setup.py.
>
> i.

I think you're exactly right, Istvan. Maybe someone will write a patch
for what you suggest.

I haven't done any packaging myself, but it would seem to me that
another trick users could resort to might be to look at the setup.py
setup() function's install_requires arg, and then try to install
what's listed there using their own system's package management
software.

I'm not exactly sure what the --no-deps arg to easy_install does. Does
it force the named package to install without its dependencies, or
does it give a package listing and then bail out without installing
anything? The docs don't seem to specify.

---John

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


Threaded for loop

2007-01-13 Thread John

I want to do something like this:

for i = 1 in range(0,N):
 for j = 1 in range(0,N):
   D[i][j] = calculate(i,j)

I would like to now do this using a fixed number of threads, say 10
threads.
What is the easiest way to do the "parfor" in python?

Thanks in advance for your help,
--j

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


Re: Threaded for loop

2007-01-13 Thread John

Damn! That is bad news. So even if caclulate is independent for (i,j)
and
is computable on separate CPUs (parts of it are CPU bound, parts are IO
bound)
python cant take advantage of this?

Surprised,
--Tom

Paul Rubin wrote:
> "John" <[EMAIL PROTECTED]> writes:
> > I want to do something like this:
> >
> > for i = 1 in range(0,N):
> >  for j = 1 in range(0,N):
> >D[i][j] = calculate(i,j)
> >
> > I would like to now do this using a fixed number of threads, say 10
> > threads. What is the easiest way to do the "parfor" in python?
>
> It won't help in terms of actual parallelism.  Python only lets one
> thread run at a time, even on a multi-cpu computer.

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


Re: Threaded for loop

2007-01-13 Thread John

Damn! That is bad news. So even if caclulate is independent for (i,j)
and
is computable on separate CPUs (parts of it are CPU bound, parts are IO
bound)
python cant take advantage of this?

Surprised,
--j

Paul Rubin wrote:
> "John" <[EMAIL PROTECTED]> writes:
> > I want to do something like this:
> >
> > for i = 1 in range(0,N):
> >  for j = 1 in range(0,N):
> >D[i][j] = calculate(i,j)
> >
> > I would like to now do this using a fixed number of threads, say 10
> > threads. What is the easiest way to do the "parfor" in python?
>
> It won't help in terms of actual parallelism.  Python only lets one
> thread run at a time, even on a multi-cpu computer.

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


Re: Threaded for loop

2007-01-13 Thread John


Thanks. Does it matter if I call shell commands os.system...etc in
calculate?

Thanks,
--j

[EMAIL PROTECTED] wrote:
> John wrote:
> > I want to do something like this:
> >
> > for i = 1 in range(0,N):
> >  for j = 1 in range(0,N):
> >D[i][j] = calculate(i,j)
> >
> > I would like to now do this using a fixed number of threads, say 10
> > threads.
> > What is the easiest way to do the "parfor" in python?
> >
> > Thanks in advance for your help,
>
> As it was already mentioned before threads will not help in terms of
> parallelism (only one thread will be actually working). If you want to
> calculate this in parallel here is an easy solution:
>
> import ppsmp
>
> #start with 10 processes
> srv = ppsmp.Server(10)
>
> f = []
>
> for i = 1 in range(0,N):
>   for j = 1 in range(0,N):
>   #it might be a little bit more complex if 'calculate' depends on
> other modules or calls functions
>   f.append(srv.submit(calculate, (i,j)))
>
> for i = 1 in range(0,N):
>   for j = 1 in range(0,N):
>  D[i][j] = f.pop(0)
>
> You can get the latest version of ppsmp module here:
> http://www.parallelpython.com/

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


html + javascript automations = [mechanize + ?? ] or something else?

2007-01-15 Thread John

I have to write a spyder for a webpage that uses html + javascript. I
had it written using mechanize
but the authors of the webpage now use a lot of javascript. Mechanize
can no longer do the job.
Does anyone know how I could automate my spyder to understand
javascript? Is there a way
to control a browser like firefox from python itself? How about IE?
That way, we do not have
to go thru something like mechanize?

Thanks in advance for your help/comments,
--j

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


Re: html + javascript automations = [mechanize + ?? ] or something else?

2007-01-15 Thread John

I am curious about the webbrowser module. I can open up firefox
using webbrowser.open(), but can one control it? Say enter a
login / passwd on a webpage? Send keystrokes to firefox?
mouse clicks?

Thanks,
--j

John wrote:
> I have to write a spyder for a webpage that uses html + javascript. I
> had it written using mechanize
> but the authors of the webpage now use a lot of javascript. Mechanize
> can no longer do the job.
> Does anyone know how I could automate my spyder to understand
> javascript? Is there a way
> to control a browser like firefox from python itself? How about IE?
> That way, we do not have
> to go thru something like mechanize?
> 
> Thanks in advance for your help/comments,
> --j

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


installing/maintaining modules for multiple versions of python

2007-01-15 Thread John

I have a suse box that has by default python 2.4 running and I have a
2.5 version installed
in /reg/python2.5. How do I install new modules for only 2.5 without
disturbing the 2.4 default
installation. 

Thanks,
--j

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


Re: html + javascript automations = [mechanize + ?? ] or something else?

2007-01-21 Thread John

I tried to install pamie (but I have mostly used python on cygwin on
windows).
In the section " What will you need to run PAMIE", it says I will need
"Mark Hammonds Win32 All"
which I can not find. Can anyone tell me how do I install PAMIE? Do I
need python for
windows that is different from cygwin's python?

Thanks,
--j

ina wrote:
> John wrote:
> > I have to write a spyder for a webpage that uses html + javascript. I
> > had it written using mechanize
> > but the authors of the webpage now use a lot of javascript. Mechanize
> > can no longer do the job.
> > Does anyone know how I could automate my spyder to understand
> > javascript? Is there a way
> > to control a browser like firefox from python itself? How about IE?
> > That way, we do not have
> > to go thru something like mechanize?
> >
> > Thanks in advance for your help/comments,
> > --j
>
> You want pamie, iec or ishybrowser.  Pamie is probably the best choice
> since it gets patches and updates on a regular basis.
> 
> http://pamie.sourceforge.net/

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


Re: html + javascript automations = [mechanize + ?? ] or something else?

2007-01-21 Thread John


My python2.5 installation on windows did not come with "win32com".
How do I install/get this module for windows?

Thanks,
--j

Duncan Booth wrote:
> "John" <[EMAIL PROTECTED]> wrote:
>
> > Is there a way
> > to control a browser like firefox from python itself? How about IE?
>
> IE is easy enough to control and you have full access to the DOM:
>
> >>> import win32com
> >>> win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-
> C05BAE0B}', 0, 1, 1)
>  'C:\Python25\lib\site-packages\win32com\gen_py\EAB22AC0-30C1-11CF-A7EB-
> C05BAE0Bx0x1x1.py'>
> >>> IE = win32com.client.DispatchEx('InternetExplorer.Application.1')
> >>> dir(IE)
> ['CLSID', 'ClientToWindow', 'ExecWB', 'GetProperty', 'GoBack', 'GoForward',
> 'GoHome', 'GoSearch', 'Navigate', 'Navigate2', 'PutProperty',
> 'QueryStatusWB', 'Quit', 'Refresh', 'Refresh2', 'ShowBrowserBar', 'Stop',
> '_ApplyTypes_', '__call__', '__cmp__', '__doc__', '__getattr__',
> '__init__', '__int__', '__module__', '__repr__', '__setattr__', '__str__',
> '__unicode__', '_get_good_object_', '_get_good_single_object_', '_oleobj_',
> '_prop_map_get_', '_prop_map_put_', 'coclass_clsid']
> >>> IE.Visible=True
> >>> IE.Navigate("http://plone.org";)
> >>> while IE.Busy: pass
>
> >>> print IE.Document.getElementById("portlet-news").innerHTML
>  href="feed://plone.org/news/newslisting/RSS">http://plone.org/rss.gif";>  href="http://plone.org/news";>News 
>
> ... and so on ...
>
>
> See
> http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/int
> ernetexplorer.asp
> for the documentation.

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


Re: html + javascript automations = [mechanize + ?? ] or somethingelse?

2007-01-21 Thread John

I tried it, didnt work with the python25 distribution msi file that is
on python.org
But activestate python worked. Now I can open IE using COM. What I am
trying
to figure out is how to click an x,y coordinate on a page in IE
automatically
using COM. How about typing something automatically...Any ideas?

Thanks,
--j

Gabriel Genellina wrote:
> "John" <[EMAIL PROTECTED]> escribió en el mensaje
> news:[EMAIL PROTECTED]
>
> > My python2.5 installation on windows did not come with "win32com".
> > How do I install/get this module for windows?
>
> Look for the pywin32 package at sourceforge.net
> 
> -- 
> Gabriel Genellina

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


class explorer for automating IE

2007-01-21 Thread John

I found this class which was written in 2003.

http://xper.org/wiki/seminar/InternetExplorerAutomation

Is there a better/more complete version around that someone knows of.

Thanks,
--j

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


Re: class explorer for automating IE

2007-01-21 Thread John

Is there an analogue of IE Mechanize in python?

http://search.cpan.org/src/ABELTJE/Win32-IE-Mechanize-0.009/README

Thanks,
--j

On Jan 22, 1:48 am, "John" <[EMAIL PROTECTED]> wrote:
> I found this class which was written in 2003.
>
> http://xper.org/wiki/seminar/InternetExplorerAutomation
>
> Is there a better/more complete version around that someone knows of.
> 
> Thanks,
> --j

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


Re: class explorer for automating IE

2007-01-22 Thread John

The problem is that this does not run javascript code it seems.
I got started with pamie, which seems to work till now.

Thanks,
--j

On Jan 22, 2:42 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> John wrote:
> > Is there an analogue of IE Mechanize in 
> > python?http://www.google.com/search?q=python%20mechanize&btnI=I%27m+Feeling+...

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


Can somebody give me a python code for this?

2007-02-07 Thread John
Given an array of elements, look at it as a binary tree. Start at the last 
interior node, and downheap it. Then downheap the previous interior node, 
and continue in this fashion, up to the root. 


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


Re: Can somebody give me a python code for this?

2007-02-07 Thread John
I solved it myself.
Don't bother.

"John" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Given an array of elements, look at it as a binary tree. Start at the last 
> interior node, and downheap it. Then downheap the previous interior node, 
> and continue in this fashion, up to the root.
> 


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


Re: Newbie Question

2007-02-08 Thread John
Visual Basic is also good.


"Reid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello all
>
> I am just starting to play with programing again as a hobby. I have heard
> good things about python. I have not really looked into the language much.
> My question is, will python make programs with a gui under windows xp. If
it
> will do this I will explore the language more, if not I will try some
other
> language.
>
> Reid
>
>


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


How to covert ASCII to integer in Python?

2007-02-22 Thread John
Is there any built in function that converts ASCII to integer or vice versa
in Python?

Thanks!


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


Re: How to covert ASCII to integer in Python?

2007-02-22 Thread John
I just found ord(c), which convert ascii to integer.

Anybody know what the reverse is?

"John" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Is there any built in function that converts ASCII to integer or vice
versa
> in Python?
>
> Thanks!
>
>


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


What is the best queue implemetation in Python?

2007-02-22 Thread John
I want to write a code for Breadth First Traveral for Graph, which needs a
queue to implement.

I wonder that for such a powerful language as Python, whether there is a
better and simpler implementation for a traditional FIFO queue?


Thanks!


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


Re: What is the best queue implemetation in Python?

2007-02-22 Thread John
Than C or PASCAL
I mean, list or dictionary in Python are so powerful than the traditional
array. Maybe I can make use of it?


"John Machin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Feb 23, 11:12 am, "John" <[EMAIL PROTECTED]> wrote:
> > I want to write a code for Breadth First Traveral for Graph, which needs
a
> > queue to implement.
> >
> > I wonder that for such a powerful language as Python, whether there is a
> > better and simpler implementation for a traditional FIFO queue?
> >
>
> Better and simpler than *WHAT*?
>
>
>
>


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


Re: How to output newline or carriage return with optparse

2007-11-08 Thread John
On Nov 8, 12:40 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > Thanks for the help Tim.  I just copied and pasted your code into a
> > file in my $PYTHONPATH (IndentedHelpFormatterWithNL.py), but I'm
> > getting the following error:
>
> > class IndentedHelpFormatterWithNL(IndentedHelpFormatter):
> > NameError: name 'IndentedHelpFormatter' is not defined
>
> > I tried adding: from optparse imoport IndentedHelpFormatter into the
> > aforementioned file, but no luck again.  What am I missing???
>
> spelling "import" correctly? :)  Also, make sure that, if you've
> named your module "IndentedHelpFormatterWithNL.py" that created
> your parser with
>
>parser = OptionParser(...
>  formatter=
>  IndentedHelpFormatterWithNL.IndentedHelpFormatterWithNL
>  )
>
> You'll also want to make sure that these two lines:
>
>from optparse import IndentedHelpFormatter
>import textwrap
>
> are at the top of the IndentedHelpFormatterWithNL.py file, not at
> the top of the file importing the IndentedHelpFormatter.
>
> -tkc

That seems to do the trick.  I'm sure there are quite a few people out
there who have run into this same problem-- I'm glad you're adding it
to the patches!

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


Re: python from any command line?

2007-12-09 Thread john
Hi,

You need to edit your path variable. (I'm assuming you're using
Windows). Go to:

Settings > Control Panel > System > Advanced > Environment Variables.

Now double click on 'Path' and append ";C:\Python25\" (minus the
quotation marks) to the text displayed in the Variable Value box.

BW,

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


popen3 on windows

2006-04-28 Thread John
Hello.  Can anyone tell me how to get p.poll() or a workaound to work when 
using popen3() on windows? I use python 2.3.  I am trying to launch a 
command window to execute a command and then check periodically to see if 
the command has finished executing.  If it has not finished after a given 
amount of time, I want to close the process.  Is this possible on windows?

p = win32pipe.popen3('command') will create the tuple of files p, but none 
have a poll() attribute.  p[1].read() will hang up if the command has not 
finished.  Any suggestions?  The other alternative is that I use the above 
to start the command and then use another os command to see if my process is 
running in the background on windows.  If it is, then perhaps I can close it 
if it if need be.

Thanks. 


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


printing dots in simple program while waiting

2008-01-09 Thread John
Ok, so this should be a really simple thing to do, but I haven't been
able to get it on the first few tries and couldn't find anything after
searching a bit.

what i want to do is print a 'waiting' statement while a script is
working-- the multithreading aspect isn't an issue, the printing on
the same line is.  i want to print something like:

(1sec) working...
(2sec) working
(3sec) working.


where the 'working' line isn't being printed each second, but the dots
are being added with time.

something like:

import time
s = '.'
print 'working'
while True:
print s
time.sleep(1)


however, this doesn't work since it prints:

working
.
.
.

any suggestions?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: printing dots in simple program while waiting

2008-01-09 Thread John
On Jan 9, 11:56 am, Martin Marcher <[EMAIL PROTECTED]> wrote:
> John wrote:
> > import time
> > s = '.'
> > print 'working', # Note the "," at the end of the line
> > while True:
> > print s
> > time.sleep(1)
>
> see my comment in the code above...
>
> if that's what you mean
>
> /martin
>
> --http://noneisyours.marcher.namehttp://feeds.feedburner.com/NoneIsYours
>
> You are not free to read this message,
> by doing so, you have violated my licence
> and are required to urinate publicly. Thank you.

Thanks for the input Martin, but I already tried that.  If you put a
comma on that line it successfully prints the first '.' on the same
line, but the rest below.  Like:

working .
.
.
.



I want:

working..


I have tried the comma thing on the "print s" line ("print s,"), but
then it doesn't print anything at all...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: printing dots in simple program while waiting

2008-01-09 Thread John
On Jan 9, 12:14 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote:
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:python-
> > [EMAIL PROTECTED] On Behalf Of Martin Marcher
> > Sent: Wednesday, January 09, 2008 11:57 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: printing dots in simple program while waiting
>
> > John wrote:
>
> > > import time
> > > s = '.'
> > > print 'working', # Note the "," at the end of the line
> > > while True:
> > > print s
> > > time.sleep(1)
>
> > see my comment in the code above...
>
> > if that's what you mean
>
> Bah.  The trailing command may prevent the newline, but it appends a
> space whether you want it or not.[1]  Use sys.stdout.write('.') instead.
>
> import sys
>
> print "wussy nanny state, tax 'n spend my spaces, liberal comma:"
> for i in range(1, 10):
> print '.',
> print
> print "manly neo-con I know what's Right so keep your government out of
> my strings! print:"
> for i in range(1, 10):
> sys.stdout.write('.')
>
> [1] Which has to be _the_ most annoying feature of Python.  *grrr*
>
> *
>
> The information transmitted is intended only for the person or entity to 
> which it is addressed and may contain confidential, proprietary, and/or 
> privileged material. Any review, retransmission, dissemination or other use 
> of, or taking of any action in reliance upon this information by persons or 
> entities other than the intended recipient is prohibited. If you received 
> this in error, please contact the sender and delete the material from all 
> computers. GA625





Thanks for all of the help.  This is what ended up working:



import time
import sys

s = '.'
sys.stdout.write( 'working' )
while True:
sys.stdout.write( s )
sys.stdout.flush()
time.sleep(0.5)



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


matplotlib install error

2008-02-07 Thread John
I'm trying to install matplotlib and currently getting the below
error.  I searched the group and google and couldn't find anything
similar... Any ideas?

Thanks in advance!

src/ft2font.cpp: In member function 'Py::Object
Glyph::get_path(FT_FaceRec_* const&)':
src/ft2font.cpp:441: error: 'FT_CURVE_TAG_CUBIC' was not declared in
this scope
src/ft2font.cpp:444: error: 'FT_CURVE_TAG_CONIC' was not declared in
this scope
src/ft2font.cpp:447: error: 'FT_CURVE_TAG_ON' was not declared in this
scope
src/ft2font.cpp:487: error: 'FT_CURVE_TAG_ON' was not declared in this
scope
src/ft2font.cpp:500: error: 'FT_CURVE_TAG_CONIC' was not declared in
this scope
src/ft2font.cpp:572: error: 'FT_CURVE_TAG_CUBIC' was not declared in
this scope
src/ft2font.cpp: In member function 'Py::Object
FT2Font::set_text(const Py::Tuple&, const Py::Dict&)':
src/ft2font.cpp:983: error: 'FT_KERNING_DEFAULT' was not declared in
this scope
src/ft2font.cpp: In member function 'Py::Object
FT2Font::get_ps_font_info(const Py::Tuple&)':
src/ft2font.cpp:1428: error: 'PS_FontInfoRec' was not declared in this
scope
src/ft2font.cpp:1428: error: expected `;' before 'fontinfo'
src/ft2font.cpp:1430: error: 'fontinfo' was not declared in this scope
src/ft2font.cpp:1430: error: 'FT_Get_PS_Font_Info' was not declared in
this scope
src/ft2font.cpp: In function 'void initft2font()':
src/ft2font.cpp:1884: error: 'FT_KERNING_DEFAULT' was not declared in
this scope
src/ft2font.cpp:1885: error: 'FT_KERNING_UNFITTED' was not declared in
this scope
src/ft2font.cpp:1886: error: 'FT_KERNING_UNSCALED' was not declared in
this scope
src/ft2font.cpp:1905: error: 'FT_LOAD_NO_AUTOHINT' was not declared in
this scope
src/ft2font.cpp:1906: error: 'FT_LOAD_TARGET_NORMAL' was not declared
in this scope
src/ft2font.cpp:1907: error: 'FT_LOAD_TARGET_LIGHT' was not declared
in this scope
src/ft2font.cpp:1908: error: 'FT_LOAD_TARGET_MONO' was not declared in
this scope
src/ft2font.cpp:1909: error: 'FT_LOAD_TARGET_LCD' was not declared in
this scope
src/ft2font.cpp:1910: error: 'FT_LOAD_TARGET_LCD_V' was not declared
in this scope
error: command 'gcc' failed with exit status 1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: matplotlib install error

2008-02-08 Thread John

> Is thate really all of the error? It hints on a missing include, which
> will be mentioned earlier.
>
> Diez

  platform: linux2

REQUIRED DEPENDENCIES
 numpy: 1.0.3.1
 freetype2: found, but unknown version (no pkg-config)

OPTIONAL BACKEND DEPENDENCIES
libpng: found, but unknown version (no pkg-config)
   Tkinter: Tkinter: 50704, Tk: 8.3, Tcl: 8.3
  wxPython: no
* wxPython not found
  Gtk+: no
* Building for Gtk+ requires pygtk; you must
be able
* to "import gtk" in your build/install
environment
Qt: no
   Qt4: no
 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
  datetime: present, version unknown
  dateutil: matplotlib will provide
  pytz: matplotlib will provide

OPTIONAL USETEX DEPENDENCIES
dvipng: no
   ghostscript: 6.52
 latex: 3.14159
   pdftops: 1.00

EXPERIMENTAL CONFIG PACKAGE DEPENDENCIES
 configobj: matplotlib will provide
  enthought.traits: matplotlib will provide

[Edit setup.cfg to suppress the above messages]

running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-
i686-2.5/matplotlib/mpl-data
copying lib/matplotlib/mpl-data/matplotlib.conf -> build/lib.linux-
i686-2.5/matplotlib/mpl-data
running build_ext
building 'matplotlib.ft2font' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-
prototypes -fPIC -I/usr/local/include -I/usr/include -I. -I/usr/local/
include/freetype2 -I/usr/include/freetype2 -I./freetype2 -I/data1/
szscm1/usr/local/include/python2.5 -c src/ft2font.cpp -o build/
temp.linux-i686-2.5/src/ft2font.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid
for Ada/C/ObjC but not for C++
In file included from /data1/szscm1/usr/local/include/python2.5/
Python.h:8,
 from ./CXX/WrapPython.h:47,
 from ./CXX/Extensions.hxx:48,
 from src/ft2font.h:18,
 from src/ft2font.cpp:2:
/data1/szscm1/usr/local/include/python2.5/pyconfig.h:932:1: warning:
"_POSIX_C_SOURCE" redefined
In file included from /data1/qzcpfl/gcc-build/lib/gcc/i686-pc-linux-
gnu/4.2.1/../../../../include/c++/4.2.1/i686-pc-linux-gnu/bits/
os_defines.h:44,
 from /data1/qzcpfl/gcc-build/lib/gcc/i686-pc-linux-
gnu/4.2.1/../../../../include/c++/4.2.1/i686-pc-linux-gnu/bits/c+
+config.h:41,
 from /data1/qzcpfl/gcc-build/lib/gcc/i686-pc-linux-
gnu/4.2.1/../../../../include/c++/4.2.1/iosfwd:44,
 from /data1/qzcpfl/gcc-build/lib/gcc/i686-pc-linux-
gnu/4.2.1/../../../../include/c++/4.2.1/ios:43,
 from /data1/qzcpfl/gcc-build/lib/gcc/i686-pc-linux-
gnu/4.2.1/../../../../include/c++/4.2.1/istream:44,
 from /data1/qzcpfl/gcc-build/lib/gcc/i686-pc-linux-
gnu/4.2.1/../../../../include/c++/4.2.1/sstream:44,
 from src/ft2font.cpp:1:
/usr/include/features.h:131:1: warning: this is the location of the
previous definition
src/ft2font.cpp: In member function 'Py::Object
Glyph::get_path(FT_FaceRec_* const&)':
src/ft2font.cpp:441: error: 'FT_CURVE_TAG_CUBIC' was not declared in
this scope
src/ft2font.cpp:444: error: 'FT_CURVE_TAG_CONIC' was not declared in
this scope
src/ft2font.cpp:447: error: 'FT_CURVE_TAG_ON' was not declared in this
scope
src/ft2font.cpp:487: error: 'FT_CURVE_TAG_ON' was not declared in this
scope
src/ft2font.cpp:500: error: 'FT_CURVE_TAG_CONIC' was not declared in
this scope
src/ft2font.cpp:572: error: 'FT_CURVE_TAG_CUBIC' was not declared in
this scope
src/ft2font.cpp: In member function 'Py::Object
FT2Font::set_text(const Py::Tuple&, const Py::Dict&)':
src/ft2font.cpp:983: error: 'FT_KERNING_DEFAULT' was not declared in
this scope
src/ft2font.cpp: In member function 'Py::Object
FT2Font::get_ps_font_info(const Py::Tuple&)':
src/ft2font.cpp:1428: error: 'PS_FontInfoRec' was not declared in this
scope
src/ft2font.cpp:1428: error: expected `;' before 'fontinfo'
src/ft2font.cpp:1430: error: 'fontinfo' was not declared in this scope
src/ft2font.cpp:1430: error: 'FT_Get_PS_Font_Info' was not declared in
this scope
src/ft2font.cpp: In function 'void initft2font()':
src/ft2font.cpp:1884: error: 'FT_KERNING_DEFAULT' was not declared in
this scope
src/ft2font.cpp:1885: error: 'FT_KERNING_UNFITTED' was not declared in
this scope
src/ft2font.cpp:1886: error: 'FT_KERNING_UNSCALED' was not declared in
this scope
src/ft2font.cpp:1905: error: 'FT_LOAD_NO_AUTOHINT' was not declared in
this scope
src/ft2font.cpp:1906: error: 'FT_LOAD_TARGET_NORMAL' was not declared
in this scope
src/ft2font.cpp:1907: error: 'FT_LOAD_TARGET_LIGHT' was not declared
in this scope
src/ft2font.cpp:1908: error: 'FT_LOAD_TARG

Topographical sorting

2008-02-11 Thread John
I'm working on a project involving the topographical sorting of partially
ordered sets (posets), using the poset (S, |), where S is the set of
integers <= n. Ultimately, I need to determine all possible topographical
sorts for whatever n happens to be. This requires me to be able to build the
ordered set and then traverse it. The majority of my work is done, and I am
now stuck on figuring out how to determine the number of total sorts
possible. If you are unfamiliar with posets, here is a quick bit of
information about them:

Say that n=6. This means my set of data is {1, 2, 3, 4, 5, 6}. My condition
is |, or the divisor symbol. So I would construct my set with the following
relationship:

1 has all primes as its neighbors
2 divides 4 and 6
3 divides 6

1 does not divide 4 or 6, as posets are transitive, meaning if 1/2 and 2/4,
then it can be said that 1/4. This can be much better represented in this
simple diagram: http://i26.tinypic.com/2ywejwo.jpg

Now, on to my problem. Topographical sorting essentially involves removing
the minimal element in a set (1), and then arbitrarily choosing the next
minimal element and removing it as well. So, after removing 1, one could
remove 5, then 2, then 3, then 4, then 6, resulting in the sort of 15234.
One could also get 123456. There are a number of sorts possible. This is
where I am currently stuck, attempting to implement an algorithm that finds
all possible sorts. I have looked at the topographical pseudocode available
at Wikipedia, but this does not apply - it finds one topographical sort, not
all.

If anyone can offer me some guidance as to where to go from here, it would
be greatly appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Reading text file with wierd file extension?

2009-02-02 Thread john
On Feb 2, 7:57 pm, Mike Driscoll  wrote:
> On Feb 2, 8:08 pm, Lionel  wrote:
>
>
>
> > On Feb 2, 5:40 pm, "Rhodri James"  wrote:
>
> > > [Quoting restored for reduced
>
> > > On Mon, 02 Feb 2009 22:33:50 -, Lionel  wrote:
> > > > On Feb 2, 2:01 pm, Mike Driscoll  wrote:
> > > >> On Feb 2, 3:43 pm, Lionel  wrote:
> > > >> > On Feb 2, 1:07 pm, "Diez B. Roggisch"  wrote:
>
> > > >> >> This is written very slowly, so you can read it better:
>
> > > >> > Please post without sarcasm.
>
> > > On Usenet?  You'll be wanting single unequivocal answers next!
>
> > > Seriously though, you had been asked several times for the traceback,
> > > so that we could stop guessing and tell you for sure what was going
> > > on, and you hadn't provided it.  Diez's mild sarcasm was not uncalled-
> > > for.  The fact that you didn't have a traceback partially excuses you,
> > > but it would have helped if you'd said so.
>
> > > >> > This is the output from my Python shell:
>
> > > >> > >>> DatafilePath = "C:\\C8Example1.slc"
> > > >> > >>> ResourcefilePath = DatafilePath + ".rsc"
> > > >> > >>> DatafileFH = open(DatafilePath)
> > > >> > >>> ResourceFh = open(ResourcefilePath)
> > > >> > >>> DatafilePath
>
> > > >> > 'C:\\C8Example1.slc'>>> ResourcefilePath
>
> > > >> > 'C:\\C8Example1.slc.rsc'
>
> > > >> > It seems to run without trouble. However, here is the offending code
> > > >> > in my class (followed by console output):
>
> > > >> > class C8DataType:
>
> > > >> >     def __init__(self, DataFilepath):
>
> > > >> >         try:
> > > >> >             DataFH = open(DataFilepath, "rb")
>
> > > >> >         except IOError, message:
> > > >> >             # Error opening file.
> > > >> >             print(message)
> > > >> >             return None
>
> > > You're catching the IOError, presumably so that you can fail
> > > gracefully elsewhere.  This may not be a particularly good
> > > idea, and in any case it stops the exception reaching the
> > > console where it would cause the traceback to be displayed.
> > > More on this later.
>
> > > >> >         ResourceFilepath = DataFilepath + ".src"
>
> > > As other people have pointed out, you've got a typo here.
>
> > > >> >         print(DataFilepath)
> > > >> >         print(ResourceFilepath)
>
> > > >> >         # Try to open resource file, catch exception:
> > > >> >         try:
> > > >> >             ResourceFH = open(ResourceFilepath)
>
> > > >> >         except IOError, message:
> > > >> >             # Error opening file.
> > > >> >             print(message)
> > > >> >             print("Error opening " + ResourceFilepath)
> > > >> >             DataFH.close()
> > > >> >             return None
>
> > > [Huge amounts of text trimmed]
>
> > > Fair enough, you're catching the IOError so that you can
> > > ensure that DataFH is closed.  Unfortunately this concealed
> > > the traceback information, which would have made it more
> > > obvious to you what people were talking about.  Given that
> > > this has rather stuffed your C8DataType instance, you
> > > might want to think about re-raising the exception after
> > > you've closed DataFH and letting the outer layers deal
> > > with it in a more appropriate fashion.
>
> > > Incidentally, this code isn't going to do anything useful
> > > for you anyway even after you've fixed the typo.  DataFH
> > > and ResourceFH are both local variables to __init__ and
> > > will be tossed away when it finishes executing.  If you
> > > want to use them later, make them self.data_fh and
> > > self.resource_fh respectively.
>
> > > (PEP 8 recommends that you use lower_case_with_underscores
> > > for variable or attribute names, and leave MixedCase for
> > > class names.)
>
> > > --
> > > Rhodri James *-* Wildebeeste Herder to the Masses- Hide quoted text -
>
> > > - Show quoted text -
>
> > Very good comments. I'll be implementing some of your suggestions, to
> > be sure. Thanks Rhodri.
>
> You could check to see if the file actually exists using os.path.exists
> (). I've found that if I use that in combination with printing the
> path variable, I sometimes discover that either my file doesn't exist
> or that my path is slightly wrong and thus Python doesn't think my
> file exists...
>
> Mike

It's weird, right?  But thanks to Grant and Rhodri, from another
newbie (me)
and to everyone else who helps us out.

John  (the "how to ask questions" text is priceless)
--
http://mail.python.org/mailman/listinfo/python-list


importing a class thru a variable?

2008-10-21 Thread john
Hi,
This is probably a question of questionable sanity, due to the fact I
don't think I can explain this well. I'd like to have a script set up
such that it imports a class that is named in the command line
arguments as the first argument to the script.

Let's say I have a script, command.py, and I'd like to run it like
this:
command.py class_id_like_to_import --option1 value1 --option2 value2

where 'class_id_like_to_import' is a class name and --option1/value1
and so on are arguments that get passed to that class.

I know that trying to do something like:

  classname = sys.argv[1]
  import classname

doesn't exactly work. I've tried to google for something like this,
and search the old posts to this newsgroup and haven't quite found
anything resembling what I'm looking for.

Thanks in advance, and apologies if this has been answered before...
--
http://mail.python.org/mailman/listinfo/python-list


Re: can't install new modules after updating python

2009-04-18 Thread John
On Apr 18, 9:00 am, a...@pythoncraft.com (Aahz) wrote:
> In article 
> ,
>
> Generally speaking, you should never directly update the system Python;
> most Linux systems these days rely on Python for their operation.
> Instead, you install an additional copy of Python, and you cannot use
> your OS package management to install modules; just install the modules
> manually.

Agreed. I tend to keep my own Python installation in ~/opt, and then
use the usual `python setup.py install` to install modules. You just
need to make sure you have $HOME/opt/py/bin in your $PATH before the
system python (or else explicitly specify `~/opt/py/bin/python
setup.py install` when you install modules).

If your *system* Python needs modules, you install those with your OS
package management utility.
--
http://mail.python.org/mailman/listinfo/python-list


Re: iterate to make multiple variables?

2009-04-20 Thread john
On Apr 19, 11:11 pm, Tairic  wrote:
> Hi, I'm somewhat new to programming and especially to python. Today I
> was attempting to make a sudoku-solver, and I wanted to put numbers
> into sets call box1, box2, ... box9, so that I could check new values
> against the boxes
>
> I ended up declaring the boxes like this
> box1 = set([])
> box2 = set([])
> ..
> ..
> box9 = set([])
>
> Is there a way for me instead to generate these variables (box1 to
> box9) as empty sets instead of just writing them all out? Some way to
> iterate and generate them?
>
> Sorry if this is confusing, thanks in advance.

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


Re: iterate to make multiple variables?

2009-04-20 Thread john
On Apr 19, 11:11 pm, Tairic  wrote:
> Hi, I'm somewhat new to programming and especially to python. Today I
> was attempting to make a sudoku-solver, and I wanted to put numbers
> into sets call box1, box2, ... box9, so that I could check new values
> against the boxes
>
> I ended up declaring the boxes like this
> box1 = set([])
> box2 = set([])
> ..
> ..
> box9 = set([])
>
> Is there a way for me instead to generate these variables (box1 to
> box9) as empty sets instead of just writing them all out? Some way to
> iterate and generate them?
>
> Sorry if this is confusing, thanks in advance.

There's a key to answering you.  You pointed it out in your question,
when you say '...if
this is confusing, ...'.  Most of programming involves writing down
the stuff we need so that
we see it in less-confusing ways.  It's called "stepwise refinement"
by the book publishers.
What it means is that you try to think about your problem, mess about
with the tools at hand,
(lists [], sets ()  , sequences () ,strings "  ", and dictionaries
{ : }), and see what might
do for the job.  How are they different.  You ought to monkey around
with each of them, on your own--don't ask for help, because we can't
help as much as you can help yourself.  You'll understand much more,
in the end, besides.  Then, when you come back, with some code, even
some code that doesn't work worth a damn, if it's halfway reasonable,
we'll be able to show you where your slight misstep was--but often,
you'll get stuff working, and it's really important that you start to
do it.  Mess with the effing interpreter, mess with it often, and look
at different examples, and try them all out.  Truly.
--
http://mail.python.org/mailman/listinfo/python-list


What is the difference between init and enter?

2009-05-26 Thread John
I'm okay with init, but it seems to me that enter is redundant since it 
appears that anything you want to execute in enter can be done in init.

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


so funny...

2008-05-29 Thread John
http://sitscape.com/topic/funny

Just keep hit the "Surprise->" button there for amazing fun.
Click on "channel" will show you other topics, lots of fun!

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


Re: [Tutor] python gui

2008-06-11 Thread john
W W wrote:
> On Wed, Jun 11, 2008 at 10:18 AM, Gabriela Soares
> <[EMAIL PROTECTED]> wrote:
> > How ?
>
> That's an extremely broad question, and shows little initiative, and
> offers little information. Most of us are happy to help you solve
> problems for free, but few, if any, are willing to write your programs
> for free.
>

Ah, come on, it's not that broad, and easy to answer!!

"With a lot of patience!"
--
http://mail.python.org/mailman/listinfo/python-list


newbie question

2008-04-25 Thread John
I'm working with the HTMLParser module and have implemented
HTMLParser.handle_starttag() and I see there is a separate
handle_data
method (which can be implemented), but I am not clear how to tie this
together with a given start tag, so I only get the data I want.

For example, I'd like to get a handle on the character data ( the
number 1) immediately after the following start tag



1
.
.
.
Any ideas?
--
http://mail.python.org/mailman/listinfo/python-list


Re: newbie question

2008-04-25 Thread John
Thanks for the tip!
--
http://mail.python.org/mailman/listinfo/python-list


F2PY changing integers to arrays???

2008-09-09 Thread john
I have a simple module which performs basic operations on plot3d files
(below).  I wrapped like:

f2py --fcompiler=gfortran -m plot3d -c prec.f90 plot3d.f90

That seems to work fine, but i get some unexpected results...

>>> from plot3d import plot3d as p3
>>> dir(p3)
['imax', 'jmax', 'kmax', 'mg', 'prc', 'printall', 'readit', 'writeit',
'writeit2d']
>>> p3.readit( "mesh.xrtz.dat", "FORMATTED", ".TRUE." )
>>> p3.imax
array(409)


"409" is correct, but "imax" is declared as an INTEGER in fortran and
now it's an array in python???  Any ideas?








# prec.f90
MODULE prec
IMPLICIT NONE
INTEGER, PARAMETER :: single = SELECTED_REAL_KIND(p=6,r=37)
INTEGER, PARAMETER :: double = SELECTED_REAL_KIND(p=15,r=200)
END MODULE prec




# plot3d.f90
MODULE PLOT3D
USE prec
IMPLICIT NONE
INTEGER, PARAMETER :: prc=single
REAL(prc), ALLOCATABLE, DIMENSION(:,:,:,:) :: x, y, z
INTEGER :: mg, imax, jmax, kmax

CONTAINS

!--
SUBROUTINE READIT( fname, ftype, fmg )
! reads the plot3d, formatted, mg file in xyz
IMPLICIT NONE
CHARACTER(len=20), INTENT(IN) :: fname, ftype

LOGICAL :: fmg
INTEGER :: i, j, k, n, f=1

SELECT CASE (ftype)
CASE ('FORMATTED')
OPEN( UNIT=f, FILE=fname, STATUS='OLD', ACTION='READ',
FORM=ftype )
IF (fmg) READ(f,*) mg ! only read if multigrid
READ(f,*) imax, jmax, kmax
ALLOCATE( x(mg, imax, jmax, kmax) )
ALLOCATE( y(mg, imax, jmax, kmax) )
ALLOCATE( z(mg, imax, jmax, kmax) )
READ(f,*) x(n,
i,j,k),i=1,imax),j=1,jmax),k=1,kmax),n=1,mg), &
  y(n,
i,j,k),i=1,imax),j=1,jmax),k=1,kmax),n=1,mg), &
  z(n,
i,j,k),i=1,imax),j=1,jmax),k=1,kmax),n=1,mg)
CASE ('UNFORMATTED')
OPEN( UNIT=f, FILE=fname, STATUS='OLD', ACTION='READ',
FORM=ftype )
IF (fmg) READ(f) mg ! only read if multigrid
READ(f) imax, jmax, kmax
ALLOCATE( x(mg, imax, jmax, kmax) )
ALLOCATE( y(mg, imax, jmax, kmax) )
ALLOCATE( z(mg, imax, jmax, kmax) )
READ(f) x(n,
i,j,k),i=1,imax),j=1,jmax),k=1,kmax),n=1,mg), &
y(n,
i,j,k),i=1,imax),j=1,jmax),k=1,kmax),n=1,mg), &
z(n,
i,j,k),i=1,imax),j=1,jmax),k=1,kmax),n=1,mg)
CASE DEFAULT
WRITE(*,*) 'filetype not supported in '
STOP
END SELECT

CLOSE(f)

END SUBROUTINE READIT

END MODULE PLOT3D



























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


Re: F2PY changing integers to arrays???

2008-09-09 Thread john
Hmmm...   I didn't even try that...  I thought this might have caused
problems down the road passing this var to other classes, etc., but i
guess not!

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


catching exceptions from fortran

2008-09-11 Thread john
I wrapped some fortran code using F2PY and need to be able to catch
fortran runtime errors to run the following:

# "grid" is a wrapped fortran module
# no runtime errors incurred when run with the correct inputs for
filetype
#---
def readGrid( self, coord='xyz' ):
mg = ( '.FALSE.', '.TRUE.' )
form = ( 'FORMATTED', 'UNFORMATTED' )
success = False
for m in mg:
for f in form:
try:
if coord == 'xyz':
self.grid.readxyz( 
self.filename, f, m )
success = True
elif coord == 'xyrb':
self.grid.readxyrb( 
self.filename, f, m )
success = True
else:
import sys
print 'gridtype "' + str(coord) 
+ '" not supported. ' \
+ 
''
except:
continue
if not success:
import sys
print 'gridfile "' + str(self.filename) + '" not read 
in any
recognized format' \
+ ' '
#


basically, what i want to happen is to try to run 'something' with the
wrapped fortran code and if that doesn't work (error encountered,
etc.) try something else.  is there an easier way to go about doing
this?  is there something i'm missing about catching exceptions here?

Thanks in advance!


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


sending a text message via webpage button

2006-03-07 Thread John
Can anyone help me in coding a script that can send a text message
typed to
the script like.

sendmessage 6318019564 "test message"

What I want to do is fill up this information on this webpage

http://www.cingularme.com/do/public/send;jsessionid=aKDwXM1S0Reh

and click the submit button using the python script. Any ideas on
how to do this or if someone has already done this?

Thanks,
--j

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


counting number of (overlapping) occurances

2006-03-09 Thread John
I have two strings S1 and S2. I want to know how many times
S2 occurs inside S1.

For instance

if S1 = ""
and S2 = "AA"

then the count is 3. Is there an easy way to do this in python?
I was trying to use the "count" function but it does not do
overlapping counts it seems.

Thanks,
--j

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


Re: counting number of (overlapping) occurances

2006-03-09 Thread John
Thanks a lot,

This works but is a bit slow, I guess I'll have to live with it.
Any chance this could be sped up in python?

Thanks once again,
--j

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


instantiate a class with a variable

2006-03-27 Thread John
Hi, is it possible to instantiate a class with a variable.

example

class foo:
def method(self):
pass

x='foo'

Can I use variable x value to create an instance of my class?

Thanks, John

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


Re: instantiate a class with a variable

2006-03-28 Thread John
Thanks for the help, this was exactly what I needed. Working Great
bruno at modulix wrote:
> John wrote:
> > Hi, is it possible to instantiate a class with a variable.
> >
> > example
> >
> > class foo:
> > def method(self):
> > pass
> >
> > x='foo'
> >
> > Can I use variable x value to create an instance of my class?
>
> You got examples using string 'foo', now if all you need is to store or
> pass around the class, just use it as any other object (yes, classes
> *are* objects):
>
> class Foo(object): pass
>
> x = Foo
>
> f = x()
> assert type(f) is Foo
>
>
> --
> bruno desthuilliers
> python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
> p in '[EMAIL PROTECTED]'.split('@')])"

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


Python (and me) getting confused finding keys

2009-12-22 Thread John
Hi there,

I have a rather lengthy program that troubles me for quite some time. After 
some debugging, I arrived at the following assertion error:

for e in edges.keys():
assert edges.has_key(e)

Oops!? Is there ANY way that something like this can possibly happen?

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


Re: Python (and me) getting confused finding keys

2009-12-22 Thread John
> another thread can remove the key prior to the has_key call; or perhaps
>  edges isn't a real dictionary?
> 

of course. But unless there is a way of using threading without being aware of 
it, this is not the case. Also, edges is definitely a dict (has been declared 
some lines before, and no obscure functions have been called in the meantime, 
just some adding to edges). Python would also fail on edges.keys() if edges 
wasn't a dict...


cheers,
john
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >