> Well... there's also Tix... but I don't know if you consider it as
> part of Tk or not.
>
> It's a bit complicated to get the feel from due to a lack of
explicit
> documentation for python, but once you get the tric about the
> Tcl->Python conversion, things get pretty smooth.
The Tcl-Python con
Hello Michael,
Thank you for your answer. Actually, my question is not specific to
interactive sessions. I've written a script that loads some modules, create
variables and show figures. What I would like to find, is a command for
clearing all the created variables and close all figures before beg
> # This program simulates the random branching and extinction of
linages.
> # It also mutates a series of characters representing morphology at
> each branch point
> # The program replicates the program first described by D.M. Raup
and
> S.G. Gould
> # 1974 Systematic Zoology 23: 305-322.
> # writ
> I'm not yet used to search in the cookbook... and I though such
> "basic" widget would have been implemented directly in Tk or Tix...
A bit of historic perspective. John Ousterhout invented TCl/Tk
to provide a control language for his electrical engineering
projects. Thus its focus is on GUIs
I think you may be looking for something that is not needed in Python or that you can easily do
another way.
If you are running a script from the command line, e.g.
> python myscript.py
then myscript.py will have a completely fresh runtime environment every time
you call it.
If you are running
Dear Kent,
Consider I'm working with an interactive session during which I have already
run some scripts. Those scripts have produced several variables, say, e.g.,
a and b. Now I execute myscript which also creates variables named a and b,
but with a possibly different type or content. To be sure
Hi,
After searching a while for a solution on the web and the archive of
this newgroups, I haven't found any answer to my questions... So here
are they...
Here is a command line session of Python on a Windows XP computer :
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
I'm still not sure why there is a problem. How are you running the scripts from the interactive
session? If you are importing the script, its variables will be in its own namespace. If you are
creating variables interactively yourself, your best bet is probably to just restart the
interpreter. (
I have created a file-like object out of a triple quoted string. I
was
wondering if there is a better way to implement readline than what I
have below? It just doesn't seem like a very good way to do this.
class _macroString(object):
def __init__(self,s):
self.macro=s
self.l
Chad Crabtree wrote:
>Is there a way to know what the path of the file is that imported a
>module? I've tried __file__ and playing with globals() but I can't
>seem
>to crack this.
>
There most be a way because the Tracebacks give us this info.
You want to take a look at the 'insp
Best: use the StringIO or cStringIO module instead, this is exactly what it is for. If you really
need len() you could maybe subclass StringIO to do what you want.
Next best: Use an iterator. Something like this (Warning! not tested!):
class _macroString(object):
def __init__(self,s):
You could use trackback.extract_stack() to get the current stack trace. If you inspect this from
within the imported module you could probably figure out who is importing you.
Do you really want the module where the import was done (the place where the import statement is)?
Or are you trying to
Ok I will investigate this. Thank you that is probably what I
needed.
I am trying to make a macro expander for python based on BOO's
facility
for this. I thought it was neat. In addition I think it would be
helpful to simulate adding keywords so that all these bloggers
talking
about proposed syn
Thank you KentBot. That was what I wanted.
Kent Johnson wrote:
> Best: use the StringIO or cStringIO module instead, this is exactly
> what it is for. If you really need len() you could maybe subclass
> StringIO to do what you want.
>
> Next best: Use an iterator. Something like this (Warning!
> class _macroString(object):
> def __init__(self,s):
> self.macro=s
> self.list=self.macro.split("\n")
> for n,v in enumerate(self.list):
> self.list[n]=v+'\n'
> def readline(self,n=[-1]):
> n[0]+=1
> return self.list[n[0]]
Why not just
On Fri, 14 Jan 2005, Chad Crabtree wrote:
> class _macroString(object):
> def __init__(self,s):
> self.macro=s
> self.list=self.macro.split("\n")
> for n,v in enumerate(self.list):
> self.list[n]=v+'\n'
Is this for loop a safe technique, where the list you
During the recent discussion on jython, a poster
brought up the good point that one should hide
variables and modules to indicate that they are
not for public use:
self.__for_internal_purposes = 5
__internal_stuff.py
"""
This module only makes sense for use with
the parent module.
"""
So one co
On Fri, 14 Jan 2005 09:30:46 +0100, Dimitri D'Or
<[EMAIL PROTECTED]> wrote:
> Thank you for your answer. Actually, my question is not specific to
> interactive sessions. I've written a script that loads some modules, create
> variables and show figures. What I would like to find, is a command for
Jacob S. wrote:
I assume that both you and Liam are using previous-er versions of python?
Now files are iterators by line and you can do this.
openFile = open("probe_pairs.txt","r")
indexesToRemove = []
for line in openFile:
# [...]
My version of Python isn't *that* old (IIRC this works since 2
On Fri, 14 Jan 2005, Chad Crabtree wrote:
> I have created a file-like object out of a triple quoted string. I was
> wondering if there is a better way to implement readline than what I
> have below? It just doesn't seem like a very good way to do this.
>
> class _macroString(object):
> def
On Fri, 14 Jan 2005, Terry Carroll wrote:
> > class _macroString(object):
> > def __init__(self,s):
> > self.macro=s
> > self.list=self.macro.split("\n")
> > for n,v in enumerate(self.list):
> > self.list[n]=v+'\n'
>
> Is this for loop a safe technique, wh
One final note to wrap things up. I posted a slightly cleaner version of
my code on the Python Cookbook, with a reference to the solutions of
Gonçalo and Danny via the tutor archives here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/363051
--
Email: singingxduck AT gmail DOT com
AIM
Terry Carroll wrote:
On Fri, 14 Jan 2005, Chad Crabtree wrote:
class _macroString(object):
def __init__(self,s):
self.macro=s
self.list=self.macro.split("\n")
for n,v in enumerate(self.list):
self.list[n]=v+'\n'
Is this for loop a safe technique, where the list
Hi group:
I have two lists a. 'my_report' and b. 'what'.
In list 'what', I want to take 6649 (element1:
164:623\t6649) and write to a new list ( although I
printed the result, my
intension is to list.append(result).
I took column 1 value of element 1 in what, which is
164:623 and checked in col
On Fri, 14 Jan 2005, kumar s wrote:
> >>>for i in range(len(what)):
> ele = split(what[i],'\t')
> cor1 = ele[0]
> for k in range(len(my_report)):
> cols = split(my_report[k],'\t')
> cor = cols[0]
> if cor1 == cor:
>
On Jan 14, 2005, at 23:28, kumar s wrote:
for i in range(len(what)):
ele = split(what[i],'\t')
cor1 = ele[0]
for k in range(len(my_report)):
cols = split(my_report[k],'\t')
cor = cols[0]
if cor1 == cor:
Danny Yoo wrote:
>Using the default parameter 'n' in the readline() method isn't safe:
all
>class instances will end up using the same 'n'. You may want to put
the
>current line number as part of an instance's state, since two
instances of
>a macroString should be able to keep track of their line
On Fri, 14 Jan 2005 08:47:49 -
"Alan Gauld" <[EMAIL PROTECTED]> wrote:
> Tk was written in the 80's so given
> its origins was not likely to have a table.
>
> Of course it would be nice if they added one now!!!
>
It looks like they are already working on it:
http://wiki.tcl.tk/12753
> > for n,v in enumerate(self.list):
> > self.list[n]=v+'\n'
>
>
> Is this for loop a safe technique, where the list you're enumerating
over
> in the for statement is the same as the one being updated in the
loop
> body? I always avoid things like that.
Its not changing the li
> My question is, how far should one take these guidlines?
My response is, as far as you need and no further.
In other words if it would actually cause problems
for clients to access those variables disguise them,
but otherwise trust your fellow programmers not to
be stupid.
Its the same princ
A few thoughts:
- you might want to make a configuration object that you can pass around, this is probably better
than passing around an instance of the main Burn class.
- typical Python style is *not* to define setter and getter functions. If you need to mediate
attribute access you can do it la
> I'm am bored and people are not asking enough questions/answering
them to
> keep my mind busy. Is there any other mailing list that I can
subscribe to
> like this one that lets anyone ask and answer questions?
I assume you'vve checked the Python newsgroup?
It should be busy enough for anyone! Of
This is my first attempt at programing and my first program sort of did work
hear is the program and if any one can tell me what i did wrong or forgot i
would appreciate it
a = input("Type in the Grose: ")
b = input("type in the Miles: ")
print "a * 0.74 / b is" a*0.74/b
as you can see it sh
Brian van den Broek wrote:
2) To get around that, and be more efficient with matricies with many
empty cells:
.>>> my_matrix_as_dict = {(1,1):4, (1,2):6, (1,3):8,
(2,1):56, (2,3):12,
(3,1):3, (3,2):3}
.>>> my_matrix_as_dict[(3,1)]
3
.>>> my_matrix_as_dic
> I have a simple list:> ['a', 'apple', 'b', 'boy', 'c', 'cat']> I want to create a dictionary:> dict = {'a':'apple', 'b':'boy', 'c':'cat'}
From the Quick and Dirty Department: If you have Python version 2.3 or later, you can use 'itertools' to unflatten the list in a very concise manner. Here i
On Fri, 14 Jan 2005, Terry Carroll wrote:
> Is this for loop a safe technique, where the list you're enumerating over
> in the for statement is the same as the one being updated in the loop
> body?
Rather than cluttering the list by making three replies, I'd just like to
thank Danny, Alan and J
On Jan 10, 2005, at 14:31, john stanley wrote:
This is my first attempt at programing and my first program sort of
did work hear is the program and if any one can tell me what i did
wrong or forgot i would appreciate it
a = input("Type in the Grose: ")
b = input("type in the Miles: ")
print "a
Hi Danny:
Thank you for your suggestion. I tried creating a
dictionary of 'what' list and searched keys with
has_key method and it is pretty fast.
Thanks again. following is the piece of code.
K
>>> cors = []
>>> intr = []
>>> for i in range(len(what)):
ele = split(what[i],'\t')
Does anyone know of any online resource that explains how to interface to
Microsoft Access via Python, where the intended audience is someone who
knows Python, but not the Microsoft innards?
I've found http://starship.python.net/crew/bwilk/access.html (which
doesn't work for me, and presumably
A couple of minutes of googling for 'python odbc' finds the ODBC driver that comes with win32all. It
seems to have a fairly simple interface. The download from this page has an example:
http://py.vaults.ca/apyllo2.py/D906422565
HTH
Kent
Terry Carroll wrote:
Does anyone know of any online resourc
Hello all,
I'm trying to use Python to start the dos-box ("cmd.exe") and be able to
call commands on it and receive output from it. However, none of the
documentation for popen and spawn cover this . . . Any help would be
appreciated.
Thanks in advance,
Orri
--
Email: singingxduck AT gmail DOT
On Fri, 14 Jan 2005, Kent Johnson wrote:
> A couple of minutes of googling for 'python odbc' finds the ODBC driver
> that comes with win32all. It seems to have a fairly simple interface.
> The download from this page has an example:
> http://py.vaults.ca/apyllo2.py/D906422565
Thanks, Kent. I'm
42 matches
Mail list logo