Re: Practice question

2014-10-06 Thread C Smith
14 wrote:
> On 10/5/14 7:02 PM, Seymore4Head wrote:
>>
>> For the record, I don't want a hint.  I want the answer.
>> I see a practice question is similar to this.
>> 15 <= x < 30  And it wants a similar expression that is equivalent.
>> So the right answer is 15<= x or x <30
>
>
> No, "15 <= x < 30" is equivalent to "15 <= x and x < 30".
>
>> but one of the other answers is
>> not (15<= x and x <30)
>
>
> You are speaking ambiguously.  Which did you mean:
> a) one of the other answers isn't "15 <= x and x < 30", or:
> b) one of the other answers is "not (15 <= x and x < 30)" ?
>
> --
> Ned Batchelder, http://nedbatchelder.com
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


article posting

2014-10-06 Thread Maxim Lesnichenko
Dear Python community members,

 

I would be very appreciate you if somebody could give me the contacts of
responsible person for posting articles on python.org resource.

 

It could be chief editor`s or administrator`s name and  e-mail,

 

Thank you very much advance,

 

 

Best Regards 

Maxim Lesnichenko 
Business Development Manager 
Redwerk 

phone: +1 (347) 329-1444 
email:   [email protected] 
skype: redwerk.com 
web:    http://redwerk.com

 



 

 

-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3.4.1 on W2K?

2014-10-06 Thread Pal Acreide
Hi, I'm a lurker here and enjoy the back-and-forth, especially among the 
experts among you.


My question is this: I have Python 3.4.1 installed on 64-bit Win 7 Home 
Premium, and on 32-bit Win 7 Pro  running on a virtual machine (Oracle 
VirtualBox). Now I'm trying to install it on Windows 2000 Pro also running 
under VBox. However, at some point near the end of the Python installation I 
get an error message to the effect that a program required for Win Installer is 
missing and the installation aborts. I'm running W2K SP4 + (undocumented) SP5.1.


I guess it comes down to: Can Python 3.4.1 be installed on W2K?

BTW, the reason I run VBox is that I belong to a group of diehard users of the 
classic DOS word-processor XyWrite. I've devised a way to use Python as an 
extension of XyWrite's built-in Programming Language (XPL): 
http://users.datarealm.com/xywwweb/xypydoc.htm

Although it works well on virtual Win 7 Pro, I'd like to get it going in W2K if 
possible.

Thanks. 

-- 
Pal A.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "High water" Memory fragmentation still a thing?

2014-10-06 Thread Steven D'Aprano
On Sun, 05 Oct 2014 20:23:42 +0100, mm0fmf wrote:

> On 04/10/2014 02:02, Steven D'Aprano wrote:
>> Way back in the mid 1980s, Apple Macintoshes used a memory manager
>> which could move memory around.
> 
> But the memory manager didn't return a pointer to memory the way malloc
> does. It returned a pointer to the pointer and you had to double
> dereference it to get the heap address (ISTR, 30 years ago now).

Correct.


> The
> advantage being the memory manager could shuffle the memory about and
> update the pointers. Your pointer to a pointer would still point to the
> same block after a shuffle. Of course you couldn't hold on to a partial
> dereference across system calls... can you guess why? :-)

Because system calls might trigger a memory compaction or move.


Before the move, you have a managed "pointer to pointer" (handle) 
pointing to a managed point which points to a block of memory:


handle -> pointer -> "Some stuff here"

Grab a copy of the pointer with a partial deref:

myPtr := handle^;  (*I'm an old Pascal guy.*)


So we have this:

handle -> pointer -> "Some stuff here"
myPtr ---^


Then you call a system routine that moves memory, and the memory manager 
moves the block, updating the pointer, but leaving myPtr pointing at 
garbage:


handle -> pointer > "Some stuff here"
myPtr ---^


and as soon as you try using myPtr, you likely get the dreaded Bomb 
dialog box:

http://www.macobserver.com/tmo/article/happy-birthday-mac-how-to-recover-from-the-dreaded-bomb-box-error-message

I'm not suggesting that a 1984 memory manager is the solution to all our 
problems. I'm just pointing it out as proof that the concept works. If I 
knew more about Java and .Net, I could use them as examples instead :-)



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.4.1 on W2K?

2014-10-06 Thread Tim Golden
On 06/10/2014 01:04, Pal Acreide wrote:
> Hi, I'm a lurker here and enjoy the back-and-forth, especially among the
> experts among you.
> 
> My question is this: I have Python 3.4.1 installed on 64-bit Win 7 Home
> Premium, and on 32-bit Win 7 Pro  running on a virtual machine (Oracle
> VirtualBox). Now I'm trying to install it on Windows 2000 Pro also
> running under VBox. However, at some point near the end of the Python
> installation I get an error message to the effect that a program
> required for Win Installer is missing and the installation aborts. I'm
> running W2K SP4 + (undocumented) SP5.1.
> 
> I guess it comes down to: Can Python 3.4.1 be installed on W2K?

I'm afraid we formally dropped support for Win 2000 at least one version
ago. You can see the official schedule here:

http://legacy.python.org/dev/peps/pep-0011/#unsupporting-platforms

and you'll note that Win2K was unsupported from 3.3.

In the first instance, all this means is that we no longer go out of our
way to use backwards-compatible APIs (ie to avoid newer APIs). At that
stage, it's quite possible that much or all Python code will still work
on an older platform.

But at a certain point, we may decide to de-clutter the codebase by
removing particular #ifdefs and workarounds which exist to support a
now-unsupported platform. At that point, you would expect Python to no
longer be usable on that platform in some way or another.


Of course, if you're happy to work with a slightly older version of
Python, such as 3.2, then you should be fine.

TJG

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.4.1 on W2K?

2014-10-06 Thread Chris Angelico
On Mon, Oct 6, 2014 at 11:04 AM, Pal Acreide
 wrote:
> BTW, the reason I run VBox is that I belong to a group of diehard users of
> the classic DOS word-processor XyWrite. I've devised a way to use Python as
> an extension of XyWrite's built-in Programming Language (XPL):
> http://users.datarealm.com/xywwweb/xypydoc.htm
> Although it works well on virtual Win 7 Pro, I'd like to get it going in W2K
> if possible.

Wow. I wonder, since you're already poking around with extremely
legacy stuff, would it be easier for you to use OS/2 instead of Win2K?
Paul Smedley still produces OS/2 builds of Python, and OS/2 itself
runs happily under VirtualBox (we have an OS/2 VM still on our network
here, and I use Python to manage its backups). Might not end up any
better than your current system, but it might be!

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Clearing globals in CPython

2014-10-06 Thread jakubo
On 2014-10-01, Peter Otten <[email protected]> wrote:
> Steven D'Aprano wrote:
>
>> Out of curiosity, I ran:
>> 
>> globals().clear()
>> 
>> Oops.
>> 
>> So, with no built-ins available, import no longer works. That makes things
>> rather tricky.
>> 
>> Obviously the easiest way to recover is to exit the current session and
>> restart it, but as a challenge, can we recover from this state?
>
> $ python3
> Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
> [GCC 4.8.2] on linux
> Type "help", "copyright", "credits" or "license" for more information.
 globals().clear()
 import that
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: __import__ not found
 object = 1 .__class__.__bases__[0]
 Quitter = [c for c in object.__subclasses__() if c.__name__ == 
> "Quitter"][0]
 __builtins__ = Quitter.__call__.__globals__["__builtins__"]
 import this
> The Zen of Python, by Tim Peters
>
> Beautiful is better than ugly.
> Explicit is better than implicit.
> Simple is better than complex.
> Complex is better than complicated.
> Flat is better than nested.
> Sparse is better than dense.
> Readability counts.
> Special cases aren't special enough to break the rules.
> Although practicality beats purity.
> Errors should never pass silently.
> Unless explicitly silenced.
> In the face of ambiguity, refuse the temptation to guess.
> There should be one-- and preferably only one --obvious way to do it.
> Although that way may not be obvious at first unless you're Dutch.
> Now is better than never.
> Although never is often better than *right* now.
> If the implementation is hard to explain, it's a bad idea.
> If the implementation is easy to explain, it may be a good idea.
> Namespaces are one honking great idea -- let's do more of those!


I have funnier one :)

$ python3
Python 3.4.1 (default, Sep 10 2014, 22:21:18)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> globals().clear()
>>> import this
Traceback (most recent call last):
  File "", line 1, in 
  ImportError: __import__ not found
>>> True.__
True.__abs__(   True.__dir__(   True.__format__(
True.__init__(  True.__mul__(   True.__radd__(
True.__rlshift__(   True.__rshift__(True.__sub__(
True.__add__(   True.__divmod__(True.__ge__(
True.__int__(   True.__ne__(True.__rand__(
True.__rmod__(  True.__rsub__(  True.__subclasshook__(
True.__and__(   True.__doc__True.__getattribute__(
True.__invert__(True.__neg__(   True.__rdivmod__(
True.__rmul__(  True.__rtruediv__(  True.__truediv__(
True.__bool__(  True.__eq__(True.__getnewargs__(
True.__le__(True.__new__(   True.__reduce__(
True.__ror__(   True.__rxor__(  True.__trunc__(
True.__ceil__(  True.__float__( True.__gt__(
True.__lshift__(True.__or__(True.__reduce_ex__(
True.__round__( True.__setattr__(   True.__xor__(
True.__class__( True.__floor__( True.__hash__(
True.__lt__(True.__pos__(   True.__repr__(
True.__rpow__(  True.__sizeof__(
True.__delattr__(   True.__floordiv__(  True.__index__(
True.__mod__(   True.__pow__(   True.__rfloordiv__(
True.__rrshift__(   True.__str__(
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>>


After invoking autocompletion (.__ and hitting tab),
session has been automagically healed.


-- 
jakubo
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Clearing globals in CPython

2014-10-06 Thread Steven D'Aprano
On Mon, 06 Oct 2014 09:05:17 +, jakubo wrote:

> After invoking autocompletion (.__ and hitting tab), session has been
> automagically healed.


That's ... um ...

I have no words.


Can you confirm that autocompletion modifies globals()? I don't have 3.4 
installed here.


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Clearing globals in CPython

2014-10-06 Thread Chris Angelico
On Mon, Oct 6, 2014 at 8:08 PM, Steven D'Aprano  wrote:
> On Mon, 06 Oct 2014 09:05:17 +, jakubo wrote:
>
>> After invoking autocompletion (.__ and hitting tab), session has been
>> automagically healed.
>
>
> That's ... um ...
>
> I have no words.
>
>
> Can you confirm that autocompletion modifies globals()? I don't have 3.4
> installed here.

I can confirm that the trick does work. That's... extremely weird.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


ruby instance variable in python

2014-10-06 Thread roro codeath
for instance in ruby i can write following code:

module M
def ins_var
@ins_var ||= nil
end

def m
@ins_var = "val"
end

def m2
ins_var # => "val"
end

end

in py

# m.py

# how to def a ins_var?

def m:
# how to set a ins_var?

def m2:
# how to get a ins_var?
-- 
https://mail.python.org/mailman/listinfo/python-list


ruby instance variable in python

2014-10-06 Thread roro codeath
in ruby:

module M
def ins_var
@ins_var ||= nil
end

def m
@ins_var = 'val'
end

def m2
m
ins_var # => 'val'
end
end

in py:

# m.py

# how to def ins_var

def m:
# how to set ins_var

def m2:
m()
# how to get ins var
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ruby instance variable in python

2014-10-06 Thread David Palao
Hello,
If you explain what the ruby code does, I think much more people will
be able to help you. Don't forget, this is a Python list. Not
everybody knows Ruby here.

Best

2014-10-06 12:06 GMT+02:00 roro codeath :
> in ruby:
>
> module M
> def ins_var
> @ins_var ||= nil
> end
>
> def m
> @ins_var = 'val'
> end
>
> def m2
> m
> ins_var # => 'val'
> end
> end
>
> in py:
>
> # m.py
>
> # how to def ins_var
>
> def m:
> # how to set ins_var
>
> def m2:
> m()
> # how to get ins var
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Representing mathematical equations

2014-10-06 Thread varun7rs
Hello,

I am working on a mathematical equation which I'm finding really hard to 
express in python. Could any of you spare some time to help me out?

The equation looks like this

b(i,x) = [Σ(l∈L) [bd(l) * dist(l) * hc(l)]]  / Σ(l∈L) l

I have a problem in representing the above equation. I don't know how to use 
teh loops over here to express b(i,x)

i,x,l are sets with different numbers

Thank You
I'm sorry if the equation is not expressed in a standard form. I don't have 
LateX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:Representing mathematical equations

2014-10-06 Thread Dave Angel
[email protected] Wrote in message:
> Hello,
> 
> I am working on a mathematical equation which I'm finding really hard to 
> express in python. Could any of you spare some time to help me out?
> 
> The equation looks like this
> 
> b(i,x) = [Σ(l∈L) [bd(l) * dist(l) * hc(l)]]  / Σ(l∈L) l
> 
> I have a problem in representing the above equation. I don't know how to use 
> teh loops over here to express b(i,x)
> 
> i,x,l are sets with different numbers
> 

Perhaps you meant  L is a set of numbers,  none repeated.  If you
 really meant l, I have no clue.

As for i and x, they don't appear on the right side so they're a
 red herring. 

I also don't know what bd, dist, and hc are. Are they each a
 function of a single number? Or are they vectors,  indexed by
 int? If so, then presumably L is a set of ints.

How about you express some sample data that you'd like to
 evaluate. For example,  start with
   L = set (1, 4, 3)
   bd = [4.3, 12.11, 93, -0.9, 42]
.



> I'm sorry if the equation is not expressed in a standard form. I don't have 
> LateX

No problem,  you did a good job expressing it in unicode in a text
 message. 

Ii Ll  1

-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Skip Montanaro
On Sun, Oct 5, 2014 at 9:47 PM, Rustom Mody  wrote:
> Sorry Seymore if this sounds condescending -- its not a complaint
> against you but against those who treat the print statement/expression as
> kosher for newbies.

So if you're not griping about Seymore's original post, are you
griping about my response? It was the one you quoted. And what's with
the comparison between use of the print statement and driving on the
wrong side of the road?

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread varun7rs
On Monday, 6 October 2014 13:14:04 UTC+2, [email protected]  wrote:
> Hello,
> 
> 
> 
> I am working on a mathematical equation which I'm finding really hard to 
> express in python. Could any of you spare some time to help me out?
> 
> 
> 
> The equation looks like this
> 
> 
> 
> b(i,x) = [Σ(l∈L) [bd(l) * dist(l) * hc(l)]]  / Σ(l∈L) l
> 
> 
> 
> I have a problem in representing the above equation. I don't know how to use 
> teh loops over here to express b(i,x)
> 
> 
> 
> i,x,l are sets with different numbers
> 
> 
> 
> Thank You
> 
> I'm sorry if the equation is not expressed in a standard form. I don't have 
> LateX

Okay, I forgot to explain them. L is a set of links, dist is a number 
(distance), bd is the bandwidth and hc is a number as well 
(hopcount)...different bandwidths, hopcounts and distances for different 
links...
b(i,x) is what i intend to calculate out of these details...here 'i' could be 
the head or tail of the link l and x is a node that hosts i

Thank You
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread varun7rs
On Monday, 6 October 2014 15:03:44 UTC+2, [email protected]  wrote:
> On Monday, 6 October 2014 13:14:04 UTC+2, [email protected]  wrote:
> 
> > Hello,
> 
> > 
> 
> > 
> 
> > 
> 
> > I am working on a mathematical equation which I'm finding really hard to 
> > express in python. Could any of you spare some time to help me out?
> 
> > 
> 
> > 
> 
> > 
> 
> > The equation looks like this
> 
> > 
> 
> > 
> 
> > 
> 
> > b(i,x) = [Σ(l∈L) [bd(l) * dist(l) * hc(l)]]  / Σ(l∈L) l
> 
> > 
> 
> > 
> 
> > 
> 
> > I have a problem in representing the above equation. I don't know how to 
> > use teh loops over here to express b(i,x)
> 
> > 
> 
> > 
> 
> > 
> 
> > i,x,l are sets with different numbers
> 
> > 
> 
> > 
> 
> > 
> 
> > Thank You
> 
> > 
> 
> > I'm sorry if the equation is not expressed in a standard form. I don't have 
> > LateX
> 
> 
> 
> Okay, I forgot to explain them. L is a set of links, dist is a number 
> (distance), bd is the bandwidth and hc is a number as well 
> (hopcount)...different bandwidths, hopcounts and distances for different 
> links...
> 
> b(i,x) is what i intend to calculate out of these details...here 'i' could be 
> the head or tail of the link l and x is a node that hosts i
> 
> 
> 
> Thank You

Unbelievable. I again forgot to express them

L  = [(1,3), (5,7), .]
bd = [23, 34,43.44.]
dist = [3,7,5,7, ]
hc = [2,3,4,1,2,2,...]
for every l belonging to L, i could be either 1 or 3 for L[0], similarly for 
L[1] it could be 5 or 7
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ruby instance variable in python

2014-10-06 Thread Mark Lawrence

On 06/10/2014 11:45, David Palao wrote:

Hello,
If you explain what the ruby code does, I think much more people will
be able to help you. Don't forget, this is a Python list. Not
everybody knows Ruby here.

Best

2014-10-06 12:06 GMT+02:00 roro codeath :

in ruby:



Please don't top post here, thank you.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Python 2.76

2014-10-06 Thread Sas Parmar
Dear Sirs

I am working on a project at Service Birmingham to migrate our applications 
from Windows Server 2003 over to Windows Server 2008 R2

Can you confirm if Python 2.76 is compatible with Server 2008 R2?

If not can you confirm if any changes can be made to make it work on Server 
2008 R2 (ie. Version updates or configuration changes)

Kind Regards,

Sas Parmar
Contractor for Server 2003 to 2008 Migration

Service Birmingham | Units 2&3 B1 | 50 Summer Hill Road | Birmingham | B1 3RB
[email protected]


***
The information contained within this e-mail (and any attachment) sent by 
Service Birmingham Ltd. is confidential and may be legally privileged.  It is 
intended only for the named recipient or entity to whom it is addressed.  If 
you are not the intended recipient, please notify the sender and delete the 
e-mail immediately.  Unauthorised access, use, disclosure, storage or copying 
is not permitted and may be unlawful.  Any e-mail including its content may be 
monitored and used by Service Birmingham Ltd. for reasons of security and for 
monitoring internal compliance with Security Policy.  E-mail blocking software 
will also be used.  Any views or opinions expressed are solely those of the 
originator and do not necessarily represent those of Service Birmingham Ltd.

Although Service Birmingham Ltd. has made every reasonable effort to ensure 
that this message and any attachments contain no viruses and have not been 
intercepted or amended, it can not make any assurances to this effect.

Service Birmingham Ltd., Registered in England & Wales under Company No. 
05660977
Registered Office: Units 2&3, B1, 50 Summer Hill Road, Birmingham, B1 3BZ.
***-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread Mark Lawrence

On 06/10/2014 14:07, [email protected] wrote:

[snip 69 lines]


L  = [(1,3), (5,7), .]
bd = [23, 34,43.44.]
dist = [3,7,5,7, ]
hc = [2,3,4,1,2,2,...]
for every l belonging to L, i could be either 1 or 3 for L[0], similarly for 
L[1] it could be 5 or 7



Would you please access this list via 
https://mail.python.org/mailman/listinfo/python-list or read and action 
this https://wiki.python.org/moin/GoogleGroupsPython to prevent us 
seeing the double line spacing and single line paragraphs that I've 
snipped above, thanks.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Joel Goldstick
On Mon, Oct 6, 2014 at 9:52 AM, Sas Parmar
 wrote:
> Dear Sirs
>
>
>
> I am working on a project at Service Birmingham to migrate our applications
> from Windows Server 2003 over to Windows Server 2008 R2
>
>
>
> Can you confirm if Python 2.76 is compatible with Server 2008 R2?
>
>
>
> If not can you confirm if any changes can be made to make it work on Server
> 2008 R2 (ie. Version updates or configuration changes)
>
>
Look Here:  http://ampps.com/download

>
> Kind Regards,
>
>
>
> Sas Parmar
>
> Contractor for Server 2003 to 2008 Migration
>
>
>
> Service Birmingham | Units 2&3 B1 | 50 Summer Hill Road | Birmingham | B1
> 3RB
>
> [email protected]
>
>
>
>
> ***
> The information contained within this e-mail (and any attachment) sent by
> Service Birmingham Ltd. is confidential and may be legally privileged. It is
> intended only for the named recipient or entity to whom it is addressed. If
> you are not the intended recipient, please notify the sender and delete the
> e-mail immediately. Unauthorised access, use, disclosure, storage or copying
> is not permitted and may be unlawful. Any e-mail including its content may
> be monitored and used by Service Birmingham Ltd. for reasons of security and
> for monitoring internal compliance with Security Policy. E-mail blocking
> software will also be used. Any views or opinions expressed are solely those
> of the originator and do not necessarily represent those of Service
> Birmingham Ltd.
>
> Although Service Birmingham Ltd. has made every reasonable effort to ensure
> that this message and any attachments contain no viruses and have not been
> intercepted or amended, it can not make any assurances to this effect.
>
> Service Birmingham Ltd., Registered in England & Wales under Company No.
> 05660977
> Registered Office: Units 2&3, B1, 50 Summer Hill Road, Birmingham, B1 3BZ.
> ***
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Chris Angelico
On Tue, Oct 7, 2014 at 1:18 AM, Joel Goldstick  wrote:
> Look Here:  http://ampps.com/download

Any particular reason for using this third-party build of Python? I
note that they distribute some slightly old builds (2.7.2 on Windows,
2.7.6 on other platforms), so unless they have some strong
justification, I'd prefer to recommend the official python.org
installers and all the bugfixes they incorporate.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Chris Angelico
On Tue, Oct 7, 2014 at 12:52 AM, Sas Parmar
 wrote:
> I am working on a project at Service Birmingham to migrate our applications
> from Windows Server 2003 over to Windows Server 2008 R2
>
> Can you confirm if Python 2.76 is compatible with Server 2008 R2?
>
> If not can you confirm if any changes can be made to make it work on Server
> 2008 R2 (ie. Version updates or configuration changes)

It should be fully supported. However, unless you have a particular
reason for using 2.7.6 (it's normally written in three parts, by the
way), you'll probably want to use the latest bug-fix release, 2.7.8;
there've been a number of bugs fixed, including some SSL improvements.
Where do you normally download Python from? There are a number of
different sources, and some of them may offer different promises of
support (ActiveState, for instance, supports some older versions of
Python), but this is the primary place to get the official installers:

https://www.python.org/download/releases/2.7.8/

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Joel Goldstick
On Mon, Oct 6, 2014 at 10:27 AM, Chris Angelico  wrote:
> On Tue, Oct 7, 2014 at 1:18 AM, Joel Goldstick  
> wrote:
>> Look Here:  http://ampps.com/download
>
> Any particular reason for using this third-party build of Python? I
> note that they distribute some slightly old builds (2.7.2 on Windows,
> 2.7.6 on other platforms), so unless they have some strong
> justification, I'd prefer to recommend the official python.org
> installers and all the bugfixes they incorporate.
>

No, I just meant to point out that these people are using a version of
2.7 with the OS the OP is using.
Maybe that is helpful to know.

> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Chris Angelico
On Tue, Oct 7, 2014 at 1:30 AM, Joel Goldstick  wrote:
> No, I just meant to point out that these people are using a version of
> 2.7 with the OS the OP is using.
> Maybe that is helpful to know.

Sure. A little extra verbiage could have made that clearer :)

Unfortunately it's not proof; they seem to be doing their own builds,
so it's actually possible that they've changed something to make it
work on those platforms (which, if it were true, would explain the lag
on versions - it takes work to maintain something like that, and it's
often not worth redoing that for each bugfix release). So while it may
be helpful, it's certainly not conclusive.

I did a bit of quick poking around, and didn't find anywhere a simple
list of the officially-supported platforms for each Python release.
PEP 11 links it to Microsoft's support lifecycle, which means you have
to go pointer-chasing a bit to figure out what's supported. So there's
this:

http://support2.microsoft.com/lifecycle/?p1=14134

Now, Python 2.7.0 came out in 2010:

https://www.python.org/download/releases/2.7

Which means Server 2008 R2 was around when it was first released. I'm
not entirely sure what "Service Pack Support End Date" means, but in
any case, there's mainstream support for Server 2008 R2 until 2015,
ergo Python 2.7.8 should be supported. But it's a smidge complicated
to look this all up, and I'm not confident that my lookups have been
entirely correct. Feel free to do your own pointer chase and verify or
disprove my results.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Chris “Kwpolska” Warrick
On Mon, Oct 6, 2014 at 4:30 PM, Joel Goldstick  wrote:
> […]
> No, I just meant to point out that these people are using a version of
> 2.7 with the OS the OP is using.
> Maybe that is helpful to know.

This would have assumed those people bothered keeping their Python
version up-to-date.

Now: Windows Server 2008 R2 is the server counterpart of Windows 7.
Which pretty much HAS to support recently released software (py2.7.6
was released 2013-11-10).  Nevertheless, it’d be nice to upgrade to
Python 2.7.8, which also supports the system, and features new
capabilities, bug fixes and security fixes (including Heartbleed…)
without breaking backwards compatibility.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread Michael Torrie
On 10/06/2014 07:07 AM, [email protected] wrote:
>> Okay, I forgot to explain them. L is a set of links, dist is a
>> number (distance), bd is the bandwidth and hc is a number as well
>> (hopcount)...different bandwidths, hopcounts and distances for different
>> links... b(i,x) is what i intend to calculate out of these details...here
>> 'i'could be the head or tail of the link l and x is a node that hosts i
>> Thank You
> 
> Unbelievable. I again forgot to express them
> L  = [(1,3), (5,7), .]
> bd = [23, 34,43.44.]
> dist = [3,7,5,7, ]
> hc = [2,3,4,1,2,2,...]
> for every l belonging to L, i could be either 1 or 3 for L[0], similarly for 
> L[1] it could be 5 or 7

You might want to ask on the scipy mailing list[1].  I'm sure the folks
over there deal with complex sums and math all the time.  Numpy
(standalone, or as part of scipy) has some facilities for working with
vectors, products, and summations in an efficient manner.

[1] http://mail.scipy.org/mailman/listinfo/scipy-user


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Chris “Kwpolska” Warrick
CC'ing the mailing list.

On Mon, Oct 6, 2014 at 5:29 PM, Sas Parmar
 wrote:
> Hi Chris
>
> I need to get in contact with the actual manufacturer of Python.
>
> Do you have an email address or phone number?

This is a very problematic question.  Why do you need to contact “the
manufacturer”?  Python is an open-source language with multiple people
involved.  Depending on what your query is, you may want the Python
Software Foundation, a release manager, tons of other people…  State
your question here and you may receive an answer or a pointer to
someone with an answer.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Rustom Mody
On Monday, October 6, 2014 6:34:27 PM UTC+5:30, Skip Montanaro wrote:
> On Sun, Oct 5, 2014 at 9:47 PM, Rustom Mody  wrote:
> > Sorry Seymore if this sounds condescending -- its not a complaint
> > against you but against those who treat the print statement/expression as
> > kosher for newbies.

> So if you're not griping about Seymore's original post, are you
> griping about my response? It was the one you quoted.

It so happened you were the person to note that here was a question(er)
needing instruction about using the interpreter. Nothing wrong with the 
answer (or the question). Something wrong with the point at which it emerges.

> And what's with the comparison between use of the print statement
> and driving on the wrong side of the road?

Consider the sequence:

1. Drives on the wrong side of the road
2. Has no clue that there's such a concept as 'wrong side of road'
3. Teaches people to drive without conveying anything about 'wrong side of road'

Hopefully you will agree that 1 < 2 < 3??

My gripe is with 3
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "High water" Memory fragmentation still a thing?

2014-10-06 Thread bryanjugglercryptographer
Chris Angelico wrote:
> This is why a lot of long-duration processes are built to be restarted
> periodically. It's not strictly necessary, but it can be the most
> effective way of solving a problem. I tend to ignore that, though, and
> let my processes just keep on running... for 88 wk 4d 23:56:27 so far,
> on one of those processes. It's consuming less than half a gig of
> virtual memory, quarter gig resident, and it's been doing a fair bit [...]

A shipping product has to meet a higher standard. Planned process mortality is 
a reasonably simple strategy for building robust services from tools that have 
flaws in resource management. It assumes only that the operating system 
reliably reclaims resources from dead processes. 

The usual pattern is to have one or two parent processes that keep several 
worker processes running but do not themselves directly serve clients. The 
workers do the heavy lifting and are programmed to eventually die, letting 
younger workers take over.

For an example see the Apache HTTP daemon, particularly the classic pre-forking 
server. There's a configuration parameter, "MaxRequestsPerChild", that sets how 
many requests a process should answer before terminating.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "High water" Memory fragmentation still a thing?

2014-10-06 Thread Chris Angelico
On Tue, Oct 7, 2014 at 3:21 AM,
 wrote:
> Chris Angelico wrote:
>> This is why a lot of long-duration processes are built to be restarted
>> periodically. It's not strictly necessary, but it can be the most
>> effective way of solving a problem. I tend to ignore that, though, and
>> let my processes just keep on running... for 88 wk 4d 23:56:27 so far,
>> on one of those processes. It's consuming less than half a gig of
>> virtual memory, quarter gig resident, and it's been doing a fair bit [...]
>
> A shipping product has to meet a higher standard. Planned process mortality 
> is a reasonably simple strategy for building robust services from tools that 
> have flaws in resource management. It assumes only that the operating system 
> reliably reclaims resources from dead processes.
>

Sure, and that's all well and good. But what I just cited there *is* a
shipping product. That's a live server that runs a game that I'm admin
of. So it's possible to do without the resource safety net of periodic
restarts.

> For an example see the Apache HTTP daemon, particularly the classic 
> pre-forking server. There's a configuration parameter, "MaxRequestsPerChild", 
> that sets how many requests a process should answer before terminating.
>

That assumes that requests can be handled equally by any server
process - and more so, that there are such things as discrete
requests. That's true of HTTP, but not of everything. And even with
HTTP, if you do "long polls" [1] then clients might remain connected
for arbitrary lengths of time; either you have to cut them off when
you terminate the server process (hopefully that isn't too often, or
you lose the benefit of long polling), or you retain processes for
much longer.

Restarting isn't necessary. It's like rebooting a computer: people get
into the habit of doing it, because it "fixes problems", but all that
means is that it allows you to get sloppy with resource management.
Working under the constraint that your one process will remain running
for at least a year forces you to be careful, and IMO results in
better code overall.

ChrisA

[1] https://en.wikipedia.org/wiki/Push_technology#Long_polling
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread Peter Pearson
On Mon, 06 Oct 2014 08:42:01 -0600, Michael Torrie  wrote:
> On 10/06/2014 07:07 AM, [email protected] wrote:
>>> Okay, I forgot to explain them. L is a set of links, dist is a
>>> number (distance), bd is the bandwidth and hc is a number as well
>>> (hopcount)...different bandwidths, hopcounts and distances for different
>>> links... b(i,x) is what i intend to calculate out of these details...here
>>> 'i'could be the head or tail of the link l and x is a node that hosts i
>>> Thank You
>> 
>> Unbelievable. I again forgot to express them
>> L  = [(1,3), (5,7), .]
>> bd = [23, 34,43.44.]
>> dist = [3,7,5,7, ]
>> hc = [2,3,4,1,2,2,...]
>> for every l belonging to L, i could be either 1 or 3 for L[0], similarly 
>> for L[1] it could be 5 or 7
>
> You might want to ask on the scipy mailing list[1].  I'm sure the folks
> over there deal with complex sums and math all the time.  Numpy
> (standalone, or as part of scipy) has some facilities for working with
> vectors, products, and summations in an efficient manner.

I don't think the OP is interested in complex numbers.  I think this
is a question about organizing loops.  But I can't tell for sure.

My guess is that l is one of the pairs in L, and that i is one of the
elements in l, or perhaps both in succession.  OP hints that "x is a
node that hosts i", but how that affects the right-hand side of the
equation defining the quantity to be computed, which is lost in the
history of this thread, is unclear.

There's a lesson here for the OP, varun7rs: If your initial query
had been clear and complete, you would have your answer by now.

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Chris Angelico
On Tue, Oct 7, 2014 at 3:23 AM, Rustom Mody  wrote:
> Consider the sequence:
>
> 1. Drives on the wrong side of the road
> 2. Has no clue that there's such a concept as 'wrong side of road'
> 3. Teaches people to drive without conveying anything about 'wrong side of 
> road'
>
> Hopefully you will agree that 1 < 2 < 3??
>
> My gripe is with 3

No, I don't agree. Teaching people to drive is separate from teaching
road rules, which vary by legislature. I can draw the exact same
analogy:

1. Fails to follow proper protocol at a hook turn intersection
2. Has no clue that there's such a concept as a hook turn
3. Teaches people to drive without conveying anything about hook turns.

Most of you are probably in state 2, and your instructors were
probably in state 3. Neither's a problem, because hook turns don't
matter until you come to an intersection where they're used. (And even
then, there's often signage.)

The complaints you're making are about something that does not matter.
There are multiple usage patterns for Python; one is to eschew the
interactive interpreter and run everything from scripts. That's fine,
there's nothing wrong with it. And then, the nuances of interactive
Python are completely insignificant.

I don't see that your complaints about print and interactive mode have
anything at all to do with this thread.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Rustom Mody
On Monday, October 6, 2014 10:22:27 PM UTC+5:30, Chris Angelico wrote:
> On Tue, Oct 7, 2014 at 3:23 AM, Rustom Mody wrote:
> > Consider the sequence:
> > 1. Drives on the wrong side of the road
> > 2. Has no clue that there's such a concept as 'wrong side of road'
> > 3. Teaches people to drive without conveying anything about 'wrong side of 
> > road'
> > Hopefully you will agree that 1 < 2 < 3??
> > My gripe is with 3

> No, I don't agree.

Interesting

So you dont agree with: "1<2<3" ?

Or with "My gripe is 3"  ?

The second would be quite bizarre:

"I have a headache..."

"Sorry. But I dont agree with that"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Chris Angelico
On Tue, Oct 7, 2014 at 4:05 AM, Rustom Mody  wrote:
> On Monday, October 6, 2014 10:22:27 PM UTC+5:30, Chris Angelico wrote:
>> On Tue, Oct 7, 2014 at 3:23 AM, Rustom Mody wrote:
>> > Consider the sequence:
>> > 1. Drives on the wrong side of the road
>> > 2. Has no clue that there's such a concept as 'wrong side of road'
>> > 3. Teaches people to drive without conveying anything about 'wrong side of 
>> > road'
>> > Hopefully you will agree that 1 < 2 < 3??
>> > My gripe is with 3
>
>> No, I don't agree.
>
> Interesting
>
> So you dont agree with: "1<2<3" ?
>
> Or with "My gripe is 3"  ?
>
> The second would be quite bizarre:
>
> "I have a headache..."
>
> "Sorry. But I dont agree with that"

Well, hey, I've eaten things that disagreed with me. You'd think that
would be purely factual. "I ate you!" "I disagree!".

But no, it was the "1 < 2 < 3" part that I disagreed with... as I'm
sure you were aware. Never let the obvious truth of something get in
the way of a good joke :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "High water" Memory fragmentation still a thing?

2014-10-06 Thread bryanjugglercryptographer
dieter wrote:
> As you see from the description, memory compaction presents a heavy burden
> for all extension writers.

Particularly because many CPython extensions are actually interfaces to 
pre-existing libraries. To leverage the system's facilities CPython has to 
follow the system's conventions, which memory compaction would break.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread Dave Angel
[email protected] Wrote in message:
> On Monday, 6 October 2014 15:03:44 UTC+2, [email protected]  wrote:
>

(Deleted all the 8-space quoting. Either use a better email client
 or remove the extra 7 lines between every line you
 quote.)

>> 
>> Okay, I forgot to explain them. L is a set of links, dist is a number 
>> (distance), bd is the bandwidth and hc is a number as well 
>> (hopcount)...different bandwidths, hopcounts and distances for different 
>> links...
>> 
>> b(i,x) is what i intend to calculate out of these details...here 'i' could 
>> be the head or tail of the link l and x is a node that hosts i

> 
> Unbelievable. I again forgot to express them
> 
> L  = [(1,3), (5,7), .]
> bd = [23, 34,43.44.]
> dist = [3,7,5,7, ]
> hc = [2,3,4,1,2,2,...]
> for every l belonging to L, i could be either 1 or 3 for L[0], similarly for 
> L[1] it could be 5 or 7

Now it's clear I don't have a clue. L is either a set or a list.
 Little l is an element of that set, and is either a tuple or is
 mysteriously subscripted by a boolean at the other end of the
 expression. ..

-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recommended hosting

2014-10-06 Thread writeson
Hi all,

OP here, thanks for all your reply's, all very useful. I'm going to check out a 
couple and see what works for the project I have in mind. 

Thanks again!
Doug
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Joel Goldstick
On Mon, Oct 6, 2014 at 11:38 AM, Chris “Kwpolska” Warrick
 wrote:
> CC'ing the mailing list.
>
> On Mon, Oct 6, 2014 at 5:29 PM, Sas Parmar
>  wrote:
>> Hi Chris
>>
>> I need to get in contact with the actual manufacturer of Python.
>>
>> Do you have an email address or phone number?
>
> This is a very problematic question.  Why do you need to contact “the
> manufacturer”?  Python is an open-source language with multiple people
> involved.  Depending on what your query is, you may want the Python
> Software Foundation, a release manager, tons of other people…  State
> your question here and you may receive an answer or a pointer to
> someone with an answer.
>
> --
> Chris “Kwpolska” Warrick 
> PGP: 5EAAEA16
> stop html mail | always bottom-post | only UTF-8 makes sense
> --
> https://mail.python.org/mailman/listinfo/python-list

Assuming you have a relationship with microsoft, you might try asking
them if they support the version of python you want to use.


-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread Rustom Mody
On Monday, October 6, 2014 10:52:40 PM UTC+5:30, Dave Angel wrote:
> varun7rs Wrote in message:
> > On Monday, 6 October 2014 15:03:44 UTC+2, Varun  wrote:

> (Deleted all the 8-space quoting. Either use a better email client
>  or remove the extra 7 lines between every line you
>  quote.)

> >> Okay, I forgot to explain them. L is a set of links, dist is a number 
> >> (distance), bd is the bandwidth and hc is a number as well 
> >> (hopcount)...different bandwidths, hopcounts and distances for different 
> >> links...
> >> b(i,x) is what i intend to calculate out of these details...here 'i' could 
> >> be the head or tail of the link l and x is a node that hosts i

> > Unbelievable. I again forgot to express them
> > L  = [(1,3), (5,7), .]
> > bd = [23, 34,43.44.]
> > dist = [3,7,5,7, ]
> > hc = [2,3,4,1,2,2,...]
> > for every l belonging to L, i could be either 1 or 3 for L[0], similarly 
> > for L[1] it could be 5 or 7

> Now it's clear I don't have a clue. L is either a set or a list.
>  Little l is an element of that set, and is either a tuple or is
>  mysteriously subscripted by a boolean at the other end of the
>  expression. ..

As Dave says there are too many loose ends in your spec to make much sense.

Anyway heres a small start to help you start off --
both for cleaning up your spec as well as moving towards an implementation

Take your denominator term: Σ(l∈L) l

You also say "i could be head or tail of l"
Dunno what to make of that 'or'... Toss a coin and choose??

So here are two version that will calculate the denominator for head and for 
tail

>>> L  = [(1,3), (5,7)]

>>> sum(x for (x,y) in L)
6
>>> sum(y for (x,y) in L)
10

If you need to examine the sub-expressions (always a good idea!), use

>>> (x for (x,y) in L)
 at 0x7fe04025c730>

Whazzat?

>>> list(x for (x,y) in L)
[1, 5]

Or just simply
>>> [x for (x,y) in L]
[1, 5]

You can use that literally in the sum

>>> sum([x for (x,y) in L])
6


>>> sum([(x,y) for (x,y) in L])
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for +: 'int' and 'tuple'

Python just expressing that you are goofing off by trying to add tuples
rather than numbers

>>> sum([l for l in L])
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for +: 'int' and 'tuple'

Same as above
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.76

2014-10-06 Thread Chris Angelico
On Tue, Oct 7, 2014 at 4:31 AM, Joel Goldstick  wrote:
> Assuming you have a relationship with microsoft, you might try asking
> them if they support the version of python you want to use.

I'm not sure there's any official Microsoft support for existing
versions of Python. With Steve Dower of Microsoft joining the Python
dev team, that will be changing as of 3.5 (though the full extent of
his input may not be visible until 3.6), but I don't know what's
happening with 2.7. In any case, I doubt you'll get anywhere by asking
MS to support the application; much better to simply ask the
application vendor... which is exactly what the OP did.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread Rustom Mody
On Monday, October 6, 2014 11:18:55 PM UTC+5:30, Rustom Mody wrote:

> >>> sum([(x,y) for (x,y) in L])
> Traceback (most recent call last):
> TypeError: unsupported operand type(s) for +: 'int' and 'tuple'

> Python just expressing that you are goofing off by trying to add tuples
> rather than numbers

I forgot to mention that this comes from just taking your
denominator
term  "Σ(l∈L) l" literally.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ruby instance variable in python

2014-10-06 Thread Steven D'Aprano
roro codeath wrote:

> in ruby:
> 
> module M
> def ins_var
> @ins_var ||= nil
> end
> 
> def m
> @ins_var = 'val'
> end
> 
> def m2
> m
> ins_var # => 'val'
> end
> end


I admit that my Ruby skills are admittedly pretty lousy. Still, I used to
think that Ruby was pretty readable, but I find the above completely
meaningless. So I'm going to guess what you want, sorry if I guess wrong.


> in py:
> 
> # m.py
> 
> # how to def ins_var
> 
> def m:
> # how to set ins_var
> 
> def m2:
> m()
> # how to get ins var


Please explain what you mean by "instance variable". There are two standard
things which it could be.

(1) A string variable is a variable holding a string. A float variable is a
variable holding a float. A list variable is a variable holding a list. So
an instance variable must be a variable holding an instance.

ins_var = NameOfTheClass(arg)

You just instantiate the class, passing whatever arguments it expects.

(2) In the Java world, "instance variable" doesn't mean a variable at all,
but an attribute of classes which is stored on the instance. (As opposed to
those attributes stored on the class itself, which they refer to
as "static", since in Java they are known to the compiler.)

To define "instance variables" (attributes), you have to have a class to
define them in. Remember that Python uses the "Offside Rule" (significant
indentation).

class MyClass(object):  # subclass of object
def __init__(self, arg):
# Initialise the instance.
self.ins_var = arg
def method(self, arg):
return self.ins_var == arg:
 

instance = MyClass("some value")
print(instance.ins_var) # prints "some value"
instance.method("spam and eggs")  # returns False
instance.method("some value")  # returns True


Does this help?



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Steven D'Aprano
On Mon, 06 Oct 2014 10:05:40 -0700, Rustom Mody wrote:

> On Monday, October 6, 2014 10:22:27 PM UTC+5:30, Chris Angelico wrote:
>> On Tue, Oct 7, 2014 at 3:23 AM, Rustom Mody wrote:
>> > Consider the sequence:
>> > 1. Drives on the wrong side of the road 2. Has no clue that there's
>> > such a concept as 'wrong side of road' 3. Teaches people to drive
>> > without conveying anything about 'wrong side of road' Hopefully you
>> > will agree that 1 < 2 < 3?? My gripe is with 3
> 
>> No, I don't agree.
> 
> Interesting
> 
> So you dont agree with: "1<2<3" ?

I can't speak for Chris, by my answer is neither Yes nor No, but Mu.

http://en.wikipedia.org/wiki/Mu_%28negative%29#In_popular_culture


I don't understand what semantics you are giving the < symbol. It's not 
"less than", since statements 1, 2 and 3 above don't have a total order 
or even a partial order. What does it mean to say that "Drives on the 
wrong side of the road" is less than "Teaches people to drive without 
conveying anything about 'wrong side of road'"? Less than in what sense? 
Alphabetical order? Less dangerous? Less competent? Less annoying? Less 
expensive?

So, no, I don't agree. Nor do I disagree.

I have fewer issues with your conclusion and analogy than I do with the 
basic premise that there is a connection between Seymore's problem here 
and the use, or non-use, of print in the interactive interpreter. I don't 
see how replacing interactive use and/or the use of print with functions 
containing return statements would help Seymore.



> Or with "My gripe is 3"  ?
> 
> The second would be quite bizarre:

If it's bizarre, why do you consider that Chris may mean that? The 
reasonable thing would be to reject it from contention.


> "I have a headache..."
> 
> "Sorry. But I dont agree with that"


"I don't agree that you have a headache. You're obviously lying, acting, 
delusional, an insentient robot programmed to repeat the words 'I have a 
headache', a zombie (not the brain eating kind, the philosophical kind), 
a sophisticated bot (but not sophisticated enough to pass the Turing 
test), or otherwise faking it."

I'm just sayin'...



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assignment Operators?

2014-10-06 Thread sohcahtoa82
On Thursday, October 2, 2014 6:24:37 AM UTC-7, Didymus wrote:
> Hi All,
> 
> 
> 
>I was wondering if someone could explain an assignment operator that I'm 
> seeing in some code. As an example:
> 
> 
> 
> >>> errors = False
> 
> >>> errors |= 3
> 
> >>> errors 
> 
> 3
> 
> >>> errors |= 4
> 
> >>> errors
> 
> 7
> 
> 
> 
>The '|=' operator, I read should be like a = a | b, but this appears to 
> add the two numbers as long as it's more than the previous:
> 
> 
> 
> >>> errors |= 5
> 
> >>> errors
> 
> 7
> 
> 
> 
>Is there anywhere I can read up more on this and the other assignment 
> operators and what/how they work. I got this off 
> 
> 
> 
> http://rgruet.free.fr/PQR27/PQR2.7.html
> 
> 
> 
> 
> 
> I'm using:
> 
> % python
> 
> Python 2.7.5 (default, Sep 25 2014, 13:57:38) 
> 
> [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
> 
> 
> 
> 
> 
>   Thanks for any help in advance.
> 
>
> 
>  Tom

As others have said, the | operator is a bit-wise 'or', as opposed to a boolean 
'or'.

False, when evaluated as an integer, converts to 0.  So False | 3 is equal to 
3, and so your errors variable is now 3.

On the next step, you did | again with 4.  Now, | didn't ADD 3 and 4 like you 
think it did.  It did a bit-wise or.  3 in binary is 11.  4 in binary is 100.  
OR them together and you get 111, which is 7.  The fact that the two numbers 
you chose have the same result whether you add them or 'or' them is a 
coincidence.

5 in binary is 101.  When you OR that with 111, you get 111, which is still 7.

If you're confused by this, read up on the binary number system and 
AND/OR/XOR/NAND logic.

-DJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Redge @ Versalytics.com

> On Oct 6, 2014, at 4:49 PM, Steven D'Aprano  wrote:
> 
>> On Mon, 06 Oct 2014 10:05:40 -0700, Rustom Mody wrote:
>> 
>>> On Monday, October 6, 2014 10:22:27 PM UTC+5:30, Chris Angelico wrote:
 On Tue, Oct 7, 2014 at 3:23 AM, Rustom Mody wrote:
 Consider the sequence:
 1. Drives on the wrong side of the road 2. Has no clue that there's
 such a concept as 'wrong side of road' 3. Teaches people to drive
 without conveying anything about 'wrong side of road' Hopefully you
 will agree that 1 < 2 < 3?? My gripe is with 3
>> 
>>> No, I don't agree.
>> 
>> Interesting
>> 
>> So you dont agree with: "1<2<3" ?
> 
> I can't speak for Chris, by my answer is neither Yes nor No, but Mu.
> 
> http://en.wikipedia.org/wiki/Mu_%28negative%29#In_popular_culture
> 
> 
> I don't understand what semantics you are giving the < symbol. It's not 
> "less than", since statements 1, 2 and 3 above don't have a total order 
> or even a partial order. What does it mean to say that "Drives on the 
> wrong side of the road" is less than "Teaches people to drive without 
> conveying anything about 'wrong side of road'"? Less than in what sense? 
> Alphabetical order? Less dangerous? Less competent? Less annoying? Less 
> expensive?
> 
> So, no, I don't agree. Nor do I disagree.
> 
> I have fewer issues with your conclusion and analogy than I do with the 
> basic premise that there is a connection between Seymore's problem here 
> and the use, or non-use, of print in the interactive interpreter. I don't 
> see how replacing interactive use and/or the use of print with functions 
> containing return statements would help Seymore.
> 
> 
> 
>> Or with "My gripe is 3"  ?
>> 
>> The second would be quite bizarre:
> 
> If it's bizarre, why do you consider that Chris may mean that? The 
> reasonable thing would be to reject it from contention.
> 
> 
>> "I have a headache..."
>> 
>> "Sorry. But I dont agree with that"
> 
> 
> "I don't agree that you have a headache. You're obviously lying, acting, 
> delusional, an insentient robot programmed to repeat the words 'I have a 
> headache', a zombie (not the brain eating kind, the philosophical kind), 
> a sophisticated bot (but not sophisticated enough to pass the Turing 
> test), or otherwise faking it."
> 
> I'm just sayin'...
> 
> 
> 
> -- 
> Steven
> -- 
> I agree that 1<2<3.  From a numerical point of view this is correct.  The 
> distraction here is the inference that the numbers somehow relate to the 
> statements preceding this conclusion.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Denis McMahon
On Sun, 05 Oct 2014 19:02:31 -0400, Seymore4Head wrote:

> For the record, I don't want a hint.  I want the answer.
> I see a practice question is similar to this.
> 15 <= x < 30  And it wants a similar expression that is equivalent.

I think part of the problem here is that you don't understand the 
expression.

The expression:

15 <= x < 30

contains two conditions:

15 <= x

x < 30

For the whole expression to be true, both conditions must be true, hence 
the equivalence is:

(15 <= x) and (x < 30)

to test this in python command line, see if the two different expressions 
give the same result for a suitable range of values of x:

for x in range(50):
if not (15 <= x < 30) == ((15 <= x) and (x < 30)):
print "discrepancy"

or

for x in range(50):
if (15 <= x < 30) == ((15 <= x) and (x < 30)):
print "ok"

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Representing mathematical equations

2014-10-06 Thread Michael Torrie
On 10/06/2014 10:45 AM, Peter Pearson wrote:
> I don't think the OP is interested in complex numbers.  I think this
> is a question about organizing loops.  But I can't tell for sure.

Poor choice of words on my part. I meant complicated.  This is exactly
the kind of thing that people use numpy and other libraries to assist
with.  Right up scipy's alley.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Practice question

2014-10-06 Thread Seymore4Head
On Tue, 7 Oct 2014 01:46:37 + (UTC), Denis McMahon
 wrote:

>On Sun, 05 Oct 2014 19:02:31 -0400, Seymore4Head wrote:
>
>> For the record, I don't want a hint.  I want the answer.
>> I see a practice question is similar to this.
>> 15 <= x < 30  And it wants a similar expression that is equivalent.
>
>I think part of the problem here is that you don't understand the 
>expression.
>
>The expression:
>
>15 <= x < 30
>
>contains two conditions:
>
>15 <= x
>
>x < 30
>
>For the whole expression to be true, both conditions must be true, hence 
>the equivalence is:
>
>(15 <= x) and (x < 30)
>
>to test this in python command line, see if the two different expressions 
>give the same result for a suitable range of values of x:
>
>for x in range(50):
>if not (15 <= x < 30) == ((15 <= x) and (x < 30)):
>print "discrepancy"
>
>or
>
>for x in range(50):
>if (15 <= x < 30) == ((15 <= x) and (x < 30)):
>print "ok"

All of the practice questions up to this question had 4 answers.  With
each question you could verify the correct answers by just copy and
pasting each choice into Python.

So when the instructions said I could verify this with Python I
assumed there might be some way to test if the question was == to each
answer.
-- 
https://mail.python.org/mailman/listinfo/python-list


Syntax Highlighting in a tkinter Text widget

2014-10-06 Thread Nicholas Cannon
Hey guys Im working on an open source text 
editor(https://github.com/nicodasiko/Text-Config-2) and I would like to add 
syntax highlighting(mainly for python code). I have built the editor in python 
and the text input is a Text tkinter widget. I know how to add tags and 
highlight things  but Im not sure on how to constantly update the highlighting.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Syntax Highlighting in a tkinter Text widget

2014-10-06 Thread Christian Gollwitzer

Am 07.10.14 07:35, schrieb Nicholas Cannon:

Hey guys Im working on an open source text
editor(https://github.com/nicodasiko/Text-Config-2) and I would like
to add syntax highlighting(mainly for python code). I have built the
editor in python and the text input is a Text tkinter widget. I know
how to add tags and highlight things  but Im not sure on how to
constantly update the highlighting.


How long do you expect the input to be? If it will be short pieces, just 
run your regexps at every keystroke.


You can also cheat and use an existing tool for syntax highlighting. One 
possibility is the ctext widget, which is based on the text widget and 
is part of tcllib:


http://tcllib.sourceforge.net/doc/ctext.html

All you need to do is to wrap it for the use in Tkinter.

Another alternative would be ScintillaTk

http://sourceforge.net/projects/scintillatk/

Scintilla is a full-blown editor component, which is used in many code 
editors as the basic building block. Since this is a compiled extension, 
I have no idea how hard it will be to interface it with Python, however.


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: Pythonic way to iterate through multidimensional space?

2014-10-06 Thread Gelonida N

On 8/6/2014 1:39 PM, Tim Chase wrote:

On 2014-08-06 11:04, Gayathri J wrote:

Below is the code I tried to check if itertools.product() was
faster than normal nested loops...

they arent! arent they supposed to be...or am i making a mistake?


I believe something like this was discussed a while ago and there was
a faster-but-uglier solution so you might want to consult this thread:

https://mail.python.org/pipermail/python-list/2008-January/516109.html

I believe this may have taken place before itertools.product() came
into existence.



Disadvantage of itertools.product() is, that it makes a copy in memory.
Reason ist, that itertools also makes products of generators (meaning of 
objects, that one can't iterate several times through)



There are two use cases, that I occasionaly stumble over:

One is making the product over lists(),
product( list_of_lists )

ex:

product( [ [1,2,3], ['A','B'], ['a', 'b', 'c'] ] )

the other one making a product over a list of functions, which will 
create generators


ex:
product( [ lambda: [ 'A', 'B' ], lambda: xrange(3) ] )


I personally would also be interested in a fast generic solution that 
can iterate through an N-dimensional array and which does not duplicate 
the memory or iterate through a list of generator-factories or however 
this would be called.





--
https://mail.python.org/mailman/listinfo/python-list