[issue25879] Code objects from same line can compare equal

2015-12-15 Thread Kirk McDonald
Kirk McDonald added the comment: This is a duplicate of http://bugs.python.org/issue25843 -- resolution: -> duplicate status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue25879] Code objects from same line can compare equal

2015-12-15 Thread Kirk McDonald
New submission from Kirk McDonald: The following code gives an unexpected result: >>> a, b = lambda: 1, lambda: 1.0 >>> a() 1 >>> b() 1 >>> type(b()) >>> a.__code__ is b.__code__ True The cause boils down to this line of code: https://hg

[issue25879] Code objects from same line can compare equal

2015-12-15 Thread Kirk McDonald
Changes by Kirk McDonald <kirklin.mcdon...@gmail.com>: -- components: +Interpreter Core type: -> behavior versions: +Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 ___ Python tracker <rep...@bugs.pytho

[issue5611] Auto-detect indentation in C source in vimrc

2009-03-30 Thread Kirk McDonald
New submission from Kirk McDonald kirklin.mcdon...@gmail.com: According to PEP 7, older C source files are indented with tabs, and newer ones are indented with spaces. The vimrc file in the repository assumes that existing C source files should be indented with tabs, and it should indent

[issue1643] Add group() to itertools

2007-12-17 Thread Kirk McDonald
New submission from Kirk McDonald: One question which is asked with surprising frequency in #python is how to yield multiple objects at a time from an iterable object. That is, given [1, 2, 3, 4, 5, 6], get [(1, 2), (3, 4), (5, 6)]. The grouper function in the itertools recipes page provides

Re: what is the keyword is for?

2006-08-15 Thread Kirk McDonald
) integers. Python may re-use certain small integers when you might not expect it to; this is done in the interests of efficiency. If you only compare the /values/ of numbers (with ==), then you will never notice this. a = 1 b = 1 c = 100 d = 100 a is b True c is d False -Kirk

Re: Augument assignment versus regular assignment

2006-07-09 Thread Kirk McDonald
Frank Millman wrote: nagy wrote: Thanks, Kirk. I considered the += as only a shorthand notation for the assignment operator. Since for lists + is simply a concatetation, I am not sure it x=x+[2] is creating a brand new list. Could you refer me to any documentation on this? Thanks, Nagy My

Re: Augument assignment versus regular assignment

2006-07-08 Thread Kirk McDonald
Python frees it. The augmented assignment, as I went over previously, attempts to modify the list object directly. Any names bound to the object (or any other objects that reference the object) will see the changes. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: Augument assignment versus regular assignment

2006-07-07 Thread Kirk McDonald
nagy wrote: I do the following. First create lists x,y,z. Then add an element to x using the augumented assignment operator. This causes all the other lists to be changed also. But if I use the assignment x=x+[4] instead of using the augumented assignment, the y and z lists do not change.

Re: Turning a callback function into a generator

2006-07-03 Thread Kirk McDonald
[EMAIL PROTECTED] wrote: Peter Otten wrote: Kirk McDonald wrote: Let's say I have a function that takes a callback function as a parameter, and uses it to describe an iteration: def func(callback): for i in [1, 2, 3, 4, 5]: callback(i) Which object is immutable

Re: Turning a callback function into a generator

2006-07-03 Thread Kirk McDonald
Alex Martelli wrote: Lawrence D'Oliveiro [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Kirk McDonald [EMAIL PROTECTED] wrote: I want to somehow, in some way, provide an iteration interface to this function. Thoughts? Run it in a separate thread/process? Sounds best to me

Turning a callback function into a generator

2006-07-02 Thread Kirk McDonald
on the callback mechanism. The function is an existing interface, and I cannot change it. I want to somehow, in some way, provide an iteration interface to this function. Thoughts? -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

API functions not working as expected

2006-06-15 Thread Kirk McDonald
this function. Am I missing something here? Is there, in fact, no point to these InPlace* functions? -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

TypeCheck vs IsInstance in C API

2006-05-30 Thread Kirk McDonald
a tuple as the second argument and check the type of the first argument against every item in the tuple. I also see that TypeCheck was added in version 2.2. Why was it added? Its functionality already seems covered by IsInstance. Is it a new-style vs. old-style class thing? -Kirk McDonald

Re: setting file permissions on a web server

2006-04-30 Thread Kirk McDonald
to Windows network file-sharing.) (Heh, I checked just before posting this and someone beat me to it. Here's my post anyway.) :-) -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: 2-dimensional data structures

2006-02-18 Thread Kirk McDonald
variables, and so on. What can I say? It was a straight conversion from C++. I hardly knew what Pythonic meant.) -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: calculating on matrix indices

2006-02-17 Thread Kirk McDonald
floats), but this does cause it to work. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: embedding python in HTML

2006-02-17 Thread Kirk McDonald
John Salerno wrote: bruno at modulix wrote: You've got to understand that Python is *not* a 'ServerPage' language (- php, asp, jsp etc) in itself. Your server can now run python, fine, but *how* ? CGI ? FastCGI ? mod_python ? other ? (hint: it's probably just plain old CGI...) So does

Re: UnboundMethodType and MethodType

2006-02-08 Thread Kirk McDonald
PROTECTED] You know what? That makes perfect sense. Thank you. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: UnboundMethodType and MethodType

2006-02-07 Thread Kirk McDonald
or not. Thus, it should always have the same type. It's simply called in different ways. You can just as easily say: B.bar(b) As: b.bar() -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: Automatic class attribute

2006-02-03 Thread Kirk McDonald
): def __init__(cls, name, bases, dict): cls.observers = [] def showObservers(cls): print cls.observers class C(object): __metaclass__ = M class D1(C): pass class D2(C): pass -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: Global variables, Classes, inheritance

2006-02-03 Thread Kirk McDonald
in a function. Namespaces in Python are really great. It is worth reading up on globals() and locals() if you don't get them yet. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: python's library support

2006-02-03 Thread Kirk McDonald
a lot, and if it fails you, there's more than likely a third-party library available. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: OO conventions

2006-02-01 Thread Kirk McDonald
with the PIL module; there might be more stuff going on behind the scenes with the way they do it.) -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: cgi - secure sessions

2006-02-01 Thread Kirk McDonald
I've been playing with them recently, and they seem to work. :-) -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: cgi - secure sessions

2006-02-01 Thread Kirk McDonald
/module-Cookie.html It may simplify matters. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Kirk McDonald
, k) for k, v in self.histo.items()] sortedList.sort() Should do it... -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Kirk McDonald
) dict.get's default return value is your friend. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Kirk McDonald
::map this ain't. To sort its elements, you need to build a list of the items and sort that, e.g.: items = [(v, k) for k, v in self.histo.items()] items.sort() This will give you a list of (value, key) tuples sorted by value. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python

Introspection with classes

2006-01-31 Thread Kirk McDonald
of a class variable which, uh, was sort of dumb). Coming from C++, I'm still wrapping my brain around Python's introspection abilties. Can I generalize this more? Am I missing some idiom or language feature that would benefit me? Where's my time machine? -Kirk McDonald -- http://mail.python.org

Re: Returning a value from code string

2006-01-29 Thread Kirk McDonald
the PSP document deal with it. That should be adequate. In short, I learned something about exec and namespaces that I'm not actually going to use. Hooray! -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing lines from a text file

2006-01-29 Thread Kirk McDonald
#SECTION00514 -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing lines from a text file

2006-01-29 Thread Kirk McDonald
hard. Say you want to read in all the lines from the file object f and just print them out one at a time: lines = f.getlines() for line in lines: print line Simple. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing lines from a text file

2006-01-29 Thread Kirk McDonald
is the following: AttributeError: 'file' object has no attribute 'getlines' D'oh! That's because the method is readlines(). Stupid brain: log = open('C:\log_0.txt') lines = log.readlines() for line in lines: print line -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

URL Character Decoding

2006-01-29 Thread Kirk McDonald
not entirely used to them. This is clearer to me, at least.) I guess what I'm asking is: Is there a library function (in Python or mod_python) that knows how to do this? Or, failing that, is there a different regex I could use to get rid of the substitution function? -Kirk McDonald -- http

Re: URL Character Decoding

2006-01-29 Thread Kirk McDonald
Kirk McDonald wrote: If you have a link such as, e.g.: a href=index.py?title=Main MenuMain menu!/a The space will be translated to the character code '%20' when you later retrieve the GET data. Not knowing if there was a library function that would convert these back to their actual

Re: URL Character Decoding

2006-01-29 Thread Kirk McDonald
Kirk McDonald wrote: Actually, I just noticed this doesn't really work at all. The URL character codes are in hex, so not only does the regex not match what it should, but sub_func fails miserably. See why I wanted a library function? -Kirk McDonald Not to keep talking to myself

Re: URL Character Decoding

2006-01-29 Thread Kirk McDonald
Paul McGuire wrote: Kirk McDonald [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] If you have a link such as, e.g.: a href=index.py?title=Main MenuMain menu!/a The space will be translated to the character code '%20' when you later retrieve the GET data. I guess what I'm asking

Re: Returning a value from code string

2006-01-28 Thread Kirk McDonald
. :-) -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Kirk McDonald
Fred wrote: No matter what I type in the form text box (or even if I leave it blank) I get all the records. Try this: #!/usr/local/bin/python print Content-Type: text/html\n import MySQLdb import cgi db=MySQLdb.connect(host = 'localhost', db = 'phone') cursor=db.cursor() cursor.execute(Select

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Kirk McDonald
Fred wrote: Yeah, I already tried that (except you have a , after name. Your code produces the same error: NameError: name 'name' is not defined I know I am close!! Just missing some small thing... Oh, duh. I forgot something: #!/usr/local/bin/python print Content-Type: text/html\n

Re: Returning a value from code string

2006-01-28 Thread Kirk McDonald
Max wrote: Kirk McDonald wrote: Another kind of node (I'm still deciding whether to call them Codenodes or Opcodes or maybe Pynodes) is a chunk of code that can be asked to run itself, and which can be edited, on the fly, from within the website. Thus, one can both alter

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Kirk McDonald
Dennis Lee Bieber wrote: On Sat, 28 Jan 2006 10:14:44 -0800, Kirk McDonald [EMAIL PROTECTED] declaimed the following in comp.lang.python: The comma is intentional: the MySQLdb wants the argument(s) as a tuple. The DB-API wants tuples... But my last perusal of the MySQLdb Python

Re: String Manipulation Help!

2006-01-28 Thread Kirk McDonald
it works. -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Re: Decoupling the version of the file from the name of the module.

2006-01-28 Thread Kirk McDonald
really want to do this right, you could install Subversion. :-) -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list

Returning a value from code string

2006-01-27 Thread Kirk McDonald
could have defined it like this: noreturn = \ locals().update(kwargs) print 'arg = %s' % arg -Kirk McDonald -- http://mail.python.org/mailman/listinfo/python-list