On Wed, 24 Jul 2013 11:31:58 -0700, Ethan Furman wrote:
> On 07/24/2013 10:23 AM, Stefan Behnel wrote:
>> Peter Otten, 24.07.2013 08:23:
>>> Ethan Furman wrote:
So, my question boils down to: in Python 3 how is dict.keys()
different from dict? What are the use cases?
>>>
>>> To me
On Thu, 25 Jul 2013 04:15:42 +1000, Chris Angelico wrote:
> If nobody had ever thought of doing a multi-format string
> representation, I could well imagine the Python core devs debating
> whether the cost of UTF-32 strings is worth the correctness and
> consistency improvements... and most likely
On Thu, 25 Jul 2013 16:02:42 +1000, Chris Angelico wrote:
> On Thu, Jul 25, 2013 at 3:48 PM, Steven D'Aprano
> wrote:
>> Dicts aren't sets, and don't support set methods:
>>
>> py> d1 - d2
>> Traceback (most recent call last):
>> File &q
On Thu, 25 Jul 2013 17:58:10 +1000, Chris Angelico wrote:
> On Thu, Jul 25, 2013 at 5:15 PM, Steven D'Aprano
> wrote:
>> On Thu, 25 Jul 2013 04:15:42 +1000, Chris Angelico wrote:
>>
>>> If nobody had ever thought of doing a multi-format string
>>> repres
On Thu, 25 Jul 2013 18:15:22 +1000, Chris Angelico wrote:
> On Thu, Jul 25, 2013 at 5:27 PM, Steven D'Aprano
> wrote:
>> On Thu, 25 Jul 2013 16:02:42 +1000, Chris Angelico wrote:
>>
>>> On Thu, Jul 25, 2013 at 3:48 PM, Steven D'Aprano
>>> wrote:
On Thu, 25 Jul 2013 20:34:23 +1000, Chris Angelico wrote:
> On Thu, Jul 25, 2013 at 7:44 PM, Steven D'Aprano
> wrote:
>> On Thu, 25 Jul 2013 18:15:22 +1000, Chris Angelico wrote:
>>> That's true, but we already have that issue with sets. What's the
>>>
On Thu, 25 Jul 2013 14:36:25 +0100, Jeremy Sanders wrote:
> wxjmfa...@gmail.com wrote:
>
>> Short example. Writing an editor with something like the FSR is simply
>> impossible (properly).
>
> http://www.gnu.org/software/emacs/manual/html_node/elisp/Text-
Representations.html#Text-Representation
On Fri, 26 Jul 2013 01:36:07 +1000, Chris Angelico wrote:
> On Fri, Jul 26, 2013 at 1:26 AM, Steven D'Aprano
> wrote:
>> On Thu, 25 Jul 2013 14:36:25 +0100, Jeremy Sanders wrote:
>>> "To conserve memory, Emacs does not hold fixed-length 22-bit numbers
>>>
On Thu, 25 Jul 2013 15:45:38 -0500, Ian Kelly wrote:
> On Thu, Jul 25, 2013 at 12:18 PM, Steven D'Aprano
> wrote:
>> On Fri, 26 Jul 2013 01:36:07 +1000, Chris Angelico wrote:
>>
>>> On Fri, Jul 26, 2013 at 1:26 AM, Steven D'Aprano
>>> wrote:
&
As requested, some constructive criticism of your module.
On Thu, 25 Jul 2013 09:24:30 -0400, Devyn Collier Johnson wrote:
> #!/usr/bin/python3
> #Made by Devyn Collier Johnson, NCLA, Linux+, LPIC-1, DCTS
What's NCLA, Linux+, LPIC-1, DCTS? Do these mean anything? Are we
supposed to know what th
On Fri, 26 Jul 2013 13:21:47 -0700, cerr wrote:
> or should I just write my own dump function that can hanle thiS?
>
> Please advise!
Given the choice between reading the documentation to pickle.dump:
help(pickle.dump)
or spending the next month writing a replacement for pickle, testing it,
On Thu, 25 Jul 2013 21:20:45 -0600, Ian Kelly wrote:
> On Thu, Jul 25, 2013 at 8:48 PM, Steven D'Aprano
> wrote:
>> UTF-8 uses a flexible representation on a character-by-character basis.
>> When parsing UTF-8, one needs to look at EVERY character to decide how
>> ma
On Fri, 26 Jul 2013 22:12:36 -0600, Ian Kelly wrote:
> On Fri, Jul 26, 2013 at 9:37 PM, Steven D'Aprano
> wrote:
>> See the similarity now? Both flexibly change the width used by code-
>> points, UTF-8 based on the code-point itself regardless of the rest of
>> th
On Fri, 26 Jul 2013 08:46:58 -0700, wxjmfauth wrote:
> BTW, I'm pleased to read "sequence of bits" and not bytes. Again, utf
> transformers are producing sequence of bits, call Unicode Transformation
> Units, with lengths of 8/16/32 *bits*, from there the names utf8/16/32.
> UCS transformers are (
On Sat, 27 Jul 2013 08:22:00 -0400, Devyn Collier Johnson wrote:
> On 07/27/2013 07:30 AM, Chris “Kwpolska” Warrick wrote:
>> On Sat, Jul 27, 2013 at 12:58 PM, Devyn Collier Johnson
>> wrote:
>>> Linux systems with the proper software can use the "notify-send"
>>> command. Is there a cross-platfo
On Sun, 28 Jul 2013 15:59:04 -0400, Roy Smith wrote:
[...]
> I'm rather shocked to discover that count() is the slowest
> of all! I expected it to be the fastest. Or, certainly, no slower than
> default().
>
> The full profiler dump is at the end of this message, but the gist of it
> is:
>
> n
On Sun, 28 Jul 2013 12:23:04 -0700, wxjmfauth wrote:
> Do not forget that à la "FSR" mechanism for a non-ascii user is
> *irrelevant*.
You have been told repeatedly, Python's internals are *full* of ASCII-
only strings.
py> dir(list)
['__add__', '__class__', '__contains__', '__delattr__', '__del
On Sun, 28 Jul 2013 18:38:10 -0700, Tim O'Callaghan wrote:
> Hi,
>
> I hope that this hasn't been asked for the millionth time, so my
> apologies if it has.
[...]
> I hope that this was clear enough, apologies if it wasn't.
Clear as mud.
> It's late(ish), I'm tired and borderline frustrated :
Comparing floats to Fractions gives unexpected results:
# Python 3.3
py> from fractions import Fraction
py> 1/3 == Fraction(1, 3)
False
but:
py> 1/3 == float(Fraction(1, 3))
True
I expected that float-to-Fraction comparisons would convert the Fraction
to a float, but apparently they do the op
On Mon, 29 Jul 2013 17:48:21 +0100, MRAB wrote:
> On 29/07/2013 17:20, Chris Angelico wrote:
>> On Mon, Jul 29, 2013 at 5:09 PM, MRAB
>> wrote:
>>> I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats
>>> are approximate anyway, and the float value 1/3 is more likely to be
>>> Fr
On Mon, 29 Jul 2013 13:08:20 -0400, Terry Reedy wrote:
> In other words, there can be multiple unequal Franctions that have the
> same float value: for instance, Fraction(1,3) and
> Fraction(6004799503160661, 18014398509481984)
>
> > So from that standpoint it makes sense to me to cast to Fracti
On Mon, 29 Jul 2013 17:20:27 +0100, Chris Angelico wrote:
Fraction(0.3)
> Fraction(5404319552844595, 18014398509481984)
Fraction(0.33)
> Fraction(5944751508129055, 18014398509481984)
[...]
Fraction(0.3)
> Fraction(6004799503160661, 18014398509481984)
>
> Rounding of
On Mon, 29 Jul 2013 18:04:19 +0100, MRAB wrote:
> I thought that you're not meant to check for equality when using floats.
Heavens no. You're only meant to *mostly* not check for equality using
floats. As Miracle Max might say:
"It just so happens that floats are only MOSTLY inexact. There's a
On Mon, 29 Jul 2013 15:43:49 -0400, Devyn Collier Johnson wrote:
> In Python programming, the PEP8 recommends limiting lines to a maximum
> of 79 characters because "There are still many devices around that are
> limited to 80 character lines"
> (http://www.python.org/dev/peps/pep-0008/#code-lay-o
On Mon, 29 Jul 2013 15:18:59 -0500, Ed Leafe wrote:
> On Jul 29, 2013, at 3:08 PM, Joel Goldstick
> wrote:
>> Not performance, but human readability
>
> IMO, this isn't always the case. There are many lines of code
that are
> broken up to meet the 79 character limit, and as a result
On Mon, 29 Jul 2013 16:56:06 -0400, Devyn Collier Johnson wrote:
> collier@Nacho-Laptop:~$ ./pyglet.py
Here you are running a module called pyglet, which I assume you wrote.
> Traceback (most recent call last):
>File "./pyglet.py", line 2, in
> import pyglet
And here you try to impor
On Mon, 29 Jul 2013 16:24:51 -0400, Devyn Collier Johnson wrote:
> So, I can have a script with large lines and not negatively influence
> performance on systems that do not use punch cards?
You'll negatively influence anyone who has to read, or edit, your code.
Very likely including you.
But n
On Mon, 29 Jul 2013 18:22:02 -0400, Devyn Collier Johnson wrote:
> Duh, thanks for the tip (^u^), but I still get an error (different
> error). NOTE: this is all python2.7 code because Pyglet supposedly has
> issues with Python3.
[...]
> Traceback (most recent call last):
>File "./pymedia.py",
On Tue, 30 Jul 2013 14:27:10 +0100, Chris Angelico wrote:
> for delay in 100,300,600,1000,3000,5000,1:
> if not os.path.exists(directory): break
> sleep(delay)
>
> That'll sleep a maximum of 20 seconds, tune as required.
Actually, that will sleep a maximum of 5.55 hours, and a minimum of
On Tue, 30 Jul 2013 12:09:11 -0700, wxjmfauth wrote:
> And do not forget, in a pure utf coding scheme, your char or a char will
> *never* be larger than 4 bytes.
>
sys.getsizeof('a')
> 26
sys.getsizeof('\U000101000')
> 48
Neither character above is larger than 4 bytes. You forgot to de
On Mon, 18 Jun 2012 14:24:03 -0500, Andrew Berg wrote:
> Are there any tools out there that will parse a script and tell me if it
> is compatible with an arbitrary version of Python and highlight any
> incompatibilities? I need to check a few of my scripts that target 3.2
> to see if I can make th
On Mon, 18 Jun 2012 07:00:01 -0700, jmfauth wrote:
> On 18 juin, 12:11, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> On Mon, 18 Jun 2012 02:30:50 -0700, jmfauth wrote:
>> > On 18 juin, 10:28, Benjamin Kaplan wrote:
>> >> The u prefix is only t
On Wed, 20 Jun 2012 01:12:00 -0700, jmfauth wrote:
> Python 3.3.0a4 (v3.3.0a4:7c51388a3aa7+, May 31 2012, 20:15:21) [MSC v.
> 1600
> 32 bit (Intel)] on win32
---
> running smidzero.py...
> ...smidzero has been executed
What is "smidzero.py", and what is it doing?
---
> input(':')
> :él
Does Jython 2.5 honour the PYTHONSTARTUP environment variable? According
to my testing, it doesn't.
There used to be a page describing the differences between Jython and
CPython here:
http://www.jython.org/docs/differences.html
but it appears to have been eaten by the 404 Monster.
--
Steve
On Wed, 20 Jun 2012 18:27:53 -0600, Ian Kelly wrote:
> On Wed, Jun 20, 2012 at 5:30 PM, gmspro wrote:
>>
>> Hi,
>>
>> Is python a interpreted or compiled language?
>
> Like other languages that use a VM bytecode, it's a little bit of both.
> The actual Python code is compiled into Python byteco
On Thu, 21 Jun 2012 21:25:04 +1000, John O'Hagan wrote:
> Sometimes a function gets called repeatedly with the same expensive
> argument:
>
> def some_func(arg, i):
> (do_something with arg and i)
>
> same_old_arg = big_calculation()
Since big_calculation() is only called once, the cost of
On Sat, 23 Jun 2012 19:14:43 +0100, Rotwang wrote:
> The problem is that if the object was
> pickled by the module run as a script and then unpickled by the imported
> module, the unpickler looks in __main__ rather than mymodule for the
> object's class, and doesn't find it.
Possibly the solutio
On Sun, 24 Jun 2012 18:45:45 -0400, Dave Angel wrote:
> Bare exceptions are the bane of
> programming; Using it is like trying to learn to drive while
> blindfolded.
+1 QOTW
I really wish bare exceptions were removed from Python 3. There's no
point to try...except any longer, and it's just an
On Sun, 24 Jun 2012 16:16:25 -0700, Charles Hixson wrote:
> But what I wanted was to catch any exception.
Be careful of what you ask for, since you might get it.
"Catch any exception" is almost certainly the wrong thing to do, almost
always. The one good reason I've seen for a bare except is to
On Mon, 25 Jun 2012 09:51:15 +1000, Chris Angelico wrote:
> Mind you, I think every programmer should spend some time debugging
> blind.
You're a cruel, cruel man.
I suppose next you're going to say that every programmer should spend
some time programming using Notepad as their only editor.
On Mon, 25 Jun 2012 04:17:00 -0700, jmfauth wrote:
> Mea culpa. I had not my head on my shoulders. Inputing if working fine,
> it returns "text" correctly.
>
> However, and this is something different, I'm a little bit surprised,
> input() does not handle escaped characters (\u, \U).
No, it is n
On Mon, 25 Jun 2012 23:36:59 +0200, Christian Tismer wrote:
> I saw quite a lot of downloads of this package now, but not a single
> reaction or any feedback.
Feel fortunate that you are getting any downloads at all :)
In my experience, if you are really lucky, perhaps one in a hundred
people w
(Rick, don't make me regret communicating with you again.)
On Mon, 25 Jun 2012 19:28:01 -0700, rantingrickjohnson wrote:
> However, there is something to be said for "old habits die hard". I
> myself lament every time i must type->(, then blah, then->) AGAIN!. My
> fingers are hardwired for the o
On Tue, 26 Jun 2012 02:15:17 -0400, Devin Jeanpierre wrote:
>> Making print a statement in the first place was a mistake, but
>> fortunately it was a simple enough mistake to rectify once the need for
>> backward compatibility was relaxed.
>
> Hmmm, why is the function so much better than the sta
On Wed, 27 Jun 2012 19:06:08 +0100, MRAB wrote:
> On 27/06/2012 18:33, subhabangal...@gmail.com wrote:
>> Dear Group,
>> I am Sri Subhabrata Banerjee writing from India. I am running a small
>> program which exploits around 12 1 to 2 KB .txt files. I am using MS
>> Windows XP Service Pack 3 and Py
On Wed, 27 Jun 2012 16:24:30 -0700, David wrote:
> First, you should be getting an error on
> vars()[var] = Button(f3, text = "00", bg = "white")
> as vars() has not been declared
The Fine Manual says differently:
Python 2:
http://docs.python.org/library/functions.html#vars
Python 3:
http://do
On Wed, 27 Jun 2012 17:13:00 -0700, Charles Hixson wrote:
> On 06/25/2012 12:48 AM, Steven D'Aprano wrote:
>> On Sun, 24 Jun 2012 16:16:25 -0700, Charles Hixson wrote:
>>
>>
>>> But what I wanted was to catch any exception.
>>>
>> Be c
On Wed, 27 Jun 2012 17:44:23 -0700, alex23 wrote:
> If you believe providing a complementary __past__ namespace will work -
> even though I believe Guido has explicitly stated it will never happen -
> then the onus is on you to come up with an implementation.
Guido speaks only for CPython. Other
On Wed, 27 Jun 2012 19:15:54 -0700, woooee wrote:
> "as vars() has not been declared and it does not appear to be valid
> Python syntax"
>
> You assume too much IMHO. Vars() was not declared in the code provided
> and I do not think that we should be assuming that it is a function
> returning a
On Thu, 28 Jun 2012 17:26:36 +0100, andrea crotti wrote:
>> Returning a boolean isn't very Pythonic. It would be better, IMHO, if
>> it could swallow a specified exception (or specified exceptions?)
>> raised when an attempt failed, up to the maximum permitted number of
>> attempts. If the final a
On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
> On Jun 29, 12:57 pm, "Littlefield, Tyler" wrote:
>> I was curious if someone wouldn't mind poking at some code. The project
>> page is at:http://code.google.com/p/pymud Any information is greatly
>> appreciated.
>
> I couldn't find any actual c
On Fri, 29 Jun 2012 09:31:53 -0700, Josh English wrote:
> I have a list of tuples, and usually print them using:
>
> print c, " ".join(map(str, list_of_tuples))
>
> This is beginning to feel clunky (but gives me essentially what I want),
> and I thought there was a better, more concise, way to a
On Fri, 29 Jun 2012 19:41:11 +, Alister wrote:
> also this section in main strikes me as a bit odd and convoluted
>
> w = world()
> serv = server(client)
> w.server = serv
> serv.world = w
>
> I think you are cross referencing classes & would be better to
> investigate inheri
On Sun, 01 Jul 2012 00:05:26 +0200, Thomas Jollans wrote:
> Yes. My sole point, really, is that "normally", one would expect these
> two expressions to be equivalent:
>
> a < b < c
> (a < b) < c
Good grief. Why would you expect that?
You can't just arbitrarily stick parentheses around parts of
On Sun, 01 Jul 2012 10:37:05 +1000, Chris Angelico wrote:
> On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney
> wrote:
>> Thomas Jollans writes:
>>
>>> My sole point, really, is that "normally", one would expect these two
>>> expressions to be equivalent:
>>>
>>> a < b < c
>>> (a < b) < c
>>
>> What n
On Sun, 01 Jul 2012 12:20:52 +1000, Chris Angelico wrote:
> On Sun, Jul 1, 2012 at 12:06 PM, Steven D'Aprano
> wrote:
>> You can't just arbitrarily stick parentheses around parts of
>> expressions and expect the result to remain unchanged. Order of
>> evaluati
On Sun, 01 Jul 2012 14:23:36 +1000, Chris Angelico wrote:
> On Sun, Jul 1, 2012 at 2:17 PM, Steven D'Aprano
> wrote:
>> Nonsense. Of course parens change the evaluation of the expression.
>> That's what parens are for!
>
> The whole point of my example was th
On Sun, 01 Jul 2012 13:48:04 +1000, Chris Angelico wrote:
> On Sun, Jul 1, 2012 at 1:23 PM, Steven D'Aprano
> wrote:
>> All the worse for those languages, since they violate the semantics of
>> mathematical notation.
>
> Not so. It simply means that booleans
On Sun, 01 Jul 2012 05:18:09 -0400, Devin Jeanpierre wrote:
> Also, you claimed earlier that the notion of associative "<" is not
> founded in mathematical notation. It really depends on whose
> mathematical notation you use -- there's more than one, you know. For
> example, it's reasonable to exp
On Sun, 01 Jul 2012 09:35:40 +0200, Thomas Jollans wrote:
> On 07/01/2012 04:06 AM, Steven D'Aprano wrote:
>> On Sun, 01 Jul 2012 00:05:26 +0200, Thomas Jollans wrote:
>>
>>> As soon as you read it as a ternary operator,
>>
>> Well that's you
On Sun, 01 Jul 2012 05:55:24 -0400, Terry Reedy wrote:
> On 7/1/2012 2:54 AM, Steven D'Aprano wrote:
>
>> So no, Python has always included chained comparisons, and yes, it is
>> shameful that a language would force you to unlearn standard notation
>> in favour
On Sun, 01 Jul 2012 16:33:15 +1000, Chris Angelico wrote:
> On Sun, Jul 1, 2012 at 4:27 PM, Steven D'Aprano
> wrote:
>> Yes, you can find specially crafted examples where adding parentheses
>> in certain places, but not others, doesn't change the overall
>> eva
On Sun, 01 Jul 2012 21:50:29 -0400, Devin Jeanpierre wrote:
> On Sun, Jul 1, 2012 at 9:28 PM, Steven D'Aprano
> wrote:
>> Technically, < in Python is left-associative: a < b < c first evaluates
>> a, not b or c. But it is left-associative under the rules of comp
On Mon, 02 Jul 2012 12:04:29 +1000, Chris Angelico wrote:
>> Chained comparisons in the Python sense may be rare in computer
>> languages, but it is the standard in mathematics and hardly needs to be
>> explained to anyone over the age of twelve. That is a terrible
>> indictment on the state of pr
On Tue, 03 Jul 2012 02:55:48 +1000, Chris Angelico wrote:
> On Tue, Jul 3, 2012 at 1:16 AM, Rick Johnson
> wrote:
>> py> 1 + 3 * 4
>> should ALWAYS equal 16!
>>
>> With parenthesis only used for grouping: py> a + (b*c) + d
>>
>> Which seems like the most consistent approach to me.
>
> Oh yes, ab
On Tue, 03 Jul 2012 12:25:59 +1000, John O'Hagan wrote:
> On Tue, 3 Jul 2012 11:22:55 +1000
> Chris Angelico wrote:
>
>> On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano
>> wrote:
>>
>> > Perhaps the world would be better off if mathematicians th
You can create instances without a __dict__ by setting __slots__:
py> class Dictless:
... __slots__ = ['a', 'b', 'c']
...
py> Dictless().__dict__
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'Dictless' object has no attribute '__dict__'
But the class itself stil
On Wed, 04 Jul 2012 10:42:56 +0100, andrea crotti wrote:
> I'm writing a program which has to interact with many external
> resources, at least:
> - mysql database
> - perforce
> - shared mounts
> - files on disk
>
> And the logic is quite complex, because there are many possible paths to
> follo
On Wed, 04 Jul 2012 13:27:29 -0700, Mariano DAngelo wrote:
> Hi I'm trying to create a class from a string This is my code, but
> is not working
>
> 'myshop.models.base'
> module_name, class_name = model.rsplit(".", 1)
> module = importlib.import_module(module_name)
> class_ = getattr(m
On Wed, 04 Jul 2012 18:48:08 -0400, Dave Angel wrote:
> As i said above, the rules are different for globals, and they are even
> if you use locals() to access them. However, i'd consider it prudent
> never to assume you can write to the dictionary constructed by either
> the locals() or the glob
On Wed, 04 Jul 2012 16:21:46 -0700, subhabangalore wrote:
[...]
> I got to code a bunch of documents which are combined together.
[...]
> The task is to separate the documents on the fly and to parse each of
> the documents with a definite set of rules.
>
> Now, the way I am processing is:
> I a
On Wed, 04 Jul 2012 23:38:17 -0400, Terry Reedy wrote:
> If I run the script in 3.3 Idle, I get the same output you got. If I
> then enter '5-2' interactively, I still get 3. Maybe the constant folder
> is always on now.
Yes, I believe constant folding is always on, since Python 2.4 if I
remembe
On Thu, 05 Jul 2012 12:29:24 +0200, Olive wrote:
> I am learning python -:)
>
> I am creating a new class: package (to analyse the packages database in
> some linux distros). I have created a class package such that
> package("string") give me an instance of package if string is a correct
> repre
On Thu, 05 Jul 2012 23:56:37 +1000, Chris Angelico wrote:
> (The "magic number" 86400 is a well-known number, being seconds in a
> day.
Does that include leap seconds?
> Feel free to replace it with 24*60*60 if it makes you feel better;
> I'm pretty sure Python will translate it into a constan
On Thu, 05 Jul 2012 15:57:53 +0200, Hans Mulder wrote:
> On 5/07/12 07:32:48, Steven D'Aprano wrote:
>> On Wed, 04 Jul 2012 23:38:17 -0400, Terry Reedy wrote:
>>
>>> If I run the script in 3.3 Idle, I get the same output you got. If I
>>> then enter '5
On Fri, 06 Jul 2012 00:55:48 +0200, Damjan wrote:
> Also this:
>
> #! /usr/bin/python2
> # retardations in python's datetime
>
> import pytz
> TZ = pytz.timezone('Europe/Skopje')
>
> from datetime import datetime
>
> x1 = datetime.now(tz=TZ)
> x2 = datetime(x1.year, x1.month, x1.day, tzinfo=TZ)
On Thu, 05 Jul 2012 16:46:48 -0500, Evan Driscoll wrote:
> On 01/-10/-28163 01:59 PM, Alexander Blinne wrote:
>> 5+0 is actually 4+0, because 5 == 4, so 5+0 gives 4. 5+1 is actually
>> 4+1, which is 5, but 5 is again 4. 5+2 is 4+2 which is 6.
>
> Now all I can think is "Hoory for new math, new-ho
On Thu, 05 Jul 2012 11:15:04 -0700, rurpy wrote:
> On Thursday, July 5, 2012 11:34:16 AM UTC-6, John Nagle wrote:
>>[...]
>>You can also call time.time(), and get the number of seconds
>> since the epoch (usually 1970-01-01 00:00:00 UTC). That's just a
>> number, and you can do arithmetic on t
On Fri, 06 Jul 2012 12:55:31 -0400, Karl Knechtel wrote:
> Hello all,
>
> While attempting to make a wrapper for opening multiple types of
> UTF-encoded files (more on that later, in a separate post, I guess), I
> ran into some oddities with the `codecs` module, specifically to do with
> `.regist
On Fri, 06 Jul 2012 21:56:35 -0700, iMath wrote:
> What’s the differences between these two pieces of code ?
Have you tried it? What do you see?
Obviously the difference is that the second piece calls print() at the
end, and the first does not.
Since the for-loops are identical, we can ignor
On Mon, 09 Jul 2012 07:54:47 +1000, Chris Angelico wrote:
> It's like
> the difference between reminder text on a Magic: The Gathering card and
> the actual entries in the Comprehensive Rules. Perfect example is the
> "Madness" ability - the reminder text explains the ability, but uses
> language
On Mon, 09 Jul 2012 18:41:28 +1000, Chris Angelico wrote:
> Does it really hurt to anthropomorphize
Don't anthropomorphise computers. They don't like it when you do.
> and say that "Python looks for
> modules in the directories in sys.path" instead of "Module lookup
> consists of iterating bla
On Tue, 10 Jul 2012 09:05:50 -0700, Ethan Furman wrote:
> Jean-Michel Pichavant wrote:
>> Why would you want to hire someone that knows something pointless as
>> the version where feature X has been introduced ?
>
> As an example from today, if someone claimed to have 5+ years of Python
> experie
On Tue, 10 Jul 2012 11:29:24 +0200, Jean-Michel Pichavant wrote:
> Why would you want to hire someone that knows something pointless as the
> version where feature X has been introduced ? Just tell him that feature
> X has been introducted in version Y, costless 2.5sec training. Don't you
> want t
On Tue, 10 Jul 2012 10:11:22 +0200, Christian Heimes wrote:
> Am 10.07.2012 09:33, schrieb Steven D'Aprano:
>> This is why I hate job interviews. You have like 30 minutes, or even as
>> little as 30 seconds, to make a good impression on somebody who may or
>> may not
On Wed, 11 Jul 2012 02:59:15 +1000, Chris Angelico wrote:
> On Wed, Jul 11, 2012 at 2:51 AM, Steven D'Aprano
> wrote:
>> If only that were true. I know quite a few people who looked the
>> interviewer straight in the eye and told the most bare-faced lies
>> without
On Tue, 10 Jul 2012 10:46:08 -0700, Subhabrata wrote:
> Dear Group,
>
> I kept a good number of files in a folder. Now I want to read all of
> them. They are in different formats and different encoding. Using
> listdir/glob.glob I am able to find the list but how to open/read or
> process them fo
On Wed, 11 Jul 2012 11:15:02 -0700, subhabangalore wrote:
> On Tuesday, July 10, 2012 11:16:08 PM UTC+5:30, Subhabrata wrote:
>> Dear Group,
>>
>> I kept a good number of files in a folder. Now I want to read all of
>> them. They are in different formats and different encoding. Using
>> listdir/g
On Wed, 11 Jul 2012 11:38:18 -0700, woooee wrote:
> You should not be using lambda in this case
> .for x in [2, 3]:
> .funcs = [x**ctr for ctr in range( 5 )]
> .for p in range(5):
> .print x, funcs[p]
> .print
If you change the requirements, it's always easy to solve problem
On Wed, 11 Jul 2012 13:21:34 -0700, John Ladasky wrote:
> Exactly. It's threads like these which remind me why I never use
> lambda. I would rather give a function an explicit name and adhere to
> the familiar Python syntax, despite the two extra lines of code.
lambda is familiar Python syntax,
On Wed, 11 Jul 2012 21:05:30 -0400, Dennis Lee Bieber wrote:
> {non sequitur: I still recall my archaic C++ class with the OOAD
> assignment of designing said calculator -- we never had to implement
> one, just design the basic classes/methods/attributes [on 3x5 cards] for
> a four-banger. I manag
On Wed, 11 Jul 2012 20:39:45 -0700, 8 Dihedral wrote:
> I'll contribute my way of python programming:
>
> def powerb(x, b): #
> return x**b
Here's a shorter version:
py> pow
> One functor is enough!
Nothing we have been discussing in this thread has been a functor, either
in the
On Wed, 11 Jul 2012 08:41:57 +0200, Daniel Fetchinson wrote:
> funcs = [ lambda x: x**i for i in range( 5 ) ]
Here's another solution:
from functools import partial
funcs = [partial(lambda i, x: x**i, i) for i in range(5)]
Notice that the arguments i and x are defined in the opposite order.
T
On Wed, 11 Jul 2012 22:04:51 -0700, 8 Dihedral wrote:
> I have to make sure my functor to keep the state variable values for
> different objects that call the same functor to behave correctly in
> order to avoid passing extra parameters in various objects using the
> same functor.
Yo dawg,
On Thu, 12 Jul 2012 09:44:15 +, Alister wrote:
> On Wed, 11 Jul 2012 08:43:11 +0200, Daniel Fetchinson wrote:
>
>>> funcs = [ lambda x: x**i for i in range( 5 ) ]
[...]
> Having read Steve's explanation in the other thread (which I think has
> finally flipped the light switch on lambda for m
On Thu, 12 Jul 2012 15:05:26 +0200, Christian Heimes wrote:
> You need to flush the data to disk as well as the metadata of the file
> and its directory in order to survive a system crash. The close()
> syscall already makes sure that all data is flushed into the IO layer of
> the operating system
On Thu, 12 Jul 2012 15:17:03 +0100, andrea crotti wrote:
> Well that's what I thought, but I can't find any explicit exit anywhere
> in shutil, so what's going on there?
Hard to say, since you don't give any context to your question.
When replying to posts, please leave enough quoted to establis
On Thu, 12 Jul 2012 16:37:42 +0100, andrea crotti wrote:
> 2012/7/12 John Gordon :
>> In andrea crotti
>> writes:
>>
>>> Well that's what I thought, but I can't find any explicit exit
>>> anywhere in shutil, so what's going on there?
>>
>> Try catching SystemExit specifically (it doesn't inherit
On Thu, 12 Jul 2012 14:20:18 +0100, andrea crotti wrote:
> One thing that I don't quite understand is why some calls even if I
> catch the exception still makes the whole program quit.
Without seeing your whole program, we can't possibly answer this. But by
consulting my crystal ball, I bet you
On Fri, 13 Jul 2012 12:12:01 +1000, Chris Angelico wrote:
> On Fri, Jul 13, 2012 at 11:20 AM, Rick Johnson
> wrote:
>> On Jul 12, 2:39 pm, Christian Heimes wrote:
>>> Windows's file system layer is not POSIX compatible. For example you
>>> can't remove or replace a file while it is opened by a p
401 - 500 of 13783 matches
Mail list logo