Re: FOR statement

2006-10-20 Thread Jordan Greenberg
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

A Universe Set

2006-10-03 Thread jordan . nick
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

Re: Need help with syntax on inheritance.

2006-10-03 Thread jordan . nick
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

Re: test message

2006-11-26 Thread Jordan Greenberg
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

Re: test message

2006-11-26 Thread Jordan Greenberg
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'

Re: python skipping lines?

2006-11-27 Thread Jordan Greenberg
[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

Re: dictionary comparison

2005-05-05 Thread Jordan Rastrick
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

Re: Merging overlapping spans/ranges

2005-05-10 Thread Jordan Rastrick
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

Re: Merging overlapping spans/ranges

2005-05-11 Thread Jordan Rastrick
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:

Is isinstance always "considered harmful"?

2005-05-15 Thread Jordan Rastrick
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

Re: Is isinstance always "considered harmful"?

2005-05-16 Thread Jordan Rastrick
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

Re: Is isinstance always "considered harmful"?

2005-05-16 Thread Jordan Rastrick
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

Re: "End Of Line" Confusion

2005-05-17 Thread Jordan Rastrick
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

Re: "End Of Line" Confusion

2005-05-18 Thread Jordan Rastrick
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

Re: any macro-like construct/technique/trick?

2005-06-01 Thread Jordan Rastrick
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

Re: Lost in the inheritance tree...

2005-06-06 Thread Jordan Rastrick
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()

Re: Lost in the inheritance tree... THANKS!

2005-06-06 Thread Jordan Rastrick
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

Annoying behaviour of the != operator

2005-06-08 Thread Jordan Rastrick
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

Re: Annoying behaviour of the != operator

2005-06-08 Thread Jordan Rastrick
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

Re: Annoying behaviour of the != operator

2005-06-08 Thread Jordan Rastrick
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

Re: Annoying behaviour of the != operator

2005-06-08 Thread Jordan Rastrick
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

Re: Annoying behaviour of the != operator

2005-06-08 Thread Jordan Rastrick
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

Re: Annoying behaviour of the != operator

2005-06-08 Thread Jordan Rastrick
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

Re: Please help me understand this code....

2005-06-17 Thread Jordan Rastrick
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

Re: Overcoming herpetophobia (or what's up w/ Python scopes)?

2005-06-17 Thread Jordan Rastrick
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

Re: OO approach to decision sequence?

2005-06-18 Thread Jordan Rastrick
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

Re: extreme newbie

2005-06-18 Thread Jordan Rastrick
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

Re: namespace question

2007-05-18 Thread Jordan Greenberg
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

Re: Proof that \ is a better line joiner than parenthetical sets

2008-06-06 Thread Jordan Greenberg
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

TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'

2008-05-01 Thread Jordan Harry
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 =

Re: help

2006-03-08 Thread Jordan Greenberg
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

Re: Function params with **? what do these mean?

2006-03-20 Thread Jordan Greenberg
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

Re: Getting a loop to activate a loop above it

2006-03-22 Thread Jordan Greenberg
tion doesn't just jump around unless you tell it to. -- Jordan T. Greenberg Spork Polisher -- http://mail.python.org/mailman/listinfo/python-list

"Nim" game being created, no GUI used... Need tips...

2010-02-05 Thread Jordan Uchima
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

still having problems with "Nim". using python 2.6.4

2010-02-07 Thread Jordan Uchima
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 "

errno 107 socket.recv issue

2010-02-09 Thread Jordan Apgar
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

Re: errno 107 socket.recv issue

2010-02-09 Thread Jordan Apgar
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

Re: errno 107 socket.recv issue

2010-02-09 Thread Jordan Apgar
> 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

Re: errno 107 socket.recv issue

2010-02-09 Thread Jordan Apgar
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

Pycrypto RSA Issue

2010-02-09 Thread Jordan Apgar
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

Re: errno 107 socket.recv issue

2010-02-09 Thread Jordan Apgar
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

Re: Pycrypto RSA Issue

2010-02-09 Thread Jordan Apgar
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

SocketServer error: AttributeError: instance has no __call__ method

2010-02-10 Thread Jordan Apgar
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"

SimpleXMLRPCServer and client address

2010-02-10 Thread Jordan Apgar
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

Pycrypto RSA ciphertext to string back to ciphertext issue

2010-02-11 Thread Jordan Apgar
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

fork vs threading.Thread

2010-02-12 Thread Jordan Apgar
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

Binary data transfer issue

2010-03-15 Thread Jordan Apgar
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

datetime string conversion error

2010-03-16 Thread Jordan Apgar
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

Re: datetime string conversion error

2010-03-16 Thread Jordan Apgar
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

array matching

2010-04-29 Thread Bill Jordan
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

programming

2010-09-19 Thread Jordan Blanton
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

RE: Borg vs. Module

2006-07-31 Thread Jordan R McCoy
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:

RE: ImportError raised in script, not interactive session.

2006-07-31 Thread Jordan R McCoy
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

<    1   2