On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote:
> Tem Pl :
>
>> Here are some concurrency benchmarks for python vs other languages.
>>
>> https://github.com/atemerev/skynet/pull/53
>>
>> Is there something wrong with this implementation?
>
> It's a "fork bomb".
Isn't that the point of the
On Wed, Feb 24, 2016 at 9:13 AM, Marko Rauhamaa wrote:
> Ian Kelly :
>
>> On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote:
>>> Tem Pl :
>>>> Is there something wrong with this implementation?
>>>
>>> It's a "fork bomb".
>
On Thu, Feb 25, 2016 at 5:40 PM, Steven D'Aprano wrote:
> If you take "Special cases are not special enough" seriously, you will not
> use `import os.path` since os is not a package:
>
> py> os.__package__
> ''
>
> and os.path is not part of os, it's just a publicly exposed attribute which
> merel
On Fri, Feb 26, 2016 at 3:08 PM, Sven R. Kunze wrote:
> Python sometimes seems not to hop back and forth between C and Python code.
C code as a rule tends to ignore dunder methods. Those are used to
implement Python operations, not C operations.
> _siftup(heap, 0)# that's C
Your com
On Sun, Feb 28, 2016 at 11:40 PM, wrote:
> Hello list,
>
> We can not import a module twice in a session of Python (subsequent attempts
> to import same module don't result in any error though, but it is
> not-effective).
>
> However after making change to module, we can reload() it (if not rel
On Feb 29, 2016 7:11 AM, wrote:
>
> Sorry but would not if (array==empty) suffice and be alot clearer?
In Python, you can just do "if len(array) == 0" or "if not array".
In JavaScript you have "if (array.length === 0)". Is there some problem
with that?
I would prefer this over your suggestion s
On Mon, Feb 29, 2016 at 8:18 AM, Ganesh Pal wrote:
> Iam on python 2.6
Python 2.6 has been unsupported since October 2013. Among other
things, that means it is no longer receiving security updates like
more recent versions. Unless you have an extremely strong reason for
wanting to stay to Python
On Mon, Feb 29, 2016 at 9:06 AM, Random832 wrote:
> On Mon, Feb 29, 2016, at 10:36, ast wrote:
>> but why doesn't it work with built-in classes int, float, list ?
>>
>> L = [1, 8, 0]
>> L.test = 'its a list !'
>>
>> (however lists are mutable, int, float ... are not)
>
> Because those classes
On Mon, Feb 29, 2016 at 9:21 AM, Larry Martell wrote:
> On Sat, Feb 27, 2016 at 4:37 AM, Steven D'Aprano wrote:
>> The author of Requests, Kenneth Reitz, discusses his recent recovery from a
>> MentalHealthError exception.
>>
>> http://www.kennethreitz.org/essays/mentalhealtherror-an-exception-oc
On Mon, Feb 29, 2016 at 10:26 AM, Ganesh Pal wrote:
> On Mon, Feb 29, 2016 at 9:59 PM, Ian Kelly wrote:
>> On Mon, Feb 29, 2016 at 8:18 AM, Ganesh Pal wrote:
>>> Iam on python 2.6
>
>>> 1. usage of try- expect
>>
>> try-except in every single funct
On Mon, Feb 29, 2016 at 1:07 PM, wrote:
> This program creates a uniform linktree of x nodes, and it knows when it get
> stuck in a loop generating random values.
>
> Because the networks random generated, only a subset of the permutations will
> generate a uniform network most get stuck in loo
On Mon, Feb 29, 2016 at 4:14 PM, Cameron Simpson wrote:
> Another remark here: if you're going to log, log the exception as well:
>
> logging.error("something went wrong: %s", e)
>
> Ian's example code is nice and simple to illustrate "log and then reraise"
> but few things are as annoying as
It's not at all clear what the problem is from your description. What
is it that you expect the code to do? What is it doing instead that
violates your expectation? Why are you asking for Javascript help on a
Python mailing list?
On Mon, Feb 29, 2016 at 10:40 PM, wrote:
> I've been looking at th
On Mar 1, 2016 4:41 AM, "Chris Angelico" wrote:
>
> On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano
wrote:
> > I cannot imagine why you would want to reload() in production code. That
> > would imply that your production code is modifying already-imported
> > modules, then wanting to import them
On Tue, Mar 1, 2016 at 3:02 PM, Chris Angelico wrote:
> On Wed, Mar 2, 2016 at 8:53 AM, Ian Kelly wrote:
>> I have a hard time understanding the appeal of super-long uptimes. I'm not
>> even comfortable running a single kernel version that long. What's so awful
>&g
On Tue, Mar 1, 2016 at 6:19 PM, Steven D'Aprano wrote:
> On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote:
>
>> There's a big difference between
>> that and clocking a year of uptime just because you can, though.
>
> What other reason is there for having a year
On Wed, Mar 2, 2016 at 2:35 AM, Jussi Piitulainen
wrote:
> The following are too delicate for me. I suppose the answers could have
> been different, but I can't guess what mechanism actually leads to these
> results. Just idle curiosity on my part.
>
890 is 890
> True
id(890) == id(890)
On Wed, Mar 2, 2016 at 10:57 AM, Rob Gaddi
wrote:
> Peter Pearson wrote:
>
>> On Tue, 1 Mar 2016 18:24:12 +0100, ast wrote:
>>>
>>> It's not clear to me what arguments are passed to the
>>> __new__ method. Here is a piece of code:
>>>
>>>
>>> class Premiere:
>>>
>>> def __new__(cls, price):
>>
On Mar 2, 2016 9:01 PM, "Rustom Mody" wrote:
>
> On Thursday, March 3, 2016 at 7:59:13 AM UTC+5:30, Steven D'Aprano wrote:
> > On Thu, 3 Mar 2016 04:02 am, Rustom Mody wrote:
> >
> > > And how is [1]'s starting different from Kenneth's finding his weight
> > > to be the weight of the universe?
> >
On Thu, Mar 3, 2016 at 10:21 AM, alister wrote:
> On Thu, 03 Mar 2016 13:35:12 +1100, Chris Angelico wrote:
>> 1) No physical object can have negative mass.
>> 2) I am a part of the universe and have positive mass.
>> 3) I am not Kenneth.
>> 4) The sum of my mass and Kenneth's mass must exceed Ken
On Thu, Mar 3, 2016 at 10:03 AM, Rustom Mody wrote:
> Is it so damn hard to be a bit honest and when asked about is in python to
> reply:
>
> If you dont know what you are doing, dont use 'is' (None excepted)
> If you know why are you asking?
That seems like a rather unhelpful response.
--
http
On Thu, Mar 3, 2016 at 1:20 PM, alister wrote:
> On Thu, 03 Mar 2016 11:03:55 -0700, Ian Kelly wrote:
>
>> On Thu, Mar 3, 2016 at 10:21 AM, alister
>> wrote:
>>> On Thu, 03 Mar 2016 13:35:12 +1100, Chris Angelico wrote:
>>>> 1) No physical object can hav
On Thu, Mar 3, 2016 at 1:28 PM, Pavel Volkov wrote:
> Suppose, I have some resource-intensive tasks implemented as functions in
> Python.
> Those are called repeatedly in my program.
> It's guranteed that a call with the same arguments always produces the same
> return value.
> I want to cache the
On Fri, Mar 4, 2016 at 7:03 AM, alister wrote:
> On Fri, 04 Mar 2016 10:12:58 +, cl wrote:
>
>> Steven D'Aprano wrote:
>>> On Fri, 4 Mar 2016 12:23 pm, INADA Naoki wrote:
>>>
>>>
>>> >>
>>> >> Indeed. I don't understand why, when splitting a condition such as
>>> >> this,
>>> >> people tend t
On Fri, Mar 4, 2016 at 11:50 AM, crankypuss wrote:
> I don't know about that, but you've certainly shown that what I was told
> about this group being helpful and non-combative is bullshit.
Look in a mirror much?
--
https://mail.python.org/mailman/listinfo/python-list
On Sat, Mar 5, 2016 at 9:21 AM, Antoon Pardon
wrote:
> Op 05-03-16 om 16:18 schreef Chris Angelico:
>> On Sun, Mar 6, 2016 at 2:05 AM, Antoon Pardon
>> wrote:
>>> Using python 3.4/3.5
>>>
>>> Suppose I have the following class:
>>>
>>> class Tryout:
>>>
>>> @extern
>>> def method(self, ..
On Sun, Mar 6, 2016 at 10:05 AM, Mark Lawrence wrote:
> Why in the year 2016 are people still giving links to the Luddite Python 2
> docs?
Maybe because it's the version that comes up when googling for "python
if statement".
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, Mar 7, 2016 at 8:54 AM, Tony van der Hoff wrote:
> I thought I understood this, but apparently not:
> Under py3:
>
> 1. "import tkinter" imports the whole module into the name space. Any access
> to names therein must be prefixed with the module name.
> ie top = tkinter.Tk()
> But tkinter.
On Thu, Mar 3, 2016 at 11:50 AM, Tim Chase
wrote:
> I think that relative imports should ameliorate this, as I usually
> hit it when I'm using smtplib which in turn imports "email" (and, in
> 2.x when it found my local email.py would crash and burn). If it used
> a relative import that forced it t
On Mon, Mar 7, 2016 at 9:39 AM, Ben Morales wrote:
> I am trying to download Python but I have windows 10 and I do not see a 64
> bit download for my operating system. Do you have a 64 bit for windows?
What page are you looking at?
https://www.python.org/downloads/release/python-351/ has download
On Mon, Mar 7, 2016 at 10:23 AM, Tony van der Hoff wrote:
> However, more generally, how am I supposed to know that a module is part of
> a package, and needs a "magic" stanza to get a module loaded?
If the import path of the module has a dot in it, then it's part of a package.
--
https://mail.p
On Mon, Mar 7, 2016 at 10:25 AM, Mark Lawrence wrote:
> On 07/03/2016 16:57, Ian Kelly wrote:
>>
>> On Mon, Mar 7, 2016 at 9:39 AM, Ben Morales
>> wrote:
>>>
>>> I am trying to download Python but I have windows 10 and I do not see a
>>> 64
>>
On Mon, Mar 7, 2016 at 11:51 AM, Jon Ribbens
wrote:
> I must say that Python on Windows was a very poor experience indeed,
> "virtualenv" does not work and "venv" refuses to create the 'activate'
> shell script so does not work either
I've used both of these on Windows (although not recently) and
On Mon, Mar 7, 2016 at 3:51 PM, Fillmore wrote:
>
> learning Python from Perl here. Want to do things as Pythonicly as possible.
>
> I am reading a TSV, but need to skip the first 5 lines. The following works,
> but wonder if there's a more pythonc way to do things. Thanks
I'd probably use iterto
On Mon, Mar 7, 2016 at 4:09 PM, Fillmore wrote:
>
> I must be missing something simple because I can't find a way to break out
> of a nested loop in Python.
>
> Is there a way to label loops?
No, you can't break out of nested loops, apart from structuring your
code such that return does what you
On Mon, Mar 7, 2016 at 6:41 PM, Jon Ribbens
wrote:
> On 2016-03-07, Ian Kelly wrote:
>> On Mon, Mar 7, 2016 at 11:51 AM, Jon Ribbens
>> wrote:
>>> I must say that Python on Windows was a very poor experience indeed,
>>> "virtualenv" does not work
On Tue, Mar 8, 2016 at 10:56 AM, Jon Ribbens
wrote:
> The only things I can think of that are at all 'weird' are that there
> are spaces in the filenames, and there's more than one drive. But
> the former of those is utterly standard for Windows, and the latter
> doesn't really even rise to the le
On Tue, Mar 8, 2016 at 5:13 PM, Chris Angelico wrote:
> On Wed, Mar 9, 2016 at 10:52 AM, Steven D'Aprano wrote:
>>> Well, running bash on Windows is decidedly non-standard. This is like
>>> installing a Python package on a Linux system and then complaining
>>> that it won't run under wine. I don'
On Wed, Mar 9, 2016 at 2:14 AM, Veek. M wrote:
> what i wanted to know was, x = Client('192.168.0.1') will create an
> object 'x' with the IP inside it. When I do:
> pickle.dump(x)
> pickle doesn't know where in the object the IP is, so he'll call
> __getstate__ and expect the return value to be t
On Thu, Mar 10, 2016 at 6:41 AM, Ben Mezger wrote:
> Hi all,
>
> I've been studying Object Oriented Theory using Java. Theoretically, all
> attributes should be private, meaning no one except the methods itself
> can access the attribute;
>
> public class Foo {
> private int bar;
> ...
En
On Thu, Mar 10, 2016 at 11:59 AM, Neal Becker wrote:
> sohcahto...@gmail.com wrote:
>
>> On Thursday, March 10, 2016 at 10:33:47 AM UTC-8, Neal Becker wrote:
>>> Is there a way to ensure resource cleanup with a construct such as:
>>>
>>> x = load (open ('my file', 'rb))
>>>
>>> Is there a way to e
On Thu, Mar 10, 2016 at 2:33 PM, Fillmore wrote:
>
> when I put a Python script in pipe with other commands, it will refuse to
> let go silently. Any way I can avoid this?
What is your script doing? I don't see this problem.
ikelly@queso:~ $ cat somescript.py
import sys
for i in range(20):
On Thu, Mar 10, 2016 at 3:09 PM, Peter Otten <__pete...@web.de> wrote:
> I suppose you need to fill the OS-level cache:
>
> $ cat somescript.py
> import sys
>
> for i in range(int(sys.argv[1])):
> sys.stdout.write('line %d\n' % i)
> $ python somescript.py 20 | head -n5
> line 0
> line 1
> line
On Mar 10, 2016 5:15 PM, "Fillmore" wrote:
>
>
> Here's another handy Perl regex which I am not sure how to translate to
Python.
>
> I use it to avoid processing lines that contain funny chars...
>
> if ($string =~ /[^[:print:]]/) {next OUTER;}
Python's re module doesn't support POSIX character c
On Mar 10, 2016 6:33 PM, "Mark Lawrence" wrote:
>
> On 11/03/2016 00:25, Ian Kelly wrote:
>>
>> On Mar 10, 2016 5:15 PM, "Fillmore" wrote:
>>>
>>>
>>>
>>> Here's another handy Perl regex which I am not sure how to
On Fri, Mar 11, 2016 at 2:29 AM, dieter wrote:
> If you are really interested to enforce Java encapsulation policies
> (access to attributes via "getter/setter" only), you will need
> to use your own "metaclass".
>
> The "metaclass" has a similar relation to a class as a class to
> an instance: i.
On Thu, Mar 10, 2016 at 5:45 PM, Rick Johnson
wrote:
> Many times, i would have preferred to define my module space
> across multiple files, multiple files that could share state
> without resorting to the yoga-style "import contortions",
> and/or the dreaded "circular import nightmares" that plag
On Fri, Mar 11, 2016 at 9:34 AM, Wolfgang Maier
wrote:
> On 11.03.2016 15:23, Fillmore wrote:
>>
>> On 03/11/2016 07:13 AM, Wolfgang Maier wrote:
>>>
>>> One lesson for Perl regex users is that in Python many things can be
>>> solved without regexes.
>>> How about defining:
>>>
>>> printable = {ch
On Fri, Mar 11, 2016 at 4:18 PM, Fillmore wrote:
>
> Playing with ArgumentParser. I can't find a way to override the -h and
> --help options so that it provides my custom help message.
>
> -h, --help show this help message and exit
>
> Here is what I am trying:
>
> parser = argparse.Argu
On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote:
> A property uses the @property decorator and has @foo.setter
> @foo.deleter.
>
> A descriptor follows the descriptor protocol and implements the __get__
> __set__ __delete__ methods.
>
> But they both do essentially the same thing, allow us to do:
On Fri, Mar 11, 2016 at 11:24 PM, Veek. M wrote:
> Ian Kelly wrote:
>
>> On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote:
>>> Also, what's this bit:
>>> self.default = default if default else type()
>>
>> If the default parameter has a truthy value,
On Fri, Mar 11, 2016 at 7:39 PM, Rick Johnson
wrote:
> At run-time, i don't care how large a "module namespace" may
> be. Sometimes a module namespace will be small, with only a
> few exposed symbols, but sometimes, a module namespace will
> expose thousands of symbols.
Thousands, really? What sy
On Mar 14, 2016 2:34 AM, "Tyson" wrote:
>
> I am having a lot of trouble getting python to find the pygame module; my
> operating system is Windows 7. Can you offer any help? . Should I
> download pygame into the same folder as Python? . any ideas at all?
In what form did you download PyGame?
On Sun, Mar 13, 2016 at 5:00 PM, Jeff Schumaker wrote:
> I'm trying to use Python Editor v5 for Chromebooks. It works fine, except it
> won't read data files. I'm just wondering if anyone else is using this editor
> and has found a solution to this problem.
Sorry, haven't tried it. On my Chrome
On Mon, Mar 14, 2016 at 9:06 AM, Oscar Benjamin
wrote:
> On 14 March 2016 at 14:35, Rick Johnson wrote:
>>
>> I would strongly warn anyone against using the zip function
>> unless
> ...
>> I meant to say: absolutely, one hundred percent *SURE*, that
>> both sequences are of the same length, or, a
On Mon, Mar 14, 2016 at 9:19 AM, Skip Montanaro
wrote:
> Is this correct (today, with Daylight Savings in effect)?
>
import pytz
i.timezone
> 'America/Chicago'
pytz.timezone(i.timezone)
>
ot
> datetime.datetime(2016, 3, 14, 9, 30, tzinfo= 'America/New_York' EDT-1 day, 20:00:00
On Mon, Mar 14, 2016 at 9:32 AM, Skip Montanaro
wrote:
> On Mon, Mar 14, 2016 at 10:26 AM, Ian Kelly wrote:
>> Why should it? You only asked pytz for the Chicago timezone. You
>> didn't ask for it relative to any specific time.
>
> Thanks. I thought using Ameri
On Mon, Mar 14, 2016 at 10:53 AM, Rick Johnson
wrote:
> If you download and run an installer, one that is
> appropriate for your operating system and Python version,
> everything will be taken care of for you.
>
> Since you are using Python 3.5.1 on a windows box, you'll
> want to download and ins
On Mon, Mar 14, 2016 at 11:32 AM, Rick Johnson
wrote:
> Ignoring Tkinter, which is a gawd awful mess, how would you
> re-organize the 3,656 symbols in OpenGL.GL into smaller
> modules, without dividing them up along some random or
> arbitrary lines?
In that particular case, I wouldn't, except pos
On Fri, Mar 18, 2016 at 8:56 AM, Random832 wrote:
> On Fri, Mar 18, 2016, at 03:00, Ian Kelly wrote:
>> jmf has been asked this before, and as I recall he seems to feel that
>> UTF-8 should be used for all purposes, ignoring the limitations of
>> that encoding such as that i
On Fri, Mar 18, 2016 at 10:44 AM, Steven D'Aprano wrote:
> On Sat, 19 Mar 2016 02:31 am, Random832 wrote:
>
>> On Fri, Mar 18, 2016, at 11:17, Ian Kelly wrote:
>>> If the string is simple UCS-2, that's easy.
>
> Hmmm, well, nobody uses UCS-2 any more, since th
On Fri, Mar 18, 2016 at 3:19 PM, Mark Lawrence wrote:
>
> I have no idea at what the above can mean, other than that you are agreeing
> with the RUE.
Mark, are you aware that this is a rather classic ad hominem of guilt
by association? "I didn't pay any attention to your actual argument,
but you
On Fri, Mar 18, 2016 at 6:37 AM, Chris Angelico wrote:
> On Fri, Mar 18, 2016 at 10:46 PM, Steven D'Aprano wrote:
>> Technically, UTF-8 doesn't *necessarily* imply indexing is O(n). For
>> instance, your UTF-8 string might consist of an array of bytes containing
>> the string, plus an array of in
On Thu, Mar 17, 2016 at 1:21 PM, Rick Johnson
wrote:
> In the event that i change my mind about Unicode, and/or for
> the sake of others, who may want to know, please provide a
> list of languages that *YOU* think handle Unicode better than
> Python, starting with the best first. Thanks.
jmf has
On Fri, Mar 18, 2016 at 5:49 AM, Sven R. Kunze wrote:
> Hi,
>
> we got an interesting problem. We need to monkeypatch Django's reverse
> function:
>
>
> First approach:
>
> urlresolvers.reverse = patched_reverse
>
>
> Problem: some of Django's internal modules import urlresolvers.reverse
> before
On Fri, Mar 18, 2016 at 9:01 AM, Sven R. Kunze wrote:
> On 18.03.2016 15:48, Ian Kelly wrote:
>>
>> Well I didn't design it, so I'm not really sure. But it could be argued
>> that the defaults are intrinsic to the function declaration, not the code
>> obje
On Mar 18, 2016 8:33 AM, "Sven R. Kunze" wrote:
>
> On 18.03.2016 14:47, Ian Kelly wrote:
>>
>> Your patched version takes two extra arguments. Did you add the
>> defaults for those to the function's __defaults__ attribute?
>
>
> That's it!
On Fri, Mar 18, 2016 at 7:47 AM, Ian Kelly wrote:
> Your patched version takes two extra arguments. Did you add the
> defaults for those to the function's __defaults__ attribute?
And as an afterthought, you'll likely need to replace the function's
__globals__ with your o
On Mon, Mar 21, 2016 at 9:38 AM, Joseph L. Casale
wrote:
> With non static properties, you can use a decorator that overwrites the
> method on the instance with an attribute containing the methods return
> effectively caching it.
Can you give an example of what you mean?
> What technique for a s
On Mon, Mar 21, 2016 at 10:36 AM, Steven D'Aprano wrote:
> On Tue, 22 Mar 2016 03:15 am, Ian Kelly wrote:
>> Why not do the same thing but using a class attribute instead of an
>> instance attribute?
>
> Properties don't work when called from a class:
Prop
On Mon, Mar 21, 2016 at 10:54 AM, Chris Angelico wrote:
> On Tue, Mar 22, 2016 at 3:49 AM, Joseph L. Casale
> wrote:
>> Right, but _private refers to an api call that is expensive and may not even
>> be accessed,
>> so while I may new up three instances of Test across a, b and c, if none of
>>
On Mon, Mar 21, 2016 at 4:25 AM, Michael Welle wrote:
> Hello,
>
> I use a multiprocessing pool. My producer calls pool.map_async()
> to fill the pool's job queue. It can do that quite fast, while the
> consumer processes need much more time to empty the job queue. Since the
> producer can create
On Mon, Mar 21, 2016 at 2:03 PM, Ben Bacarisse wrote:
> For experts here: why can't I write a lambda that has a statement in it
> (actually I wanted two: lambda l, i: l[i] += 1; return l)?
https://docs.python.org/3/faq/design.html#why-can-t-lambda-expressions-contain-statements
--
https://mail.p
On Mon, Mar 21, 2016 at 2:12 PM, Ian Kelly wrote:
> On Mon, Mar 21, 2016 at 2:03 PM, Ben Bacarisse wrote:
>> For experts here: why can't I write a lambda that has a statement in it
>> (actually I wanted two: lambda l, i: l[i] += 1; return l)?
>
> https://docs.python.org
On Mon, Mar 21, 2016 at 1:46 PM, Michael Welle wrote:
> Wait on the result means to set a multiprocessing.Event if one of the
> consumers finds the sentinel task and wait for it on the producer? Hmm,
> that might be better than incrementing a counter. But still, it couples
> the consumers and the
On Mon, Mar 21, 2016 at 6:05 PM, Steven D'Aprano wrote:
> On Tue, 22 Mar 2016 04:48 am, Ian Kelly wrote:
>
>> You don't actually need a metaclass for this:
>>
>>>>> class Desc:
>> ... def __get__(self, obj, type=None):
>> ...
On Thu, Mar 24, 2016 at 4:58 PM, Mark Lawrence wrote:
> No. While this idiot, BartC, is let loose on this forum, I'll say what I
> like.
Good to know. I've been on the fence about this for a long time, but
lately the frequency of your outbursts seems to have increased, and
you're being more of a
On Thu, Oct 23, 2014 at 1:20 AM, Mark Lawrence wrote:
> If you were to read and digest what is written it would help. You're trying
> to run IDLE. We're talking the interactive interpreter.
IDLE includes the interactive interpreter.
> If (at least on
> Windows) you run a command prompt and th
On Thu, Oct 23, 2014 at 7:44 AM, Marko Rauhamaa wrote:
> However, the "[f, g][cond]()" technique is how pure lambda calculus
> implements conditional branching so it is interesting in its own right.
I wasn't aware that lambda calculus had lists and indexing built in.
> IOW, you can do "short-cir
On Thu, Oct 23, 2014 at 8:30 AM, Simon Kennedy wrote:
> Just out of academic interest, is there somewhere in the Python docs where
> the following is explained?
https://docs.python.org/3/reference/expressions.html#booleans
3 == True
> False
if 3:
> print("It's Twue")
>
> It's
On Thu, Oct 23, 2014 at 11:07 AM, Seymore4Head
wrote:
> BTW I forgot to add that example 2 and 3 don't seem to be too useful
> in Python 3, but they are in Python 2. I don't understand how the
> Python 3 is an improved version.
In Python 2, range returns a list containing all the requested
eleme
On Fri, Oct 24, 2014 at 9:56 AM, Rustom Mody wrote:
>> Range(10) stores the min max values and loads each number in between
>> when needed.
>
> It loads?? As in 'load-up-a-van'??
As in loads into memory.
> When you see:
>
10
> 10
>
> 1. Does someone (a clerk maybe) in the computer count to
On Fri, Oct 24, 2014 at 10:37 AM, Seymore4Head
wrote:
> If I could explain to you why something doesn't work then I could fix
> it myself. I don't understand why it doesn't work. The best I can do
> is repost the code.
You don't need to be able to explain why it doesn't work. You just
need to b
On Fri, Oct 24, 2014 at 11:03 AM, Seymore4Head
wrote:
> Actually I was a little frustrated when I added that line back in as
> the other lines all work.
> Using list(range(10)) Doesn't throw an error but it doesn't work.
>
> http://i.imgur.com/DTc5zoL.jpg
>
> The interpreter. I don't know how to
On Fri, Oct 24, 2014 at 7:07 AM, Steven D'Aprano
>> if j < 10:
>> j += 1
>> else:
>> j = 3
>>
>> or:
>>
>> j = j + 1 if j < 10 else 3
>>
>> or:
>>
>> j = (lambda: 3, lambda: j + 1)[j < 10]()
>
> Certainly not the third one. That's needlessly obfuscated for the sake
On Fri, Oct 24, 2014 at 2:58 PM, Seymore4Head
wrote:
> name="123-xyz-abc"
> for x in name:
> if x in range(10):
> print ("Range",(x))
> if x in str(range(10)):
> print ("String range",(x))
>
> It doesn't throw an error but it doesn't print what you would expect.
That print
On Sat, Oct 25, 2014 at 5:58 AM, Ned Batchelder wrote:
> You mention "standard Python idioms." I think this style of
> conditional-via-indexing is becoming quite uncommon, and is no longer one of
> the standard Python idioms. This is now in the category of "outdated hack."
I think that's probab
On Sat, Oct 25, 2014 at 12:46 AM, Larry Hudson
wrote:
>> name="123-xyz-abc"
>> for x in name:
>> if x in range(10):
>
> x is a character (a one-element string). range(10) is a list of ints. A
> string will never match an int. BTW, as it is used here, range(10) is for
> Py2, for Py3 it need
On Mon, Oct 27, 2014 at 10:17 AM, Wolfgang Maier
wrote:
> See
> https://docs.python.org/3/library/stdtypes.html?highlight=list#common-sequence-operations
> under Note 2 .
>
> Also asked and answered multiple times at stackoverflow, e.g.,
> http://stackoverflow.com/questions/6688223/
Also see
htt
On Thu, Oct 30, 2014 at 11:01 AM, Rustom Mody wrote:
> On Wednesday, October 29, 2014 11:49:27 AM UTC+5:30, Zachary Ware wrote:
>> On Wed, Oct 29, 2014 at 1:11 AM, Rustom Mody wrote:
>> > On Wednesday, October 29, 2014 11:10:06 AM UTC+5:30, Zachary Ware wrote:
>> >> Of course, that's 3 (progressiv
On Thu, Oct 30, 2014 at 11:09 AM, Ian Kelly wrote:
> On Thu, Oct 30, 2014 at 11:01 AM, Rustom Mody wrote:
>> On Wednesday, October 29, 2014 11:49:27 AM UTC+5:30, Zachary Ware wrote:
>>> On Wed, Oct 29, 2014 at 1:11 AM, Rustom Mody wrote:
>>> > On Wednesday, October
On Fri, Oct 31, 2014 at 8:05 AM, Seymore4Head
wrote:
> Because the topic of that lesson was getter setter.
> I can construct an __init___ but I was practicing get/set.
Doesn't sound like a very good lesson to me. Getters and setters are
the Java way of doing things. The Pythonic way is to just u
On Fri, Oct 31, 2014 at 7:06 PM, Steven D'Aprano
wrote:
> And there are times when using getters and setters is the right choice.
> Properties should only be used for quite lightweight calculations, because
> attribute access is supposed to be fast. If your calculation is complex,
> time-consuming
On Nov 2, 2014 5:31 AM, "Denis McMahon" wrote:
> And perhaps that also addresses the square - rectangle (or circle -
> ellipse) issue - square, rectangle and rhombus are all forms of
> quadrilateral, and perhaps should all inherit a base class Quadrilateral,
> rather than trying (and partially fai
On Nov 6, 2014 1:06 AM, "Rustom Mody" wrote:
> In studying (somewhat theoretically) the general world of
> collection data structures we see
> - sets -- neither order nor repetition
> - bags -- no order, repetition significant
> - lists -- both order and repetition
>
> Sometimes 'bag' is called
On Nov 6, 2014 10:47 PM, "Sturla Molden" wrote:
>
> Grant Edwards wrote:
> > According to
> >
http://www.theregister.co.uk/2014/11/06/hackers_use_gmail_drafts_as_dead_drops_to_control_malware_bots
:
> >
> > "Attacks occur in two phases. Hackers first infect a targeted
> >machine via simple
On Nov 6, 2014 10:51 AM, "Ian Kelly" wrote:
>
> On Nov 6, 2014 1:06 AM, "Rustom Mody" wrote:
> > Calling a bag as counter is inappropriate for an analogous reason
> > to why calling a dictionary as a 'hash' is inappropriate --
> > it confu
On Sun, Nov 9, 2014 at 2:06 AM, Veek M wrote:
> https://docs.python.org/3.4/library/functools.html
>
> 1. "A key function is a callable that accepts one argument and returns
> another value indicating the position in the desired collation sequence."
>
> x = ['x','z','q']; sort(key=str.upper)
This
On Mon, Nov 10, 2014 at 12:19 PM, Peter Otten <__pete...@web.de> wrote:
> I'm not sure this works. I tried:
Here's a simpler failure case.
>>> ineq = """f2 > f3
... f3 > f1"""
[Previously posted code elided]
>>> greater_thans
set([('f3', 'f1'), ('f2', 'f3')])
>>> sorted(all_f, cmp=lambda t1, t2
On Mon, Nov 10, 2014 at 2:45 PM, wrote:
> On Monday, November 10, 2014 1:01:05 PM UTC-8, Grant Edwards wrote:
>> On 2014-11-10, sohcahtoa82 wrote:
>>
>> > Please help me this assignment is due in an hour. Don't give me
>> > hints, just give me the answer because I only want a grade. I'm not
>>
1701 - 1800 of 3558 matches
Mail list logo