I also believe this is a bug.
Here's an even shorter demonstration of the behavior:
>>> u"\\".encode("unicode_escape").decode("unicode_escape")
Traceback (most recent call last):
File "", line 1, in ?
UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in
position 0: \ at end of str
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
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
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
> [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
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
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
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
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
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
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
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 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
"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 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'%
>
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
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
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
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))'
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
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
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
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'
>>>
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
>>> 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 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
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
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
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")
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
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/
#
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
>
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
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
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
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
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
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 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
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)
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
"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
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
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
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
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
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"
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
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
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:
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'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
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 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
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
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
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
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:
-
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
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
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
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
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,
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
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
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
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
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
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
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
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
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 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,
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
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 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
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:
#
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
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
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
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
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
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
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
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
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
-
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,
> 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
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
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
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
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 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
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
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
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
I generated a ~22-megabyte file with this small Python program:
print "["
for i in xrange(200):
print "'" + str(i) + "', "
print "]"
As the original poster suggested, Python uses at least several hundreds
of megabytes when execfile()ing that source. I had t
The 'code' module contains 'Utilities needed to emulate Python's interactive
interpreter.'. By subclassing code.InteractiveConsole and replacing the
raw_input method with one which reads from a file, I think you can get what you
want.
The example below the classes uses StringIO so that it can be
On Sun, Sep 18, 2005 at 02:15:00PM +1000, Maurice Ling wrote:
> Sorry but what are SEEK_END and SEEK_SET?
Oops, that's what I get for snipping a part of a larger program.
SEEK_SET = 0
SEEK_END = 2
Jeff
pgpC1OTox5VvO.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/pyt
Perhaps you mean to use the function socket.gethostbyname instead.
>>> import socket
>>> socket.gethostbyaddr("www.google.ca")
Traceback (most recent call last):
File "", line 1, in ?
socket.herror: (1, 'Unknown host')
>>> socket.gethostbyname("www.google.ca")
'64.233.167.147'
Jeff
pgpsZ1m3Oc
1 - 100 of 148 matches
Mail list logo