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
>>
On Mon, Nov 10, 2014 at 8:09 PM, Paddy wrote:
> On Monday, 10 November 2014 18:45:15 UTC, Paddy wrote:
>> Hi, I do agree with
>> Raymond H. about the relative merits of cmp= and key= in
>> sort/sorted, but I decided to als
On Sat, Nov 8, 2014 at 3:31 PM, Gregory Ewing
wrote:
> (BTW, I'm actually surprised that this technique makes c callable.
> There must be more going on that just "look up __call__ in the class
> object", because evaluating C.__call__ just returns the descriptor
> and doesn't invoking the descripto
On Tue, Nov 11, 2014 at 12:44 AM, Paddy wrote:
> Thanks Ian. The original author states "...and it is sure that the given
> inputs will give an output, i.e., the inputs will always be valid.", which
> could be taken as meaning that all inputs are sufficient, well formed, and
> contain all relat
On Tue, Nov 11, 2014 at 2:21 AM, Paddy wrote:
> On Tuesday, 11 November 2014 09:07:14 UTC, Ian wrote:
>> On Tue, Nov 11, 2014 at 12:44 AM, Paddy wrote:
>> > Thanks Ian. The original author states "...and it is sure that the given
>> > inputs will give an output, i.e., the inputs will always be
On Tue, Nov 11, 2014 at 9:53 AM, Mary-Frances McNamee <
maryfrances.mcna...@epas-ltd.com> wrote:
>
> I am currently working on a bit of coding for a raspberry pi, I was
wondering maybe I could get some advice? I want my program to run for a
certain time, for example 7am-2.30am everyday. Is this pos
On Wed, Nov 12, 2014 at 8:33 AM, Fabio Zadrozny wrote:
> As a reference, I recently found a blog post related to that:
> http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/ (the Slots
> part comments on that).
>
> It does seem a bit counter-intuitive that this happens the way it does
On Wed, Nov 12, 2014 at 2:33 PM, Chris Kaynor wrote:
> A decorator is an interesting idea, and should be easy to implement (only
> lightly tested):
>
> def main(func):
> if func.__module__ == "__main__":
> func()
> return func # The return could be omitted to block the function
On Wed, Nov 12, 2014 at 2:56 PM, Marko Rauhamaa wrote:
> Ethan Furman :
>
>> On 11/12/2014 01:41 PM, Marko Rauhamaa wrote:
>>>
>>> Or I might indicate the exhaustion of possibilities:
>>>
>>> if status == OK:
>>> ...
>>> elif status == ERROR:
>>> ...
>>> else:
On Wed, Nov 12, 2014 at 3:04 PM, Ian Kelly wrote:
> On Wed, Nov 12, 2014 at 2:56 PM, Marko Rauhamaa wrote:
>> How would it be better if you removed the assert then?
>
> You don't need to remove it. Just reorganize it to make sure it
> indicates actual exhaustion of possib
On Wed, Nov 12, 2014 at 3:09 PM, Chris Kaynor wrote:
> I was thinking along the lines of replacing:
>
> if __name__ == "__main__":
> <<>>
>
> with
>
> @main
> def myFunction()
> <<<>
>
> Both blocks of code will be called at the same time.
99% of the time the content of <<>> is just "main
On Wed, Nov 12, 2014 at 3:13 PM, Anton wrote:
> On Wednesday, November 12, 2014 2:05:17 PM UTC-8, Ian wrote:
>> You don't need to remove it. Just reorganize it to make sure it
>> indicates actual exhaustion of possibilities. E.g. using the "assert
>> False" pattern from your post:
>>
>> if status
On Wed, Nov 12, 2014 at 3:48 PM, Anton wrote:
> On Wednesday, November 12, 2014 2:42:19 PM UTC-8, Ian wrote:
>> On Wed, Nov 12, 2014 at 3:13 PM, Anton wrote:
>> > If the code is run optimized and asserts are ignore CONFUSED statement
>> > would still not be handled and you will not know about it
On Wed, Nov 12, 2014 at 3:47 PM, Marko Rauhamaa wrote:
> Ian Kelly :
>
>> Although to be honest I'd rather use something like "raise
>> RuntimeError('Unreachable code reached')" than "assert False" here. If
>> the expectation is that th
On Thu, Nov 13, 2014 at 11:32 AM, Ethan Furman wrote:
> On 11/12/2014 01:51 PM, Ian Kelly wrote:
>>
>> On Wed, Nov 12, 2014 at 2:33 PM, Chris Kaynor wrote:
>>>
>>> A decorator is an interesting idea, and should be easy to implement (only
>>> lightly te
On Thu, Nov 13, 2014 at 1:44 PM, Skip Montanaro
wrote:
> On Thu, Nov 13, 2014 at 2:33 PM, Ian Kelly wrote:
>> ... other things decorated with atexit.register
>> might actually be called before the main function
>
> I don't think that will happen. The atexit module is d
On Thu, Nov 13, 2014 at 1:53 PM, Skip Montanaro
wrote:
> On Thu, Nov 13, 2014 at 2:44 PM, Skip Montanaro
> wrote:
>> What's not documented is
>> the behavior of calling atexit.register() while atexit._run_exitfuncs
>> is running. That's an implementation detail, and though unlikely to
>> change,
On Fri, Nov 14, 2014 at 12:36 AM, Cameron Simpson wrote:
> On 13Nov2014 15:48, satishmlm...@gmail.com wrote:
>>
>> import sys
>> for stream in (sys.stdin, sys.stdout, sys.stderr):
>> print(stream.fileno())
>>
>>
>> io.UnsupportedOperation: fileno
>>
>> Is there a workaround?
>
>
> The f
On Fri, Nov 14, 2014 at 4:37 AM, Steven D'Aprano
wrote:
> Ethan Furman wrote:
>
>>> There's no way to make the CONFUSED status be handled without actually
>>> changing the code. The difference is that this version will not
>>> incorrectly treat CONFUSED as WARNING; it just won't do anything at
>>>
On Fri, Nov 14, 2014 at 3:17 PM, Richard Riehle wrote:
> In C, C++, Ada, and functional languages, I can create an array of functions,
> albeit with the nastiness of pointers in the C family. For example, an
> array of functions where each function is an active button, or an array of
> functi
On Sat, Nov 15, 2014 at 10:07 AM, ast wrote:
> Hi
>
> I needed a function f(x) which looks like sinus(2pi.x) but faster.
> I wrote this one:
>
> --
> from math import floor
>
> def sinusLite(x):
>x = x - floor(x)
>return -16*(x-0.25)**2 + 1 if x < 0.5 else 16*(x-0.7
On Sun, Nov 16, 2014 at 3:39 AM, Vito De Tullio wrote:
> for the "right time" you can choose to spin a thread and wait to the end of
> the load of the module
Yuck. "Just add threads" is /not/ the answer to everything.
This case looks fairly harmless on the surface, although I could
imagine it br
On Sun, Nov 16, 2014 at 1:07 PM, ryguy7272 wrote:
> When I type 'import math', it seems like my Python recognizes this library.
> Great. When I try to run the following script, I get an error, which
> suggests (to me) the math library is not working correctly.
>
> Script:
> import math
> def m
On Sun, Nov 16, 2014 at 12:36 PM, Abdul Abdul wrote:
> My question is, where did PIL go here? Can a module have another module
> inside it?
Yes, a module that contains other modules is usually called a package.
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, Nov 16, 2014 at 2:45 PM, Abdul Abdul wrote:
> I just came across the following line of code:
>
> outputfile = os.path.splitext(infile)[0] + ".jpg"
>
> Can you kindly explain to me what those parts mean?
>>> import os.path
>>> help(os.path.splitext)
Help on function splitext in module ntpa
On Sun, Nov 16, 2014 at 2:32 PM, Abdul Abdul wrote:
> Hello,
>
> I'm walking through an example that goes as follows:
>
> from PIL import Image
> import os
>
> for inputfile in filelist
> outputfile = os.path.splitext(inputfile)[0]+".jpg"
> if inputfile != outputfile:
> try:
>
On Sun, Nov 16, 2014 at 4:22 PM, Terry Reedy wrote:
> If pylint sees 'map(lambda ...: ', it would be appropriate to suggest using
> a comprehension or generator expression instead. This avoids the unneeded
> creation and repeated call of a new function.
There's actually a separate warning for th
On Sun, Nov 16, 2014 at 1:39 PM, ryguy7272 wrote:
> Anyway, I open the cmd window, and typed this: 'easy_install python
> graphics'. So, it starts up and runs/downloads the appropriate library from
> the web. I get confirmation (in the cmd window) that it finishes, then I try
> to run this sc
1701 - 1800 of 3471 matches
Mail list logo