ython 2.5.1, for example, which is
hardly the latest.)
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
I'm working on a small curses application that opens an external
editor occasionally; in the current case I'm testing its running vi.
Once I exit vi and return to the curses application I lose the
background color, window frames, and any text I had on the screen
before I opened vi. I can still see
On Oct 8, 1:16 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> Joe Keen wrote:
> > I'm working on a small curses application that opens an external
> > editor occasionally; in the current case I'm testing its running vi.
> > Once I exit vi and return
We have a client who's paranoid about distributing the Python source
to his commercial app. Is there some way I can distribute and use
just the .pyc files, so as to not give away the source?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
I have a written a generator for an apache log which returns two types of
information,
hostname and the filename requested.
The 'log' generator can be 'consumed' like this:
for r in log:
print r['host'], r['filename']
I want to find the top '100' hosts (sorted in descending order of total
requ
On Wed, Oct 8, 2008 at 1:55 PM, Joe Python <[EMAIL PROTECTED]> wrote:
> I want to find the top '100' hosts (sorted in descending order of total
> requests) like follows:
> Is there a fast way to this without scanning the log file many times?
As you encounter a new &q
sorted(hosts,key=hosts.get, reverse=True):
for file in filename:
print host, all[host,file]
print hosts[host]
I was looking for a better option instead of building 'three' collections
to improve performance.
- Jo
On Wed, Oct 8, 2008 at 2:15 PM, Joe Riopel <[EMAIL PROT
On Oct 9, 2008, at 7:05 AM, [EMAIL PROTECTED] wrote:
Tino>
http://docs.python.org/library/stdtypes.html#string-formatting-operations
That shows how to use the template formatting as it currently
exists. To my
knowledge there is no support for the inverse operation, which is
what
doesn't match), or a dictionary
with values for 'object', 'location', and 'subloc'.
But I couldn't find anything like that in the docs. Am I overlooking
something?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
s that have
special meaning to RegEx, except for '$' (which is why I can't use
re.escape).
Probably the rest of the code could be improved too. I'm eager to
hear your feedback.
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
primarily a Mac user, but occasionally has to dabble in
Linux or Windows. If we do make this change, he'll be using Python in
a professional capacity to develop commercial apps.
There are a lot of Python books out there... which one would you
recommend in this case?
Thanks,
- Joe
--
erably as per PEP 0001. But that document also suggests first
discussing it here. I'm still a newbie (or actually, oldbie-turned-
nonbie-turned-newbie-again), so I could use some advice. What's the
next step in advocating for this idea?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
-tagged comment,
rather than in the docstring.
I still think it's a nifty idea though.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
008 4:39:55 PM Maecenas lectus libero, tincidunt sed ]
Note: there is an element corresponding to each time entry in the array
I tried to use the pattern but its not working:
pattern = r'(\d+/\d+/\d+ \d+:\d+:\d+ .+)'
pat = re.compile(pattern)
result = re.split(pat,s)
ollow code over something that includes everything but the kitchen
sink.
Any suggestions?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
I don't want to
recommend an abandoned platform. Anything else I should consider?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
ar to say that ONLY those can do the job.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
of a and b is a reference to some object that
has a "foo" attribute.
Not sure if all this was helpful to anyone, but I hope so!
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
t it's comforting to know that you're not
incurring the penalty of copying a huge data buffer every time you
pass one to a function or assign it to another variable.
But with mutable objects, it is ordinary and expected that what you
have is a reference to the object, and you can tell this quite simply
by mutating the object in any way. Every modern language I know works
the same way, and I'd wager that the ones I don't know (e.g. Ruby)
also work that way. Python's a beautiful language, but I'm afraid
it's nothing special in this particular regard.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 16, 2008, at 11:23 PM, Dennis Lee Bieber wrote:
On Thu, 16 Oct 2008 21:19:28 -0600, Joe Strout <[EMAIL PROTECTED]>
declaimed the following in comp.lang.python:
Now that IS mysterious. Doesn't calling a function add a frame to a
stack? And doesn't that necessitate c
Can someone who
gets this share a clue?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
-- in fact all the source except the
assignment to s could be replaced with the one-liner
print s.encode('rot13')
Though the existing source is interesting in its own way too.
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
? Do you then have a proper UTF-8
string, but the problem is that none of the standard Python library
methods know how to properly interpret UTF-8?
4. In Python 3.0, this silliness goes away, because all strings are
Unicode by default.
Thanks for any answers/corrections,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
p your value in some mutable type (like a
list) and pass that instead. A little awkward, but no big deal, as
there are darn few valid reasons to ever pass something by reference
anyway, especially in a language with tuple packing and unpacking.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
files or sockets or whatever, of course I'll
have to think about what encoding the text should be... but internal
to my own source code, I shouldn't have to.
I understand the need for a transition strategy, which is what we have
in 2.x, and that's working well enough. But I
a ByRef parameter in modern languages. And it seems
that Python simply doesn't have that.
People here don't describe Python as different just because they
*want*
it to be different. Python acknowledges intellectual debts to many
languages, none of which is exactly like it.
Sur
ed-up and streamlined C++. Even old-timers (like me) who learned
FORTRAN and COBOL way back in the day have long since moved on.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
hoping that the answer is "no" -- most string literals in a source
file are text (which should be Unicode text, these days); a raw byte
string would be the exceptional case, and I'd be happy to use the "r"
prefix for those.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
codings is
currently primitive compared to some other environments, and I see
that this extends to the database modules. Fine, fair enough, it is
what it is, but there is no harm in asking about (or even yearning
for) a more intelligent system that does more of the grunt work for us.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
ompatibility with
other Unices -- well-behaved Mac apps put global settings (and so on)
in the appropriate subfolder under /Library, with per user data in the
appropriate subfolder under ~/Library.
Cheers,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
re indentation shows containment, and with
the name/type/attributes for each item on a line -- any sort of
standard, or just something you guys made up?
Thanks very much,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
t, because Python arguments are ALWAYS
passed by value. There is no call by reference in Python. Period,
end of story, nothing to see here.
Cheers,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
them. If that's a problem, explicitly remove them from the map
when you know you're done with them, or use weak references.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
s are
expressions that are evaluated, and the resulting value copied into
the formal parameter, pure and simple. The continued attempts to
obfuscate this is pointless and wrong.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
ad it yet. But I may not get another chance to work on it
for a few days, so I wanted to get it out there now. I welcome your
feedback.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
following:
variable: "ariablevay"
value: "aluvay"
reference: "eferencevay"
call-by-value: "allcay-ibay-aluvay"
call-by-reference: (no term needed, since Python doesn't have it)
There. Now we've got a simple mapping from standard terminology to
as "l"?
Hey, that's a very nice little demonstration of an orphaned object.
Thanks for sharing it!
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
e called by value (the value itself is
copied).
Quite right. Now, note that "ByRef" and "ByVal" apply to both.
Generalize to Python. There you go.
Best,
- Joe
P.S. I really am trying to quit responding to this thread. Sometimes
the urge is too strong. But I'll keep trying!
--
http://mail.python.org/mailman/listinfo/python-list
very clearly, is call-by-value.
To call it something else only clouds the issue and results in
confusion. (Perhaps explaining why there appears to be far more
confusion about call semantics in the Python community than in the
community of other languages where the default semantics are exactly
the same.)
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
l approach, but this test will fail for Unicode
strings, and so is probably bad mojo moving forward. Instead I suggest:
isinstance(x, basestring)
which will work whether x='asdf' or x=u'asdf'.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
There is no need for new terms.
Agreed.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
d first.
That's a very sensible stance. +1!
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
btained results really do match the
expected results, considered as a dictionary rather than as a string.
But doctest doesn't see it that way.
What's the standard solution for this? Should I iterate over the
sorted keys and print those out instead? Is there some built-in
method somewhere that will print a dictionary in a reliable order?
Does doctest have some special way to tell it to consider the result
as a dictionary rather than a string? Or something else?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
as I'm one of them.)
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
he only passing methods. True or
False?
True, but the others are rarely used and don't apply to any of the
languages we've been discussing.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 3, 2008, at 4:38 PM, Paulo J. Matos wrote:
However, I wouldn't dare to say Python needs structures to be a good
language, or anything similar. My question was more directed to : if
there aren't structures in Python, what do Pythonists use instead?
Classes.
Best,
- Joe
er language calls call-by-value.
But I really am trying not to continue this debate. So that's my last
reply about it for tonight, I promise. :)
Cheers,
- Joe
<http://www.strout.net/info/coding/valref/>
--
http://mail.python.org/mailman/listinfo/python-list
ing this myself, but if you think you can do a
better job at a reasonable rate, I'm happy to let you do so.
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
them to give you a feel
for what it can do.
In addition to the quality apparent to the end-user (which I think is
the most important thing), I find the wx API to be quite sensible and
easy to work with too.
HTH,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
as no analog in Python. Python object
variables are references to objects on the heap, just like pointers in
C++ to objects created with "new". So this example is a red herring.
I'd be very interested in hearing whether, as a C/C++ user, the above
explanation is clear and makes sense to you.
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
development point of view).
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 4, 2008, at 3:42 PM, Steven D'Aprano wrote:
This example is also call-by-value, but the value in this case is a
type
that has no analog in Python.
I'm disappointed to see that my prediction that Joe would, yet again,
utterly ignore all the arguments against his pet theory w
e of those languages mentioned use call-by-value.
In fact both of these statements are false, but we can cut our time
and effort in half if you will just select the one that you believe to
be true, so we can focus on that. Which is it?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
u can mutate an object passed to a
function.
As should be painfully clear by now, that argument is total bunk. You
can pass an object reference by value, and use it to mutate the object
it refers to just fine. To test whether you're passing by reference
or by value, you need to instead assign a new value to the formal
parameter, and see whether that affects the actual parameter.
Cheers,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
will do, or even what sort of arguments are valid.
Answer: it's a copy of it. Assignments don't affect the actual
parameter at all. This is exactly what "call by value" means.
Best,
- Joe
[1] http://www.python.org/doc/2.5.2/ext/refcounts.html
[2] http://www.strout.net/info/coding/valref/
--
http://mail.python.org/mailman/listinfo/python-list
Error: shape mismatch: objects cannot be broadcast to a single shape
This is supposed to be doing a matrix multply of an (m,n)(n,1). This results in
an (m,1). This should then be able to be added to the 2*rand(m,1), but, its not
for some reason.
Ideas?
s "pass by
object" means nothing (until you explain that it means the former).
However, if you really think the term is that handy, and we want to
agree to say "Python uses pass by object" and answer the inevitable
"huh?" question with "that's shorthand for object references passed by
value," then I'd be OK with that.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
r own model is valid but there is a better one which is
easier to grasp for people without a background in C/C++ - like
languages.
Well, if by C/C++-like languages, you mean also Java, VB.NET, and so
on, then maybe you're right -- perhaps my view is colored by my
experience with those. But alternatively, perhaps there are enough
Python users without experience in other OOP languages, that the
standard terminology was unfamiliar to them, and they made up their
own, resulting in the current linguistic mess.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
Val" (default) mode in RB and VB.NET
6. My own experience implementing the RB compiler (not that
implementation details matter, but it forced me to think very
carefully about references and parameter passing for a very long time)
Not that I'm trying to argue from authority; I'm trying
.
I wonder if that could be tested systematically. Perhaps we could
round up 20 newbies, divide them into two groups of 10, give each one
a 1-page explanation either based on passing object references by-
value, or passing values sort-of-kind-of-by-reference, and then check
their comprehension by predicting the output of some code snippets.
That'd be very interesting. It's hard for me to believe that the
glossing-over-references approach really is easier for anybody, but
maybe I'm wrong.
I would even argue that your confusion supports this argument. Your
understanding of Python is perfectly adequate, so get with the program
for Pete's sake!
In my case, my understanding of Python became clear only once I
stopped listening to all the confusing descriptions here, and realized
that Python is no different from other OOP languages I already knew.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
hon
assignment is different, since it clearly doesn't copy the value.
Well, I can't vouch for all of them. But I can vouch for quite a few.
But here you go again: you're forced to claim that Python's parameter
passing is different, AND its assignment is different, with t
-page explanation either based on passing object references
by-value, or passing values sort-of-kind-of-by-reference, and then
check their comprehension by predicting the output of some code
snippets. That'd be very interesting.
Except for your garbling of the alternative to your version, I agree.
I suspect that different people might do better with different
explanations, depending on background.
Could be.
Maybe we could run such an experiment at PyCon, pulling in non-
attendees from the hallway and getting them to take the test in
exchange for a free donut or coffee.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
users of other languages, this is the same semantics used for objects
in Java, RB/VB.NET, and C++ when dealing with objects."
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
rtainly is sufficient.
Having ANY references to it is both necessary and sufficient to
exist. And isn't that the easiest way to say it?
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 8, 2008, at 2:38 PM, Terry Reedy wrote:
So if you then insist that Python uses "call by object",
you're actually saying it uses call by value!
Both Joe and you seem to be engaging in the following bit of
sophistry:
"In order for code A to call code B, some
Is there any Python-based fish simulation project? I've tried
searching google and pypi, but no luck. No burning need, just seems
like it'd be fun.
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
erence;
changing the object and changing the object reference are two
different things.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 10, 2008, at 2:30 PM, Aaron Brady wrote:
I agree with Terry that all calling is call-by-value, and Steven that
all calling is call-by-bit-flipping. I agree with Joe that call-by-
object is a special case of call-by-value.
Woo! Almost sounds like approaching consensus. :)
However
ce to some shared list instance, such as
one defined as a default argument to your __init__ method.
HTH,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
e to its own module, but I haven't been able to find it. Can
someone share a clue?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
Some corrections, to highlight the depth of my confusion...
On Nov 11, 2008, at 9:10 PM, Joe Strout wrote:
doctest.testmod(mymodule)
This actually works fine if I'm importing the module (with the
standard name) somewhere else
Actually, it does not.
I noticed that a fun
le, under pdb) I can import
the module and then run themodule._test().
To whom should I make the suggestion that this go into doctest docs?
Cheers,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
ified
class, and make sure that the given object has corresponding callable
attributes.
For case 2, we might be able to cache the result so that we don't do
all that work again the next time the same type comparison is done.
Anyway, I'll evolve something in our shop here and live
o our practices ASAP.
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
fy that whatever object I have, it has
the same public (non-underscore) methods as the class I'm claiming.)
Are there any standard methods or idioms for doing that?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
y and efficiently
handle the common cases, while still being able to handle the uncommon
ones.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
if len(obj) > 0:
s = obj[0]
if s[0] != s:
return False
return True
Thanks for this, too; that's the sort of method I had in mind. That
last test for string-likeness is particularly clever. I'll need to
think more deeply about the implications.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
I have to remember
to change those references too. But then, if I renamed a function,
I'd have to change all the callers anyway. So maybe this is better.
What do y'all think?
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
of their email: "Helpful-Answer" for helpful answers, and "Unhelpful-
Preaching" for the other kind. Then those of us not interested in one
sort or the other could set up an email filter.
Best,
- Joe
P.S. I'm sorry, Chris, I don't mean to rip your head off in
particula
ftware professionally for decades,
and may have a better idea than anybody else what their needs are.
Hypothetically speaking, is it possible that there could be any
language feature Python doesn't have, which might be useful to anyone
in any situation? If so, how would you recogniz
iable isn't THAT ugly. But it's nice to have some
options.
At any rate, you (and rurpy) have taken the time to consider the
question I was actually asking, instead of arguing with me whether I
should be asking it. I really appreciate that. Your suggestions are
helpful and have taught me some new Python tricks. Thanks very much!
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
might say "don't eat omelets;
pancakes are much tastier, you should eat them instead." But that
doesn't tell you how to cook an omelet, does it?
I hope mine was more palatable to you.
Yours was tasty indeed, thanks very much!
Cheers,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
t is clear to the
reader, as well as enforced by the interpreter.
Neat stuff, thank you!
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
e references too. But then, if I renamed a function, I'd have to
change all the callers anyway. So maybe this is better. What do
y'all
think?
I've used this myself, but to me it feels more icky than the semi-
private
argument trick above.
Thanks for the feedback.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
uld
return such a thing sometimes).
So, in this case, the simplest solution was to have the method that
initially accepts and stores the data check to make sure that data
satisfies the assumptions of the class.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
e(intlike
which asserts that foo is something dictionary-like that maps string-
like things to something like a sequence of integer-like things. Most
cases would not be this complex, of course, but would be closer to
assert(fits(foo, strlike))
But this is still pretty ugly. Hmm. Maybe I'd better wait for
ABCs. :)
Cheers,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 14, 2008, at 4:33 PM, Jerry Hill wrote:
Then add
def __init__(self):
a = 0
b = 0
to your box class to make a and b instance variables.
Doesn't that have to be "self.a" and "self.b"?
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
?
Well, here's a thought: create a zip file (using the standard zipfile
module), and pickle your data into that.
HTH,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
f the box
(i.e., no need to install anything extra). It doesn't do the task you
describe, but it does demonstrate animation and interaction with the
mouse, and would be easy to extend and adapt in the direction you want.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
Actually, contortions are required to make the standard definition of
"call by value" NOT be applicable to Python as well as all other
modern OOP languages [1].
Maybe we can discuss it further, and make this thread about the thread
longer than the thread it's about?
Cheers,
- Jo
the case where the value is an object reference (as is always
the case in Python)."
I assert that anyone who does not understand all of the above, is
helping to spread confusion.
I agree.
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
s that way where? Using what tool to view it?
My guess is that there is nothing wrong with the file, but that
whatever you're using to view it is simply displaying it as two lines
even though it is actually one.
HTH,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
er was a colon.)
Cheers,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
There are lots of ways to do that. Here's one:
>>> qfields = ['"' + fld.strip() + '"' for fld in (num,desc,date)]
>>> out = qfields.join(',')
>>> out
'"40922003","Life Fitness Products $1 ","12-13-08"'
Cheers,
- Joe
P.S. Pay no attention to the grumpy graybeards who want to drive new
users away from Python. There are quite a few friendly and helpful
people here, too. :)
--
http://mail.python.org/mailman/listinfo/python-list
up:
<http://www.strout.net/info/coding/valref/>
I wrote this to help people in exactly your situation, so please do
give me feedback and let me know how it did or didn't help.
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 21, 2008, at 9:00 AM, Steve Holden wrote:
Joe Strout wrote:
On Nov 21, 2008, at 2:08 AM, Steven D'Aprano wrote:
a, b = line.split()
Note that in a case like this, you may want to consider using
partition
instead of split:
a, sep, b = line.partition(' ')
Thi
will
automatically "close" itself when it dies (and since a closed object
in those cases is useless, I'd rather not have it around after it's
closed anyway). Is the same true in Python, or do we need to
explicitly close things?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
that the file
will be closed as soon as it loses its last reference, but I see that
we shouldn't count on that in the Python world.)
Best,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
ch mixins might be used and
in what combination. So I'd like to take a list of class references,
and instantiate an object that derives from all of them, dynamically.
Is this possible? If so, how?
Thanks,
- Joe
--
http://mail.python.org/mailman/listinfo/python-list
.5.2/ref/objects.html#l2h-21>, and that
speaks only about the traditional use of type() to check the type of
an object.
help(type) does mention the form you show, though it doesn't explain
what the dict is for.
Where would I find documentation on this nifty function?
Thanks,
401 - 500 of 584 matches
Mail list logo