Re: numpy column_stack - why does this work?

2015-11-16 Thread PythonDude
On Friday, 13 November 2015 18:17:59 UTC+1, Ian  wrote:
> On Fri, Nov 13, 2015 at 8:37 AM, PythonDude  wrote:
> > 3) I DON'T understand why the code doesn't look like this:
> >
> > means, stds = np.column_stack([
> > for _ in xrange(n_portfolios):
> >   getMuSigma_from_PF(return_vec) ])
> 
> Because that would be invalid syntax; you can't put a for loop inside
> an expression like that. Your question is not about numpy.column_stack
> at all, but about list comprehensions. I suggest you start by reading
> this:
> 
> https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
> 
> Then if you're still confused, come back and ask further questions.

Thank you very much, I'll look careful into that before asking again :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A Program that prints the numbers from 1 to 100

2015-11-16 Thread Ammammata
Il giorno Sat 14 Nov 2015 07:18:18p, *BartC* inviava su comp.lang.python il 
messaggio news:n27tp6$ec5$1...@dont-email.me. Vediamo cosa scrisse:

> Here's one way

+1 :)

-- 
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
>  http://www.bb2002.it :)  <
... [ al lavoro ] ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help in pexpect multiprocessing

2015-11-16 Thread harirammanohar159
On Monday, 9 November 2015 18:07:36 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi,
> 
> I am using multiprocessing with pexpect, issue is whenever i call a function 
> which is having expect(), its throwing error which is genuine as multiple 
> threads are processing it same time (i/o prompt same time by multiple 
> processes..so issues in picture...), so i want to use lock for that section 
> alone to avoid it, but still fails in implementing it...can you help me
> 
> username = input('Enter your username: ')
> password = getpass.getpass()
> 
> s = pxssh.pxssh()
> s.login ('host','username','password')
> s.sendline ('ps -ef|grep java')
> s.prompt(timeout=1)
> 
> Try 1:
> 
> if condition == 'met':
>np = len(list1)
>p = multiprocessing.Pool(np)
>p.map(stop, [(ds) for ds in list1])
> 
> def stop(ds):
> s.sendline ('cd /usr')
> if condition:
> lock = threading.Lock()
> lock.acquire()
> s.expect('Enter username:')
> s.sendline ('user')
> s.expect('Enter password:*')
> s.sendline('pass')
> lock.release()
> s.prompt(timeout=200)
> print('stopped ds...')
> 
> Try 2:
> 
> if condition == 'met':
> lock = Lock()
> for ds in list1:
> Process(target=stop, args=(ds,lock)).start()
> 
> def stop(ds,l):
> s.sendline ('cd /usr')
> if condition:
> l.acquire()
> s.expect('Enter username:')
> s.sendline ('user')
> s.expect('Enter password:*')
> s.sendline('pass')
> l.release()
> s.prompt(timeout=200)
> print('stopped ds...')
> 
> Both are giving me same trace..
> 
> pexpect.ExceptionPexpect: isalive() encountered condition where "terminated" 
> is 0, but there was no child process. Did someone else call waitpid() on our 
> process?
> 
> Thanks in Advance

Hey Lucena,

Thank you for suggestion, yeah process queues doing the samething, creating new 
sesssion for each process and executing simulatenously.. requirement is served..

but still i want to tackle the situation with locks, but not able to as 
throwing the below error.

pexpect.ExceptionPexpect: isalive() encountered condition where "terminated" is 
0, but there was no child process. Did someone else call waitpid() on our 
process? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the right way to import a package?

2015-11-16 Thread Grobu

On 14/11/15 21:00, fl wrote:

Hi,

I want to use a code snippet found on-line. It has such content:

from numpy import *
dt = 0.1
# Initialization of state matrices
X = array([[0.0], [0.0], [0.1], [0.1]])

# Measurement matrices
Y = array([[X[0,0] + abs(randn(1)[0])], [X[1,0] + abs(randn(1)[0])]])



When the above content is inside a .py document and running, there will be
  an error:

---> 15 Y = array([[X[0,0] + abs(randn(1)[0])], [X[1,0] + abs(randn(1)[0])]])
  16 #Y = ([[X[0,0]], [X[1,0] + 0]])

NameError: name 'randn' is not defined


But when I run the above line by line at the console (Canopy), there will be
no error for the above line.

My question is:

The import and the following are wrong.

X = array([[0.0], [0.0], [0.1], [0.1]])

It should be:

import numpy as np
...
Y = np.array([[X[0,0] + abs(np.randn(1)[0])], [X[1,0] + abs(np.randn(1)[0])]])

This looks like the code I once saw. But the file when running has such
  error:

---> 15 Y = np.array([[X[0,0] + abs(np.randn(1)[0])], [X[1,0] + 
abs(np.randn(1)[0])]])

AttributeError: 'module' object has no attribute 'randn'

When it is run line by line at the console, it has the same error.

It is strange that the same content has errors depends on inside a file, or
at CLI console.

What is missing I don't realize? Thanks,




You can try :
from numpy import *
from numpy.random import *

HTH,

- Grobu -

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


Re: A Program that prints the numbers from 1 to 100

2015-11-16 Thread harirammanohar159
On Saturday, 14 November 2015 23:04:40 UTC+5:30, Cai Gengyang  wrote:
> I want to write a program in Python that does this 
> 
> "Write a program that prints the numbers from 1 to 100. But for multiples of 
> three print "Fizz" instead of the number and for the multiples of five print 
> "Buzz". For numbers which are multiples of both three and five print 
> "FizzBuzz"."
> 
> How do I go about doing it ?

This would help, but try to write on your own to improve, else you cant make 
this going long

i = 1

while i <= 100:
if multipleof_3 and multipleof_5:
print("FizzBuzz")
++i
elif multipleof_3:
print("Fizz")
++i
elif multipleof_5:
print("Buzz")
++i
else:
print(number)
++i
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problems using struct pack/unpack in files, and reading them.

2015-11-16 Thread Steven D'Aprano
On Mon, 16 Nov 2015 05:15 pm, Gregory Ewing wrote:

> Ian Kelly wrote:
>> Unary integer division seems pretty silly since the only possible results
>> would be 0, 1 or -1.
> 
> Ints are not the only thing that // can be applied to:
> 
>  >>> 1.0//0.01
> 99.0


Good catch!



-- 
Steven

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


Re: What meaning is 'a[0:10:2]'?

2015-11-16 Thread Steven D'Aprano
On Mon, 16 Nov 2015 11:27 am, fl wrote:

> hi,
> 
> When I learn slice, I have a new question on the help file. If I set:
> 
> pp=a[0:10:2]
> 
> pp is array([1, 3])

Really? How do you get that answer? What is `a`?


> I don't know how a[0:10:2] gives array([1, 3]).

Neither do I, because you have not told us what `a` is.

But I know what `a[0:10:2]` *should* be:

it takes a copy of elements from a, starting at position 0, ending just
before position 10, and taking every second one.


py> a = list(range(100, 121))
py> print(a)
[100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
115, 116, 117, 118, 119, 120]

py> print(a[0:10])
[100, 101, 102, 103, 104, 105, 106, 107, 108, 109]

py> print(a[0:10:2])
[100, 102, 104, 106, 108]

py> print(a[0:10:3])
[100, 103, 106, 109]


By default, the first item is automatically 0, so these two slices are the
same:

a[0:10:2]
a[:10:2]


If the start or end position are out of range, the slice will only include
positions that actually exist:

py> a[:1:5]
[100, 105, 110, 115, 120]




-- 
Steven

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


Re: A Program that prints the numbers from 1 to 100

2015-11-16 Thread Chris Angelico
On Mon, Nov 16, 2015 at 10:57 PM,   wrote:
> This would help, but try to write on your own to improve, else you cant make 
> this going long
>

Here's another version, but with a deliberate bug in it. You may use
this code if and only if your comprehension is sufficient to detect
and correct that bug.

next(filter(None,(print(next(filter(None,reversed(x for x in
enumerate(itertools.islice(itertools.cycle(("Fizzbuzz",0,"","Fizz",not
"Fuzz","Buzz","Fizz",(),bytes(),"Fizz","Buzz",{},"Fizz",False,globals().get(math.pi))),1,101,None)

Actually... you know what, I think debugging THAT is a malicious prank
to pull on an experienced Python programmer; plus, if you're caught
submitting that for your project, you deserve all the shame you get.
Trust me, this is NOT good code. Here's the corrected version. It
works, but you do not want to use this.

next(filter(None,(print(next(filter(None,reversed(x for x in
itertools.islice(enumerate(itertools.cycle(("Fizzbuzz",0,"","Fizz",not
"Fuzz","Buzz","Fizz",(),bytes(),"Fizz","Buzz",{},"Fizz",False,globals().get(math.pi,1,101))),None)

Enjoy!

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


Names [was Re: What meaning is 'a[0:10:2]'?]

2015-11-16 Thread Steven D'Aprano
On Mon, 16 Nov 2015 11:46 am, Ben Finney wrote:

> (Please set a “From” address that has a name for you as an individual;
> “fl” is rather anonymous and doesn't help us to identify you in these
> conversations.)

As far as I know, there's only one "fl" who posts here. And "fl" as a
cognomen is no worse than such well-known examples as:

J.R. https://en.wikipedia.org/wiki/JR_(artist)

and https://en.wikipedia.org/wiki/Who_shot_J.R.%3F

M.J. https://en.wikipedia.org/wiki/Mary_Jane_Watson

djk (who you worked with for a number of years *wink*)

T.I. https://en.wikipedia.org/wiki/T.I.

not to mention many famous people who are frequently, but not exclusively,
known by initials:

JMS https://en.wikipedia.org/wiki/J._Michael_Straczynski
MLK https://en.wikipedia.org/wiki/Martin_Luther_King,_Jr.
JFK https://en.wikipedia.org/wiki/John_F._Kennedy


On-the-internet-nobody-can-tell-if-your-name-really-is-Mxyzptlk-ly yr's,


-- 
Steven

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


uninstall 3.5

2015-11-16 Thread Adrien Viala
Hello,

Thank you for your work. Just discovering python.

My issue steps were  :
- 3.5 installed
- friend codes in 2.7
- server scripts can t run on my laptop (cant find module 0o)
- whatever, must be 3.5 / 2.7 issues
- let's try virtualenv
- can t download virtualenvwrapper-powershell : error X that i can t find
info about on googl
- whatever let's uninstall 3.5

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


Re: Matplotlib error: Value Error: x and y must have same first dimension

2015-11-16 Thread Abhishek Mallela
Thank you Laura and Oscar.

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


Re: uninstall 3.5

2015-11-16 Thread Adrien Viala
Hi again, Correct guess, virtualenvwrapper-powershell correctly installed
under 2.7 :)

On Sun, 15 Nov 2015 at 12:31 Adrien Viala <
adrien.georges.louis.vi...@gmail.com> wrote:

> Hello,
>
> Thank you for your work. Just discovering python.
>
> My issue steps were  :
> - 3.5 installed
> - friend codes in 2.7
> - server scripts can t run on my laptop (cant find module 0o)
> - whatever, must be 3.5 / 2.7 issues
> - let's try virtualenv
> - can t download virtualenvwrapper-powershell : error X that i can t find
> info about on googl
> - whatever let's uninstall 3.5
>
> :/
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why won't this run?

2015-11-16 Thread Gary Herron

On 11/15/2015 12:38 PM, jbak36 wrote:

Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit 
(AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.

#this program says hello and asks for my name
print:('Hello world!')

Hello world!



You are lying to us somehow.  That attempt to print (as you've written 
it) does not produce the the line of output you've indicated.  Instead 
it produces a syntax error, because Python does not use a colon in that 
situation.


So change your print:(...) lines to print(...) (without the colon) and 
try again.  If there is further trouble, ask another question, but 
please cut and paste the actual and *exact* results into the email.


Gary Herron


--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

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


WinXP invalid python 3.5 installation

2015-11-16 Thread lokotraktor
Dear all,

Would you be so kind and help me to find a fix of my trouble?

I have had installed python 2.7 already.
I have downloaded the
https://www.python.org/ftp/python/3.5.0/python-3.5.0.exe
and have installed it on Windows XP Home Edition Version 2002 SP3 (I am the 
administrator, which is on czech laguage the word "Spravce".)

Please see kindly attachements:
python_3,5_empty_installer_window.png
.. First I saw the incomplete python installer window. Clicking just in the 
"empty middle" the installation process of the Python 3.5.0 started and 
succesfully (?)  finished.

Trying to launche the newly installed python I encounter troubles depicted 
at:
python_3,5_not_valid_app_of_win32_type.png .. python.exe is not valid 
application of Win32 type.
python_3,5_not_valid_app_of_win32_type_2.png .. (The "Pristup byl odepren." 
means Acces denied.)

After a little bit googling I have find depends.exe to get know the python 
installation was complete or not.
The finding of depends is not good. See kindly the
python_3,5_depends_s_finding.png

Finaly I tried to uninstall python 3.5. using Control panels, Add or Remove 
Programs, Python, Uninstall (everything on czech language so that I do not 
know propper english wnidows terms). As I see the "incomplete python 
installer window" I tried to click in the middle of empty area. Another fail
appeared to me:
python_3.5_unable_to_remove.png
python-unistal-log.txt

Is something I can fix to obtain fully working upgrade of Python 3.5 on my 
Windows XP?
Please, feel free to ask me for more detailled information.
Best regards,
Jiri Fajmon[17C0:17D4][2015-11-15T10:07:17]i001: Burn v3.10.0.1823, Windows v5.1 (Build 
2600: Service Pack 3), path: C:\Documents and Settings\Spravce\Local 
Settings\Data aplikací\Package 
Cache\{1197d2bb-6cf8-488a-b994-d5bf6d7efe7b}\python-3.5.0.exe
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'ActionLikeInstalling' to value 'Installing'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'ActionLikeInstallation' to value 'Setup'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'ShortVersion' to value '3.5'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'ShortVersionNoDot' to value '35'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'InstallAllUsers' to value '0'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'InstallLauncherAllUsers' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 'TargetDir' 
to value ''
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'DefaultAllUsersTargetDir' to value '[ProgramFilesFolder]Python [ShortVersion]'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'TargetPlatform' to value 'x86'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'DefaultJustForMeTargetDir' to value 
'[LocalAppDataFolder]Programs\Python\Python[ShortVersionNoDot]-32'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'OptionalFeaturesRegistryKey' to value 
'Software\Python\PythonCore\[ShortVersion]-32\InstalledFeatures'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'TargetDirRegistryKey' to value 
'Software\Python\PythonCore\[ShortVersion]-32\InstallPath'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'DefaultCustomTargetDir' to value ''
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'InstallAllUsersState' to value 'enabled'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'InstallLauncherAllUsersState' to value 'enabled'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'CustomInstallLauncherAllUsersState' to value '[InstallLauncherAllUsersState]'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'TargetDirState' to value 'enabled'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing string variable 
'CustomBrowseButtonState' to value 'enabled'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_core' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_exe' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_dev' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_lib' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_test' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_doc' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_tools' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_tcltk' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_pip' to value '1'
[17C0:17D4][2015-11-15T10:07:17]i000: Initializing numeric variable 
'Include_launcher' to value '1'
[17C0:17D4]

Re: Question about yield

2015-11-16 Thread Steven D'Aprano
On Sun, 15 Nov 2015 01:37 pm, fl wrote:

> Hi,
> I have read a couple of tutorial on yield. The following code snippet
> still gives me a shock. I am told yield is a little like return. I only
> see one yield in the tutorial examples. Here it has two yields. And there
> are three variables following keyword yield.

Correct. `yield` exits the running function, but unlike `return`, the
function doesn't close down, it just pauses, ready to start up again when
you call next() on it.

Here is an example of an ordinary function:

py> def function():
... return 1
... return 2
... return 3
...
py> function()
1
py> function()
1

Each time you call the function, it starts again at the beginning, and exits
after the first `return`. So the lines `return 2` and `return 3` are dead
code that never gets run.

Here is an example of a generator function with yield. Calling generators is
a bit different from calling a function: first you have to initialise them
by calling the function to create a "generator object", then you call the
next() function to advance to the next `yield` statement, and finally they
raise an exception when there are no more `yields`.

An example might help:

py> def generator():
... yield 1
... yield 2
... yield 3
...
py> gen = generator()
py> next(gen)
1
py> next(gen)
2
py> next(gen)
3
py> next(gen)
Traceback (most recent call last):
  File "", line 1, in 
StopIteration


To start the generator from the beginning again, you have to create a new
generator object by calling the function:

gen = generator()


Calling next() many times is often inconvenient. Normally you will iterate
over the generator:

for x in gen:
print(x)

or you call collect all the items using list(). See example below.

Here is a generator which takes a list as argument, and returns a running
sum of the list values:

def running_sum(alist):
total = 0
for value in alist:
total += value
yield total


And here is an example of using it:

py> gen = running_sum(data)
py> list(gen)
[1, 3, 6, 16, 18, 18, 23]



-- 
Steven

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


Re: WinXP invalid python 3.5 installation

2015-11-16 Thread Chris Angelico
On Sun, Nov 15, 2015 at 8:19 PM,   wrote:
> I have downloaded the
> https://www.python.org/ftp/python/3.5.0/python-3.5.0.exe
> and have installed it on Windows XP Home Edition Version 2002 SP3 (I am the
> administrator, which is on czech laguage the word "Spravce".)

You're not going to be able to install Python 3.5 on Windows XP - the
latest Python doesn't support the old Windows. You can upgrade to
Windows 7 or 8 or 10, or downgrade to Python 3.4, or jump across to
Linux or some other OS. The installer for 3.5 currently isn't very
clear about the problem, but that's going to be changed in a couple of
weeks, so you'll know what your options are.

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


Re: Problems using struct pack/unpack in files, and reading them.

2015-11-16 Thread Steven D'Aprano
On Sun, 15 Nov 2015 01:23 pm, Chris Angelico wrote:

> On Sun, Nov 15, 2015 at 1:08 PM, Steven D'Aprano 
> wrote:
>> number = +raw_input("enter a number: ")
>>
>> versus:
>>
>> text = raw_input("enter a number: ")
>> try:
>> number = float(text)
>> except ValueError:
>> number = int(text)
> 
> What kinds of strings can float() not handle but int() can, 

Heh, I think I got the order of them backwards. You should try to convert to
int first, and if that fails, try float.


> and in a 
> program that's going to group floats and ints together as "numbers",
> will they ever be useful? I'd be more likely to write this as simply:

Obviously this code assumes you want to distinguish between ints and floats
for some reason. In Python, unlike Lua, Javascript and a few others, we do
distinguish between ints and floats. Since they have different
capabilities, that may sometimes be useful:


py> 10.0 ** 400
Traceback (most recent call last):
  File "", line 1, in 
OverflowError: (34, 'Numerical result out of range')
py> 10 ** 400
1
0
0
0
0



-- 
Steven

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


Re: Problems using struct pack/unpack in files, and reading them.

2015-11-16 Thread Chris Angelico
On Tue, Nov 17, 2015 at 12:17 AM, Steven D'Aprano  wrote:
> On Sun, 15 Nov 2015 01:23 pm, Chris Angelico wrote:
>
>> On Sun, Nov 15, 2015 at 1:08 PM, Steven D'Aprano 
>> wrote:
>>> number = +raw_input("enter a number: ")
>>>
>>> versus:
>>>
>>> text = raw_input("enter a number: ")
>>> try:
>>> number = float(text)
>>> except ValueError:
>>> number = int(text)
>>
>> What kinds of strings can float() not handle but int() can,
>
> Heh, I think I got the order of them backwards. You should try to convert to
> int first, and if that fails, try float.

Ah! Yes, that makes sense then. I assumed this...

>> and in a
>> program that's going to group floats and ints together as "numbers",
>> will they ever be useful? I'd be more likely to write this as simply:

... on the basis of the "float first" check.

> Obviously this code assumes you want to distinguish between ints and floats
> for some reason. In Python, unlike Lua, Javascript and a few others, we do
> distinguish between ints and floats. Since they have different
> capabilities, that may sometimes be useful:
>
>
> py> 10.0 ** 400
> Traceback (most recent call last):
>   File "", line 1, in 
> OverflowError: (34, 'Numerical result out of range')
> py> 10 ** 400
> 1
> 0
> 0
> 0
> 0
> 

Right. If you check int() first and then float(), you can make use of
this. But if the user enters that string and you try to float() it, it
will work:

>>> float(str(int(10**400)))
inf

Hence my confusion. :)

With that small change, your code makes fine sense.

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


Re: A Program that prints the numbers from 1 to 100

2015-11-16 Thread Jussi Piitulainen
Chris Angelico writes:
>
> Here's another version, but with a deliberate bug in it. [- -]

This one recycles fish in a way that looks a bit worrying but it seems
to work. If there's a bug, it's not deliberate. Except stopping at 15 is
deliberate.

from contextlib import contextmanager as fish
from collections import defaultdict as fowl
@fish
def fish(fish):
chip = fowl(str)
chip.update(((fowl(int)[fish],fish),))
yield chip
with fish("Fish") as f, fish("Bush") as b:
print(*("{}{}".format(f[k%3],b[k%5]) or k for k in range(1,16)))

# prints:
1 2 Fish 4 Bush Fish 7 8 Fish Bush 11 Fish 13 14 FishBush
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A Program that prints the numbers from 1 to 100

2015-11-16 Thread Chris Angelico
On Tue, Nov 17, 2015 at 12:39 AM, Jussi Piitulainen
 wrote:
> This one recycles fish in a way that looks a bit worrying but it seems
> to work.

Recycles fish?

http://www.saigan.com/kidscorner/comics/unhfulb.jpg

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


pexpect matching?

2015-11-16 Thread Didymus
Greetings,

  I have the following code:

import pexpect

child = pexpect.spawn('/bin/bash')
i = child.expect_exact('bash-3.2$ ')

child.sendline("rpm -q --queryformat '%{VERSION}\\n' glibc")
i = child.expect (['2', '2.5', '2.52.5', pexpect.TIMEOUT])

print  child.before
print '---'
print  child.after

if i == 0:
print 'We got 2'
elif i == 1:
print 'We got 2.5'
elif i == 2:
print ' We got 7'
elif i == 3:
print 'Timed Out!'
else:
print 'What happened?'

The output of the commandline is:

% rpm -q --queryformat '%{VERSION}\n' glibc
2.5
2.5


I've tried to use "\b", "^", "$" around the return stings and even 
expect_exact, but end up with it printing "We got 2". It's just mathcing the 
first character and not the entire string.

rpm -q --queryformat '%{VERSION}\n' glibc

---
2
We got 2

What am I doing wrong here? What do I need to tell the expect line  to grab the 
entire line back to check against?

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


Re: uninstall 3.5

2015-11-16 Thread Ian Kelly
On Nov 16, 2015 6:10 AM, "Adrien Viala" <
adrien.georges.louis.vi...@gmail.com> wrote:
>
> Hello,
>
> Thank you for your work. Just discovering python.
>
> My issue steps were  :
> - 3.5 installed
> - friend codes in 2.7
> - server scripts can t run on my laptop (cant find module 0o)
> - whatever, must be 3.5 / 2.7 issues
> - let's try virtualenv
> - can t download virtualenvwrapper-powershell : error X that i can t find
> info about on googl
> - whatever let's uninstall 3.5

If your friend is writing code for 2.7 and not writing for 2/3
compatibility, then you're not going to be able to run that code in Python
3. A virtual env won't help with that, because it's still Python 3.

Get your friend to upgrade to Python 3, or to write compatible code (there
are tools to help with this), or install Python 2.7.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running latest 32-bit Python on 64-bit system

2015-11-16 Thread Zachary Ware
On Fri, Nov 13, 2015 at 4:52 AM, Christian Ullrich  wrote:
> Hello,
>
> I have a problem with using the (otherwise nice) Python launcher. How can I
> get it to run the highest 32-bit Python on my 64-bit system? This is on
> Windows, but I think it applies to other OSes as well.
>
> My application runs (unmodified) with Python 3.[345], but only with the
> 32-bit version because it loads a DLL that has no 64-bit version available.
> I would like to run it on any system that has *any* suitable Python
> installed.
>
> However, with the shebang syntax supported by the launcher, I can only
> demand a 32-bit version if I also specify the Python minor version I want,
> and I don't necessarily know that in advance.
>
> I can code around that, of course, but I don't want to. If Python can select
> the 64-bit version to run by itself, it should also be able to for the
> 32-bit version, right?

I don't think there's currently a way to do what you want, but it
seems like a reasonable thing to do.  Would you mind raising an
enhancement request on bugs.python.org?

About the closest you could come currently would be to specify the
full path to the interpreter, but of course that may vary by machine.

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


import module pyttsx in windows IDLE failed

2015-11-16 Thread input/ldompeling
When I try to run this module in Windows IDLE I get this message:
How can I solve this problem.

Thanks

Traceback (most recent call last):
  File "C:\raspberrypi\recipe-578839-1.py", line 1, in 
import pyttsx
ImportError: No module named 'pyttsx'

This is what I found on the internet:
---
import pyttsx
engine = pyttsx.init()
engine.setProperty('rate', 70)

voices = engine.getProperty('voices')
for voice in voices:
print ("Using voice:"), repr(voice)
engine.setProperty('voice', voice.id)
engine.say("Hi there, how's you ?")
engine.say("A B C D E F G H I J K L M")
engine.say("N O P Q R S T U V W X Y Z")
engine.say("0 1 2 3 4 5 6 7 8 9")
engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")
engine.say("Violet Indigo Blue Green Yellow Orange Red")
engine.say("Apple Banana Cherry Date Guava")
engine.runAndWait()


-- 
- --- -- -
Posted with NewsLeecher v7.0 Beta 2
Web @ http://www.newsleecher.com/?usenet
--- -  -- -

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


write data in Excel using python

2015-11-16 Thread syedmwaliullah
hi, 
I am trying to write Excel file suing output from another software where the 
output comes as myturnlist.Show()

The first part is for the output from the software which is saved in the 
clipboard. 

The big middle part works to open Excel and save the data into excel file 
called "TurnData.xlsx". 

For some reason it doesn't save the file. 

Any idea?

Thanks in advance.


import VisumPy.excel

# Write to Excel

myturnlist.Show()
turnData = myturnlist.SaveToClipboard(59,0)

excel = win32com.client.Dispatch("Excel.Application")
wb = excel.Workbooks.Add()
exce.Visible = True
wb.WorkSheets[0].Paste()
excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx")

myturnlist.Close()
-- 
https://mail.python.org/mailman/listinfo/python-list


Immediate Requirement for IIB/APM Administrator at Orlando, FL.

2015-11-16 Thread recruiter . venkat36

Hi , 

Hope you are doing Good, We have Immediate Requirement for IIB/APM 
Administrator, Kindly go through the Job Description Below and If interested 
Please Respond to this Mail.

Job Description:
Title: IIB/APM Administrator
Location: - Orlando, FL
Duration: - 3 Months

IBM Technical expert is needed to automate the installation and configuration 
of IIB in multiple environments. Automate the installation and configuration of 
IBM's APM and APM agents products as well.
 
Job Requirements:
*   Expertise in installation, configuration and implementation of IBM 
Products: IIB, APM
*   Hands-on expertise in jython, wsadmin, msqi and bash shell.
*   Multi-node on-premise configuration experience with the above products.
 
Consultant will automate the following:
*  the install and configuration of IIB
*  the install and configuration of APM
*  the install and configuration of APM agents 
1. Scope
Various efforts underway to launch and use IBM's IIB and APM in our 
environment.  Before and/or at the start of this engagement, we expect one 
manual install of these products to have taken place in a non-production 
environment.  This scope of this position is to perform all work related to 
automating the install and configuration of these products for subsequent 
deployments, based on the installation and configuration performed during our 
initial manual install. 
 
2. Detailed Description of the Services:
Consultant will act on behalf of Build Services team performing the following:
o   Perform all design and development activities around the automation stated 
above using provided frameworks.  Scripting is expected to use jython, wsadmin, 
mqsi, and bash shell as applicable. 
o   Ensure all developed automation is aligned to and works with build and 
continuous integration frameworks.
o   Automation must cover both the initial install and configuration of each 
product, in addition to providing a framework to make incremental configuration 
changes over time.
o   Automation must cover the ability to configure different environments, for 
example development, testing, etc.  Automation should not have to be updated 
for each environment; instead the automation and scripting should be able to 
read configuration parameters from the environment and/or a configuration file.
o   Perform all validation and documentation activities relation to the 
developed automation, working with applicable teams as required.
o   Perform development activities relating to the automation of component 
validation.
o   Support troubleshooting in relation to execution of using the automation 
for official environment builds.
o   Use provided toolsets and procedures for defect tracking.
o   Perform and participate in reviews, inspections, and turnover procedures to 
build stakeholders.
 
 
The client will assist with the following functions during the duration of this 
project:
The Integration and Middleware Technical Lead(s) will perform the following:
o   Provide final approval design for all automation and continuous integration 
presented by consultant.
o   Provide functional subject matter resources for consultants to work with 
during all project phases.
o   Provide virtual workstations with VPN connectivity for design and 
development activities.
o   Provide an R&D environment that can be used to test automation.
o   Provide licenses for applicable development and build tools.
o   Provide incident and defect tracking toolsets.
o   Frameworks to work within for build, deployment, and continuous integration 
deliverables.
o   Participate in reviews, inspections, and turnovers.
o   Provide information on architecture vision and artifacts.
o   Provide functional information about the applicable application 
environments.
o   Assist in problem resolution.
o   Approve technical specifications and manual install documentation 
referencing the initial environment install of which the automation should be 
based.
o   Provide information on existing configuration management tools.
o   Provide content in existing Best Practice Library
o   Provide functional information about the existing application environment.
o   Assist in problem resolution.
o   Provide review, inspection, and turnover process and procedures.

Awaiting for your reply

Thanks in Anticipation,
Val | IT Division Inc.|
Direct: 678-740-6997|
v...@itdivisioninc.com |www.ITDivisionInc.com| 
Disclaimer: To be removed from our mailing lists please reply back with 
the"REMOVE" in subject line. Sorry for any inconvenience.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread MRAB

On 2015-11-16 17:12, input/ldompel...@casema.nl wrote:

When I try to run this module in Windows IDLE I get this message:
How can I solve this problem.

Thanks

Traceback (most recent call last):
   File "C:\raspberrypi\recipe-578839-1.py", line 1, in 
 import pyttsx
ImportError: No module named 'pyttsx'

This is what I found on the internet:
---
import pyttsx
engine = pyttsx.init()
engine.setProperty('rate', 70)

voices = engine.getProperty('voices')
for voice in voices:
 print ("Using voice:"), repr(voice)
 engine.setProperty('voice', voice.id)
 engine.say("Hi there, how's you ?")
 engine.say("A B C D E F G H I J K L M")
 engine.say("N O P Q R S T U V W X Y Z")
 engine.say("0 1 2 3 4 5 6 7 8 9")
 engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")
 engine.say("Violet Indigo Blue Green Yellow Orange Red")
 engine.say("Apple Banana Cherry Date Guava")
engine.runAndWait()



Have you installed pyttsx?

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


Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread input/ldompeling
In reply to "MRAB" who wrote the following:
Have you installed pyttsx?

No, I did not.
Where can I find pyttsx to install ?

Thanks
-
> On 2015-11-16 17:12, input/ldompel...@casema.nl wrote:
> > When I try to run this module in Windows IDLE I get this message:
> > How can I solve this problem.
> > 
> > Thanks
> > 
> > Traceback (most recent call last):
> >File "C:\raspberrypi\recipe-578839-1.py", line 1, in 
> >  import pyttsx
> > ImportError: No module named 'pyttsx'
> > 
> > This is what I found on the internet:
> > ---
> > import pyttsx
> > engine = pyttsx.init()
> > engine.setProperty('rate', 70)
> > 
> > voices = engine.getProperty('voices')
> > for voice in voices:
> >  print ("Using voice:"), repr(voice)
> >  engine.setProperty('voice', voice.id)
> >  engine.say("Hi there, how's you ?")
> >  engine.say("A B C D E F G H I J K L M")
> >  engine.say("N O P Q R S T U V W X Y Z")
> >  engine.say("0 1 2 3 4 5 6 7 8 9")
> >  engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")
> >  engine.say("Violet Indigo Blue Green Yellow Orange Red")
> >  engine.say("Apple Banana Cherry Date Guava")
> > engine.runAndWait()
> > 
> > 
> Have you installed pyttsx?




-- 
- --- -- -
Posted with NewsLeecher v7.0 Beta 2
Web @ http://www.newsleecher.com/?usenet
--- -  -- -

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


Getting started Image processing python

2015-11-16 Thread Vindhyachal Takniki
1. I want to learn basic image processing in python. (working on raspberry pi 2 
board)

2. I have a image with different color dots like red,white, etc.After taking 
image, need to identify how many are red,white etc. 
I am looking for free image processing libs for that. Which one is better for 
begineers : http://scikit-image.org/download.html  or 
http://opencv-python-tutroals.readthedocs.org/en/latest/index.html ?





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


Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread MRAB

On 2015-11-16 17:45, input/ldompel...@casema.nl wrote:

In reply to "MRAB" who wrote the following:
Have you installed pyttsx?

No, I did not.
Where can I find pyttsx to install ?


The first place to look is PyPI. It's here:

https://pypi.python.org/pypi/pyttsx

You might want to look at the links for the homepage and documentation.
That mentions a later version.


Thanks
-

On 2015-11-16 17:12, input/ldompel...@casema.nl wrote:
> When I try to run this module in Windows IDLE I get this message:
> How can I solve this problem.
>
> Thanks
>
> Traceback (most recent call last):
>File "C:\raspberrypi\recipe-578839-1.py", line 1, in 
>  import pyttsx
> ImportError: No module named 'pyttsx'
>
> This is what I found on the internet:
> ---
> import pyttsx
> engine = pyttsx.init()
> engine.setProperty('rate', 70)
>
> voices = engine.getProperty('voices')
> for voice in voices:
>  print ("Using voice:"), repr(voice)
>  engine.setProperty('voice', voice.id)
>  engine.say("Hi there, how's you ?")
>  engine.say("A B C D E F G H I J K L M")
>  engine.say("N O P Q R S T U V W X Y Z")
>  engine.say("0 1 2 3 4 5 6 7 8 9")
>  engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")
>  engine.say("Violet Indigo Blue Green Yellow Orange Red")
>  engine.say("Apple Banana Cherry Date Guava")
> engine.runAndWait()
>
>
Have you installed pyttsx?




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


Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread Terry Reedy

On 11/16/2015 12:45 PM, input/ldompel...@casema.nl wrote:

In reply to "MRAB" who wrote the following:
Have you installed pyttsx?

No, I did not.
Where can I find pyttsx to install ?


Let pip find it (its on pypi).
On a command line, enter 'pip install pyttsx'

--
Terry Jan Reedy

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


Re: write data in Excel using python

2015-11-16 Thread Michiel Overtoom

Hi,

> On 16 Nov 2015, at 18:14, syedmwaliul...@gmail.com wrote:
> For some reason it doesn't save the file.

Did you get an error message?

> excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx")

When you use backslashes in strings, don't forget to escape them:

> excel.activeWorkbook.SaveAs("c:\\TurnData.xlsx")

or use raw strings:

> excel.activeWorkbook.SaveAs(r"c:\TurnData.xlsx")

Greetings,


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


Re: Running latest 32-bit Python on 64-bit system

2015-11-16 Thread Christian Ullrich

* Zachary Ware wrote:


On Fri, Nov 13, 2015 at 4:52 AM, Christian Ullrich  wrote:



However, with the shebang syntax supported by the launcher, I can only
demand a 32-bit version if I also specify the Python minor version I want,
and I don't necessarily know that in advance.

I can code around that, of course, but I don't want to. If Python can select
the 64-bit version to run by itself, it should also be able to for the
32-bit version, right?


I don't think there's currently a way to do what you want, but it
seems like a reasonable thing to do.  Would you mind raising an
enhancement request on bugs.python.org?


. Crossing my fingers ...


About the closest you could come currently would be to specify the
full path to the interpreter, but of course that may vary by machine.


And it would include the version number in either the path (Windows) or 
the file name (elsewhere) again, rather defeating the purpose.


Thanks for your help,

--
Christian


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


Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread input/ldompeling
Now I get this error:

Traceback (most recent call last):
  File "C:\raspberrypi\recipe-578839-1.py", line 1, in 
import pyttsx
  File 
"C:\Users\loek\AppData\Local\Programs\Python\Python35\lib\site-packages\pyttsx\__init__.py",
 line 18, in 
from engine import Engine
ImportError: No module named 'engine'
===



In reply to "Terry Reedy" who wrote the following:

> On 11/16/2015 12:45 PM, input/ldompel...@casema.nl wrote:
> > In reply to "MRAB" who wrote the following:
> > Have you installed pyttsx?
> > 
> > No, I did not.
> > Where can I find pyttsx to install ?
> 
> Let pip find it (its on pypi).
> On a command line, enter 'pip install pyttsx'
> 
> --
> Terry Jan Reedy




-- 
- --- -- -
Posted with NewsLeecher v7.0 Beta 2
Web @ http://www.newsleecher.com/?usenet
--- -  -- -

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


Re: write data in Excel using python

2015-11-16 Thread Ian Kelly
On Mon, Nov 16, 2015 at 11:20 AM, Michiel Overtoom  wrote:
>
> Hi,
>
>> On 16 Nov 2015, at 18:14, syedmwaliul...@gmail.com wrote:
>> For some reason it doesn't save the file.
>
> Did you get an error message?
>
>> excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx")
>
> When you use backslashes in strings, don't forget to escape them:
>
>> excel.activeWorkbook.SaveAs("c:\\TurnData.xlsx")
>
> or use raw strings:
>
>> excel.activeWorkbook.SaveAs(r"c:\TurnData.xlsx")

You can also just use a forward slash:

excel.activeWorkbook.SaveAs("c:/TurnData.xlsx")

Windows happily accepts this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: write data in Excel using python

2015-11-16 Thread tdsperth
On Tuesday, November 17, 2015 at 1:14:56 AM UTC+8, SW wrote:
> hi, 
> I am trying to write Excel file suing output from another software where the 
> output comes as myturnlist.Show()
> 
> The first part is for the output from the software which is saved in the 
> clipboard. 
> 
> The big middle part works to open Excel and save the data into excel file 
> called "TurnData.xlsx". 
> 
> For some reason it doesn't save the file. 
> 
> Any idea?
> 
> Thanks in advance.
> 
> 
> import VisumPy.excel
> 
> # Write to Excel
> 
> myturnlist.Show()
> turnData = myturnlist.SaveToClipboard(59,0)
> 
> excel = win32com.client.Dispatch("Excel.Application")
> wb = excel.Workbooks.Add()
> exce.Visible = True
> wb.WorkSheets[0].Paste()
> excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx")
> 
> myturnlist.Close()

Take out exce.Visible = True ( which I believe is atypo)

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


palindrome

2015-11-16 Thread Seymore4Head
http://www.practicepython.org/exercise/2014/03/12/06-string-lists.html

Here is my answers.  What would make it better?

import random
str1=""
letcount=4
count=0
abc='abcdefghijklmnopqrstuvwxyz'
while True:
for i in range(letcount):
a=random.choice(abc)
str1+=a
print str1
count+=1
if str1==str1[::-1]:
break
else:
str1=""
print "Tries= ",count
print str1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: palindrome

2015-11-16 Thread Abhiram R
On Tue, Nov 17, 2015 at 9:59 AM, Seymore4Head 
wrote:

> http://www.practicepython.org/exercise/2014/03/12/06-string-lists.html
>
> Here is my answers.  What would make it better?
>
> import random
> str1=""
> letcount=4
> count=0
> abc='abcdefghijklmnopqrstuvwxyz'
> while True:
> for i in range(letcount):
> a=random.choice(abc)
> str1+=a
> print str1
> count+=1
> if str1==str1[::-1]:
> break
> else:
> str1=""
> print "Tries= ",count
> print str1
> --
>
> ​

The question asks to get an input from the user and print if it's a
palindrome or not.
It should be just

strA=raw_input()
if strA==strA[::-1]:
print "Palindrome"
else:
print "Not"

Right? Am I missing something? Why are you generating random strings and
trying to check for palindromes?​


Thanks
Abhiram R (IRC - abhiii5459_ ; Twitter - https://twitter.com/abhiii5459)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: palindrome

2015-11-16 Thread Seymore4Head
On Tue, 17 Nov 2015 10:09:27 +0530, Abhiram R
 wrote:

>On Tue, Nov 17, 2015 at 9:59 AM, Seymore4Head 
>wrote:
>
>> http://www.practicepython.org/exercise/2014/03/12/06-string-lists.html
>>
>> Here is my answers.  What would make it better?
>>
>> import random
>> str1=""
>> letcount=4
>> count=0
>> abc='abcdefghijklmnopqrstuvwxyz'
>> while True:
>> for i in range(letcount):
>> a=random.choice(abc)
>> str1+=a
>> print str1
>> count+=1
>> if str1==str1[::-1]:
>> break
>> else:
>> str1=""
>> print "Tries= ",count
>> print str1
>> --
>>
>> ?
>
>The question asks to get an input from the user and print if it's a
>palindrome or not.
>It should be just
>
>strA=raw_input()
>if strA==strA[::-1]:
>print "Palindrome"
>else:
>print "Not"
>
>Right? Am I missing something? Why are you generating random strings and
>trying to check for palindromes??
>
The instructions do ask for input.  I am lazy.  I thought it would be
cool to have random input instead of just typing a phrase.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: palindrome

2015-11-16 Thread Abhiram R
On Tue, Nov 17, 2015 at 10:18 AM, Seymore4Head  wrote:

> On Tue, 17 Nov 2015 10:09:27 +0530, Abhiram R
>  wrote:
>
> >On Tue, Nov 17, 2015 at 9:59 AM, Seymore4Head
> 
> >wrote:
> >
> >> http://www.practicepython.org/exercise/2014/03/12/06-string-lists.html
> >>
> >> Here is my answers.  What would make it better?
> >>
> >> import random
> >> str1=""
> >> letcount=4
> >> count=0
> >> abc='abcdefghijklmnopqrstuvwxyz'
> >> while True:
> >> for i in range(letcount):
> >> a=random.choice(abc)
> >> str1+=a
> >> print str1
> >> count+=1
> >> if str1==str1[::-1]:
> >> break
> >> else:
> >> str1=""
> >> print "Tries= ",count
> >> print str1
> >> --
> >>
> >> ?
> >
> >The question asks to get an input from the user and print if it's a
> >palindrome or not.
> >It should be just
> >
> >strA=raw_input()
> >if strA==strA[::-1]:
> >print "Palindrome"
> >else:
> >print "Not"
> >
> >Right? Am I missing something? Why are you generating random strings and
> >trying to check for palindromes??
> >
> The instructions do ask for input.  I am lazy.  I thought it would be
> cool to have random input instead of just typing a phrase.
> --
>
>
​Haha. Nice. Although with your length of string and the range you're
picking from,the chances of you getting a palindrome are (1/24!)  :D ​




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