http://www.parttimejobsu.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I am facing some problem in installing the OpenOpt optimization toolbox.
What I have done is I downloaded the OpenOpt package and added the
folder containing scikits to the PythonPath by:
sys.path.append('C:\Documents and Settings\User\Desktop\openopt')
but when i try following:
from sciki
I have a linux machine (ip = 10.10.10.8), which can ping other
machines on the same subnet...such as
10.10.10.1
10.10.10.2
10.10.10.5
10.10.10.6
10.10.10.254
If I use socket.gethostbyaddr() I get back results when ip is
10.10.10.1 and 10.10.10.254 but for the other IP addresses
(10.10.10.5, .6, e
thanks, forgot that.
--
http://mail.python.org/mailman/listinfo/python-list
I have some HTML such as
blah blah blah
I wnat to pull out the text that lies inside the quotes of the src
attribute. So in this example I would get image/blah/a.jpg
My regex so far is: src=\"(.*)\" however the group in this case
would end up being, image/blah/a.jpg" id="d">bla
Has anyone seen this error before:
wrap_EncryptByteArray() argument 1 must be string without null bytes,
not str
I am having a hard time finding anything about it.
--
http://mail.python.org/mailman/listinfo/python-list
> You'll need __eq__ for testing if two objects are equivalent, and
> __hash__ for calculating object's hash value.
>
> class Type:
> def __init__(self, val):
> self.val = val
>
> def __eq__(self, other):
> return self.val == other.val
>
> def __hash__(self):
> r
Hi,
I have a class such as,
class Type:
def __init__(self, val):
self.val = val
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
So I have a dictionary which maps an instance of Type to an instance
of Person. Now I need to retrieve
>
> I hope you see now why it is consistent.
>
> Georg
yea that clears it up. thanks.
--
http://mail.python.org/mailman/listinfo/python-list
> As an immutable type, tuple makes use of __new__.
>
> class MyTuple(tuple):
> def __new__(cls, *args):
> return tuple.__new__(cls, args)
>
> should work.
>
> Georg
strange. not very consistent.
--
http://mail.python.org/mailman/listinfo/python-list
I wanted to extend tuple but ran into a problem. Here is what I
thought would work
class MyTuple(tuple):
def __init__(self, *args):
tuple.__init__(self, args)
x = MyTuple(1,2,3,4)
That gives me...
TypeError: tuple() takes at most 1 argument (4 given).
However, this call works:
x
I have a file, "a.py"
blah = None
def go():
global blah
blah = 5
>From the python interpreter I try
>>> from a import *
>>> blah
>>> go()
>>> blah
>>>
...i was hoping to see "5" get printed out the second time I displayed
blah, but it doesn't. Now, if I type this same code directly
On Mar 20, 9:58 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> After a bunch of questions of that kind, I suggest you take a step back, and
> read this:
>
> http://docs.python.org/tut/node8.html
got it, thanks.
--
http://mail.python.org/mailman/listinfo/python-list
I have the following directory/file structure...
c:\foo\utils.py
c:\foo\bar\ok.py
In ok.py I want to do something like...
import utils
utils.helpMeDoSomething()
However, it seems that ok.py doesn't "know" about utils. Other than
manually configuring sys.path what can I do?
thanks
--
htt
thanks for the help.
--
http://mail.python.org/mailman/listinfo/python-list
> Blerch! Why not just call the modules by the right names in the first
> place? Then each will have its own sys.modules entry for a start ...
>
> regards
> Steve
what do i need to do? also, is there a way I can load each one as I
have but each one have its own unique entry in sys.modules? For
nevermind this took care of it:
import sys
def tryAllThree():
a = "c:\\alpha"
b = "c:\\beta"
g = "c:\\gamma"
sys.path.append(a)
import Person
alpha = Person.Person()
sys.path.remove(a)
sys.path.append(b)
reload(Person)
beta = Person.Person()
sys.path
I have the following directory structure setup...
c:\alpha\Person.py
--
class Person(IPerson):
def __init__(self):
print "Alpha person here"
c:\beta\Person.py
--
class Person(IPerson):
def __init__(self):
print "Beta person here"
c:\gamma\P
When do I need to use a trailing slash to separate code over multiple
lines.
For example:
x = "hello world, this is my multiline " + \
"string"
x = {'name' : \
'bob'}
Do I need to use the "\" in the above examples? When do i need to use
it?
--
http://mail.python.org/mailman/li
I have a wxTextCtrl:
wx.TextCtrl(self.myPanel, -1, "", style=wx.TE_MULTILINE)
I take a set of text (65,000 characters), and paste it into the text
control. all looks well. Then when I click a button I print out the
entered text and the length of that text. Here is what I am seeing...
1. Paste
On Mar 14, 7:29 am, "abcd" <[EMAIL PROTECTED]> wrote:
> Hi,
>I have a dictionary which may contain various keys/values, however,
> it will always contain 'name' and 'age' keys.
>
>This dictionary is kept inside a class, such as
>
Hi,
I have a dictionary which may contain various keys/values, however,
it will always contain 'name' and 'age' keys.
This dictionary is kept inside a class, such as
class Person:
def __init__(self, name, age):
self.data = {'name' : name, 'age' : age}
de
> But a thread leaves the script running until the thread exits, right?
> So the webpage would just keep saying "loading" at the bottom I think.
>
> -Greg
give it a shot. if you spawn off a new thread your code should keep
executing while the thread does its work in the "background".
--
http://
probably a Thread.
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 9, 2:50 pm, "abcd" <[EMAIL PROTECTED]> wrote:
> I guess this might be overkill then...
>
> class MyList(list):
> def __init__(self):
> self.l = threading.Lock()
>
> def append(self, val):
> try:
> self.l.ac
I guess this might be overkill then...
class MyList(list):
def __init__(self):
self.l = threading.Lock()
def append(self, val):
try:
self.l.acquire()
list.append(self, val)
finally:
if self.l.locked():
self.l.rele
Thanks for the link. I saw that one in my google search but didn't
visit it for some reason.
Looks like most operations should be just fine.
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Are lists thread safe? Or do I have to use a Lock when modifying the
list (adding, removing, etc)? Can you point me to some documentation
on this?
thanks
--
http://mail.python.org/mailman/listinfo/python-list
:(
--
http://mail.python.org/mailman/listinfo/python-list
Is there a way to capture key strokes on a system using python (other
than pyHook)? can wxPython capture keystrokes for the system (not
just, say a text box)?
thanks
--
http://mail.python.org/mailman/listinfo/python-list
anyone?
--
http://mail.python.org/mailman/listinfo/python-list
I'd pick, Dive Into Python (http://www.diveintopython.org/) you
can read it online for FREE!
--
http://mail.python.org/mailman/listinfo/python-list
I am having trouble with pyHook on python 2.4.1. Basically I have a
python app that uses pyHook to capture keyboard events and write them
straight to a file. The application is running as a service on a
windows machine. If I am at that windows machine the application
works just fine, logging my
On Jan 31, 8:02 am, Benjamin Niemann <[EMAIL PROTECTED]> wrote:
> marshal is used to (de)serialize python objects from/to strings.
> marshal.loads() tries to deserialize an encoded string back into a python
> object - which does not make sense here.
> What you probably want is:
>
> exec data in my_
I have the following code which is sent over the wire as a string...
from time import time
class Foo:
def go(self):
print "Time:", time()
I get this code and store it as, "data"
data = receivePythonSource()
Then I try...
exec marshal.loads(data) in my_module.__dict__
However I ge
>Yes because usually you don't expect a list or dictionary but some object
> that *acts* like a list or dictionary. Or you even expect just some
> aspects of the type's behavior. For example that it is something you can
> iterate over.
>
> Ciao,
> Marc 'BlackJack' Rintsch
good point. is
Well my example function was simply taking a string and printing, but
most of my cases would be expecting a list, dictionary or some other
custom object. Still propose not to validate the type of data being
passed in?
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Well my example function was simply taking a string and printing, but
most of my cases would be expecting a list, dictionary or some other
custom object. Still propose not to validate the type of data being
passed in?
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
> The "Python way" is to validate by performing the operations you need to
> perform and catching any exceptions that result. In the case of your
> example, you seem to be saying that you'd rather raise your own
> exception (which, by the way, should really be a subclass of Exception,
> but we will
In my code I am debating whether or not to validate the types of data
being passed to my functions. For example
def sayHello(self, name):
if not name:
rasie "name can't be null"
if not isinstance(name, str):
raise "name must be a string"
print "Hello " + name
Is the u
Yea basically I need Queue like functionality with the ability to
search for a particular instance in it. I guess I could just use a
list and search it as needed.
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
I have a class such as...
id = 0
class Foo:
def __init__(self, data):
self.id = id
id += 1
self.data = data
And I am storing them in a Queue.Queue...
import Queue
q = Queue.Queue()
q.put(Foo('blah'))
q.put(Foo('hello world'))
q.put(Foo('test'))
how can I search "q" f
yea i meant to have animal extend thing and dog extend animalmy
mistake.
anyways, is there a way to check without having an instance of the
class?
such as,
isinstance(Dog, (Animal, Thing)) ??
thanks
--
http://mail.python.org/mailman/listinfo/python-list
How can tell if an object is a subclass of something else?
Imagine...
class Thing:
pass
class Animal:
pass
class Dog:
pass
d = Dog()
I want to find out that 'd' is a Dog, Animal and Thing. Such as...
d is a Dog
d is a Animal
d is a Thing
Thanks
--
http://mail.python.org/mailm
I am using fnmatch.fnmatch to find some files. The only problem I have
is that it only takes one pattern...so if I want to search using
multiple patterns I have to do something like
patterns = ['abc*.txt', 'foo*']
for p in patterns:
if fnmatch.fnmatch(some_file_name, p):
return T
thanks for the feedback, I am watching the screencasts, which are
helping already. I think I will try out the Dabo GUI tool since it
uses wxPython...and see if I can get the code I need from it.
thanks
--
http://mail.python.org/mailman/listinfo/python-list
> How do I do sometihing simple like that in python?
print "hello"
print "Jim"
> How do I enter line numbers, or if none, what do I do.
no line numbers needed
> Can the interpreter load a text file with my program in it?
read in a text file:
data = open("something.txt").read()
> How do I list
On Oct 30, 3:47 pm, John Salerno <[EMAIL PROTECTED]> wrote:
>I noticed that one object you refer to is
> self.textPane, is that supposed to be self.textPanel?
no, self.textPane is the actual wx.TextCtrl.
I used a GUI Builder to the layout stuff...perhaps that's my problem :)
is there a good site
> But one question that comes to mind is, do you not add sizerTextPanel to
> sizerMainPanel? I think all sub-sizers should be added to the main
> sizer, unless there's some weird reason I don't know of.
well i set the sizer on the textPanel and then I add the textPanel to
sizerMainPanel
--
http:
On Oct 30, 2:52 pm, John Salerno <[EMAIL PROTECTED]> wrote:
Don't know for sure, but you can try calling the Refresh() method on
the
> text control and see if that fixes it.
Didn't make a difference. Not sure what the problem is, I am wondering
if it is a layout issue since that is my weak spot w
I have a TextCtrl which is set to be multi-line. I have a function
say, updateText(msg), which takes some string and appends it to the
text control...
txtControl.AppendText(msg)
however, if the text that I am appending would cause the scroll
bars to appear/or scroll since the text is long th
Gabriel Genellina wrote:
> A VNC server is about 400K in size...
Yea, VNC is not an option in my case.
thanks anyway, perhaps I'll look into generating a slideshow using
HTML/javascript which can load the images.
--
http://mail.python.org/mailman/listinfo/python-list
Brett Hoerner wrote:
> Are you sure you can't use VNC? An animated GIF based on full-screen
> grabs will be amazingly huge and have very low color quality at the
> same time.
>
> Installing VNC on Windows should take you about 30 seconds, honest.
>
> Or is this for some sort of project where you c
fredrik,
in other posts you have mentioned the use of gifmaker. i have tried
that with the following:
I am using gifmaker.py from PIL v1.1.5 on python 2.4.1.
CODE
import ImageGrab, gifmaker
seq = []
while keepOnGoing:
im =
Fredrik Lundh wrote:
> to repeat myself:
>
> here's a tool that lets you use VNC to capture the screen, and then
> convert
> the result to a flash animation:
>
>http://www.unixuser.org/~euske/vnc2swf/
>
>
is there a way to make animated GIFs with python? vnc2swf is to much
for w
oh and vnc2swf would not be an option, i cant be setting up a vnc
server, etc. just need to use python (and necessary packages).
animated gif would probably be best i am assuming.
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
> GIF is horribly unsuitable for screenshots on modern machines. have you
> considered using PNG ?
>
> or even better, Flash?
well I am trying to take screenshots and make them into an animated
GIF, however, putting them into a Flash movie would be coolany idea
how to go
I have PIL 1.1.5 on python 2.4.1 and I am attempting to get a smaller
(file size) of an image.
for example:
im = ImageGrab.grab()
im.save("tmp.gif") about 1.7mb
im.save("tmp.jpeg") about 290kb
anyways I want to save the image as a GIF, but not have it be so
largeso I thought th
I am using gifmaker.py from PIL v1.1.5 on python 2.4.1.
CODE
import ImageGrab, gifmaker
seq = []
while keepOnGoing:
im = ImageGrab.grab()
seq.append(im)
fp = open("out.gif", "wb")
gifmaker.makedelta(fp, seq)
fp.close()
--
Carsten Haese wrote:
> Use Python 2.5 where there is a true conditional
> expression or find another way to solve your problem.
python 2.5 once we upgrade (hopefully soon), anyways...an earlier post
suggested the inverse...
x = None
result = (x is not None and str(x) or "")
which works just fine
x = None
result = (x is None and "" or str(x))
print result, type(result)
---
OUTPUT
---
None
y = 5
result = (y is 5 and "it's five" or "it's not five")
print result
-
OUTPUT
-
it's five
...what's wrong with the first operation I did with x?
Rob Williscroft wrote:
> http://docs.python.org/ref/function.html#l2h-619
thanks. weird that it works that way since they even state "This is
generally not what was intended."
oh well.
--
http://mail.python.org/mailman/listinfo/python-list
class Foo:
def __init__(self, name, data=[]):
self.name = name
self.data = data
def addData(self, val):
self.data.append(val)
f = Foo('a')
f.addData(1)
f.addData(2)
f2 = Foo('b')
print f.name, f.data
print f2.name, f2.data
OUTPUT
--
I have a class which extends 'file'
class MyFile(file):
def __init__(self, fname, mode='r'):
file.__init__(self, fname, mode)
def write(self, str):
print "writing a string"
file.write(self, str)
def writelines(self, lines):
print "writing lines"
> Fix: Start the script from the main thread only.
>
> Regards,
>
>
> Björn
thanks for NO help.anyways, I got rid of the Timer b/c all i was
using it for was to check the state of the "shift" key.but I am now
binding to key up/down.
thanks anyway
--
http://mail.python.org/mailman/listi
I have a python script which creates a wx.App, which creates a wx.Frame
(which has a wx.Timer).
looks sorta like this:
class MyProgram:
def __init__(self):
self.app = MyApp(0)
self.app.MainLoop()
class MyApp(wx.App):
def OnInit(self):
self.myframe= MyFrame()
Larry Bates wrote:
> This is not really a Python question. Blocking ports is a function
> of your firewall solution.
>
ok, no of any python solutions? or command-line firewalls?
--
http://mail.python.org/mailman/listinfo/python-list
any ideas on how to block a network port from being used, or one that
is currently in use? For example, say I want to block port 23 from
being used. by used, I mean allowing connections to or from it.
thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list
if i have a number, say the size of a file, is there an easy way to
output it so that it includes commas?
for example:
1890284
would be:
1,890,284
I am looking for something builtin to python, not a third party lib.
thanks
--
http://mail.python.org/mailman/listinfo/python-list
I am trying to get a regex that will match \r\n in a string.
ultimately i am trying to replace all \r\n with somethign else, say
BLAH.
For example:
This is a message
on a new line
would become:
This is a messageBLAHon a new line.
any ideas? i tried
re.compile('\r\n').match("This is a message"
not sure why this passes:
>>> regex = r'[A-Za-z]:\\([^/:\*\?"<>\|])*'
>>> p = re.compile(regex)
>>> p.match('c:\\test')
<_sre.SRE_Match object at 0x009D77E0>
>>> p.match('c:\\test?:/')
<_sre.SRE_Match object at 0x009D7720>
>>>
the last example shouldnt give a match
--
http://mail.python.org/ma
Sybren Stuvel wrote:
> Yes, because after the "c:" you expect a backslash, and not a tab
> character. Read the manual again about raw strings and character
> escaping, it'll do you good.
doh. i shall do that.
thanks.
--
http://mail.python.org/mailman/listinfo/python-list
sorry i forgot to escape the question mark...
> [code]
> import re
> p = re.compile(r'[A-Za-z]:\\([^/:\*?"<>\|])*')
even when I escape that it still doesnt work as expected.
p = re.compile(r'[A-Za-z]:\\([^/:\*\?"<>\|])*')
p.match('c:\test') still returns None.
--
http://mail.python.org/mailm
well thanks for the quick replies, but now my regex doesn't work.
[code]
import re
p = re.compile(r'[A-Za-z]:\\([^/:\*?"<>\|])*')
x = p.match("c:\test")
[/code]
x is None
any ideas why? i escape the back-slash, the asterisk *, and the PIPE |
b/c they are regex special characters.
--
http
I have a regex: '[A-Za-z]:\\([^/:\*\?"<>\|])*'
when I do, re.compile('[A-Za-z]:\\([^/:\*\?"<>\|])*') ...I get
sre_constants.error: unbalanced parenthesis
do i need to escape something else? i see that i have matching
parenthesis.
thx
--
http://mail.python.org/mailman/listinfo/python-list
yea i saw thatguess I was trusting that my regex was accurate :)
...b/c i was getting a Matcher when I shouldnt have, but i found that
it must be the regex.
--
http://mail.python.org/mailman/listinfo/python-list
how can i determine if a given character sequence matches my regex,
completely?
in java for example I can do,
Pattern.compile(regex).matcher(input).matches()
this returns True/False whether or not input matches the regex
completely.
is there a matches in python?
--
http://mail.python.org/mailm
Just curious if anyone had any information, or links, regarding the
blocking of network ports and/or taking over (hijacking) ports using
Python.
Any python modules/libs you could recommend? tutorials/reading
materials?
Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list
If I have code which imports a module over and over again...say each
time a function is called, does that cause Python to actually re-import
it...or will it skip it once the module has been imported??
for example:
def foo():
import bar
bar.printStuff()
foo()
foo()
foo()
foo()
...will th
i found that the problem is because of an import, which is strange.
The imported module looks something like this
[code]
import time
class Foo:
pass
class Bar:
global javax.swing
import javax.swing
[/code]
so it seems that pydoc cant giggity-giggit!
--
http://mail.python.org/m
Anyone ever use the PythonDoc ant task? I have the following...
...this is a cut out of the build xml i am using...but it shows the
relevant parts. Anyways I can run my "pyDoc" target and it runs
successful with no errors. a "docs" directory is created but
I have a script which zips up a directory, once it does with that
(before it closes the zip file) I want to replace a file that was added
to the zip, say "Foo.txt".
So I tried this...
[code]
z = zipfile.ZipFile("blah.zip", "w")
# zip the directory
#...
z.writestr("c:\\path\\to\\current\\foo_txt_fi
the error i get when i run the exec is, "java.lang.ClassFormatError"...
thanks
--
http://mail.python.org/mailman/listinfo/python-list
I have a single jython file, foo.py which contains multiple classes. I
read that into a string and try to exec itbut I get errors saying
something like unable to load class. It seems to work fine if foo.py
only contains a single class, any ideas?
--
http://mail.python.org/mailman/listinfo/p
Daniel Evers wrote:
> Right. You can check this e.g. with
>
> hasattr(x, "__getitem__")
>
> because the __getitem__ method is used for indexing.
Thanks...that is what I was looking for!
--
http://mail.python.org/mailman/listinfo/python-list
Richard Brodie wrote:
> subscriptable: supports an indexing operator, like a list does.
doesn't seem to be a builtin function or module...or is that just your
definition of subscriptable?
--
http://mail.python.org/mailman/listinfo/python-list
I recently came across a problem where I saw this error:
"TypeError: unsubscriptable object"
How can I determine if an object is "scriptable" or "unscriptable"?
--
http://mail.python.org/mailman/listinfo/python-list
I have a program which is written in C and interfaced with python via
Swig. However, the function I call prints stuff out to the console. I
would like to capture what it is printing out. I tried:
[code]
import MyCProg, sys
f = open("tmp.txt", "wb")
sys.stdout = f
MyCProg.getData()
f.close()
sy
Dennis Lee Bieber wrote:
> On 27 Mar 2006 10:17:21 -0800, "abcd" <[EMAIL PROTECTED]> declaimed
> the following in comp.lang.python:
>
> > anyone have v2.x of pysqlite that I could download? the website is
> > down for a hardware upgrade with no date as to whe
anyone have v2.x of pysqlite that I could download? the website is
down for a hardware upgrade with no date as to when it will be back.
I checked sourceforge but there are no files there to download.
thanks.
--
http://mail.python.org/mailman/listinfo/python-list
When I call:
pythoncom.PumpMessages()
...it blocks at that line. According to the docs, it says it will run
until it receives a WM_QUITso I try to create a separate thread and
do
import win32api
win32api.PostQuitMessage()
...but the code is still blocking at PumpMessages. Any ideas? othe
When I call:
pythoncom.PumpMessages()
...it blocks at that line. According to the docs, it says it will run
until it receives a WM_QUITso I try to create a separate thread and
do
import win32api
win32api.PostQuitMessage()
...but the code is still blocking at PumpMessages. Any ideas? othe
well actually, the site looked promising...only problem is no talks
have audio, video or handouts available (at least right now).
oh well.
--
http://mail.python.org/mailman/listinfo/python-list
Max M wrote:
> http://us.pycon.org/AudioVideoRecording/HomePage
Thanks, after going to the URL, I clicked "talks" and got to
http://us.pycon.org/talks ...this page lets u pick which talks you
want to access.
thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Anyone know if (and when) the talks from PyCon2006 will be available
for download. I am particularly interested in the tutorials (as they
did not have them at PyCono2005).
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
i was missing "self" in my method signature!
doh!
--
http://mail.python.org/mailman/listinfo/python-list
Not sure if it matters, but this occurs when running a unittest.
The trace back is:
Traceback (most recent call last):
File "C:\Python24\Lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Python24\Lib\threading.py", line 422, in run
self.__target(*self.__args, **self.__kwa
I have class like this...
import threading
class MyBlah(object):
def __init__(self):
self.makeThread(self.blah, (4,9))
def blah(self, x, y):
print "X and Y:", x, y
def makeThread(self, func, args=(), kwargs={}):
threading.Thread(target=self.blah, args=args,
kw
is there a built-in way of printing the size of a file nicely?
So if the file size is 103803 bytes it prints out like: 103.8K
or
0.1MB
something liek that?
--
http://mail.python.org/mailman/listinfo/python-list
Ian Leitch wrote:
> >>> from urlparse import urlparse
> >>> dict([n for n in [i.split('=') for i in
> urlparse('http://www.somesite.com/cgi-bin/foo.cgi?name=john&age=90')[4].split('&')]])
> {'age': '90', 'name': 'john'}
Ian, thanks for the reply, but that is not what I need to do. Inside
foo.cg
1 - 100 of 106 matches
Mail list logo