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
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
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
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
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
) 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
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
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
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.
[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
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
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
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
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
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
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
floats), but this does cause it to work.
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
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
PROTECTED]
You know what? That makes perfect sense. Thank you.
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
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
):
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
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
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
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
I've been playing with them recently, and they seem to work. :-)
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
/module-Cookie.html
It may simplify matters.
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
, k) for k, v in self.histo.items()]
sortedList.sort()
Should do it...
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
)
dict.get's default return value is your friend.
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
::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
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
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
#SECTION00514
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
. :-)
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
it works.
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
really want to do this right, you could install Subversion. :-)
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
could have defined it like
this:
noreturn = \
locals().update(kwargs)
print 'arg = %s' % arg
-Kirk McDonald
--
http://mail.python.org/mailman/listinfo/python-list
46 matches
Mail list logo