On Wed, May 9, 2012 at 4:30 PM, Adrian Hunt wrote:
>
> Hi ya,
>
> Not to be confrontative but just because a project is open-source, it
> doesn't mean IP is open too!! The original idea is still property of the
> originator... It just has the global community adding their own IP and
> fixes. This
On Fri, May 11, 2012 at 10:23 AM, Chris Angelico wrote:
> Hmm. What happens if the interpreter can't construct a MemoryError exception?
I believe that a MemoryError instance is pre-allocated for just this
scenario. You can see it in the result of gc.get_objects().
>>> [x for x in gc.get_objects
On Wed, May 9, 2012 at 5:02 AM, J. Mwebaze wrote:
>
> I have a bunch of objects of the same type. Each object has a version
> attribute and this refers to source code that was used to make the object.
> SouceCode is maintained in separate files. eg.
> myclass_01.py, myclass_02.py, myclass_03.py,
On Fri, May 11, 2012 at 3:29 PM, gry wrote:
> sys.version --> '2.6 (r26:66714, Feb 21 2009, 02:16:04) \n[GCC 4.3.2
> [gcc-4_3-branch revision 141291]]
> I thought this script would be very lean and fast, but with a large
> value for n (like 15), it uses 26G of virtural memory, and things
> sta
On Mon, May 14, 2012 at 7:50 PM, Christian Heimes wrote:
> Am 13.05.2012 21:11, schrieb Bob Grommes:
>> Noob alert: writing my first Python class library.
>>
>> I have a straightforward class called Utility that lives in Utility.py.
>>
>> I'm trying to get a handle on best practices for fleshing o
On Fri, May 11, 2012 at 1:32 PM, Jason wrote:
> Is there any way to specify the end of line character to use in
> file.readline() ?
>
> I would like to use '\r\n' as the end of line and allow either \r or \n by
> itself within the line.
In Python 3 you can pass the argument newline='\r\n' to th
On Tue, May 15, 2012 at 3:25 AM, Christian Heimes wrote:
> Code explains more than words. I've created two examples that some issues.
>
> Mutable values break dicts as you won't be able to retrieve the same
> object again:
Sure, you'll get no argument from me on that. I was more interested
in th
On Wed, May 16, 2012 at 8:08 AM, e-mail mgbg25171
wrote:
> def execute (code) :
> p = 0
> while p < len(code) :
> func = code[p]
> p += 1
> newP = func(code,p)
> if newP != None :
> p = newP
>
> I'm trying to work out what this does
>
> code
On Wed, May 16, 2012 at 9:48 AM, Marco wrote:
> Hi all, because
>
> "There should be one-- and preferably only one --obvious way to do it",
>
> there should be a difference between the two methods in the subject, but I
> can't find it:
>
'123'.isdecimal(), '123'.isdigit()
> (True, True)
On Wed, May 16, 2012 at 10:24 AM, Ulrich Eckhardt wrote:
> Marco wrote:
>> >>> '123'.isdecimal(), '123'.isdigit()
>> (True, True)
>> >>> print('\u0660123')
>> ٠123
>> >>> '\u0660123'.isdigit(), '\u0660123'.isdecimal()
>> (True, True)
>> >>> print('\u216B')
>> Ⅻ
>> >>> '\u216B'.isdecimal(), '\
On Wed, May 16, 2012 at 8:59 AM, ytj wrote:
> Hello, all:
>
> I have two programs, one is written in py3k, the other is written in
> python 2. I am wondering how to make them work together except port
> the python 2 code to py3k? Is that possible to expose python2's
> function to py3k? In other wo
On Wed, May 16, 2012 at 3:07 PM, Thomas 'PointedEars' Lahn
wrote:
> RTFM.
>
> $ python3 -c 'print("42".isdecimal.__doc__ + "\n");
> print("42".isdigit.__doc__)'
> S.isdecimal() -> bool
>
> Return True if there are only decimal characters in S,
> False otherwise.
>
> S.isdigit() -> bool
>
> Return
On Wed, May 16, 2012 at 3:33 PM, Ethan Furman wrote:
> Just hit a snag:
>
> In cPython the deterministic garbage collection allows me a particular
> optimization when retrieving records from a dbf file -- namely, by using
> weakrefs I can tell if the record is still in memory and active, and if so
On Wed, May 16, 2012 at 3:52 PM, Charles Hixson
wrote:
> I want to persist simple dicts, but due to the security problems with
> (un)pickle, I'd prefer to not use shelve, and the only way I could see to
> persist them onto sqlite also invoked pickle.
>
> As (un)pickle allows arbitrary system comma
On Wed, May 16, 2012 at 4:53 PM, Charles Hixson
wrote:
> On 05/16/2012 03:11 PM, Ian Kelly wrote:
>>
>> On Wed, May 16, 2012 at 3:52 PM, Charles Hixson
>> wrote:
>>
>>>
>>> I want to persist simple dicts, but due to the security problems with
>
On Sun, May 20, 2012 at 10:52 AM, e-mail mgbg25171
wrote:
> There's a little forth program written in python here
> #http://openbookproject.net/py4fun/forth/forth.py
> I'm struggling to understand what these lines mean.
>
> def rJnz (cod,p) : return (cod[p],p+1)[ds.pop()]
> def rJz (cod,p) : retu
On Thu, May 24, 2012 at 5:12 PM, Emile van Sebille wrote:
> On 5/24/2012 2:30 PM Paul Rubin said...
>
>> Paul Rubin writes:
>>>
>>> new_list = chain( ((x,y-1), (x,y+1)) for x,y in coord_list )
>>
>>
>> Sorry:
>>
>> new_list = list(chain( ((x,y-1), (x,y+1)) for x,y in coord_list))
>
>
>
>>>
On Fri, May 25, 2012 at 10:33 AM, Chris Angelico wrote:
> On Sat, May 26, 2012 at 2:25 AM, Peter Pearson
> wrote:
>> Amusingly, every time I log into Discovercard's web site, I
>> get a red-letter warning that my registered email address is
>> invalid. Inquiring, I was told that the presence of
On Fri, May 25, 2012 at 1:45 PM, Damjan Georgievski wrote:
> http://www.python.org/dev/peps/pep-0405/
>
> I don't get what PEP 405 (Python Virtual Environments) brings vs what we
> already had in PEP 370 since Python 2.6.
>
> Obviously 405 has a tool to create virtual environments, but that's triv
On Tue, May 29, 2012 at 7:33 PM, Roy Smith wrote:
> I have a long string (possibly 100s of Mbytes) that I want to search for
> regex matches. re.finditer() is *almost* what I want, but the problem
> is that it returns matching strings. What I need is a list of offsets
> in the string where the r
On Tue, May 29, 2012 at 7:45 PM, MRAB wrote:
> On 30/05/2012 02:33, Roy Smith wrote:
>>
>> I have a long string (possibly 100s of Mbytes) that I want to search for
>> regex matches. re.finditer() is *almost* what I want, but the problem
>> is that it returns matching strings. What I need is a li
On Tue, May 29, 2012 at 9:33 AM, Scott Siegler wrote:
> Hello,
>
> I have a surface that I load an image onto. During a collision I would like
> to clear out the images of both surfaces that collided and show the score.
> Is there a function call to clear a surface with an image?
>
> One way I
On Mon, Jun 4, 2012 at 10:17 AM, Benjamin Kaplan
wrote:
> On Mon, Jun 4, 2012 at 11:47 AM, David Shi wrote:
>> Hello, Mohan,
>>
>> Did you test it? I am using Windows. Where are the exact steps for
>> compiling in DOS?
>>
>> Once .class or jar files created, how to use these files?
>>
>> Could
On Mon, Jun 4, 2012 at 11:19 PM, Steven D'Aprano
wrote:
> How do I programmatically get the argument spec of built-in types'
> __init__ or __new__ methods?
I don't think that you can. Methods implemented in C don't really even
have established argument specs. They just take tuples and dicts and
On Tue, Jun 5, 2012 at 2:48 AM, Steven D'Aprano
wrote:
> I was playing around with metaclasses and I wondered what would happen if
> the metaclass itself had a metaclass. Sort of a metametaclass.
>
> Apparently it gives an error. Can anyone explain why this does not work?
In your example, Meta is
On Thu, Jun 7, 2012 at 12:48 PM, Steve wrote:
> The leaks can be removed by uncommenting both lines shown.
That's just a matter of timing. You call the function before you call
set_debug, so when you uncomment the lines, the garbage collector is
explicitly run before the debug flags are set. Wh
For comparison, here is what a leaking program would look like:
class Foo(object):
def __init__(self, other=None):
if other is None:
other = Foo(self)
self.other = other
def __del__(self):
pass
import gc
gc.set_debug(gc.DEBUG_STATS | gc.DEBUG_LEAK)
f
On Fri, Jun 8, 2012 at 10:02 AM, Steve wrote:
> Well, I guess I was confused by the terminology. I thought there were leaked
> objects _after_ a garbage collection had been run (as it said "collecting
> generation 2").
That means that it's going to check all objects. The garbage
collector divide
On Fri, Jun 8, 2012 at 10:43 AM, Emile van Sebille wrote:
> Or alternately by leveraging true/false as 1/0:
>
[ 100*(not(ii%2))+ii for ii in range(10)]
The same thing, leaving bools out of it altogether:
>>> [100*(1-ii%2)+ii for ii in range(10)]
--
http://mail.python.org/mailman/listinfo/p
On Fri, Jun 8, 2012 at 4:24 PM, Dan Stromberg wrote:
> Am I misinterpreting this? It seems like according to the PEP, I should
> have still been able to import treap.py despite having a treap/. But I
> couldn't; I had to rename treap/ to treap-dir/ first.
That's how I understand it. The existe
On Fri, Jun 8, 2012 at 5:41 PM, stayvoid wrote:
> Hello,
>
> I want to pass several values to a function which is located on a
> server (so I can't change its behavior).
> That function only accepts five values which must be ints.
>
> There are several lists:
> a = [1, 2, 3, 4, 5]
> b = [5, 4, 3,
On Mon, Jun 11, 2012 at 1:51 AM, Tom Harris wrote:
> Greetings,
>
> I have a class that implements the iterator protocol, and tokenises a string
> into a series of tokens. As well as the token, it keeps track of some
> information such as line number, source file, etc.
So each processor needs to
On Wed, Jun 13, 2012 at 10:06 PM, Jose H. Martinez
wrote:
> string.split(',') will give you an array.
>
> Example:
>
> 'AAA,",,",EEE,FFF,GGG '.split(',')
>
> ['AAA', '"', '', '"', 'EEE', 'FFF', 'GGG']
But it incorrectly splits the quoted part. A proper CSV parser (like
th
On Sat, Jun 16, 2012 at 3:20 AM, Dieter Maurer wrote:
> In addition it shows that the "kdb.py" code is very old. "whrandom"
> is been replaced by "random" a long time ago.
Komodo 2.5 was released in 2003. At the time, Python was on release
2.3. Komodo is currently on version 7. The OP should co
On Thu, Jun 2, 2011 at 4:47 AM, loial wrote:
> Unfortunately using jpython or json are not options at the moment
How about JPype? Or do the Java and Python need to be in separate processes?
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Jun 2, 2011 at 11:22 AM, Steven D'Aprano
wrote:
> It seems to me that early binding is less flexible than late, because
> with late binding you have a chance to simulate early binding by saving a
> reference of the variable elsewhere, such as in a default value, or an
> instance attribute.
On Thu, Jun 2, 2011 at 3:26 PM, Algis Kabaila wrote:
> import math
>
> length = math.hypot(z, math.hypot(x, y))
>
> One line and fast.
The dimension is arbitrary, though, so:
length = reduce(math.hypot, self._coords, 0)
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Jun 2, 2011 at 4:38 PM, Tim Delaney wrote:
> First of all, do you have the parameters to the lambda the wrong way around
> in the map() version? zip(histogram, range(255)) will return (histogram
> value, index), but enumerate(histogram) will return (index, histogram
> value). But the param
On Thu, Jun 2, 2011 at 7:28 PM, Keir Rice wrote:
> Ian, I was basing my code off Fredrik Lundh post on comparing images.
> http://effbot.org/zone/pil-comparing-images.htm
Ah, now I get what it's doing. Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Jun 3, 2011 at 2:30 AM, Thomas Rachel
wrote:
> So there should be a way to replace the closure of a function with a
> snapshot of it at a certain time. If there was an internal function with
> access to the readonly attribute func_closure and with the capability of
> changing or creating a
On Fri, Jun 3, 2011 at 3:53 PM, Gabriel wrote:
> But still, is this solution really faster or better than the one using
> list comprehension and the expression 'x*x'?
No, not really.
>c:\python32\python -m timeit -s "coords = list(range(100))" -s "from math
>import hypot" -s "from functools imp
On Sat, Jun 4, 2011 at 12:09 PM, Chris Angelico wrote:
> Python doesn't seem to have an inbuilt function to divide strings in
> this way. At least, I can't find it (except the special case where n
> is 1, which is simply 'list(string)'). Pike allows you to use the
> division operator: "Hello, worl
On Fri, Jun 3, 2011 at 2:35 PM, Joe wrote:
> foo.__dict__['color']='blue'
> fu.__dict__['color']='red'
You don't need to use __dict__ to set function attributes. Just do:
foo.color = 'blue'
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Jun 6, 2011 at 9:29 AM, Steven D'Aprano
wrote:
> [...]
>> I would expect
>> any regex processor to compile the regex into an FSM.
>
> Flying Spaghetti Monster?
>
> I have been Touched by His Noodly Appendage!!!
Finite State Machine.
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Jun 6, 2011 at 10:08 AM, Neil Cerutti wrote:
> import re
>
> print("re solution")
> with open("data.txt") as f:
> for line in f:
> fixed = re.sub(r"(TABLE='\S+)\s+'", r"\1'", line)
> print(fixed, end='')
>
> print("non-re solution")
> with open("data.txt") as f:
> for l
On Mon, Jun 6, 2011 at 11:17 AM, Neil Cerutti wrote:
> I wrestled with using addition like that, and decided against it.
> The 7 is a magic number and repeats/hides information. I wanted
> something like:
>
> prefix = "TABLE='"
> start = line.index(prefix) + len(prefix)
>
> But decided I searc
On Mon, Jun 6, 2011 at 11:48 AM, Ethan Furman wrote:
> I like the readability of this version, but isn't generating an exception on
> every other line going to kill performance?
I timed it on the example data before I posted and found that it was
still 10 times as fast as the regex version. I di
On Mon, Jun 6, 2011 at 4:19 PM, miamia wrote:
> php I am trying to use is here:
> http://code.google.com/p/antares4pymes/source/browse/trunk/library/System/Crypt/AES.php?r=20
That library does not appear to be doing CBC as far as I can tell.
Maybe they will agree if you use EBC instead?
> BLOCK_
On Mon, Jun 6, 2011 at 6:11 PM, Ben Finney wrote:
>> You must use prefix-** in the call to unpack the mapping as keyword
>> arguments. Note that using locals() like this isn't best-practice.
>
> Who says so, and do you find their argument convincing? Do you have a
> reference for that so we can se
On Mon, Jun 6, 2011 at 6:11 PM, Ben Finney wrote:
> Chris Rebert writes:
>
>> print "{solo} was captured by {jabba}".format(**locals()) # RIGHT
>
> I tend to use ‘u"foo {bar} baz".format(**vars())’, since ‘vars’ can also
> take the namespace of an object. I only need to remember one “give me
> th
On Tue, Jun 7, 2011 at 1:31 PM, Dun Peal wrote:
> On Jun 7, 1:23 pm, Neil Cerutti wrote:
>> Use pdb.
>
> Neil, thanks for the tip; `pdb` is indeed a great debugging tool.
>
> Still, it doesn't obviate the need for arguments in the stack trace.
Your program could use sys.excepthook to generate a
On Tue, Jun 7, 2011 at 11:51 AM, Ethan Furman wrote:
>> I'm not sure where he gets the idea that this has any impact on
>> concurrency, though.
>
> What if f has two calls to self.h() [or some other function], and self.h
> changes in between?
>
> Surely that would be a major headache.
I could ima
On Tue, Jun 7, 2011 at 2:22 PM, Ian Kelly wrote:
> from functools import partial
>
> def g(value):
> print(value)
> return partial(g, value+1)
>
> f = partial(0)
> for i in range(1):
> f = f()
The "partial(0)" should read "partial(g,
On Tue, Jun 7, 2011 at 2:42 PM, Paul Rubin wrote:
> geremy condra writes:
>> # adds random junk to the filename- should make it hard to guess
>> rrr = os.urandom(16)
>> fname += base64.b64encode(rrr)
>
> Don't use b64 output in a filename -- it can have slashes in it! :-(
>
> Simplest is to use
2011/6/10 Sérgio Monteiro Basto :
> ok after thinking about this, this problem exist because Python want be
> smart with ttys, which is in my point of view is wrong, should not encode to
> utf-8, because tty is in utf-8. Python should always encode to the same
> thing. If the default is ascii, shou
On Fri, Jun 10, 2011 at 10:55 AM, Eric Snow wrote:
> The only problem, as seen in the last line, is that the __doc__ on
> instances is not inherited on instances of the class. Object
> attribute lookup only looks to the type's __dict__ for inheritance,
> and not the types's type. However, that s
Python 3.2 has this lovely new contextlib.ContextDecorator mixin [1]
for context manager classes that allows you to apply the context
manager as a decorator. The docs for this feature include the note:
ContextDecorator is used by contextmanager(), so you get this
functionality automatically.
On Fri, Jun 10, 2011 at 4:57 PM, Ian Kelly wrote:
> So as far as I can tell, generator-based context managers simply can't
> be used as ContextDecorators. Furthermore, the documentation's claim
> that they can is actually harmful, since they *appear* to work at
> first.
On Sat, Jun 11, 2011 at 1:27 PM, Giampaolo Rodolà wrote:
> @deprecated()
> def foo():
> return 0
This is equivalent to:
foo = deprecated()(foo)
> @deprecated(some_function)
> def foo():
> return 0
foo = deprecated(some_function)(foo)
> @deprecated
> def foo():
On Sat, Jun 11, 2011 at 8:21 PM, Andrew Berg wrote:
> On 2011.06.11 09:12 PM, Terry Reedy wrote:
>> On 6/11/2011 9:32 PM, Andrew Berg wrote:
>> > I'm pretty happy that I can copy variables and their value from one
>>
>> You are copying names and their associations, but not the objects or
>> thier
On Sat, Jun 11, 2011 at 10:32 PM, Andrew Berg wrote:
> On 2011.06.11 10:40 PM, Ben Finney wrote:
>> It's exactly the same as with an ordinary assignment (‘a = b’) in
>> Python.
> Fair enough.
>> > How would I make actual copies?
>> At what level?
> Level? I just want to be able to create an object
On Tue, Jun 14, 2011 at 12:11 AM, Xah Lee wrote:
> numerical keypad is useful to many. Most people can't touch type. Even
> for touch typist, many doesn't do the number keys. So, when they need
> to type credit, phone number, etc, they go for the number pad.
It's not about being *able* to touch t
On Thu, Jun 16, 2011 at 4:43 PM, gervaz wrote:
> Hi all, can someone tell me why the read() function in the following
> py3 code returns b''?
>
h = http.client.HTTPConnection("www.twitter.com")
h.connect()
h.request("HEAD", "/", "HTTP 1.0")
r = h.getresponse()
r.read()
> b
On Tue, Jun 14, 2011 at 4:57 PM, MRAB wrote:
> To me, the obvious choice would be "return", not "break".
No, "return" returns a value. Modules do not return values.
Therefore "return" would be inappropriate. If this feature were
deemed desirable, "break" would make more sense to me.
--
http://
On Thu, Jun 16, 2011 at 7:21 PM, Erik Max Francis wrote:
>> This would, if I understand imports correctly, have ham() operate in
>> one namespace and spam() in another. Depending on what's being done,
>> that could be quite harmless, or it could be annoying (no sharing
>> module-level constants, e
On Thu, Jun 16, 2011 at 10:24 PM, Erik Max Francis wrote:
> True. So let's use `in` to represent breaking out of the top-level code of
> a module. Why not, it's not the first time a keyword has been reused,
> right?
>
> The point is, if it's not obvious already from that facetious proposal, it's
On Thu, Jun 16, 2011 at 10:21 PM, Erik Max Francis wrote:
> Ethan Furman wrote:
>>
>> The Context:
>>
>> "It's quite consistent on which control structures you can break out of"
>>
>> Hmmm Nope, nothing there to suggest you were talking about the 'break'
>> keyword.
>
> That's what I wrote, al
On Fri, Jun 17, 2011 at 4:27 AM, bruno.desthuilli...@gmail.com
wrote:
> On Jun 11, 10:28 pm, Ian Kelly wrote:
>>
>> Since there is no way to distinguish the two cases by the arguments,
>
> def deprecated(func=None, replacement=None):
> if replacement:
>
On Fri, Jun 17, 2011 at 8:45 AM, Franck Ditter wrote:
> Hi, I'm just wondering about the complexity of some Python operations
> to mimic Lisp car and cdr in Python...
>
> def length(L) :
> if not L : return 0
> return 1 + length(L[1:])
>
> Should I think of the slice L[1:] as (cdr L) ? I mean, i
On Fri, Jun 17, 2011 at 10:56 AM, Wolfgang Rohdewald
wrote:
> On Freitag 17 Juni 2011, Steven D'Aprano wrote:
>> run this one-
>> liner and wonder no more...
>
> looks like something dangerous to me. What does
> it do? rm -rf ?
The thread at the link discusses what it does in great detail.
--
ht
On Fri, Jun 17, 2011 at 3:02 PM, Shashank Singh
wrote:
> Correct me if I am wrong here but isn't the second one is O(log N)?
> Binary search?
> That is when you have an already sorted list from somewhere and you
> are inserting just one new value.
Finding the position to insert is O(log n), but t
On Fri, Jun 17, 2011 at 3:48 PM, Chris Torek wrote:
> If len(large_list) is m, this is O(m). Inserting each item in
> the "right place" would be O(m log (n + m)). But we still
> have to sort:
>
> a.sort()
>
> This is O(log (n + m)), hence likely better than repeatedly inserting
> in the corre
On Sat, Jun 18, 2011 at 7:37 AM, bruno.desthuilli...@gmail.com
wrote:
> If you go that way, then using polymorphic dispatch might (or not,
> depending on the game's rules ) be a good idea:
>
>
> class Character(object):
> BASE_HEALTH = 50
> ...
> def __init__(self, name):
> ...
>
On Mon, Jun 20, 2011 at 5:57 AM, Mel wrote:
> Battle for Wesnoth is set up this way. I don't know what the code does, but
> you can go wild creating new classes of character by mixing up new
> combinations of attribute settings in new configuration files, and injecting
> them into the standard ga
On Mon, Jun 20, 2011 at 12:14 PM, Tim Johnson wrote:
> Currently using python 2.6, but am serving some systems that have
> older versions of python (no earlier than.
> Question 1:
> With what version of python was str.format() first implemented?
2.6
> Question 2:
> Given the following string:
On Mon, Jun 20, 2011 at 1:43 PM, deathweaselx86 wrote:
> Howdy guys, I am new.
>
> I've been converting lists to sets, then back to lists again to get
> unique lists.
> e.g
>
> Python 2.5.2 (r252:60911, Jan 20 2010, 21:48:48)
> [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
> Type "help", "copyrigh
On Tue, Jun 21, 2011 at 12:05 PM, Billy Mays wrote:
> I know I could use enumerate:
>
> for i, v in enumerate(myList):
> doStuff(i, myList[i])
>
> ...but that stiff seems clunky.
Why not:
for i, v in enumerate(myList):
doStuff(i, v)
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jun 21, 2011 at 12:26 PM, Ian wrote:
> myForkedScript has code like this:
> if fail:
>os._exit(1)
> else:
>os._exit(os.EX_OK)
>
> Is using os._exit() the correct way to get a return value back to the
> main process?
sys.exit() is the preferred way.
> I thought the value 'n', pass
> Where did you find the Unix docs you pasted in? I didn't find it in
> the man pages. Thank you. Based on what you say, I will change my
> os._exit() to sys.exit().
http://docs.python.org/library/os.html#os.wait
http://docs.python.org/library/os.html#os.waitpid
I don't know what man pages you
On Tue, Jun 21, 2011 at 1:48 PM, John Salerno wrote:
> Here is what I have so far. Initially the get_factors function just
> iterated over the entire range(2, n + 1), but since a number can't
> have a factor greater than half of itself, I tried to shorten the
> range by doing range(2, n //2), but
On Tue, Jun 21, 2011 at 3:09 PM, John Salerno wrote:
> Don't worry, I was still unclear about what to do after reading all
> the responses, even yours! But one thing that made me feel better was
> that I wasn't having a Python problem as much as a *math* problem. I
> changed my get_factors functio
On Tue, Jun 21, 2011 at 5:39 PM, News123 wrote:
> Hi,
>
> I'm having a django browser application.
>
> There's certain administrative tasks, that I'd like to perform from the
> command line (cronjob or manually).
> As these scripts might be huge and might consume quite some memory I'd
> prefer, th
On Tue, Jun 21, 2011 at 6:42 PM, News123 wrote:
> ###
> If running myapp.py I get following output:
>
> yes this line is executed
> Traceback (most recent call last):
> File "./myapp.py", line 11, in
> class Mini(models.Model):
> File
> "/opt/my_py
On Tue, Jun 21, 2011 at 6:21 PM, News123 wrote:
> Out of curiousity: Do you know whether the imports would be executed for
> each potential command as soon as I call manage.py or only
> 'on demand'?
Off the top of my head, I don't know.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jun 21, 2011 at 11:58 PM, Chris Torek wrote:
> I was curious about implementing prime factorization as a generator,
> using a prime-number generator to come up with the factors, and
> doing memoization of the generated primes to produce a program that
> does what "factor" does, e.g.:
This
On Wed, Jun 22, 2011 at 6:01 AM, Anny Mous wrote:
> def sieve():
> """Yield prime integers efficiently.
>
> This uses the Sieve of Eratosthenes, modified to generate the primes
> lazily rather than the traditional version which operates on a fixed
> size array of integers.
> """
>
On Wed, Jun 22, 2011 at 3:54 PM, Steven D'Aprano
wrote:
> Fortunately, that's not how it works, and far from being a "limitation",
> it would be *disastrous* if iterables worked that way. I can't imagine
> how many bugs would occur from people reassigning to the loop variable,
> forgetting that it
On Thu, Jun 23, 2011 at 1:58 PM, John Salerno wrote:
> After I've run the re.search function on a string and no match was
> found, how can I access that string? When I try to print it directly,
> it's an empty string, I assume because it has been "consumed." How do
> I prevent this?
This has noth
On Tue, Jun 28, 2011 at 10:52 AM, Jigar Tanna
wrote:
> coming across to certain views from people, it is not a good practice
> to use
> decorators with arguments (i.e. @memoize() ) and instead it is good to
> just
> use @memoize. Can any of you guys explain me advantages and
> disadvantages of
> u
On Tue, Jun 28, 2011 at 1:33 PM, hisan wrote:
> How to create n number thread in python. i want iterate over the for loop and
> create a thread for each iteration .
> sample code
> for i in range(o,50):
> i want to create 50 thread here which call the same function. how start and
> stop each t
On Tue, Jun 28, 2011 at 1:33 PM, Xah Lee wrote:
> this will be of interest to those bleeding-edge pythoners.
>
> “what… is the airspeed velocity of an unladen swallow?”
>
> xahlee.org/funny/unladen_swallow.html
More interesting to me is not the ad but that Wolfram Alpha will
actually answer the q
On Wed, Jun 29, 2011 at 1:30 PM, Ethan Furman wrote:
> How about just having one bit of code that works either way?
How would you adapt that code if you wanted to be able to decorate a
function that takes arguments?
This also won't work if the argument to the decorator is itself a
callable, such
On Wed, Jun 29, 2011 at 3:29 PM, Ethan Furman wrote:
> 8<
> class enclose(object):
> func = None
> def __init__(self, char='#'):
> self.char = char
> if callable(char): # was a function passed in directly?
>
On Thu, Jun 30, 2011 at 11:18 AM, MRAB wrote:
>> And that was a direct cut&paste from a command window; showing it
>> had slept for some 90 seconds before I killed it.
>>
> Looks like it hasn't changed even in WinXP, Python 3.2.
It gets cast to an unsigned long, so I expect sleep(-1) on Wi
On Sat, Jul 2, 2011 at 12:08 PM, John Salerno wrote:
> But why does the documentation say "The return value of the decorator
> need not be callable"?
Because the language does not enforce the restriction that the return
value should be a callable. If it's not a callable, then the result
will jus
On Mon, Jul 4, 2011 at 6:01 PM, Tim Johnson wrote:
>> Yes, but what are you actually *trying to do*? "Detecting data members" is
>> not an end in itself. Why do you think you need to detect data members?
>
> Steven, I'm building a documentation system. I have my own MVC framework
> and the goal
On Mon, Jul 4, 2011 at 12:36 AM, Xah Lee wrote:
> So, a solution by regex is out.
Actually, none of the complications you listed appear to exclude
regexes. Here's a possible (untested) solution:
((?:\s*)+)
\s*((?:[^<]|<(?!/p>))+)
\s*
and corresponding replacement string:
\1
\2
I don't kno
On Tue, Jul 5, 2011 at 2:37 PM, Xah Lee wrote:
> but in anycase, i can't see how this part would work
> ((?:[^<]|<(?!/p>))+)
It's not that different from the pattern 「alt="[^"]+"」 earlier in the
regex. The capture group accepts one or more characters that either
aren't '<', or that are '<' but a
On Wed, Jul 6, 2011 at 12:49 AM, Ulrich Eckhardt
wrote:
> Mel wrote:
>> In wx, many of the window classes have Create methods, for filling in
>> various attributes in "two-step construction". I'm not sure why, because
>> it works so well to just supply all the details when the class is called
>>
On Wed, Jul 6, 2011 at 9:04 AM, Mihai Badoiu wrote:
> How do I do interactive plots in python? Say I have to plot f(x) and g(x)
> and I want in the plot to be able to click on f and make it disappear. Any
> python library that does this?
Matplotlib can be integrated with either wxPython or PyQt
701 - 800 of 3471 matches
Mail list logo