rror (cannot concatenate
'str' and 'int' objects). ;) But yes, rebinding codeSt to a new
string should allow the old string to be destroyed (if there are no
other references to it).
Hope that this helps.
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
#x27;re running or
not. I'd have *thought*, however, that if it *is* present, you'd get
a syntax error rather than a memory error, so it's probably not there
but you should check it anyhow. :)
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
les are all of
reasonable size to fit into memory. Your code makes this same
assumption, too, of course. This assumption should be valid for up to
a few tens of thousands (maybe even hundreds of thousands, depending
on your hardware) of items. If you have more than this, then your
best bet wou
's exactly what html parsers *do*, well,
the conclusions seems obvious (to me at least). ;)
There are lots of html parsing tools available in Python (though I've
never needed one myself). I've heard lots of good things about
BeautifulSoup...
Jeff Shannon
Technician/Programmer
Credit Interna
get error because append method
does not work on list.
No -- look carefully at the tracebacks, and you'll see that nowhere
does it complain about append(), nor does it give the line numbers in
which the append() takes place. It complains about split(), and tells
you exactly which l
perations.
I'd check whether XP's built-in firewall is enabled, and if so, check
whether it might be blocking connections to loopback / localhost /
127.0.0.1 (all of these indicate the same thing).
Jeff Shannon
Technician/Programmer
Credit International
___
Jeff Shannon wrote:
if myrange in range(10,90): # "in" is the key word here
return True
else
return False
This is, however, the correct solution. :)
Or I *should* say, rather, that this is *a* correct solution, in that
it will yield the expected answer. Kent Johnson'
ults of each
test, only about whether I should continue afterwards or not. In this
case, I'm weighing the cost of multiple returns against the cost of
multiple nestings or of using flag variables, and I find multiple
returns to be the lowest-cost option.
Jeff Shann
of data to operate on, or many such sets, is mostly
irrelevant (though classes are even more valuable when there *are*
many sets of data). Defining a class isn't so much a statement that
"I want lots of things like this", as it is a declaration of
modularity -- "This stuff a
sitename will consistently produce the
same four characters.
Now, here's a 'batteries-included' function that does much the same
thing (though it'll be different characters).
.>> def complex2(domain):
... import md5
... digest =
e
else
return False
This is, however, the correct solution. :) Presuming again, of
course, that myrange is an integer -- but be aware that user input
normally comes in the form of strings, so it will be necessary, at
some point, to create an integer from that string using int().
Jeff Shannon
Te
home directory to getting the home directory for whoever the current
user is.
You can refine main() further, too -- for instance, instead of setting
an empty flag, you could just call can() as soon as you find the -e
option.
Jeff Shannon
Technician/Programmer
Credit International
server with desktop PCs, though, I've been
able to use Python for a few projects, and I often use it for
interactively exploring data files and doing sysadmin-type work.
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist
.
import func_module
# ...
for ...
func = getattr(func_module, verb)
# ...
Once again, you should probably wrap that in a try/except block (this
time looking for AttributeErrors).
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
n
exactly the same way that lambda does. A function object (whether
named with def, or lambda) like this, which captures a variable's
current state, is called a closure. Closures are indispensible for
GUI callbacks like this, and many pe
er a Damson or a
Prune, and which forwards method calls / attribute accesses to its
contained object.
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
= a[1::2]
(Note that this is untested, as I don't have a recent version of
Python handy at the moment; I'm on 2.2 here, which doesn't have
extended slices.)
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - T
probe_pairs.append(line)
openfile.close()
Either way, lines that start with 'Name=' get thrown away, and all
other lines get kept.
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ess to the file-like pipe objects is probably
buffered. You'll want to call pipe.flush() after writing to it, or
the child process won't actually see what you've written.
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ld (IIRC this works since 2.2,
which is what I usually use), I'm just in the habit of using
readlines(). I suppose that, in a case like this where the filesize
is not insignificant, it *would* be worthwhile to take advantage of
the file iterator to avoid having that fairly large l
ually, I'd have avoided saving the intermediary state and
simply done all the list processing at once:
self.list = [line+'\n' for line in self.macro.split('\n')]
Either way, though, I'm creating a new list rather than modifying the
old list in-place, which avoids
ame', '.txt')
>>>
I've also added a second clause to ensure that returned files are not
links, as per the rest of the O.P.'s spec.
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
import
process and modify the target module before the Python parser gets it,
which should enable you to avoid the SyntaxError problems.
(Of course, I've never messed around with hooking __import__(), so I
could just be talking out of my ...)
Jeff Shannon
Technic
x27;
>>>
Note that in the second case, I've included a space in the lstrip()
parameter. lstrip() is essentially saying "remove all leading
characters until you find a character that's not in this sequence" --
a space counts as a character. (Took m
the most common case, and I'm not
sure that your expectation is necessarily more generally useful than
the current behavior. Especially given that your behavior is the one
that's easier to hand-code if it's desired.
Jeff Shannon
Te
e as devastating as some might lead you to believe. ;) It certainly
won't prevent you from using Python for functional programming...
(And personally, I suspect that if lambdas *are* removed, they will be
replaced with a different construct that will fill the same needs in a
lenty more awful languages around that didn't
happen to be "rescued" from oblivion by an accident of history...)
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
hat the supposed advantages of anonymity come across as little more
than handwaving assertions to me, no matter how sincerely they're
intended. (I've just started to read through SICP, to pick up some
lisp/scheme, in hopes of understanding the ap
Max Noel wrote:
On Feb 3, 2005, at 23:41, Jeff Shannon wrote:
(But then, at my job I'm stuck using a horrible Frankenstein's monster
of a proprietary language on a daily basis, so I can't help but
believe that there's plenty more awful languages around that didn't
ha
Occassionally it improves readability, but more
often it obscures and obfuscates.
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
automatically add the newline
that print does (which is why I've specified it in the above sample).
Indeed, print can do all sorts of odd things with whitespace,
leaving sys.stdout.write() as the best way to have real control over
your output a
of saying "I want a switch, how can I
implement that in Python?", I've taken the approach of "The end result
I want is ***; what tools does Python offer to achieve that?" This
conceptual shift is, IMHO, *the* most important mental hurdle in
learning a [second/third/n-th] language.
Jeff Shannon
Technician/Programmer
Credit International
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
step:
.n = Node(**tags)
You could also put all of the splitting into fields in a method, and
when __init__ gets a single string as its argument simply pass it to
that method and update with the results...
--Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
is finished, and then
return. If the thread is already finished when it's called, it
returns immediately.
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On Tue, 15 Feb 2005 23:48:31 -0500, Brian van den Broek
<[EMAIL PROTECTED]> wrote:
> Jeff Shannon said unto the world upon 2005-02-15 21:20:
> > On Tue, 15 Feb 2005 17:19:37 -0500, Brian van den Broek
> > <[EMAIL PROTECTED]> wrote:
> >
> > For starters, I
y the following bare except statement. That means that you'll run
(what I presume to be) your error-handling code even when you
successfully convert every member of fcs...
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ernal searches would be. But I suppose that
there's room for reasonable people to disagree, here. :)
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
is way:
class Child(Parent):
def __init__(self, new, *args, **kwargs):
Parent.__init__(self, *args, **kwargs)
self.new = new
This way, the Child class doesn't need to know or care about what
parameters get passed on to Parent; it uses the ones it needs, and
passes all t
where it could be simplified by delegating to a Cells instance, too...
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
se you'll have to research that
independently. I know that you can use the "assoc" command to
associate the .py extension with the Python.File filetype, but I'm not
sure how to create filetypes or change actions that are taken upon
filetypes if it's different from
;s probably better to have Tournament and Round be independent
classes, but have Tournament instances hold a list of Rounds (which
may be passed in during initialization, or may be added later). This
is called "composition", and is just as important (or perhaps more
important) of an idea as in
e, but when
you add items to it, you also specify a priority for them. Then, when
you retrieve an item from the queue, what you get is not necessarily
the first-inserted item, but rather the item with highest priority.
You might want to check the Cookbook to see if there's a priority
queue recipe
creating new references to the same list.
> Oh PS
>
> Is there a more elegant solution to
>
> if string == 'sun' or string == 'mon' or string == 'tue' or string ==
> 'wed' or string == 'thu' or string == 'fri' or string == 'sat':
Try:
if string in ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']:
(Or perhaps look into using the datetime module, depending on how
detailed your needs are.)
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
a single object
will not hash the same at different points in its life, or objects
which are equal will not hash identically.)
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
a *lot* of repeated
operations, e.g. a loop with many (i.e. hundreds to thousands of)
iterations.
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
hould work the
same as the rest of your GUI.
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
g why you're not getting an equality, you were wondering
whether your machine had frozen?
There's always a trade-off. It's important to be aware of the
weaknesses of the tools that you use, but *every* tool has weaknesses,
and it doesn't make sense to discard a tool just because you've
learned what those weaknesses are.
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
exe"), which launches a separate program in an
independent process. However, if you're trying to get the results of
the file selection back into your own app, you need to do the file
browsing within your own process (or explicitly use some form of
inter
ect that this is probably related to
either permissions or environment variables.
Jeff Shannon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
e, but we won't get into that.
You *don't* want to do this.)
In this case, I agree that a factory is your best bet.
Jeff Shannon
>
> class Node:
> ...
> def __init__(self, cargo=None, prev=None, next=None, nod=False):
> """x.__
50 matches
Mail list logo