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
On Mon, Nov 17, 2014 at 3:17 PM, Dave Angel wrote:
> "Charles T. Smith" Wrote in message:
>
>> Well, I guess that's the definitive answer... the tips for delaying
>> import are good, I'll try to leverage them.
>>
>> I was hoping there would be a way to have python postpone evaluation
>> similar t
On Mon, Nov 17, 2014 at 6:20 PM, Dave Angel wrote:
> Ian Kelly Wrote in message:
>> On Mon, Nov 17, 2014 at 3:17 PM, Dave Angel wrote:
>
>>> In a module that might get tangled in a cycle, avoid global code
>>> that depends on other modules. Instead of putting s
On Thu, Nov 20, 2014 at 10:42 AM, wrote:
> and it means you can't safely
> blindly use %s with an unknown object.
You can't safely do this anyway. Whether it's %s with a str and a
unicode, or %s with a unicode and a str, *something* is going to have
to be implicitly encoded or decoded, and if as
On Thu, Nov 20, 2014 at 11:06 AM, Ian Kelly wrote:
> On Thu, Nov 20, 2014 at 10:42 AM, wrote:
>> and it means you can't safely
>> blindly use %s with an unknown object.
>
> You can't safely do this anyway. Whether it's %s with a str and a
> unicode, or
On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote:
> There's also the E-factory for creating (sub-)trees and a nicely objectish
> way:
>
> http://lxml.de/lxmlhtml.html#creating-html-with-the-e-factory
That looks ugly with all those caps and also hard to extend. Notably
it seems to be missing
On Thu, Nov 20, 2014 at 1:13 PM, Dave Angel wrote:
> dave em Wrote in message:
>> 1. In the factorial() function we call the CPU_Percent() function and write
>> the CPU utilization value to a file.
>> - Is this a correct value or will the CPU utilization below lower because
>> the factorial()
On Thu, Nov 20, 2014 at 1:10 PM, Stefan Behnel wrote:
> Ian Kelly schrieb am 20.11.2014 um 20:44:
>> On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote:
>>> There's also the E-factory for creating (sub-)trees and a nicely objectish
>>> way:
>>>
>&
On Thu, Nov 20, 2014 at 8:53 PM, Rick Johnson
wrote:
> FOR INSTANCE: Let's say i write a module that presents a
> reusable GUI calendar widget, and then i name the module
> "calender.py".
>
> Then Later, when i try to import *MY* GUI widget named
> "calendar", i will not get *MY* calendar widget,
On Thu, Nov 20, 2014 at 10:54 PM, Gill Shen wrote:
> How is this behavior implemented under the hood? And why is this allowed at
> all? Is it just a curiosity or can you do something useful with it?
Reference cycles are common in Python and other OO languages. For
example, adding a widget to a w
On Fri, Nov 21, 2014 at 9:12 AM, Tim Chase
wrote:
> The only time I've been stung by name overloading is in the indirect
> case of creating a local email.py file and then importing smtplib
> only to have things break in unforeseen ways. If smtplib used
> relative imports for $STDLIB/email.py I su
On Fri, Nov 21, 2014 at 10:39 AM, wrote:
> On Fri, Nov 21, 2014, at 02:00, Marko Rauhamaa wrote:
>> Gill Shen :
>>
>> > How is this [nesting] behavior implemented under the hood?
>>
>> Pointers.
>>
>> > And why is this allowed at all?
>>
>> There's no reason not to.
>
> There's no reason not to a
On Fri, Nov 21, 2014 at 11:24 AM, Rick Johnson
wrote:
> Are you also going to call drivers "fools" because they bought
> a "certain brand" of car only to have the airbag explode in
> their face?
No, but I'll call them fools if they buy a car and the engine catches
fire because they never bothered
On Fri, Nov 21, 2014 at 3:25 PM, Rick Johnson
wrote:
>> The only exception is if you're doing "import calendar" from inside
>> the ricklib package, and you're using Python 2, and you don't have
>> "from __future__ import absolute_import" at the top of your module.
>> The solution to this is easy:
On Fri, Nov 21, 2014 at 6:07 PM, Rick Johnson
wrote:
> On Friday, November 21, 2014 5:59:44 PM UTC-6, Chris Angelico wrote:
>> In other words, what you want is:
>>
>> # today's method, import based on search path
>> import sys
>> # new explicit path method
>> import '/usr/local/lib/python3.5/lib-d
On Sat, Nov 22, 2014 at 11:49 PM, Patrick Stinson wrote:
> If I create a module with imp.new_module(name), how can I unload it so that
> all the references contained in it are set to zero and the module is deleted?
> deleting the reference that is returned doesn’t seem to do the job, and it’s
>
On Sun, Nov 23, 2014 at 2:48 AM, Ian Kelly wrote:
> On Sat, Nov 22, 2014 at 11:49 PM, Patrick Stinson
> wrote:
>> If I create a module with imp.new_module(name), how can I unload it so that
>> all the references contained in it are set to zero and the module is
>&g
On Nov 23, 2014 4:10 AM, "Patrick Stinson" wrote:
> m = types.ModuleType('mine')
> exec(s, m.__dict__)
> print('deleting...')
> m = None
> print('done')
>
> and the output is:
>
> deleting...
> done
> __del__
>
> I the “__del__" to come between “deleting…” and “done”. This is not being
run from th
On Nov 24, 2014 1:27 AM, "Patrick Stinson" wrote:
>
> How does the __del__ method have a reference to the module’s globals
dict? because it references the print function?
The module's dict becomes the __globals__ dict used by the function for
looking up globals and builtins.
> Crazy. Is there an
On Nov 21, 2014 10:09 PM, "Michael Torrie" wrote:
> I can't speak for wxWidgets, but when I last looked at it years ago it
> fairly reeked of MFC-style GUI programming with event tables instead of
> a nice, flexible signal/callback interface. Has this changed?
I recall the C++ implementation use
On Nov 23, 2014 4:41 PM, "Gregory Ewing"
wrote:
>
> Chris Angelico wrote:
>>
>> Just out of curiosity, why does the stdlib need modules for
>> manipulating .wav and other sound files, but we have to go to PyPI to
>> get a PostgreSQL client?
>
>
> I suspect it's mainly for historical reasons. The w
On Nov 27, 2014 4:26 AM, "Frank Millman" wrote:
> All Python database adaptors that I have used start a transaction when you
> open a cursor. I have just re-read DB-API 2.0, and I cannot see anything
> that specifies this behaviour, but AFAICT this is what happens.
I don't know how others work, b
On Nov 27, 2014 4:39 PM, "Chris Angelico" wrote:
>
> On Fri, Nov 28, 2014 at 5:02 AM, Ian Kelly wrote:
> > On Nov 27, 2014 4:26 AM, "Frank Millman" wrote:
> >> All Python database adaptors that I have used start a transaction when
you
> >> op
On Mon, Dec 1, 2014 at 11:05 AM, Larry Martell wrote:
> Is there a way to set the default_factory of defaultdict so that
> accesses to undefined keys get to set to the key?
>
> i.e. if d['xxx'] were accessed and there was no key 'xxx' then
> d['xxx'] would get set to 'xxx'
>
> I know I can define
On Mon, Dec 1, 2014 at 11:29 AM, Larry Martell wrote:
> I spoke too soon:
>
class defaultdictkey(defaultdict):
> ... def __missing__(self, key):
> ... self[key] = self.default_factory(key)
> ...
x = defaultdictkey(lambda k: k)
print x['aaa']
> None
print x['aaa']
> aaa
On Dec 3, 2014 4:34 AM, "Chris Angelico" wrote:
>
> On Wed, Dec 3, 2014 at 10:27 PM, Peter Otten <__pete...@web.de> wrote:
> > Don't repeat yourself, so
> >
> > from os import path
> >
> > always. On the other hand I have never thought about actual renames, e.
g.
> >
> > from os import path as std
On Wed, Dec 3, 2014 at 5:28 AM, Gregory Ewing
wrote:
>
> Kasper Peeters wrote:
>>
>> That may have been the design plan, but in Python 2.7.6, I definitely
>> am able to inject locals via PyEval_GetLocals() and have them be visible
>> both from the C and Python side;
>
> What seems to be happening
On Dec 4, 2014 8:56 AM, "Marko Rauhamaa" wrote:
>
> "ast" :
>
> > Does any body know when time.monotonic() rolls over ?
>
> Never, according to the documentation you linked.
>
> Admittedly, the documentation confuses the reader by chatting about some
> irrelevant internal Windows details.
Not ent
On Thu, Dec 4, 2014 at 11:09 AM, Marko Rauhamaa wrote:
>
> Chris Angelico :
>
> > It's not a Python issue. Python can't do anything more than ask the
> > system, and if the system's value rolls over several times a year,
> > Python can't magically cure that. The information has already been
> > lo
On Thu, Dec 4, 2014 at 1:09 PM, LJ wrote:
>
> Hi All,
>
> I have a quick question regarding the modification of global variables
within functions. To illustrate, consider the following toy example:
>
> a={"1": set()}
> b=9
>
> def gt(l):
>a["1"] = a["1"] | set([l])
>
> When calling this last f
On Thu, Dec 4, 2014 at 1:24 PM, Akira Li <4kir4...@gmail.com> wrote:
>
> Ian Kelly writes:
> > This seems like a lot of effort to unreliably design around a problem
that
> > will matter to only a tiny fraction of users.
>
> - people's computers are mo
On Thu, Dec 4, 2014 at 3:44 PM, Marko Rauhamaa wrote:
>
> Ian Kelly :
>
> > It's not clear to me whether those cases are relevant to the rollover
> > concern anyway. I wouldn't be shocked if the GetTickCount() function
> > simply stopped increasing while
On Fri, Dec 5, 2014 at 10:31 AM, wrote:
>
> Hi Guys,
>
> I am trying to combine string and dict in the print statement, however
getting an error. Would someone let me know what will be correct way to do
that.
>
> stats={'lname': 'shah', 'fname': 'gaurang'}
> a=test
>
> print "%s %(fname)s %(lname)
On Fri, Dec 5, 2014 at 10:40 AM, Aahan Krish wrote:
> Q2. PEP 8 also reads, "Python 3 disallows mixing the use of tabs and
spaces for indentation."
>
> So, if I am using tabs for indentation and spaces for alignment, is it
still considered "mixing the use of tabs and spaces" in Python 3? (Please
s
On Fri, Dec 5, 2014 at 11:49 AM, Aahan Krish wrote:
>
> Hello Ian,
>
> So, wrt Q2, what you are saying is, the following would cause issues in
Python 3?
>
> int f(int x,
> ..int y) {
> --->return g(x,
> --->.y);
> }
>
> Where:
>
> ---> for tabs (used for indentation
On Fri, Dec 5, 2014 at 4:30 AM, Fetchinson .
wrote:
> > The formatting of long text essays get completely mangled towards the
> > bottom
> > of the page, e.g.:
> >
> > https://www.python.org/download/releases/2.2/descrintro
>
> It doesn't look mangled to me (firefox 22).
That's quite old at this
On Fri, Dec 5, 2014 at 3:43 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:
> It requires Javascript or else basic functionality fails.
In what way does basic functionality fail? I just tried loading the page
with Javascript disabled and it seemed fine.
> With Javascript,
> bas
On Dec 7, 2014 9:33 AM, "Dave Angel" wrote:
>
> On 12/05/2014 03:51 PM, John J Posner wrote:
>>
>> At the beginning of this thread, Ian Kelly said:
>
>
> Since this clearly is intended to be part of the earlier thread, please
make it so by using reply-l
On Dec 7, 2014 8:31 AM, "Ned Batchelder" wrote:
> NOTE: THIS EXAMPLE IS HORRIBLE. This code is crazy-confusing, and should
never have been used as an example of iteration. It layers at least three
iterations on top of each other, making it very difficult to see what is
going on. It uses "while i
On Sun, Dec 7, 2014 at 9:50 AM, sam pendleton wrote:
> Having to put the garage package on the sys.path seems a little off,
> why wouldn't relative imports work?
Relative imports are relative to a package's hierarchy of namespaces, not
relative to the file system. As such, you can't perform a rel
On Fri, Dec 5, 2014 at 4:30 AM, Fetchinson .
wrote:
> > Many links are broken. When you click on the broken link, it says that
it
> > has been reported and will be fixed, but weeks later it remains broken,
> > e.g.:
> >
> > https://www.python.org/doc/essays/metaclasses/Eiffel.py
>
> What makes you
On Tue, Dec 9, 2014 at 11:30 PM, Chris Angelico wrote:
> Are you sure it isn't? Your 'space' is an iterable cubic
> cross-product. Your first loop checks (0,0,0) which is the first
> element returned, and is thus fast... but it also *consumes* that
> first element. The next time you test it, the e
On Wed, Dec 10, 2014 at 1:21 AM, Peter Otten <__pete...@web.de> wrote:
>
> Ian Kelly wrote:
> > Huh, I wasn't even aware that membership tests worked on iterables with
no
> > __contains__ method. Seems odd to me that 'x in y' should be supported
but
>
On Wed, Dec 10, 2014 at 9:01 AM, Ian Kelly wrote:
> This also seems perfectly natural:
>
> def len(iterable):
> return sum(1 for item in iterable)
>
> My observation is that seems strange to me that one standard sequence
operation should be supported for arbitrary iterators
On Wed, Dec 10, 2014 at 9:10 AM, Jean-Michel Pichavant <
jeanmic...@sequans.com> wrote:
> If you like one-liners,
>
> def __init__(self, center=(0,0), radius=10, mass=None):
> self.center = center
> self.radius = radius
> self.mass = (mass is None and radius**2) or mass
If mass is None
On Wed, Dec 10, 2014 at 2:24 AM, Steven D'Aprano
wrote:
>
> Example: In the statistics module in Python 3.4, I added a `median`
> function to calculate the median by the traditional schoolbook algorithm.
> But that's only one out of a number of ways to calculate medium, and
> inspired by similar s
On Wed, Dec 10, 2014 at 10:48 AM, Terry Reedy wrote:
>> Likewise the generated help for the help() function,
>> unless care is taken to explicitly mention the existence of those
>> functions in either the doc string for the module
>
>
> help(it.chain) lists
> | from_iterable(...) from builtins.t
On Tue, Dec 9, 2014 at 10:16 PM, Cameron Simpson wrote:
> - the AA menu buttons are all dysfunctional, being purely javascript; it
would be better if the menu was styled "display=none" by default, and made
visible by javascript
With Javascript enabled, the AA menu buttons don't seem to be displa
On Thu, Dec 11, 2014 at 3:02 AM, Jean-Michel Pichavant <
jeanmic...@sequans.com> wrote:
> I would advise to remove the the mass parameter of your Sphere
initialization. It could be inconsistent with the radius.
> To compute the mass you would need the radius and the volumetric mass
density.
You a
On Thu, Dec 11, 2014 at 11:03 AM, Ian Kelly wrote:
>
> On Thu, Dec 11, 2014 at 3:02 AM, Jean-Michel Pichavant <
jeanmic...@sequans.com> wrote:
> > I would advise to remove the the mass parameter of your Sphere
initialization. It could be inconsistent with the radius.
> >
On Wed, Dec 10, 2014 at 9:01 PM, Steven D'Aprano
wrote:
>
> On Wed, 10 Dec 2014 09:46:55 -0700, Ian Kelly wrote:
>
> > I don't particularly have a problem with functions having attributes,
> > e.g. I think itertools.chain.from_iterable is just peachy. There is a
>
On Thu, Dec 11, 2014 at 4:28 PM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:
>
> Ian Kelly wrote:
>
> > A function, on the
> > other hand, is not well suited to be a namespace, because it's not
> > expected to provide one.
>
>
On Thu, Dec 11, 2014 at 6:55 PM, Roy Smith wrote:
>
> In article ,
> Ian Kelly wrote:
>
> > I never said that functions can't be used as namespaces. I said that
> > functions are *bad* namespaces, and I gave reasons why I think this is
true.
>
> An excel
On Mon, Dec 15, 2014 at 10:46 PM, Jason Swails
wrote:
>
> This was a problem posed to me, which I solved in Python. I thought it
was neat and enjoyed the exercise of working through it; feel free to
ignore. For people looking for little projects to practice their skills
with (or a simple distrac
On Tue, Dec 16, 2014 at 9:57 AM, Jacob Kruger wrote:
>
> Would prefer to use something free, that could work somewhat
cross-platform, but, my primary target is for windows OS, and would
primarily just want to be able to easily trigger playback of either .wav or
.mp3 background sound effects, but,
On Tue, Dec 16, 2014 at 11:30 PM, Abubakar Roko
wrote:
>
> Good day,
>
> Please I am new in using python to write program. I am trying to parse an
XML document using sax parse and store the parsed result in a tree like
defined
> below. XNode class define an xml element which has an ID , a tag, a
On Thu, Dec 18, 2014 at 5:37 AM, Juan Christian
wrote:
> I read the cron doc, it's really simple to use, but one think I didn't
see out-of-the-box is a way to set a random time, like 'execute this in a
5~10 min interval', I can only set specific times like 'execute this each
minute, each hour, eac
On Mon, Dec 22, 2014 at 2:21 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:
> > (b) * Is there anything that I need to consider while using list
> > comprehension with threads ?*
>
> That depends on what you mean by "using list comprehension with threads".
>
> If you mean "use
On Dec 22, 2014 2:37 PM, "Dave Angel" wrote:
>
> I'll pick on one function first, called instructions(). If the user
types something invalid, you print "Invalid input." and call the function
again. In this case, because the call is at the end, no harm is usually
done, but it would be tricky to e
On Dec 22, 2014 6:06 PM, wrote:
>
> Huh...there actually is a limit of about 1,000. I'm assuming this is
hard-coded? I did a similar test with Java a while back and was getting
different results every time.
The default is 1000 but it can be configured with sys.setrecursionlimit. I
think Java on
On Tue, Dec 23, 2014 at 11:55 AM, Seb wrote:
>
> Hi,
>
> I'm fairly new to Python, and while trying to implement a custom sliding
> window operation for a pandas Series, I came across a great piece of
> code¹:
>
> >>> def n_grams(a, n):
> ... z = (islice(a, i, None) for i in range(n))
> ...
On Sat, Dec 20, 2014 at 9:34 AM, John Culleton
wrote:
>
> This week I wrote my first Python program, a script callable from
Scribus, a DTP program. It ran! Now I want to spread my wings a little. How
do I call a C language executable subprogram from Python and pass
information back and forth?
Whe
On Wed, Dec 24, 2014 at 4:22 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:
> What happens here is that you time a piece of code to:
>
> - Build a large list containing 100 million individual int objects. Each
int
> object has to be allocated at run time, as does the list. Each
On Wed, Dec 24, 2014 at 1:34 PM, Rustom Mody wrote:
> +1 for the slice in succinct form
Not only more succinct but also more correct. The purpose of islice is to
slice arbitrary iterables as opposed to just sequences. But this function
requires a reentrant iterable anyway and returns garbage if y
On Thu, Dec 25, 2014 at 8:18 AM, JC wrote:
>
> Hello,
>
> Is it possible in python:
>
> if ((x = a(b,c)) == 'TRUE'):
> print x
No, assignments in Python are statements, not expressions.
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, Dec 24, 2014 at 5:21 AM, Rustom Mody wrote:
> On Tuesday, December 23, 2014 6:30:30 PM UTC+5:30, shawool wrote:
>> Thank you for answering my query.
>>
>> Fonts and colors are reset to defaults now. Sorry for the inconvenience
>> caused.
>>
>> Regards,
>> Shawool
>
> Sorry for the peevish
On Mon, Dec 29, 2014 at 9:28 AM, Chris Angelico wrote:
> Why is sre_constants segfaulting?! It's such a simple file! I assume
> the "matches" comment means it thinks there's no problem with the .pyc
> file; is it possible that, despite those checks, there's an issue
> there? I could delete the .py
On Mon, Dec 29, 2014 at 7:05 PM, Chris Angelico wrote:
> Are .pyc files compatible across revisions? Could I carry this file to
> a 2.7.9 and see if the crash still happens?
PEP 6 requires that .pyc files for a particular major release must
work with all the bug fix releases for that version.
--
On Mon, Dec 29, 2014 at 11:34 PM, Ian Kelly wrote:
> On Mon, Dec 29, 2014 at 7:05 PM, Chris Angelico wrote:
>> Are .pyc files compatible across revisions? Could I carry this file to
>> a 2.7.9 and see if the crash still happens?
>
> PEP 6 requires that .pyc files for a par
On Wed, Jan 7, 2015 at 1:12 PM, John Ladasky wrote:
> Do I need to "import my_svr.model as model" then? Adding that line changes
> nothing. I get the exact same "ImportError: No module named 'model'".
>
> Likewise for "import my_svr", "from my_svr import *", or even "from
> my_svr.model import
On Thu, Jan 8, 2015 at 7:15 AM, maurog wrote:
> I'm running some pandas examples and I canno find in what module NaN is
> defined. Does anyone know what module I have to import in order to have
> it defined?
It's not defined anywhere. To get nan as a literal just do:
nan = float("nan")
--
h
On Thu, Jan 8, 2015 at 5:11 AM, Chris Angelico wrote:
> As yield is an expression, it's legal in a lambda function, which then
> means you have a generator function. But it's not quite the same as
> the equivalent function made with def:
>
> $ python3
> Python 3.5.0a0 (default:1c51f1650c42+, Dec 2
On Wed, Jan 7, 2015 at 11:21 PM, Marko Rauhamaa wrote:
> Steven D'Aprano :
>
>> Marko Rauhamaa wrote:
>>> I prefer the Scheme way:
>>>#f is a falsey object
>>>everything else is a truthy object
>>
>> The Scheme way has no underlying model of what truthiness represents, just
>> an arbitrary
On Thu, Jan 8, 2015 at 10:56 AM, Rustom Mody wrote:
> Given a matrix I want to shift the 1st column 0 (ie leave as is)
> 2nd by one place, 3rd by 2 places etc.
>
> This code works.
> But I wonder if numpy can do it shorter and simpler.
>
> -
> def transpose(mat):
> return(
1801 - 1900 of 3558 matches
Mail list logo