Re: [Tutor] vim as a python editor

2010-12-15 Thread Knacktus

Am 15.12.2010 23:26, schrieb Paul Griffiths:

Hi - I'm a beginner at programming and Python.

I have been looking for an editor to replace Idle and tried out a few.
I liked Geany but decided on vim because I am also learning Linux
and the vim skills might be useful.  I run Python 2.6.5 on Ubuntu 10.04.

How have those of you who use vim configured it?  I have looked
on the web but got a bit confused by the advice and options.

I am currently following some of the advice in the on-line tutorial at
http://openbookproject.net/thinkcs/python/english2e/app_c.html and

- installed the full version of vim (sudo apt-get install vim-gnome)
- created a .vimrc file in my home directory and entered
 syntax enable
 filetype indent on
 set et
 set sw=4
 set smarttab
 map  :w\|!python %

- added the following to .bashrc:
 EDITOR=vim
 export EDITOR


I forgot:
Here some more information about vim and Python:

http://wiki.python.org/moin/Vim

Some guy tuned vim to the maximum with code completion and everything. 
But start simple to learn the basics. You can extend anytime later.


Jan



I open up a terminal in the folder where I keep my python files and
create two additional tabs in this terminal.  I use the first tab to
run python, the second one to run vim and the third one for running
linux commands such as ls to list the folder contents.

Is this is a reasonable approach?  Thank you for any feed back.


PaulG



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] vim as a python editor

2010-12-15 Thread Knacktus

Am 15.12.2010 23:26, schrieb Paul Griffiths:

Hi - I'm a beginner at programming and Python.

I have been looking for an editor to replace Idle and tried out a few.
I liked Geany but decided on vim because I am also learning Linux
and the vim skills might be useful.  I run Python 2.6.5 on Ubuntu 10.04.

How have those of you who use vim configured it?  I have looked
on the web but got a bit confused by the advice and options.

I am currently following some of the advice in the on-line tutorial at
http://openbookproject.net/thinkcs/python/english2e/app_c.html and

- installed the full version of vim (sudo apt-get install vim-gnome)
- created a .vimrc file in my home directory and entered
 syntax enable
 filetype indent on
 set et
 set sw=4
 set smarttab
 map  :w\|!python %

- added the following to .bashrc:
 EDITOR=vim
 export EDITOR

I open up a terminal in the folder where I keep my python files and
create two additional tabs in this terminal.  I use the first tab to
run python, the second one to run vim and the third one for running
linux commands such as ls to list the folder contents.

Is this is a reasonable approach?  Thank you for any feed back.
Sure. I'm more an IDE-guy for Python now, but in my "before-days" with 
Fortran I used pretty much this approach.
Even though I'm using an IDE (on Windows) myself, I would recommend 
learning vi/vim.


Regs,

Jan




PaulG



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] vim as a python editor

2010-12-15 Thread Alan Gauld


"Paul Griffiths"  wrote


How have those of you who use vim configured it?  I have looked
on the web but got a bit confused by the advice and options.


I use both IDLE (for simple short scipts) and vim (for bigger
multi-file projects).

I use vim pretty much out of the box, I deliberately don't configure
it because I want it to work the same on any Linux box I log into.
I use the standad Python syntax highlighting scheme.

There is an IDLE-style settings file available somewhere that
will make vim superficially like IDLE, but personally I didn't
find it helped much and I prefer to keep to standard vim.


- added the following to .bashrc:
   EDITOR=vim
   export EDITOR


You should do the same for VISUAL.
Some programs distinguish between EDITOR and VISUAL and
the default for both is ed...


I open up a terminal in the folder where I keep my python files and
create two additional tabs in this terminal.  I use the first tab to
run python, the second one to run vim and the third one for running
linux commands such as ls to list the folder contents.


I don't use a tabbed console but prefer three windows(*).
One running graphical vim (vim -g), one running the python
interpreter and one a standard shell prompt. My mode of
working is try something in the interpreter, when it works translate
it into vim. Save the file and then run it in the shell window (up 
arrow

is my friend).

(*) I usually have a browser open at the Python documentation too.
And I have Firefox shortcuts/tags set up so I go to my favourite
pages - like the module A-Z listing - in one short code (ie a-z).

I also use split screen view in vim so that within vim I often have
two or three buffers open at once all displayed in a split screen.
One addition I'd like in vim 8 is the ability to have tabbed editor
buffers in addition to split screens. Switching buffers isn't hard
but tabs make it much easier. (Scite has tabs but no split screen
and that's worse, but I'd like both!)


Is this is a reasonable approach?  Thank you for any feed back.


Works for me, and a lot of other folks too.

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] vim as a python editor

2010-12-15 Thread Paul Griffiths
Hi - I'm a beginner at programming and Python.

I have been looking for an editor to replace Idle and tried out a few.
I liked Geany but decided on vim because I am also learning Linux
and the vim skills might be useful.  I run Python 2.6.5 on Ubuntu 10.04.

How have those of you who use vim configured it?  I have looked
on the web but got a bit confused by the advice and options.

I am currently following some of the advice in the on-line tutorial at
http://openbookproject.net/thinkcs/python/english2e/app_c.html and

- installed the full version of vim (sudo apt-get install vim-gnome)
- created a .vimrc file in my home directory and entered
syntax enable
filetype indent on
set et
set sw=4
set smarttab
map  :w\|!python %

- added the following to .bashrc:
EDITOR=vim
export EDITOR

I open up a terminal in the folder where I keep my python files and
create two additional tabs in this terminal.  I use the first tab to
run python, the second one to run vim and the third one for running
linux commands such as ls to list the folder contents.

Is this is a reasonable approach?  Thank you for any feed back.


PaulG
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Parameterized Queries failing on MySQL

2010-12-15 Thread Shea Grove

> 

> I’m using pyodbc to interact with MS SQL Server and I’m starting to support 
> mysql.  My issue is that when I use a parameterized query, it works for SQL 
> Server, but crashes when I point to MySQL.  Is there a different syntax that 
> I should be using? or module?
>  
> EG
> Import pyodbc
>  
> def openCursor(DSN):
> cnxn=pyodbc.connect(('DSN=%s')%DSN)
> cursor=cnxn.cursor()
> return cnxn,cursor
>  
> lParams=[]
> query='insert into RestaurantTable values (?, ?, ?, ?, ?, ?, ?, ?, ?)'
>  
> #SQL Server Works
> scnxn,scursor = openCursor(SQLServer)
> scursor.execute(query,lParams)
> scnxn.commit()
> scnxn.close()
>  
> #This Query bombs out and crashes my IDLE shell.  No transactions are 
> commited.
> mcnxn,mcursor = openCursor(MySQL)
> mcursor.execute(query,params)
> mcnxn.commit()
> mcnxn.close()
>  
>  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Can't even get hello to work???!!

2010-12-15 Thread Emile van Sebille

On 12/15/2010 9:56 AM Alan Gauld said...


"Khalid Akram"  wrote


I'm using Python 3.1.3 on Windows XP (using Python Shell).
This is what I am trying:

print 'hello'
...
SyntaxError: invalid syntax



What could possibly be wrong?


You are using a Python v3 interpreter but a Python v2 tutorial.
Python v3 has several new features which are not backward compatible
with v2.



Actually, "the print statement is deprecated" ought not be out of reach. 
 Invalidating every existing python book's first chapter without bias 
is unfortunate.


Emile





Try

print( 'hello' )

You can either downgrade Python to v2 and follow your tutorial
or find a v3 tutorial. (If you can already program just use the official
one on the Python web site or if you are a new programmer you
might like to try mine :-)




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Can't even get hello to work???!!

2010-12-15 Thread Alan Gauld


"Khalid Akram"  wrote


I'm using Python 3.1.3 on Windows XP (using Python Shell).
This is what I am trying:

print 'hello'
...
SyntaxError: invalid syntax



What could possibly be wrong?


You are using a Python v3 interpreter but a Python v2 tutorial.
Python v3 has several new features which are not backward compatible 
with v2.


Try

print( 'hello' )

You can either downgrade Python to v2 and follow your tutorial
or find a v3 tutorial. (If you can already program just use the 
official

one on the Python web site or if you are a new programmer you
might like to try mine :-)

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Can't even get hello to work???!!

2010-12-15 Thread Khalid Akram
Hello,

I'm using Python 3.1.3 on Windows XP (using Python Shell).

This is what I am trying:

print 'hello'

and I get:

SyntaxError: invalid syntax

What could possibly be wrong? I've tried it on the command line and even in 
hello.py - always get "SyntaxError".

Very confused.

Thanks
Khalid
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pyodbc/date values in MS Access

2010-12-15 Thread Peter Otten
Albert-Jan Roskam wrote:

> Hi,
> 
> I'm using pyodbc (Python 2.5) to insert records in an MS Access database.
> For security reasons, question marks should be used for string replacement
> [*]. The standard %s would make the code vulnerable to sql code injection.
> Problem is, string replacement in the Good Way somehow doesn't work when
> the values are dates. Below, snippet #1 does not work (Access says the
> inserted value is not consistent with the defined datatype), but #2 does.
> I tried various other ways (ie. DateValue, CDate, etc.) but none of them
> works. Is there a solution for this?
> 
> [*] see http://code.google.com/p/pyodbc/wiki/GettingStarted --> under
> 'Parameters'
> 
> ### 1
> sql = "INSERT INTO tblSomeTable (myDate) VALUES (?);"
> cursor.execute(sql, "#01/01/2010#")


(1) Try providing the date in ISO format "-mm-dd"

"2010-01-01"

or (even better if supported) as a date value

from datetime import date
date(2010, 1, 1)

(2) Wrap the value into a tuple which I think is required by the Python 
DBAPI.

cursor.execute(sql, ("2010-01-01",))
cursor.execute(sql, (date(2010, 1, 1),))

Peter

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Test Automation framework recommendation....

2010-12-15 Thread cajsdy
Thanks all here. I'm asked UML and UI tools for python in the other thread.
I'm looking for any suggestions to build test automation system, from
the test plan management, test execution, python scripting management.

Testplan: Testlink is a good example and I used it for the small
project, but it lacks of prompt support. Editing function is not that
good for word, ppt or xls. Silk havn't tried yet.

Test manager: managing the testing execution across the platform,
check out test plan and TCs from Testplan manager, control the test
process for distributed UUT, collect stats, upload results.

Script managenet: suvversion control,

Thanks

-- 
Sent from my mobile device
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pyodbc/date values in MS Access

2010-12-15 Thread Alan Gauld


"Albert-Jan Roskam"  wrote

dates. Below, snippet #1 does not work (Access says the inserted 
value is not

consistent with the defined datatype), but #2 does.


#2 is just normal string formatting so should always work.
But the cursor method is presumabnly doing some kind
of data type checking. What kind of data type does Access
normally expect for a date? Is it just a formatted string? Or
is there perhaps a numeric or datetime format that the
execute() might be expecting?


### 1
sql = "INSERT INTO tblSomeTable (myDate) VALUES (?);"
cursor.execute(sql, "#01/01/2010#")

### 2
sql = "INSERT INTO tblSomeTable (myDate) VALUES (%s);"
cursor.execute(sql % "#01/01/2010#")


HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any recommend of UML tool and UI design tool for python?

2010-12-15 Thread cajsdy
Thank you very much and thank you Alan.
Definitely I will take a look. I would prefer the paid version and I
will need the support.


On 12/12/10, Knacktus  wrote:
> Am 12.12.2010 19:16, schrieb Alan Gauld:
>>
>> "cajsdy"  wrote
>>> Either paid or free open source is fine.
>>> I'm creating automation frame work. Idealy it includes:
>>>
>>> test plan management,
>>> test manager across windows, unix, linux, solaris and other os.
>>> UML documentation for python scripts
>>> IDE tool for python on windoes and linux
>>> UI design tool for python(best is integrated with IDE)
>>
>> Eclipse would be the logical choice and there are a few free
>> UML editor plug-ins. I've tried one (can't recall the name) and
>> although a bit clunky compared to commercoal versions it
>> worked fine for small class and sequence diagrams.
>>
>> If you don't need full CASE modelling facilities someting
>> like a drawing tool such as Dia, Visio or Smartdraw might
>> suffice.
>>
>> If you want full CASE features (model validation, simulation,
>> code generation, reverse engineering fof diagrams from code, etc)
>> then I think you will need to pay - and probably quite a lot! I've
>> used both Borland Together and IBM RSA. I prefer Borland
>> although IBM produces prettier diagrams - but I found it a
>> lot less intuitive. to use. Both come as Eclipse plugins and
>> work with whatever version control tools Eclipse is using.
>>
>> There are other standalone UML tools too but it depends how
>> much of UML you want to use. If it's only a few basic class diagrams,
>> sequence diagrams and state diagrams then prettty much
>> anything will do. If you need to get into the more structural
>> aspects of UML (deployment diagrams, components, nested states,
>> activity charts, use-cases etc) then you might want to look at
>> paying out some money.
>>
>
> If you're willing to pay for a CASE tool then check out Enterprise
> Architect from http://sparxsystems.eu/
> For the massive features I think it's reasonable priced (professional
> edition for 165 Euro + VAT).
> UML-Source Code integration with Python ... I don't know if it really
> works. You would need to limit your code to pure OO-style. Such
> integration might work with Java and C# (Enterprise Architect can do
> this: Change code -> update UML and vice versa). Nevertheless.
> Enterprise Architect supports Python for reverse engineering.
>
> For designing UIs: You will need another tool. It depends on your GUI
> toolkit. If you're planning to use PyQt  as GUI toolkit (which I can
> only highly recommend) you're lucky. It has GUI designer, which is quite
> nice.
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

-- 
Sent from my mobile device
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] pyodbc/date values in MS Access

2010-12-15 Thread Albert-Jan Roskam
Hi,

I'm using pyodbc (Python 2.5) to insert records in an MS Access database. For 
security reasons, question marks should be used for string replacement [*]. The 
standard %s would make the code vulnerable to sql code injection. Problem is, 
string replacement in the Good Way somehow doesn't work when the values are 
dates. Below, snippet #1 does not work (Access says the inserted value is not 
consistent with the defined datatype), but #2 does. I tried various other ways 
(ie. DateValue, CDate, etc.) but none of them works. Is there a solution for 
this?

[*] see http://code.google.com/p/pyodbc/wiki/GettingStarted --> under 
'Parameters'

### 1
sql = "INSERT INTO tblSomeTable (myDate) VALUES (?);"
cursor.execute(sql, "#01/01/2010#")

### 2
sql = "INSERT INTO tblSomeTable (myDate) VALUES (%s);"
cursor.execute(sql % "#01/01/2010#")

 Cheers!!
Albert-Jan


~~
All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have 
the 
Romans ever done for us?
~~



  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] permutations?

2010-12-15 Thread Francesco Loffredo

On 14/12/2010, Brett Ritter and Dave Angel wrote:

Francesco Loffredo wrote:

...
mylist[:] = [x for x in mylist if x != "something"]
vs.
mylist = [x for x in mylist if x != "something"]
...


Brett:

mylist[:] is a slice of mylist (you know that).  If you ASSIGN it to
something, you'll get a copy of that slice, but if you modify it
you're modifying the list in place.

> ...

Dave:

...
On the left side of an assignment, a slice operator specifies which part of an 
existing object gets replaced by the right side. So
whenever you have a list that's referred to by more than one symbol, you may 
want to use a syntax like this.

The slice operator does a very different thing inside an expression (eg. on the 
right side of an assignment).


*THANK YOU BOTH!*
This is something I overlooked, and I'm very happy you made me understand it.


-
Nessun virus nel messaggio.
Controllato da AVG - www.avg.com
Versione: 10.0.1170 / Database dei virus: 426/3315 -  Data di rilascio: 
14/12/2010

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor