Raw string fu

2005-10-26 Thread Joshua Ginsberg
>>> r'\' File "", line 1 r'\' ^ SyntaxError: EOL while scanning single-quoted string >>> r'\\' '' Does that seem wrong to anybody else? Shouldn't the first one be syntactically correct? -jag -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda evaluation

2005-10-06 Thread Joshua Ginsberg
lambda is going to have to take arbitrary arguments, so I can't specify x=x before the arbitrary arguments (otherwise, it gets overridden) and I can't specify it afterward (syntax error). :-/ Thanks! -jag On Thu, 2005-10-06 at 16:27 -0400, Jp Calderone wrote: > On Thu, 06 Oct 2005 16:1

Lambda evaluation

2005-10-06 Thread Joshua Ginsberg
So this part makes total sense to me: >>> d = {} >>> for x in [1,2,3]: ... d[x] = lambda y: y*x ... >>> d[1](3) 9 Because x in the lambda definition isn't evaluated until the lambda is executed, at which point x is 3. Is there a way to specifically hard code into that lambda definition the c

Lambda with copy.deepcopy()

2005-08-30 Thread Joshua Ginsberg
Howdy -- I have a class that has an attribute that is a dictionary that contains an object that has a kword argument that is a lambda. Confused yet? Simplified example: import copy class Foo: def __init__(self, fn=None): self.fn = fn class Bar: d = {'foobar':

Iterators from urllib2

2005-07-22 Thread Joshua Ginsberg
I'm a bit baffled by something... In a script I wrote, I have defined a function that runs urllib2.urlopen() on a urllib2.Request object and returns the file-like object. The code that calls this function attempts to build a csv.DictReader object based on that file-like object, but an error

Re: [Pythonmac-SIG] Fwd: PPC OSX vs. x86 Linux

2005-04-11 Thread Joshua Ginsberg
Well, I compiled a fresh version of Python 2.3.5 from python.org to test the datetime theory... and I'm still getting 150sec execution times. :-/ I'm gonna test the string vs. strop now... -jag <>Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-

Weird...

2005-04-11 Thread Joshua Ginsberg
>>> {'a':1,'b':'2','c':[3,4]}.keys() ['a', 'c', 'b'] How come? :-) -jag Python 2.3.3 (#1, May 7 2004, 10:31:40) [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2 <>Joshua Ginsberg -- [EMAIL PROTECTED] Brain

Re: Https Form Page

2005-04-10 Thread Joshua Ginsberg
It all really, really, really depends on your script processing the form. My suggestion is to use the openssl s_client program, manually submit your data, and see what your server is responding with. -jag <>Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-24

Re: Exception Handling

2005-04-08 Thread Joshua Ginsberg
rror class inherits from the generic Exception class). -jag <>Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 3:29 PM, SuperJared wrote: I'm new to Python, well versed in PHP and a bit of Perl. I've written a simple back

Re: Https Form Page

2005-04-08 Thread Joshua Ginsberg
ps_headers = fs.info().headers https_mimetype = fs.info().type -jag <>Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 2:13 PM, Hasan D wrote: I'm new on this httplib and urllib. Actually I dont know what should i use. I wa

Re: Equivalent string.find method for a list of strings

2005-04-08 Thread Joshua Ginsberg
try: filter(lambda x: lines[x].find(searchstring) != -1, range(len(lines))) That will return a list with the indices of every line containing a hit for your search string. -jag <>Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, a

Re: Equivalent string.find method for a list of strings

2005-04-08 Thread Joshua Ginsberg
Try: filter(lambda x: x.find(searchstring) != -1, lines) <>Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 12:17 PM, jeremit0 wrote: I have read a text file using the command lines = myfile.readlines() and now I want to seach

Re: redirect stdout

2005-04-08 Thread Joshua Ginsberg
Use *NIX magic. Make a named pipe to a python program that pushes stdin to syslog and when you execute your program, redirect stdout to the named pipe. -jag <>Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 10:52 AM, Neal

PPC OSX vs. x86 Linux

2005-04-08 Thread Joshua Ginsberg
, 00:49:11) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin and Python 2.3.3 (#1, May 7 2004, 10:31:40) [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2 <>Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131-- http://mail.python.o