On Sun, Oct 26, 2014 at 5:12 PM, Steven D'Aprano
wrote:
> However, mutator methods on a class don't change global state, they change
> the state of an instance. Even random.random and friends don't change
> global state, they change a (hidden) instance, and you can create your own
> instances when
Chris Angelico wrote:
> On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody
> wrote:
>> Its generally accepted that side-effecting functions are not a good idea
>> -- typically a function that returns something and changes global state.
>
> Only in certain circles. Not in Python. There are large number
On Sun, Oct 26, 2014 at 3:15 PM, Steven D'Aprano
wrote:
> Since the list items exist only to be counted, the actual item used makes no
> difference. You could use any value at all, or even a different value each
> time:
>
> len([random.random() for line in lines if not line.strip()])
>
> What
Ben Finney wrote:
> Steven D'Aprano writes:
>
>> I suspect that Guido and the core developers disagree with you, since
>> they had the opportunity to fix that in Python 3 and didn't.
>
> That doesn't follow; there are numerous warts in Python 2 that were not
> fixed in Python 3. As I understan
On 10/25/2014 07:20 PM, Chris Angelico wrote:
> So don't use Python idioms in BASIC. :) Back when I used to write
> BASIC code, I'd do explicit comparisons with zero for this sort of
> thing... these days, I'd use Python idioms, but I'd also write Python
> code :)
>
> I think it's indicative that
On Sun, Oct 26, 2014 at 12:04 PM, Michael Torrie wrote:
> But you can run
> into trouble if you tried to use a common python idiom like this:
>
> x = read_some_lines() 'returns number of lines read, or zero if none are
> if not x:
> print ("I couldn't read any lines")
> exit(1)
>
>
Ben Finney writes:
> This is short and clear and needs no leaking of the underlying bool
> implementation::
>
> len(True for line in lines if line.strip())
Correction::
len([True for line in lines if line.strip()])
--
\ “Our task must be to free ourselves from our prison by widen
On 10/22/2014 09:46 PM, Gregory Ewing wrote:
> Chris Angelico wrote:
>> I've seen much MUCH worse... where multiple conditional
>> expressions get combined arithmetically, and then the result used
>> somewhere...
>
> In the days of old-school BASIC it was common to
> exploit the fact that boolean
Steven D'Aprano writes:
> I suspect that Guido and the core developers disagree with you, since
> they had the opportunity to fix that in Python 3 and didn't.
That doesn't follow; there are numerous warts in Python 2 that were not
fixed in Python 3. As I understand it, the preservation of bool–i
Ben Finney wrote:
> Steven D'Aprano writes:
>
>> Of course it won't be clear to *everyone* but it should be clear
>> enough to people who are familiar with standard Python idioms. A
>> concrete example should be more obvious than the fake example:
>>
>> title = ('Mr', 'Ms')[person.sex == 'F']
>>
On Sun, Oct 26, 2014 at 11:09 AM, Mark Lawrence wrote:
> Horrible IMHO, it just doesn't fit in my mind set. Still each to their own.
Yeah, the comprehension version is way more explicit (though it
probably ought to be a set and a set comp, not a tuple and a list
comp), and not as good, IMO. But
On 26/10/2014 01:01, Chris Angelico wrote:
On Sun, Oct 26, 2014 at 10:53 AM, Ben Finney wrote:
Dan Stromberg writes:
EG, if I have 3 mutually exclusive command line options, I'll do
something like:
if option_a + option_b + option_c != 1:
sys.stderr.write('{}: -a, -b and -c are mutually
On Sun, Oct 26, 2014 at 10:53 AM, Ben Finney wrote:
> Dan Stromberg writes:
>
>> EG, if I have 3 mutually exclusive command line options, I'll do
>> something like:
>>
>> if option_a + option_b + option_c != 1:
>>sys.stderr.write('{}: -a, -b and -c are mutually
>> exclusive\n'.format(sys.arg
Dan Stromberg writes:
> EG, if I have 3 mutually exclusive command line options, I'll do
> something like:
>
> if option_a + option_b + option_c != 1:
>sys.stderr.write('{}: -a, -b and -c are mutually
> exclusive\n'.format(sys.argv[0]))
That is an excellent illustration of why exploiting th
On 25/10/2014 23:48, Terry Reedy wrote:
On 10/25/2014 2:23 PM, Dennis Lee Bieber wrote:
On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head
declaimed the following:
I do get the difference. I don't actually use Python 2. I use
CodeSkulptor. I do have Python 3 installed. Actually I have Pyth
On 10/25/2014 6:22 PM, Dan Sommers wrote:
On Sat, 25 Oct 2014 23:41:52 +0200, Wolfgang Maier wrote:
... It may be rare to use an expression both for its side-effects and
its return value ...
A lot of concurrency-related operations work that way. In the old days,
it was CPU-level Test and Set
On 10/25/2014 2:23 PM, Dennis Lee Bieber wrote:
On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head
declaimed the following:
I do get the difference. I don't actually use Python 2. I use
CodeSkulptor. I do have Python 3 installed. Actually I have Python 2
installed but IDLE defaults to Pytho
On Sat, Oct 25, 2014 at 1:45 PM, Ben Finney wrote:
> Steven D'Aprano writes:
>> title = ('Mr', 'Ms')[person.sex == 'F']
>>
>> which should be clear to anyone who understands indexing in Python and
>> that True == 1 and False == 0.
>
> I consider it an accident of history, and one which should not
On Sat, 25 Oct 2014 23:41:52 +0200, Wolfgang Maier wrote:
> ... It may be rare to use an expression both for its side-effects and
> its return value ...
A lot of concurrency-related operations work that way. In the old days,
it was CPU-level Test and Set (or Compare and Set) instructions. These
On Fri, 24 Oct 2014 20:15:02 -0400, Seymore4Head wrote:
> On Wed, 22 Oct 2014 16:30:37 -0400, Seymore4Head
> wrote:
>
> name="012"
name is a string of 3 characters
> b=list(range(3))
b is a list of 3 numbers
> print (name[1])
name[1] is the string "1"
> print (b[1])
b[1] is the number 1
On 25.10.2014 19:27, Rustom Mody wrote:
Moved from other (Seymore's) thread where this is perhaps not relevant
On Saturday, October 25, 2014 1:15:09 PM UTC+5:30, Steven D'Aprano wrote:
Rustom Mody wrote:
On Saturday, October 25, 2014 11:20:03 AM UTC+5:30, Chris Angelico wrote:
On Sat, Oct 25
On Sat, 25 Oct 2014 15:01:54 +, Grant Edwards wrote:
> On 2014-10-24, Denis McMahon wrote:
>> On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote:
>>
>>> Thanks everyone for your suggestions.
>>
>> Try loading the following in codeskulptor:
>>
>> http://www.codeskulptor.org/#user38_j6kGKge
Steven D'Aprano writes:
> Of course it won't be clear to *everyone* but it should be clear
> enough to people who are familiar with standard Python idioms. A
> concrete example should be more obvious than the fake example:
>
> title = ('Mr', 'Ms')[person.sex == 'F']
>
> which should be clear to a
On Sat, 25 Oct 2014 16:03:16 +1100, Steven D'Aprano wrote:
> [Alister]
>> I had to mentally step through this before it became apparent what it
>> was doing, can see places where it could be usefull (a switch
>> replacement) but it is not instantly obvious
>
> Very little code is instantly obvio
On Sat, 25 Oct 2014 14:23:44 -0400, Dennis Lee Bieber
wrote:
>On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head
> declaimed the following:
>
>>
>>I do get the difference. I don't actually use Python 2. I use
>>CodeSkulptor. I do have Python 3 installed. Actually I have Python 2
>>installed but
Moved from other (Seymore's) thread where this is perhaps not relevant
On Saturday, October 25, 2014 1:15:09 PM UTC+5:30, Steven D'Aprano wrote:
> Rustom Mody wrote:
>
> > On Saturday, October 25, 2014 11:20:03 AM UTC+5:30, Chris Angelico wrote:
> >> On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody
On Saturday, October 25, 2014 1:15:09 PM UTC+5:30, Steven D'Aprano wrote:
> Rustom Mody wrote:
>
> > On Saturday, October 25, 2014 11:20:03 AM UTC+5:30, Chris Angelico wrote:
> >> On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody wrote:
> >> > Its generally accepted that side-effecting functions are n
There's a metope group for Python in NYC and they have project nights/study
groups. You should check them out.
http://www.meetup.com/nycpython/
On Saturday, October 25, 2014 11:08:31 AM UTC-5, ryguy7272 wrote:
> Are there any Python professionals in or around NYC who can meetup for an
> hour o
Are there any Python professionals in or around NYC who can meetup for an hour
or two to help me with a few things? I've been trying to run various Python
scripts for a few months now, and I'm not having any success with this stuff at
all. Basically, everything built into Python works perfectly
On 2014-10-24, Denis McMahon wrote:
> On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head wrote:
>
>> Thanks everyone for your suggestions.
>
> Try loading the following in codeskulptor:
>
> http://www.codeskulptor.org/#user38_j6kGKgeOMr_0.py
No.
We[1] aren't intested in whatever Python-like langua
On Sat, Oct 25, 2014 at 12:46 AM, Larry Hudson
wrote:
>> name="123-xyz-abc"
>> for x in name:
>> if x in range(10):
>
> x is a character (a one-element string). range(10) is a list of ints. A
> string will never match an int. BTW, as it is used here, range(10) is for
> Py2, for Py3 it need
On Sat, Oct 25, 2014 at 5:58 AM, Ned Batchelder wrote:
> You mention "standard Python idioms." I think this style of
> conditional-via-indexing is becoming quite uncommon, and is no longer one of
> the standard Python idioms. This is now in the category of "outdated hack."
I think that's probab
It’s a special HTTPS url and searching further it seems to be a SNI problem
talked about here:
http://stackoverflow.com/questions/18578439/using-requests-with-tls-doesnt-give-sni-support
> 25 okt 2014 kl. 08:48 skrev Joel Goldstick :
>
> On Sat, Oct 25, 2014 at 9:40 AM, Roland Hedberg wrote:
>
On Sat, Oct 25, 2014 at 9:40 AM, Roland Hedberg wrote:
> When I try to access a URL using requests I always get:
> socket.error: [Errno 104] Connection reset by peer
>
> If I try to access the same URL using curl I get no error message instead I
> get the page.
> The same result if I use a web br
Oh, by the way!
To make this more interesting :-/
I saw this behavior on a Linux machine (Ubuntu 14.04 LTS) using Python 2.7.6 if
I do the same exercise
on a Mac OS X machine also with Python 2.7.6 - no problem what so ever.
> 25 okt 2014 kl. 08:40 skrev Roland Hedberg :
>
> When I try to acce
When I try to access a URL using requests I always get:
socket.error: [Errno 104] Connection reset by peer
If I try to access the same URL using curl I get no error message instead I get
the page.
The same result if I use a web browser like Safari.
But, if I use python httplib I also get Errno
On 10/25/14 1:03 AM, Steven D'Aprano wrote:
alister wrote:
>On Fri, 24 Oct 2014 10:20:30 -0700, Dan Stromberg wrote:
>
>>On Fri, Oct 24, 2014 at 1:38 AM, Steven D'Aprano
>> wrote:
>>>I don't get why that's considered hard to read.
>>
>>>So why is it hard to read when the index is a flag?
>
Rustom Mody wrote:
> On Saturday, October 25, 2014 11:20:03 AM UTC+5:30, Chris Angelico wrote:
>> On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody wrote:
>> > Its generally accepted that side-effecting functions are not a good
>> > idea -- typically a function that returns something and changes globa
On 25/10/2014 03:41, Seymore4Head wrote:
On Fri, 24 Oct 2014 19:16:21 -0700, Larry Hudson
wrote:
On 10/24/2014 07:38 AM, Seymore4Head wrote:
I do get the difference. I don't actually use Python 2. I use
CodeSkulptor. I do have Python 3 installed. Actually I have Python 2
installed but ID
39 matches
Mail list logo