Re: Hello World

2014-12-21 Thread Marko Rauhamaa
CM :

> On Sunday, December 21, 2014 2:44:50 AM UTC-5, CM wrote:
>> Hello, world!
>> 13
>
> Actually, there is no comma after Hello. 

Do you have a patch?


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


Re: how to generate a wsdl file for a web service in python

2014-12-21 Thread Burak Arslan

On 12/19/14 12:45, brice DORA wrote:
> i have already my python file which contains all methods of my web service. 
> so do you give a example or tell me how i can do it...

No, all you need is there in that example.

You need to decorate your functions using Spyne's @rpc, denote
input/output types using Spyne's type markers, wrap it inside a subclass
of Spyne's ServiceBase, pass the resulting service class to a Spyne
application setting your input/output protocols (you probably want Soap)
and pass that application to a transport of your choice (you probably
want WsgiApplication). If you need a Wsgi server, use CherryPy.

Bon courage,
Burak

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


Re: very weird pandas behavior

2014-12-21 Thread ryguy7272
On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:
> I downloaded pandas and put it in my python directory, then, at the C-prompt, 
> I ran this:
> "pip install pandas"
> 
> It looks like everything downloaded and installed fine.  Great.
> 
> Now, in Python Shell, I enter this:
> import pandas as pd
> 
> I get this error.  
> Traceback (most recent call last):
>   File "", line 1, in 
> import pandas as pd
> ImportError: No module named pandas
> 
> 
> Any idea what I'm doing wrong?


Thanks Steven.  I just tried what you recommended, and got this.

>>> import sys
>>> print(sys.version)
2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]
>>> print(sys.path)
['C:\\Python27\\Lib\\idlelib', 
'C:\\Python27\\lib\\site-packages\\requests-2.4.3-py2.7.egg', 
'C:\\Python27\\lib\\site-packages\\html-1.16-py2.7.egg', 'C:\\Python34', 
'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\DLLs', 
'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 
'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']
>>> 


I also got this.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Ryan>python
Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> python27
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'python27' is not defined
>>> python33
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'python33' is not defined
>>> python34
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'python34' is not defined
>>>

Any idea what's wrong?  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: very weird pandas behavior

2014-12-21 Thread Dave Angel

On 12/21/2014 07:44 AM, ryguy7272 wrote:

On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:

I downloaded pandas and put it in my python directory, then, at the C-prompt, I 
ran this:
"pip install pandas"


Thanks Steven.  I just tried what you recommended, and got this.


import sys
print(sys.version)

2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]

print(sys.path)

['C:\\Python27\\Lib\\idlelib', 
'C:\\Python27\\lib\\site-packages\\requests-2.4.3-py2.7.egg', 
'C:\\Python27\\lib\\site-packages\\html-1.16-py2.7.egg', 'C:\\Python34', 
'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\DLLs', 
'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 
'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']





I also got this.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Ryan>python
Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

python27

Traceback (most recent call last):
   File "", line 1, in 
NameError: name 'python27' is not defined


python27 and python33 are Windows commands, not Python ones.  You run 
them at the cmd prompt.  Steven suggested those to see what other 
versions of Python you have installed.


And of course the other question is what directory did pandas get 
installed to.   You can find that out with the find command, except that 
you're on Windows.  So I think you'd have to use  dir /s




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


Re: Hello World

2014-12-21 Thread Marko Rauhamaa
Tony the Tiger :

> On Sat, 20 Dec 2014 23:57:08 +1100, Steven D'Aprano wrote:
>
>> I am in total awe.
>
> I'm not. It has no real value.

It is, of course, a joke, and there are whole tongue-in-cheek languages
like Brainfuck. However, some similar exercises carry deep meaning.
Take, for example, iota and jot (http://semarch.linguistics.fas.nyu.edu/barker/Iota/>).

> Write your code like that and you'll soon be looking for a new job.

Navigare necesse est, vivere non est necesse.


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


problems with Methods in Python 3.4.2

2014-12-21 Thread Marcus Lütolf
Hello Dears,

I solved the problem: There are two underscore key strokes required.
Marcus.

Hello Dears,

1)I am trying to do this:



>>> dir(_builtins_)



I am getting this:

Traceback (most recent call last):

  File "", line 1, in 

dir(_builtins_)

NameError: name '_builtins_' is not defined



2)I am trying to do this:



>>> 'TTA',_add_('GGA')



I’am getting this :

Traceback (most recent call last):

  File "", line 1, in 

'TTA',_add_('GGA')

NameError: name '_add_' is not defined



3)I am trying to do this:



>>> -3  .abs()



I’am getting this

Traceback (most recent call last):

  File "", line 1, in 

-3 .abs()

AttributeError: 'int' object has no attribute 'abs'



4) finally, after printing



>>>abs._doc_()



I am getting this (and so on) :

Traceback (most recent call last):

  File "", line 1, in 

abs._doc_()

AttributeError: 'builtin_function_or_method' object has no attribute '_doc_'

What did I do wrong ? Thanks for help, Marcus Luetolf, M.D., 90 Bondastreet,
CH-7000 Chur, Switzerland.





---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
http://www.avast.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple background sound effect playback

2014-12-21 Thread Akira Li
"Jacob Kruger"  writes:

> Would prefer to use something free, that could work somewhat
> cross-platform, but, my primary target is for windows OS, and would
> primarily just want to be able to easily trigger playback of either
> .wav or .mp3 background sound effects, but, yes, would also be nice to
> be able to control them a little bit in terms of volume, possibly
> stereo panning as well as playback rate/frequency/pitch?
>
> I have used something called sound_lib, as well as another one
> relating to a sort of windows directSound effect, but, both of them
> had issues when working with either py2exe or cx_freeze when it came
> to compiling into executable, and main thing is would like to keep it
> simple...
>
> Suggestions?
>

You could try GStreamer: it is free, cross-platform, it allows you to
play media files in the background, to control volume, stereo panning
(e.g., GstAudioPanorama), to change the playback rate while preserving
pitch, it can use DirectShow on Windows, etc -- see
http://gstreamer.freedesktop.org/features/

The downside is that it may be complex to install and use e.g., it
probably works with py2exe but it won't be simple to configure.

If you know other library that provides similar feature list while being
less complex; do tell.


--
Akira.

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


Re: Simple background sound effect playback

2014-12-21 Thread Jacob Kruger
Will have a look at it as well, but, also already tested generating a 
console/command line app using the pygame code to play an .ogg file, panning 
it left and right, and the compilation worked alright, and am now still busy 
reloading primary machine, so haven't taken it too much further, but let's 
see...


Am not sure of redistribution licence either, and will need/want to test it 
on a couple of other types of machines.


Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "Akira Li" <4kir4...@gmail.com>

To: 
Sent: Monday, December 22, 2014 12:11 AM
Subject: Re: Simple background sound effect playback



"Jacob Kruger"  writes:


Would prefer to use something free, that could work somewhat
cross-platform, but, my primary target is for windows OS, and would
primarily just want to be able to easily trigger playback of either
.wav or .mp3 background sound effects, but, yes, would also be nice to
be able to control them a little bit in terms of volume, possibly
stereo panning as well as playback rate/frequency/pitch?

I have used something called sound_lib, as well as another one
relating to a sort of windows directSound effect, but, both of them
had issues when working with either py2exe or cx_freeze when it came
to compiling into executable, and main thing is would like to keep it
simple...

Suggestions?



You could try GStreamer: it is free, cross-platform, it allows you to
play media files in the background, to control volume, stereo panning
(e.g., GstAudioPanorama), to change the playback rate while preserving
pitch, it can use DirectShow on Windows, etc -- see
http://gstreamer.freedesktop.org/features/

The downside is that it may be complex to install and use e.g., it
probably works with py2exe but it won't be simple to configure.

If you know other library that provides similar feature list while being
less complex; do tell.


--
Akira.

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



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


Re: Hello World

2014-12-21 Thread Steven D'Aprano
Tony the Tiger wrote:

> On Sat, 20 Dec 2014 23:57:08 +1100, Steven D'Aprano wrote:
> 
>> I am in total awe.
> 
> I'm not. It has no real value. Write your code like that and you'll soon
> be looking for a new job.

Awww, did da widdle puddy tat get up on the wrong side of the bed this
morning? :-)


Obviously you don't write obfuscated code like this for production use,
except in such cases where you deliberately want to write obfuscated code
for production use.

Any beginner with 3 seconds experience with Python can write:

print "Hello World"


But being able to write obfuscated code to that degree displays real skill
and understanding of the language, and a great deal of patience and "stick
with it"-ness, all of which are valuable work skills.



-- 
Steven

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


Re: Hello World

2014-12-21 Thread Roy Smith
In article <54974ed7$0$12986$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> Obviously you don't write obfuscated code like this for production use,
> except in such cases where you deliberately want to write obfuscated code
> for production use.

Heh.  I once worked on a C++ project that included its own crypo code 
(i.e. custom implementations of things like AES and SHA-1).  The person 
who wrote some particular bit of the code had decided that deliberately 
obfuscating the function and variable names would somehow make it more 
secure, so that's what he did.

The mind boggles.  At so many levels.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2014-12-21 Thread Chris Angelico
On Mon, Dec 22, 2014 at 10:50 AM, Roy Smith  wrote:
> Heh.  I once worked on a C++ project that included its own crypo code
> (i.e. custom implementations of things like AES and SHA-1).  The person
> who wrote some particular bit of the code had decided that deliberately
> obfuscating the function and variable names would somehow make it more
> secure, so that's what he did.
>
> The mind boggles.  At so many levels.

Level 0: Why implement your own crypto?!?

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


Re: Hello World

2014-12-21 Thread Roy Smith
In article ,
 Chris Angelico  wrote:

> On Mon, Dec 22, 2014 at 10:50 AM, Roy Smith  wrote:
> > Heh.  I once worked on a C++ project that included its own crypo code
> > (i.e. custom implementations of things like AES and SHA-1).  The person
> > who wrote some particular bit of the code had decided that deliberately
> > obfuscating the function and variable names would somehow make it more
> > secure, so that's what he did.
> >
> > The mind boggles.  At so many levels.
> 
> Level 0: Why implement your own crypto?!?
> 
> ChrisA

That would be one of the levels.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2014-12-21 Thread mm0fmf

On 22/12/2014 00:10, Chris Angelico wrote:

Level 0: Why implement your own crypto?!?


Because people who don't understand the concepts behind cryptography 
don't understand that the crypto algorithm can be open whilst the 
results of applying the algorithm are secure.


There again I always use ROT-13 to encrypt my stuff. For the stuff that 
really has to be NSA-proof I use ROT-13 twice.


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


Re: Hello World

2014-12-21 Thread Chris Angelico
On Mon, Dec 22, 2014 at 11:12 AM, Roy Smith  wrote:
> In article ,
>  Chris Angelico  wrote:
>
>> On Mon, Dec 22, 2014 at 10:50 AM, Roy Smith  wrote:
>> > Heh.  I once worked on a C++ project that included its own crypo code
>> > (i.e. custom implementations of things like AES and SHA-1).  The person
>> > who wrote some particular bit of the code had decided that deliberately
>> > obfuscating the function and variable names would somehow make it more
>> > secure, so that's what he did.
>> >
>> > The mind boggles.  At so many levels.
>>
>> Level 0: Why implement your own crypto?!?
>>
>> ChrisA
>
> That would be one of the levels.

Good, I'm glad you agree on that one. I don't mind reimplementing some
other protocols (couple years ago now I built my own OAuth library
because the provided one was being terrible - no, this wasn't in
Python), especially the simple ones (SMTP or FTP - use a
library/module if available, but otherwise just establish a socket
connection and do whatever you need), and even complex protocols can
occasionally be worth reworking (Pike has its own PostgreSQL client,
rather than using libpq, and it gets some handy improvements in
concurrency), but crypto's one thing that it's *never* worth
rewriting.

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


Re: Hello World

2014-12-21 Thread Tim Chase
On 2014-12-22 00:20, mm0fmf wrote:
> On 22/12/2014 00:10, Chris Angelico wrote:
> > Level 0: Why implement your own crypto?!?
> 
> Because people who don't understand the concepts behind
> cryptography don't understand that the crypto algorithm can be open
> whilst the results of applying the algorithm are secure.
> 
> There again I always use ROT-13 to encrypt my stuff. For the stuff
> that really has to be NSA-proof I use ROT-13 twice.

Pshaw. When I really want to be secure, I stick to *Triple ROT13*

I mean, why else would Vim have the ability to do it easily out of
the box? (I suspect Emacs offers similar functionality)

Like ed(1), it's a standard! ;-)

-tkc




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


Re: very weird pandas behavior

2014-12-21 Thread ryguy7272
On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:
> I downloaded pandas and put it in my python directory, then, at the C-prompt, 
> I ran this:
> "pip install pandas"
> 
> It looks like everything downloaded and installed fine.  Great.
> 
> Now, in Python Shell, I enter this:
> import pandas as pd
> 
> I get this error.  
> Traceback (most recent call last):
>   File "", line 1, in 
> import pandas as pd
> ImportError: No module named pandas
> 
> 
> Any idea what I'm doing wrong?



Sorry for being so dense here guys!!  I do tons and tons of work with VBA, VB, 
C#, SQL, R, Matlab, and a little work with Pascal.  I guess that's preventing 
me from understanding how Python works.  Sorry, but I just don't understand 
this thing.  I uninstalled Python27 and just reinstalled it.  I open the cmd 
prompt, and entered two short commands: 'pip install numpy' & 'pip install 
pandas'.  Then, I got to Python Shell and enter this: 'import numpy' & 'import 
pandas'.  immediately I get errors.  

Traceback (most recent call last):
  File "", line 1, in 
import numpy
ImportError: No module named numpy

Traceback (most recent call last):
  File "", line 1, in 
import pandas
ImportError: No module named pandas

I guess if I can't do something simple, I can't do anything complex...or 
anything at all.

Part of the problem is, I don't know why in 2014 we're entering commands in the 
C-prompt to run a Windows program.  I thought all of that stuff was over in the 
very early 1990s.  Also, I can't understand why Python can't download this from 
the Internet.  

If someone can help me figure this out, I'd be most appreciative.  I don't want 
to give up, but after spending over 6 months learning Python, and reading 15 
Python books cover to cover, I don't understand why a simple 'import pandas' 
can't even work!!  That's about as basic as it gets.

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


Re: very weird pandas behavior

2014-12-21 Thread Chris Angelico
On Mon, Dec 22, 2014 at 12:01 PM, ryguy7272  wrote:
> Part of the problem is, I don't know why in 2014 we're entering commands in 
> the C-prompt to run a Windows program.  I thought all of that stuff was over 
> in the very early 1990s.  Also, I can't understand why Python can't download 
> this from the Internet.
>

You're expecting a GUI to let you pick stuff to install? That probably
exists... as a wrapper around the terminal commands. The command line
has never died, and never will. (I dream of futuristic voice-activated
spaceship computers that respond to "Computer! Console." by revealing
a keyboard and screen with a login prompt.)

Python can download this from the internet; in fact, that's exactly
what the "pip install numpy" command does. However, you have to be
explicit. You don't want the simple "import numpy" command to go and
install some third-party software; that would mean that mistyping it
as "import numpt" would also attempt to install something new, and
immediately run it. That's dangerous, costly (network requests can
take a long time), and definitely not a good idea.

What happened when you ran the 'pip install' lines? Also, what is the
output of 'pip --version' and 'python --version'?

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


Re: very weird pandas behavior

2014-12-21 Thread oldknackers
On Saturday, December 20, 2014 3:46:40 PM UTC, ryguy7272 wrote:
> I downloaded pandas and put it in my python directory, then, at the C-prompt, 
> I ran this:
> "pip install pandas"
> 
> It looks like everything downloaded and installed fine.  Great.
> 
> Now, in Python Shell, I enter this:
> import pandas as pd
> 
> I get this error.  
> Traceback (most recent call last):
>   File "", line 1, in 
> import pandas as pd
> ImportError: No module named pandas
> 
> 
> Any idea what I'm doing wrong?

It's begining to look like weird behavour from ryguy7272, multipe times asking 
how to install numpy on python-forum.org and not following the advice given.
http://www.python-forum.org/viewtopic.php?f=10&t=13700&p=23970#p23970
http://www.python-forum.org/viewtopic.php?f=6&t=13748&p=24082#p24082
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: very weird pandas behavior

2014-12-21 Thread Dave Angel

On 12/21/2014 08:01 PM, ryguy7272 wrote:

On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:

I downloaded pandas and put it in my python directory, then, at the C-prompt, I 
ran this:
"pip install pandas"

It looks like everything downloaded and installed fine.  Great.

Now, in Python Shell, I enter this:
import pandas as pd

I get this error.
Traceback (most recent call last):
   File "", line 1, in 
 import pandas as pd
ImportError: No module named pandas


Any idea what I'm doing wrong?




Sorry for being so dense here guys!!  I do tons and tons of work with VBA, VB, 
C#, SQL, R, Matlab, and a little work with Pascal.
> I guess that's preventing me from understanding how Python works. 
Sorry, but I just don't understand this thing.


Have you tried reading and responding to the advice you get?  Or do you 
just pick and choose?



 I uninstalled Python27 and just reinstalled it.


What did you do with the other Python versions that you still haven't 
said whether you have?



 I open the cmd prompt, and entered two short commands: 'pip install numpy' & 
'pip install pandas'.


And they got "command not found" errors, right?  After all, you haven't 
installed PIP yet.  Or if you have, it might be left over from some 
other version of Python.


Have you read anything about PIP?  Have you read the web page:
   https://pypi.python.org/pypi/pip/

Perhaps you could try:
pip show --files numpy

and see where they got installed.  Are they the same place as the Python 
2.7 you just installed?




 Then, I got to Python Shell and enter this: 'import numpy' & 'import pandas'.  
immediately I get errors.

Traceback (most recent call last):
   File "", line 1, in 
 import numpy
ImportError: No module named numpy

Traceback (most recent call last):
   File "", line 1, in 
 import pandas
ImportError: No module named pandas

I guess if I can't do something simple, I can't do anything complex...or 
anything at all.



If I had any confidence that you were always running the same version of 
Python, from the same installation, then I could suggest more stuff, 
like checking out sys.path and comparing it to the place where PIP 
installed things.


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


Re: very weird pandas behavior

2014-12-21 Thread ryguy7272
On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:
> I downloaded pandas and put it in my python directory, then, at the C-prompt, 
> I ran this:
> "pip install pandas"
> 
> It looks like everything downloaded and installed fine.  Great.
> 
> Now, in Python Shell, I enter this:
> import pandas as pd
> 
> I get this error.  
> Traceback (most recent call last):
>   File "", line 1, in 
> import pandas as pd
> ImportError: No module named pandas
> 
> 
> Any idea what I'm doing wrong?



Thanks for being patient with me everyone.


I just tried this:
C:\Users\Ryan>pip --version
pip 1.5.6 from C:\Python27\lib (python 2.7)

C:\Users\Ryan>python --version
Python 2.7


I just tried 'pip show --files numpy' in the command prompt; nothing happened.


I'll read that link now.


I know my eyes are not very good...my vision is quite poor...but I'm trying to 
read this stuff, and I'm trying to figure out what's going on here...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: very weird pandas behavior

2014-12-21 Thread ryguy7272
On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:
> I downloaded pandas and put it in my python directory, then, at the C-prompt, 
> I ran this:
> "pip install pandas"
> 
> It looks like everything downloaded and installed fine.  Great.
> 
> Now, in Python Shell, I enter this:
> import pandas as pd
> 
> I get this error.  
> Traceback (most recent call last):
>   File "", line 1, in 
> import pandas as pd
> ImportError: No module named pandas
> 
> 
> Any idea what I'm doing wrong?



Ok, if I enter this into the command prompt:

'pip show --files numpy'
'pip show --files pandas'

I get nothing returned from either entry.  That seems ot be a problem!

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


Re: very weird pandas behavior

2014-12-21 Thread ryguy7272
On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:
> I downloaded pandas and put it in my python directory, then, at the C-prompt, 
> I ran this:
> "pip install pandas"
> 
> It looks like everything downloaded and installed fine.  Great.
> 
> Now, in Python Shell, I enter this:
> import pandas as pd
> 
> I get this error.  
> Traceback (most recent call last):
>   File "", line 1, in 
> import pandas as pd
> ImportError: No module named pandas
> 
> 
> Any idea what I'm doing wrong?



I just ran these two commands in the c-prompt:
pip install --upgrade numpy
pip install --upgrade pandas

It seemed like everything was being downloaded and installed.  Seems ok.  Then 
I go back to the Python Shell and ran 'import numpy' & 'import pandas' and I 
still get the errors that I got before.

So, I move on to this:
pip uninstall numpy
pip uninstall pandas

It says, cannon uninstall, non installed.

Sorry, but that's what drives me nuts.  I install a few packages, and the 
messages that I get says the package is installed...then it says it's NOT 
installed...I don't know what to think...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2014-12-21 Thread Cameron Simpson

On 21Dec2014 01:31, Terry Reedy  wrote:

On 12/21/2014 12:31 AM, Chris Angelico wrote:

On Sun, Dec 21, 2014 at 4:14 PM, CM  wrote:

I ran it in IDLE with Python 2.7.8 and got:

Traceback (most recent call last):
  File "C:/Python27/helloworld.py", line 39, in 
lambda _, __, ___, , _, __, ___, : _
  File "C:/Python27/helloworld.py", line 21, in 
_))) + (_ << __) + (_ << ___)
OSError: [Errno 9] Bad file descriptor


Yes, because - like most "Hello world" programs - it attempts to write
to stdout. This interferes with IDLE and the way it captures output
for the graphical environment.


Just to be clear, writing to sys.stdout works fine in Idle.

import sys; sys.stdout.write('hello ')

hello  #2.7

In 3.4, the number of chars? bytes? is returned and written also.

Whether you mean something different by 'stdout' or not, I am not 
sure.


He means file descriptor 1. sys.stdout does not have a file descriptor at all 
under IDLE.



The error is from writing to a non-existent file descriptor.
The os 'file descriptor functions are unix functions.  Many but not 
all also work on Windows.  I do not believe that was true on msdos. 
According to the os doc, they do not work on osx.


Please cite that doc. OSX _is_ UNIX, like almost all modern platforms.
A glance at a set of 3.4.0 docs convenient to hand finds only one call 
explicitly labelled as not working under MacOS (os.fdatasync).



Python io streams are not required to have a file descriptor.


Indeed, but the program cited relies on one. So it is not perfectly portable, 
but still widely usable.


Cheers,
Cameron Simpson 

Tachyon: A gluon that's not completely dry.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2014-12-21 Thread Rustom Mody
On Monday, December 22, 2014 4:21:13 AM UTC+5:30, Steven D'Aprano wrote:
> 
> Awww, did da widdle puddy tat get up on the wrong side of the bed this
> morning? :-)
> 
> 
> Obviously you don't write obfuscated code like this for production use,
> except in such cases where you deliberately want to write obfuscated code
> for production use.
> 
> Any beginner with 3 seconds experience with Python can write:
> 
> print "Hello World"
> 

Bad Boy -- Stand in the corner for forgetting the '()'
[Good boys use python3]
On a more serious note...

> Tony the Tiger wrote:
> 
> > On Sat, 20 Dec 2014 23:57:08 +1100, Steven D'Aprano wrote:
> > 
> >> I am in total awe.
> > 
> > I'm not. It has no real value. Write your code like that and you'll soon
> > be looking for a new job.


If a python teacher wanted, that blog has enough internal python mechanisms on 
display strung together into a cute result
for a number of lectures. [If only I could wrap my brain round it all]

IOW learning language-L and real world programming in L are 
quite different. Related to 

1. People read programs far more often than they write
2. Different types of vocabularies
http://en.wikipedia.org/wiki/Vocabulary#Degree_of_knowledge
and next
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: very weird pandas behavior

2014-12-21 Thread Chris Angelico
On Mon, Dec 22, 2014 at 1:25 PM, ryguy7272  wrote:
>
> I just ran these two commands in the c-prompt:
> pip install --upgrade numpy
> pip install --upgrade pandas
>
> It seemed like everything was being downloaded and installed.  Seems ok.  
> Then I go back to the Python Shell and ran 'import numpy' & 'import pandas' 
> and I still get the errors that I got before.
>
> So, I move on to this:
> pip uninstall numpy
> pip uninstall pandas
>
> It says, cannon uninstall, non installed.
>
> Sorry, but that's what drives me nuts.  I install a few packages, and the 
> messages that I get says the package is installed...then it says it's NOT 
> installed...I don't know what to think...
>

Lesson #0 of computing: When a program tells you something and you
then ask for help, *copy and paste* the program's output. "It seemed
like" is the most likely source of error here. Maybe there was an
error reported, and you simply didn't recognize it... but by not
showing us the output, you force us to trust your judgment about what
it seemed like.

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


Re: very weird pandas behavior

2014-12-21 Thread Mark Lawrence

On 22/12/2014 02:07, ryguy7272 wrote:

On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:

I downloaded pandas and put it in my python directory, then, at the C-prompt, I 
ran this:
"pip install pandas"

It looks like everything downloaded and installed fine.  Great.

Now, in Python Shell, I enter this:
import pandas as pd

I get this error.
Traceback (most recent call last):
   File "", line 1, in 
 import pandas as pd
ImportError: No module named pandas


Any idea what I'm doing wrong?




Thanks for being patient with me everyone.


I just tried this:
C:\Users\Ryan>pip --version
pip 1.5.6 from C:\Python27\lib (python 2.7)

C:\Users\Ryan>python --version
Python 2.7


I just tried 'pip show --files numpy' in the command prompt; nothing happened.


I'll read that link now.


I know my eyes are not very good...my vision is quite poor...but I'm trying to 
read this stuff, and I'm trying to figure out what's going on here...



Try 'pip --help'.

c:\cpython>pip --help

Usage:
  pip  [options]

Commands:
  install Install packages.
  uninstall   Uninstall packages.
  freeze  Output installed packages in requirements 
format.

  listList installed packages.
  showShow information about installed packages.
  search  Search PyPI for packages.
  wheel   Build wheels from your requirements.
  zip DEPRECATED. Zip individual packages.
  unzip   DEPRECATED. Unzip individual packages.
  bundle  DEPRECATED. Create pybundles.
  helpShow help for commands.

General Options:
  -h, --help  Show help.
  -v, --verbose   Give more output. Option is additive, and 
can be

  used up to 3 times.
  -V, --version   Show version and exit.
  -q, --quiet Give less output.
  --log-filePath to a verbose non-appending log, that 
only
  logs failures. This log is active by 
default at

  C:\Users\Mark\pip\pip.log.
  --log Path to a verbose appending log. This log is
  inactive by default.
  --proxy  Specify a proxy in the form
  [user:passwd@]proxy.server:port.
  --timeout  Set the socket timeout (default 15 seconds).
  --exists-action Default action when a path already exists:
  (s)witch, (i)gnore, (w)ipe, (b)ackup.
  --certPath to alternate CA bundle.

Having digested the above try 'pip list'.

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

Mark Lawrence

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


Re: very weird pandas behavior

2014-12-21 Thread Rustom Mody
On Monday, December 22, 2014 7:55:50 AM UTC+5:30, ryguy7272 wrote:

> Sorry, but that's what drives me nuts.  I install a few packages, and the 
> messages that I get says the package is installed...then it says it's NOT 
> installed...I don't know what to think...

Its nice to bang the head against the wall (at times)
The wall can feel so cool (at times)

Its also nice to listen

> On Saturday, December 20, 2014 10:46:40 AM UTC-5, ryguy7272 wrote:
> > I downloaded pandas and put it in my python directory, then, at the 
> > C-prompt, I ran this:
> > "pip install pandas"
> > 
> > It looks like everything downloaded and installed fine.  Great.
> > 
> > Now, in Python Shell, I enter this:
> > import pandas as pd
> > 
> > I get this error.  
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > import pandas as pd
> > ImportError: No module named pandas
> > 
> > 
> > Any idea what I'm doing wrong?
> 
> 
> 
> I just ran these two commands in the c-prompt:
> pip install --upgrade numpy
> pip install --upgrade pandas
> 
> It seemed like everything was being downloaded and installed.

To whom did it 'seem'?
Best I can see you've been suggested to paste the result of these
commands and you insist on thrashing about and not paying attention.

On a different note:

> Part of the problem is, I don't know why in 2014 we're 
> entering commands in the C-prompt to run a Windows program.  I 
> thought all of that stuff was over in the very early 1990s.  
> Also, I can't understand why Python can't download this from 
> the Internet.

is called culture-clash.
Like going from one side of the Atlantic to the other and complaining
"Why the &^)%% is everyone driving on the wrong side of the road?"

We use the command line a bit out here.
Perhaps less than bash-programmers
More then VB programmers.

You are free to
1. Get used to the different culture
2. Stay in familiar territory
3. Thrash about
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2014-12-21 Thread Mark Lawrence

On 22/12/2014 00:20, mm0fmf wrote:

On 22/12/2014 00:10, Chris Angelico wrote:

Level 0: Why implement your own crypto?!?


Because people who don't understand the concepts behind cryptography
don't understand that the crypto algorithm can be open whilst the
results of applying the algorithm are secure.

There again I always use ROT-13 to encrypt my stuff. For the stuff that
really has to be NSA-proof I use ROT-13 twice.



That is the sort of cunning plan that is even more cunning than the very 
best of Baldrick's cunning plans :)


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


Why my ; continuator idea is better for debugging too.

2014-12-21 Thread Skybuck Flying

Hello,

In the past I wrote about pascal's ; mistake.

; should be used as a continuator.

I just made a programming mistake which solidifies/merits my idea:

The programming mistake was this:

vBattlefieldLosingWarrior :=

// modified warrior and brain
vSimulatorWinningWarrior := vBattlefieldBattle.Warrior[0];

Code should look like this:

vBattlefieldLosingWarrior := 
TBattlefieldWarrior(vBattlefieldBattle.Warrior[2].Association);


// modified warrior and brain
vSimulatorWinningWarrior := vBattlefieldBattle.Warrior[0];

Fortunately there was a type mistmatch which hinted me at the programming 
mistake.


The code is a bit messy above so let's make a simpler example to understand, 
the in my oppinion, dangerous programming mistake:


A :=

B := C;

The above statements "A :=" is valid in Delphi's current design.

The danger is that B is assigned to A which is not what I wanted, the 
problem was missing code at A.


So the danger is that some day, somebody will write B in such a way that it 
will accidently be assigned to A.


By using ";" as a continuator instead of a "seperator" the code would look 
as follows:


A :=

B := C

Since there was no continuator specified, "future-Delphi" would have been 
able to detect this programming mistake.


Since it won't try to attach B to A since there is no continuator symbol.

I found it worth it to mention this so there ya go.

I am always glad when Delphi finds bugs like these... fortunately this time 
I got lucky thanks to a type mismatch.


Also the statement would have looked like A:=B:=C; which I think is not a 
valid statement in Delphi.


I ll test that just to be sure.

Yes fortunately Delphi does not allow such dangerous statements.

However I think C does, I am pretty sure of it. Another nice example why C 
is dangerous ! ;)


(Also my request for python is the ":" symbol removed from language and 
instead require statements to be on next line below if statement that be 
nice)
(Currently the ":" is perceived by me as unnecessary and annoying, an easy 
typo to make just like forgetting a ";" however these are not necessary in 
python so why remove ";" but not ":" ? seems inconsistent, and ya know me... 
I don't like inconsistencies, it's frikking annoying.).


Bye,
 Skybuck.

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


Re: Why my ; continuator idea is better for debugging too.

2014-12-21 Thread Steven D'Aprano
On Mon, 22 Dec 2014 04:28:33 +0100, Skybuck Flying wrote:

> I don't like inconsistencies, it's frikking annoying.).

I don't like cross-posting trolls, they're frikking annoying.


> Bye,

Oh, if only that were true.



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


Re: Why my ; continuator idea is better for debugging too.

2014-12-21 Thread Chris Angelico
On Mon, Dec 22, 2014 at 2:53 PM, Steven D'Aprano  wrote:
> On Mon, 22 Dec 2014 04:28:33 +0100, Skybuck Flying wrote:
>
>> I don't like inconsistencies, it's frikking annoying.).
>
> I don't like cross-posting trolls, they're frikking annoying.

My first thought was that it had been sent to the wrong list. That's
something I've been guilty of at times.

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


Re: code python

2014-12-21 Thread Rustom Mody
On Saturday, December 20, 2014 7:30:20 AM UTC+5:30, Khetam Yassen wrote:
> Hello all
> I Have problem about , How i can compute accuracy to unigram,bigram and 
> trigram
> and how i can change the size to iteration separate from 1 to 10 in each 
> stage from iteration train take 90% and training 10%.
> thank you to read my message

Assuming this is about nltk, your subject line needs to say that.
Also may be better to ask on an nltk-specific list
https://groups.google.com/forum/#!forum/nltk-users
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: very weird pandas behavior

2014-12-21 Thread Steven D'Aprano
On Sun, 21 Dec 2014 18:25:38 -0800, ryguy7272 wrote:

> I just ran these two commands in the c-prompt: 
> pip install --upgrade numpy
> pip install --upgrade pandas

What is the purpose of the --upgrade switch?

Just run `pip install numpy`, and COPY and PASTE the entire output of pip 
into your reply. Please don't say "it seemed like it installed", because 
your judgement may be wrong.


> It seemed like everything was being downloaded and installed.  Seems ok.
>  Then I go back to the Python Shell and ran 'import numpy' & 'import
> pandas' and I still get the errors that I got before.


I gave you some instructions to try before, but you don't appear to have 
followed them. Let's try again:

(1) First, confirm how many different versions of Python you have 
installed. Please don't reinstall Python again. That doesn't help, if 
anything it may make matters worse.

I suggested that you try running the following commands from the DOS 
prompt (or C-prompt, if you prefer to call it that):

python27
python33
python34

although not being an expert on Windows I'm not sure if there is a better 
way.

Another way may be to use the Windows' Find Files command to look for 
any .exe files with "python" in the name.


(2) Next, try installing numpy and pandas again, only this time don't use 
the --upgrade switch. COPY AND PASTE the output so we can see exactly 
what happened.


(3) Try running the Python shell again. Tell us *what* Python shell you 
are using. Your tracebacks say "" which is not standard. What 
are you actually running? Tell us *exactly* what steps you take to run 
the Python shell.


(4) I think you are running some sort of IDE (Integrated Development 
Environment). Are you running a third-party system like Anaconda, or 
possible something like Spyder? If so, then I suggest you check whether 
that third-party system is causing the problem. From the C prompt, just 
run "python" and then try importing numpy and see what happens. Again, 
COPY AND PASTE any output.


(5) Consider that unless you have a C compiler, and possibly a Fortran 
compiler, you may not be able to install numpy from source on your 
system. You may need to find some pre-built packages that match your 
version of Windows.



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


List Comprehensions

2014-12-21 Thread Ganesh Pal
Hi ,


(a)  I was trying to reduce the below piece of code using List
comprehension ? Any suggestion please let me know


 for opt in options:
  opt['result'] = Queue.Queue()
  tmp_thread = pause.Thread(opt)
  threads.append(tmp_thread)
   tmp_thread.start()

(b) *   Is there anything that I need to consider while using list
comprehension with threads ?*


Regards,

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


Re: List Comprehensions

2014-12-21 Thread Chris Angelico
On Mon, Dec 22, 2014 at 4:42 PM, Ganesh Pal  wrote:
> (a)  I was trying to reduce the below piece of code using List comprehension
> ? Any suggestion please let me know
>
>
>  for opt in options:
>   opt['result'] = Queue.Queue()
>   tmp_thread = pause.Thread(opt)
>   threads.append(tmp_thread)
>tmp_thread.start()
>
> (b)Is there anything that I need to consider while using list
> comprehension with threads ?

Your code is doing several things at once, so it's probably not worth
trying to turn it into a comprehension. I don't think it needs to be
shortened, anyway; looks fine to me.

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


Re: Hello World

2014-12-21 Thread Steve Hayes
On Mon, 22 Dec 2014 09:51:02 +1100, Steven D'Aprano
 wrote:

>Tony the Tiger wrote:
>
>> On Sat, 20 Dec 2014 23:57:08 +1100, Steven D'Aprano wrote:
>> 
>>> I am in total awe.
>> 
>> I'm not. It has no real value. Write your code like that and you'll soon
>> be looking for a new job.
>
>Awww, did da widdle puddy tat get up on the wrong side of the bed this
>morning? :-)
>
>
>Obviously you don't write obfuscated code like this for production use,
>except in such cases where you deliberately want to write obfuscated code
>for production use.

Yes, my initial reaction was "that's awesome".

And my second thought was that it was scary.

I ran it. It worked, and printed "Hello world". I was awed.

But what if I had run it and it reformatted my hard disk?

How would I have known that it would or wouldn't do that?


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: very weird pandas behavior

2014-12-21 Thread oldknackers
On Saturday, December 20, 2014 3:46:40 PM UTC, ryguy7272 wrote:
> I downloaded pandas and put it in my python directory, then, at the C-prompt, 
> I ran this:
> "pip install pandas"
> 
> It looks like everything downloaded and installed fine.  Great.
> 
> Now, in Python Shell, I enter this:
> import pandas as pd
> 
> I get this error.  
> Traceback (most recent call last):
>   File "", line 1, in 
> import pandas as pd
> ImportError: No module named pandas
> 
> 
> Any idea what I'm doing wrong?

Take a look at ryguy7272's previous questions here
https://groups.google.com/forum/#!searchin/comp.lang.python/ryguy7272
which take no notice of advice given.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2014-12-21 Thread Chris Angelico
On Mon, Dec 22, 2014 at 5:21 PM, Steve Hayes  wrote:
> Yes, my initial reaction was "that's awesome".
>
> And my second thought was that it was scary.
>
> I ran it. It worked, and printed "Hello world". I was awed.
>
> But what if I had run it and it reformatted my hard disk?
>
> How would I have known that it would or wouldn't do that?

You trust that (a) Steven D'Aprano isn't going to give you outright
malicious code (or that he trusts that the original author won't), and
that (b) your hard disk cannot be reformatted by a non-root user.
Every major platform has this kind of privilege separation (Windows
doesn't call it "root" but "Administrator", but the effect is, AIUI,
equivalent), so unless you're running random scripts from the internet
with maximum privileges, you should be safe.

Frankly, though, it's no worse than downloading binary code from the
internet and running it. How do you know that the executable you just
downloaded really is what it claims to be, that you didn't get some
MITM shipping you a malicious binary? Yet men and women do this every
day, with none to say "Oh the pity of it", save me and fools like me.

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


Re: Hello World

2014-12-21 Thread Steve Hayes
On Mon, 22 Dec 2014 17:33:10 +1100, Chris Angelico  wrote:

>On Mon, Dec 22, 2014 at 5:21 PM, Steve Hayes  wrote:
>> Yes, my initial reaction was "that's awesome".
>>
>> And my second thought was that it was scary.
>>
>> I ran it. It worked, and printed "Hello world". I was awed.
>>
>> But what if I had run it and it reformatted my hard disk?
>>
>> How would I have known that it would or wouldn't do that?
>
>You trust that (a) Steven D'Aprano isn't going to give you outright
>malicious code (or that he trusts that the original author won't), and
>that (b) your hard disk cannot be reformatted by a non-root user.
>Every major platform has this kind of privilege separation (Windows
>doesn't call it "root" but "Administrator", but the effect is, AIUI,
>equivalent), so unless you're running random scripts from the internet
>with maximum privileges, you should be safe.

Well yes, (a) is what I did and why I ran it. 

But a hacker who can write that kind of stuff can probably bypass any
safeguards built into the OS. 

As others have pointed out, it's not so much coding as black magic!


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2014-12-21 Thread Chris Angelico
On Mon, Dec 22, 2014 at 6:46 PM, Steve Hayes  wrote:
> But a hacker who can write that kind of stuff can probably bypass any
> safeguards built into the OS.

This isn't magic. You can't just do more of it to get past the
firewalls, like in sci fi. It's much MUCH easier to attack the humans
than the computers.

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