Mr. Gauld is referring to!! I searched python.org and alan-g.me.uk.
Does anyone have a link?
I posted a link to the Python howto and my tutorial is at alan-g.me.uk
You will find it on the contents frame under Regular Expressions...
Its in the Advanced Topics section.
--
Alan Gauld
Author of
"Emile van Sebille" wrote in message
news:gtnrtf$pi...@ger.gmane.org...
On 5/4/2009 2:50 PM bob gailer said...
PDavid wrote:
Dear list,
in different books I come across different syntax for dealing with
files. It seems that open(filename, 'r') and file(filename, 'r') are
used interchangeably,
;t think why unless you have a very strange
parser at the other end). In that case I think you do need to insert
the \x characters.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python
what the value of that is
over struct or int? Can anyone enlighten me about why I'd ever want to
use this?
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
"Dan Liang" wrote
And I put together the code below based on your suggestions, with minor
changes and it does work.
Good, now your question is?
-Begin code
#!usr/bin/python
tags = {
'noun-prop': 'noun_prop null null'.split(),
'case_def_gen': 'case_d
Please use a sensible subject and don;t reporst the whole digest.
"Dan Liang" wrote in message
Thank you for your help. I have been working on the file, but I still
have a
problem doing what I wanted. As a reminder,
Can you tell us what exactly the problem is? It's easier than us
trying to
My turn to apologise for premature sending of email...
For some reason I didn't notice the section of mail after
the code snippet!
Alan G
"Dan Liang" wrote in message
Now since I have to work on different data format as follows:
-Begin data
w1\t
ut if I had closed the file and
then did this: res = open('c:/myscripts/simple2.ttt').read(), it would
have worked.
Thats right because you now open the file for reading,
therefore the cursor is repositioned at he start of the file and
the mode is set correctly.
HTH,
--
Alan G
ourse now I am stuck on
how to apply the delimiter and search function to the items in the
list..?
Either call your function on each file as you find it -- no need
for a list, or...
for f in allfiles:
myFunction(f)
Provided your function can take the filename as a parameter
either met
"wesley chun" wrote
does anyone have the idiom for the above isinstance() check for 3.x?
Test for io.stream (or a derivative) - which is what open now returns.
files are no more...
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.pyth
x27;m not sure citing anything Java does is a good rationale in
Python! Hopefully we can do rather better than the horrors
of Java :-)
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python
os *= bufsize
f.seek(pos)
lines = f.read().split(linesep)
f.close()
return lines[-2:]
def tail_it(fname, bufsize=8192, linesep=os.linesep):
while True:
new_time = os.stat(tail_fname).st_mtime
if new_time > old_time:
time.sleep(sec_to_wait)
"Alan Gauld" wrote
f.seek(0, 2)
pos, tailsize = divmod(f.tell(), bufsize)
if tailsize == 0:
pos = max(0, pos-1)
pos *= bufsize
f.seek(pos)
I got confused trying to work out exactly what this was doing.
pos is initially the numbe
led explicitly - it is called implicitly by the file going out
of scope at the end of the function - and its good practice to explicitly
close the file
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor mail
books. I would be
interested in a review if anyone reads it.
http://www.pragprog.com/titles/gwpy/practical-programming
Based on the excerpt that I read online it looks pretty good.
I couldn't see anything to carp about at all. Very impressive.
--
Alan Gauld
Author of the Learn to P
cessing the registry.
How you do it over the LAN and how you disable the keyboard
I'll leave as an exercise for your investigation!
One other option is to look into using WSH via the pythonwin
or ctypes API.
--
Alan Gauld
Author of the Learn to Program web sit
/NonProgrammers
http://docs.python.org/tutorial/
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
- Original Message
> From: Christopher Barkley
> To: Alan Gauld
> Sent: Friday, 8 May, 2009 5:09:25 AM
> Subject: Re: [Tutor] Need help with reg
values too (via choice) but again
catching anything other than X,Y,Z is just as easy using an
else clause in your case.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
f stftp.listdir(). Where local_path
is wherever you store the files on the local mnachine that you
want to transfer.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ds):
print word[1]
You should probably be able to do the first for loop as a list
comprehension, but I can't think of how to get the split() call
embedded into it right now!
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
"robert mcquirt" wrote
import os
os.system('file -b /home/robert/linuxlogotag')
This also works fine. The problem is that when I try to replace
the hard coded path/name with a string variable for looping,
the results are not the same as the shell's.
import os, glob
path = '/home/robert
may be wrong. But at least
you need to pass '/' as your path.
sftp.get(os.path.join(dir_path, f), f)
dir_path = '/'
sftp.get(dir_path, f)
If that doesn't work put the join back in...
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
dule. This just sends the mail directly to the mail server
without going near Outlook.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
e a python script that runs in the background
(a service or daemon) and launces a thread at periodic intrevals.
But I'd go with cron/at as the simplest solution.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
r']
Traceback!!!
d.get('Error',False)
False
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
alking to the User' topic of my tutorial.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
"Matt Herzog" wrote
I sure wish I could for the last line go,
shutil.move("src", "dest")
That would be cool.
So why don't you?
What is the problem?
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
__
x27; : 'Spain'}]
populating your dictionary becomes a matter of extracting the data:
SELECT DATE, LOCATION FROM DATA WHERE ID = key
SQLite has the advantage that the atabase is a single file and
it is portable across platforms provided they have Sqlite installed.
And its part of the P
option 1 because
its explicit and therefore clear what exactly I'm calling.
Or should I mix both these approaches?
No, do not mix them, that way leads to madness IMHO! :-)
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_
th a naming convention
such as the one above but we still need to do a fair bit of explicit
coding. Lisp does it automagically. (You might be able to do
something like it in Python using decorators....h.)
HTH,
--
Alan Gauld
Author of the Learn to Program we
ly use the superclass functionality
and add a little bit of local processing for any attributes in the
child class.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.
ry overridden method
then I'd say that was bad design.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ase but its not really OO programming, its
just programming with objects! The hysteria over abuse of inheritance
has kind of thrown the baby out with the bathwater IMHO!
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
tml parser such as Beautiful Soup
that aspect may be worth converting to Python.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
this way subclass
methods play a role in AUGMENTING THE BEHAVIOUR
DEFINED IN THE SUPERCLASS.
- end quote --
(caps mine)
So at least two well known OOP authorities recognise that such
is common practice.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk
reliable and saves you a lot of
extra work checking whether the src and dst are on the same
filesystem etc.
You should justy be abloe to use shutil.move()
What is the probnlem with this (apart from Kent's point that
you were not passing filenames originally!)
--
Alan Gauld
Author of the
ar/baz/spam
Another way of doing the same thing would be with join:
'/'.join([src,fnames])
or for platform independance:
os.sep.join([src,fnames])
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
__
ur
but is very common in practice.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
1st field and 3rd field?
And what do you mean by *both* rows? You have 3 rows?
It is not clear what exactly you are asking for.
It is also not clear what you don't understand. Can you give us
an example of what you have done and explain how it fails?
--
Alan Gauld
Author of the Learn to P
"Jabin Jezreel" wrote
What is the idiomatic way to write the right side of
(a, b) = (l[0:2], l[2:])
?
(not worried about the parens, just the splitting of the sequence)
I think you have it.
I'm not aware of any better way.
--
Alan Gauld
Author of the Learn to Progra
"Jacob Mansfield" wrote
hi everyone, I'm a bit new here but i was wondering if someone could
check
some of my code, it's not doing quite what it's meant to.
That's not very specific. What is it meant to do?
What does it actually do? Do you get any error messages?
If so post them in the emai
rd',1,2,3]
sorted(L, cmp=comp)
['word', 'picture', 1, 2, 3, 3, 4]
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
t;ts" case above?
That I don't know. The asterisk notation can only be used
for unpacking function arguments, but why it is limited to
that role I don't know...?
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
__
p you need to send the complete message for each error.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
bprocess.
It is slightly more complex than popen or commands but
it is future proof (for now at least!)
Simple example:
import subprocess
lsout = subprocess.Popen('ls -ls', shell=True,
stdout=subprocess.PIPE).stdout
print lsout.read()
--
Alan Gauld
Author of the Learn to Progr
x or
Python.
In *nix use touch and in Python use
open(foo,'w').close()
When working in Python, every time you are tempted to call
a unix command via os.system/popen etc check to see if
there is a way to do it from within python fiorst.
There often is.
HTH,
--
Alan Gauld
Author
issues).
But a lot will depend on transaction volumes etc. If
you never, or rarely, have concurrent accesses then using
a text file might work. Or you could do it all in memory
via a long running process and a queue. But if volumes
are (or could become) high or bursty I'd go for the SQL rou
d? Did you index the key columns?
- Directory path traversal - have you moved the location of
any key files? Either the executables/scriopts or the data?
Just some ideas before you resort to profiling.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
htt
"Strax-Haber, Matthew (LARC-D320)" wrote
My class sub-types dict. In __init__, there is a call to
self.update(pickle.load()). For some reason, this triggers
__del__. Why?
A pure guess, but maybe the pickle load creates a new instance which
replaces the original which then gets garbage col
del__(self):
try:
os.remove(self.lockname)
except: pass
Of course the question of whether using disk storage to indicate
object lifetime is a good design pattern is another issue altogether!
--
Alan Gauld
Author of the Learn to Program web site
htt
find any you can loop
over the instances using replace() or sub() to change
them. The translate module might even let you do all
changes in one go.
That should be faster I think.
HTH
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
s probably your best bet. It includes a GUI builder and has strong links
to databases.
http://dabodev.com/
Caveat: I've only read the web pages, not used it! But it has had some
good reviews on this list before.
--
Alan Gauld
Author of the Learn to Program web site
http://w
T'
>>> funcs[2]('THIS IS A SIMPLE TEST')
'this is a simple test'
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
"Andy Cheesman" wrote
Is there a Method for wrapping delphi and/or pascal code into python like
SWIG?
I've googled to no avail, Can anyone help me?
Try this:
http://membres.lycos.fr/marat/delphi/python.htm
Alan G
___
Tutor maillist - Tutor@
> understand exactly what you are saying and what you are advocating.
> The 'dictionary of functions' is the 'best' approach because of simplicity
> and because it minimizes chances or errors.
Correct. Maintaining synch of indexes between two arrays of data items
is always going to be a risky b
"Marc Tompkins" wrote
Is there a Method for wrapping delphi and/or pascal code into python
like
SWIG?
http://membres.lycos.fr/marat/delphi/python.htm
That's a package to let you embed Python in Delphi; the OP wants to go
the
other direction.
So it is, I didn't read the OP question clo
hon v3 the even more powerful new formatting
features there)
self.menu[5]=("Transaction History",self.display_transactions)
Can I use the numbers 1,2,3,4 as a way to return the history?
I don;t really understand what you mean by this bit?
--
Alan Gauld
Author of the Learn to Program web si
tely not getting the
point?
It's up to you to know where the file is and tell Python.
You might try this to find out where Python is looking for
the file by default.
import os
print os.getcwd()
Which prints what Python considers the Current Working Directory.
You will find a lot more on this
y have to set up some paths in Eclipe's
preferences.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
;t do it in advance just add to it as you need to.
On the other hand, any code I might write would be difficult
for others to use.
If you stick to the a standard Python package tools it should be fine.
Not just on Linux but on any other OS too.
--
Alan Gauld
Author o
exactly what kind of data you are dealing with.
What do you guys recommend? I want to search the file for certain hex
value
and get the byte offset within the file.
It might help if you posted some code too. And tell us what
happens when you run it, and why that was not what you wanted to happe
"prasad rao" wrote
for x in dir(sys):
?? if sys.x is callable:
Even if you use the other suggestions to prove its
callable that doesn't mean you can do this:
print sys.x()
If the callable takes parameters then this will fail.
You need to know quite a lot more about what you
are
"M Tramp" wrote
the packages I needed. Fink appeared to be installing them fine with
little
interaction from me.
I ran Eclipse again, but it still burps on:
import gtk
Have you installed pygtk?
You need both pygtk and gtk.
The former uses the latter.
Alan G
___
"xbmuncher" wrote
I ran this in IDLE:
t = 'hi'
print t
SyntaxError: invalid syntax (, line 1)
I've also tried this as sample.py :
import string
text = 'hello world'
print text
It gives me a syntax error on "print text" line
Looks like you are using Python v3.
Most tutorials are stil
"M Tramp" wrote
You need both pygtk and gtk.
The former uses the latter.
Yes. It is. I went back and installed more.
Still I get the error: "No module named gtk"
So I'm back to -- or nearly so -- my original question.
Where on my hard drive should these libraries reside?
I'm suspect
hing happens.
Don't worry too much, just enter the code and run it.
If you do want to use the >>> prompt to experiment
use an OS command line window rather than an IDE.
In pratice when working with Tkinter I've leaned not to trust
any IDE but just use it as a text editor. I type
confusing situation with mutable
types that Dave referred to. If the function changes a parameter
value and it is mutable then the original object is changed.
If it is immutable a new object is assigned to the parameters
name.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http:
gt;" + lastName +
", " + firstName + ""
But IMHO its much easier to use string formatting:
aVar = 'http://users.example.com/~%s>%s,%s' %(
userName,lastName,firstName)
Its also more efficient.
However in practice you don;t need to store it as a variab
"Gregory Morton" wrote
Looking in the directory for Python, I see no real sign
of IDLE anywhere in it.
Look at the properties of the start menu item.
It should show the shortcut points to something like:
C:\Python25\Lib\idlelib\idle.pyw
Is there any logic behind why I can't access IDLE wi
> Strangely, the shortcut properties don't show the target. On my
> Windows XP system, the properties just show
> Target type: Application
> Target location: (blank)
> Target: Python 2.6.1
>
> Kent
Bizarre! My XP box says
Target type: PYW File
Target location: idlelib
Target: C:\Python25\Lib
f examples.
Finally look at the ActiveState web site for Python recipes.
Lots of good ideas there.
Of course what constitutes good code is somewhat subjective but
the library and recipes are virtually all pretty good code IMHO.
--
Alan Gauld
Author of the Learn to Program web site
http://www.al
"Gregory Morton" wrote
I've been reading this Python 3.0.1
tutorial(http://docs.python.org/3.0/tutorial/controlflow.html),
Looks like a bug in the tutorial! In Python 3 you cannot just print a range
it is now a generator. Notice that in the tutorial the range() calls are
not
shown at the >
. But since
the supplier is chosen from external factors the Flavor doesn't
need to know about its supplier. And the supplier only needs
to know about how to query a flavour.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
__
iously but those that do seem to find it works OK.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
"vince spicer" wrote
import commands
output = commands.getout("ls -lah")
There are many ways to do this in Python including
os.popen, commands and subprocess.
But subprocess is the "officially correct" version, the others
are deprecated and could theoretically disappear in a future
ver
en go back to the top for the next number to test.
You will find more about loops in the Loops topic
of my tutorial.
HTH
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
you
will have to do quite a lot of programming to make it work, probably
defining your own custom widget. That's a lot of work.
Your best bet is to ask the question on the various toolkit specific
forums and mailing lists since there will likely be people who have
done it already.
HTH,
--
Alan
s[1]=dexterity=+change
points=points-change
if allot=='str':
change=int(raw_input('How many points do you wish to allot? '))
attributes[3]=strength=+change
And this gets even more messy.
Again think how it would look with a dictionary...
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ans there is an error
so turning the messages off won't help your program to run,
you just won't get any clues as to why its not working!
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
arger programs than this.
But as an example of using a class its nearly OK, just the
tweak of the return value to think about - and that applies
to the function version too!
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_
t;HEX:%s" % hex(-29)
'HEX:-0x1d'
And all is as expected.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
"xbmuncher" wrote
I'd like to use notepad++ to execute the scripts I edit, is there a way
to
solve this problem?
Thats really a question for Notepad++ users!
You might be able to use a shortcut to Notepad++ and change
that Startup folder to be the one where your python scripts live?
Beyond
e location of the problem! - is in the earlier lines.
However taking a wild guess - are you using Python v3?
print "-- beginning to convert XLS to CSV --"
If so print is now a function so you need to surround the string
with ()
But if you are not using v3, then please s
r a number!'
You could put the whole thing in a while loop so the error gets
printed but the user has a chance to corect it.
def get_inputs():
while True:
try:
# blah blah
return . # breaks from the while loop
except ValueError,
thons help() function.
Change logs are mostly kept in the version control tool, but
you can access the svn repository onthe web site to see
the history etc.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tuto
quot; part of the
copy on the result.
As a minimum subclasses should adhere to the parent interface.
Unfortunately because Python only allows a single constructor
that can be a limiting factor :-(
( Multiple constructors (or factory methods) is one feature I
would like to see added to Python! )
"W W" wrote
( Multiple constructors (or factory methods) is one feature I would
like
to see added to Python! )
Wouldn't it be possible to create sort of a... bastardization? i.e.
def __init__(self, *args):
if len(args) == 0:
#do something
if len(args) == 1:
#do somethin
le(fn, cnt)
But its two lines not one... :-(
And so far as I know it has not been PEPd although I'm sure it has
been discussed.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.o
"Kent Johnson" wrote
But its two lines not one... :-(
Why not this?
class C:
def __init__(self): pass
@staticmethod
def LoadFromFile(fname, count):
c = C()
# init c from the file
return c
and similar for Create(). Client code is one line:
c = C.LoadFromFile(fn, cnt)
Kent
"Kent Johnson" wrote
> We can fake the Delphi style by using a default constructor and then
> just
> calling the "constructors" after initialisation:
> But its two lines not one... :-(
Why not this?
class C:
def __init__(self): pass
@staticmethod
def LoadFromFile(fname, count):
c
"Allen Fowler" wrote
Are there any utilities to help "spell check" source code? (Docstrings,
etc)
I used to have an emacvs script that could do it for C/C++ using
the vanilla Unix spell program. Unfiortunately I can't remember its name
but a hunt around the e,macs web sites might throw up a
> From: "wormina...@gmail.com"
> To: Alan Gauld
> Sent: Tuesday, 2 June, 2009 1:09:39 AM
> Subject: Re: [Tutor] Spell checking source code?
>
> In vim,
>
> :set spell
> :set nospell
> :help spell
But that will check the whole file. The OP only wanted
ally some flags.
Please read the documentation then ask some specific questions
about what you don't understand. The Text widget is immensley powerful
so you need to spend some time studying it to get the best out of it.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-
lues. Certainly IDLE,
Pythonwin and Eclipse/PyDev can all do that.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
entry2=Entry(frame3,relief='sunken',border=1)
entry2.pack(side='left',fill='both')
lable2=Label(frame3,text='modifide time',border=1)
lable2.pack(side='left',fill='both')
entry3=Entry(frame3,relief='sunken',border=1)
entry
"W W" wrote
Do you (or sombody else) know how to get ipython working with Python 2.6
(you know, the Python release, which has that new turtle module ;-) )
doesn't install on my Windows box... other than that I've got no
experience
with it
I thought the new turtle module could be made to
f r[0] in d: d[r[0]].append(r[2])
... else: d[r[0]] = [r[0],r[2]]
...
new = [v for k,v in d.items()]
new
[['F1', 0.9, 0.5], ['f2', 0.6999]]
There may be a more elegant way to handle the if/else
but its too early to think of one :-)
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
en directly, it does not write onto the stdout stream. (I think if you
switch to ex mode it does use stdout - but I may be wrong about that!)
If vim is just an unfortunate example then it might be possible but I think
we need to know a bit more about what exactly you are trying to do.
--
Alan Gauld
If vim is just an unfortunate example then it might be possible but I think
we need to know a bit more about what exactly you are trying to do.
> It's actually a stand alone program; which opens up a $EDITOR; an
> then prints to stdout the results of some db munging. ...
> what I'm wanting to g
ach class?
Until we know what the cklasses are for its hard to know what you
want improved...
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
1001 - 1100 of 9948 matches
Mail list logo