t kind
of window/screen)?
There are a dozen possible ways to "display a picture"
depending on what you specifically want.
--
Alan G
Author of the Learn to Program web site
[2]http://www.alan-g.me.uk/
[3]http://www.amazon.com/author/alan_gauld
because I was the tech editor but the book
Professional Python has a nice chapter on decorators.
HTH
--
Alan G
Author of the Learn to Program web site
[3]http://www.alan-g.me.uk/
[4]http://www.amazon.co
Apologies for top posting I blame the tablet!
Malcolm, don't make us guess, show us how you put the quotes in and the
error messages (in full).
Alan g.
Sent from my Fonepad
Malcolm Boone <oasis.bo...@gmail.com> wrote:
So you are saying the right side
as possible...)
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
tuples but it should work for either)
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
can't use import because then Python would try to parse the HTML
from the
imported file.
I thought PHP also parsed any html rendered through an included
file?
It does but PHP 'understands' HTML - or more specifically ignores it!
Alan G
(as strings) in which case a mapping has to
exist somewhere already.
I'm curious as to how you are addressing those issues?
Is this something that only developers will be using?
How will the user know what names are possible?
Alan G.
___
Tutor maillist
(or class based)
list of instances and write a del() method that removes
itself.
Then a class method can iterate that instance list
doing whatever it needs to do...
HTH,
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman
.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
quagmire. However given the
nature of the code Nathan is producing and the prices
he's charging I doubt if we are going to be contesting
our share of his millions! It seems pretty harmless at
this level.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
in the file handling
topic of my tutorial.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
of string formatting.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
interests to maximise their own input.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
and the older 16 bit Win 3 API.
Why 'thunk' I do not know but the term seems to have stuck long
after everyone stopped using Win32 thunks...
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist
-liner did!)
then better to be slowly correct than rapidly wrong... :-)
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
is set up as a default
parameter value in the lambda definition.
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
If you are a Unix head using windows run to the cygwin site
and install the whole caboodle.
You'll think you are back in Unix land...
If thats impossible them open a DOS boc (aka Command Prompt)
and type
python foo.py
Or even just double click the file in Windows explorer...
Alan G
Cygwin (http://www.cygwin.com/) It gives you a bash shell in
Windows.
Actually it gives you a whole Unix environment including X Windows
and over 500 unix command line tools plus GNU C, sendmail, etc etc...
Alan G.
___
Tutor maillist - Tutor
for f, x in bunch_of_files, range(z):
...
Or maybe can I access the number of times the
loop has run?
I think thats what enumerate does...
for x,y in enumerate([1,3,5]):
... print x,y
...
0 1
1 3
2 5
Yep, looks like what you need.
Alan G
Author of the Learn to Program web tutor
the intent even more explicit...
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
if we see
the full error text.
Alan G
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
or assembler, just be prepared to write a
lot of code...
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
to the hardware.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
easier
to use a proper parser - such as beautiful soup.
http://www.crummy.com/software/BeautifulSoup/
Is there any special reason why you are using a regex
sledgehammer to crack this particular nut? Or is it
just to gain experience using regex?
Alan G
However is it normal that to parse a 2618 lines xml file
it takes 20-30 seconds or so?
Only if you are running it on an original Palm Pilot!
Seriously, I'd expect it to be more like 2-3 seconds.
Something fishy there.
Alan G.
___
Tutor maillist
in page. It was looking
a tad daunting, now I don't need to.
Excellent, thanks Kent.
Alan G.
PS Now off to find out what the heck 'Groovy' looks like! :-)
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
handling topic for
some info and examples of usage:
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
to do that before you can use it.
When i insert python it says it is not recognizable as an internal
or external command. can somebody help me?
The installer should set everything up OK, but try typing
PATH
at the OS prompt and see if Python appears anywhere in
the output.
HTH,
Alan G
Author
happening.
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
(scrollable
listboxes etc)
2) Your mailer seems to be adding extra lines, ie I assume the code
isn't
really double spaced? :-)
So whats the specific problem?
Oh yes - and what version of Python?
Alan G.
I haven't added my error handling yet.
Can anyone help?
I've tried using spawn, system etc
so
the programmer doesn't need to.
An alternative way to solve your probnlem is to use format strings:
print Years = %s;\tPrincipal = %s % (years,principal)
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
that is hearsay!) so I suspect you need
to
ask again on the MacPython programming list, they will know there what
to
do I'm sure.
Sorry, but I suspect its just a tad too specialised a topic for the
tutor list.
Alan G.
(Now someone will post the answer and prove me wrong - again
is an enhancement of the older SpecTcl which I used when I
did Tcl GUI programming. Its quite easy to use although in common
with mamy such tools the code it produces is not particularly pretty.
I've never tried IDE Studio...
Alan G.
Currently learning JSP with the aid of the NetBeans IDE...
Next step
go? I've never
tried that, being a command line junkie, but surely a similar prooblem
ensues?
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org
I haven't seen this mentioned on the list, but has anyone else noticed
that v2.4 now includes the Tix GUI library in addition to Tkinter. Tix
is a collection of more advanced Tk widgets (trees, tables etc)
similar
in many ways to PMW.
Just in case its useful to anyone.
Alan G
... just not programming in Python.
Seems relevant to me... BUT if you can be sure Windows Host Scripting
is
installed ands active that is much much easier to use...
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman
? And if its not too long the code too?
It saves us from guessing... :-)
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
it all back to the file in one move.
file.write(contents[pos + len(name):])
file.close()
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http
for that
to happen.
put in those print statements to verify that the contents of those
variables are what I expected them to be. That's all that mess is
for.
The debug/test print statements are fine, I was only pointing out
that one line did nothing, not the entire block.
HTH,
Alan G
Author
- naturally! :-)
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I would like to check if a certain word exists in a given string.
since I learned to love lists, I used
if myword in mystring:
...didnt work. I have now resorted to
Which version of Python?
'boo' in 'mybigbooboo'
True
Works for me in Python 2.4...
Alan G.
(Regular readers
reading make a difference?
Guessing,
Alan G.
PS. Anyone else notice how some topics seem to come up in bunches.
We haven't had any questions involving binary files for months and
this last week we've had at least 3!
___
Tutor maillist - Tutor
'
list(s)
[u'\u8c01', u'\u4eca', u'\u5929', u'\u7a7f', u'\u4ec0', u'\u4e48']
What seemed to be the problem? Or am I missing something?
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
s = ' '.join(s.split()[1:])
or just
s = s.split(None, 1)[1]
Neat, I hadn't noticed the maxsplit parameter before.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
to increment N either.
print N
for i in range(N):
And you can use len(T) to replace N here.
T[i]
This doesn't do anything! :-)
print T[i]
print date[i], open[i], hi[i], lo[i], close[i], vol[i]
print T[1][2], T[0][0]
z = (hi[2] +lo[2])/2.0
print z
HTH,
Alan G
Author
How do I split a string like Hans into a list of characters
['H','a','n','s']?
list('fred')
['f', 'r', 'e', 'd']
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor
Smith,
Jack Smith,
Sam Love,
Joe Smith]
counts = {}
for name in names:
if name in counts:
counts[name] += 1
else: counts[name] = 1
print counts
You could also use a list comprehension combined with the list
count() method but I doubt if its much faster.
HTH,
Alan G
Author
()[1:])
If the numbes may form a more complex pattern then a regex would be
better.
Use the regex to find the end index and use a slice around the index.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
small blocks of data and it should seem to function
concurrently. If you can't do that then threads are your next best
option.
Alternatively write two programs and join them via a common UI
program using popen or subprocess...
Alan g
___
Tutor maillist
a restaurant menu with a daily updated
header.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
of trial and error. OTOH If you have ever done it
from VB
you will know that already1
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
and accurate and quite
good fun. Of course I may be a tad biased...
http://www.btplc.com/thegroup/Networkstory/index.html
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
corrected to fix a bug reported by a recent
reader...)
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
useful under Win32:
http://www.microsoft.com/technet/scriptcenter/scripts/python/pyindex.mspx
Excellent! thanks for posting this, I hadn't seen it before.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
JavaScript where you really need client
side
scripting.
HTH,
Alan G.
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
1000 members.
Premature optimisation is a dangerous trap.
If you find you really have a problem then we can start to consider
the options!
Alan g
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Forwarding to tutor.
ok. yes i do use windows. how do i write my own encription??
and yes i am going to use Tkinter
You might like to take a look at this:
http://docs.python.org/lib/crypto.html
Alan G.
___
Tutor maillist - Tutor@python.org
http
installer.py?
THe usual unix shebang trick will work just fine.
call your install script 'install' and put
#! /bin/env/python
as the first line. It should then run directly with no problems.
Assuming of course that Python is already installed on the web server!
HTH,
Alan G
of that list.
Another option might be to use -1 as the index to ensure you
always use the last element:
Dis_Tot = Dis_N + DEF_CARRIER_DIS[-1]
HTH,
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
,
tcl,
ruby etc. It's been standard Unix practice for many years.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
But usually simply controlling the display witrh a format
string is all you want to do.
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman
# data is list of 65, 67, 69
for b in bytes:
print 0x%X % b # represent number as hex
You can use the struct module too, but it's a wee bit more complicated
to use. An explanation of handling binary data can be found in the
'sidebar' in my File Handling tutorial topic
HTH,
Alan G
Author
,
like so:
print Here is a split \
... line
Here is a split line
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
it.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
(which I think you do?) then you will
need to write your own encryption routine or find another
module that works on Windows systems - anyone?
Hopefully those hints will get you started. As before build it up
slowly, get the login fixed first then add the features of the
final program one by one.
Alan
changeIndex = nextRightBracket + 1
else:
i += 1
read Alan's tutorial again. *grin*
Umm, well the section on branching does refer to the two loops and
when
each is most appropriate, so... :-)
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
will need
to use popen2 (Or the new subprocess module) to access stderr.
I don't know for sure that mplayer is dping that but I'd say
its a strong possibility.
HTH,
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo
people is a basic question,
Nope, this is a very good question. I haven't been paying attention to
the card dealing functions posted recently but I assume adding in a
dictionary to assign a value per card dealt wouldn't be too hard.
You could then return the cards as tuples or somesuch...
Alan G
! What is it doing wrong? Is there an error message?
What output did you expect? What did you get?
Without that information we have to read the code and guess what you
were trying to do. Then try to guess what might be different to what
you expected.
Alan G
):
result = 1
for x in range(2,n+1):
result *= x
return result
By avoiding while loops you avoid all the mess of trying to maintain
the counter - one of the most common causes of errors in programming!
For a different approach see the recursion topic in my tutor.
HTH,
Alan G
Author
can't even begin to guess from that what it is you are
actually trying to do.
Can you give us more explanation and maybe some sample data?
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
in practice?
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
it will take two of your lists and return -1,0 or 1.
Or you can use Python's own logic to help
def cmplists(lst1,lst2):
return cmp(lst1[2],lst2[2])
Now you can sort Quant by passing your function into sort...
HTH,
Alan G.
___
Tutor maillist
in s:
if line.startswith(substring):
# do something here
Alternatively a regular exression match as suggested by others is
probably
faster.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
7th.
But it depends on what exactly you want to do with it.
If you do want a basic intro to regex you can try my tutorial
topic on them. It doesn't cover the deeper bits but gives
the 30% I use 70% of the time...
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk
exists which could potentially change in some future exotic
version of Python... You really are interested in the value
of x not its identity.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
loop is doing, but thats
the reason for the key error.
HTH,
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
the code was still
in RAM or somesuch This is a good example of why timing
tests must be done over many repetitions and averaged.
Since you are running near the limit of recordability
you might increase the number of loop iterations to 1000...
Alan G
.
Finally, lookaing at tyour regex you might be better using
a simple string method - startswith()
if temp.startswith(A):
That should be even faster still.
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
= 'page'
HTH
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
the call to group(). I was just thinking if
we got a None match.
Ironic since it was me tagged the group call on in the first place!
try/except it needs to be then...
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo
before hitting F5? (I'm not sure whether this would have the result
you
see but its all I can think of!)
Finally, what version of Python/IDLE and which OS?
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
before hitting F5? (I'm not sure whether this would have the result
you
see but its all I can think of!)
Finally, what version of Python/IDLE and which OS?
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
'])]
If the strings are all three chars you could do:
[valid for valid in f if valid[:3] in ['abc', '123', 'ff5'] ]
HTH,
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
explain it in fairly dense detail.
2- If not, then is it possible to feed the SSH password
input with my Python script?
Yes but you probably need the python version of expect module.
Not part of the standard library but available on source-forge
I believe.
Alan G
it's better to ask forgiveness than permission so...
try:
type = re.search('\w+', parameters['type'].value).group()
except KeyError: type = 'page'
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
curses
mscvrt = curses.initscr()
mscvcrt.getch()
I will make the changes and upload the fixed file as soon as possible.
Thanks for bringing it up.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
Hi Hossein,
According to:
http://www.amk.ca
with the function definition. Did you try calling
mycalc.cmpSeq in this same session?
Clutching at straws...
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
to display the result on a console window,
but by naming the script .pyw there will be no console so you won't
see the output! Again you probably need to use a global Label control
and set the text proprty to the result.
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk
then
it could be anywhere in between those two extremes.
HTH,
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
will see both and check the
modification date but if it finds an isolated pyc first it will
just use that.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
at the bottom of each page - it saves bandwidth
on the tutor list (and my embarrasment :-)
BTW Which version of the tutor are you reading? The inti bug
seems to have been fixed in the latest English version...
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
. Shelve would be pretty
much ideal for this application.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
becoming unable
to locate the file in question), I'm eager to hear it.
It's not the function that does it, it's Python itself.
If you just try using print for the two values(with and without 'r')
you will see
the same effect. It's standard Python string handling.
Alan G
It runs fine but the file saved to disk is the
information at : 'http://support.mywork.co.uk'
not
'http://support.mywork.co.uk/index.php?node=2371pagetree=fromid=20397objectid=21897;'
Could there be cookies involved?
Just a thought,
Alan G
a posting with no clue as to the problem but full of basic syntax
errors.
And maybe it could have been expressed more subtly but having returned
from 3 long days I was not in the mood for sweet talking! :-(
Sorry if it offended, it was not meant so to do.
Alan G
Author of the Learn to Program web
as the values.
See the bank account example in my OOP topic for an example.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
take the
time to *understand* what you are doing before doing it!
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
exactly extract
the string from within in_line). The answer to most of your questions
is given inthe error messages Nathan, just look at what it tells
you and the approximate location of the error in your code.
HTH,
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp
mentined it does at least have an HTML rendering control to
start from, I assume you don't really want to have to write a
complete rendering engine too?!
Although if you do at least Python has its HTMLparser module to
help...
Alan g
___
Tutor maillist
1 - 100 of 274 matches
Mail list logo