Steven D'Aprano writes:
> Perhaps you are thinking that Python could determine ahead of time
> whether x[1] += y involved a list or a tuple, and not perform the
> finally assignment if x was a tuple. Well, maybe, but such an approach
> (if possible!) is fraught with danger and mysterious errors e
Terry Reedy writes:
> On 2/9/2012 8:23 PM, noydb wrote:
>> So how would you round UP always? Say the number is 3219, so you want
(//100+1)*100
> 3400
Note that that doesn't work for numbers that are already round:
>>> (3300//100+1)*100
3400# 3300 would be correct
I'd go with Chri
Alec Taylor writes:
> The source-code used has been made available:
> http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.h
> http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.c
>
> I plan on wrapping it in a class.
You should get acquainted with the Python/C API, which is the standard
Stefan Behnel writes:
>> which is the standard way of extending Python with high-performance
>> (and/or system-specific) C code.
>
> Well, it's *one* way. Certainly not the easiest way, neither the most
> portable and you'll have a hard time making it the fastest.
I didn't say it was easy, but
Ethan Furman writes:
>> def car(L):
>> return L[0]
>> def cdr(L):
>> return L[1]
>
> IANAL (I am not a Lisper), but shouldn't that be 'return L[1:]' ?
Not for the linked list implementation he presented.
>> def length(L):
>> if not L: return 0
>> return 1 + length(cdr(L))
>
> Ho
Terry writes:
> Future division ("from __future__ import division") works within
> scripts executed by import or execfile(). However, it does not work
> when entered interactively in the interpreter like this:
>
from __future__ import division
a=2/3
Are you referring to the interactive
Billy Mays writes:
> Is there any way to just create a new generator that clears its
> closed` status?
You can define getLines in terms of the readline file method, which does
return new data when it is available.
def getLines(f):
lines = []
while True:
line = f.readline()
Frank Millman writes:
> int(float(x)) does the job, and I am happy with that. I was just
> asking if there were any alternatives.
int(float(s)) will corrupt integers larger than 2**53, should you ever
need them. int(decimal.Decimal(s)) works with numbers of arbitrary
size.
--
http://mail.pytho
Neil Cerutti writes:
> On 2011-07-29, Dennis Lee Bieber wrote:
>> Fine... So normpath it first...
>>
> os.path.normpath(r'C:/windows').split(os.sep)
>> ['C:', 'windows']
That apparently doesn't distinguish between r'C:\windows' and
r'C:windows'. On Windows the first is an absolute pat
Steven D'Aprano writes:
> I've never seen this second form in actual code. Does anyone use it,
> and if so, what use-cases do you have?
Since APIs that signal end-of-iteration by returning a sentinel have
fallen out of favor in Python (with good reason), this form is rare, but
still it's sometim
Dave Abrahams writes:
list(chain( *(((x,n) for n in range(3)) for x in 'abc') ))
> [('c', 0), ('c', 1), ('c', 2), ('c', 0), ('c', 1), ('c', 2), ('c', 0), ('c',
> 1), ('c', 2)]
>
> Huh? Can anyone explain why the last result is different?
list(chain(*EXPR)) is constructing a tuple out of
Steven D'Aprano writes:
> "Python's data model is different from other languages"
>
> which is perfectly correct, if you think of C as "other languages". But
> it's equally correct to say that Python's data model is the same as other
> languages. As I understand it, Python and Ruby have the sam
candide writes:
> But beside this, how to recognise classes whose object doesn't have a
> __dict__ attribute ?
str, list and others aren't classes, they are types. While all
(new-style) classes are types, not all types are classes. It's
instances of classes (types created by executing the "cla
candide writes:
> Le 28/10/2011 00:57, Hrvoje Niksic a écrit :
>
>> was used at class definition time to suppress it. Built-in and
>> extension types can choose whether to implement __dict__.
>>
>
> Is it possible in the CPython implementation to write something
Ben Finney writes:
> Tim Chase writes:
>
>> On 11/03/11 16:36, Terry Reedy wrote:
>> > CPython iterates (and prints) dict items in their arbitrary internal
>> > hash table order, which depends on the number and entry order of the
>> > items. It is a bug to depend on that arbitrary order in any w
Andrew writes:
> How to do you create a server that accepts a set of user code?
[...]
Look up the "exec" statement, the server can use it to execute any code
received from the client as a string.
Note "any code", though; exec runs in no sandbox and if a malicious
client defines addition(1, 2) t
Chris Rebert writes:
> C does not have a built-in fixed-point datatype, so the `struct`
> module doesn't handle fixed-point numbers directly.
The built-in decimal module supports fixed-point arithmetic, but the
struct module doesn't know about it. A bug report (or patch) by someone
who works wi
Chris Angelico writes:
>> The hash can grow with (k,v) pairs accumulated in the run time.
>> An auto memory management mechanism is required for a hash of a non-fixed
>> size of (k,v) pairs.
>
> That's a hash table
In many contexts "hash table" is shortened to "hash" when there is no
ambiguity.
Terry Reedy writes:
>> [Hashing is] pretty much mandated because of the __hash__ protocol.
>
> Lib Ref 4.8. Mapping Types — dict
> "A mapping object maps hashable values to arbitrary objects."
>
> This does not say that the mapping has to *use* the hash value ;-).
> Even if it does, it could use
Chris Angelico writes:
> 2011/12/5 Hrvoje Niksic :
>> If a Python implementation tried to implement dict as a tree,
>> instances of classes that define only __eq__ and __hash__ would not
>> be correctly inserted in such a dict.
>
> Couldn't you just make a t
Tim Chase writes:
> From an interface perspective, I suppose it would work. However one
> of the main computer-science reasons for addressing by a hash is to
> get O(1) access to items (modulo pessimal hash structures/algorithms
> which can approach O(N) if everything hashes to the same
> value/
Steven D'Aprano writes:
> Except for people who needed dicts with tens of millions of items.
Huge tree-based dicts would be somewhat slower than today's hash-based
dicts, but they would be far from unusable. Trees are often used to
organize large datasets for quick access.
The case of dicts wh
Neal Becker writes:
> python has builtin zip, but not unzip
>
> A bit of googling found my answer for my decorate/sort/undecorate problem:
>
> a, b = zip (*sorted ((c,d) for c,d in zip (x,y)))
>
> That zip (*sorted...
>
> does the unzipping.
>
> But it's less than intuitively obvious.
>
> I'm thi
Dave Angel writes:
> I do something similar when there's a portion of code that should
> never be reached:
>
> assert("reason why I cannot get here")
Shouldn't that be assert False, "reason why I cannot get here"?
--
http://mail.python.org/mailman/listinfo/python-list
Douglas Alan <[EMAIL PROTECTED]> writes:
> I think you overstate your case. Lispers understand iteration
> interfaces perfectly well, but tend to prefer mapping fuctions to
> iteration because mapping functions are both easier to code (they
> are basically equivalent to coding generators) and eff
James Alan Farrell <[EMAIL PROTECTED]> writes:
> Hello,
> I recently installed new anti-virus software and was surprised the
> next time I brought up IDLE, that it was accessing the internet.
>
> I dislike software accessing the internet without telling me about it,
> especially because of my slow
Douglas Alan <[EMAIL PROTECTED]> writes:
>>> The downside is that they are not quite as flexible as iterators
>>> (which can be hard to code) and generators, which are slow.
>
>> Why do you think generators are any slower than hand-coded iterators?
>
> Generators aren't slower than hand-coded ite
Alan Franzoni <[EMAIL PROTECTED]> writes:
> I have a serious "leak" issue; even though I clear all those sets
> and I delete all the references I can have to the current namespace,
> memory is not freed.
Maybe the memory is freed (marked as available for further use by
Python), just not released
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
but what is your best way to test for for False in a list?
[...]
>>> status = all(list)
>> Am I mistaken, or is this no identity test for False at all?
>
> You are mistaken.
> all take an iterable and returns if each value of it is true.
Testing
Will McGugan <[EMAIL PROTECTED]> writes:
> Is there a canonical way of storing per-thread data in Python?
mydata = threading.local()
mydata.x = 1
...
http://docs.python.org/lib/module-threading.html
--
http://mail.python.org/mailman/listinfo/python-list
Paul McGuire <[EMAIL PROTECTED]> writes:
>> >>> False in [3, 2, 1, 0, -1]
>>
>> True# no False here>>> all([3, 2, 1, 0, -1])
>>
>> False # false value present, not necessarily False
>
> I think if you want identity testing, you'll need to code your own;
I'm aware of that, I simply pointed o
Nick Craig-Wood <[EMAIL PROTECTED]> writes:
>> I think your polling way works; it seems there no other way around this
>> problem other than polling or extending Popen class.
>
> I think polling is probably the right way of doing it...
It requires the program to wake up every 0.1s to poll for
Jason Zheng <[EMAIL PROTECTED]> writes:
> greg wrote:
>> Jason Zheng wrote:
>>> Hate to reply to my own thread, but this is the working program
>>> that can demonstrate what I posted earlier:
>> I've figured out what's going on. The Popen class has a
>> __del__ method which does a non-blocking wai
Nick Craig-Wood <[EMAIL PROTECTED]> writes:
>> This can still be a problem for applications that call wait in a
>> dedicated thread, but the program can always ignore the processes
>> it doesn't know anything about.
>
> Ignoring them isn't good enough because it means that the bit of
> code whi
Jason Zheng <[EMAIL PROTECTED]> writes:
> Hrvoje Niksic wrote:
>>> greg wrote:
>> Actually, it's not that bad. _cleanup only polls the instances that
>> are no longer referenced by user code, but still running. If you hang
>> on to Popen instances, the
Robert Dailey <[EMAIL PROTECTED]> writes:
> class filestream:
> def __init__( self, filename ):
> self.m_file = open( filename, "rwb" )
[...]
> So far, I've found that unlike with the C++ version of fopen(), the
> Python 'open()' call does not create the file for you when opene
lgx <[EMAIL PROTECTED]> writes:
>From Google results, I find some source code write like that. But
>some code write like below:
>
> obj = PyString_FromString("value");
> PyDict_SetItemString(pDict,"key",obj);
> Py_DECREF(obj);
>
> So, which one is correct?
The latter is correct. While PyDict_Ge
Jason Zheng <[EMAIL PROTECTED]> writes:
>>> Nope it still doesn't work. I'm running python 2.4.4, tho.
>> That explains it, then, and also why greg's code didn't work. You
>> still have the option to try to run 2.5's subprocess.py under 2.4.
> Is it more convenient to just inherit the Popen class
Steve Holden <[EMAIL PROTECTED]> writes:
> So it would appear that the developers chose the Knuth algorithm
> (with a slight variation) for *their* implementation. Now you have
> to ask yourself whether your surmise is genuinely correct (in which
> case the documentation may contain a bug) or whet
MD <[EMAIL PROTECTED]> writes:
> 2) Is there anyway to find the type of the object in C using something
> like a switch statement? I was looking for something like this
>switch type(object) {
> STRING: "This is a string object";
> break;
> INTEGER: "This is an integer
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> In the case of CPython, the current implementation uses the Mersenne
> Twister, which has a huge period of 2**19937. However, 2081! is
> larger than that number, which means that at best a list of 2081
> items or longer can't be perfectly shuffled (not
"Evan Klitzke" <[EMAIL PROTECTED]> writes:
> You should take a look at the man pages for close(2) and write(2) (not
> fclose). Generally you will only get an error in C if you try to close
> a file that isn't open. In Python you don't even have to worry about
> that -- if you close a regular file
"Evan Klitzke" <[EMAIL PROTECTED]> writes:
>> But the writes are buffered, and close causes the buffer to be
>> flushed. file.close can throw an exception just like fclose, but
>> it will still ensure that the file is closed.
>
> Is this buffering being done by Python or the kernel?
It is done i
Adrian Petrescu <[EMAIL PROTECTED]> writes:
> I checked the online Python documentation at
> http://python.org/doc/1.5.2/lib/module-stat.html
> but it just says to "consult the documentation for your system.".
The page you're looking for is at
http://www.python.org/doc/current/lib/os-file-dir.ht
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> In particular, old-style classes are noticeably faster than
> new-style classes for some things (I think it was attribute lookup
> that surprised me recently, possibly related to the property
> stuff...)
Can you post an example that we can benchma
alf <[EMAIL PROTECTED]> writes:
> still would like to find out why it is happening (now FD_CLOEXEC
> narrowed may yahooing/googling searches). While realize that file
> descriptors are shared by forked processes it is still weird why the
> port moves to the child process once parent gets killed. w
I often have the need to match multiple regexes against a single
string, typically a line of input, like this:
if (matchobj = re1.match(line)):
... re1 matched; do something with matchobj ...
elif (matchobj = re2.match(line)):
... re2 matched; do something with matchobj ...
elif (matchobj = re
"Karim Ali" <[EMAIL PROTECTED]> writes:
> -
> while not eof <- really want the EOF and not just an empty line!
> readline by line
> end while;
> -
for line in open_file:
...
It will stop on EOF, not on empty line.
> But also, in cas
Grzegorz Słodkowicz <[EMAIL PROTECTED]> writes:
>> Seriously, it's just an optimization by the implementers. There is
>> no need for more than one empty tuple, since tuples can never be
>> modified once created.
>>
>> But they decided not to create (1, ) in advance. They probably knew
>> that hard
Erik Max Francis <[EMAIL PROTECTED]> writes:
> So far the fastest way I've found is using the `sum` builtin and
> generators::
>
> ordinalSum = sum(ord(x) for x in data)
> ordinalSumSquared = sum(ord(x)**2 for x in data)
For ordinalSum, using imap is almost twice as fast:
$ python -m
Erik Max Francis <[EMAIL PROTECTED]> writes:
> Hrvoje Niksic wrote:
>
>> For ordinalSum, using imap is almost twice as fast:
>> $ python -m timeit -s 'data=[chr(x) for x in xrange(256)]'
>> 'sum(ord(x) for x in data)'
>> 1 loops, best
Signal <[EMAIL PROTECTED]> writes:
> 2. Is there anyway to somehow to take advantage of this "caching" by
> initializing it without reading through the entire file first?
>
> 3. If the answer to #2 is No, then is there a way to purge this
> "cache" in order to get a more accurate result in my rout
Paul Sijben <[EMAIL PROTECTED]> writes:
> I am running a multi-threaded python application in a dual core
> intel running Ubuntu.
[...]
Judging from the stack trace, this patch has a good chance of fixing
your problem:
http://mail.python.org/pipermail/python-dev/2007-August/074232.html
--
h
Christof Winter <[EMAIL PROTECTED]> writes:
> To get rid of the if statements, replace __init__ function with:
>
> def __init__(self, tc):
> functionToCall = eval("self.testCase%s" % tc)
Or functionToCall = getattr(self, "testCase" + tc)
eval can introduce unwanted side effects.
--
Nick Craig-Wood <[EMAIL PROTECTED]> writes:
> If you are running linux > 2.6.18 then you can use
> /proc/sys/vm/drop_caches for exactly that purpose.
>
> http://www.linuxinsight.com/proc_sys_vm_drop_caches.html
That URL claims that you need to run "sync" before dropping the cache,
and so do oth
Steve Holden <[EMAIL PROTECTED]> writes:
>> That URL claims that you need to run "sync" before dropping the
>> cache, and so do other resources. I wonder if that means that
>> dropping the cache is unsafe on a running system.
>
> Good grief. Just let the operating system do its job, for Pete's
>
Nick Craig-Wood <[EMAIL PROTECTED]> writes:
>> > http://www.linuxinsight.com/proc_sys_vm_drop_caches.html
>>
>> That URL claims that you need to run "sync" before dropping the cache,
>> and so do other resources. I wonder if that means that dropping the
>> cache is unsafe on a running syste
tooru honda <[EMAIL PROTECTED]> writes:
> I have read the source code of the built-in random module,
> random.py. After also reading Wiki article on Knuth Shuffle
> algorithm, I wonder if the shuffle method implemented in random.py
> produces results with modulo bias.
It doesn't have modulo bias
fernando <[EMAIL PROTECTED]> writes:
> Could someone post an example on how to register a python function as
> a callback in a C function?
If I understand correctly, your C function receives a Python function
(as a function object of type PyObject *), which you need to call from
C. To do that, c
"mhearne808[insert-at-sign-here]gmail[insert-dot-here]com" <[EMAIL PROTECTED]>
writes:
> I think I'm still confused.
What Miles tried to tell you is that you should call fcnt.flock from
both PA and PB. In the example you posted, you failed to call it from
PB. No lock call, so no locking happen
[EMAIL PROTECTED] writes:
>> for row in izip_longest(*d, fillvalue='*'):
>> print ', '.join(row)
>>
>> HTH
>
> I thought that but when I tried it I recieved a
> "Syntax Error: Invalid Syntax"
> with a ^ pointing to fillvalue :S
Python isn't too happy about adding individual keyword arguments
Dr Mephesto <[EMAIL PROTECTED]> writes:
> I would like to create a pretty big list of lists; a list 3,000,000
> long, each entry containing 5 empty lists. My application will
> append data each of the 5 sublists, so they will be of varying
> lengths (so no arrays!).
>
> Does anyone know the most e
Dr Mephesto <[EMAIL PROTECTED]> writes:
> I need some real speed!
Is the speed with the GC turned off sufficient for your usage?
--
http://mail.python.org/mailman/listinfo/python-list
Chris Johnson <[EMAIL PROTECTED]> writes:
> What I want to do is build an array of lambda functions, like so:
>
> a = [lambda: i for i in range(10)]
Use a factory function for creating the lambdas. The explicit
function call will force a new variable binding to be created each
time, and the lamb
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> Should garbage-collecting 16 million strings really take 20+
> minutes?
It shouldn't. For testing purposes I've created a set of 16 milion
strings like this:
s = set()
for n in xrange(1600):
s.add('somerandomprefix' + str(n)) # prefix makes t
Christoph Krammer <[EMAIL PROTECTED]> writes:
> I have to convert a huge mbox file (~1.5G) to MySQL.
Have you tried commenting out the MySQL portion of the code? Does the
code then manage to finish processing the mailbox?
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
> I am trying unsuccessfully to remove some methods from an instance,
You can't remove the method from an instance because the method is
stored in its class.
> With the older python classes I could have done:
> self.__class__.__dict__[''test1"] to achieve the desire
<[EMAIL PROTECTED]> writes:
> 1) New instance has to have a property called 'name'
> 2) When instance is attemped to created, e.g., x=kls(name='myname'), and
> there already exists an instance with obj.name =='myname', that
> pre-existing instance is returned, instead of making new one.
> 3) A c
Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
> If a class X is in the MRO of call Y, then X is a superclass of Y. I
> agree that the documentation for super is somewhat misleading (and
> obviously wrong), but it still *give access to* (at least one of)
> the superclass(es).
I believe the confu
Ben Finney <[EMAIL PROTECTED]> writes:
> Hrvoje Niksic <[EMAIL PROTECTED]> writes:
>
>> class X(Y):
>> def foo(self):
>> super(X, self).foo()
>>
>> ...there is in fact no guarantee that super() calls a superclass of
>> X. However, it
Ben Finney <[EMAIL PROTECTED]> writes:
> Evan is claiming that "the next class in the MRO _is_ a superclass",
> apparently by his definition or some other that I've not seen.
The definition of superclass is not the issue, the issue is
"superclass *of which class*"? You expect super(A, self) to i
Michele Simionato <[EMAIL PROTECTED]> writes:
> On Sep 19, 12:36 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote:
>
>> The next class in the MRO *is* a superclass of the *instance*. Else it
>> wouldn't be in the MRO !-)
>
> Bruno, there is no such a thing as a superclass in a multiple
> inherita
Michele Simionato <[EMAIL PROTECTED]> writes:
> On Sep 19, 1:16 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
>> Your arguments against the superclass term seem to assume that there
>> is only a single superclass to a particular class.
>
> If you say "the&q
Ben Finney <[EMAIL PROTECTED]> writes:
>> The definition of superclass is not the issue, the issue is
>> "superclass *of which class*"? You expect super(A, self) to iterate
>> only over superclasses of A, even when self is an instance of a
>> subtype of A.
>
> Yes. Those are the specific paramete
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> I need to overload the operator in and let him return an object
> ... It seems it is not a behavior Python expect :
Python expects it all right, but it intentionally converts the value
to a boolean. The 'in' operator calls PySequence_Contains, wh
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
>> The string "yop" evaluates to the boolean value True, as it is not
>> empty.
>
> Does it means that when overloading an operator, python just
> wrap the call to the method and keep control of the returned
> values ???
In case of 'in' operator, it
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> I can construct an empty instance in the __new__ constructor, and I
> can initialize an non-empty instance in the __init__ initializer,
> but I can't think of any good way to stop __init__ from being called
> if the instance is empty. In pseudo-code, I
"Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> writes:
> Yep - appears I must have been misremembering from another language
> (dunno which)
Tcl
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard <[EMAIL PROTECTED]> writes:
> With this is the implementation, I'm definitely -1. Not because it's a
> bad implementation, but because if the iteration is always doing a
> sort, then there's no reason for a separate data structure.
Agreed. A true sorted dict would keep its keys so
Duncan Booth <[EMAIL PROTECTED]> writes:
> I that's the point though: you can't write one implementation that has good
> performance for all patterns of use
An implementation of sorted dict using a balanced tree as the
underlying data structure would give decent performance in all the
mentioned
HYRY <[EMAIL PROTECTED]> writes:
> This works, but I think the key of DOC is too long, so I want to use
> the id of list.append.__doc__ as the key; or use the id of
> list.append:
Using the id is not a good idea because id's are not permanent. Using
list.append as the hash key will work and will
Mark Summerfield <[EMAIL PROTECTED]> writes:
> On 26 Sep, 09:51, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
>> Duncan Booth <[EMAIL PROTECTED]> writes:
>> > I that's the point though: you can't write one implementation
>> > that has good perf
Paul Hankin <[EMAIL PROTECTED]> writes:
>> An implementation of sorted dict using a balanced tree as the
>> underlying data structure would give decent performance in all the
>> mentioned use cases. For example, red-black trees search, insert,
>> and delete in O(log n) time.
>
> But dicts do sear
Ladislav Andel <[EMAIL PROTECTED]> writes:
> Hello, why ~ bit-wise unary operator returns -(x+1) and not bit
> inversion of the given integer?
On 2s-complement architectures, -(x+1) *is* bit inversion of the given
integer.
> example:
> a = 7978
> a = ~a
> python returns -7979
>
> but I need to g
[ Note that there is now a mailing list dedicated to the C API:
http://mail.python.org/mailman/listinfo/capi-sig ]
mauro <[EMAIL PROTECTED]> writes:
> I am trying to call within a C extension a Python function provided as
> an argument by the user with: PyObject_Call(). The C extension should
> w
Joel <[EMAIL PROTECTED]> writes:
> I found the solution :
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440569
> describes a solution based on threads. I tested it and it works
> perfectly.
Note that, unlike the original alarm code, it doesn't really interrupt
the timed-out method, it
Joel <[EMAIL PROTECTED]> writes:
>> Note that, unlike the original alarm code, it doesn't really interrupt
>> the timed-out method, it just returns the control back to the caller,
>> using an exception to mark that a timeout occurred. The "timed out"
>> code is still merrily running in the backgr
"Chris Mellon" <[EMAIL PROTECTED]> writes:
> You can use ctypes and the Python API to raise a Python exception in
> the thread.
How, by changing the thread's exception state?
--
http://mail.python.org/mailman/listinfo/python-list
xkenneth <[EMAIL PROTECTED]> writes:
> Looking to do something similair. I'm working with alot of timestamps
> and if they're within a couple seconds I need them to be indexed and
> removed from a list.
> Is there any possible way to index with a custom cmp() function?
>
> I assume it would be som
Daryl Lee <[EMAIL PROTECTED]> writes:
> I am trying to locate all lines in a suite of files with quoted
> strings of particular lengths. A search pattern like r'".{15}"'
> finds 15-character strings very nicely. But I have some very long
> ones, and a pattern like r'".{272}"' fails miserably, ev
Brad Johnson <[EMAIL PROTECTED]> writes:
> I have a place where I execute a Python command that calls into C++
> code which then in turn calls back into Python using the same
> interpreter. I get a fatal error which is "PyThreadStage_Get: no
> current thread."
Does the C++ code call into the inte
Antoon Pardon <[EMAIL PROTECTED]> writes:
> It may be convincing if you only consider natural numbers in
> ascending order. Suppose you have the sequence a .. b and you want
> the reverse. If you work with included bounds the reverse is just b
> .. a. If you use the python convention, things beco
Raymond Hettinger <[EMAIL PROTECTED]> writes:
> [Paul Rubin]
>> I hope in 3.0 there's a real fix, i.e. the count should promote to
>> long.
>
> In Py2.6, I will mostly likely put in an automatic promotion to long
> for both enumerate() and count(). It took a while to figure-out how
> to do this w
[EMAIL PROTECTED] writes:
> I will expose my case quicly.
> The MYCLASES.py file contains the A class, so i can use
> from MYCLASES import A
> a = ()
>
> Using the "package mode" (wich looks fine BTW), having the simple
> MYCLASES/
> __init__.py
> A.py
>
> forces my (i guess) to use the
Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
> it's quite common to use the __init__.py of the package (as
> explained by Ben) as a facade to the internal organization of the
> package, so you can change this internal organization without
> breaking client code.
We agree on that. It is the OP
Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
>> We agree on that. It is the OP who *wants* to access his modules
>> directly without ever naming the package.
>
> To be exact, he wants to reorganize it's source code (splitting a
> file that's getting too big AFAICT)
You're right, I misread his
Gerardo Herzig <[EMAIL PROTECTED]> writes:
> If the original MYCLASSES.py has 5 different classes ,say A,B,C,D,E
> , each one has to be imported (as A and B) in order to be used for
> the client code. The thing is, there are more than 5 classes, and
> looks like a lot of unnecesary work to me, sin
Abandoned <[EMAIL PROTECTED]> writes:
> I do this use FOR easly but the speed very imported for me. I want
> to the fastest method please help me.
Can you post the code snippet that was too slow for you? Are the
lists sorted?
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> Well, I've read the thread, and I've read the thread it links to,
> and for the life of me I'm still no clearer as to why __slots__
> shouldn't be used except that:
[...]
> But is there actually anything *harmful* that can happen if I use
> __slots__?
[EMAIL PROTECTED] writes:
> Now when I run the 'run.py', it will print two different numbers.
> sys.modules tells me that 'mod1' is imported as both 'one.mod1' and
> 'mod1', which explains the result.
If I were you, I'd make sure that the module duplicate problem is
resolved first, for example by
1 - 100 of 450 matches
Mail list logo