Hi all,
I'm pretty new to Python (a little over a month). I was wondering -- is
something like this:
s = re.compile('whatever')
def t(whatnot):
return s.search(whatnot)
for i in xrange(1000):
print t(something[i])
significantly faster than something like this:
def t(whatnot):
s =
Thanks for all the answers on this. (And, sorry the lousy Subject line; I
couldn't think of a better one.)
--
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 -- pass it on
--
http://mail.python.org/mailman/listinfo/python-list
Here are a couple of functions that I feel stupid for having written.
They work, and they're pretty straightforward; it's just that I feel like
I must be missing an easier way to do this...
def net_to_int(numstring):
"""Convert a big-endian binary number, in the form of a string of
arbit
On Wed, 26 Dec 2007 16:50:53 -0800, Dennis Lee Bieber wrote:
> your code might (I've not actually checked it) be incorrect if ported
> to another machine.
Nope. :-)
> If the problem is that you have the four bytes as a character string,
> use the struct module to interpret it as a binary integer
Look at this -- from Python 2.5.1:
>>> a = [1, 2, 3, 4, 5]
>>> for x in a:
... if x == 3:
... a.remove(x)
... print x
...
1
2
3
5
>>> a
[1, 2, 4, 5]
>>>
Sure, the resulting list is correct. But 4 is never printed during the
loop!
What I was really trying to do was this:
apps =
On Wed, 30 Jan 2008 06:07:45 -0800, cokofreedom wrote:
> Anyone else noticed that the OP has not actually replied to any of the
> suggestions...
Sorry. I was just fascinated at the turns it was taking. But the first
answer was fine for me:
for name in apps[:]:
etc.
Thanks all.
--
09 F9 11
This is proving to be a recurring problem for me.
First, I used the save() method of a Python Imaging Library "Image"
object to write directly to the "wfile" of a BaseHTTPRequestHandler-
derived class:
pic.save(self.wfile, 'JPEG')
Worked great in Linux, barfed in Windows. I had to do this
On Fri, 05 Dec 2008 12:16:47 -0800, Fernando H. Sanches wrote:
> I agree that the tab/space thing should be changed. Would it be too hard
> to make the parser see if the indentation is consistent in the whole
> file?
*Something* has changed. I had a piece of code where, without realizing
it, I h
On Sat, 24 May 2008 13:12:13 +0200, Johannes Bauer wrote:
> char *tmp;
> tmp = fgets(buf, sizeof(buf), f);
> while (tmp) {
> printf("%s\n", buf);
> tmp = fgets(buf, sizeof(buf), f);
> }
I think a more Pythonic way to write this, in general, would be:
while (1) {
char *tmp = fgets
So, basically what I'm doing is this:
window1 = Tkinter.Tk()
...
window1.destroy()
...
window2 = Tkinter.Tk()
This works well in Linux and Mac OS X (and the PyGtk equivalent works on
all platforms), but in Windows XP, the second window comes up without
focus. (I have to click on it to focus it.
On Wed, 11 Jun 2008 12:25:29 -0700, geoffbache wrote:
> (1) py2exe. This is really for when python isn't installed on the remote
> user's machine, so it requires you to distribute a large amount of DLLs
> etc which are part of the python installation. A bit silly when I know
> that the remote user
On Fri, 13 Jun 2008 21:59:06 +0530, srinivasan srinivas wrote:
> I am going to do some socket related programming in Python. Before that,
> I wish to know the Gotchas of Python Scoket Programming.
The only gotcha I see is that you won't want to go back to doing it in C.
--
09 F9 11 02 9D 74 E3
On Sun, 22 Jun 2008 08:44:25 -0500, Saul Spatz wrote:
> macoovacany wrote:
>> http://macoovacany.wordpress.com/
> When I tried to run it, I got all kinds of syntax errors because of
> non-ASCII characters; namely, you have fancy left and right single and
> double quotes.
That's probably WordPress
On Wed, 25 Jun 2008 16:02:52 -0700, John Machin wrote:
> Here's one approach (requires Python 2.5 or later):
> [(50 if x < 50 else x, 50 if y < 50 else y, 50 if z < 50 else z) for
> (x, y, z) in source]
[(max(x, 50), max(y, 50), max(z, 50)) for (x, y, z) in source]
--
09 F9 11 02 9D 74 E3 5B D8
On Fri, 04 Jul 2008 16:19:34 +0100, Tim Rowe wrote:
> pythonw.exe (that's the windows executable, right?)
python.exe and pythonw.exe are both Windows executables. There are no non-
Windows executables in a Python for Windows package.
python.exe is used for console apps or interactive sessions.
On Sun, 13 Jul 2008 00:58:59 +0200, Python.Arno wrote:
> http://undefined.org/python/py2app.html
py2app bundles Python itself into the app, right? I wonder, is there no
way to create an app bundle that relies on the existing installation of
Python, since OS X already comes with Python? I have a
On Mon, 28 Jul 2008 19:51:26 +0200, Tommy Nordgren wrote:
> There is Platypus, a general open source program to wrap a script
> in an Macintosh (GUI) Application.
Thanks. I tried Platypus, and it's close to what I want. But I still
can't seem to get rid of the small "Console" window that pops up
On Sun, 27 Jul 2008 20:31:07 +0200, Martin v. Löwis wrote:
> Originally, AMD called it x86-64, and later renamed it to AMD64. Intel
> originally implemented it under the name EM64T (for Extended Memory 64
> Technology), and now calls the architecture Intel 64.
I hadn't heard "Intel 64" before. Th
On Mon, 28 Jul 2008 21:09:10 +0200, Tommy Nordgren wrote:
> Try setting the Output popup menu to 'None'
That was the first thing I did.
--
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 -- pass it on
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 28 Jul 2008 15:18:43 -0400, Kevin Walzer wrote:
> Add this call to your Python script somewhere (modify as needed):
>
> try:
> self.tk.call('console', 'hide')
> except TclError:
> pass
Ah, yes! Thanks.
--
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56
On Tue, 29 Jul 2008 12:24:49 -0700, Russell E. Owen wrote:
> That is exactly what py2app does by default if you run py2app with the
> system python.
Thanks. I see that it* avoids the issue with Tk starting in the
background that I get with Platypus, too.
In fact, it looks like the bundlebuilder
On Wed, 30 Jul 2008 16:57:35 +, I wrote:
> [bundlebuidler] does put in a version-specific #! line, but if I change
> that to #!/usr/bin/env python, the app still works, and it seems to me
> that it will work for any version of Python on OS 10.4, 10.5, and maybe
> 10.3.
Then again, I see now t
On Wed, 01 Oct 2008 17:56:34 +0200, Boris Borcic wrote:
> 42, for instance.
>
> Proof :
>
> >>> 42 is not object
> True
>
> QED
>>> isinstance(42, object)
True
--
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 -- pass it on
--
http://mail.python.org/mailman/listinfo/python-list
23 matches
Mail list logo