473,473 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A Tcl/Tk programmer learns Python--any advice?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm a Tcl/Tk developer who has been dabbling with Python for some time,
but had not seen a compelling reason to really learn the language.
Programming in Tkinter seemed redundant to me since I already have
direct access to that toolkit via Tcl, and the other Python GUI toolkits
I tried--PyQt and wxPython--were frustrating with their learning curve.

Well, I have finally found a good reason to learn Python in more depth:
the language already directly supports things that I want to do in my
next project (specifically the Carbon modules in Mac OS X), whereas Tcl
would require a lot of extending in C before I could get started. I've
decided that it's probably less work to learn the Python way of doing
things, and if I stick with Tkinter, then the learning curve will be
reduced.

I've gotten all the approropriate resources for learning Python (docs,
books, tutorials), so my question is this: are there any "gotchas" that
Tcl programmers often encounter in learning Python? I'm thinking
specifically about habits that may require "unlearning," for instance,
such as grokking object orientation (Tcl procedures are now embedded
deep in my brain).

Any advice, particularly from other programmers with a lot of experience
in Tcl, is appreciated.

- --
Cheers,

Kevin Walzer, PhD
WordTech Software - "Tame the Terminal"
http://www.wordtech-software.com
sw at wordtech-software.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDb3sLJmdQs+6YVcoRAq5xAJoCbDYeMO58yRPqid4K5W Td1+PbcgCbBATL
0UppdVmVdcb+AfFUIsvrdrY=
=Hk8w
-----END PGP SIGNATURE-----
Nov 7 '05 #1
14 1629
In article <ef***************************@FUSE.NET>,
Kevin Walzer <sw@wordtech-software.com> wrote:
Nov 7 '05 #2
"Kevin Walzer" <sw@wordtech-software.com> wrote:
I've gotten all the approropriate resources for learning Python (docs,
books, tutorials), so my question is this: are there any "gotchas" that
Tcl programmers often encounter in learning Python? I'm thinking
specifically about habits that may require "unlearning," for instance,
such as grokking object orientation (Tcl procedures are now embedded
deep in my brain).


I don't know Tcl, but python doesn't force you to be OO; you can write
100% procedural code if you want to. OTOH, you'll probably need other
people's code that is OO, so at the very least you'll have to be able
to read and use it. Fortunately, using an existing OO module/library is
much easier than designing and writing it, so you can get away with it
with little effort.

George

Nov 7 '05 #3
In article <ef***************************@FUSE.NET>,
Kevin Walzer <sw@wordtech-software.com> wrote:
I'm a Tcl/Tk developer who has been dabbling with Python for some time,...
Well, I have finally found a good reason to learn Python in more depth:...

Any advice, particularly from other programmers with a lot of experience
in Tcl, is appreciated.


In Tkinter you don't name widgets to specify their hierarchy; instead
when you create a new widget you specify it's parent. A tk name does get
generated for you, but you'll never need it.

You can set and get properties on Tkinter widgets using dictionary
notation:
curr_value = wdg["property_name"]
wdg["property_name"] = new_value
this is very convenient if you don't want to set a lot of properties at
once.

Grid in Tkinter has less useful defaults than in tk. You should probably
specify row and column when using Tkinter's gridder.

If you try to mix tk and Tkinter, beware of Tkinter objects that clean
up after themselves. For instance a tkFont.Font object represents a
named font in tk, but if you lose all references to it in python, the
named font in tk is destroyed.

Features of Python that are well integrated and well worth using include:
- objects
- collection classes (including list, dict and set)
- exception handling
- default arguments for functions

tcl is a unusual in its desire to parse every string as a command. It
has plusses and minuses, but in any case, you'll have to learn to do
without (as you would when switching to almost any other language).

-- Russell
Nov 8 '05 #4
In article <ro*************************@gnus01.u.washington.e du>,
Russell E. Owen <ro***@cesmail.net> wrote:
Nov 8 '05 #5
Ah, another one leaves the fold... : \

Robert

Nov 9 '05 #6
Even though its for any (not just Tcl) experienced programmer, and even
though you've got all the appropriate resources, I'll mention that you
should get a lot out of the book Dive Into Python, at
http://www.diveintopython.org/

Nov 9 '05 #7
In article <11*********************@g47g2000cwa.googlegroups. com>,
si*****@gmail.com says...
Ah, another one leaves the fold... : \


I think I saw somebody say about OO in Python: "It's there, but you
don't have to use it." Every time somebody wants OO in the core of tcl,
he is asked: "Why do you want it?"

If OO was as easy in Tcl as in Python, there would be no real reason to
switch in my opinion. (And maybe simpler namespaces and passing of lists
to functions, we all love the uplevel and upvar commands, don't we?)
--
Svenn
Nov 9 '05 #8

Svenn Are Bjerkem wrote:
In article <11*********************@g47g2000cwa.googlegroups. com>,
si*****@gmail.com says...
Ah, another one leaves the fold... : \


I think I saw somebody say about OO in Python: "It's there, but you
don't have to use it." Every time somebody wants OO in the core of tcl,
he is asked: "Why do you want it?"

If OO was as easy in Tcl as in Python, there would be no real reason to
switch in my opinion. (And maybe simpler namespaces and passing of lists
to functions, we all love the uplevel and upvar commands, don't we?)
--
Svenn


That is a misconception. There are several really good packages for OO
in Tcl. XOTcl, [incr] Tcl, and my favorite Snit.

On top of that there is currently being added OO to the core of Tcl as
well. That should all be integrated in when 8.5 comes out in the
spring.

Tk is getting a native L&F uplift as well.

However, I think it is more perception than function now.

Robert

Nov 9 '05 #9
In article <11**********************@z14g2000cwz.googlegroups .com>,
si*****@gmail.com says...
That is a misconception. There are several really good packages for OO
in Tcl. XOTcl, [incr] Tcl, and my favorite Snit.
None of which are core functions. As I stated, there is currently no OO
in the core like in python.

On top of that there is currently being added OO to the core of Tcl as
well. That should all be integrated in when 8.5 comes out in the
spring.
Which once again is a confirmation that my statement was correct about
missing OO in the current core.

Tk is getting a native L&F uplift as well.


This is just eye candy, Tkinter was long time GUI for python and no
reason to move from Tcl to python. Today you can choose about any
toolkit for python and Tcl still has rusty old Tk.

It is all a question what you want to solve and how you want to solve
it. Tcl/Tk was once the best way to write "throwaway" applications with
a GUI, and it still is, in my opinion, but then I know too little python
so far.

(and python can not do "set result [exec someprog << $input]" as far as
I know)

--
Svenn
Nov 10 '05 #10
Why does there need to be OO "in the core"? That is one thing I have
never understood. If you want OO, get a package that fits your style of
OO and "package require" you are off and running. That probably isn't
what you would be looking at Tcl for anyway.

I agree about Tk and I am actually talking with someone about adding a
wxTcl to the mix as well. I think wx is a much better toolkit.
It is all a question what you want to solve and how you want to solve
it.


That is so true.

Robert

Nov 10 '05 #11
On 2005-11-10, Svenn Are Bjerkem <sv*******@bjerkem.de> wrote:
(and python can not do "set result [exec someprog << $input]"
as far as I know)


I don't remember Tcl very well, but doesn't this do the same
thing?

result = os.popen('someprog','r').read()

--
Grant Edwards grante Yow! I have a VISION! It's
at a RANCID double-FISHWICH on
visi.com an ENRICHED BUN!!
Nov 10 '05 #12
Svenn Are Bjerkem wrote:
(and python can not do "set result [exec someprog << $input]" as far as
I know)


execute a pro

import subprocess

</F>

Nov 10 '05 #13
In article <11**********************@z14g2000cwz.googlegroups .com>,
si*****@gmail.com says...
Why does there need to be OO "in the core"? That is one thing I have
never understood. If you want OO, get a package that fits your style of
OO and "package require" you are off and running. That probably isn't
what you would be looking at Tcl for anyway.


We are now starting the normal discussion that tcl'ers have about OO in
the core, and thus just whipping up old dirt. For people like me who has
invested a lot of time to learn a language that I use to solve everyday
problems, it would be nice if I could continue to use that same language
to do more advanced stuff. Loading packages is a work-around in my eyes,
and I am actually following your advice of looking at a different
language, that's why I am here in the first place. There is no need to
wear rubber boots at a party if you can wear sneakers.

--
Svenn
Nov 11 '05 #14
"Robert Hicks" <si*****@gmail.com> wrote:
Why does there need to be OO "in the core"? That is one thing I have
never understood. If you want OO, get a package that fits your style of
OO and "package require" you are off and running. That probably isn't
what you would be looking at Tcl for anyway.


The problem there is that you end up with N different implementations.
They each have roughly similar capabilities, but are different enough in
the details that somebody who knows one will have trouble maintaining code
using another. Each one probably has some features which make it better
than the others in some ways, and some ugly warts too. None is superior
enough in all respects to become dominant.

It's just like C++ went through with strings and containers before STL came
along. Everybody rolled their own, or bought one of the several
commercially available libraries. That meant you could be an expert at C++
and still have a steep learning curve when coming into a new project.
Nov 11 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Martin Piper | last post by:
Hi all. I've recently landed myself the position of trainee C++ programmer which I'm extremely pleased about, but also nervous. According to the feedback from the interview, I have a good...
3
by: Oasis | last post by:
Hello, I'm new to c#. I have situation where I want to execute a number of insert statements that differ only in a few dynamic values. When I was a Java programmer, I would do this with a...
9
by: Malcolm | last post by:
After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter. The question is, how is it most useful? At the moment I have a function int basic(const char *script,...
9
by: Rafael Charnovscki | last post by:
I can comprehend the basics of that subject (pointers, memory allocation, heap, stack etc), but I am interested to have references with more details. I have some C/C++ books and lots of URLs...
3
by: OJLP | last post by:
Hi. I am about to embark on C# learning. I have had limited VB experience. Can anyone offer any advice as to some good books / courses to attend, for a newbie to get the basics as quick as...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
1
by: rsaikamesh | last post by:
Hi Friends, This need some advice from you. I was working on ASP.NET with c# programming 7 month back. Then i was asked to work in c++ with Linux. I have been just creating User Interfaces for...
9
by: Phper | last post by:
Can anyone give me advice on how to learn PHP?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.