Sybren Stuvel wrote:
> KraftDiner enlightened us with:
> > What makes asyncore.loop exit?
>
> Why ask questions about something you're unable to use, when I've
> given you something that does work?
>
Who said it didn't work?
> Sybren
> --
> The pr
Bryan Olson wrote:
> KraftDiner wrote:
>
> > Thanks I can't seem to get this example to do anything except sit
> > there
> > http://docs.python.org/lib/asyncore-example.html
>
> Yeah, the example code, by itself, will just sit there.
> As an example, i
Marc 'BlackJack' Rintsch wrote:
> In <[EMAIL PROTECTED]>, KraftDiner
> wrote:
>
> > If you don't know how long your input data is going to be how can you
> > at least treat it a text line at a time... like looking for new line in
> > the data...
If you don't know how long your input data is going to be how can you
at least treat it a text line at a time... like looking for new line in
the data... Right now recv blocks. Yes I could do a select, but the
examples seem a bit complicated for a simple line oriented input...
--
http://mail.py
Can pythons array.tofile method be used for a TCP/IP Socket?
ie can the socket be a file object?
--
http://mail.python.org/mailman/listinfo/python-list
Terry Reedy wrote:
> "KraftDiner" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> >
> > So what type / class should one use to represent a 16 bit integers
> > (signed or unsigned)?
>
> For most purposes, Python just has integers,
Simon Forman wrote:
> KraftDiner wrote:
> > What is the range of a variable of type int()
> >
> > eg:
> > i = int()
> > print i.max() # 0x
> > print i.min() # 0x
> >
> > is it a signed 16 bit or 32 bit or is it unsigned 16 or 32.
What is the range of a variable of type int()
eg:
i = int()
print i.max() # 0x
print i.min() # 0x
is it a signed 16 bit or 32 bit or is it unsigned 16 or 32...
I've noticed that it can be incremented into a new class of type
long...
--
http://mail.python.org/mailman/listinfo/py
I have a dictionary and sometime the lookup fails...
it seems to raise an exception when this happens.
What should I do to fix/catch this problem?
desc = self.numericDict[k][2]
KeyError: 589824 < This is the error that is being produced,
because there is no key
589824.
--
http://mail.p
Rob Cowie wrote:
> KraftDiner wrote:
> > I have the following code...
> >
> > import array
> > len32 = array.array('L')
> > len16 = array.array('H')
> >
> > len32.append(0)
> > len16.append(0)
> >
> > y = len32[0]
I have the following code...
import array
len32 = array.array('L')
len16 = array.array('H')
len32.append(0)
len16.append(0)
y = len32[0]
print y.__class__
z = len16[0]
print z.__class__
how can I change Zs type to long?
Or how how can I change an arrays type?
--
http://mail.python.org/mailm
Hi I have a list of Ojbects... I want to change one of the objects in
the list for a new object
How do I replace an existing object with a new one and maintain the
list order..
This is what I have...
def setAttribute(self, desc, value):
n = anObject(desc, value)
for o in self.Objects:
Simon Brunning wrote:
> On 16 Aug 2006 12:53:12 -0700, KraftDiner <[EMAIL PROTECTED]> wrote:
> > I can see that this might work...
> > c = [a, b]
> > for c in [a,b]:
> >c.getName()
> >
> > but when does baseClass ever get used?
> > Why did i
Simon Forman wrote:
> KraftDiner wrote:
> > Fredrik Lundh wrote:
> > > KraftDiner wrote:
> > >
> > > > This is not working the way I think it should
> > > > it would appear that fromfile and getName are calling the baseClass
> > > &g
Fredrik Lundh wrote:
> KraftDiner wrote:
>
> > This is not working the way I think it should
> > it would appear that fromfile and getName are calling the baseClass
> > methods which are
> > simple passes What have I done wrong?
> >
> > class
This is not working the way I think it should
it would appear that fromfile and getName are calling the baseClass
methods which are
simple passes What have I done wrong?
class baseClass:
def __init__(self, type):
if type == 'A':
self = typeA(
Steven D'Aprano wrote:
> On Tue, 15 Aug 2006 19:35:11 -0700, KraftDiner wrote:
>
> > I have two classes:
> >
> > class implicitClass:
> >def __init__(self):
> >def isIVR(self): #This is a class private method.
>
> The convention is to flag
Steven D'Aprano wrote:
> On Tue, 15 Aug 2006 19:35:11 -0700, KraftDiner wrote:
>
> > I have two classes:
> >
> > class implicitClass:
> >def __init__(self):
> >def isIVR(self): #This is a class private method.
>
> The convention is to flag
I have two classes:
class implicitClass:
def __init__(self):
def isIVR(self): #This is a class private method.
def fromfile(self, fileObj, byteOrder):
def getVR(self):
def getGroup(self):
def getElement(self):
def getSize(self):
def getData(self):
class explicitClass:
I have a question..
myGlobalDictionary = dictionary()
class someClass:
def __init__(self):
self.x = 0;
def getValue(self, v)
myGlobalDictionary.getVal(v)
myGlobalDictionary doesn't seem to be visible to my someClass methods.
Why? What should I do?
--
http://mail.python.org
I have a class that is defined in a file called MyClass.py
How do I use that class in another python script..
import MyClass ? (Does it need to be in a specific location?)
--
http://mail.python.org/mailman/listinfo/python-list
Grant Edwards wrote:
> On 2006-08-15, KraftDiner <[EMAIL PROTECTED]> wrote:
>
> > I open a file in python by
> > f = open('filename', mode='rb')
> >
> > how can I tell if I am at the end of file?
>
> I don't believe you can u
How can you tell if the host processor is a big or little endian
machine?
--
http://mail.python.org/mailman/listinfo/python-list
I open a file in python by
f = open('filename', mode='rb')
how can I tell if I am at the end of file?
f.eof() isn't implmented.
How can I implement its functionallity?
Thanks.
B.
--
http://mail.python.org/mailman/listinfo/python-list
Tim Chase wrote:
> > 1) there seems to be an optional topdown flag. Is that passed to
> > os.walk(path, topdownFlag)
>
> Yes.
>
> > 2) I only want to process files that match *.txt for example... Does
> > that mean I need to parse the list of files for the .txt extention or
> > can I pass a wild
Larry Bates wrote:
> KraftDiner wrote:
> > The os.walk function walks the operating systems directory tree.
> >
> > This seems to work, but I don't quite understand the tupple that is
> > returned...
> > Can someone explain please?
> >
>
The os.walk function walks the operating systems directory tree.
This seems to work, but I don't quite understand the tupple that is
returned...
Can someone explain please?
for root, dirs, files in os.walk('/directory/'):
print root
# print dirs
# print files
--
http://mail.
Hi I need help writing a python script that traverses (recursivly) a
directory and its sub directories and processes all files in the
directory. So at each directory if there are files in it I must build
a list of those files and process them by exectuing a system command
(exec?)
Can some one tel
Could someone point me to step by step instructions on building boost
python on mac os x?
I have bjam running.. I have the boost source... but the tests are
failing..
Probably something to do with environement variables...
Anyone with time?
--
http://mail.python.org/mailman/listinfo/python-list
What ways can I call my C++ classes from within Python.
I've looked at boost but it would appear that there is little
support or knowledge on boost in the python community.
--
http://mail.python.org/mailman/listinfo/python-list
Hi, I'm trying to call a C++ class from python.
I've looked around and the solution would appear to be boost.
I'm not sure but maybe I've downloaded and installed the entire boost
library,
when there is probably a separate tar ball for python / C++
integration.
Can someone please point me to a tar
I had a structure that looked like this
((0,1), (2, 3), (4, 5), (6,7)
I changed my code slightly and now I do this:
odd = (1,3,5,7)
even = (0,2,4,6)
all = zip(even, odd)
however the zip produces:
[(0, 1), (2, 3), (4, 5), (6, 7)]
Which is a list of tuples.. I wanted a tuple of tuples...
--
http
I have a 2D array. Say it is 10x10 and I want a 1D Array of 100
elements...
What is the syntax?
oneD = reshape(twoD, (100,1))
or
oneD = reshape(twoD, (1,100))
One I guess is the transpose of the other but both seem to be
arrays of arrays...
help?!
--
http://mail.python.org/mailman/listinfo/py
Hi!
In python I'm able to read in binary data from a file.
data = file.read() # Reads in an entire file.
However the data is 16bits per sample and python is storing the
data in a string. How do I convert that 8bit data into a list of 16
bit integers?
Note: I want generic python lists or tupels
I'm wondering if your solution fits my requirements
I need to be able to pass these objects which are python lists
to a pyObjC (on MAC OS X) framework. At the moment the
framework is expecting NSArray or NSData as input and this works
for 'generic' python lists I don't know about numpy arr
I have a list that starts out as a two dimensional list
I convert it to a 1D list by:
b = sum(a, [])
any idea how I can take be and convert it back to a 2D list?
--
http://mail.python.org/mailman/listinfo/python-list
nope.. sorry its not...
I meant x = [[1,2,3],[3,4,5],[5,6,7]]
--
http://mail.python.org/mailman/listinfo/python-list
Oh by the way the b = sum(a, []) worked well to convert the two
dimensional array to a 1D array...
Is there a way to bring that 1D array back to a 2D array?
--
http://mail.python.org/mailman/listinfo/python-list
Yes I missed the fine print that said that the code had 'side effects'
So:
a = [None]*256
for i in range(256):
a[i] = [None] * 256
for i in range(0,256):
for j in range(0,256):
a[i][j] = i**2
a = sum(a, [])
print a[0]
print a[65535]
--
http://mail.py
Strange behaviour...
a = [[None] * 256] * 256
for i in range(0,256):
for j in range(0,256):
a[i][j] = i**2
a = sum(a, [])
print a[0]
print a[65535]
Prints:
65025
65025
--
http://mail.python.org/mailman/listinfo/python-list
Thank you that worked great!
a = [[None] * 256] * 256
for i in range(0,256):
for j in range(0,256):
a[i][j] = i**2
Now.. Can I change this quickly into a 1 dimensional list of length
65536?
--
http://mail.python.org/mailman/listinfo/python-list
I need a matrix of 256 x 256 unsigned short values...
The matrix can be implemented as a list of lists or a tuple...
So for example:
[[1][2][3], [4][5][6], [7][8][9]]
or
((1,2,3),(4,5,6), (7,8,9))
This is what I have so far but its not working...
a = [][]
for i in range(0,256):
for j in r
Many thanks everyone.
One last quick question...
The dictionary, I believe, is sorted by the key.
Is there a way to sort it by the value?
Say I wanted to put out a list of the frequency sorted by highest to
lowest?
--
http://mail.python.org/mailman/listinfo/python-list
Ok so this is nice.. Just one thing.. When you try to get a value from
a dictionary
and it isn't found in the dictionary things go bad...
Take this for example:
class histogram(object):
def __init__(self):
self.histo = {}
def update(self, point):
i
The dictionary is sorted by the point key.
Is there a way to sort the dictionary by the value?
Seems to me this goes against the purpose of a dictionary but
thats what I need to do..
--
http://mail.python.org/mailman/listinfo/python-list
Cool.
Ok so my histogram class had two methods 1) To increment a point and 2)
to get the point.
def class histo:
def __init__(self):
histo = {}
def update(point):
'''searches the dictionary for point and if it exists increment the
value.
if it doesn't exist set the value to 1'''
Hi, I wrote a C++ class that implements an n dimensional histogram in
C++, using stl maps and vectors. I want to code this up now in Python
and would like some input from this group.
The C++ class was VERY simple..
std::map, unsigned long> histo;
Say for example I want a 3D histogram th
So ok I've written a piece of code that demonstrates the problem.
Can you suggest how I change the Square class init?
class Shape(object):
def __init__(self):
print 'MyBaseClass __init__'
class Rectangle(Shape):
def __init__(self):
super(self.__clas
I'm having trouble getting a copy of and object... (a deep copy)
I'm writing a method that creates a mirror image of an object (on
screen)
In order to do this i need to get a copy of the object and then modify
some
of its attributes.
I tried:
objs = myListOfObjects
for obj in objs:
if obj.flag
try this:
class x(object):
def __init__(self):
self.someName = "hello"
def someMethod(self):
self.sumName = "bye"
find that bug.
--
http://mail.python.org/mailman/listinfo/python-list
I've spent hours trying to find a bug that was a simple spelling
mistake.
in an init method I declare a variable self.someLongName
later in a different method of the class I use
self.sumLongName
Now I really meant self.someLongName.
In fact I don't want a variable called sumLongName.
Frankly how
I have a class
class MyClass(MyBaseClass)
def __init__(self)
super(self.__class__, self).__init__()
self.type = MyClassType
return self
It has a few methods...
I have another class and the only difference is the __init__ method..
I tried this:
class MySpecialClass(MyClass)
I was under the assumption that everything in python was a refrence...
so if I code this:
lst = [1,2,3]
for i in lst:
if i==2:
i = 4
print lst
I though the contents of lst would be modified.. (After reading that
'everything' is a refrence.)
so it seems that in order to do this I need to
Thanks all!
--
http://mail.python.org/mailman/listinfo/python-list
I'm porting a routing from C++ to python.
There is a complex for loop that I don't know how to code in python
for (i = nPoints-1, j = 0; j < nPoints; i = j, j++)
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
I have two lists...
a=[1,2,3]
b=[4,5,6]
n=0
for i in a:
print i, b[n]
n=n+1
how can i have two iterators on my for loop?
rather than have to use the counter n?
like:
for i,j in a,b:
print i, j
Do you know what I mean?
--
http://mail.python.org/mailman/listinfo/python-list
I understand that everything in python is a refrence
I have a small problem..
I have a list and want to make a copy of it and add an element to the
end of the new list,
but keep the original intact
so:
tmp = myList
tmp.append(something)
print tmp, myList
should be different...
--
htt
NICE! :)
--
http://mail.python.org/mailman/listinfo/python-list
I guess its all good...
I just am not crazy about using fillColor[0] id rather use fillColor.r
So is that a structure I need to define or a class...
I'm kind of new to python what would that class or structure look like?
and then do the default parameters still work?
--
http://mail.python.org/ma
I have defined a method as follows:
def renderABezierPath(self, path, closePath=True, r=1.0, g=1.0, b=1.0,
a=1.0, fr=0.0, fg=0.0, fb=0.0, fa=.25):
Now wouldn't it be simpler if it was:
def renderABezierPath(self, path, closePath=True, outlineColor,
fillColor):
But how do you set default vaules
I like python.. Its ok.. One thing that I find a bit dangerous it the
use
of the tab character for indentation.. I've had copy and pasts loose
indentation on me and its theoretically impossible to really figure out
what the indentation should be. I think for the extra effort it would
have
taken to
I am trying to implement a two dimensional array.
mylist = [[a,b,c],[d,e,f,c],[g,h,i]]
So the array is of length 3 here...
So how do I initialize this array and then set each object?
At some point in my code I know there will be 3 lists in the list.
So how do I initialize this list such that I can
Is there a cleaner way to implement this code?
if len(self.listOfObjects) == 0:
self.listOfObjects.append(self.currentObject)
elif:
self.listOfObjects[self.currentSlice] =
self.currentO
unzip doesn't seem to work for me...
--
http://mail.python.org/mailman/listinfo/python-list
In C++ you can specify a comparision method, how can I do this with
python...
Say for instance the first list was a dictionary and I wanted to sort
on one of the keys in the dictionary?
--
http://mail.python.org/mailman/listinfo/python-list
yes... Thats the idea...
--
http://mail.python.org/mailman/listinfo/python-list
I have two lists.
I want to sort by a value in the first list and have the second list
sorted as well... Any suggestions on how I should/could do this?
--
http://mail.python.org/mailman/listinfo/python-list
This is what I've got so far:
class Shape(object):
def __init__(self):
pass
def render(self):
print 'Shape render'
self.outline()
def outline(self):
pass
class Rect(Shape):
def __init__(self):
Well here is a rough sketch of my code...
This is giving my two problems.
1) TypeError: super() argument 1 must be type, not classobj
2) I want to be sure the the draw code calls the inherited classes
outline and not its own...
class Shape:
def __init__(self):
pass
I have a base class called Shape
And then classes like Circle, Square, Triangle etc, that inherit from
Shape:
My quesiton is can a method of the Shape class call a method in Circle,
or Square etc...?
--
http://mail.python.org/mailman/listinfo/python-list
Well I guess what I'm trying to achive is the invalidate the instance
of the object.
I have been using None to denote an invalide or uninitialized instance
of an object.
There is a degenerate case in my code where a polygon has less than 3
points and
I want to class to flag this instance of the ob
if I create an object like...
obj = None
...
obj = anObject()
can obj set itself to none in some method of the class?
--
http://mail.python.org/mailman/listinfo/python-list
I have a list, and within it, objects are marked for deletion.
However when I iterate through the list to remove objects
not all the marked objects are deleted..
here is a code portion:
i = 0
for obj in self.objList:
i
I have a base class
class geometry(object):
def __init__(self):
self.blue = 1
self.red = 2
def render(self):
pass
class square(geometry):
def __init__(self):
super(square, self).__init__()
def render(self)
print 'square'
class circle(geometry):
d
I have a base class
class geometry(object):
def __init__(self):
self.blue = 1
self.red = 2
def render(self):
pass
class square(geometry):
def __init__(self):
super(square, self).__init__()
def render(self)
print 'square'
class circle(geometry):
d
75 matches
Mail list logo