4
> 3
> 2
> 1
>>> def printreverse(lst):
if lst:
printreverse(lst[1:])
print lst[:1][0]
>>> printreverse([1,2,3,4])
No good reason at all to do it this way. But recursion is fun.
-Jordan Greenberg
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
Has the addition of a Universe Set object ever been suggested. Like U
= set(0), so that any object was a member of U? Maybe this gets into
some crazy Cantorian stuff since U is in U. But it seems like it would
be useful and would have a nice symmetry with emptyset:set([]), that
is:
for any obje
SpreadTooThin wrote:
> If you are deriving a new class from another class,
> that you must (I assume) know the initializer of the other class.
>
> So in myClass
>
> import array
> class myClass(arrary.array):
>def __init__(self, now here I need to put array's constructor
> parameters..., then
er up my (and everyone else's) newsreader with your garbage.
Thanks,
Jordan
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney wrote:
> Jordan Greenberg <[EMAIL PROTECTED]> writes:
>
>> [EMAIL PROTECTED] wrote:
>>> This is a test message, please ignore.
>> I could do that, but reminding you that test messages go in *.test
>> groups is way more fun.
>
> I'
[EMAIL PROTECTED] wrote:
> Hi,
> Any ideas of what could be the problem?
>
Hard to say without seeing your code.
Jordan Greenberg
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
rickle wrote:
> I'm trying to compare sun patch levels on a server to those of what
sun
> is recommending. For those that aren't familiar with sun patch
> numbering here is a quick run down.
>
> A patch number shows up like this:
> 113680-03
> ^^ ^^
> patch# revision
>
> What I want to do is
Max M wrote:
> I am writing a "find-free-time" function for a calendar. There are a
lot
> of time spans with start end times, some overlapping, some not.
>
> To find the free time spans, I first need to convert the events into
a
> list of non overlapping time spans "meta-spans".
>
> This nice asci
Should work fine as far as I can see. Of course, thats not very
'pythonic' - I should probably give at least 10 different unit tests
that it passes ;)
Its gratifying to know I'm not the only one who needed that final
yield.
Jim Sizelove wrote:
> Bengt Richter wrote:
> > On Tue, 10 May 2005 15:14:
y first time, how exciting!), and in the
meantime, I'll let replies start accumulating froma whole lot of
people who are a lot smarter and more experience in Python than myself
:)
Several-weeks-in-and-still-liking-Python-better-than-any-other-previously-learned-language-ly
yours,
Jordan Rastrick
--
http://mail.python.org/mailman/listinfo/python-list
Leif K-Brooks wrote:
> Regardless of the various issues surrounding isinstance(), you have a
> difference in functionality. Since you're just storing a reference in
> the case of another LinkedList instead of copying it, mutating the
> LinkedList will be different from mutating another iterable t
Thanks for the replies, everyone. As is usual when reading
comp.lang.python, I got some invaluable exposure to new ideas (multiple
dispatching in particular seems to fill a gap I've felt in OO
programming in the past.)
I'm starting to think this newsgroup is in its own right an excellent
reason to
Well, copying and pasting this text, and changing <<>> to Foo so
that its a legal Python identifier (why did you not want to name your
class, out of curiosity), I get no problems with this.
class Foo:
def digest():
''' char[28] digest ( )
Return the digest of the strings passe
uggestion is to try my personal first rule for fixing
mysterious, unusual bugs in small, trivial pieces of code - which is to
delete the whole thing and type it out again from scratch. It works
surprisingly often.
Good luck
- Jordan
--
http://mail.python.org/mailman/listinfo/python-list
Is having to read two lines really that much worse than one? And the
only thing you find objectionable about the most obvious solution?
If so, then what's wrong with:
def foo():
# do some stuff
if debug: emit_dbg_obj(DbgObjFoo(a,b,c))
# do more stuff
To my mind, this is no l
Although you get infinite recursion with this code, you still get
enough information on the error from the interpreter to help you debug.
Running IDLE, I get a traceback of:
File "C:/Documents and Settings/Jordan/Desktop/more_blah.py", line 11,
in __init__
self.createFrames()
comp.lang.python is a great newsgroup in that respect - so long as you
ask a semi-intelligent question, you nearly always end up with a quick
and helpful response.
Good luck with learning programming, and Python (IMO its one of the
best possible languages to do it in)
--
http://mail.python.org/m
Can anybody please give me a decent justification for this:
class A(object):
def __init__(self, a):
self.a = a
def __eq__(self, other):
return self.a == other.a
s = A(3)
t = A(3)
>>> print s == t
True
>>> print s != t
True
I just spent a long, long time tracking down a
Well, I don't really want the objects to be comparable. In fact, to
quote that PEP you linked:
An additional motivation is that frequently, types don't have a
natural ordering, but still need to be compared for equality.
Currently such a type *must* implement comparison and thus
Just because a behaviour is documented, doesn't mean its not counter
intutitive, potentially confusing, and unnessecary.
I have spent a fair amount of time reading the Python docs. I have not
yet memorised them. I may have read this particular section of the
reference manual, or I may have not, I
I'd suggest the only nessecary change is, if objects a,b both define
__eq__ and not __ne__, then a != b should return not (a == b)
If a class defines __ne__ but not __eq__, well that seems pretty
perverse to me. I don't especially care one way or another how thats
resolved to be honest.
The order
Well, I'll admit I haven't ever used the Numeric module, but since
PEP207 was submitted and accepted, with Numeric as apparently one of
its main motivations, I'm going to assume that the pros and cons for
having == and ilk return things other than True or False have already
been discussed at length
I'm a Maths and Philosophy undergraduate first and foremost, with
Computer Science as a tacked on third; I've studied a fair bit of logic
both informally and formally, and am familiar with things such as the
non-nessecity of the law of the excluded middle in an arbitrary
propositional calculus farm
The : is used in Python for slice notation, which is explained pretty
thoroughly in the Python tutorial, specifically at:
http://www.python.org/doc/2.4/tut/node5.html
--
http://mail.python.org/mailman/listinfo/python-list
Python's current scoping differs from that in versions 2.1 and earlier
- statically nested (lexical) scoping was introduced under PEP 227.
I don't know what differences, if any, remain between Python's and
Perl's scoping rules, or if there is any tutorial concerning Python
scoping thats aimed spec
I've coded some simple recursive tree data structures using OO before
(unfortunately not in Python though). It's not nessecarily an
ill-suited approach to the task, although it depends on the specific
details of what you're doing. What's the the piece of code from which
your if...elif fragment is t
Another thing to keep in mind is that while technically both Python and
Java are converted into intermediate byte-codes, which are then
interpreted, the Java Virtual Machine runs java bytecode significantly
faster. Partly this is because Sun have put a lot of effort into making
Java as fast as poss
T. Crane wrote:
> Hi,
>
> If I define a class like so:
>
> class myClass:
> import numpy
> a = 1
> b = 2
> c = 3
>
> def myFun(self):
> print a,b,c
> return numpy.sin(a)
>
>
> I get the error that the global names a,b,c,numpy are not defined. Fairly
> stra
Joshua Kugler wrote:
"Beautiful is better than ugly."
And I think putting parenthesis around a multi-line statement is much
prettier.
So there! :)
j
And PEP 8 agrees with you. Another vote for parens.
-Jordan
--
http://mail.python.org/mailman/listinfo/python-list
I'm trying to write a simple program to calculate permutations. I created a
file called "mod.py" and put the following in it:
def factorial(n):
a = n
b = n
while a>0 and b>1:
n = (n)*(b-1)
b = b-1
def perm(n, r):
a = factorial(n)
b = factorial(n-r)
q =
I see no problem with finding existing code on the Internet and used to
learn a subject, so long as it isn't just stolen and handed in as is.
I guess I still believe people are good, no matter how hard Usenet and
IRC tries to convince me otherwise.
--
http://mail.python.org/mailman/listinfo/pyth
in the parameter list, **param gets a dict of arguments that dont
correspond to somthing in the formal parameter list.
More & examples in the python docs:
http://docs.python.org/tut/node6.html#SECTION00672
--
Jordan T. Greenberg
--
http://mail.python.org/mailman/list
tion doesn't just jump around unless you tell
it to.
--
Jordan T. Greenberg
Spork Polisher
--
http://mail.python.org/mailman/listinfo/python-list
I am creating a game called Nim, but cannot get a loop going no matter what
I do. What i am trying to do is get it to only accept input from 1 to 4,
and keep asking for input from the same player if he/she enters in an
invalid number. I also want it to stop when there is 1 or no piece(s) left,
and
my problem is that i can't get it to make the players have more than 1 turn
each, it accepts any value for playerChoice, (it is only supposed to accept
values from 1 to 4), and "
I have a simple tcp server and client where the server sits and waits
for a message and then processes it, my client sends its first message
to the server. On the server I receive:
socket.error: [Errno 107] Transport endpoint is not connected
when calling
msg = self.socket.recv(self.buffer)
My c
I found my car ;)
here's the server:
class commServer:
"""Class to hold a tcp server and interact with with it
allows for a wrapper around socket class to keep code clean"""
def __init__ (self, host, hostid, port, buff =1024):
self.host = host
self.hostid = hostid #id
> http://docs.python.org/library/socketserver.html
>
> JM
each time a handler is spawned is it client specific? in other words
when two clients send something to the server do handlers spawn for
each of them or does everything just go into a single handler?
--
http://mail.python.org/mailman/list
thanks JM,
at this point i switched over to this scheme and now I'm getting an
error durring instantiation of the server:
Server.py:
from Crypto.PublicKey import RSA
from ServerNegotiator import ServerNegotiator
from sharedComs import *
f = open("hostid")
tup = stringToTuple(f.readline()[0:-1])
H
I am trying to encrypt public data along with another tuple and then
decrypt it after sending. RSA is needed for negotiation of keys for
AES. But I just get garbage after I decrypt it. This is what I'm
attempting to do:
from Crypto.PublicKey import RSA
from Crypto import Random
gkey = RSA.generat
On Feb 9, 1:51 pm, Jean-Michel Pichavant
wrote:
> Jordan Apgar wrote:
> > thanks JM,
>
> > at this point i switched over to this scheme and now I'm getting an
> > error durring instantiation of the server:
> > Server.py:
> > from Crypto.PublicKey im
On Feb 9, 1:27 pm, Legrandin
wrote:
> > gkey = RSA.generate(384, Random.new().read)
> > string = str((gkey.publickey().__getstate__(),(333,444)))
>
> You are encrypting with RSA a piece of data which is way
> larger than the key size (48 bytes).
ah thanks Legrandin
--
http://mail.python.org/mail
Hey guys,
I'm having some issues connecting to my Socket Server, I get this
traceback on the sever side:
Exception happened during processing of request from ('127.0.0.1',
56404)
Traceback (most recent call last):
File "/usr/lib/python2.6/SocketServer.py"
I'm trying to right a server that needs specific information for each
client accessing it. The easiest way I could think of doing this is
keeping this information based on ip address (the information is only
valid for a short time). I know there is no was to get the client's
address directly and
Hey all,
I'm trying to convert the encrypted data from RSA to a string for
sending over xmlrpc and then back to usable data. Whenever I decrypt
I just get junk data. Has anyone else tried doing this? Here's some
example code:
from Crypto.PublicKey import RSA
from Crypto import Random
key = RSA
I'm trying to run two servers in the same program at once. Here are
the two:
class TftpServJ(Thread):
def __init__(self, ip, root, port=69, debug = False ):
Thread.__init__(self)
setup stuff here
def run(self):
try:
self.server.listen(self.ip, self.port
Hi all,
I'm trying to transfer a binary file over xmlrpclib. My test file is
a .jpeg file. I can transfer all the data over but when I go to open
the .jpeg I get "Error interpreting JPEG image file (Invalid JPEG file
structure: SOS before SOF)"
here's the code:
===Various Shared Funct
int date
print olddate
I get:
2010-03-16 14:46:38.409137
2010-01-16 14:46:38.409137
notice the 01 in the second date from what I could tell everything is
formatted correctly.
thanks for the help.
~Jordan
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 16, 3:07 pm, Christian Heimes wrote:
> Jordan Apgar wrote:
> > Hey all,
> > I'm trying to convert a string to a date time object and all my fields
> > convert except for month which seems to default to january.
>
> > here's what I'm
Hey guys,
I am sorry if this is not the right list to post some questions. I have a
simple question please and would appreciate some answers as I am new to Python.
I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]]
I want to arrang this array in different arrays so each one will have what is
att
I am in a computer science class in which I am supposed to be creating a
program involving a sine wave and some other functions. I understand the
concept of the problem, but I don't understand any of the "lingo" being
used. The directions might as well be written in a different language. Is
there a
tered it, and drove me to pour over the source to find out what
was happening. Perhaps this was good, but I wonder if it would just have
been simpler to provide the same access through a module function (eg:
reactor.reactor() -> reactor instance).
--
Jordan McCoy
-Original Message-
From:
e standard directories.
If this isn't the case, what are you using for TARGET_DIR?
Jordan
-Original Message-
From: [EMAIL PROTECTED] on behalf of Adam Blinkinsop
Sent: Mon 7/31/2006 5:42 PM
To: [email protected]
Subject: ImportError raised in script, not interactive session.
I
101 - 153 of 153 matches
Mail list logo