ests/test.txt w
dummyfile.open: ('d:/tests/test.txt', 'w') <--- first open for writing
dummyopen: d:/tests/test.txt r
dummyfile.open: ('d:/tests/test.txt', 'r') <--- then for reading
dummyfile.read: ()
dummyfile.write: ('',)
> spend 5 hours RTFM. I got
, and
there's only so much compressing you can do.
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Mark Brown wrote:
I'm a newbie and was wondering which of these IF conditions is better
structure:
1. if not os.path.exists('filename'):
2. if os.path.exists('filename') == False:
I prefer the "if not" variety.
Yours,
Andrei
___
aList = [elem+1 for elem in aList]
but it's barely shorter than the explicit loop, so not necessarily an
improvement from that point of view. But at least it prevents the bug
from biting :).
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
?
I'd use return in the form of
def p():
v = 3
def q():
return v+1
v = q()
If you need to modify a lot of p-vars inside q, I'd say it's probably wiser
to go with a class and appropriate methods.
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EM
know
if it also includes Dive into Python, FAQ's and HowTo's like the ActiveState one
does. It's nothing that you can't download on your own for free, but it's just
more comfortable to get it all in a single package.
Andrei
__
= []
for line in self.lines:
for point in line.points:
if point not in self.points:
self.points.append(point)
And you could go even higher, to a tetraeder made out of triangles, if you
extended Point
'map', since you just have to modify the data. Modifying data is safer and
easier than modifying code.
- it's easier to debug than when you have a billion lines of call stack.
- I expect it to consume less memory
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[E
ad/skip lines manually as needed.
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
___
Tutor maillist - Tut
xt
>>> a = node('item a')
>>> b = node(3)
>>> c = node((3,4))
>>> d = node('last item')
>>> a.next = b
>>> b.next = c
>>> c.next = d
>>> mynode = a
>>> while mynode:
... print mynode.item
... myn
omework for me".
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
it's reasonably easy to replace it with something else later. For
example 20 MB memory use doesn't sound like much to me on a modern
computer, but I'd leave Nevow out of the choice of your XMLRPC server.
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROT
in turn be another loop accepting words as
input which get 'translated', until the user gives a blank string or
whatever as input in order to terminate the loop (and automatically fall
back into the loop of the lobby)
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL
But I also can't imagine right now any realistic cases
where it would be useful to have a dictionary contain itself as a value.
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfg
John Fouhy wrote on Sun, 03 Apr 2005 09:53:56 +1200:
> Andrei wrote:
>> Liam Clarke wrote on Sat, 2 Apr 2005 22:12:49 +1200:
>>>I know that as above doesn't work, but was just wondering if it's
>>>possible, and if it's a Bad Thing?
>> Max has alrea
t; globals(),locals()'%(s,s),'','exec')),t)[1] for s in l]
[1.0, 2.0, 3.0, 'abc', '', 4.0, 9.5, 9.0]
I would recommend against it though :). Having a special function for this
purpose is the way to go, a ternary operator doesn't really add any
eep it readable):
>>> s = "%20s" % "xyz"
>>> len(s), s
(20, ' xyz')
or:
>>> s = "xyz"
>>> s = s + (20 - len(s)) * ' '
>>> s, len(s)
('xyz ', 20)
--
Yours,
And
numbers
stored as strings :).
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
age). If you pass that
parameter in the SendMessage calls, I think the mouse should click
on a certain position (although I haven't tested, as I'm not on
Windows ATM).
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
he
player is in plus the connected rooms), an Item class (with subclasses for
different types of items, where different implementations of e.g. PickUp methods
would determine if the player could pick up a pencil or a skyscraper), etc.
Yours,
Andrei
Bob Gailer alum.rpi.edu> writes:
> At 12:22 PM 4/7/2005, Andrei wrote:
> >Kevin gmail.com> writes:
> >
> > > I am fooling around with classes and I was trying to create a very
> > > small one player text adventure. I made a class called commands here
&g
pick up excalibur even though
conan already has it.)
You can see that conan and donan are both players (Player objects), but each of
them has his own name, inventory and strength. Even if conan's inventory is
full, donan can still pick up new things.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
e the fact that __init__ is indeed
inherited:
>>> class C(A):
... pass
>>> c = C() # inherited __init__ (A.__init__) is called
>>> c.a
13
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V er
ink of an address book (where you use names as keys and
addresses as values), a menu system (where certain user input is mapped to
a certain function), a cache system (where results of certain
time-consuming operations are saved in case the user asks for the same
operation again) and there are man
7;t provide?
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/
a more detailed description it's hard to determine. I would say it's
perpahs a bit unusual if you do indeed have two modules with the same interface
but different behavior.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
erfectly, even though
initial random file distributions give 240+ discs), but I haven't checked the
results very thoroughly. It might be doing something really stupid. It's also
reasonably fast (1000 generations of 1000 individuals each is feasible for
example, but not necessarily
s
context just a different way of defining a function. The net result is a
comparison function which is called by the sort() method in order to determine
which of two dictionaries is 'smaller' or 'larger'.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
not Python-specific: if they
convey their ideas clearly, you can implement such things on your own.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
y and add the appropriate methods, so that the
interface remains the same.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
t does! However, a different test reveals this:
>>> d = {4:0, 5:0, 1:0}
>>> d.keys()
[1, 4, 5]
Aha! So it sorts the keys (both tests support this conclusion). Or does it?
>>> d = {4:0, -1:0, 5:0}
>>> d.keys()
[4, 5, -1]
Nope, not sorted, not ordered - exactly as the Python specification states,
dictionaries are unordered.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
a plain text
generic editor, save the program and double-click on it in Explorer (if you're
on Windows) or launch it by typing at the command line:
python myscript.py
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
, but from that point on, it's no longer your
responsibility to protect them from themselves. Python works on the assumption
that programmers are responsible adults :).
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
t 4 letters, type i[-4:].
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ke it a global variable and only initialize it at the
start of the program).
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ith certain connections between them (if there aren't too many points,
otherwise you'll hit a recursion depth limit or a stack overflow). Or for a menu
navigation system, where a showmenu() routine calls itself to display submenus.
Yours,
Andrei
___
en then it's still easier to keep them in a list of tuples, because it's
easier to do manipulations like "remove the lowest score" when you insert a
higher one.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
> mydb = bsddb.btopen('game.db')
>>> pickle.loads(mydb['lastplayer'])
'John Doe'
This is not useful for small amounts of data like the highscores list, but if
you have more data (e.g. level data, dialog texts) and you need quick access to
it without having to keep everything in memory all the time, bsddb is a
comfortable option.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
erything goes well,
you'll get a NameError if you try to print it. Also if it does exist, it will
need to be reset before the try-except, otherwise afterwards you won't know
whether its value comes from the last try-except or from some time in the past.
On a sidenote: recommended Python
ary and mistakes might lead to breakage)
It's quite obvious though that no method is good enough if you attach any kind
of value to high scores, by e.g. posting the highest scores on your webpage.
Yours,
Andrei
___
Tutor maillist - Tutor@python
> always thought it a bad smell.
It does indeed smell of a maintenance nightmare waiting to happen :). The bad
part is that it tends to get progressively worse. Imagine also what would happen
if you'd get even more of those similar modules.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Tkinter wrapper) it would be even
absolutely trivial (show a standard directory selection dialog, then copy the
stuff - 5 lines of code or so). It would be cross-platform too.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
eful to rise to the top of
> the examples?
It would indeed, if someone implemented it :).
> would get used or not. Perhaps the personal feedback of the tutor list
> is more effective.
OTOH, finding it yourself is faster than waiting for a reply.
Yours,
Andrei
___
g else -
though more obsfucation != more security). The effect this will have in stopping
a determined person will be pretty much zero, but at least it's not out there in
the open and a simple text search won't cause it to just show up.
Yours,
Andrei
_
Joseph Quigley wrote on Fri, 22 Apr 2005 13:45:05 -0600:
> Interesting. So several distros use rpms? I though only red hat used 'em.
Yeah, including some major ones like Mandrake and Suse.
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! C
ce for
your application :). Command line apps which wipe out the command line
history are bad. You might prefer making a GUI or a web application
instead.
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yv
above shows that numbering begins at 0, with the fourth line having
number 3. So either I misunderstand the question, or the snippet is confusing.
That being said, I can imagine counting lines from 1 because programming editors
also tend to count from 1 instead of 0 and this way it
than regular Python, it is still much
> slower than C.
Except in some amusing cases:
http://mail.python.org/pipermail/python-list/2004-April/215272.html
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gu
ut to
have some benefits (it's possible to mix OO and procedural code). If a project
runs into thousands of lines of code, it virtually always makes sense to bring
OO into the picture.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
o this mailing list and ask questions (though I do caution
> them not to submit their homework simply to get a solution).
I think people reading a magazine called "IT Pro" should be aware of such
basic etiquette :).
--
Yours,
Andrei
=
Real contact info (decode with rot13)
learn a bit more about Python's facilities before
embarking on an ambitious project :) - you won't get very far without knowing
how to use lists and dictionaries.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
7;,indexfile.read(4))[0]" and similar lines.
A file class which would wrap this stuff and offer a nice interface with methods
like ReadInt, ReadDouble would clear it up a bit.
- "Private function" in the comment of __newdemo. I'd remove it, since the
double underscore already documents this.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
should go around modifying code on its
own in *any* way, even if it's spaces. Although, now that I think about it, a
VCS might have an option of ignoring leading/trailing whitespace when doing
diffs, such an option could bite when merging Python code.
Yours,
Andrei
__
at "How to think like a computer scientist in
Python" (http://www.ibiblio.org/obp/thinkCSpy/). Chapters 8 and 10 discuss Lists
and Dictionaries
http://www.ibiblio.org/obp/thinkCSpy/chap08.htm
http://www.ibiblio.org/obp/thinkCSpy/chap10.htm ,
but I'd recommend you rea
when a specific revision is requested. Sure you
> hope it's the same as it was in the beginning but there's always a
> chance for error.
Yep. But the fact that only the indentation changed, sounds fishy. I'd rather
expect editor settings to be at fault than the VCS. If you
be decrypted without the password, even if
the source code is available.
--
Yours,
Andrei
=
Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
__
or
2-person rooms and applies a discount if the reservation is on a day between
monday and thursday.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
t;> test5.var()
Traceback (most recent call last):
File "", line 1, in ?
File "", line 4, in var
NameError: global name 'dummy' is not defined
>>> dummy = 234
>>> test5.var()
234
>>> test5().var()
234
Which soultion is right, depends on your needs. I'm tempted to say (3) is the
best one, unless you really need that to be a class attribute.
Tip: http://zephyrfalcon.org/labs/python_pitfalls.html
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
couldn't convert to integer
print 'Not a number'
choice = 5
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
all games
exit
If you go into more detail, you'll end up writing a long version of the Python
code, which kind of defeats the purpose of pseudocode.
> Any useful advice for algorithm would be appreciated.
It's more important (at least for larger progams) to think about good design in
y get more
comments, while easier portions get fewer comments - just as it should be.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
omething
similar, this code would still not be quite high level, because shuffling the
source, taking a slice and such are not built into those languages. In fact,
in those languages you'd most likely choose a different approach at this
level.
Yours,
Andrei
_
ly in the directions which could be
foreseen beforehand). Going from design-in-head straight to production code
doesn't (at least for me) lead to the best of results in those respects, even
though the code may work.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
e of loading all
kinds of simple minigames. I don't know how far it is by now, but if you look in
the pygame mailing list archives you should be able to find it.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
if the function finds it has called itself too many
times - helps against infinite recursion too.
>>> def a(i):
... i += 1
... if i < 500:
... a(i)
>>> a(0)
If you try the function above without the if condition, it will generate a
Runt
around all this metaclass safety by adding
using this code:
NoNewAttrs.__metaclass__.__setattr__ = type.__setattr__
NoNewAttrs.__setattr__ = object.__setattr__
nna.x = 5
print 'After reset: nna.x =', nna.x
Run this and you'll see
Glade - you can design your
interface in a point-and-click manner. You will need to learn a bit
about wxPython in the process, but don't have to become an expert.
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact info:
''.join([''.join(s) for s in
n: http://en.wikipedia.org/wiki/Binary_search
Yours,
Andrei
=
Mail address in header catches spam. Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V
ernq gur yvfg, fb gurer'f ab arrq gb PP.
___
sition, swallows and just about
anything else that seems weird can usually be tracked down to that same
source.
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact info (decode with rot13):
[EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V
ernq gur yvfg, fb
looking up
treatments/illnesses for a given patient (with the patient being the key
in the database) or if the number of patients is quite low (hundreds).
If however an important use is to do other types of searches too (e.g.
find all patients with an age above X who use a drug Y) and you ha
ave an editor in which
to be productive, it's probably better to invest some time in learning
to use one of the existing options. Whether it's Spe, Scite, Komodo,
Vim, Emacs or whatever else suits you, is not very relevant.
--
Yours,
Andrei
=
Mail address in header catches sp
> I can't see a simple way around it (wood for the trees)
How about using a "while True" loop that you break out of only when a
correct value has been identified:
while True:
dau_version = raw_input('blabla')
if dau_version in ("2.8",
h of if-statements.
if g is between X1 and Y1: result is Z1
else if g is between X2 and Y2: result is Z2
else if ...
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact info:
''.join([''.join(s) for s in zip(
"[EMAIL PROTECTED] pmfe!Pes ontuei
important difference. You should terminate the try-except
block (confirm with extra ENTER) before doing more stuff.
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact info:
''.join([''.join(s) for s in zip(
"[EMAIL PROTECTED] pmfe!Pes ontuei ulcp
x27;, e.g. ">>> print 6; print 5"
will work just fine.
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact info:
''.join([''.join(s) for s in zip(
"[EMAIL PROTECTED] pmfe!Pes ontuei ulc
ng at the top of the digest:
'When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."'
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact info:
''.join([''.join(s) for s in
ython, which seems to be what you got - one is a
Python distro, the other is an extension of the VisualStudio IDE. Neither is a
.Net implementation of Python, IronPython is (http://www.ironpython.com/).
Yours,
Andrei
___
Tutor maillist - Tutor@pyth
s for input
and the return statement to output any necessary modifications, e.g.:
def p(inp):
output = inp + 1
print output
return output
if __name__ == '__main__':
x = 5
x = p(x)
It would be even better with a decent function name of course :). More
i
mutation
retList.append(word)
else:
# Return a list of all permutations using all characters
[ retList.extend(
[ word[pos] + item
for item in permute3(word[0:pos]+word[pos+1:len(word)]) ] )
for pos in range(len(wor
quires a single update, while the dictionary
requires one new key-value pair and modifications in another two
places in order to get it working correctly.
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact info:
''.join([''.join(s) for s in
gt; def func(self):
... print self.__class__
>>> A.f = func
>>> B.f = func
>>> a, b = A(), B()
>>> a.f(), b.f()
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact info:
''.join([''.join(s) for s in zip(
"[E
put a
webbased interface onto it, or subclass it and make a glossary which can
also do multiple language translations, or use a different storage
backend, etc.).
--
Yours,
Andrei
=
Mail address in header catches spam. Real contact
"Hello %s" % username
else:
print "Incorrect name or password!"
Other environments (e.g. wxPython, PyGame or web interfaces) offer different
ways of achieving the same results, but I presume you're really new to Python
and not yet messing around with those.
Yours,
Andr
on "amount <= 0" and
inform the user that a number larger than 0 is required.
Here's a modified version:
def getAmount(currency):
while True:
useramount = raw_input('Amount: ').lower().strip()
if useramount in 'qx':
return
Patricia gmail.com> writes:
> I have to store and retrieve text files from a database table and
> the size of each file is about 500k. Can someone give me an idea
> on how to do this?
You might want to have a look at this:
http://sourceforge.net/projects/mysql-python
Yo
cript, this difference is of no
consequence (that value is close enough to zero):
>>> "%.2f" % (.1+.1+.1-.3)
'0.00'
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ith
'%%'. E.g.:
>>> "%%.%df" % 2 # the '%%' will be changed to '%' in the result
'%.2f'
>>> "%%.%df" % 4
'%.4f'
>>> s1 = "%%.%df" % 2
>>> print s1, s1 % 3.41234
'%.2f', '3.41'
>>> s2 = "%%.%df" % 4
>>> print s2, s2 % 3.41234
'%.4f', '3.4123'
>>> ("%%.%df" % 2) % 3.23423
'3.23'
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
for function names is that they should contain a (well chosen) verb
and an object. As always it ends up being a matter of personal taste. I for
example might call that function insertSeparators or formatNumber, but other
people might prefer longer names
Py, which is part of TurboGears) seems to have decent
support for all kinds of Python things, but it's paid - if they allow a
1-month account, you could try it out for very little money over there.
Yours,
Andrei
___
Tutor maillist - Tutor@python.o
rted locs:", locs
maxrange = locs[0][:] # guaranteed to start with min
for loc in locs[1:]: # loop over rest of locs
if loc[0] <= maxrange[1]:
maxrange[1] = loc[1]
else:
print " discontinuity found for", loc
return None
ll take
item #0 in MyList and request its item #1. It's equivalent to saying
MySubList = MyList[0]
print MySubList[1]
In an interactive session:
>>> li = [[1,2], [3,4]]
>>> li[0]
[1, 2]
>>> li[0][0]
1
>>> li[0][1]
2
>>> li[1][1]
4
Yours,
Andr
are not
specified. You could read it like "if the filename ends with .gif or .jpg or
.tiff". In older Python versions, you could implement the same functionality as:
if s.endswith('.gif') or s.endswith('.jpg') or s.endswith('.tiff')
This is in co
od
on a certain object, without knowing what that object is - it needs to examine
the object at runtime to determine if the method is available. The potential
compiler would have to handle all of these cases, meaning you'd end up with...
well, CPython. Typical compiler efforts in the past have limited the flexibility
of the language.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
PA sapo.pt> writes:
> Is there any site offering e-learning about Python?
>
> If not, the PSF should do it!
If you mean if there are any online tutorials: lots of them. Here's a very large
list: http://www.awaretek.com/tutorials.htm
ewed by a teacher in a more classical approach.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ested), but it
will take anything you throw at it as long as Python itself can handle it.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ing is potentially dangerous.
Say I accidentally specify p=2atn. The program will calculate with 2 kPa, but I
wouldn't know that. If instead it displayed its interpretation of my input by
writing "p = 2 kPa" to the screen, I'd have a better chance of noticing.
Alternatively
ses very
cumbersome to deal with, or trusting the programmer to do the right thing -
thereby making it easier to stick his grubby little fingers in places where he
shouldn't. Some people prefer the former, some the latter.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
a child, otherwise they're
unrelated.
> I can't seem to rack my brains around a solution for this. Maybe it's
> my tree-structure that is making this more complex than it should be?
Hierarchies are easier if you look at them as families: it's easier to
ask a parent how many children it has, than it is to ask one of the
siblings if there is any sibling younger than it, then ask that younger
sibling if it has any younger siblings, etc.
Yours,
Andrei
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_init__(self, x): self.x = x
... def dostuff(self, arg):
... print self.x
... print arg
...
>>> def dostuff(obj, method):
... method(obj, 'blabla')
...
>>> a = A(5)
>>> dostuff(a, A.dostuff)
5 # this demonstate
1 - 100 of 119 matches
Mail list logo