comp.lang.python - 25 new messages in 13 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* Last M digits of expression A^N - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/f3b6bfdd7b10c6c7?hl=en
* method names nounVerb or verbNoun - 6 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/53e8e2795730e0ab?hl=en
* merge stdin, stdout? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/75afdea13cc24143?hl=en
* How to guard against bugs like this one? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/fe6430e7980e2a96?hl=en
* method to intercept string formatting % operations - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/f0acce6896bb76cd?hl=en
* dmp detektei , detektei nuernberg , detektive frankfurt , detektivbueros
frankfurt , detektei wiesbaden , detektei braunschweig , mr monk
privatdetektiv , personenschutz frankfurt , + + + + +++ DETEKTEIEN DETEKTIVE
ONLINE +++ DETEKTEI HAMBURG +++ - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/234380e047da7176?hl=en
* Python and Ruby - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/dfe4f6c60032755e?hl=en
* C:\Python25\Lib\IDLELIB\idle.pyw won't start - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/0dbc675fff5ecf07?hl=en
* Your beloved python features - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/599b3c9772421ece?hl=en
* which - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/5fcc1a3f067c1f50?hl=en
* reconstruct the source of a lambda from its func_code, func_name, etc - 1
messages, 1 author
http://groups.google.com/group/comp.lang.python/t/9cd2701ebc9accf8?hl=en
* xmlrpc slow in windows 7 if hostnames are used - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e4157a12dd9ece8c?hl=en
* Dreaming of new generation IDE - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e019614ea149e7bd?hl=en
==============================================================================
TOPIC: Last M digits of expression A^N
http://groups.google.com/group/comp.lang.python/t/f3b6bfdd7b10c6c7?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Feb 5 2010 12:21 pm
From: Gerald Britton
On Fri, Feb 5, 2010 at 3:14 PM, mukesh tiwari
<mukeshtiwari.iiitm@gmail.com> wrote:
> Hello everyone. I am kind of new to python so pardon me if i sound
> stupid.
> I have to find out the last M digits of expression.One thing i can do
> is (A**N)%M but my A and N are too large (10^100) and M is less than
> 10^5. The other approach was repeated squaring and taking mod of
> expression. Is there any other way to do this in python more faster
> than log N.
>
> def power(A,N,M):
> ret=1
> while(N):
> if(N%2!=0):ret=(ret*A)%M
> A=(A*A)%M
> N=N//2
> return ret
> --
> http://mail.python.org/mailman/listinfo/python-list
>
http://docs.python.org/3.1/library/decimal.html#decimal.Context.power
--
Gerald Britton
== 2 of 2 ==
Date: Fri, Feb 5 2010 12:28 pm
From: Mensanator
On Feb 5, 2:18 pm, Mark Dickinson <dicki...@gmail.com> wrote:
> On Feb 5, 8:14 pm, mukesh tiwari <mukeshtiwari.ii...@gmail.com> wrote:
>
> > Hello everyone. I am kind of new to python so pardon me if i sound
> > stupid.
> > I have to find out the last M digits of expression.One thing i can do
> > is (A**N)%M but my A and N are too large (10^100) and M is less than
> > 10^5. The other approach was repeated squaring and taking mod of
> > expression. Is there any other way to do this in python more faster
> > than log N.
>
> > def power(A,N,M):
> > ret=1
> > while(N):
> > if(N%2!=0):ret=(ret*A)%M
> > A=(A*A)%M
> > N=N//2
> > return ret
>
> The built-in pow function does exactly this,
It doesn't do 'exactly' that. M is the number of digits.
If you want 17 digits, the third number should 10**17.
Using 17 directly will give you a 2-digit answer as shown.
Try this instead:
>>> pow(12345,67891,10**17)
50553131103515625
> if you give it three
> arguments:
>
> >>> pow(12345, 67891, 17)
> 10
> >>> 12345 ** 67891 % 17
>
> 10L
>
> (Though this won't work for negative N.)
>
> Mark
==============================================================================
TOPIC: method names nounVerb or verbNoun
http://groups.google.com/group/comp.lang.python/t/53e8e2795730e0ab?hl=en
==============================================================================
== 1 of 6 ==
Date: Fri, Feb 5 2010 12:26 pm
From: MRAB
Wanderer wrote:
> Which is the more accepted way to compose method names nounVerb or
> verbNoun?
>
> For example voltageGet or getVoltage? getVoltage sounds more normal,
> but voltageGet is more like voltage.Get. I seem to mix them and I
> should probably pick one way and stick with it.
>
I would use the 'normal' order, which in this case is 'get_voltage'.
== 2 of 6 ==
Date: Fri, Feb 5 2010 12:26 pm
From: Chris Rebert
On Fri, Feb 5, 2010 at 11:53 AM, Wanderer <wanderer@dialup4less.com> wrote:
> Which is the more accepted way to compose method names nounVerb or
> verbNoun?
>
> For example voltageGet or getVoltage? getVoltage sounds more normal,
> but voltageGet is more like voltage.Get. I seem to mix them and I
> should probably pick one way and stick with it.
Use properties[1] and just call it `voltage`. Python is not Java [2];
explicit getters/setters are unpythonic.
[1] http://docs.python.org/library/functions.html#property
[2] http://dirtsimple.org/2004/12/python-is-not-java.html
Cheers,
Chris
--
http://blog.rebertia.com
== 3 of 6 ==
Date: Fri, Feb 5 2010 1:49 pm
From: Wanderer
On Feb 5, 3:26 pm, Chris Rebert <c...@rebertia.com> wrote:
> On Fri, Feb 5, 2010 at 11:53 AM, Wanderer <wande...@dialup4less.com> wrote:
> > Which is the more accepted way to compose method names nounVerb or
> > verbNoun?
>
> > For example voltageGet or getVoltage? getVoltage sounds more normal,
> > but voltageGet is more like voltage.Get. I seem to mix them and I
> > should probably pick one way and stick with it.
>
> Use properties[1] and just call it `voltage`. Python is not Java [2];
> explicit getters/setters are unpythonic.
>
> [1]http://docs.python.org/library/functions.html#property
> [2]http://dirtsimple.org/2004/12/python-is-not-java.html
>
> Cheers,
> Chris
> --http://blog.rebertia.com
Maybe I'm not using Get right either. I'm wrapping functions.
def AbbeGet(self, Lens):
"""
Get the Abbe Number V for the material
where
V = (Nd - 1)/(Nf - Nc)
where the Index of Refractions are
Nd at the Fraunhofer D line 0.5892um
Nf at the Fraunhofer F line 0.4861um
Nc at the Fraunhofer C line 0.6563um
"""
Nd = Lens.Mat.NtGet(0.5892)
Nf = Lens.Mat.NtGet(0.4861)
Nc = Lens.Mat.NtGet(0.6563)
if (Nf - Nc) != 0:
V = (Nd - 1)/(Nf - Nc)
else:
V = 1e6
return V
# end AbbeGet
== 4 of 6 ==
Date: Fri, Feb 5 2010 1:53 pm
From: "Alf P. Steinbach"
* Wanderer:
> On Feb 5, 3:26 pm, Chris Rebert <c...@rebertia.com> wrote:
>> On Fri, Feb 5, 2010 at 11:53 AM, Wanderer <wande...@dialup4less.com> wrote:
>>> Which is the more accepted way to compose method names nounVerb or
>>> verbNoun?
>>> For example voltageGet or getVoltage? getVoltage sounds more normal,
>>> but voltageGet is more like voltage.Get. I seem to mix them and I
>>> should probably pick one way and stick with it.
>> Use properties[1] and just call it `voltage`. Python is not Java [2];
>> explicit getters/setters are unpythonic.
>>
>> [1]http://docs.python.org/library/functions.html#property
>> [2]http://dirtsimple.org/2004/12/python-is-not-java.html
>>
>> Cheers,
>> Chris
>> --http://blog.rebertia.com
>
> Maybe I'm not using Get right either. I'm wrapping functions.
>
> def AbbeGet(self, Lens):
> """
> Get the Abbe Number V for the material
> where
> V = (Nd - 1)/(Nf - Nc)
> where the Index of Refractions are
> Nd at the Fraunhofer D line 0.5892um
> Nf at the Fraunhofer F line 0.4861um
> Nc at the Fraunhofer C line 0.6563um
> """
>
> Nd = Lens.Mat.NtGet(0.5892)
> Nf = Lens.Mat.NtGet(0.4861)
> Nc = Lens.Mat.NtGet(0.6563)
>
> if (Nf - Nc) != 0:
> V = (Nd - 1)/(Nf - Nc)
> else:
> V = 1e6
>
> return V
>
> # end AbbeGet
Consider this piece of code:
x = 2*sin( angle )
versus this:
x = 2*get_sin( angle )
or this:
x = 2*sin_get( angle )
Cheers & hth.,
- Alf
== 5 of 6 ==
Date: Fri, Feb 5 2010 1:53 pm
From: Chris Rebert
On Fri, Feb 5, 2010 at 1:49 PM, Wanderer <wanderer@dialup4less.com> wrote:
> On Feb 5, 3:26 pm, Chris Rebert <c...@rebertia.com> wrote:
>> On Fri, Feb 5, 2010 at 11:53 AM, Wanderer <wande...@dialup4less.com> wrote:
>> > Which is the more accepted way to compose method names nounVerb or
>> > verbNoun?
>>
>> > For example voltageGet or getVoltage? getVoltage sounds more normal,
>> > but voltageGet is more like voltage.Get. I seem to mix them and I
>> > should probably pick one way and stick with it.
>>
>> Use properties[1] and just call it `voltage`. Python is not Java [2];
>> explicit getters/setters are unpythonic.
>>
>> [1]http://docs.python.org/library/functions.html#property
>
> Maybe I'm not using Get right either. I'm wrapping functions.
>
> def AbbeGet(self, Lens):
> """
> Get the Abbe Number V for the material
> where
> V = (Nd - 1)/(Nf - Nc)
> where the Index of Refractions are
> Nd at the Fraunhofer D line 0.5892um
> Nf at the Fraunhofer F line 0.4861um
> Nc at the Fraunhofer C line 0.6563um
> """
>
> Nd = Lens.Mat.NtGet(0.5892)
> Nf = Lens.Mat.NtGet(0.4861)
> Nc = Lens.Mat.NtGet(0.6563)
>
> if (Nf - Nc) != 0:
> V = (Nd - 1)/(Nf - Nc)
> else:
> V = 1e6
>
> return V
This isn't even really a method; you don't refer to "self" in the body
at all. Why isn't it just a function?
Cheers,
Chris
--
http://blog.rebertia.com
== 6 of 6 ==
Date: Fri, Feb 5 2010 2:21 pm
From: Wanderer
On Feb 5, 4:53 pm, Chris Rebert <c...@rebertia.com> wrote:
> On Fri, Feb 5, 2010 at 1:49 PM, Wanderer <wande...@dialup4less.com> wrote:
> > On Feb 5, 3:26 pm, Chris Rebert <c...@rebertia.com> wrote:
> >> On Fri, Feb 5, 2010 at 11:53 AM, Wanderer <wande...@dialup4less.com> wrote:
> >> > Which is the more accepted way to compose method names nounVerb or
> >> > verbNoun?
>
> >> > For example voltageGet or getVoltage? getVoltage sounds more normal,
> >> > but voltageGet is more like voltage.Get. I seem to mix them and I
> >> > should probably pick one way and stick with it.
>
> >> Use properties[1] and just call it `voltage`. Python is not Java [2];
> >> explicit getters/setters are unpythonic.
>
> >> [1]http://docs.python.org/library/functions.html#property
>
> > Maybe I'm not using Get right either. I'm wrapping functions.
>
> > def AbbeGet(self, Lens):
> > """
> > Get the Abbe Number V for the material
> > where
> > V = (Nd - 1)/(Nf - Nc)
> > where the Index of Refractions are
> > Nd at the Fraunhofer D line 0.5892um
> > Nf at the Fraunhofer F line 0.4861um
> > Nc at the Fraunhofer C line 0.6563um
> > """
>
> > Nd = Lens.Mat.NtGet(0.5892)
> > Nf = Lens.Mat.NtGet(0.4861)
> > Nc = Lens.Mat.NtGet(0.6563)
>
> > if (Nf - Nc) != 0:
> > V = (Nd - 1)/(Nf - Nc)
> > else:
> > V = 1e6
>
> > return V
>
> This isn't even really a method; you don't refer to "self" in the body
> at all. Why isn't it just a function?
>
> Cheers,
> Chris
> --http://blog.rebertia.com
Okay, I guess it should be a function called abbe() instead of a
method called AbbeGet(). That should solve the problem of trying to
remember whether I called it GetAbbe or AbbeGet.
Thanks
==============================================================================
TOPIC: merge stdin, stdout?
http://groups.google.com/group/comp.lang.python/t/75afdea13cc24143?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Feb 5 2010 12:39 pm
From: jonny lowe
On Feb 4, 8:20 pm, exar...@twistedmatrix.com wrote:
> On 01:56 am, jonny.lowe.12...@gmail.com wrote:
>
>
>
> >Hi everyone,
>
> >Is there an easy way to mergestdinandstdout? For instance suppose I
> >havescriptthat prompts for a number and prints the number. If you
> >execute this with redirection from a file say input.txt with 42 in the
> >file, then executing
>
> >./myscript < input.txt > output.txt
>
> >the output.txt might look like this:
>
> >Enter a number:
> >You entered 42.
>
> >What I want is to have an easy way to merge input.txt and thestdout
> >so that output.txt look like:
>
> >Enter a number: 42
> >You entered 42.
>
> >Here, the first 42 is of course from input.txt.
>
> It sounds like you might be looking forscript(1)?
>
> Jean-Paul
Hi Jean-Paul,
I tried it. But stdin is not merged in with stdout. Maybe I'm using
script wrongly? This is what I've done. I have a python script y.
Here's what it looks like when I run it and I entered "sss":
$ ./y
gimme x:sss
you entered sss
Now I'm going to use the script command. I'm using an input file
input.txt that contains just the string "hello".
$ script -c "./y < input.txt" output.txt
Script started, file is output.txt
gimme x:you entered hello
Script done, file is output.txt
And when I view output.txt this is what I see:
$ less output.txt
Script started on Thu Feb 4 22:28:12 2010
gimme x:you entered hello
Script done on Thu Feb 4 22:28:13 2010
As you can see the stdin is not printed. What I'd really wanted was
something like this in output.txt:
gimme x:hello
you entered hello
-jon
==============================================================================
TOPIC: How to guard against bugs like this one?
http://groups.google.com/group/comp.lang.python/t/fe6430e7980e2a96?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Feb 5 2010 12:44 pm
From: MRAB
Stephen Hansen wrote:
> On Fri, Feb 5, 2010 at 12:16 PM, John Nagle <nagle@animats.com
> <mailto:nagle@animats.com>> wrote:
>
> kj wrote:
>
> Through a *lot* of trial an error I finally discovered that the
> root cause of the problem was the fact that, in the same directory
> as buggy.py, there is *another* innocuous little script, totally
> unrelated, whose name happens to be numbers.py.
>
>
> The right answer to this is to make module search return an
> error if two modules satisfy the search criteria. "First find"
> isn't a good solution.
>
>
> And thereby slowdown every single import and application startup time as
> the common case of finding a module in one of the first couple entries
> in sys.path now has to search it in every single item on that path. Its
> not uncommon to have a LOT of things on sys.path.
>
> No thanks. "First Find" is good enough, especially with PEP328 and
> absolute_import being on in Python 3 (and presumably 2.7). It doesn't
> really help older Python versions unfortunately, but changing how import
> works wouldn't help them anyways. Yeah, there might be two paths on
> sys.path which both have a 'numbers.py' at the top level and First Find
> might return the wrong one, but... people making poor decisions on code
> organization and not using packages isn't something the language really
> needs to fix.
>
You might want to write a script that looks through the search paths for
duplicated names, especially ones which hide modules in the standard
library. Has anyone done this already?
== 2 of 2 ==
Date: Fri, Feb 5 2010 1:48 pm
From: Ethan Furman
John Nagle wrote:
> kj wrote:
> ...
>>
>> Through a *lot* of trial an error I finally discovered that the
>> root cause of the problem was the fact that, in the same directory
>> as buggy.py, there is *another* innocuous little script, totally
>> unrelated, whose name happens to be numbers.py.
>
> The right answer to this is to make module search return an
> error if two modules satisfy the search criteria. "First find"
> isn't a good solution.
>
> John Nagle
Then what happens when you *want* to shadow a module? As MRAB suggests,
if you are really concerned about it use a script that checks for
duplicate modules (not a bad idea for debugging), but don't start
throwing errors... next thing you know we won't be able to shadow
classes, functions, or built-ins! !-)
~Ethan~
==============================================================================
TOPIC: method to intercept string formatting % operations
http://groups.google.com/group/comp.lang.python/t/f0acce6896bb76cd?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Feb 5 2010 12:53 pm
From: Raymond Hettinger
On Feb 5, 6:57 am, bradallen <bradallen...@gmail.com> wrote:
> Hello,
>
> For container class derived from namedtuple, but which also behaves
> like a dictionary by implementing __getitem__ for non-integer index
> values, is there a special reserved method which allows intercepting %
> string formatting operations? I would like for my container type to
> behave appropriately depending on whether the string formatting
> operation has a string like this :
>
> "whatever %s yadayada" % mycontainer # needs to act like a tuple
>
> "whatever %(key)s yadayada" % mycontainer # needs to act like a
> dictionary
The implementation for str.__mod__ refuses to
treat tuples and tuple subclasses as a dictionary.
Since namedtuples are a subclass of tuple, you're
not going to have any luck with this one.
To see actual C code, look at PyString_Format() in
http://svn.python.org/view/python/trunk/Objects/stringobject.c?view=markup
PyObject *dict = NULL;
. . .
if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) &&
!PyObject_TypeCheck(args, &PyBaseString_Type))
dict = args;
Since automatic conversion is out, you can instead use
the namedtuple._asdict() method for an explicit conversion:
>>> from collections import namedtuple
>>> Point = namedtuple('Point', 'x y')
>>> p = Point(5, 12)
>>> 'x: %(x)s' % p._asdict()
'x: 5'
Raymond
== 2 of 2 ==
Date: Fri, Feb 5 2010 2:19 pm
From: Steven D'Aprano
On Fri, 05 Feb 2010 16:49:00 +0100, Jean-Michel Pichavant wrote:
> Anyway why would you want to use the tuple form ? it's beaten in every
> aspect by the dictionary form.
Except convenience, efficiency and readability.
"%s %s" % (1, 2)
versus
"%(a)s %(b)s" % {'a': 1, 'b': 2}
I'm all in favour of the second form when you need it. But you certainly
don't need it all time.
--
Steven
==============================================================================
TOPIC: dmp detektei , detektei nuernberg , detektive frankfurt ,
detektivbueros frankfurt , detektei wiesbaden , detektei braunschweig , mr
monk privatdetektiv , personenschutz frankfurt , + + + + +++ DETEKTEIEN
DETEKTIVE ONLINE +++ DETEKTEI HAMBURG +++
http://groups.google.com/group/comp.lang.python/t/234380e047da7176?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Feb 5 2010 12:54 pm
From: gerti maurer
dmp detektei , detektei nuernberg , detektive frankfurt ,
detektivbueros frankfurt , detektei wiesbaden , detektei
braunschweig , mr monk privatdetektiv , personenschutz frankfurt ,
+
+
+
+
+++ DETEKTEIEN DETEKTIVE ONLINE +++ DETEKTEI HAMBURG +++
PRIVATDETEKTIVE +++
+
+
http://WWW.NBR-DETECTIVE.NL
http://WWW.NBR-DETECTIVE.NL
http://WWW.NBR-DETECTIVE.NL
http://WWW.NBR-DETECTIVE.NL
http://WWW.NBR-DETECTIVE.NL
http://WWW.NBR-DETECTIVE.NL
http://WWW.NBR-DETECTIVE.NL
http://WWW.NBR-DETECTIVE.NL
http://WWW.NBR-DETECTIVE.NL
+
+
+
+
wird man privatdetektiv detektive com
detektiv conan privat detektiv frankfurt
detektei memmingen detektei
lehrgang frankfurt detektei saarland
detektei gps factoring
ermittler ausbildung zum detektiv
detektei detektiv privatdedektiv muenchen
www detektive com detektei muenster
privatdetektiv jim pauder privatdetektiv frankfurt
detektei sicherheit privatdedektiv berlin
www detektei secretly de kostet ein privatdetektiv
ich privatdetektiv detektive deutschland
factoring detektive koeln
==============================================================================
TOPIC: Python and Ruby
http://groups.google.com/group/comp.lang.python/t/dfe4f6c60032755e?hl=en
==============================================================================
== 1 of 3 ==
Date: Fri, Feb 5 2010 1:03 pm
From: Robert Kern
On 2010-02-04 17:46 PM, Ethan Furman wrote:
> Robert Kern wrote:
>> On 2010-02-04 14:55 PM, Jonathan Gardner wrote:
>>> On Feb 3, 3:39 pm, Steve Holden<st...@holdenweb.com> wrote:
>>>> Robert Kern wrote:
>>>>> On 2010-02-03 15:32 PM, Jonathan Gardner wrote:
>>>>
>>>>>> I can explain all of Python in an hour; I doubt anyone will
>>>>>> understand
>>>>>> all of Python in an hour.
>>>>
>>>>> With all respect, talking about a subject without a reasonable
>>>>> chance of
>>>>> your audience understanding the subject afterwards is not explaining.
>>>>> It's just exposition.
>>>>
>>>> I agree. If the audience doesn't understand then you haven't
>>>> explained it.
>>>
>>> On the contrary, that explanation would have everything you need. It
>>> would take an hour to read or listen to the explanation, but much more
>>> than that time to truly understand everything that was said.
>>
>> Like I said, that's exposition, not explanation. There is an important
>> distinction between the two words. Simply providing information is not
>> explanation. If it takes four hours for your audience to understand
>> it, then you explained it in four hours no matter when you stopped
>> talking.
>
> And if it takes six months? Would you seriously say it took you six
> months to explain something because it took that long for your audience
> to understand it?
>
> At some point you have to make the transition from person A explaining
> and person(s) B understanding -- they don't necessarily happen
> synchronously.
Then it's exposition and understanding, not explanation and understanding.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
== 2 of 3 ==
Date: Fri, Feb 5 2010 1:39 pm
From: Ethan Furman
Robert Kern wrote:
> On 2010-02-04 17:46 PM, Ethan Furman wrote:
>> Robert Kern wrote:
>>> On 2010-02-04 14:55 PM, Jonathan Gardner wrote:
>>>> On Feb 3, 3:39 pm, Steve Holden<st...@holdenweb.com> wrote:
>>>>> Robert Kern wrote:
>>>>>> On 2010-02-03 15:32 PM, Jonathan Gardner wrote:
>>>>>
>>>>>>> I can explain all of Python in an hour; I doubt anyone will
>>>>>>> understand
>>>>>>> all of Python in an hour.
>>>>>
>>>>>> With all respect, talking about a subject without a reasonable
>>>>>> chance of
>>>>>> your audience understanding the subject afterwards is not explaining.
>>>>>> It's just exposition.
>>>>>
>>>>> I agree. If the audience doesn't understand then you haven't
>>>>> explained it.
>>>>
>>>> On the contrary, that explanation would have everything you need. It
>>>> would take an hour to read or listen to the explanation, but much more
>>>> than that time to truly understand everything that was said.
>>>
>>> Like I said, that's exposition, not explanation. There is an important
>>> distinction between the two words. Simply providing information is not
>>> explanation. If it takes four hours for your audience to understand
>>> it, then you explained it in four hours no matter when you stopped
>>> talking.
>>
>> And if it takes six months? Would you seriously say it took you six
>> months to explain something because it took that long for your audience
>> to understand it?
>>
>> At some point you have to make the transition from person A explaining
>> and person(s) B understanding -- they don't necessarily happen
>> synchronously.
>
> Then it's exposition and understanding, not explanation and understanding.
>
Hmm. Well, I can see your point -- after all, if are "explaining" but
your audience is not understanding, are you really explaining? Okay,
looking in the dictionary...
ex⋅plain –verb (used with object)
1. to make plain or clear; render understandable or intelligible: to
explain an obscure point.
2. to make known in detail: to explain how to do something.
un⋅der⋅stand –verb (used with object)
1. to perceive the meaning of; grasp the idea of; comprehend: to
understand Spanish; I didn't understand your question.
2. to be thoroughly familiar with; apprehend clearly the character,
nature, or subtleties of: to understand a trade.
3. to assign a meaning to; interpret: He understood her suggestion as a
complaint.
4. to grasp the significance, implications, or importance of: He does
not understand responsibility.
For me, at least, it boils down to this feeling that understanding is
not a True/False item, but more of a scale (like all the the numbers
between 0.0 and 1.0 [not including 1.0 of course -- this *is* Python!
;)]). As a personal example, decorators are not that difficult to grasp
-- you take your function and wrap it in another function; but what you
can do with them! They are truly impressive once your understanding
deepens.
And at the end of the day (or this thread, whichever comes first ;)
Python is awesome, and that's what counts.
~Ethan~
== 3 of 3 ==
Date: Fri, Feb 5 2010 2:02 pm
From: Steven D'Aprano
On Fri, 05 Feb 2010 09:22:03 -0500, Lou Pecora wrote:
[...]
>> > That's what I needed. 3 lines to write or read a inhomogeneous
>> > collection of variables.
>>
>> Easy, but also quick and dirty -- good enough for small scripts, but
>> not really good enough for production applications.
[...]
> I understand where you are coming from: Production Code. I was just
> making a point about Python and my code is only used by me. I can edit
> the file for the simple I/O I do. I am not recommending this way for
> everyone. Just an example.
We're in violent agreement then :)
--
Steven
==============================================================================
TOPIC: C:\Python25\Lib\IDLELIB\idle.pyw won't start
http://groups.google.com/group/comp.lang.python/t/0dbc675fff5ecf07?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Feb 5 2010 1:09 pm
From: Anthra Norell
Duncan Booth wrote:
> Anthra Norell <anthra.norell@bluewin.ch> wrote:
>
>
>>> Using pythonw.exe will start the program with all error output dumped in
>>> the bit bucket. Running from a command prompt with python.exe will at
>>> least let you see if there are any errors.
>>>
>>>
>> python.exe from the command line works all right in a DOS window. The
>> problem must be with idle.pyw. I tried the old idle.pyw (2.4) with the
>> new python.exe. (2.5) and that didn't work either.
>> What is the bit bucket? If I had a clue, I could go from there. What
>> puzzles me is that version 2.4 has been working fine and one wouldn't
>> think that the changes from 2.4 to 2.5 would be so extensive as to cause
>> a major malfunction. For the time being 2.4 works fine. I'd much prefer
>> 2.5, though, because it includes the image library (PIL), whereas 2.4
>> cannot even use it.
>>
>
> Bit bucket: http://en.wikipedia.org/wiki/Bit_bucket
>
> If you are seeing nothing at all when running it with python.exe instead of
> pythonw.exe then something bizarre must be happening.
>
> My guess would have been that you had a problem importing something: e.g.
> if Tkinter isn't installed properly then running Idle under pythonw.exe
> would exit with an error message but you wouldn't see the error message.
> However since you don't see an error message when running it with
> python.exe it isn't that.
>
> Sorry, I'm out of ideas for now.
>
>
No matter. I'll just keep working with 2.4. The machine is on its way
out anyway. I have a brand new Dell Latitude E6500 without an operating
system waiting to be set up with Linux. That'll take some time. Thank
you for your suggestions.
Frederic
==============================================================================
TOPIC: Your beloved python features
http://groups.google.com/group/comp.lang.python/t/599b3c9772421ece?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Feb 5 2010 1:22 pm
From: "Bruce C. Baker"
"George Sakkis" <george.sakkis@gmail.com> wrote in message
news:de06116c-e77c-47c4-982d-62b48bca5064@j31g2000yqa.googlegroups.com...
I'll give the benefit of doubt and assume you're joking rather than
trolling.
George
*************************************************************
Not trolling, my friend!
GvR got it right when he discarded the superfluous semicolons from the ends
of statements--and then he ADDS superfluous colons to the ends of control
statements? It will probably be as much of a shock to you as it was to me
when I learned after studying parsing that colons, semicolons, "then"'s and
"do"'s, etc., are simply noise tokens that serve no purpose except to
clutter up the source.
As for enforced indentation, back in the late 60's when I was a programming
newbie I remember thinking how cool it would be to just indent the
statements controlled by for loops (we didn't have none of them fancy while
loops in FORTRAN back then! :-) ) Not too long after that I saw the havoc
that a buggy editor could wreak on nicely-formatted source. :-( Formatting
held hostage to a significant, invisible whitespace char? An inevitable
accident waiting to happen! Not good, Guido; not good at all.
That'll do for starters. :-)
== 2 of 2 ==
Date: Fri, Feb 5 2010 1:56 pm
From: CM
> GvR got it right when he discarded the superfluous semicolons from the ends
> of statements--and then he ADDS superfluous colons to the ends of control
> statements? It will probably be as much of a shock to you as it was to me
> when I learned after studying parsing that colons, semicolons, "then"'s and
> "do"'s, etc., are simply noise tokens that serve no purpose except to
> clutter up the source.
Some argue that the colon is a useful visual cue that aids in
readability and
that "explicit is better than implicit". I think one can feel either
way about it.
For my part, I prefer to have colons at that point, because it serves
as a
mental primer that a certain type of block follows. Semi-colons at
the end
of statements don't seem to provide any mental priming for me that
can't
better be served by a line break.
> As for enforced indentation, back in the late 60's when I was a programming
> newbie I remember thinking how cool it would be to just indent the
> statements controlled by for loops (we didn't have none of them fancy while
> loops in FORTRAN back then! :-) ) Not too long after that I saw the havoc
> that a buggy editor could wreak on nicely-formatted source. :-( Formatting
> held hostage to a significant, invisible whitespace char? An inevitable
> accident waiting to happen! Not good, Guido; not good at all.
First, why would you tolerate a buggy editor?
I've had my share of challenges in learning Python, but indentation
problems
would be about 403rd down on the list. A simple indentation error is
shown in
my editor that immediately gets fixed. No havoc at all. And I also
know that
every piece of Python code I ever get from others *has* to be readable
(at
least in terms of the very visually helpful indented blocks).
Che
Che
>
> That'll do for starters. :-)
==============================================================================
TOPIC: which
http://groups.google.com/group/comp.lang.python/t/5fcc1a3f067c1f50?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Feb 5 2010 2:19 pm
From: Steven D'Aprano
On Fri, 05 Feb 2010 16:52:19 +0100, mk wrote:
> assert isinstance(cmd, basestring) or cmd is None, "cmd should be string
> or None"
Do not use assertions for input validation. That's not what they're for.
assert is compiled away when you run your code with the -O switch, which
means that the test may never be made at all. You should limit assertions
for testing "this can never happen" situations, verifying pre- and post-
conditions, checking the internal logic of your code, and similar.
See also:
http://nedbatchelder.com/text/assert.html
--
Steven
== 2 of 2 ==
Date: Fri, Feb 5 2010 2:21 pm
From: Steven D'Aprano
On Fri, 05 Feb 2010 15:21:05 +0100, mk wrote:
> if isinstance(cmd, str):
> self.cmd = cmd.replace(r'${ADDR}',ip)
> else:
> self.cmd = cmd
>
> or
>
> self.cmd = cmd
> if isinstance(cmd, str):
> self.cmd = cmd.replace(r'${ADDR}',ip)
Whichever one you like. The differences are insignificance, and
essentially boil down to personal preference.
--
Steven
==============================================================================
TOPIC: reconstruct the source of a lambda from its func_code, func_name, etc
http://groups.google.com/group/comp.lang.python/t/9cd2701ebc9accf8?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Feb 5 2010 2:19 pm
From: Phlip
Thy Pon:
Has anyone figured out how to reflect a passed function, such as a
lambda, all the way back to its source?
I am aware than func_code knows the file name and line number; I would
rather not use them to read the file because the lambda might not
start in the first column. I will go with this option until someone
suggests a better fix!
--
Phlip
http://penbird.tumblr.com/
==============================================================================
TOPIC: xmlrpc slow in windows 7 if hostnames are used
http://groups.google.com/group/comp.lang.python/t/e4157a12dd9ece8c?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Feb 5 2010 2:20 pm
From: News123
Hi Gabriel,
Gabriel Genellina wrote:
> En Thu, 04 Feb 2010 19:34:20 -0300, News123 <news123@free.fr> escribi�:
>
>> I wrote a small xmlrpc client on Windows 7 with python 2.6
>>
>> srv = xmlrpclib.Server('http://localhost:80')
>>
>> I was able to perform about 1 rpc call per second
>>
>> After changing to
>> srv = xmlrpclib.Server('http://127.0.0.1:80')
>>
>> I was able to perform about 10 to 16 rpc calls per second.
>
> Not necesarily. There is another difference: 127.0.0.1 is an IPv4
> address, localhost maps to both IPv4 and IPv6 addresses (::1)
>
> I vaguely remember a problem with that - IPv6 is tried first, doesn't
> work, only then IPv4, and that slows down the whole process.
> Try disabling completely the IPv6 stack, if you don't need it.
How can I completely disable IP6.
I went to my network device and disabled IPV6 under properties. The
XMRPC calls were stull slow.
bye
N
==============================================================================
TOPIC: Dreaming of new generation IDE
http://groups.google.com/group/comp.lang.python/t/e019614ea149e7bd?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Feb 5 2010 2:22 pm
From: "bartc"
"Steve Holden" <steve@holdenweb.com> wrote in message
news:mailman.1998.1265399766.28905.python-list@python.org...
> Arnaud Delobelle wrote:
>> Robert Kern <robert.kern@gmail.com> writes:
>>
>>> I prefer Guido's formulation (which, naturally, I can't find a direct
>>> quote for right now): if you expect that a boolean argument is only
>>> going to take *literal* True or False, then it should be split into
>>> two functions.
>>
>> So rather than three boolean arguments, would you have eight functions?
>>
> If there's genuinely a need for that functionality, yes.
So you want a function such as drawtext(s, bold=true, italic=false,
underline=true) to be split into:
drawtext(s)
drawtextb(s)
drawtexti(s)
drawtextu(s)
drawtextbi(s)
drawtextbu(s)
drawtextiu(s)
drawtextbiu(s)
Which of course is going to be fun if the bold/italic/underline values are
not constants; instead of writing:
drawtext(s,b,i,u)
you have to say:
if b==0 and i==0 and u==0:
drawtext(s)
elif b==1 and i==0 and u==0:
drawtextb(s)
and so on. With half-a-dozen or more booleans, this becomes completely
impractical.
--
Bartc
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en
To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home