Probably the quoting of the argument to grep.
try this instead:
> p1 = Popen(['grep', 'Sep 22', '/var/log/auth.log'], stdout=PIPE)
etc
Jeff
--
http://mail.python.org/mailman/listinfo/python-list
For the same reason that
def f(z):
z *= z
c = 1
f(c)
print c
prints 1.
Jeff
pgpF5jQBO3otJ.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
Oops!
I should have used '2' in the example, or some other number.
I was trying to make a point about what
x *= ...
means when it is in the context of a function (or method) body.
I think this is key to understanding what Python did in the case the user
posted.
Being rude wasn't my inte
You can index into a string:
>>> s = '06897'
>>> s[2]
'8'
You can also turn each character into an integer, in various ways:
>>> [int(c) for c in s]
[0, 6, 8, 9, 7]
>>> map(int, s)
[0, 6, 8, 9, 7]
Jeff
pgpDMq5e3RucB.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/pyth
Compared to your program, I think the key to mine is to divide by "limit"
before taking the log. In this way, things below the "limit" go to the next
lower integer.
I think that instead of having 'step' and 'base', there should be a single
value which would be 1000 or 1024.
import math
def Mak
You need to "export" the variables. otherwise, they exist only in the shell,
not in the processes it starts.
Jeff
pgplXE5VuF44A.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
Use sys.stdout.write instead of print. It will solve these problems you are
having.
If you really want to know what's going on, read the language manual,
http://docs.python.org/ref/print.html It explains the behavior of this extra
space, which is output by a successive 'print' statement. The imp
Here's one case where it's bad to call update.
def perform_longrunning_calculation():
time.sleep(1)
app.update()
time.sleep(1)
suppose you kick this off with a keybinding, such as:
app.bind("c", lambda e: perform_longrunning_calculat
> would it be advisable to guard against this with something like this?
>
> def perform_longrunning_calculation():
> if not app.busy:
> app.busy = 1
[...]
By using that kind of construct, instead of using update_idletasks(),
you force all code to be aware of and manage the app.busy
it *is* a string.
because most of the characters are not printable, they're presented using hex
notation when you repr() the string. That's what entering an expression in the
interactive interpreter does (except that it never prints 'None').
If you really want to write whatever those bytes are,
As for performance, you'll need to benchmark it.
However, I think the functionality you're asking for is available as
inspect.currentframe(), and if the implementation is in "C" it may have a tiny
performance advantage over the Python version.
Jeff
pgpENIs7apfaF.pgp
Description: PGP signature
-
On Mon, Oct 03, 2005 at 02:34:40PM -0700, leo wrote:
> I come from a java background, where Exceptions are a big Avoid Me, but
> are the performance implications the same in Python? We're expecting a
> big load on our app (100,000 users/hour) , so we'd like to be as tuned
> as possible.
I don't kn
Here are two ideas that come to mind:
files = glob.glob("UNQ*.dat") + glob.glob("Unq*.dat") + glob.glob("unq.dat")
files = [f for f in glob.glob("*.dat") if f[:3] in ("UNQ", "Unq", "unq")]
Jeff
pgp30Rue2EGi7.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
I've rewritten your middle example to be clearer.
$ python2.4
Python 2.4.1 (#1, May 16 2005, 15:15:14)
[GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> type("Y", (type,), {"mro": lambda x: [float]})("X", (), {})
and here's
Apparently, calling bind() with a zero "port" will choose some available port
number, as demonstrated by this program:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("", 0))
print s.getsockname()
Here's how it behaved over several runs:
$ python soc.py
('0.0.0.0', 34
On Tue, Oct 04, 2005 at 05:19:37PM -0400, Mohammed Smadi wrote:
> what else would you do? I am using examples from the web and they all
> bind to a port at the localhost before connecting to the remote host.
[...]
the web must be stupider than I thought.
Here's how Python's own ftplib connects
Interesting. I'd noticed that the metaclass one didn't crash my 2.2, but I
didn't check the marshal one.
This one core dumps in 'Python 2.2.2 (#1, Feb 24 2003, 19:13:11) ... linux2'
but inexplicably prints 'keys' when I ran it on the 2.4.1 I used in my last
post.
>>> import marshal
>>> f = lambd
Here's how:
1. open your web browser
2. visit the url http://docs.python.org
3. click the link "Library Reference" (keep this under your pillow)
4. scan down the list of modules until you see these two items:
4.6 StringIO -- Read and write strings as files
4.7 cStringIO -- Faster v
I'm surprised you found any example of 'locals().update' that worked.
Here's one that doesn't work:
def f(y):
locals().update({'x': y})
return x
print f(3) # prints 3?
Jeff
pgpLVe48NBWmT.pgp
Description: PGP signature
--
http://mail.python.org/mailm
Do you have a simple program that demonstrates the problem?
I have an x86 machine with Python 2.3, and an x86_64 machine with Python 2.4
available. I wrote a simple test program which performs a slice operation,
but it behaves the same on both platforms.
Here's the program:
#
On Sat, Oct 08, 2005 at 01:53:28PM +, Duncan Booth wrote:
> Unless the results stored in the cache are very large data structures, I
> would suggest that you simply store (args,kwargs) as the cache key and
> accept the hit that sometime you'll cache the same call multiple times.
... except t
You'll probably see a slight speed increase with something like
for a in CustomersToMatch:
for b in Customers:
if a[2] == b[2]:
a[1] = b[1]
break
But a really fast approach is to use a dictionary or other structure
that turns the inner loop in
On Mon, Oct 10, 2005 at 09:12:13AM +1000, Timothy Smith wrote:
> FAYI i have already found it and it was a wrongly indented code block :/
When indentation leaves an illegal program structure, Python gives a very
informative error message, such as
File "/tmp/x.py", line 3
return 3
On Mon, Oct 10, 2005 at 12:20:13AM +0100, Tom Anderson wrote:
> What puzzles me, though, are bytecodes 17, 39 and 42 - surely these aren't
> reachable? Does the compiler just throw in a default 'return None'
> epilogue, with routes there from every code path, even when it's not
> needed? If so,
I took the advice from this web page:
http://support.microsoft.com/kb/q100027/
(I don't know how this extends to floppies, and the 9x family of OSes isn't
listed in "applies to", so this may not help your case)
Here, I open "physical drive 0" and see that the magic number indicates a valid
On Mon, Oct 10, 2005 at 03:02:30PM -0700, Dave wrote:
> Hello All,
>
> As far as I understand, Python deals with a lot of
> string objects, i.e. it looks up all names. Is there a
> way to find out how many name lookup operations take
> place in a Python program? Is it the name lookup
> operation o
Recalling the parallel pinout, pin 3 is data bit 2. Have you tried
def BIT(x): return 1<
pgprfRaNUTBBH.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
I'm not aware of any PEPs on the subject, but google groups turns up some past
threads. Here's one from February 2004:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/d5fcc1c8825a60dc/96856af647ce71d5
I didn't immediately find this message of Guido's that everyone's talk
While there may be a discussion somewhere in the archives,
the comments in listobject.c are enlightening too.
/* Ensure ob_item has room for at least newsize elements, and set
* ob_size to newsize. If newsize > ob_size on entry, the content
* of the new slots at exit is undefined heap trash; it
On Tue, Oct 11, 2005 at 11:06:32AM -0700, [EMAIL PROTECTED] wrote:
> Note that when I type:
> >>>dir(D)
[...]
> the functions __ge__, __gt__, __lt__, __le__ seem to be non-implemented
> but there is some __doc__ in them. Is there the intention to do
> something similar as is described above or are
Concatenating filenames with "+" is seldom what you want.
Instead, you should use os.path.join (or, to decrease portability,
nt.path.join).
Jeff
pgpUKTuVnB2qh.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
It should be the same as for any program
$ program-compiled-with-pg
$ gprof /path/to/program-compiled-with-pg
you'll need to make sure that python is not only *compiled* with -pg
but that the *link line* contains -pg as well. That's a common "gotcha" when
it comes to profiling.
Jeff
pgpQy
there's 'os.rename' for moving (single) files, and several functions in
'shutil' for moving and copying trees of files.
Jeff
pgpS5MgPvRJQZ.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
If you're always going from grey to tinted, then the easiest way is to
treat it as a 'P' image with a special palette.
I believe this function will prepare the palette:
def make_palette(tr, tg, tb):
l = []
for i in range(255):
l.extend([tr*i / 255,
On Mon, Oct 10, 2005 at 08:37:03PM +0100, Tom Anderson wrote:
> So python doesn't use the old SmallTalk 80 SmallInteger hack, or similar?
> Fair enough - the performance gain is nice, but the extra complexity would
> be a huge pain, i imagine.
I tried to implement this once. There was not a per
mple, using a file in UTF-8 I have laying around:
>>> f = codecs.open("/users/jepler/txt/UTF-8-demo.txt", "r", "utf-8")
>>> for i in range(5): print repr(f.readline())
...
u'UTF-8 encoded sample plain-text file\n'
u'\u203e\u203e\u203e\u
It's almost certainly a false positive. In my day job we run into false
positive antivirus detections like this once or twice a year, and
typically get a runaround from the AV vendor (who often have the gall to
suggest that we should buy a copy of their broken software before
they'll fix their pro
In Unix, you generally can't affect the environment of your parent program (in
a broad sense, which includes environment variables, current working directory,
opened files, effective user ID, etc).
You have two basic choices to achieve an effect like this. First, you can
start a subshell with the
I think you're mistaken about how 'sh -c' works. The next argument after "-c"
is
the script, and following arguments are the positional arguments. (what, you've
never used -c in conjunction with positional arguments? me either!)
Example:
-
On Wed, Oct 19, 2005 at 09:26:16AM -0700, Dr. Who wrote:
> The fact that the directory already exists is irrelevant to the function...it
> still failed to create the directory.
That's not true. Imagine that os.makedirs() is used inside tempfile.mkdtemp()
(I looked, and it isn't) and the proposed
In the FileDialog module there are both LoadFileDialog and SaveFileDialog. Is
the latter what you want?
Jeff
pgptzMbfYw5VI.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
does collections.deque have a blocking popleft()? If not, it's not very
suitable to replace Queue.Queue.
Jeff
pgp9S3BEmciKx.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
I think that you want to use
return PyString_FromStringAndSize(buf, 8);
Jeff
pgp3nNxegNjmk.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Oct 25, 2005 at 04:11:39PM +0100, Matthew Fowler wrote:
> "problem with execution of xhpl on AxisProduct: [Errno 8] Exec format
> error"
In this case, it appears that Python is reporting the error of some operating
system call, such as execve.
On my operating system, here's a program wh
I'm not sure why Tk behaves this way, but you can observe the same behavior
with a "wish" script. It would seem that "break" skips any other scripts
associated with item tags, but still proceeds to bindings at the widget level.
Using a binding with "break" on the canvas itself may help you get the
I wrote the following small program:
#---
import sys, Tkinter
t = Tkinter.Tk()
b = Tkinter.Button(command=lambda: sys.exit(0), text="Click to exit")
b.pack()
t.mainloop()
#---
I recommend using 'xwd' to actually get the screenshot, because xwd is
installed nearly everwhere X is. xwd-format images are "documented" by the
header file X11/XWDFile.h. This program works in a pipeline to convert certain
xwd-format images to postscript. You can use it something like this:
On Mon, Oct 31, 2005 at 03:17:05PM -0800, dale cooper wrote:
> Thanks, but I've got another question:
>
> can't find Tcl configuration script "tclConfig.sh"
This file comes from the following package:
$ rpm -qf /usr/lib*/tclConfig.sh
tcl-devel-8.4.9-3
Fedora generally splits packages which are
This section of the tutorial discusses the module search path:
http://docs.python.org/tut/node8.html
6.1.1 The Module Search Path
When a module named spam is imported, the interpreter searches for a file
named
spam.py in the current directory, and then in the list of director
You are importing and using, directly or indirectly, the "strop" module.
Here's an example from the interactive interpreter which triggers the warning:
$ python2.3
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
Type "help", "copyright", "credits"
The file you open() may be closed as soon as it is no longer possible to refer
to it.
So in the first case, because the top-level variable 'f' continues to refer to
the opened
file, the file may not be closed.
In the second case, no variable refers to the opened file after lock() returns,
so P
There should be no problem with this. After all, even the "greeter" is just an
X application. Depending on which login manager you use (xdm/kdm/gdm/whatever)
the details of getting your Tkinter app to actually be run will vary, though.
In gdm, it looks like adding it to the file /etc/X11/gdm/Init
I think this is fcntl(..., F_SETFL, ...), so something like
import os, fcntl, sys
flags = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL)
flags |= os.O_DIRECT
fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, flags)
Jeff
pgpx52DBavw3Y.pgp
Description: PGP signature
--
http://m
Here's some text from my open(2) manpage:
Transfer sizes, and the alignment of user buffer and file offset must all
be multiples of the logical block size of the file system.
It's unlikely that in practice you can get Python's sys.stdin.read() or
os.read() to reliably use a buffer that
"login APIs" vary widely from system to system.
Classic Unix systems use calls like getpwent and crypt to check passwords, and
then call setuid, setgid and setgroups to set the identity of the user who is
logging in. These are all available in stock Python, check the library
reference for more de
Use 'd' as the format character for 64-bit double precision numbers with struct.
>>> x = 148.73
>>> unpack(">> unpack("
pgpB2b9owxZs7.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
Let's find out! This program creates a series of rectangles, with the color
going from black to nearly white. White corresponds to higher x and y
coordinate values. So the answer to your question can be seen in the output
of the program.
import Tkinter
c = Tkinter.Canvas(width=220, height=220)
On Fri, Nov 11, 2005 at 11:25:56PM -0500, Mike Meyer wrote:
> You didn't say what the password was for, so I skipped asking for it.
You're a real comedian.
Jeff
pgpxqmFz5jalu.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
Normally, an entry widget requests horizontal space equal to the value of the
width= option times the "average" character width of the font it displays.
Setting it to 0 makes the entry request exactly enough width to show the string
it contains.
Making them sticky to the east and west sides of th
On Sun, Nov 13, 2005 at 09:44:43PM +, Bengt Richter wrote:
> even if expr1 had a __unaryop__ method,
> expr1 - expr2
> could not become
> expr1.__unaryop__(-expr2)
> unless you forced the issue with
> expr1 (-expr2)
as opposed to being a function call? I don't think you've solved
So if you have the dominoes (1 2), (3 2) and (3 1) you must arrange them as
1|2|3
2|3|1
? If so, then it seems to me your algorithm is this:
1. pick an arbitrary domino to be first, and an arbitrary side to be the "top"
2a. until the dominoes are exhausted, pick the other domino wi
Compared to your program, I
* Made sure that the slave program actually flushed its stdout buffers
* didn't call read(), which will by default continue reading until
it reaches EOF, not merely read the available data
#!/usr/bin/env python
import sys, time, Tkinter, itertools, _tkinter, os
if
Since this is a bug in Python (Tix.py), it should be submitted to the Python
Patch tracker at sf.net/projects/python
You need a free "sourceforge" account to submit an item to the bug or patch
tracker.
Jeff
pgp1zmMFcYHrz.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo
It's likely to be a challenge; each one has its own "event loop", and
the exact pitfalls of trying to use both at the same time probably
depend on the operating system too. For instance, on X, Tk and SDL
probably both expect full control of the handlers registered with
XSetErrorHandler and XSetIOE
On Tue, Nov 15, 2005 at 06:33:40PM -0700, Nathan Pinno wrote:
> Thanks. I was going to use TKInter to pop up a message box, then use pygame
> to run the game and display the score on the playing surface. Is this still
> possible (I'm using Python 2.4.1 and Pygame 1.7.0 on WinXP with Service Pack
>
Tkinter "frame"s don't scroll. Instead, you need to use something like
bwidget's "ScrollableFrame" widget. You may want to combine this with
bwidget's "ScrolledWindow".
Below is an example which uses my "pybwidget" package, available at
http://tkinter.unpy.net/bwidget/
#
This is really just a snide joke at the expense of Microsoft, but have you
checked the MSDN documentation about ConvertToNonresident or ReplaceAttribute2?
Your search - site:msdn.microsoft.com ConvertToNonresident OR
ReplaceAttribute2 - did not match any documents.
-- google.com
Sure, there's a difference. Consider how this program behaves.
Quit only quits the mainloop, Destroy destroys the root widget.
When you Quit, you can enter the mainloop again.
from Tkinter import *
t = Tk()
Button(t, command=t.quit, text="Quit").pack()
Button(t, command=t.destroy, text="Destroy")
As Fredrik suggests, consult the source to find out. Almost all of this
is in the realm of being an implementation detail, and hashes aren't
guaranteed to be the same from version to version or machine to machine.
I'm not even sure they're guaranteed to be the same from run to run.
Here's an exam
You could use a format like "#s#sO", and then use PyFloat_Check,
PyFloat_AsDouble, and the equivalent PyInt macros to get the "C" value out of
the Python object.
You should be able to use the converter "O&" to get what you want. The
conversion function might look like:
int double_only(PyO
If I found the right "U3" when I googled, then maybe this is relevant:
http://www.voidspace.org.uk/python/movpy/
Jeff
pgp1AjuUdEskN.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
>>> ll = [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]]
>>> ls = [frozenset(i) for i in ll]
>>> ss = set(ls)
>>> ss
set([frozenset([1, 3]), frozenset([1, 2]), frozenset([1, 4]), frozenset([3])])
>>> [list(i) for i in ss]
[[1, 3], [1, 2], [1, 4], [3]]
pgphz7iINDVUi.pgp
Description: PGP signature
--
http:/
If your proposal is implemented, what does this code mean?
if [1,2]+[3,4] != [1,2,3,4]: raise TestFailed, 'list concatenation'
Since it contains ']+[' I assume it must now be parsed as a user-defined
operator, but this code currently has a meaning in Python.
(This code is the first example
On Tue, Nov 22, 2005 at 04:08:41PM -0800, Steve R. Hastings wrote:
> Actually, that's a better syntax than the one I proposed, too:
>
> __+__
> # __add__ # this one's already in use, so not allowed
> __outer*__
Again, this means something already.
>>> __ = 3
>>> __+__
6
>>> __outer = 'x'
>>>
That code works here.
Python2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
It's Windows XP, Pentium 4, unknown amount of RAM. I'm running python.exe in a
console window. It also worked in IDLE.
Jeff
pgptwrbVpG8CR.pgp
Description: PGP signature
--
http://mail.python.or
You can already get a set from a dictionary's keys in an efficient manner:
>>> l = dict.fromkeys(range(10))
>>> set(l)
Set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Jeff
pgplWRjKoPA4t.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
You might benefit some from scgi. From the httpd side, you can either use
"mod_scgi" in the server or "cgi2scgi" if can't install mod_scgi.
cgi2scgi doesn't have all the performance benefit of mod_scgi, but cgi2scgi is
a fairly lightweight "C" program.
http://www.mems-exchange.org/softwa
One reason might be Practicality. The zip() versions handily beat the
listcomp versions on a 10kitem dict. (python2.4)
$ timeit.py -s 'd = dict.fromkeys(range(1))' '[(v, k) for (k, v) in
d.iteritems()]'
100 loops, best of 3: 5.05 msec per loop
$ timeit.py -s 'd = dict.fromkeys(range(1))'
If I understand correctly, you're looking for the socket method
getsockname(), documented at
http://docs.python.org/lib/socket-objects.html
Jeff
pgppauvaXgXhK.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
You can tell by the exit code from system() whether the subprocess
exited due to a signal. Consider this code:
import os
while 1:
print os.system("sleep 1")
unless you happen to hit ctrl-c at the right time, you'll see it print
"2" (and "0" when the sleep finishes). The exit code
What property of the STL stack is important to you?
You can use a Python list as a stack. It has methods append() and
pop() which run in amortized-constant-time. It can be tested for
empty/nonempty in constant time too (if st: # stack is not empty).
Jeff
pgpU1CCrfIPhk.pgp
Description: PGP sig
On Tue, Nov 29, 2005 at 10:41:13AM +, Bengt Richter wrote:
> Seems like str.__mod__ could take an arbitary (BTW, matching length,
> necessarily?
> Or just long enough?) iterable in place of a tuple, just like it can take
> an arbitrary mapping object in place of a dict for e.g. '%(name)s'%
>
"run" is not the name of a Python built-in function. That leaves
everyone but you somewhat in the dark about why it does or does not wait
for the created process to complete.
If you want a function that starts a new process and waits for it to
complete, you probably want to use os.spawnv(os.P_WAI
On Tue, Nov 29, 2005 at 09:48:15AM +0100, David Siroky wrote:
> Hi!
>
> I need to enlighten myself in Python unicode speed and implementation.
>
> My platform is AMD [EMAIL PROTECTED] (x86-32), Debian, Python 2.4.
>
> First a simple example (and time results):
>
> x = "a"*5000
> real0m0
I'm guessing that the expected behavior is
>>> struct.calcsize('idi')
20
because the double should be aligned to an 8-byte boundary.
This is the case on my linux/x86_64 machine:
$ python -c 'import struct; print struct.calcsize("idi")'
20
I don't know much about 'itanium', but i'd b
On this system (Linux 2.6.x, AMD64, 2 GB RAM, python2.4) I am able to
construct a 1 GB string by repetition, as well as compress a 512MB
string with gzip in one gulp.
$ cat claudio.py
s = '1234567890'*(1048576*50)
import zlib
c = zlib.compress(s)
print len(c)
open("/tmp/c
The "urllib2" module is designed for tasks like this. The tutorial
shows how to use urllib2.urlopen() to fetch the contents of a URL
using the http protocol.
Jeff
pgpdV8higv7SR.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
This comes up from time to time. The brain damage is all Windows', not
Python's. Here's one thread which seems to suggest a bizarre doubling
of the initial quote of the commandline.
http://groups.google.com/group/comp.lang.python/browse_frm/thread/89d94656ea393d5b/ef40a65017848671
pgp1T5KPY01o
On Mon, Dec 05, 2005 at 06:27:44AM -0800, Narendra wrote:
> I was able to do that but my e-mail is ending in bulk when i'm trying
> to senf to hotmail/msn.
Perhaps this is an over-zealous filter on the hotmail/msn side, not a
problem with Python.
I don't know for sure, but some news stories indic
Perhaps this project's code or ideas could be of service:
http://freshmeat.net/projects/enca/
Jeff
pgpYyDfS0xrTp.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
First, get the method with getattr() and then use the *-notation or
apply to call it with args.
getattr(obj, func_name)(*args)
or
apply(getattr(obj, func_name), args)
Jeff
pgpm38MC4TzIU.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
> [John Marshall]
> > For strings of > 1 character, what are the chances
> > that hash(st) and hash(st[::-1]) would return the
> > same value?
>
On Mon, Dec 05, 2005 at 09:11:14PM -0500, Tim Peters wrote:
> First, if `st` is a string, `st[::-1]` is a list. Do you really mean
> to compare string h
It means there is a bug in a Python extension or in Python itself.
If you can reproduce the bug by importing only modules written in Python
or included with Python, then you should document the steps to do so in
a bug report in the bug tracker on http://sourceforge.net/python
If you can only rep
Note that you can use the 'uu' encoding, which will handle
arbitrary-length input and give multi-line uuencoded output, including
the 'begin' and 'end' lines:
>>> print ("\377" * 120).encode("uu")
begin 666
M
M
On Fri, Dec 09, 2005 at 06:29:12PM +0100, Johannes Reichel wrote:
> Hi!
>
> In C++ you can overload functions and constructors. For example if I have a
> class that represents a complex number, than it would be nice if I can
> write two seperate constructors
Python doesn't support this, but it do
You'll find that using Python Longs unsuitable if you *change* the
bitmaps---All numeric types are immutable, so you'll copy the bitmap
each time you perform an operation like "set bit".
numarray has a 'bit' typecode, though I'm not sure how such an array is
actually stored---from a quick look, it
def smadi(s):
h, m, s = s.split(":")
h = int(h)
m = int(m)
s = float(s)
return s + m*60 + h * 3600
>>> print smadi("16:23:20.019519")
59000.019519
Jeff
pgpWjc1O3xtLf.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
The only difference is when you want to include " or ' inside the string. If
you want to include the "like" quote, then escape it ("\"", '\''). If you
include the "unlike" quote, no escape is needed ("'" or '"').
I think that people new to programming will use '' if it is unshifted on their
keyb
Without a 'global' statement, all variables which are assigned in the body of a
function are local to that function.
Here is an example showing that f() does not create a module-level variable,
but g() does.
>>> def f():
... z = 3
...
>>> def g():
... global z
... z = 3
...
>>> z
Tr
Depending what you mean, it may be dirt simple:
-- foo.py --
print "bar"
-- end of foo.py --
When a module is first imported, all the statements in it are executed. "def"
statements define functions, and "class" statements define clasess. But you
can have any type of statement you like at the to
1 - 100 of 148 matches
Mail list logo