Re: Python Help

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 4:57 PM, Jeffe  wrote:
> Looking for a something basic yet operational, fee based or we can discuss 
> equity if succesfully funded. Have some Big people interested with a solid 
> business framework. Just need the software to show and its on..
>

Unfortunately, the Python Job Board isn't currently active, so I can't
point you there. But you may find that Stack Overflow Careers will
help:

http://careers.stackoverflow.com/

Good luck! There's people out there who can do what you're wanting.
It's just a matter of finding them!

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


Python Help

2014-10-14 Thread Jeffe
Hi,

I am looking for anyone who knows python (C++ is also ok) well enough to write 
a basic script login registration and tws ib api connected. Looking to build a 
asset/security trading platform and have investors interested but want to see 
it operational first. 

Looking for a something basic yet operational, fee based or we can discuss 
equity if succesfully funded. Have some Big people interested with a solid 
business framework. Just need the software to show and its on..

Similar to this...https://www.youtube.com/watch?v=Bu0kpU-ozaw

We have Solid trading strategies but investors want to see the software 
operational first before integrating our strategies (and their funds) so we may 
collect trading fees while we run our patterns simultaneously


Looking forward to hearing back from you,

Jeff
jeffevalen...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Jython or Pyton issue-- Kindly Help me....

2014-10-14 Thread Venugopal Reddy
Actuvally am having below XML File:


http://schemas.xmlsoap.org/soap/envelope/";>



13001
2014
12
178   
W78
41859
0
B


181
LIGHT TRUCK WHEELBASES  
  
P
AA5


15615
AA5K8
178 /4521MM 
WHEELBASE 
false

false



181
LIGHT TRUCK WHEELBASES  
  
P
AA5


15615
AA5K8_second 
time
178 /4521MM 
WHEELBASE 
false

false



13001
2014
12
190   
W90
41860
0
B


181
LIGHT TRUCK WHEELBASES  
  
P
AA5


15616
AA5MA
190 /4826MM 
WHEELBASE 
false

false







My expected Output is:


WersCode
AA5K8
AA5MA

== For this I have used below Code:

mport glob   
import xml.etree.ElementTree as ET

Fatfile = open('#Var_SOE_VLIS_Response_Output\\Sales_to_Wers_Code2.txt', 'a')
try:
   tree = ET.parse('#Var_ENG_Response_Files\\SoapResponse1.xml')
   Fatfile.write('')
   WersCodeList = 
tree.findall('./{urn:ford/VehicleOrder/LegacyFeatureMapping/v2.0}PortInstalledOptionFeature')
   Fatfile.write('\n')
  # x = len(WersCodeList)
  # Fatfile.write(x)
   Fatfile.write('\n333')
   for WersCode in WersCodeList :
 Fatfile.write('\n444')
 WersCode = 
WersCode.find('.//{urn:ford/VehicleOrder/LegacyFeatureMapping/v2.0}WersCode')
 Fatfile.write('\n')
 Fatfile.write(WersCode.text)
except :
Fatfile.write(' \nsorry') 
Fatfile.write(' \nSuccess') 



But I could not able to get the WersCode List using Findall.

Please please please help on this .. am struggling sice one week sir...





On Tuesday, October 14, 2014 4:14:19 PM UTC+5:30, Peter Otten wrote:
> Venugopal Reddy wrote:
> 
> 
> 
> > Ok, I will explain my problem in details :
> 
> > 
> 
> > I have below XML:
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 1
> 
> > 2008
> 
> > 2009>
> 
> > 141100
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 4
> 
> > 2011
> 
> > 59900
> 
> > 
> 
> > 
> 
> > 
> 
> > 68
> 
> > 2011
> 
> > 13600
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > From I want output below format:
> 
> > 
> 
> > CountrynameRankYeargdppc
> 
> > Liechtenstein   1  2008141100
> 
> > Singapore   4  201159900
> 
> > Panama  68 201113600
> 
> > 
> 
> > Please help how to do it..
> 
> 
> 
> Read up on elementtree:
> 
> 
> 
> http://pymotw.com/2/xml/etree/ElementTree/parse.html
> 
> 
> 
> You can load the data from the file with parse(), get the countries with 
> 
> findall(), the name with country_node.attrib["name"], and rank, year and 
> 
> gdppc with country_node.find("rank").text etc.
> 
> 
> 
> If you run into problems come back with some code of y

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Rustom Mody
On Wednesday, October 15, 2014 9:10:54 AM UTC+5:30, Anurag Patibandla wrote:
> Thanks for the response.
> Here is the code that I have tried.

> from operator import itemgetter
> keys = json.keys()
> order = list(keys)
> q1 = int(round(len(keys)*0.2))
> q2 = int(round(len(keys)*0.3))
> q3 = int(round(len(keys)*0.5))
> b = [q1,q2,q3]
> n=0
> for i in b:
> queues = order[n:n+i]

> n = n+i
> print queues

> for j in range(len(queues)):
> q = (queues[j], json.get(queues[j]))
> print q

Converting the end for loop (last 3 lines) into:


print [(queues[j], json.get(queues[j])) for j in range(len(queues))]

Does that help?

General advice:
1. Instead of writing 'naked' code as you have done, if you wrap it into
functions (preferably small)
2. Contents similar to the original naked code but with print's replaced by 
return's

you make your as well as those trying to help/collaborate with you
life easier

Also the above is a more or mechanical translation. However

something[j] ... for j in range(len(something))

is usually a sign of a C programmer writing python :-)
Usually better to write

x for x in something

So...
Better to write that comprehension as

print [(q, json.get(q)) for q in queues]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
'json' has my original larger dict
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
Thanks for the response.
Here is the code that I have tried.

from operator import itemgetter
keys = json.keys()
order = list(keys)
q1 = int(round(len(keys)*0.2))
q2 = int(round(len(keys)*0.3))
q3 = int(round(len(keys)*0.5))
b = [q1,q2,q3]
n=0
for i in b:
queues = order[n:n+i]

n = n+i
print queues

for j in range(len(queues)):
q = (queues[j], json.get(queues[j]))
print q

By this I am able to get the 3 smaller dicts I want, but can you help me assign 
them to 3 variables?
The dicts need not be ordered but it would be better if they are ordered.

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


Re: Is there an easy way to control indents in Python

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 1:35 PM, Zachary Ware
 wrote:
>> But ultimately, the
>> fault is almost certainly with the PDF.
>
> Agreed, although I'd say the PDF viewer could also be at fault.

Good point, there are some really terrible PDF viewers around. Either
way, the workaround of grabbing one line at a time will be effective -
albeit tedious for anything more than a dozen lines or so.

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


Re: Is there an easy way to control indents in Python

2014-10-14 Thread Zachary Ware
On Tue, Oct 14, 2014 at 9:18 PM, Chris Angelico  wrote:
> On Wed, Oct 15, 2014 at 1:13 PM, ryguy7272  wrote:
>> I'm just learning Python.  It seems like indents are EXTREMELY important.  I 
>> guess, since there are no brackets, everything is controlled by indents.  
>> Well, I'm reading a couple books on Python now, and in almost all of the 
>> examples they don't have proper indents, so when I copy/paste the code (from 
>> the PDF to the IDE) the indents are totally screwed up.  I'm thinking that 
>> there should be some control, or setting, for this.  I hope.  :)
>>
>
> That probably depends on the person who made the PDF. You may simply
> have to copy and paste one line at a time; if you're using an editor
> that understands Python syntax, it'll do some of your indenting for
> you, and you'll just have to manually mark the unindents.
> Alternatively, just paste it all in without indentation, then go
> through and select blocks of code and hit Tab; in many editors,
> that'll indent the selected code by one level. But ultimately, the
> fault is almost certainly with the PDF.

Agreed, although I'd say the PDF viewer could also be at fault.
Earlier today I tried to copy just a paragraph of mostly plain text
from the Firefox built-in PDF viewer, but when pasting it elsewhere,
it was pasted one character per line.  Opening it in the Windows 8.1
default PDF viewer (of all things...), copying and pasting worked like
a charm.

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


Re: Is there an easy way to control indents in Python

2014-10-14 Thread Dan Stromberg
On Tue, Oct 14, 2014 at 7:13 PM, ryguy7272  wrote:
> I'm just learning Python.  It seems like indents are EXTREMELY important.  I 
> guess, since there are no brackets, everything is controlled by indents.  
> Well, I'm reading a couple books on Python now, and in almost all of the 
> examples they don't have proper indents, so when I copy/paste the code (from 
> the PDF to the IDE) the indents are totally screwed up.  I'm thinking that 
> there should be some control, or setting, for this.  I hope.  :)

Perhaps if you share a screenshot of your PDF and the name of your PDF
viewer, we can help you more.

Here's a URL about Python and Whitespace:
http://stromberg.dnsalias.org/~strombrg/significant-whitespace.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Rustom Mody
On Wednesday, October 15, 2014 7:35:18 AM UTC+5:30, Dave Angel wrote:
> anurag Wrote in message:
> > I have a dictionary that looks like this:
> > {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> > "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> > "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> > "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
> > Now if I have 100 objects like these and I need to split them into 3 
> > smaller dicts in a ratio 2:3:5, how could I do that?
> > I tried using numpy.random.choice(), but it says it needs to be a 1-d array.


> What have you actually tried? You haven't shown any actual code.

> Look up the method dict.keys, and see how you might use that. Then
>  look up random.shuffle, and see what it would do. Also look up
>  dict.sort, since your two messages on this thread imply two
>  conflicting goals as to which sub dictionaries should go in which
>  of your buckets. 

> As for extracting 20% of the keys, slicing is your answer. If
>  there are 100 keys, 20, 30, and 50 need to be sliced
>  off.

> Then you'll need a loop to build each result dictionary from its keys.

> There are shortcuts,  but it's best to learn the fundamentals first.

> Try writing the code. If it doesn't all work show us what you've
>  tried, and what you think is wrong. And when you get an
>  exception, show the whole traceback,  don't just paraphrase one
>  of the lines.

Yes that is what is in general expected out here -- code --
maybe working, maybe not, maybe incomplete, maybe 'pseudo' etc
Then others here will improve it

However there is one conceptual thing that perhaps should be mentioned: order.

Is your data *essentially* ordered?

And by 'essentially' I mean you think of it independent of python.
Yeah in python dicts are unordered and lists are ordered and one can fudge
one to behave a bit like the other.  But before you fudge, please ponder which
you really need/want.

Below a bit of going from one to other 


# dict -> list
>>> d = {"a":1,"b":2,"c":3}
>>> d
{'a': 1, 'c': 3, 'b': 2}
>>> list(d)
['a', 'c', 'b']

# alternate
>>> d.keys()
['a', 'c', 'b']

>>> d.items()
[('a', 1), ('c', 3), ('b', 2)]
>>> d.values()
[1, 3, 2]

# list -> dict
>>> dict(d.items())
{'a': 1, 'c': 3, 'b': 2}

# round-tripping
>>> dict(d.items()) == d
True
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there an easy way to control indents in Python

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 1:13 PM, ryguy7272  wrote:
> I'm just learning Python.  It seems like indents are EXTREMELY important.  I 
> guess, since there are no brackets, everything is controlled by indents.  
> Well, I'm reading a couple books on Python now, and in almost all of the 
> examples they don't have proper indents, so when I copy/paste the code (from 
> the PDF to the IDE) the indents are totally screwed up.  I'm thinking that 
> there should be some control, or setting, for this.  I hope.  :)
>

That probably depends on the person who made the PDF. You may simply
have to copy and paste one line at a time; if you're using an editor
that understands Python syntax, it'll do some of your indenting for
you, and you'll just have to manually mark the unindents.
Alternatively, just paste it all in without indentation, then go
through and select blocks of code and hit Tab; in many editors,
that'll indent the selected code by one level. But ultimately, the
fault is almost certainly with the PDF.

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


Re: Is there an easy way to control indents in Python

2014-10-14 Thread Juan Christian
Using PyCharm is easy:

File > Settings > (IDE Settings) Editor > Smart Keys > Reformat on paste >
choose "Reformat Block"

On Tue, Oct 14, 2014 at 11:13 PM, ryguy7272  wrote:

> I'm just learning Python.  It seems like indents are EXTREMELY important.
> I guess, since there are no brackets, everything is controlled by indents.
> Well, I'm reading a couple books on Python now, and in almost all of the
> examples they don't have proper indents, so when I copy/paste the code
> (from the PDF to the IDE) the indents are totally screwed up.  I'm thinking
> that there should be some control, or setting, for this.  I hope.  :)
>
> I have PyCharm 3.4 and Python 3.4.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Is there an easy way to control indents in Python

2014-10-14 Thread ryguy7272
I'm just learning Python.  It seems like indents are EXTREMELY important.  I 
guess, since there are no brackets, everything is controlled by indents.  Well, 
I'm reading a couple books on Python now, and in almost all of the examples 
they don't have proper indents, so when I copy/paste the code (from the PDF to 
the IDE) the indents are totally screwed up.  I'm thinking that there should be 
some control, or setting, for this.  I hope.  :)

I have PyCharm 3.4 and Python 3.4.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:Parsing Python dictionary with multiple objects

2014-10-14 Thread Dave Angel
anuragpatiband...@gmail.com Wrote in message:
> I have a dictionary that looks like this:
> {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
> 
> Now if I have 100 objects like these and I need to split them into 3 smaller 
> dicts in a ratio 2:3:5, how could I do that?
> I tried using numpy.random.choice(), but it says it needs to be a 1-d array.

> 

What have you actually tried? You haven't shown any actual code.

Look up the method dict.keys, and see how you might use that. Then
 look up random.shuffle, and see what it would do. Also look up
 dict.sort, since your two messages on this thread imply two
 conflicting goals as to which sub dictionaries should go in which
 of your buckets. 

As for extracting 20% of the keys, slicing is your answer. If
 there are 100 keys, 20, 30, and 50 need to be sliced
 off.

Then you'll need a loop to build each result dictionary from its keys.

There are shortcuts,  but it's best to learn the fundamentals first.

Try writing the code. If it doesn’t all work show us what you've
 tried, and what you think is wrong. And when you get an
 exception, show the whole traceback,  don't just paraphrase one
 of the lines.


-- 
DaveA

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


Re: while loop - multiple condition

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 10:04 AM, giacomo boffi  wrote:
> Tim Chase  writes:
>
>> On 2014-10-12 22:16, Marko Rauhamaa wrote:
>>> is equivalent with
>>>
>>> while ans.lower()[0] != 'y':
>>>  ans = input('Do you like python?')
>>
>> And still better improved with
>>
>>   while ans[:1].lower() != 'y':
>> ans = input('Do you like python?')
>
>  yok is Turkish for an EMPHATIC NO
> (or, at least, that's what I was led to think many years ago)

Corrupted core, are you ready to start the procedure?
What do you think?
Interpreting vague answer as: Yes!

If your program misinterprets a non-English response to an English
question, that's not critical. It just means you haven't implemented
full i18n. :)

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


Re: while loop - multiple condition

2014-10-14 Thread giacomo boffi
Tim Chase  writes:

> On 2014-10-12 22:16, Marko Rauhamaa wrote:
>> is equivalent with
>> 
>> while ans.lower()[0] != 'y':
>>  ans = input('Do you like python?')
>
> And still better improved with
>
>   while ans[:1].lower() != 'y':
> ans = input('Do you like python?')

 yok is Turkish for an EMPHATIC NO
(or, at least, that's what I was led to think many years ago)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread MRAB

On 2014-10-14 22:15, Anurag Patibandla wrote:

On Tuesday, October 14, 2014 12:59:27 PM UTC-4, Dave Angel wrote:

anuragpatiband...@gmail.com Wrote in message:

> I have a dictionary that looks like this:
> {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"},
> "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"},
> "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"},
> "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
>
> Now if I have 100 objects like these and I need to split them into 3 smaller 
dicts in a ratio 2:3:5, how could I do that?

I really have no idea what that means.  You have 100 dicts of
 dicts? Are the keys unique? If so, you could combine them with a
 loop of update.

> I tried using numpy.random.choice(), but it says it needs to be a 1-d array.
>

How about random.choice?  It needs a sequence.

To get anything more concrete, you need to specify Python version,
and make a clearer problem statement,  perhaps with example of
what you expect.



Hey DaveA,
I am using Python 2.7.
Yes. I have a dict of dicts with keys ranging from 1..100
And the value of each of these keys is another dict. What I need to do is make 
3 smaller dicts and assign the values of keys 1..100 in the ratio 2:3:5.
For example, if my original dict is

d={"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"},
"2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"},
"3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"},
"4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
...
...
   "100":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}

I need to have three dicts d1, d2, d3 with d1 containing the values of first 20 
keys, d2 containing the values on next 30 keys and d3 containing the values of 
the next 50.
Can you please help me with this?


You can get a list of the entries using the dict's .items method. It's
then a simple matter of slicing the list.

Note that dicts aren't ordered, i.e. its keys aren't in a fixed order,
so if you want then in a particular order, you'll need to sort the list.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
On Tuesday, October 14, 2014 5:33:01 PM UTC-4, Skip Montanaro wrote:
> Shuffle the keys, then grab the first 20 for one dictionary, the next 30 for 
> the second, and the last 50 for the third.
> 
> Skip

Could you please be more specific?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: strange thing that disturbs

2014-10-14 Thread Terry Reedy

i run win7 home premium.
during the installation of python 3.4.2 i have seen the tcl/tk
option activated!


Then python -m tkinter in Command Prompt should bring up a tk windows 
with a bit a text and two buttons, one for exit. First try to find 
Python 3.4 on the Start menu and start Python 3.4 (command   Then 
try import sys, then import tkinter.  If this does not work, try 
re-installing.


If you respond, do so to the list, not me.

--
Terry Jan Reedy

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


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Skip Montanaro
Shuffle the keys, then grab the first 20 for one dictionary, the next 30
for the second, and the last 50 for the third.

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


Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
On Tuesday, October 14, 2014 12:59:27 PM UTC-4, Dave Angel wrote:
> anuragpatiband...@gmail.com Wrote in message:
> 
> > I have a dictionary that looks like this:
> 
> > {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> 
> > "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> 
> > "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> 
> > "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
> 
> > 
> 
> > Now if I have 100 objects like these and I need to split them into 3 
> > smaller dicts in a ratio 2:3:5, how could I do that?
> 
> 
> 
> I really have no idea what that means.  You have 100 dicts of
> 
>  dicts? Are the keys unique? If so, you could combine them with a
> 
>  loop of update.
> 
> 
> 
> > I tried using numpy.random.choice(), but it says it needs to be a 1-d array.
> 
> > 
> 
> 
> 
> How about random.choice?  It needs a sequence.
> 
> 
> 
> To get anything more concrete, you need to specify Python version,
> 
>   and make a clearer problem statement,  perhaps with example of
> 
>  what you expect.
> 
> 
> 
> 
> 
> -- 
> 
> DaveA

Hey DaveA,
I am using Python 2.7.
Yes. I have a dict of dicts with keys ranging from 1..100
And the value of each of these keys is another dict. What I need to do is make 
3 smaller dicts and assign the values of keys 1..100 in the ratio 2:3:5.
For example, if my original dict is 

d={"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
   "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
   "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
   "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
   ...
   ...
  "100":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}

I need to have three dicts d1, d2, d3 with d1 containing the values of first 20 
keys, d2 containing the values on next 30 keys and d3 containing the values of 
the next 50.
Can you please help me with this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stressing problem with Python < 3.3.3 / 2.7.6 and Mac OS 10.9 Mavericks

2014-10-14 Thread Wolfgang Maier

On 14.10.2014 22:30, Ned Deily wrote:

In article ,
  Wolfgang Maier  wrote:

I'm not a regular MacPython user, but today I had to build Mac wheels
for different versions of Python. To test the wheel files I set up a
fresh Mac OS 10.9 Mavericks and and installed Python 3.2, 3.3, 3.4 from
the python.org download page on it. Then I struggled for the rest of the
afternoon to try to figure out why Python 3.2 crashed when I used my
package in interactive mode until I finally realized that it's not the
package but Python that's responsible.

Turns out that I had run into http://bugs.python.org/issue18458 which
probably every MacPython user here is so familiar with that the download
page doesn't even mention it ? ;)

Seriously, I think the official download page for a OS shouldn't offer
me a version that will not work well with the latest version of that OS
without a warning. Why not add such a warning (like: versions below will
crash in interactive mode on Mac OS 10.9) in the list of downloads at
https://www.python.org/downloads/mac-osx/ between Python 2.7.6 (the
first version with the issue fixed) and Python 3.2.5 (the last affected
version).


Sorry you ran into that problem.  Unfortunately, that's a general
problem when using older versions of Python that are in
security-fix-only mode, e.g. those no longer in active maintenance mode.
Currently only 3.2.x and 3.3.x are in that category.

"The only changes made to a security branch are those fixing issues
exploitable by attackers such as crashes, privilege escalation and,
optionally, other issues such as denial of service attacks. Any other
changes are not considered a security risk and thus not backported to a
security branch."

https://docs.python.org/devguide/devcycle.html#security-branches

Fixes for new operating system releases do not fall in this category.
There are certainly other problems that one will run into on platform
releases newer than those supported and tested at the time of the final
maintenance release.  However, we did add a warning about this
particular issue to the release page of the final security release of
2.6.x.  That warning is now copied into the 3.2.6 release page.



Thanks for the fast response, Ned.

I fully understand how the issue arose and why it hasn't been fixed. No 
complaints about that.
I just thought that, if you cannot use the interactive interpreter on a 
standard version of the OS you're downloading for, that deserves a 
prominent mention.


The added warning in the 3.2.6 release page may have saved me a bit of 
searching *after* I figured out what's going on, but I wouldn't have 
discovered it *before* downloading.



In the future, if you encounter problems with the python.org website,
follow the Help link at the bottom of each page to the website issue
tracker.



Thanks for pointing that out. I thought such a link must exist, but 
posting to this list seemed simpler than looking for it. I'll remember 
it for next time.


Best,
Wolfgang
--
https://mail.python.org/mailman/listinfo/python-list


Re: stressing problem with Python < 3.3.3 / 2.7.6 and Mac OS 10.9 Mavericks

2014-10-14 Thread Ned Deily
In article ,
 Wolfgang Maier  wrote:
> I'm not a regular MacPython user, but today I had to build Mac wheels 
> for different versions of Python. To test the wheel files I set up a 
> fresh Mac OS 10.9 Mavericks and and installed Python 3.2, 3.3, 3.4 from 
> the python.org download page on it. Then I struggled for the rest of the 
> afternoon to try to figure out why Python 3.2 crashed when I used my 
> package in interactive mode until I finally realized that it's not the 
> package but Python that's responsible.
> 
> Turns out that I had run into http://bugs.python.org/issue18458 which 
> probably every MacPython user here is so familiar with that the download 
> page doesn't even mention it ? ;)
> 
> Seriously, I think the official download page for a OS shouldn't offer 
> me a version that will not work well with the latest version of that OS 
> without a warning. Why not add such a warning (like: versions below will 
> crash in interactive mode on Mac OS 10.9) in the list of downloads at 
> https://www.python.org/downloads/mac-osx/ between Python 2.7.6 (the 
> first version with the issue fixed) and Python 3.2.5 (the last affected 
> version).

Sorry you ran into that problem.  Unfortunately, that's a general 
problem when using older versions of Python that are in 
security-fix-only mode, e.g. those no longer in active maintenance mode. 
Currently only 3.2.x and 3.3.x are in that category.

"The only changes made to a security branch are those fixing issues 
exploitable by attackers such as crashes, privilege escalation and, 
optionally, other issues such as denial of service attacks. Any other 
changes are not considered a security risk and thus not backported to a 
security branch."

https://docs.python.org/devguide/devcycle.html#security-branches

Fixes for new operating system releases do not fall in this category.  
There are certainly other problems that one will run into on platform 
releases newer than those supported and tested at the time of the final 
maintenance release.  However, we did add a warning about this 
particular issue to the release page of the final security release of 
2.6.x.  That warning is now copied into the 3.2.6 release page.

In the future, if you encounter problems with the python.org website, 
follow the Help link at the bottom of each page to the website issue 
tracker.

-- 
 Ned Deily,
 n...@acm.org

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


stressing problem with Python < 3.3.3 / 2.7.6 and Mac OS 10.9 Mavericks

2014-10-14 Thread Wolfgang Maier

Hi,

I'm not a regular MacPython user, but today I had to build Mac wheels 
for different versions of Python. To test the wheel files I set up a 
fresh Mac OS 10.9 Mavericks and and installed Python 3.2, 3.3, 3.4 from 
the python.org download page on it. Then I struggled for the rest of the 
afternoon to try to figure out why Python 3.2 crashed when I used my 
package in interactive mode until I finally realized that it's not the 
package but Python that's responsible.


Turns out that I had run into http://bugs.python.org/issue18458 which 
probably every MacPython user here is so familiar with that the download 
page doesn't even mention it ? ;)


Seriously, I think the official download page for a OS shouldn't offer 
me a version that will not work well with the latest version of that OS 
without a warning. Why not add such a warning (like: versions below will 
crash in interactive mode on Mac OS 10.9) in the list of downloads at 
https://www.python.org/downloads/mac-osx/ between Python 2.7.6 (the 
first version with the issue fixed) and Python 3.2.5 (the last affected 
version).


Wolfgang

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


Re: strange thing that disturbs

2014-10-14 Thread Skip Montanaro
Adding python-list back into the CC list. I know nothing about Windows.
Perhaps someone else here can help. (Sorry about the top post all you
bottom post mavens. It seemed warranted in this case...)

Skip

On Tue, Oct 14, 2014 at 2:10 PM,  wrote:

> hi,
>
> thank you so much for the quick reply :-D
>
> i run win7 home premium...
>
> during the installation of python 3.4.2 i have seen the tcl/tk option
> activated!
>
> the change between the T and t i tried but still the module wasnt found...
>
> ... ... ...
>
> its strange... you know... i dealed with C, C++, and many other
> programming languages and it was ALWAYS the same... never it was easy and
> always there was a problem with the instalation or the editor... even
> buying a book never it was like described in the book and i got stuck at a
> point where the example in the book and the software didnt match... so that
> happening noow isnt something new to me...
>
> another question that you might be able to help me is if you can recommend
> me a simple editor for writing python programs... right now i took IEP...
> any tips?
>
> be well and thank you!
>
> GD
>
> p.s. i only installed 3.4.2... thats enough right? or do i have to install
> the 2.X version as well?
>
> 2014-10-14 20:32 GMT+02:00 Skip Montanaro :
>
>>
>> On Tue, Oct 14, 2014 at 1:13 PM,  wrote:
>>
>>> it doesnt seem to be present and doesnt react to the "python -m tkinter"
>>> -module not present
>>>
>>
>> I don't know how it's spelled in 3.4.x, but in 2.7 it's spelled
>> "Tkinter". Give that a try. (Sorry, no 3.4 install handy or I'd verify it
>> myself.)
>>
>> The other alternative is that the tkinter module wasn't built when you
>> installed Python because the build system couldn't find Tcl or Tk libraries
>> to link to. If that's the case, let us know your computing platform
>> (Windows, Linux/Unix, MacOSX) and how 3.4 was installed on your system.
>>
>> Skip
>>
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: strange thing that disturbs

2014-10-14 Thread Skip Montanaro
On Tue, Oct 14, 2014 at 1:13 PM,  wrote:

> it doesnt seem to be present and doesnt react to the "python -m tkinter"
> -module not present
>

I don't know how it's spelled in 3.4.x, but in 2.7 it's spelled "Tkinter".
Give that a try. (Sorry, no 3.4 install handy or I'd verify it myself.)

The other alternative is that the tkinter module wasn't built when you
installed Python because the build system couldn't find Tcl or Tk libraries
to link to. If that's the case, let us know your computing platform
(Windows, Linux/Unix, MacOSX) and how 3.4 was installed on your system.

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


strange thing that disturbs

2014-10-14 Thread tntsugar
hello guys,

for half an hour now i am searching for something simple...

not IRC, not Fakebook, not Twitter...

simply an email where i can ask a question to a problem i have in python
3.4.2 and the tkinter (it doesnt seem to be present and doesnt react to the
"python -m tkinter" -module not present-)...

can you please tell me where i can find help here... i would like to learn
python but... 

greetings

G.

p.s. i dont use twitter, irc or fakebook...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:downloading from links within a webpage

2014-10-14 Thread Dave Angel
Shiva  Wrote in message:
> Hi,
> 
> Here is a small code that I wrote that downloads images from a webpage url
> specified (you can limit to how many downloads you want). However, I am
> looking at adding functionality and searching external links from this page
> and downloading the same number of images from that page as well.(And
> limiting the depth it can go to)
> 
> Any ideas?  (I am using Python 3.4 & I am a beginner)
> 
> import urllib.request
> import re
> url="http://www.abc.com";
> 
> pagehtml = urllib.request.urlopen(url)
> myfile = pagehtml.read()
> matches=re.findall(r'http://\S+jpg|jpeg',str(myfile))
> 
> 
> for urltodownload in matches[0:50]:
>   imagename=urltodownload[-12:]
>   urllib.request.urlretrieve(urltodownload,imagename)
> 
> print('Done!')
>  
> Thanks,
> Shiva
> 
> 

I'm going to make the wild assumption that you can safely do both
 parses using regex, and that finding the jpegs works well enough
 with your present one.

First thing is to make most of your present code a function
 fetch(), starting with pagehtml and ending before the print. The
 function should take two arguments,  url and depthlimit.

Now, at the end of the function,  add something like

If depthlimit > 0:
matches = ... some regex that finds links
for link in matches [:40]:
 fetch (link, depthlimit - 1)

Naturally, the rest of the top level code needs to be moved after
 the function definition,  and is called by doing something
 like:

fetch (url, 10)   to have a depth limit of 10.

-- 
DaveA

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


GENIUS, KING MIDAS, CIVIL HERO MICHELE NISTA micheleni...@gmx.com + 44 (0) 7939508007! HE GET IT RIGHT ON WORLDWIDE STOCKS, CURRENCIES & COMMODITIES ALWAYS! ABOUT 5000 PREDICTIONS ON INTERNET SINCE 9.

2014-10-14 Thread MICHELE CALZOLARI CREDIT SUISSE ASSOSIM
 GENIUS, KING MIDAS, CIVIL HERO MICHELE NISTA micheleni...@gmx.com + 44 (0) 
7939508007! HE GET IT RIGHT ON WORLDWIDE STOCKS, CURRENCIES & COMMODITIES 
ALWAYS! ABOUT 5000 PREDICTIONS ON INTERNET SINCE 9.2007: 5000 SUCCESS! 100% 
SHOCKING WINNING SCORE!!! GENIUS, KING MIDAS, CIVIL HERO MICHELE NISTA 
(micheleni...@gmx.com+ 44 (0) 7939508007) ADVANCED IN EXTREMELY PERFECT WAY THE 
CONTINUOUS WALL STREET CRASH OF 1987 ( AND HE WAS, MORE OR LESS, JUST 20, AT 
THE TIME)! AS THE ONE OF 2007, 2008 AND BEGINNING OF 2009 WITH "JUST" 1 AND 
HALF YEAR OF INCREDIBLY WINNING FORETASTE! GENIUS, KING MIDAS, CIVIL HERO 
MICHELE NISTA micheleni...@gmx.com AVDANCED IN EXTREMELY PERFECT WAY, THEN, THE 
MORE OF DOUBLING OF WALL STREET, SINCE 3.2009! HE PROPHESIED ALL THIS ON 
INTERNET, AGAIN, WITH MONTHS AND MONTHS IN ADVANCE! ALL AT FANTASTIC LIGHT OF 
SUNSHINE!!! ALL PROVABLE AND VISIBLE STILL NOW!!! GENIUS, KING MIDAS, CIVIL 
HERO MICHELE NISTA (micheleni...@gmx.com + 44 (0) 7939508007) WAS "ONE OF THE 
NUMBER ON
 ES" OF ITALIAN STOCK EXCHANGE, IN THE 90S, PRODUCING OVER 10 MILIONS OF EUROS 
OF COMMISSIONS OF THE 90S ( SO, 15 MILIONS OF NOW), FROM BELOW ZERO: WAS THE 
ABSOLUTE IDOL OF GOLDMAN SACHS, MERRILL LYNCH, AND NEARLY ANY "FOR GOOD" 
INVESTMENT BANK IN THE WORLD! THAT'S WHY EVERYONE WAS GIVING HIM AND STILL GIVE 
HIM THE NICK OF KING MIDAS! INGENIOUS HERO MICHELE NISTA HAS A GREAT HEART TOO, 
"NOT JUST" A SORT OF INVINCIBLE INTUITION! HE DEDICATES, SINCE HE WAS 17, ALL 
HIS GIFTS OF HEAVEN HE HAS TO POOREST PEOPLE IN THE WORLD, VOLUNTEERING AND NOT 
ONLY, FOR MANY ORGANIZATIONS SAVING OR IMPROVING SUFFERING LIVES IN LATIN 
AMERICA AND AFRICA. HE IS CERTAINLY A CIVIL INCORRUPTIBLE HERO TOO! IN THE LAST 
21 YEARS, IN MILAN, WAS THE MOST TENACIOUS MAN HUNTING TO DESTROY THE ASSASSIN 
DICTATORSHIP OF MAFIOSO, MEGA MAFIA MONEY LAUNDERER, EXTREME NAZIFASCIST, LIAR, 
MEGA THIEF, CORRUPTING PIG, PRINCIPAL OF HUNDREDS OF MURDERS AND SLAUGHTERS, 
VERY ASCERTAINED PEDOPHILE SILVIO BERLUSCONI! FOR ALL THIS, T
 HERE WERE FOUR ATTEMPTS OF KILLING HIM, ORDERED BY BASTARD SANGUINARY, AS WELL 
AS METASTASES OF THE ENTIRE WORLD: SILVIO BERLUSCONI!!! AND HIS FATHER LOST 
LIFE ON ORDER OF NAZIFASCIST AND COSA NOSTRA'S BRUTAL, VICIOUS, CRUEL, 
FEROCIOUS PRINCIPAL OF KILLING SILVIO BERLUSCONI ( MAKING SHREWDLY TO PASS, VIA 
HIS PRIVATE OR PUBLIC NEW "OVRA, GESTAPO AND DINA" AL HIS ABSOLUTE REPELLENT 
HINDREDS OF HOMICIDES FOR FALSE ACCIDENTS, FALSE SUICIDES, FALSE ILLNESS, ALL 
THE TIMES)! AS A MATTER OF FACT, GENIUS, KING MIDAS, DEMOCRAT HERO MICHELE 
NISTA micheleni...@gmx.com + 44 (0) 7939508007 " DECIDED TO EMIGRATE" TO 
LONDON, ON 2003, TO REMAIN ALIVE!! BUT GOD, IF HE'LL CONTINUE TO DESERVE SO, 
WILL MAKE HIM WIN!!! GROUP OF FRIENDS AND CLIENTS, EXTREMELY GRATEFUL TO THIS 
KING MIDAS, TO THIS INGENIOUS AND CIVIL HERO OF OUR TIMES: MICHELE NISTA 
(micheleni...@gmx.com + 44 (0) 7939508007)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:Parsing Python dictionary with multiple objects

2014-10-14 Thread Dave Angel
anuragpatiband...@gmail.com Wrote in message:
> I have a dictionary that looks like this:
> {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
> "4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}
> 
> Now if I have 100 objects like these and I need to split them into 3 smaller 
> dicts in a ratio 2:3:5, how could I do that?

I really have no idea what that means.  You have 100 dicts of
 dicts? Are the keys unique? If so, you could combine them with a
 loop of update.

> I tried using numpy.random.choice(), but it says it needs to be a 1-d array.
> 

How about random.choice?  It needs a sequence.

To get anything more concrete, you need to specify Python version,
  and make a clearer problem statement,  perhaps with example of
 what you expect.


-- 
DaveA

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


Parsing Python dictionary with multiple objects

2014-10-14 Thread anuragpatibandla7
I have a dictionary that looks like this:
{"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
"2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
"3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, 
"4":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}}

Now if I have 100 objects like these and I need to split them into 3 smaller 
dicts in a ratio 2:3:5, how could I do that?
I tried using numpy.random.choice(), but it says it needs to be a 1-d array.

Can someone please help with this?
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: downloading from links within a webpage

2014-10-14 Thread Rustom Mody
On Tuesday, October 14, 2014 8:12:56 PM UTC+5:30, Shiva wrote:
> Hi,

> Here is a small code that I wrote that downloads images from a webpage url
> specified (you can limit to how many downloads you want). However, I am
> looking at adding functionality and searching external links from this page
> and downloading the same number of images from that page as well.(And
> limiting the depth it can go to)

> Any ideas?  (I am using Python 3.4 & I am a beginner)

> import urllib.request
> import re

Read this:
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I'm looking to start a team of developers, quants, and financial experts, to setup and manage an auto-trading-money-making-machine

2014-10-14 Thread ryguy7272
On Tuesday, October 14, 2014 9:38:55 AM UTC-4, Johann Hibschman wrote:
> Marko Rauhamaa  writes:
> 
> 
> 
> > ryguy7272 :
> 
> >
> 
> >> I'm looking to start a team of developers, quants, and financial
> 
> >> experts, to setup and manage an auto-trading-money-making-machine
> 
> >
> 
> > This has already been done: http://en.wikipedia.org/wiki/Sampo
> 
> 
> 
> And mocked by MST3K ("sampo means flavor!"):
> 
> 
> 
>   https://www.youtube.com/watch?v=cdfUkrbNvwA
> 
> 
> 
> -Johann (whose cousins are all Mattinens and Nikkanens)


Good stuff!  Very funny!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: scipy errors and gfortran

2014-10-14 Thread slyost
On Monday, October 13, 2014 1:14:27 PM UTC-5, sly...@ilstu.edu wrote:
> Trying to get scipy 0.14 running on python 3.4.1 on SLES 11 SP2 LINUX system.
> 
> Scipy seemed to compile fine using the command "python setup.py install" but 
> when I try the scipy.test("full"), I get errors regarding gfortran.  I am 
> using GCC(gfortran) version 4.9.1.
> 
> 
> 
> The error states that /usr/lib/libgfortran.so.3: version 'gfortran_1.4' was 
> not found (required by).  Google tells me that this is the name of the 
> symbol node whatever that means.
> 
> 
> 
> What do I need to do to fix these errors?  Please help.

Was able to fix the issue with an export of LD_LIBRARY_PATH, thank goodness.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: downloading from links within a webpage

2014-10-14 Thread Joel Goldstick
On Tue, Oct 14, 2014 at 10:54 AM, Chris Angelico  wrote:
> On Wed, Oct 15, 2014 at 1:42 AM, Shiva
>  wrote:
>> Here is a small code that I wrote that downloads images from a webpage url
>> specified (you can limit to how many downloads you want). However, I am
>> looking at adding functionality and searching external links from this page
>> and downloading the same number of images from that page as well.(And
>> limiting the depth it can go to)
>>
>> Any ideas?  (I am using Python 3.4 & I am a beginner)
>
> First idea: Use wget, it does all this for you :)

You might look at Requests and BeautifulSoup python modules.  Requests
is easier for many things than urllib.  BS is an HTML parser that may
be easier, and more powerful than what you can do with regex
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list



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


Re: downloading from links within a webpage

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 1:42 AM, Shiva
 wrote:
> Here is a small code that I wrote that downloads images from a webpage url
> specified (you can limit to how many downloads you want). However, I am
> looking at adding functionality and searching external links from this page
> and downloading the same number of images from that page as well.(And
> limiting the depth it can go to)
>
> Any ideas?  (I am using Python 3.4 & I am a beginner)

First idea: Use wget, it does all this for you :)

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


downloading from links within a webpage

2014-10-14 Thread Shiva
Hi,

Here is a small code that I wrote that downloads images from a webpage url
specified (you can limit to how many downloads you want). However, I am
looking at adding functionality and searching external links from this page
and downloading the same number of images from that page as well.(And
limiting the depth it can go to)

Any ideas?  (I am using Python 3.4 & I am a beginner)

import urllib.request
import re
url="http://www.abc.com";

pagehtml = urllib.request.urlopen(url)
myfile = pagehtml.read()
matches=re.findall(r'http://\S+jpg|jpeg',str(myfile))


for urltodownload in matches[0:50]:
  imagename=urltodownload[-12:]
  urllib.request.urlretrieve(urltodownload,imagename)

print('Done!')
 
Thanks,
Shiva

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


Re: Short syntax for try/pass

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 1:28 AM, Ned Batchelder  wrote:
> PEP 463 proposes a short syntax for this use case:
> http://legacy.python.org/dev/peps/pep-0463/
>
> I'm not sure what became of it.

Not quite; PEP 463 is about the case where you then want a different
value instead. I'm fairly sure the PEP is in a "virtually rejected"
state, but I nudged about it a couple of times and didn't get any
certain response on the subject.

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


Re: Short syntax for try/pass

2014-10-14 Thread Ned Batchelder

On 10/14/14 10:08 AM, Leonardo Giordani wrote:

Would it be feasible to propose a short syntax like this?

pass SomeException:
   somecode

where the above example would become:

pass IndexError:
  lst[0] = lst[0] + 1

I could not find if such a syntax has been already discussed elsewhere,
so please let me know if this is the case.

Otherwise, what do you think about it?


PEP 463 proposes a short syntax for this use case: 
http://legacy.python.org/dev/peps/pep-0463/


I'm not sure what became of it.

--
Ned Batchelder, http://nedbatchelder.com

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


Re: Short syntax for try/pass

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 1:08 AM, Leonardo Giordani
 wrote:
> a lot of times the following pattern pops out in Python code:
>
> try:
>  somecode
> except SomeException:
>  pass
>
> Converting the code to a non-EAFP version, for example
>
> if len(lst) != 0:
>  lst[0] = lst[0] + 1

This could be just "if lst:", but I agree, LBYL is not Python's style
(and isn't always possible anyway).

You can at least squish it up onto less lines, which might look better:

try: lst[0] += 1
except IndexError: pass

Alternatively, you can use this style:

from contextlib import suppress

with suppress(IndexError):
lst[0] += 1

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


Re: CLI framework using python

2014-10-14 Thread Naoki INADA
Click_ is another CLI framework.

It support multi-level nested command like git and it has some nice utilities.

I love it's design.






.. _click: http://click.pocoo.org/3/




—
Sent from Mailbox

On Tue, Oct 14, 2014 at 10:35 PM, vijnaana bhairava 
wrote:

> Hi Folks,
> The requirement is to develop a CLI framework in python for a linux router.
> The suggestions i got is to use PyCli/Cliff. Not sure which would be the 
> right choice!  Also, a few APIs are mentioned here: 
> https://pythonhosted.org/pyCLI/#module-cli.app
> Since i couldn't find any actual implementation which uses pyCli,
> i can't figure out how to make use of pyCLI.
> Another question i have is whether it uses argparse?
> If so, what value add does PYCLI do?
> Regards,
> vij
> On Thursday, October 9, 2014 5:50:51 PM UTC+5:30, vijnaana bhairava wrote:
>> Hi,
>> 
>> 
>> 
>> I need to develop a python CLI framework.
>> 
>> 
>> 
>> For example if i need to set an ip address in linux:
>> 
>> 
>> 
>> ifconfig eth0 172.16.25.125
>> 
>> 
>> 
>> I should be able to use python to do the above.
>> 
>> 
>> 
>> 1. The user will execute a python script to which i will pass the params 
>> eth0 and ip address (something like ifconf.py  eth0 172.16.25.125)
>> 
>> 
>> 
>> 2. Within the script i grab the params and do something to the effect of 
>> user executing 'ifconfig eth0 172.16.25.125' from the shell.
>> 
>> 
>> 
>> 3. There are other such commands for which i will be using python scripts. I 
>> came across pyCLI, but it doesn't have much documentation, so couldn't 
>> figure out how to move forward.
>> 
>> 
>> 
>> 4. The CLI framework needs to reuse code so i didn't want to use pure python 
>> and develop a framework from scratch. Rather use something like pyCLI/CLIFF.
>> 
>> 
>> 
>> The problem is lack of documentation with examples on how to use the above.
>> 
>> 
>> 
>> Any guidance would be greatly appreciated.
>> 
>> 
>> 
>> Regards & Thanks,
>> 
>> Vij
> -- 
> https://mail.python.org/mailman/listinfo/python-list-- 
https://mail.python.org/mailman/listinfo/python-list


Short syntax for try/pass

2014-10-14 Thread Leonardo Giordani
Hi all,

a lot of times the following pattern pops out in Python code:

try:
 somecode
except SomeException:
 pass

A very simple example could be if you want to process a list that may be
empty

def process_list(lst):
 try:
  lst[0] = lst[0] + 1
 except IndexError:
  pass

or in more complex cases in which however an exception just signals that
there is nothing to do there.

Converting the code to a non-EAFP version, for example

if len(lst) != 0:
 lst[0] = lst[0] + 1

is in my opinion generally against the Python nature, since it relies on a
specific check on the object, instead of trusting the object as being able
to either satisfy the request or raise an exception. That is, this solution
is non-polymorphic.

In such cases sometimes ABC may help, but generally speaking they it is not
always the case of being an instance of a given ABC or not. The problem
here is if the code raises an exception or not.

Would it be feasible to propose a short syntax like this?

pass SomeException:
  somecode

where the above example would become:

pass IndexError:
 lst[0] = lst[0] + 1

I could not find if such a syntax has been already discussed elsewhere, so
please let me know if this is the case.

Otherwise, what do you think about it?

Thank you

Leonardo



Leonardo Giordani
@tw_lgiordani  - lgiordani.com
My profile on About.me  - My GitHub page

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


Re: CLI framework using python

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 12:33 AM, vijnaana bhairava  wrote:
> Another question i have is whether it uses argparse?
> If so, what value add does PYCLI do?

It depends what you mean by "CLI framework". If you simply mean
something like hg, where you have subcommands and options and so on,
all you really need is argument parsing. Take the simplest possible
solution and run with it!

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


Sqlite3 help

2014-10-14 Thread Chuck
I am building a simple podcast program where I download all the data from a 
feed with feedparser and store the data in sqlite3.  I am spanking new to 
sqlite and database programming.  Should I create the database in the __init__ 
method of my class, or is that a bad idea.  I haven't done any designing that 
included databases.  

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


Re: I'm looking to start a team of developers, quants, and financial experts, to setup and manage an auto-trading-money-making-machine

2014-10-14 Thread Johann Hibschman
Marko Rauhamaa  writes:

> ryguy7272 :
>
>> I'm looking to start a team of developers, quants, and financial
>> experts, to setup and manage an auto-trading-money-making-machine
>
> This has already been done: http://en.wikipedia.org/wiki/Sampo

And mocked by MST3K ("sampo means flavor!"):

  https://www.youtube.com/watch?v=cdfUkrbNvwA

-Johann (whose cousins are all Mattinens and Nikkanens)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code Review for Paper, Rock, Scissors

2014-10-14 Thread Chris Angelico
On Tue, Oct 14, 2014 at 7:04 PM, Revenant
 wrote:
> As previously stated, I am new to Python and would also like to see if any of 
> you programming gurus have some suggestions about how I can simplify code, 
> and also if there are any other good starter programs to work on to improve 
> my skills.
>

Hi! Happy to help out. But first, there's one meta-suggestion that I'd
like to make: Use something other than Google Groups. As shown by the
line above, Google Groups has some issues with line breaks and text
wrapping; and it gets much worse when you reply to someone else's
post. I suggest using the mailing list instead:

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

Also, it can be helpful to state what version of Python you're using,
and on what platform. Your "press any key to quit" request suggests
you're probably invoking the script using a GUI, quite possibly
Windows, but that's far from certain; and as Dave's response shows,
the solutions depend on platform. I'm presuming you're using some 3.x
version of Python, as you use input() and print() functions, but I
can't tell whether you're on 3.2, 3.3, 3.4, or even an unreleased 3.5.
It's not likely to make a huge amount of difference with a script this
simple, but as a general rule, more information is better than less.

So, on to the code!

> # Creates the main menu.
> def menu():
> # Sets the scores to 0.
> global playerscore
> global compscore
> global draws
> playerscore = 0
> compscore = 0
> draws = 0

You're importing these globals into several places that don't need
them. The menu shouldn't have to concern itself with these scores; you
could initialize them all to zero at top-level, and then keep the
different functions more self-contained. The displaying of the menu
doesn't logically involve zeroing out the scores; imagine making the
very slight (and quite logical) change of having the full menu
redisplayed after each game, instead of just having the "Again? (Y/N)"
prompt - suddenly your scores aren't getting carried over.

> menuselection = input('Please enter a selection: (Play/Help/About): ')
> # Checks for an invalid selection.
> while menuselection != 'Play' and menuselection != 'play' and 
> menuselection != 'Help' and menuselection != 'help' \
> and menuselection != 'About' and menuselection != 'about':
> print('You have entered an invalid selection.')
> menuselection = input('\nPlease type a selection: (Play/Help/About): 
> ')
> else:
> if menuselection == 'Play' or menuselection == 'play':
> play()
> elif menuselection == 'Help' or menuselection == 'help':
> instructions()
> else:
> about()

The "else" clause on a while loop isn't necessary here, because you're
not using break. All you need is to put your code outside the loop.
Alternatively, you can combine the verification and iteration into one
pass, which reduces redundancy and makes it easier to add more
options. I'm also incorporating some suggestions already made,
including Dave's dispatch dictionary.

func = {"play":play, "help":instructions, "about":about}
while True:
menuselection = input('Please enter a selection:
(Play/Help/About): ').lower()
if menuselection in func: break
print('You have entered an invalid selection.')
func[menuselection]()

Note how the loop condition is now inside the loop ("if ...: break"),
with the while statement simply creating an infinite loop ("while
True:").

> def play():
> # Player chooses Paper, Rock, or Scissors.
> playerselect = input('\nPlease choose Paper, Rock, or Scissors: ')

Try to avoid comments that simply state what the next line(s) of code
do. At best, they're redundant; at worst, they're confusing, because
they can get out of sync with the code. Imagine adding a fourth option
(Claw Hammer) and forgetting to change the comment.

(Why claw hammer?
http://www.theregister.co.uk/2003/06/09/the_bastard_interviewer_from_hell/
)

> import random

It's much more common to put your imports at the top of the script,
rather than inside a function.

> # Creates the instructions.
> def instructions():
> print('\nPaper, Rock, Scissors is a simple game played against a computer 
> opponent.')
> print('The player will have a choice of selecting paper, rock, or 
> scissors.')
> print('The player\'s result will be compared with that of the computer to 
> determine who wins the round.')
> print('In the event that both the player and the computer have the same 
> selection, the round will end in a tie.')
> print('\nPaper beats rock but loses to scissors.')
> print('\nRock beats scissors but loses to paper.')
> print('\nScissors beats paper but loses to rock.')
> print('\nGood luck, and have fun!\n')
> menu()

As noted elsewhere, you have mutual recursion happening here. That's
not an advised technique in Python, as you can blow your stack
(there's no tail ca

Re: CLI framework using python

2014-10-14 Thread vijnaana bhairava
Hi Folks,

The requirement is to develop a CLI framework in python for a linux router.
The suggestions i got is to use PyCli/Cliff. Not sure which would be the right 
choice!  Also, a few APIs are mentioned here: 

https://pythonhosted.org/pyCLI/#module-cli.app

Since i couldn't find any actual implementation which uses pyCli,
i can't figure out how to make use of pyCLI.

Another question i have is whether it uses argparse?
If so, what value add does PYCLI do?

Regards,
vij

On Thursday, October 9, 2014 5:50:51 PM UTC+5:30, vijnaana bhairava wrote:
> Hi,
> 
> 
> 
> I need to develop a python CLI framework.
> 
> 
> 
> For example if i need to set an ip address in linux:
> 
> 
> 
> ifconfig eth0 172.16.25.125
> 
> 
> 
> I should be able to use python to do the above.
> 
> 
> 
> 1. The user will execute a python script to which i will pass the params eth0 
> and ip address (something like ifconf.py  eth0 172.16.25.125)
> 
> 
> 
> 2. Within the script i grab the params and do something to the effect of user 
> executing 'ifconfig eth0 172.16.25.125' from the shell.
> 
> 
> 
> 3. There are other such commands for which i will be using python scripts. I 
> came across pyCLI, but it doesn't have much documentation, so couldn't figure 
> out how to move forward.
> 
> 
> 
> 4. The CLI framework needs to reuse code so i didn't want to use pure python 
> and develop a framework from scratch. Rather use something like pyCLI/CLIFF.
> 
> 
> 
> The problem is lack of documentation with examples on how to use the above.
> 
> 
> 
> Any guidance would be greatly appreciated.
> 
> 
> 
> Regards & Thanks,
> 
> Vij
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I'm looking to start a team of developers, quants, and financial experts, to setup and manage an auto-trading-money-making-machine

2014-10-14 Thread Marko Rauhamaa
ryguy7272 :

> I'm looking to start a team of developers, quants, and financial
> experts, to setup and manage an auto-trading-money-making-machine

This has already been done: http://en.wikipedia.org/wiki/Sampo


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


Re: I'm looking to start a team of developers, quants, and financial experts, to setup and manage an auto-trading-money-making-machine

2014-10-14 Thread Skip Montanaro
On Tue, Oct 14, 2014 at 7:16 AM, ryguy7272  wrote:

> I'm looking to start a team of developers, quants, and financial experts,
> to setup and manage an auto-trading-money-making-machine
>

Two things:

1. That's obviously much easier said than done. (I happen to develop
automated trading systems for a trading firm in Chicago. Like other firms,
we have lots of developers, quants and financial experts on staff. Even for
a well-established company, success isn't guaranteed.)

2. You'd probably be better off with a posting to the Python Job Board
(once it's back up and running).

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


I'm looking to start a team of developers, quants, and financial experts, to setup and manage an auto-trading-money-making-machine

2014-10-14 Thread ryguy7272
I'm looking to start a team of developers, quants, and financial experts, to 
setup and manage an auto-trading-money-making-machine

#1) Setup a VM; must be a Windows machine (maybe Azure)
#2) Load & configure the software (Matlab, Python, R, Excel, and SQL Server)
#3) Develop and test code (Matlab or Pythonmost likely)
#4) Hook into trading tool for order execution (system to be determined; 
depends on API)
#5) Setup a corporate business structure (this is virtually done, we just need 
to flip a switch)
#5) Shop around for clients (if we have a real money-making machine, this 
should be super-easy)


Just so you know, I've done this kind of thing before, using Excel and VBA, as 
well as an execution program called Sterling Trader. It was quite profitable, 
and typically had less than 1 down day in a 22-trading-day month. The system 
was profitable about 95% of the time. However, I don't want to use Excel for 
this project; I want this to be a real system. I think we can use Matlab, or 
Python. If this is project turns out to be very profitable, I know we can raise 
capital very quickly and very easily. At the beginning, I believe it will take 
a fair amount of work, but if we put in the effort, we can have a system that 
constantly monitors the equity markets during trading hours, finds the best 
profit opportunities, according to the trading strategies that we deploy, and 
once it is setup and running, we really won't have to do a whole lot. Ideally, 
once you turn it on, the whole process will require almost no intervention. I 
know this can be done; many banks have groups that do exactly 
 what I'm proposing here. The top hedge funds do this too.

In conclusion, I think the trading strategies that we choose to employ should 
be easy to setup and test (a well-defined Google search will reveal countless 
trading strategies). I think getting the data should be pretty easy as well (we 
can load all kinds of indices into the tool). I think the hard part will be 
developing the automation processes; the tool will have to follow MANY rules 
and run all by itself. Finally, as neither Matlab nor Python are really 
execution tools, we'll have to connect to some type of system that allows us to 
send trade orders. This may, or may not, present somewhat of a challenge.


As an alternative, if we decide we don't want to manage money for other people, 
we could setup the business as a subscription service, and charge users, let's 
say $25k/year or whatever, and let people run simulations in our hosted 
environment, and they can manage money themselves...we simply provide all kinds 
of analytic tools for them to do what they want to do.



Hopefully everyone is close to New York City or Washington DC, or somewhere 
close, like Boston or Philadelphia.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: windows 7 pysqlite build error

2014-10-14 Thread Robin Becker

On 13/10/2014 22:00, Terry Reedy wrote:

On 10/13/2014 4:31 PM, Dennis Lee Bieber wrote:

On Mon, 13 Oct 2014 10:49:27 +0100, Robin Becker 
declaimed the following:


c:\users\rptlab\tmp\tmcallister\build\pysqlite\src\connection.h(33) : fatal
error C1083: Cannot open include file: 'sqli
te3.h': No such file or directory


Did \n get stuck in the name of the file in connection.h, or is that purely an
artifact of the error reporting?


it's an artefact.

error: command 'c:\\Program Files (x86)\\Microsoft Visual Studio
9.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2



I do have the various compilers installed and other extensions are building OK,
so is this an error in pysqlite or in my general setup? The include path looks
like it might relate to Python builds. I suppose it's feasible that pyqslite
builds need to be installed specially. I don't remember this happening on my old
win32 XP system, but that died and I now am forced to use 64bit win7.


Off hand, you don't have the SQLite3 /development package/.

PySQLite is just an adapter to the sqlite3 DLL; the sqlite3.h file
would be part of the source code for sqlite3, not part of pysqlite itself.




OK so I need to install sqlite3 prior to the pip install. This stuff gets tested 
more on linux and I suppose it's already there.

--
Robin Becker

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


Re: Jython or Pyton issue-- Kindly Help me....

2014-10-14 Thread Peter Otten
Venugopal Reddy wrote:

> Ok, I will explain my problem in details :
> 
> I have below XML:
> 
> 
> 
> 
> 1
> 2008
> 2009>
> 141100
> 
> 
> 
> 
> 4
> 2011
> 59900
> 
> 
> 
> 68
> 2011
> 13600
> 
> 
> 
> 
> 
> 
> From I want output below format:
> 
> CountrynameRankYeargdppc
> Liechtenstein   1  2008141100
> Singapore   4  201159900
> Panama  68 201113600
> 
> Please help how to do it..

Read up on elementtree:

http://pymotw.com/2/xml/etree/ElementTree/parse.html

You can load the data from the file with parse(), get the countries with 
findall(), the name with country_node.attrib["name"], and rank, year and 
gdppc with country_node.find("rank").text etc.

If you run into problems come back with some code of yours.


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


Re: How to install and run a script?

2014-10-14 Thread Dave Angel
Michael Torrie  Wrote in message:
> On 10/12/2014 08:05 PM, ryguy7272 wrote:
>> Ah!!!  I didn't know I needed to run it from the command prompt!  Ok, 
>> not it makes sense, and everything works.
>> 
>> Thanks to all!
> 
> You don't have to run python apps from the command line.  Apps that
> throw up windows can usually be run by double-clicking the py file in
> windows.  But apps that communicate solely on the terminal or console
> have to be run in that environment.
> 
> 
> 

If the command he's typing starts

python 

Then he needs to run it from the cmd prompt.

-- 
DaveA

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


Re:Code Review for Paper, Rock, Scissors

2014-10-14 Thread Dave Angel
Revenant  Wrote in message:
> 
> 

> One thing I want to try to add is a "Press any key to continue" function that 
> occurs at the end of the program when the user decides to quit. I looked at 
> some options online, but haven't quite figured it out yet. 
> 

Use the curses function getch, as documented on:
https://docs.python.org/3/howto/curses.html

Or if you're on Windows, try msvcrt.getch.

If you're writing code that needs to be portable, look at:
http://code.activestate.com/recipes/577977-get-single-keypress/


> As previously stated, I am new to Python and would also like to see if any of 
> you programming gurus have some suggestions about how I can simplify code, 
> and also if there are any other good starter programs to work on to improve 
> my skills. 
> 
> Thanks for reading! Code is below:
> 
> 
> # Creates the main menu.
> def menu():
> # Sets the scores to 0.
> global playerscore
> global compscore
> global draws
> playerscore = 0
> compscore = 0
> draws = 0
> menuselection = input('Please enter a selection: (Play/Help/About): ')

Save yourself trouble by using the lower method on the result of
 each input function. I'll assume that for subsequent comments.
 

> # Checks for an invalid selection.
> while menuselection != 'Play' and menuselection != 'play' and 
> menuselection != 'Help' and menuselection != 'help' \
> and menuselection != 'About' and menuselection != 'about':

Simplify to:
while menuselection not in ("play", "help", "about"):

> print('You have entered an invalid selection.')
> menuselection = input('\nPlease type a selection: (Play/Help/About): 
> ')
> else:
> if menuselection == 'Play' or menuselection == 'play':
> play()
> elif menuselection == 'Help' or menuselection == 'help':
> instructions()
> else:
> about()
> 

func = {"play":play, "help":instructions, "about":about}
func[menuselection]()
> 
> # Creates the game.
> def play():
> global playerscore
> global compscore
> global draws
> # Player chooses Paper, Rock, or Scissors.
> playerselect = input('\nPlease choose Paper, Rock, or Scissors: ')
> # Checks for an invalid selection.
> while playerselect != 'Paper' and playerselect != 'paper' and 
> playerselect != 'Rock' and playerselect != 'rock' \
> and playerselect != 'Scissors' and playerselect != 'scissors':

Again use playerselect not in ("pap... form

> print('You have entered an invalid selection.')
> playerselect = input('\nPlease choose Paper, Rock, or Scissors: ')
> else:
> if playerselect == 'Paper' or playerselect == 'paper':
> print('\nYou have selected Paper.')
> playerselect = 1
> elif playerselect == 'Rock' or playerselect == 'rock':
> print('\nYou have selected Rock.')
> playerselect = 2
> else:
> print('\nYou have selected Scissors.')
> playerselect = 3
> # Computer chooses Paper, Rock, or Scissors.
> import random
> compselect = random.randint(1, 3)

You could make life a little easier by using 0 to 2 instead,  here
and above.

> if compselect == 1:
> print('The Computer has selected Paper')
> elif compselect == 2:
> print('The Computer has selected Rock.')
> else:
> print('The Computer has selected Scissors.')

 print (None, "paper", "rock", "scissors")[compselect])

The next section can be simplified a lot by exploiting some
 symmetries. 
diff = (playerselect - compselect ) % 3

This number will be zero for a draw, 1 for computer win, and 2 for
 player win. So you can have 3 cases below instead of
 9.


> # Results if player selects paper.
> if playerselect == 1 and compselect == 1:
> print('Draw!')
> draws += 1
> score()
> else:
> if playerselect == 1 and compselect == 2:
> print('Paper beats rock. You win!')
> playerscore += 1
> score()
> elif playerselect == 1 and compselect == 3:
> print('Paper is beaten by scissors. You lose!')
> compscore += 1
> score()
> # Results if player selects rock.
> if playerselect == 2 and compselect == 2:
> print('Draw!')
> draws += 1
> score()
> else:
> if playerselect == 2 and compselect == 1:
> print('Rock is beaten by paper. You lose!')
> compscore += 1
> score()
> elif playerselect == 2 and compselect == 3:
> print('Rock beats scissors. You win!')
> playerscore += 1
> score()
> # Results if player selects rock.
> if playerselect == 3 and compselect == 3:
> print('Draw!')
> draws += 1
> score()
> else:
> if playerselect == 3 and compselect == 1:
> prin

Re: Jython or Pyton issue-- Kindly Help me....

2014-10-14 Thread Venugopal Reddy
Ok, I will explain my problem in details :

I have below XML:

 
 
 
1 
2008 
2009> 
141100 
 
 
 
 
4 
2011 
59900 
 
 
 
68 
2011 
13600 
 
 
 
 


>From I want output below format:

CountrynameRankYeargdppc 
Liechtenstein   1  2008141100 
Singapore   4  201159900 
Panama  68 201113600

Please help how to do it..


On Monday, October 13, 2014 9:14:27 PM UTC+5:30, Ian wrote:
> On Mon, Oct 13, 2014 at 5:39 AM, Venugopal Reddy
> 
>  wrote:
> 
> > Dear All,
> 
> >
> 
> > How to write a program for reading or parsing the XML file in Sub root Wise.
> 
> 
> 
> I don't know what "Sub root Wise" is. You can find an overview of
> 
> Python's XML parsing interfaces at
> 
> https://docs.python.org/2/library/xml.html. I would recommend using
> 
> the ElementTree API unless you have a specific reason to use something
> 
> else.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code Review for Paper, Rock, Scissors

2014-10-14 Thread Glenn Hutchings
Hi there!   Welcome to Python.

On Tuesday, 14 October 2014 09:04:51 UTC+1, Revenant  wrote:
> I am new to Python and would also like to see if any of you programming
> gurus have some suggestions about how I can simplify code, and also if
> there are any other good starter programs to work on to improve my
> skills.

I'm sure you'll get a lot of helpful advice here.  Here's a start: you have
a lot of places where you're comparing variables to the capitalized and
lower-case versions of the same string.  You could halve that number if you
converted your input to lowercase first.  For example:

if menuselection == 'play' or menuselection == 'Play':

changes to:

if menuselection.lower() == 'play':

There are plenty of other string methods you might find useful.
-- 
https://mail.python.org/mailman/listinfo/python-list


Code Review for Paper, Rock, Scissors

2014-10-14 Thread Revenant
Hi all!

I'm new to Python and programming in general, and am trying to learn as much as 
I can about it. 

Anyway, for a basic first program I made a simple game of Paper, Rock, 
Scissors. For this program, I incorporated a main menu that presented three 
different options, allowed the user to play a game of Paper, Rock, Scissors, 
allowed them to play the game again, and most importantly checked the user's 
input to make sure the program doesn't fail due to errors. 

One thing I want to try to add is a "Press any key to continue" function that 
occurs at the end of the program when the user decides to quit. I looked at 
some options online, but haven't quite figured it out yet. 

As previously stated, I am new to Python and would also like to see if any of 
you programming gurus have some suggestions about how I can simplify code, and 
also if there are any other good starter programs to work on to improve my 
skills. 

Thanks for reading! Code is below:


# Creates the main menu.
def menu():
# Sets the scores to 0.
global playerscore
global compscore
global draws
playerscore = 0
compscore = 0
draws = 0
menuselection = input('Please enter a selection: (Play/Help/About): ')
# Checks for an invalid selection.
while menuselection != 'Play' and menuselection != 'play' and menuselection 
!= 'Help' and menuselection != 'help' \
and menuselection != 'About' and menuselection != 'about':
print('You have entered an invalid selection.')
menuselection = input('\nPlease type a selection: (Play/Help/About): ')
else:
if menuselection == 'Play' or menuselection == 'play':
play()
elif menuselection == 'Help' or menuselection == 'help':
instructions()
else:
about()


# Creates the game.
def play():
global playerscore
global compscore
global draws
# Player chooses Paper, Rock, or Scissors.
playerselect = input('\nPlease choose Paper, Rock, or Scissors: ')
# Checks for an invalid selection.
while playerselect != 'Paper' and playerselect != 'paper' and playerselect 
!= 'Rock' and playerselect != 'rock' \
and playerselect != 'Scissors' and playerselect != 'scissors':
print('You have entered an invalid selection.')
playerselect = input('\nPlease choose Paper, Rock, or Scissors: ')
else:
if playerselect == 'Paper' or playerselect == 'paper':
print('\nYou have selected Paper.')
playerselect = 1
elif playerselect == 'Rock' or playerselect == 'rock':
print('\nYou have selected Rock.')
playerselect = 2
else:
print('\nYou have selected Scissors.')
playerselect = 3
# Computer chooses Paper, Rock, or Scissors.
import random
compselect = random.randint(1, 3)
if compselect == 1:
print('The Computer has selected Paper')
elif compselect == 2:
print('The Computer has selected Rock.')
else:
print('The Computer has selected Scissors.')
# Results if player selects paper.
if playerselect == 1 and compselect == 1:
print('Draw!')
draws += 1
score()
else:
if playerselect == 1 and compselect == 2:
print('Paper beats rock. You win!')
playerscore += 1
score()
elif playerselect == 1 and compselect == 3:
print('Paper is beaten by scissors. You lose!')
compscore += 1
score()
# Results if player selects rock.
if playerselect == 2 and compselect == 2:
print('Draw!')
draws += 1
score()
else:
if playerselect == 2 and compselect == 1:
print('Rock is beaten by paper. You lose!')
compscore += 1
score()
elif playerselect == 2 and compselect == 3:
print('Rock beats scissors. You win!')
playerscore += 1
score()
# Results if player selects rock.
if playerselect == 3 and compselect == 3:
print('Draw!')
draws += 1
score()
else:
if playerselect == 3 and compselect == 1:
print('Scissors beat paper. You win!')
playerscore += 1
score()
elif playerselect == 3 and compselect == 2:
print('Scissors are beaten by rock. You lose!')
compscore += 1
score()
again()


# Determines if the player wants to play another game.
def again():
replay = input('\nDo you want to play again (Y/N)? ')
while replay != 'Y' and replay != 'y' and replay != 'N' and replay != 'n':
print('You have entered an invalid selection.')
replay = input('\nDo you want to play again (Y/N)? ')
else:
if replay == 'Y' or replay == 'y':
play()
else:
print('\nThanks for playing!')


# Creates the instructions.
def instructions():
print('\nPaper,

Re: How to install and run a script?

2014-10-14 Thread Mark Lawrence

On 14/10/2014 06:19, Michael Torrie wrote:

On 10/12/2014 08:05 PM, ryguy7272 wrote:

Ah!!!  I didn't know I needed to run it from the command prompt!  Ok, not 
it makes sense, and everything works.

Thanks to all!


You don't have to run python apps from the command line.  Apps that
throw up windows can usually be run by double-clicking the py file in
windows.  But apps that communicate solely on the terminal or console
have to be run in that environment.



No, you need to double click a pyw file to get a windows app, py files 
always give you a console.


--
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