Re: Portable code: __import__ demands different string types between 2 and 3

2014-12-14 Thread Zachary Ware
On Mon, Dec 15, 2014 at 1:29 AM, Ben Finney wrote: > How can I get that ‘__import__’ call, complete with its ‘fromlist’ > parameter, working correctly under both Python 2 and Python 3, keeping > the ‘unicode_literals’ setting? How about "str('bar')"? > If some kind of kludge is needed to make it

Re: problem with six.moves intern importError

2014-12-14 Thread dieter
jean-michel richer writes: > Hi, > I am new to python and I am trying to use pycuda but get some > error on the following script. My environement is : > > Python 2.7.6 > libboost 1.54 > gcc/g++ 4.8.2 > CUDA 6.5 > ... > from six.moves import range, zip, intern, input > ImportError: cannot im

Portable code: __import__ demands different string types between 2 and 3

2014-12-14 Thread Ben Finney
Howdy all, What should I do, in a world where all text literals are Unicode by default, to make ‘__import__’ work in both Python 2 and 3? I'm slowly learning about making Python code that will run under both Python 2 (version 2.6 or above) and Python 3 (version 3.2 or above). This entails, I be

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Chris Angelico
On Mon, Dec 15, 2014 at 4:38 PM, Michael Torrie wrote: > Thought I had indirectly, since I've been using this print technique for > the last few days. Good to know it works either way, though. Guess the > future import is only to make not having parens and error. Yeah. I usually recommend using

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Zachary Ware
On Sun, Dec 14, 2014 at 11:38 PM, Michael Torrie wrote: > Guess the future import is only to make not having parens and error. Python 2.7.8+ (default, Nov 2 2014, 00:32:19) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print(1, 2)

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Michael Torrie
On 12/14/2014 10:32 PM, Chris Angelico wrote: > Did you actually test that? > > Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. print("hello") > hello > > Since print is a keyword when not

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Chris Angelico
On Mon, Dec 15, 2014 at 4:27 PM, Michael Torrie wrote: > On 12/14/2014 07:47 PM, Mark Lawrence wrote: >> I didn't realise that Python was so smart. It can indicate a syntax >> error at the final 't' in print before it gets to the opening bracket >> that is required for the print function in Pytho

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Michael Torrie
On 12/14/2014 07:47 PM, Mark Lawrence wrote: > I didn't realise that Python was so smart. It can indicate a syntax > error at the final 't' in print before it gets to the opening bracket > that is required for the print function in Python 3 (and Python 2 if > you're using "from __future__ impor

Re: Python Script to convert firewall rules

2014-12-14 Thread Jason Friedman
> Thank you very much. Appreciated ! But the first requirement was to convert > format1 to format2 as below: > > set interface ethernet2/5 ip 10.17.10.1/24 (format 1) > set interfaces ge-0/0/0 unit 0 family inet address 10.17.10.1/24 (format 2) > (set, interface, ip) = (set, interfaces, family inet

Re: How to import sqlite3 in my python3.4 successfully?

2014-12-14 Thread Thomas 'PointedEars' Lahn
sir wrote: ^^^ Please fix. > There are two python version in my debian7, one is python2.7 the system > default version, the other is python3.4 which compiled to install this > way. > > | apt-get update > apt-get upgrade > apt-get install build-essential > wget http://www.python.org/ftp/

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Mark Lawrence
On 15/12/2014 02:32, Chris Roy-Smith wrote: On 15/12/14 10:21, Simon Evans wrote: Dear Jussi, and Billy I have changed the input in accordance with your advice, re: -- Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Chris Angelico
On Mon, Dec 15, 2014 at 1:32 PM, Chris Roy-Smith wrote: > and here he uses a python 3.x print syntax which triggers the following > error message On the contrary; parens around a single argument will work just fine in Py2 (they're simply redundant parentheses, in the same way that you can write "

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Chris Roy-Smith
On 15/12/14 10:21, Simon Evans wrote: Dear Jussi, and Billy I have changed the input in accordance with your advice, re: -- Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win here the user

Re: Classes - converting external function to class's method.

2014-12-14 Thread Steven D'Aprano
Thomas 'PointedEars' Lahn wrote: > Ivan Evstegneev wrote: > >> I have stuck a bit with this example(took this one from the book). >> >> Here are a description steps of what I've done till now: >> >> >> Step 1 - creating an empty namespace: >> >class rec: pass > > IMHO that is not actual

Re: PySchool.net, kickstarter campaign

2014-12-14 Thread Billy Earney
Thanks.. I appreciate your contribution! On Sun, Dec 14, 2014 at 5:48 PM, Chris Angelico wrote: > > On Mon, Dec 15, 2014 at 10:41 AM, Billy Earney > wrote: > > Yes, you are correct. The scripts get compiled to javascript and then > > executed in the browser. Like you say, there are limitatio

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Steven D'Aprano
Simon Evans wrote: > Dear Jussi, and Billy > I have changed the input in accordance with your advice, re: > -- > Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] > on win 32 > Type "help", "copyrig

Re: Classes - converting external function to class's method.

2014-12-14 Thread Thomas 'PointedEars' Lahn
Terry Reedy wrote: > On 12/14/2014 6:15 PM, Thomas 'PointedEars' Lahn wrote: >> Ivan Evstegneev wrote: >>> I have stuck a bit with this example(took this one from the book). >>> >>> Here are a description steps of what I've done till now: >>> >>> Step 1 - creating an empty namespace: >>> >> cl

Re: Classes - converting external function to class's method.

2014-12-14 Thread Terry Reedy
On 12/14/2014 6:15 PM, Thomas 'PointedEars' Lahn wrote: Ivan Evstegneev wrote: I have stuck a bit with this example(took this one from the book). Here are a description steps of what I've done till now: Step 1 - creating an empty namespace: class rec: pass IMHO that is not actually creat

Re: PySchool.net, kickstarter campaign

2014-12-14 Thread Chris Angelico
On Mon, Dec 15, 2014 at 10:41 AM, Billy Earney wrote: > Yes, you are correct. The scripts get compiled to javascript and then > executed in the browser. Like you say, there are limitations, but most of > these focus around browser security issues, and on the plus side, these > scripts do not g

Re: PySchool.net, kickstarter campaign

2014-12-14 Thread Billy Earney
ChrisA, Yes, you are correct. The scripts get compiled to javascript and then executed in the browser. Like you say, there are limitations, but most of these focus around browser security issues, and on the plus side, these scripts do not get executed on the server side, so that helps reduce r

Re: PySchool.net, kickstarter campaign

2014-12-14 Thread Chris Angelico
On Mon, Dec 15, 2014 at 2:07 AM, Billy Earney wrote: > Students can create, edit, load, save, and execute Python scripts directly > in the browser. Importantly, these scripts are actually executed in the client - they are NOT being sent to the server for execution. That means there are limitation

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Simon Evans
Dear Jussi, and Billy I have changed the input in accordance with your advice, re: -- Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for

Re: Classes - converting external function to class's method.

2014-12-14 Thread Thomas 'PointedEars' Lahn
Ivan Evstegneev wrote: > I have stuck a bit with this example(took this one from the book). > > Here are a description steps of what I've done till now: > > > Step 1 - creating an empty namespace: > class rec: pass IMHO that is not actually creating a namespace; it is just declaring/def

Re: numpy question (fairly basic, I think)

2014-12-14 Thread Gregory Ewing
Albert-Jan Roskam wrote: I was trying to change the one-dim array into a two-dim array so I could easily retrieve columns. I now use a pandas DataFrame to do that. Numpy can do that, if I understand what you want correctly, but it requires an unintuitive trick. The trick is to index the array

RE: Classes - converting external function to class's method.

2014-12-14 Thread Ivan Evstegneev
Dear Steven, I very appreciate your answer. You just explained a lot of background things and you did it in more explicit and simple way than it've appeared in the book. I also agree with you about the fact that there are some advanced topics spread within a book's text. It is sometimes hard to

problem with six.moves intern importError

2014-12-14 Thread jean-michel richer
Hi, I am new to python and I am trying to use pycuda but get some error on the following script. My environement is : Python 2.7.6 libboost 1.54 gcc/g++ 4.8.2 CUDA 6.5 import pycuda.autoinit import pycuda.driver as drv import numpy from pycuda.compiler import

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Billy Earney
It looks like the last line (producer_entries...) is not indented at the same extent as the previous line. Maybe this is causing the issue? On Sun, Dec 14, 2014 at 10:15 AM, Simon Evans wrote: > > Dear Python programmers, > Having input the line of code in text: > cd Soup > to the Windows consol

PySchool.net, kickstarter campaign

2014-12-14 Thread Billy Earney
Greetings! For the past few months, I've been developing a website for educators and students to learn computer programming (ie, Python). My first project has been to create a basic programming environment entirely within a browser. Students can create, edit, load, save, and execute Python script

Re: encoding name mappings in codecs.py with email/charset.py

2014-12-14 Thread gst
Le dimanche 14 décembre 2014 14:10:22 UTC-5, Stefanos Karasavvidis a écrit : > thanks for replying gst. > > I've thought already of patching the Charset class, but hoped for a cleaner > solution. > > > This ALIASES dict has already all the iso names *with* a dash. So it must get > striped som

Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'

2014-12-14 Thread Chris Angelico
On Mon, Dec 15, 2014 at 1:48 AM, Simon Evans wrote: > Thanks Guys > This book keeps swapping from the Python console to the Windows - without > telling you, but it is the only book out there on 'Beautiful Soup' so I have > got to put up with it. There's more problems with it, but I will start a

Re: encoding name mappings in codecs.py with email/charset.py

2014-12-14 Thread Stefanos Karasavvidis
thanks for replying gst. I've thought already of patching the Charset class, but hoped for a cleaner solution. This ALIASES dict has already all the iso names *with* a dash. So it must get striped somewhere else. sk On Sun, Dec 14, 2014 at 7:21 PM, gst wrote: > Le vendredi 12 décembre 2014 04

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Jussi Piitulainen
Simon Evans writes: > I had another attempt at inputting the code perhaps with the right > indentation, I still get an error return, but not one that indicates > that the code has not been read, as you suggested. re:- > -- > > Py

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Simon Evans
I had another attempt at inputting the code perhaps with the right indentation, I still get an error return, but not one that indicates that the code has not been read, as you suggested. re:- Python 2.7.6 (default, Nov

Re: How to use the .isalpha() function correctly

2014-12-14 Thread Luke Tomaneng
On Sunday, December 14, 2014 9:27:14 AM UTC-8, Chris Warrick wrote: > On Sun, Dec 14, 2014 at 6:16 PM, Luke Tomaneng wrote: > > Here a very small program that I wrote for Codecademy. When I finished, > > Codecademy acted like it was correct, but testing of this code revealed > > otherwise. > > -

Re: Classes - converting external function to class's method.

2014-12-14 Thread Steven D'Aprano
Ivan Evstegneev wrote: > Hello Everyone, > > I have stuck a bit with this example(took this one from the book). The example you are working on (adding external functions as methods) is actually a bit more complicated than it seems, as you have discovered. You have this: class rec: pass rec.name

Re: Run Programming ?????

2014-12-14 Thread Luke Tomaneng
On Sunday, December 14, 2014 9:24:54 AM UTC-8, Luke Tomaneng wrote: > On Friday, December 12, 2014 4:40:01 AM UTC-8, Delgado Motto wrote: > > I travel alot, if not just interested in things of pocketable portability, > > and was curious if you can tell me if Python can be LEARNED from beginner >

Re: How to use the .isalpha() function correctly

2014-12-14 Thread Chris Warrick
On Sun, Dec 14, 2014 at 6:16 PM, Luke Tomaneng wrote: > Here a very small program that I wrote for Codecademy. When I finished, > Codecademy acted like it was correct, but testing of this code revealed > otherwise. > -- > print 'Welcome to the Pig

Re: Run Programming ?????

2014-12-14 Thread Luke Tomaneng
On Friday, December 12, 2014 4:40:01 AM UTC-8, Delgado Motto wrote: > I travel alot, if not just interested in things of pocketable portability, > and was curious if you can tell me if Python can be LEARNED from beginner on > an IOS device ( with interest of being able to test my code, possibly e

Re: encoding name mappings in codecs.py with email/charset.py

2014-12-14 Thread gst
Le vendredi 12 décembre 2014 04:21:14 UTC-5, Stefanos Karasavvidis a écrit : > I've hit a wall with mailman which seems to be caused by pyhon's character > encoding names. > > I've narrowed the problem down to the email/charset.py file. Basically the > following happens: > Hi, it's all in th

How to use the .isalpha() function correctly

2014-12-14 Thread Luke Tomaneng
Here a very small program that I wrote for Codecademy. When I finished, Codecademy acted like it was correct, but testing of this code revealed otherwise. -- print 'Welcome to the Pig Latin Translator!' # Start coding here! raw_input("Enter a word:

Re: How to import sqlite3 in my python3.4 successfully?

2014-12-14 Thread Albert-Jan Roskam
--- On Sun, Dec 14, 2014 4:06 PM CET sir wrote: >There are two python version in my debian7, one is python2.7 the system >default version, the other is python3.4 which compiled to install this way. > >| apt-get update > apt-get upgrade > apt-get install build-essentia

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Ned Batchelder
On 12/14/14 11:15 AM, Simon Evans wrote: Dear Python programmers, Having input the line of code in text: cd Soup to the Windows console, and having put the file 'EcologicalPyramid.html' into the Directory 'Soup', on the C drive, in accordance with instructions I input the following code to the

Classes - converting external function to class's method.

2014-12-14 Thread Ivan Evstegneev
Hello Everyone, I have stuck a bit with this example(took this one from the book). Here are a description steps of what I've done till now: Step 1 - creating an empty namespace: >>>class rec: pass Step 2 - adding some attributes: >>>rec.name = 'Bob' >>>rec.age = 40 Step 3 - Creating an in

Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Simon Evans
Dear Python programmers, Having input the line of code in text: cd Soup to the Windows console, and having put the file 'EcologicalPyramid.html' into the Directory 'Soup', on the C drive, in accordance with instructions I input the following code to the Python console, as given on page 30 of 'G

Re: how to delete my file if exits in the remote server with paramiko?

2014-12-14 Thread Roy Smith
In article , "" <1248283...@qq.com> wrote: > I want to delete the file "names.txt" if it exits in "/home/names.txt" in my > remote vps server. > import paramiko > host = "vps ip" > port = 22 > transport = paramiko.Transport((host, port)) > password = "key" > username = "root" > transport.co

How to import sqlite3 in my python3.4 successfully?

2014-12-14 Thread sir
There are two python version in my debian7, one is python2.7 the system default version, the other is python3.4 which compiled to install this way. | apt-get update apt-get upgrade apt-get install build-essential wget http://www.python.org/ftp/python/3.4.0/Python-3.4.0.tgz tar-zxvfPython

SQLObject 1.7.2

2014-12-14 Thread Oleg Broytman
Hello! I'm pleased to announce version 1.7.2, a bugfix release of branch 1.7 of SQLObject. What's new in SQLObject === * Fix a bug: zero-pad microseconds on the right, not on the left; 0.0835 seconds means 83500 microseconds. For a more complete list, please see the news:

Re: Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'

2014-12-14 Thread Simon Evans
Thanks Guys This book keeps swapping from the Python console to the Windows - without telling you, but it is the only book out there on 'Beautiful Soup' so I have got to put up with it. There's more problems with it, but I will start a new thread in regard of, I don't know if its related to the

Re: numpy question (fairly basic, I think)

2014-12-14 Thread Albert-Jan Roskam
- Original Message - > From: Steven D'Aprano > To: python-list@python.org > Cc: > Sent: Sunday, December 14, 2014 12:52 AM > Subject: Re: numpy question (fairly basic, I think) > > Albert-Jan Roskam wrote: > >> Hi, >> >> I am new to numpy. I am reading binary data one record at a

Re: how to delete my file if exits in the remote server with paramiko?

2014-12-14 Thread Skip Montanaro
On Sun, Dec 14, 2014 at 6:49 AM, 水静流深 <1248283...@qq.com> wrote: > Is there more elegant way to do the same work? Unlikely. You have two fairly simple bits of code in your example, one to connect to the remote server, the other to check for the file's existence and remove it. The only extra elegan

how to delete my file if exits in the remote server with paramiko?

2014-12-14 Thread ????????
I want to delete the file "names.txt" if it exits in "/home/names.txt" in my remote vps server. import paramiko host = "vps ip" port = 22 transport = paramiko.Transport((host, port)) password = "key" username = "root" transport.connect(username = username, password = password) sftp = paramiko.SFT

Re: which is the right file path format in python3.4 ?

2014-12-14 Thread Chris Angelico
On Sun, Dec 14, 2014 at 10:51 PM, Steven D'Aprano wrote: > I don't have access to a Windows box to check, otherwise I would do it > myself. What happens if you specify a non-existent drive letter? > > open("Q:\\xxx") # Assuming you don't have a drive Q. Hmm. I just grabbed one (granted, it's XP

Re: which is the right file path format in python3.4 ?

2014-12-14 Thread Steven D'Aprano
Chris Angelico wrote: > On Sun, Dec 14, 2014 at 10:03 PM, Steven D'Aprano > wrote: >> Run this code and show us what it prints: >> >> import os >> print(os.stat("F:\\") >> print(os.access("F:\\", os.O_RDWR)) > > (With an extra close parenthesis on the first print call) Thanks. > I'm suspicio

Re: which is the right file path format in python3.4 ?

2014-12-14 Thread Chris Angelico
On Sun, Dec 14, 2014 at 10:03 PM, Steven D'Aprano wrote: > Run this code and show us what it prints: > > import os > print(os.stat("F:\\") > print(os.access("F:\\", os.O_RDWR)) (With an extra close parenthesis on the first print call) I'm suspicious here that drive F might not even exist. I woul

Re: which is the right file path format in python3.4 ?

2014-12-14 Thread Steven D'Aprano
sir wrote: > My system is :win7+python3.4 . > > I want to write a new file "named names.txt" in disk f: > > >>> ff=open(r"F:\names.txt","w") > Traceback (most recent call last): >File "", line 1, in > OSError: [Errno 22] Invalid argument: 'F:\\names.txt' Are you sure that you have an F

Re: which is the right file path format in python3.4 ?

2014-12-14 Thread Irmen de Jong
On 14-12-2014 10:05, sir wrote: > My system is :win7+python3.4 . > > I want to write a new file "named names.txt" in disk f: > > >>> ff=open(r"F:\names.txt","w") > Traceback (most recent call last): > File "", line 1, in > OSError: [Errno 22] Invalid argument: 'F:\\names.txt' ff=open(r

which is the right file path format in python3.4 ?

2014-12-14 Thread sir
My system is :win7+python3.4 . I want to write a new file "named names.txt" in disk f: >>> ff=open(r"F:\names.txt","w") Traceback (most recent call last): File "", line 1, in OSError: [Errno 22] Invalid argument: 'F:\\names.txt' >>> ff=open(r"F:/names.txt","w") Traceback (most recent call