[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
why would binding to a function-local name speeds up performance?
Like any other constant-hoisting, pulling the lookup out of the loop
speeds things up because otherwise Python must repeat the lookup each
time through the loop (Python doesn't _know_
Larry Bates [EMAIL PROTECTED] wrote:
recently learned that you can ship COM as either an .EXE or a .DLL (nobody
has yet let me know why).
The why is pretty obvious -- you may want to be able to instantiate a
COM object either in-process, or in its own separate process, depending
on that
lancered [EMAIL PROTECTED] wrote:
Hi Dear all,
I have some data here in the form of a dictionary, called vdic. Then
I write them to a data file f using the write function as
f.write(str(vdic)). The keys of this dictionary are integers and
values are float numbers. Something like this:
Steve Holden [EMAIL PROTECTED] wrote:
...
livibetter has a better solution. the reason is that you need to
create a new list object everytime, am I right?
Yes, specifically on every *call*.
...and livibetter's solution also creates a new list on every call to
Child (that [] passed on
edfialk [EMAIL PROTECTED] wrote:
Hi, does anyone happen to know of a script that would return the
number of seconds in a month if I give it a month and a year?
My python is a little weak, but if anyone could offer some suggestions
I think I could handle it myself, or if anyone happens to
Paul Boddie [EMAIL PROTECTED] wrote:
Now I hear that the word with is being discussed for a different
purpose in Py 3 as a result of a PEP and I don't want to conflict with
that.
The with keyword appears in 2.5 onwards.
...but needs a from __future__ import with_statement in 2.5 itself.
dgdev [EMAIL PROTECTED] wrote:
I would like to pickle an extension type (written in pyrex). I have
it working thus far by defining three methods:
class C:
# for pickling
__getstate__(self):
... # make 'state_obj'
return state_obj
DanielJohnson [EMAIL PROTECTED] wrote:
how to use the combination function in python ?
For example 9 choose 2 (written as 9C2) = 9!/7!*2!=36
Please help, I couldnt find the function through help.
If you download and install gmpy, it's easy:
import gmpy
gmpy.comb(9,2)
mpz(36)
However,
Tina I [EMAIL PROTECTED] wrote:
...
He he... at the age of 40 I'm well beyond school work ;)
Why would that be? My wife's over 40, yet she's a student (currently at
Stanford -- they were overjoyed to admit her, with lot of life
experience as well as previous studies, apparently). She's not
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
You could take it up with the gmpy author and
induce him to get gmpy included in the standard distro if you are so
inclined.
Alex Martelli knows more about that subject than I and
it would be pointless for me to bug him about it.
gmpy is LGPL
Gabriel Genellina [EMAIL PROTECTED] wrote:
En Thu, 12 Apr 2007 10:56:32 -0300, Marcpp [EMAIL PROTECTED] escribió:
On 12 abr, 09:41, Hugo González Monteverde [EMAIL PROTECTED] wrote:
Leí este mail viejísimo en una lista. Yo uso Python y también quería
saber quién pythoneaba en México.
Isaac Rodriguez [EMAIL PROTECTED] wrote:
The fact that I had
to resort to this trick is a big indication of course that genuinely
private members (as opposed to a 'keep off' naming convention) are a bad
idea in general.
The fact that you had to resort to this trick is a big indication
7stud [EMAIL PROTECTED] wrote:
1) Even though the download at sourceforge said the file name was:
pyparsing-1.4.6.tar.gz
it was downloaded to my Desktop as:
pyparsing-1.4.6.tar
Did os x 10.4.7 automatically unzip it for me? .gz means the file was
compressed with gzip, but I didn't
Maxim Veksler [EMAIL PROTECTED] wrote:
...
Thank you. I'm attaching the full code so far for reference, sadly it
still doesn't work. It seems that select.select gets it's count of
fd's not from the amount passed to it by the sub_list but from the
kernel (or whatever) count for the process;
faulkner [EMAIL PROTECTED] wrote:
...
__future__ is used to access upcoming features, and changing the base
offset is not [and never will be] slated for future development. zero
has been used as the base offset in all real languages since the dawn
of time, and isn't something that can be
Sherm Pendley [EMAIL PROTECTED] wrote:
Paddy [EMAIL PROTECTED] writes:
I don't think we should add it to Python
because it would make porting VB code easier.
Great Cthulhu no!
I chimed in because your first comment regarding Perl implied that it's
commonplace for Perl programmers to
Dennis Lee Bieber [EMAIL PROTECTED] wrote:
...
In Python, the variable NAME does NOT define storage; unlike most
other classical languages where the variable name is a storage
address, and the value of the RHS is COPIED to that address. Python does
not do such copying. Names are
Mike [EMAIL PROTECTED] wrote:
...
Why is r not being reset to the empty list on subsequent calls? It
seems like it should be reinitialized when not explicitly provided.
http://www.python.org/doc/faq/general/#why-are-default-values-shared-be
tween-objects
Alex
--
Steven D'Aprano [EMAIL PROTECTED] wrote:
On Sat, 14 Apr 2007 20:34:46 -0700, Dan Bishop wrote:
On Apr 14, 10:55 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
The FORTRAN family had started as 1-based (F95, and Ada, now allow
for each array to have its own base = x : array
Steven D'Aprano [EMAIL PROTECTED] wrote:
On Sun, 15 Apr 2007 05:29:01 +0200, BJörn Lindqvist wrote:
This comes up so often that I wonder whether Python should issue a warning
when it sees [] or {} as a default argument.
What do people think? A misuse or good use of warnings?
I
7stud [EMAIL PROTECTED] wrote:
It sure looks like t changed, and therefore t is NOT immutable--and
the whole tuples are immutable mantra is a lie. However, the list
http://mail.python.org/pipermail/python-list/2002-April/140258.html
So, the statue that points to Hotel Belfiore had suddenly
[EMAIL PROTECTED] wrote:
Hi,
I have a list of url names like this, and I am trying to strip out the
domain name using the following code:
http://www.cnn.com
www.yahoo.com
http://www.ebay.co.uk
pattern = re.compile(http:(.*)\.(.*), re.S)
match = re.findall(pattern, line)
if
On Apr 12, 2007, at 1:17 PM, Maxim Veksler wrote:
...
Now, someone I work with suggested a simple work around Pass the list
objects in groups of 1024 each time to the select.select structure. I
think it's acceptable and good advice, the thing is I don't know how
to implement this the
wswilson [EMAIL PROTECTED] wrote:
Here is my code:
class A():
val = 0
def b(item, a):
a.val = a.val + 1
return item + a.val
def c():
d = [1, 2, 3]
print [b(item, A()) for item in d]
c()
I expected this to output [2, 4, 6]. However, it outputs [2,
[EMAIL PROTECTED] wrote:
...
somebody points me to a web page/reference that says how to call a
function then reclaim the whole memory back in python.
Meanwhile, the best that I could do is fork a process, compute the
results, and return them back to the parent process. This I
That's my
Gregory Piñero [EMAIL PROTECTED] wrote:
I'm curious why this code isn't working how I expect it to:
import sys
d=3
def func1(a,b,c):
print a,b,c,d
print sys.path
exec func1(1,2,3) in {'func1':func1}
returns:
1 2 3 3
[ sys.path stuff ]
Since I'm telling exec
Peter Otten [EMAIL PROTECTED] wrote:
Alex Martelli wrote:
BTW, if you DO want to call shelve.open on a path f that may correspond
to an arbitrary existing file (and want to toss away the previous
contents of that file, if any) the correct way to call is then:
s = shelve.open
[EMAIL PROTECTED] wrote:
...
Also: can someone enlighten me as to when code in class scope is run,
exactly?
It's run as a part of the execution of the class statement.
if a class A has a metaclass M, then M.__init__ does not seem to get
the code in A's class scope in its arguments
Adam Atlas [EMAIL PROTECTED] wrote:
Hasn't this been discussed many many times before? I think Guido has
been favourable to the idea of allowing :=, but that was a long time
ago, and I don't think anything ever came of it.
Personally, if anything, I'd like to see more use of the 'as'
Maxim Veksler [EMAIL PROTECTED] wrote:
ValueError: filedescriptor out of range in select()
Should I be using a different version of select or something? Or
select typically supports 1024 FDs at most (a design limit of the
underlying operating system). You may want to try poll instead
Dustan [EMAIL PROTECTED] wrote:
class Wrapper(object):
def __init__(self, obj):
self.obj = obj
def getit(self):
return self.obj
def setit(self, obj):
self.obj = obj
return obj
Yeah, that's substantialy the same
Ayaz Ahmed Khan [EMAIL PROTECTED] wrote:
...
I am getting varying results on my system on repeated runs. What about
itertools.ifilter()?
Calling itertools.ifilter returns an iterator; if you never iterate on
that iterator, that, of course, is going to be very fast (O(1), since it
does not
Lorenzo [EMAIL PROTECTED] wrote:
...
elapsedTime = mydata[1]
index = elapsedTime.find(real)
# the index will have a value 0f 110
totaltime = elapsedTime[index:]
...
Oops! I sent the wrong piece of code. The above is actually the work
around which actually works. The bad
7stud [EMAIL PROTECTED] wrote:
On Apr 4, 10:22 pm, [EMAIL PROTECTED] wrote:
how did you generate aaa.txt?
Ok, I got it to work by supplying a filename that didn't previously
exist. Neither the book I am reading, Beginning Python: From Novice
to Professional nor the book I am using as a
7stud [EMAIL PROTECTED] wrote:
...
In my opinion, the most valuable thing you could do for a next
printing would be to expand the index to 3 times its current length.
Suggest that to O'Reilly: they're the one who prepare the index, not me;
I only get to point out errors I may notice on it
Neal Becker [EMAIL PROTECTED] wrote:
...
i = 5
for my i in xrange(4):
if i: # skips first when i is 0
my i = 100
if i:
print i # of course 100
break
print i # i is between 0 3 here
print i # i is 5 here
Steve Holden [EMAIL PROTECTED] wrote:
What do you think the chances are of this being accepted for Python 3.0?
It is indeed about the most rational approach, though of course it does
cause problems with dynamic namespaces.
What problems do you have in mind? The compiler already determines
Paul Rubin http://[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] (Alex Martelli) writes:
Thus the following example does not compile:
class Test {
public static void main(String[] args) {
int i;
for (int i = 0; i 10; i++)
I'm ok
Paul Rubin http://[EMAIL PROTECTED] wrote:
I just had to write some programs that crunched a lot of large files,
both text and binary. As I use iterators more I find myself wishing
for some maybe-obvious enhancements:
1. File iterator for blocks of chars:
f = open('foo')
Aahz [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Alex Martelli [EMAIL PROTECTED] wrote:
Steve Holden [EMAIL PROTECTED] wrote:
What do you think the chances are of this being accepted for Python 3.0?
It is indeed about the most rational approach, though of course it does
Paul Rubin http://[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] (Alex Martelli) writes:
exec?
option 1: that just runs the compiler a bit later ...
Besides exec, there's also locals(), i.e.
locals['x'] = 5
can shadow a variable. Any bad results are probably deserved ;)
locals['x']=5
John Nagle [EMAIL PROTECTED] wrote:
systems that didn't work that way, in which the program source was
manipulated within the language environment, in a more structured
fashion. Smalltalk, LISP, and (wierdly) Forth environments have been
built that way. But it never really caught on.
APL
Amit Khemka [EMAIL PROTECTED] wrote:
On 3 Apr 2007 11:20:33 -0700, bahoo [EMAIL PROTECTED] wrote:
Hi,
I have a list like ['0024', 'haha', '0024']
and as output I want ['haha']
If I
myList.remove('0024')
then only the first instance of '0024' is removed.
To remove all items
Ben Finney [EMAIL PROTECTED] wrote:
ts-dev [EMAIL PROTECTED] writes:
Is it possible to prevent modification of a python file once its been
deployed?
Prevent modification by whom?
You can't prevent modification by the person who owns the
machine. It's in their possession, and
alf [EMAIL PROTECTED] wrote:
Hi,
I want to add some library but it can not be comipled? Here is an output:
If you don't have the needed compiler installed (in this case, VS 2003,
while it looks like your installation has VS 2005 instead), sure.
D:\cl
Microsoft (R) 32-bit C/C++ Optimizing
Gabriel Genellina [EMAIL PROTECTED] wrote:
En Tue, 03 Apr 2007 12:40:23 -0300, Jim Aikin [EMAIL PROTECTED]
escribió:
The Tutorial is very good, but there are numerous topics that it slides
past
(as it would have to do, in order to avoid being ten times as long). I
haven't yet gotten
Steven Bethard [EMAIL PROTECTED] wrote:
Alex Martelli wrote:
If we had a turn sequence into bag function somewhere
(and it might be worth having it for other reasons):
def bagit(seq):
import collections
d = collections.defaultdict(int)
for x in seq: d[x] += 1
[EMAIL PROTECTED] wrote:
This sounds suspiciously like a homework assignment.
I don't think you'll get much help for this one, unless
you show some code you wrote yourself already with a specific
question about problems you're having
Well you have some right. I will make it more
Harold Fellermann [EMAIL PROTECTED] wrote:
...
Within my program, I am importing a module via
__import__(module_name,globals(),locals())
The globals() you're passing are those of the *importing* module, and
have no effect on those of the *imported* module.
and I want to pass comand line
Steven Bethard [EMAIL PROTECTED] wrote:
Thomas Krüger wrote:
Alex Martelli schrieb:
Thomas Krüger [EMAIL PROTECTED] wrote:
def sorter(a, b):
return cmp(a.id, b.id)
obj_lst.sort(sorter)
A MUCH better way to obtain exactly the same semantics would be:
def getid
7stud [EMAIL PROTECTED] wrote:
...
I'm using python 2.3.5.
On Mar 29, 9:34 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
Simplest way:
class smethod(object):
def __init__(self, f): self.f=f
def __call__(self, *a, **k): return self.f(*a, **k)
Alex
Interesting. That looks
asdf1234234 [EMAIL PROTECTED] wrote:
My code is:
-a.py-
import b
class A:
def __init__(self):
pass
Incidentally, these last two lines are totally, utterly useless. Do NOT
define special methods like this -- just omit the whole def statement
and you'll have identical
Thomas Krüger [EMAIL PROTECTED] wrote:
Rehceb Rotkiv schrieb:
can I sort a multidimensional array in Python by multiple sort keys? A
litte code sample would be nice!
You can pass a function as argument to the sort method of a list.
The function should take two arguments and return -1, 0
Thomas Krüger [EMAIL PROTECTED] wrote:
BTW: having one way to do it is one of the main ideas of Python's
philosophy.
Yes, just like C's -- see point 4 in the Spirit of C summary taken
from the ISO Standard for C and quoted e.g. at
http://www.artima.com/cppsource/spiritofc.html . Of course,
Steven D'Aprano [EMAIL PROTECTED] wrote:
...
In general:
- use a list comprehension when you need to calculate the list items
- use slicing when you are copying an actual list, or if you don't care
what type of object you get
- use the list() function when your existing object might
[EMAIL PROTECTED] wrote:
...
under what circumstances do we need to create a copy of a tuple :-
btuple = atuple[:]. tuples are immutable, so wouldn't it be wasting
memory?
Nah -- btuple is atuple. The copy is a no-op, in this case.
another query, in the docs, list(a) and a[:] does the
Ben Finney [EMAIL PROTECTED] wrote:
...
That's not the only case though. What do you expect to be returned for
an input of [eggs, beans, beans, eggs, spam] ?
Assuming you want *a* mode value, and any one will do (e.g. any of
spam, eggs or beans is okay), I'd write it this way as a first
Martin Manns [EMAIL PROTECTED] wrote:
Hi,
I am experiencing some trouble with gmpy v1.01.
Multiplying an mpq with inf results in a floating point exception that
exits python. Has this already been fixed in newer gmpy versions?
No, I can reproduce the problem (on a Mac with an Intel CPU)
ken [EMAIL PROTECTED] wrote:
Can you please tell me what is the timeout value of httplib.HTTP?
i.e. how long python will wait for a response in the below code?
h = httplib.HTTP(self.url, 8080)
h.putrequest('GET', '/sample/?url=' + self.url)
h.endheaders()
HTTP per se
Joshua J. Kugler [EMAIL PROTECTED] wrote:
still be nicely portable. It just seems that since Python is gathering
that information anyway, it should make it available without me having to
walk the directory tree.
Sorry, where is Python gathering that information anyway? Unless I'm
mistaken,
7stud [EMAIL PROTECTED] wrote:
Hi,
Can someone show me how to manually implement staticmethod()? Here is
Simplest way:
class smethod(object):
def __init__(self, f): self.f=f
def __call__(self, *a, **k): return self.f(*a, **k)
Alex
--
Joshua J. Kugler [EMAIL PROTECTED] wrote:
On Thursday 29 March 2007 07:33, Alex Martelli wrote:
Joshua J. Kugler [EMAIL PROTECTED] wrote:
still be nicely portable. It just seems that since Python is gathering
that information anyway, it should make it available without me having
Paddy [EMAIL PROTECTED] wrote:
...
A bit more directly:
foo = [spam, eggs, spam, spam, spam, beans, eggs]
max(foo, key=foo.count)
'spam'
Alex
This doesn't call foo.count for duplicate entries by keeping a cache
foo = [spam, eggs, spam, spam, spam, beans, eggs]
def
Russ [EMAIL PROTECTED] wrote:
This little squabble got me thinking. I normally just use the
myDict={} method of clearing a
dictionary when I know there are no other references to it. However, I
wonder how the
efficiency of relying on the garbage collector to clear a dictionary
compares with
glomde [EMAIL PROTECTED] wrote:
Hi,
I tried to write a decorator for that should be for methods but for
some reasons
it doens seem to work when you try to do it on the __getattr__ method
in a class.
Could anybody give some hints why this is?
...
a.test # This doesnt call the __get__ !!!
[EMAIL PROTECTED] wrote:
...
class Outer:
class Inner:
printOnce = True
def __init__(self):
if Outer.Inner.printOnce:
print 'Printing once.'
Outer.Inner.printOnce = False
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
...
So I'ld suggest to start with downloading the Enthought edition of Python,
and you can judge for yourself within 10 minutes,
if it's fast enough.
cheers,
Stef Mientki
Is there a mac version??
Cameron Laird [EMAIL PROTECTED] wrote:
...
If you're just trying to learn and check things out, it might be better
to get a more recent Python from python.org (2.5 or 2.4.4) and the
various other packages as and when you need them (you can use the
MacEnthon list as a guide:-). You'll need
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I've been told that Both Fortran and Python are easy to read, and are
quite useful in creating scientific apps for the number crunching, but
Incidentally, and a bit outside what you asked: if your number
crunching involves anything beyond linear
Aahz [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
David Abrahams [EMAIL PROTECTED] wrote:
I was under the impression that both the current directory *and* the
python library directory were already, automatically, in sys.path, so
I'm really surprised to see this. Am I doing
7stud [EMAIL PROTECTED] wrote:
On Mar 24, 9:40 pm, 7stud [EMAIL PROTECTED] wrote:
On Mar 24, 8:18 pm, Michael Bentley [EMAIL PROTECTED] wrote:
On Mar 24, 2007, at 12:30 PM, Robert Hicks wrote:
I want to upgrade to 2.5 but I don't see any unistall instructions
anywhere.
[EMAIL PROTECTED] wrote:
Is there any possible way that I can place a .py file on the internet,
and use that source code in an .py file on my computer?
You can write an import hook in any way you like; see
http://www.python.org/dev/peps/pep-0302/ .
Here's a trivial example (bereft of much
Hendrik van Rooyen [EMAIL PROTECTED] wrote:
Steven D'Aprano [EMAIL PROTECTED] wrote:
On Fri, 23 Mar 2007 13:15:29 -0700, John Machin wrote:
OK, I'll bite: This was new in late 2000 when Python 2.0 was
released. Where have you been in the last ~6.5 years?
Western civilization
Thomas Dybdahl Ahle [EMAIL PROTECTED] wrote:
Hi, I have a function, which looks like the following:
connecting = False
def func ():
global connecting
connecting = True
try:
# Do lot of network stuff
except Exception, e:
connecting = False
raise e
Mark [EMAIL PROTECTED] wrote:
...
so I could just do a python_compile_and_run myscript.py and it would
do what I want, i.e. run myscript.pyc if available and valid, generate
and run it if necessary.
You can use
python -c 'import myscript; myscript.main()'
and variations thereon.
Alex
--
Tom Wright [EMAIL PROTECTED] wrote:
real programs. I can't help thinking that there are some situations where
you need a lot of memory for a short time though, and it would be nice to
be able to use it briefly and then hand most of it back. Still, I see the
practical difficulties with doing
Steve Holden [EMAIL PROTECTED] wrote:
...
a. fork
b. do the memory-hogging work in the child process
c. meanwhile the parent just waits
d. the child sends back to the parent the small results
e. the child terminates
f. the parent proceeds merrily
I learned this
Alan Isaac [EMAIL PROTECTED] wrote:
Essentially I want a generator that I can query about
its characteristics. (E.g., a random number generator
that I want to be able to ask about is distributional
parameters.)
I am thinking of a class that wraps a generator.
An object of this class will
John Nagle [EMAIL PROTECTED] wrote:
Marcin Ciura wrote:
Neither would I. I must have expressed myself not clearly enough.
Currently
x = y = z
is roughly equivalent to
x = z
y = z
I propose to change it to
y = z
x = z
Actually, it is equivalent to
y = z
x =
Paddy [EMAIL PROTECTED] wrote:
...
I have found that I have gone too far when I used listcomps for their
sideeffects rather than wanting the list produced, for example the
I agree.
second listcomp below is an expression as statement I don't want the
list produced - just the effect on
Aahz [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Alex Martelli [EMAIL PROTECTED] wrote:
list(iterimage(etc etc))
is surely a better way to express identical semantics. More generally,
[x for x in whatever] (whether x is a single name or gets peculiarly
unpacked and repacked
Aahz [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Alex Martelli [EMAIL PROTECTED] wrote:
Steve Holden [EMAIL PROTECTED] wrote:
basestring is a *type*.
basestring
type 'basestring'
It's the base class of which both str and unicode are subclasses.
I believe
Laurent Pointal [EMAIL PROTECTED] wrote:
billiejoex a écrit :
Hi,
I'm writing a small asyncore-based server application serving a lot of
clients. When I have to handle more than 1021 client simoultaneously
the 'binded' socket object raises an error:
[...]
connections: 1018
Steven D'Aprano [EMAIL PROTECTED] wrote:
...
There are plenty of reasons for preferring new style classes. If those
reasons hold for you, then of course you should use new style classes.
But that's not the same thing as saying that you should use new style
classes *even when you don't
Gabriel Genellina [EMAIL PROTECTED] wrote:
...
example i could load Person from Person (in alpha) as, Person_Alpha
or something like that in sys.modules? not sure how I might do that.
Use the as clause when importing; it's almost the same phrase you wrote
above:
from alpha.Person
Jonathan Fine [EMAIL PROTECTED] wrote:
...
In other words, I'm asking for a python24 package that
contains all (or most) of the modules that are new to
Python 2.4.
For subprocess specifically, see
http://www.lysator.liu.se/~astrand/popen5/ . I don't think anybody's
ever packaged up ALL the
John Nagle [EMAIL PROTECTED] wrote:
...
Are you looking at p. 109 of the 2nd edition of the Nutshell?
No, I'm looking at the original edition from 2003. That
was what Borders had in stock late last year.
Eeek -- the 2nd edition came out in July 2006, and several months later
7stud [EMAIL PROTECTED] wrote:
Here is some example code:
d = {a:hello, b:[1, 2, 3]}
x = d.copy()
d[b][0]=10
print x
output:
{'a': 'hello', 'b': [10, 2, 3]}
It looks like the key names of a dictionary store pointers to the
values? Or does a dictionary object manage pointers to
Ben [EMAIL PROTECTED] wrote:
I have recently learned how list comprehension works and am finding it
extremely cool. I am worried, however, that I may be stuffing it into
places that it does not belong.
What's the most pythony way to do this:
even = []
for x in range(0,width,2):
HMS Surprise [EMAIL PROTECTED] wrote:
...
Why is apply deprecated?
Because it does exacly the same job as just calling the function with
*a/**k, and there should preferably be only one obvious way to perform a
given task (this guiding principle leads to simplicity in the language,
and is
John Nagle [EMAIL PROTECTED] wrote:
...
The real problem is the published books on Python:
Learning Python, by Lutz and Ascher:
str(string) -- returns the string representation of any object.
Python in a Nutshell, by Martelli
Doesn't really address the issue, but says that
BJörn Lindqvist [EMAIL PROTECTED] wrote:
...
even2 = [(pos, col) for pos, col in iterimage(im, width, height, 2)]
list(iterimage(etc etc))
is surely a better way to express identical semantics. More generally,
[x for x in whatever] (whether x is a single name or gets peculiarly
unpacked and
Steve Holden [EMAIL PROTECTED] wrote:
greg wrote:
Paulo da Silva wrote:
As a relatively inexperient
in python, how could I know that a 'string' is an instance of
basestring?
isinstance(x, basestring)
This works because basestring is defined as the
tuple (str, unicode) and
Gabriel Genellina [EMAIL PROTECTED] wrote:
...
As far as it goes, yes. More generally, with any iterable x, the *x
construct in function call will pass as positional arguments exactly
those items which (e.g.) would be printed by the loop:
for item in x: print x
[[this applies
George Sakkis [EMAIL PROTECTED] wrote:
On Mar 18, 12:11 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hi
I need to process a really huge text file (4GB) and this is what i
need to do. It takes for ever to complete this. I read some where that
list comprehension can fast up things. Can
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
...
files (you see huge is really relative ;-)) on 2-4GB RAM boxes and
setting a big buffer (1GB or more) reduces the wall time by 30 to 50%
compared to the default value. BerkeleyDB should have a buffering
Out of curiosity, what OS and FS
7stud [EMAIL PROTECTED] wrote:
...
But the last part of the passage makes no sense to me:
--
When the method object is called with an argument list, it is unpacked
again, a new argument list is constructed from the instance object and
the original argument list, and the function object
[EMAIL PROTECTED] wrote:
If I build a strict with:
import struct
print struck.pack ('i', 1)
it returns a '\n'.
What's wrong with it???
:(
You're trying to print a binary string that's hardly printable as-is.
Try printing its repr(...) and you'll see all the binary zeros and one
you
7stud [EMAIL PROTECTED] wrote:
On Mar 18, 2:23 am, Paul Rubin http://[EMAIL PROTECTED] wrote:
Steve Holden [EMAIL PROTECTED] writes:
max(i for i,t in enumerate(x) if t = y)
Those are actually pretty direct.
How about a solution (like the bisect one suggested almost as soon as
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
On 3/18/07, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
In [EMAIL PROTECTED], Daniel Nogradi
wrote:
f = open('file.txt','r')
for line in f:
db[line.split(' ')[0]] = line.split(' ')[-1]
db.sync()
What is db
301 - 400 of 1652 matches
Mail list logo